:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --up: #006300;
  --down: #d03b3b;
  --hover: rgba(42, 120, 214, 0.08);
  --sel: rgba(42, 120, 214, 0.14);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --up: #0ca30c;
    --down: #e66767;
    --hover: rgba(57, 135, 229, 0.10);
    --sel: rgba(57, 135, 229, 0.20);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --ring: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --up: #0ca30c;
  --down: #e66767;
  --hover: rgba(57, 135, 229, 0.10);
  --sel: rgba(57, 135, 229, 0.20);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.top, main, footer { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding-top: 24px; flex-wrap: wrap; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0; }
.minor { font-size: 12px; font-weight: 500; color: var(--ink-2); margin: 16px 0 4px; }
.sub, .hint, .asof { color: var(--ink-2); margin: 2px 0 0; font-size: 13px; }
.asof.stale { color: var(--down); }
main { display: grid; gap: 16px; padding-top: 16px; padding-bottom: 24px; }
footer { color: var(--muted); font-size: 12px; padding-bottom: 32px; }

.panel { background: var(--surface); border: 1px solid var(--ring); border-radius: 12px; padding: 16px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--ring); border-radius: 12px; padding: 14px 16px; }
.tile .label { color: var(--ink-2); font-size: 12px; }
.tile .value { font-size: 24px; font-weight: 600; margin-top: 2px; }
.tile .delta { font-size: 13px; margin-top: 2px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); }
th { font-size: 12px; font-weight: 600; color: var(--ink-2); cursor: pointer; user-select: none; }
th.l, td.l { text-align: left; }
th[aria-sort="ascending"]::after { content: " ▲"; font-size: 9px; }
th[aria-sort="descending"]::after { content: " ▼"; font-size: 9px; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--hover); }
tbody tr.sel { background: var(--sel); }
td .name { display: block; color: var(--muted); font-size: 11px; }
.up { color: var(--up); }
.down { color: var(--down); }
.flat, .na { color: var(--muted); }

.seg { display: inline-flex; border: 1px solid var(--ring); border-radius: 8px; overflow: hidden; }
.seg button { background: none; border: 0; color: var(--ink-2); font: inherit; font-size: 12px; padding: 6px 10px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--ring); }
.seg button.on { background: var(--sel); color: var(--ink); font-weight: 600; }
select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--ring); border-radius: 8px; padding: 6px 8px; }

.legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 14px; height: 2px; vertical-align: middle; margin-right: 6px; border-radius: 1px; }
.chart { position: relative; height: 280px; }
.chart.short { height: 110px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .bar { fill: var(--series-1); }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .label { font-size: 11px; font-weight: 600; fill: var(--ink-2); }

.tip { position: fixed; pointer-events: none; z-index: 10; background: var(--surface); color: var(--ink); border: 1px solid var(--ring); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.12); font-variant-numeric: tabular-nums; }
.tip b { display: block; margin-bottom: 2px; }
.tip .row { display: flex; gap: 12px; justify-content: space-between; }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 12px; }
.report-card { border: 1px solid var(--ring); border-radius: 10px; padding: 12px; }
.report-card h3 { font-size: 12px; color: var(--ink-2); margin: 0 0 6px; font-weight: 600; }
.report-card ol { margin: 0; padding-left: 18px; }
.report-card li { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.report-card .big { font-size: 20px; font-weight: 600; }
.empty { color: var(--muted); padding: 12px 0; }

@media (max-width: 560px) {
  .chart { height: 220px; }
  th, td { padding: 6px 8px; }
}
