/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --success: #0d9488;
    --danger: #dc2626;
    --warning: #f59e0b;
    --bg: #f5f5f5;
    --card: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

/* ===== Navbar ===== */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 56px;
    background: var(--primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.nav-brand {
    font-size: 18px;
    font-weight: 700;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 4px;
}

.nav-menu a {
    color: #fff;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
    transition: background 0.2s;
    display: block;
}

.nav-menu a:hover { background: rgba(255,255,255,0.15); }

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: 0.2s;
}

/* ===== Cards ===== */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 16px;
}

.card-header {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.summary-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 20px;
}

.summary-card .label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.summary-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.summary-card .value.danger { color: var(--danger); }
.summary-card .value.success { color: var(--success); }
.summary-card .value.warning { color: var(--warning); }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 14px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color 0.2s;
    background: #fff;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,115,232,0.12);
}

button:focus-visible, a:focus-visible, .btn:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.status-cell:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    text-decoration: none;
    text-align: center;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: rgba(26,115,232,0.06); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 8px; font-size: 12px; }

/* ===== Tables ===== */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

th {
    background: var(--bg);
    font-weight: 600;
    position: sticky;
    top: 0;
}

tr:hover { background: rgba(26,115,232,0.04); }

/* ===== Alerts ===== */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 12px;
}

.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }
.alert-info { background: #eff6ff; color: var(--primary); border: 1px solid #bfdbfe; }

/* ===== Login ===== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.login-card {
    background: var(--card);
    padding: 40px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
}

.login-card h1 { font-size: 24px; text-align: center; margin-bottom: 4px; }
.login-subtitle { text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }

.login-form label { display: block; margin-bottom: 16px; }
.login-form label span { display: block; font-weight: 600; margin-bottom: 4px; font-size: 14px; }
.login-form .btn { width: 100%; padding: 12px; font-size: 16px; margin-top: 8px; }

/* ===== Upload ===== */
.upload-area { margin-bottom: 20px; }

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    transition: border-color 0.2s, background 0.2s;
    cursor: pointer;
}

.upload-zone.dragover, .upload-zone:hover {
    border-color: var(--primary);
    background: rgba(26,115,232,0.04);
}

.upload-icon { font-size: 48px; margin-bottom: 12px; }
.upload-zone p { color: var(--text-muted); margin-bottom: 12px; }

.upload-file-info {
    display: block;
    padding: 10px 14px;
    background: var(--bg);
    border-radius: var(--radius);
    margin-top: 8px;
}

.file-item {
    padding: 3px 0;
    font-size: 13px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
.file-item:last-child { border-bottom: none; }

.file-result { padding: 3px 0; font-size: 13px; }
.file-result.success { color: var(--success); }
.file-result.error { color: var(--danger); }

.radio-group { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: 0.2s;
}

.radio-label:has(input:checked) {
    border-color: var(--primary);
    background: rgba(26,115,232,0.06);
}

.result-area { padding: 16px; border-radius: var(--radius); margin-top: 16px; }
.result-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: var(--success); }
.result-error { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); }

.upload-tips {
    margin-top: 32px;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius);
}

.upload-tips h3 { font-size: 14px; margin-bottom: 8px; }
.upload-tips ul { padding-left: 20px; font-size: 13px; color: var(--text-muted); }
.upload-tips li { margin-bottom: 4px; }

/* ===== Dashboard ===== */
.chart-container { width: 100%; height: 400px; margin-bottom: 16px; }

.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 16px;
}

.filter-bar .form-group { margin-bottom: 0; min-width: 140px; flex: 1; }

/* ===== Report Detail ===== */
.flag-section { margin-bottom: 24px; }

.flag-section h3 {
    font-size: 16px;
    padding: 8px 14px;
    border-radius: var(--radius) var(--radius) 0 0;
    margin: 0;
}

.flag-improve h3 { background: #f0fdf4; color: var(--success); }
.flag-decline h3 { background: #fef2f2; color: var(--danger); }
.flag-below h3 { background: #fffbeb; color: var(--warning); }

.flag-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.flag-tag.improve { background: #dcfce7; color: var(--success); }
.flag-tag.decline { background: #fee2e2; color: var(--danger); }
.flag-tag.below_baseline { background: #fef3c7; color: #92400e; }

/* ===== Page Header ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.page-header h1 { font-size: 22px; }

/* ===== Tabs ===== */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
    overflow-x: auto;
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: 0.2s;
    white-space: nowrap;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===== Checkbox group ===== */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 16px;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 0;
    white-space: nowrap;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .container { padding: 10px; }

    .nav-toggle { display: flex; }
    .nav-menu {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--primary);
        flex-direction: column;
        padding: 8px 0;
        box-shadow: 0 4px 6px rgba(0,0,0,0.15);
    }
    .nav-menu.show { display: flex; }
    .nav-menu a { padding: 12px 20px; border-radius: 0; }

    .login-card { padding: 24px; margin: 0 10px; }
    .summary-cards { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .summary-card { padding: 12px 14px; }
    .summary-card .value { font-size: 22px; }

    .chart-container { height: 280px; }
    .filter-bar { flex-direction: column; gap: 8px; }
    .filter-bar .form-group { min-width: 100%; }

    .page-header { flex-direction: column; align-items: flex-start; }
    .page-header h1 { font-size: 18px; }

    .upload-zone { padding: 24px 12px; }
    .upload-icon { font-size: 36px; }
    .radio-group { flex-direction: column; }

    table { font-size: 13px; }
    th, td { padding: 8px; }
}

@media (max-width: 480px) {
    .summary-cards { grid-template-columns: 1fr; }
    .summary-card .value { font-size: 20px; }
    .chart-container { height: 240px; }
    .nav-brand { font-size: 16px; }
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-overlay[hidden] { display: none; }

.modal {
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 440px;
    margin: 16px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 18px; }
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 4px;
}
.modal-body { padding: 20px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

/* ===== Pagination ===== */
.pagination { margin-top: 12px; display: flex; justify-content: center; align-items: center; gap: 8px; }

/* ===== Upload Status Table ===== */
.status-legend {
    display: flex;
    align-items: center;
    gap: 6px 20px;
    flex-wrap: wrap;
    font-size: 13px;
    margin-bottom: 12px;
    color: var(--text-muted);
}
.legend-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: 2px;
}

.status-table {
    width: 100%;
    max-width: 450px;
    border-collapse: collapse;
}

.status-table th {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px 2px 10px;
    font-weight: 600;
    background: none;
    border: none;
}

.status-table td {
    text-align: center;
    padding: 2px;
    border: none;
}

.status-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: transform 0.15s, box-shadow 0.15s;
}
.status-cell:hover { transform: scale(1.2); box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.status-cell.full { background: #0d9488; color: #fff; }
.status-cell.partial { background: #f59e0b; color: #fff; }
.status-cell.none { background: #e5e7eb; color: #9ca3af; }
.status-cell.today { box-shadow: 0 0 0 2px var(--primary); font-weight: 700; }
