/* ---1.CSS Variables(Common settings)--- */
:root {
    --output-color: #007bff;
    --file-color: #28a745;
    --reset-color: #e57373;
    --bg-light: #f8f9fa;
    --border-color: #ced4da;
    --text-color: #333;
    --border-radius: 4px;
}

/* ---2.Base Elements--- */
body { font-family: sans-serif; margin: 15px; color: var(--text-color); line-height: 1; }
label { font-weight: bold; margin: 2px; font-size: 0.9em; }
select,
input[type="datetime-local"],
input[type="date"],
input[type="text"].form-control {
    padding: 4px 6px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 0.9em;
    background-color: #ffffff;
    box-sizing: border-box;
}
select[multiple] { height: 120px; }
canvas { display: block; width: 100% !important; margin-bottom: 20px; }

/* ---3.Layout Components--- */
.flex-center { display: flex; align-items: center; gap: 10px; }
.font-normal { font-weight: normal !important; }
.bg-light-box {
    margin-top: 10px;
    background: var(--bg-light);
    padding: 10px;
    border-radius: var(--border-radius);
    border: 1px solid #ddd;
}

/* ---4.UI Components--- */
/* Login */
.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: #f9f9f9;
}
.login-form input {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    box-sizing: border-box;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

/* link */
.nav-container {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background-color: #343a40;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 4px;
}
.nav-link {
    color: #ffffff;
    text-decoration: none;
    padding: 4px 10px;
    margin-right: 10px;
    border-radius: 4px;
    display: inline-block;
}
.nav-link:hover { background-color: #495057; color: #fff; }
.nav-link.active { background-color: #007bff; font-weight: bold; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 7px 10px; font-size: 0.9em; font-weight: bold;
    border-radius: var(--border-radius); cursor: pointer;
    border: 1px solid transparent; transition: all 0.2s;
    box-sizing: border-box;
}
.btn-output { background: var(--output-color); color: white; }
.btn-output:hover { background: #0056b3; }
.btn-file { background: var(--file-color); color: white; }
.btn-file:hover { background: #218838; }
.btn-reset { background: var(--reset-color); color: white; }
.btn-reset:hover { background: #c62828;}
.btn-select { background: #ffffff; border-color: var(--border-color); color: #495057; }
.btn-select:hover { background: #e9ecef; }
.btn-login { background: var(--output-color); color: white; width: 100%; padding: 10px; }
.btn-login:hover { background: #0056b3; }
.page-top-btn {
    position: fixed; right: 20px; bottom: 20px;
    width: 60px; height: 60px;
    background-color: #333; color: #fff;
    border: none; border-radius: 50%;
    cursor: pointer; display: none; z-index: 9999;
    opacity: 0.5; transition: opacity 0.2s; font-weight: bold;
}
.page-top-btn:hover { opacity: 1.0; }

/* Button Group (Graph/Table Switch) */
.view-switch-group { margin: 10px 0; display: flex; gap: 2px; }
.btn-left { border-radius: 4px 0 0 4px !important; }
.btn-right { border-radius: 0 4px 4px 0 !important; }

/* Control Panel */
.control-panel {
    background: #f0f2f5; padding: 15px; border-radius: 8px;
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, max-content));
    gap: 10px; align-items: end;
}
.control-group { display: flex; flex-direction: column; }
.alert-info {
    margin-bottom: 15px; font-size: 0.85em; color: #d63384;
    background: #fff5f8; padding: 10px; border-radius: 4px;
    border: 1px dashed #ed5e93
}

/* ---5.Modal & Item Selection--- */
.modal-overlay {
    display: none; position: fixed; top: 0; left: 0;
    width: 100%; height: 100%; background: rgba(0,0,0,0.6);
    z-index: 9999; backdrop-filter: blur(2px);
}
.modal-content {
    background: white; width: 90%; max-width: 1000px;
    margin: 40px auto; padding: 20px; border-radius: 12px;
    height: 85vh; display: flex; flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 2px solid #f0f0f0; padding-bottom: 10px;
}
.form-control { 
    width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 6px;
    font-size: 1em; box-sizing: border-box;
}
.checkbox-grid {
    flex-grow: 1; overflow-y: auto; display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 2px 10px; padding: 10px; border: 1px solid #f0f0f0;
    background: #fafafa; border-radius: 8px;
}
.column-label {
    display: flex; align-items: center; padding: 8px;
    border: 1px solid #eee; border-radius: 4px;
    background: white; cursor: pointer; transition: background 0.2s;
}
.column-label:hover { background: #f0f7ff; }
.column-label input { margin-right: 10px; transform: scale(1.2); }
.column-label span { font-size: 14px; }
.y-axis-input { font-size: 13px !important; padding: 4px 6px !important; text-align: right; }
.y-axis-input::-webkit-outer-spin-button,
.y-axis-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.y-axis-input[type=number] { -moz-appearance: textfield; }
/* ---6.Data Display--- */
/* Graph Area */
.chart-container { width: 100%; margin-top: 20px; display: flex; flex-direction: column; }
.graph-controls { display: flex; justify-content: flex-end; gap: 10px; padding-bottom: 10px; flex-shrink: 0; }
.main-chart-wrapper { position: relative; width: 100%; height: 500px; }
.main-chart-wrapper[style*="display: none"] { height: 0 !important; }
#sub_charts_area { width: 100%; margin: 0 !important; padding: 0 !important;}

/* Table Area */
.table-wrapper { margin-top: 20px; overflow-x: auto ; max-height: 70vh; border: 1px solid #ddd; }
.data_table { width: 100%; border-collapse: collapse; font-size: 0.85em; }
.data_table th, .data_table td { border: 1px solid #ddd; padding: 8px; }
.data_table thead th { position: sticky; top: 0; background: #eee; z-index: 10; }
