:root {
  --surface: #fcfcfb; --raised: #ffffff; --ink: #0b0b0b; --ink-2: #52514e; --muted: #898781;
  --grid: #e1e0d9; --border: #e1e0d9; --accent-soft: #e8f0fb;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --peer: #c8c7c0; --up: #b3401f; --down: #1b7a55;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: #1a1a19; --raised: #222221; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --border: #34342f; --accent-soft: #1d2a3a;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --peer: #4a4a45; --up: #e8835f; --down: #4cc595;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --surface: #1a1a19; --raised: #222221; --ink: #f0efec; --ink-2: #c3c2b7; --muted: #898781;
  --grid: #2c2c2a; --border: #34342f; --accent-soft: #1d2a3a;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --peer: #4a4a45; --up: #e8835f; --down: #4cc595;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--surface); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--s1); }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
header.top { border-bottom: 1px solid var(--border); background: var(--raised); }
header.top .wrap { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.brand { font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; margin-right: auto; }
.brand small { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 6px; }
.search { position: relative; flex: 1 1 260px; max-width: 360px; }
.search input, select {
  width: 100%; font: inherit; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--ink);
}
select { width: auto; padding: 6px 10px; }
.results {
  position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin-top: 4px; list-style: none; padding: 4px;
  background: var(--raised); border: 1px solid var(--border); border-radius: 8px; max-height: 320px; overflow: auto;
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
}
.results li a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.results li a:hover, .results li a.on { background: var(--accent-soft); }
.results li small { color: var(--muted); }

h1 { font-size: 30px; line-height: 1.2; margin: 28px 0 4px; }
h2 { font-size: 21px; margin: 0 0 4px; }
.sub { color: var(--ink-2); margin: 0 0 16px; }
.muted { color: var(--muted); }
.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin: 12px 0 20px; color: var(--ink-2); font-size: 14px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 14px; border: 0; padding: 6px 12px; background: var(--raised); color: var(--ink-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }

.hero { font-size: 19px; color: var(--ink-2); margin: 8px 0 20px; max-width: 760px; }
.hero b { color: var(--ink); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 28px; }
.tile { background: var(--raised); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.tile .label { font-size: 14px; color: var(--ink-2); }
.tile .value { font-size: 30px; font-weight: 600; line-height: 1.2; margin: 4px 0; }
.tile .delta { font-size: 13px; color: var(--muted); }

section.card { background: var(--raised); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.takeaway { font-size: 17px; margin: 4px 0 12px; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 14px; color: var(--ink-2); margin: 8px 0; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 3px; border-radius: 2px; width: 16px; }
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--ink-2); font-size: 13px; }
.chart text.val { fill: var(--ink); font-weight: 600; }
.chart text.axis { fill: var(--muted); font-size: 12px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart .row:hover .hit { fill: var(--accent-soft); }
.note { font-size: 14px; color: var(--ink-2); border-left: 3px solid var(--grid); padding: 2px 0 2px 12px; margin: 14px 0 0; }
.tablelink { font: inherit; font-size: 14px; background: none; border: 0; color: var(--s1); cursor: pointer; padding: 0; margin-top: 10px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 10px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--grid); }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data tr.me td { font-weight: 600; }
.tip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--raised); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px; line-height: 1.4;
  box-shadow: 0 6px 20px rgba(0,0,0,.15); max-width: 280px; display: none;
}
.tip b { display: block; margin-bottom: 2px; }
.tip i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } h1 { font-size: 25px; } }
.picks { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 28px; }
.picks a { padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; text-decoration: none; color: var(--ink); background: var(--raised); }
footer { color: var(--muted); font-size: 13px; padding: 24px 0 40px; }
.flag { background: #fff4d6; color: #5c4200; border-radius: 8px; padding: 8px 12px; font-size: 14px; margin-bottom: 16px; }
:root[data-theme="dark"] .flag { background: #3a2f12; color: #f3dc9b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .flag { background: #3a2f12; color: #f3dc9b; } }
/* A halo in the card colour keeps value labels readable where a reference line crosses them. */
.chart text.val { paint-order: stroke; stroke: var(--raised); stroke-width: 4px; stroke-linejoin: round; }
h2.part { font-size: 24px; margin: 36px 0 4px; }
