:root {
  color-scheme: light;
  --surface-0: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --seq-100: #cde2fb; --seq-200: #9ec5f4; --seq-400: #3987e5; --seq-450: #2a78d6; --seq-600: #184f95;
  --div-pos: #2a78d6; --div-neg: #e34948; --div-mid: #f0efec;
  --status-good: #0ca30c; --status-good-bg: #e3f5e3;
  --status-warning: #fab219; --status-warning-bg: #fff4e0;
  --status-serious: #ec835a; --status-serious-bg: #fde7dd;
  --status-critical: #d03b3b; --status-critical-bg: #fbe4e4;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface-0: #0d0d0d; --surface-1: #1a1a19;
    --text-primary: #ffffff; --text-secondary: #c3c2b7; --text-muted: #898781;
    --grid: #2c2c2a; --baseline: #383835; --border: rgba(255, 255, 255, 0.1);
    --seq-100: #184f95; --seq-200: #1c5cab; --seq-400: #3987e5; --seq-450: #3987e5; --seq-600: #86b6ef;
    --div-pos: #3987e5; --div-neg: #e66767; --div-mid: #383835;
    --status-good-bg: rgba(12,163,12,0.16); --status-warning-bg: rgba(250,178,25,0.16);
    --status-serious-bg: rgba(236,131,90,0.16); --status-critical: #e66767; --status-critical-bg: rgba(230,103,103,0.16);
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--surface-0); color: var(--text-primary); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 28px clamp(16px, 4vw, 40px) 60px; }

.topnav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.topnav .brand { font-weight: 650; font-size: 15px; }

.banner {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 16px; font-size: 12.5px; color: var(--text-secondary); margin-bottom: 24px;
}
.banner strong { color: var(--text-primary); }

h1 { font-size: 24px; font-weight: 650; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 16px; font-weight: 640; margin: 0 0 4px; }
h3 { font-size: 13.5px; font-weight: 620; margin: 0 0 2px; }
p.sub { color: var(--text-secondary); font-size: 14px; max-width: 720px; line-height: 1.5; margin: 0 0 20px; }
.chart-note { font-size: 11.5px; color: var(--text-muted); margin-bottom: 12px; }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
section { margin-bottom: 34px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; }

.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 760px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
.stat-tile .label { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.stat-tile .value { font-size: 24px; font-weight: 650; }
.stat-tile .sub { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; }

.seg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .seg-grid { grid-template-columns: 1fr; } }

/* Bar charts */
.hbar-row { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 10px; margin-bottom: 6px; }
.hbar-row:last-child { margin-bottom: 0; }
.hbar-label { font-size: 12.5px; color: var(--text-secondary); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { position: relative; height: 22px; background: var(--grid); border-radius: 4px; }
.hbar-fill { position: absolute; left: 0; top: 0; height: 100%; background: var(--seq-450); border-radius: 4px 6px 6px 4px; }
.hbar-value { position: absolute; top: 50%; transform: translateY(-50%); font-size: 12px; font-weight: 600; color: var(--text-primary); white-space: nowrap; }

/* Vertical bars (hourly) */
.vbar-chart { display: flex; align-items: flex-end; gap: 3px; height: 140px; }
.vbar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.vbar { width: 100%; background: var(--seq-450); border-radius: 3px 3px 0 0; min-height: 2px; cursor: pointer; }
.vbar:hover { filter: brightness(1.1); }
.vbar-axis { display: flex; gap: 3px; margin-top: 6px; }
.vbar-axis span { flex: 1; text-align: center; font-size: 9.5px; color: var(--text-muted); }

/* Heatmap */
.heatmap-wrap { overflow-x: auto; }
.heatmap-grid { display: grid; grid-template-columns: 60px repeat(24, 1fr); gap: 2px; min-width: 720px; }
.heatmap-cell {
  aspect-ratio: 1; border-radius: 3px; cursor: pointer; position: relative;
}
.heatmap-rowlabel { font-size: 11px; color: var(--text-secondary); display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; }
.heatmap-collabel { font-size: 9px; color: var(--text-muted); text-align: center; }
.heatmap-legend { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 11.5px; color: var(--text-secondary); }
.heatmap-legend .ramp { width: 120px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--seq-100), var(--seq-600)); }

/* Correlation matrix */
.corr-grid { display: grid; gap: 2px; }
.corr-cell { aspect-ratio: 1; border-radius: 3px; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; cursor: pointer; }
.corr-label { font-size: 10.5px; color: var(--text-secondary); display: flex; align-items: center; }

/* Tables */
table.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data-table th, table.data-table td { text-align: left; padding: 8px 9px; border-bottom: 1px solid var(--grid); }
table.data-table th { color: var(--text-secondary); font-weight: 600; font-size: 11px; white-space: nowrap; cursor: pointer; }
table.data-table th:hover { color: var(--text-primary); }
table.data-table td.num, table.data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.sort-arrow { font-size: 9px; margin-left: 3px; color: var(--text-muted); }

.flag-pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 650; border-radius: 6px; padding: 2px 7px; }
.flag-pill.warn { color: var(--status-serious); background: var(--status-serious-bg); }
.flag-pill.crit { color: var(--status-critical); background: var(--status-critical-bg); }
.flag-pill.good { color: var(--status-good); background: var(--status-good-bg); }

/* Recommendations */
.rec-list { display: grid; gap: 10px; }
.rec-card { display: flex; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-0); }
.rec-card .cat { flex: none; font-size: 11px; font-weight: 700; color: var(--seq-450); text-transform: uppercase; letter-spacing: 0.02em; width: 130px; }
.rec-card .text { font-size: 13px; color: var(--text-primary); line-height: 1.5; }

/* Line chart */
.line-chart-wrap { position: relative; }
.line-tooltip {
  position: absolute; pointer-events: none; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font-size: 12px; box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  opacity: 0; transition: opacity .1s; white-space: nowrap; z-index: 5;
}

/* Model cards */
.model-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
@media (max-width: 700px) { .model-compare { grid-template-columns: 1fr; } }
.model-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.model-card.best { border-color: var(--seq-450); background: var(--surface-0); }
.model-card .name { font-size: 13px; font-weight: 650; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; }
.model-card .metric-row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-secondary); padding: 3px 0; }
.model-card .metric-row b { color: var(--text-primary); font-variant-numeric: tabular-nums; }

.calibration-note { background: var(--surface-0); border-left: 3px solid var(--seq-450); border-radius: 0 8px 8px 0; padding: 10px 14px; margin-top: 10px; font-size: 13px; color: var(--text-secondary); line-height: 1.55; }
.calibration-note b { color: var(--text-primary); }

.footer-note { font-size: 11.5px; color: var(--text-muted); margin-top: 40px; }
