.viz-root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --good-text: #006300;
  --bad-text: #b42828;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4;
  --up: #e34948; --down: #2a78d6; --total: #52514e;
  --neutral: #f0efec;
}
@media (prefers-color-scheme: dark) {
  .viz-root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --good-text: #0ca30c;
    --bad-text: #e66767;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
    --up: #e66767; --down: #3987e5; --total: #c3c2b7;
    --neutral: #383835;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--page); }
body { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.viz-root { min-height: 100vh; background: var(--page); color: var(--text-primary); font-size: 15px; line-height: 1.45; }
main { max-width: 1180px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px 40px; }
h1 { font-size: 26px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0 0 2px; }
.muted { color: var(--text-secondary); margin: 0 0 10px; font-size: 13.5px; }
.error { color: var(--bad-text); min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }

.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 8px 0 16px; flex-wrap: wrap; }
.top .muted { margin: 4px 0 0; }
.top-actions { display: flex; gap: 8px; }
.ghost { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); border-radius: 8px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; text-decoration: none; }
.ghost:hover { background: var(--neutral); color: var(--text-primary); }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 18px 18px 14px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.card { min-width: 0; }
.grid2 .card { margin-bottom: 16px; }
@media (max-width: 820px) { .grid2 { grid-template-columns: minmax(0, 1fr); gap: 0; } }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 820px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .tile .value { font-size: 24px; } .card { padding: 14px 12px 12px; } main { padding-left: 10px; padding-right: 10px; } }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; }
.tile .label { font-size: 13px; color: var(--text-secondary); }
.tile .value { font-size: 28px; font-weight: 650; margin: 2px 0; letter-spacing: -0.01em; }
.tile .sub { font-size: 12.5px; color: var(--text-secondary); }
.delta-bad { color: var(--bad-text); font-weight: 600; }
.delta-good { color: var(--good-text); font-weight: 600; }

.chart { position: relative; height: 300px; }
.chart.tall { height: 380px; }
@media (max-width: 600px) { .chart { height: 260px; } .chart.tall { height: 330px; } }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 6px 12px; font: inherit; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--neutral); color: var(--text-primary); font-weight: 600; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 10px; font-size: 13px; color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 2px; width: 16px; border-radius: 1px; }

details { margin-top: 10px; }
summary { cursor: pointer; color: var(--text-secondary); font-size: 13.5px; }
.table-wrap { overflow-x: auto; margin-top: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--text-secondary); font-weight: 600; }
td.heat { border-bottom: 2px solid var(--surface-1); border-left: 2px solid var(--surface-1); }
td.l, th.l { text-align: left; white-space: normal; }
tr.ended td { color: var(--muted); }
.chip { display: inline-block; background: var(--neutral); border-radius: 6px; padding: 1px 6px; margin: 1px 4px 1px 0; font-size: 12px; white-space: nowrap; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }

.insights { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; }
@media (max-width: 820px) { .insights { grid-template-columns: 1fr; } }
.insight { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.insight b { display: block; font-size: 14px; margin-bottom: 2px; }

.years { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.year { border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 13px; }
.year h3 { margin: 0 0 6px; font-size: 16px; display: flex; justify-content: space-between; align-items: baseline; }
.year h3 small { font-weight: 500; font-size: 12.5px; color: var(--text-secondary); }
.year .row { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; font-variant-numeric: tabular-nums; }
.year .sec { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--grid); }
.year .sec-title { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 2px; }

.method { margin: 6px 0 0; padding-left: 18px; color: var(--text-secondary); font-size: 13.5px; }
.method li { margin-bottom: 4px; }
footer { text-align: center; font-size: 12px; padding: 8px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { margin-bottom: 4px; }
.login-card label { display: block; font-size: 13px; color: var(--text-secondary); margin-top: 12px; }
.login-card input { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; font-size: 16px; border-radius: 9px; border: 1px solid var(--axis); background: var(--page); color: var(--text-primary); }
.login-card button { margin-top: 16px; width: 100%; padding: 11px; font: inherit; font-weight: 600; border: 0; border-radius: 9px; background: var(--s1); color: #fff; cursor: pointer; }
.loading { position: fixed; inset: 0; display: grid; place-items: center; color: var(--text-secondary); pointer-events: none; }
.loading[hidden] { display: none; }
