* { box-sizing: border-box; }
:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --border: #e6ebf2;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #eef4ff;
}
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #f1f5f9; padding: 2px 6px; border-radius: 5px; font-size: 12px; color: #334155; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 236px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    flex-shrink: 0;
}
.brand-row { display: flex; align-items: center; gap: 10px; padding: 0 8px 6px; }
.brand-logo {
    width: 30px; height: 30px; border-radius: 8px;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}
.brand { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.site-badge {
    display: inline-block; margin: 4px 8px 14px; font-size: 12px; font-weight: 500;
    background: var(--primary-soft); color: var(--primary);
    padding: 3px 10px; border-radius: 999px;
}
.nav-group {
    margin: 18px 0 6px; padding: 0 10px;
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.04em; color: #94a3b8;
}
.nav-link {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 11px; border-radius: 8px;
    color: #475569; font-weight: 500; font-size: 13.5px; margin-bottom: 2px;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.78; }
.nav-link:hover { background: #f1f5f9; color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav-link.active svg { opacity: 1; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    padding: 13px 26px;
    display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; z-index: 10;
}
.page-heading { font-size: 16px; font-weight: 600; color: var(--text); }
.user-pill { display: flex; align-items: center; gap: 10px; }
.avatar-dot {
    width: 28px; height: 28px; border-radius: 999px;
    background: var(--primary-soft); color: var(--primary);
    font-weight: 700; font-size: 12px; display: inline-flex; align-items: center; justify-content: center;
}
.content { padding: 24px 26px; width: 100%; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 18px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.card-title { font-size: 15px; font-weight: 600; color: var(--text); margin: 0 0 14px; }
.card-header .card-title { margin: 0; }

.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 14px; }
.metric-box {
    background: #fcfdff; border: 1px solid var(--border);
    border-radius: 10px; padding: 15px 16px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.metric-box:hover { border-color: #cbd5e1; box-shadow: 0 3px 10px rgba(15, 23, 42, 0.04); }
.metric-top { display: flex; justify-content: space-between; align-items: center; }
.metric-label { font-size: 12px; font-weight: 500; color: var(--muted); }
.metric-chip { width: 26px; height: 26px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.chip-blue { background: #eff6ff; color: #2563eb; }
.chip-teal { background: #f0fdfa; color: #0d9488; }
.chip-indigo { background: #eef2ff; color: #4f46e5; }
.chip-amber { background: #fffbeb; color: #d97706; }
.chip-emerald { background: #ecfdf5; color: #059669; }
.chip-rose { background: #fff1f2; color: #e11d48; }
.metric-val { font-size: 24px; font-weight: 700; color: var(--text); margin: 8px 0 6px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.metric-sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.chart-wrap { width: 100%; overflow-x: auto; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); align-items: center; }
.legend-dot { width: 9px; height: 9px; border-radius: 999px; display: inline-block; margin-right: 5px; }

.filter-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filter-form label { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.filter-form input, .filter-form select, .form-row input, .form-row select {
    padding: 7px 11px; border: 1px solid #d5dce6; border-radius: 8px;
    font-size: 13px; background: #fff; color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.filter-form input:focus, .filter-form select:focus, .form-row input:focus, .form-row select:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.btn {
    padding: 7px 15px; border: 0; border-radius: 8px;
    background: var(--primary); color: #fff; cursor: pointer;
    font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center;
    transition: background 0.15s ease;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn-ghost { background: #fff; color: #334155; border: 1px solid #d5dce6; }
.btn-ghost:hover { background: #f8fafc; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge-blue { background: #eff6ff; color: #2563eb; }
.badge-green { background: #ecfdf5; color: #059669; }
.badge-amber { background: #fffbeb; color: #b45309; }
.badge-slate { background: #f1f5f9; color: #475569; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.data-table th, table.data-table td {
    padding: 10px 12px; border-bottom: 1px solid #eef2f6;
    text-align: right; white-space: nowrap;
}
table.data-table th:first-child, table.data-table td:first-child,
table.data-table th.left, table.data-table td.left { text-align: left; }
table.data-table th {
    background: #f8fafc; font-weight: 600; color: #475569;
    font-size: 12px; border-bottom: 1px solid var(--border);
}
table.data-table tbody tr:hover td { background: #f8fafc; }
table.data-table tr.summary-row td { background: #eff6ff; font-weight: 600; color: #1e3a8a; }
.table-wrap { overflow-x: auto; }

.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
    background: radial-gradient(circle at 20% 20%, #e0ecff 0%, #f6f8fb 45%, #eefaf6 100%);
}
.login-wrap {
    width: 100%; max-width: 390px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 14px; padding: 32px 28px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}
.form-row { margin-bottom: 15px; }
.form-row label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: #334155; }
.form-row input, .form-row select { width: 100%; padding: 9px 11px; }
.alert-err {
    background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
    padding: 10px 12px; border-radius: 8px; margin-bottom: 15px; font-size: 13px;
}
.alert-ok {
    background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0;
    padding: 10px 12px; border-radius: 8px; margin-bottom: 15px; font-size: 13px;
}
@media (max-width: 768px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; border-right: 0; border-bottom: 1px solid var(--border); }
    .content { padding: 16px; }
}

.combo { position: relative; display: inline-block; min-width: 190px; }
.form-row .combo { display: block; width: 100%; }
.combo-trigger {
    width: 100%; display: flex; align-items: center; gap: 6px;
    padding: 7px 10px; border: 1px solid #d5dce6; border-radius: 8px;
    background: #fff; color: var(--text); font-size: 13px; cursor: pointer; text-align: left;
}
.form-row .combo-trigger { padding: 9px 11px; }
.combo.open .combo-trigger { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.combo-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-clear {
    display: none; align-items: center; justify-content: center;
    width: 16px; height: 16px; border-radius: 999px; font-size: 13px; line-height: 1;
    color: #64748b; background: #f1f5f9;
}
.combo-clear:hover { background: #e2e8f0; color: var(--text); }
.combo-caret { font-size: 11px; color: #64748b; }
.combo-panel {
    display: none; position: absolute; left: 0; top: calc(100% + 4px);
    min-width: 100%; width: 260px; background: #fff;
    border: 1px solid var(--border); border-radius: 10px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.1); z-index: 50; padding: 8px;
}
.form-row .combo-panel { width: 100%; }
.combo.open .combo-panel { display: block; }
.combo-search {
    width: 100%; padding: 7px 10px; border: 1px solid #d5dce6; border-radius: 7px;
    font-size: 13px; margin-bottom: 6px;
}
.combo-search:focus { outline: none; border-color: var(--primary); }
.combo-list { max-height: 240px; overflow-y: auto; }
.combo-item { padding: 7px 9px; border-radius: 6px; font-size: 13px; cursor: pointer; color: var(--text); }
.combo-item:hover { background: #f1f5f9; }
.combo-item.selected { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.combo-empty { padding: 10px; text-align: center; font-size: 12.5px; color: var(--muted); }

.chart-stage { position: relative; width: 100%; height: 300px; }
.chart-stage canvas { display: block; width: 100%; height: 100%; }
.chart-tooltip {
    display: none; position: absolute; pointer-events: none; z-index: 20;
    background: rgba(15, 23, 42, 0.94); color: #f8fafc;
    padding: 9px 12px; border-radius: 8px; font-size: 12px; line-height: 1.6;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.2); white-space: nowrap;
}
.seg-tabs { display: inline-flex; background: #f1f5f9; padding: 3px; border-radius: 8px; gap: 2px; }
.seg-btn {
    border: 0; background: transparent; color: #475569; font-size: 12.5px; font-weight: 500;
    padding: 5px 11px; border-radius: 6px; cursor: pointer;
}
.seg-btn.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08); }
