:root {
  color-scheme: light;
  --page: #f9f9f7; --surface: #fcfcfb; --ink: #0b0b0b; --ink2: #52514e; --muted: #6f6d68;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11,11,11,.10);
  --accent: #2a78d6; --accent-ink: #1c5cab; --hl: #eb6834; --nodata: #e6e5df; --base: #efeee9; --stroke: #fcfcfb;
  --warn-bg: #fdf3e1; --warn-ink: #6b4a00;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --ink: #f0efec; --ink2: #c3c2b7; --muted: #9a988f;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,.10);
    --accent: #3987e5; --accent-ink: #86b6ef; --hl: #d95926; --nodata: #333331; --base: #232322; --stroke: #1a1a19;
    --warn-bg: #2e2513; --warn-ink: #f0d9a8;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
[hidden] { display: none !important; }
button, select, input { font: inherit; color: inherit; }
.top { display: flex; gap: 16px; justify-content: space-between; align-items: center; flex-wrap: wrap; padding: 20px 24px 10px; max-width: 1360px; margin: 0 auto; }
.brand h1 { font-size: 24px; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
.brand p { margin: 2px 0 0; color: var(--ink2); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.home { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--axis); border-radius: 8px; color: inherit; text-decoration: none; white-space: nowrap; }
.home:hover { background: var(--grid); }
.seg { display: inline-flex; border: 1px solid var(--axis); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 7px 16px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.tabs { display: flex; gap: 4px; padding: 0 24px; max-width: 1360px; margin: 0 auto; border-bottom: 1px solid var(--grid); overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 12px; cursor: pointer; color: var(--ink2); white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
main { max-width: 1360px; margin: 0 auto; padding: 16px 24px 48px; }
.controls { display: flex; flex-wrap: wrap; gap: 12px 20px; margin-bottom: 10px; }
.controls label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--ink2); min-width: 0; max-width: 100%; }
select, input[type=search] { background: var(--surface); border: 1px solid var(--axis); border-radius: 6px; padding: 6px 8px; max-width: 100%; }
.credit { padding: 14px 16px 22px; text-align: center; color: var(--ink2); font-size: 13px; }
.note { margin: 0 0 12px; padding: 8px 12px; background: var(--warn-bg); color: var(--warn-ink); border-radius: 6px; font-size: 14px; }
.note:empty { display: none; }
.note.small { margin: 8px 0 0; font-size: 13px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; min-width: 0; }
.tile b { display: block; font-size: 24px; font-weight: 600; line-height: 1.2; }
.tile span { color: var(--ink2); font-size: 13px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }
.map-wrap { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
#map { display: block; width: 100%; height: auto; max-height: 74vh; cursor: grab; touch-action: none; }
#map path.a { stroke: var(--stroke); stroke-width: .5; vector-effect: non-scaling-stroke; cursor: pointer; }
#map.us path.a { stroke-width: .2; }
.nd-bg { fill: var(--surface); }
.nd-ln { stroke: var(--axis); stroke-width: 2; }
.st-a { fill: var(--ink); }
#map path.base { fill: var(--surface); stroke: var(--axis); stroke-width: .6; vector-effect: non-scaling-stroke; }
#map path.ring { fill: none; stroke: var(--ink); stroke-width: 2; vector-effect: non-scaling-stroke; pointer-events: none; }
#map path.ring.hover { stroke-width: 1.25; }
.zoom { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 4px; }
.zoom button { width: 30px; height: 30px; background: var(--surface); border: 1px solid var(--axis); border-radius: 6px; cursor: pointer; line-height: 1; }
.map-stage { position: relative; }
.legend { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px 18px; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 12px; }
.legend .t { color: var(--ink2); width: 100%; }
.legend .row { display: flex; }
.legend .sw { width: 38px; }
.legend .sw i { display: block; height: 11px; margin-right: 1px; }
.legend .sw span { display: block; color: var(--ink2); font-variant-numeric: tabular-nums; margin-left: -8px; }
.legend .sw:first-child span { margin-left: 0; }
.legend .nd { display: flex; align-items: center; gap: 5px; color: var(--ink2); padding-bottom: 2px; }
.legend .nd i { width: 14px; height: 11px; border: 1px solid var(--axis); background: repeating-linear-gradient(45deg, var(--axis) 0 1.5px, transparent 1.5px 4px); }
.legend .fillkey i { background: radial-gradient(circle, var(--ink) 0 .7px, transparent 1px) 0 0 / 4px 4px, var(--grid); }
.side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.detail { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; min-height: 96px; }
.detail h3 { margin: 0; font-size: 17px; }
.detail .g { color: var(--ink2); font-size: 13px; }
.detail dl { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; margin: 8px 0 0; font-size: 14px; }
.detail dt { color: var(--ink2); }
.detail dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.detail .flag { margin: 8px 0 0; font-size: 13px; color: var(--warn-ink); }
.table-head { display: flex; gap: 8px; }
.table-head input { flex: 1; min-width: 0; }
.table-head button { background: var(--surface); border: 1px solid var(--axis); border-radius: 6px; padding: 6px 10px; cursor: pointer; white-space: nowrap; }
.table-wrap { max-height: 46vh; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { position: sticky; top: 0; background: var(--surface); text-align: left; font-weight: 600; padding: 6px 10px; border-bottom: 1px solid var(--axis); cursor: pointer; white-space: nowrap; }
td { padding: 4px 10px; border-bottom: 1px solid var(--grid); }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--grid); }
tbody tr.sel { background: var(--grid); font-weight: 600; }
tbody tr.filled td { color: var(--ink2); font-style: italic; }
.corr-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 14px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; min-width: 0; }
.card h2 { margin: 0; font-size: 16px; }
.sub { margin: 2px 0 8px; color: var(--ink2); font-size: 14px; }
svg text { fill: var(--ink2); font-size: 12px; }
.axis path, .axis line { stroke: var(--axis); }
.gridl line { stroke: var(--grid); }
.gridl path { display: none; }
.dotrow { cursor: pointer; }
.dotrow rect { fill: transparent; }
.dotrow:hover rect { fill: var(--grid); }
.dotrow.sel rect { fill: var(--grid); }
.dotrow.sel text { fill: var(--ink); font-weight: 600; }
.dotrow line { stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
.dotrow circle { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.pt { fill: var(--accent); fill-opacity: .55; stroke: var(--surface); stroke-width: 1; cursor: pointer; }
.pt.dim { fill: var(--axis); fill-opacity: .6; }
.pt.on { fill: var(--hl); fill-opacity: .95; }
.pt.sel { fill: var(--ink); fill-opacity: 1; }
.fit { stroke: var(--ink2); stroke-width: 2; fill: none; }
.lab { fill: var(--ink) !important; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
#tip { position: fixed; z-index: 10; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--axis); border-radius: 6px; padding: 6px 10px; font-size: 13px; box-shadow: 0 2px 8px rgba(0,0,0,.15); max-width: 260px; }
#tip b { display: block; }
#tip span { color: var(--ink2); }
.about { max-width: 780px; }
.about h2 { font-size: 18px; margin: 26px 0 6px; }
.about h2:first-child { margin-top: 6px; }
.about p, .about li { color: var(--ink2); }
.about strong { color: var(--ink); }
.about a { color: var(--accent-ink); }
.about table { margin: 8px 0; }
.about th { position: static; cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (max-width: 980px) {
  .map-grid, .corr-grid { grid-template-columns: minmax(0, 1fr); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .top, main { padding-left: 16px; padding-right: 16px; }
  .tabs { padding: 0 16px; }
  .controls label, .controls select { width: 100%; }
  .legend .sw { width: 34px; }
}
#rank.us { table-layout: fixed; width: 100%; }
#rank.us th:nth-child(2) { width: 112px; }
#rank.us th:nth-child(3) { width: 82px; }
#rank.us td:first-child { overflow-wrap: anywhere; }
#map circle.m { stroke: var(--ink); stroke-width: .75; vector-effect: non-scaling-stroke; cursor: pointer; }
#map circle.m.sel { stroke-width: 2.5; }
@media (max-width: 560px) { .top-actions { flex-wrap: wrap; } }
