:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --page: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --muted: #898781;
  --hairline: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 0 clamp(12px, 2vw, 28px) 40px;
}

.bar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; padding: 18px 0 12px;
}
.brand h1 { font-size: 22px; margin: 0; letter-spacing: 0.2px; }
.brand p { margin: 2px 0 0; font-size: 13px; }
.bar-right { display: flex; align-items: center; gap: 12px; }
.field { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-secondary); }
select, button.ghost {
  font: inherit; font-size: 13px; color: var(--text-primary);
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 7px; padding: 6px 11px; cursor: pointer;
}
button.ghost:hover, select:hover { border-color: var(--axis); }

.controls {
  display: flex; gap: 18px; flex-wrap: wrap; align-items: center;
  padding: 10px 12px; margin-bottom: 12px;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
}
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button {
  font: inherit; font-size: 13px; padding: 6px 13px; cursor: pointer;
  background: transparent; color: var(--text-secondary);
  border: 1px solid transparent; border-radius: 7px;
}
.seg button:hover { background: var(--hairline); }
.seg button[aria-pressed="true"] {
  background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600;
}
.toggles { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--text-secondary); }
.toggles label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.toggles input { accent-color: var(--accent); }

main { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; align-items: start; }
@media (max-width: 900px) { main { grid-template-columns: minmax(0, 1fr); } }

.mapwrap { position: relative; }
.map-host {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; line-height: 0;
}
svg.map { display: block; width: 100%; height: auto; }
svg.map .region { cursor: pointer; }
svg.map .region:hover { filter: brightness(0.9) saturate(1.12); }

.tip {
  position: absolute; pointer-events: none; z-index: 5; max-width: 250px;
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.16);
  padding: 9px 11px; font-size: 13px; line-height: 1.4;
}
.tip b { display: block; font-size: 14px; margin-bottom: 3px; }
.tip .row { display: flex; justify-content: space-between; gap: 14px; color: var(--text-secondary); }
.tip .row span:last-child { color: var(--text-primary); font-variant-numeric: tabular-nums; }

.side {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 15px;
}
.side h2 { font-size: 14px; margin: 0 0 4px; letter-spacing: 0.3px; text-transform: uppercase; }
.muted { color: var(--text-secondary); }
.small { font-size: 12px; line-height: 1.45; }

.legend { list-style: none; margin: 10px 0 0; padding: 0; }
.legend li { margin: 0; }
.legend li.static { display: flex; align-items: center; gap: 9px; padding: 5px 6px; font-size: 13px; color: var(--text-secondary); }
.legend button {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  font: inherit; font-size: 13px; color: var(--text-primary);
  background: none; border: 0; border-radius: 6px; padding: 5px 6px; cursor: pointer;
}
.legend button:hover { background: var(--hairline); }
.legend button[aria-pressed="true"] { background: var(--hairline); font-weight: 600; }
.legend .sw { width: 15px; height: 15px; border-radius: 4px; flex: 0 0 auto; border: 1px solid var(--border); }
.legend .val { margin-left: auto; color: var(--text-secondary); font-variant-numeric: tabular-nums; font-size: 12px; }
.legend.ramp { display: flex; margin-top: 10px; }
.legend.ramp li { flex: 1; }
.legend.ramp .sw { width: 100%; height: 15px; border-radius: 0; border: 0; }
.legend.ramp li:first-child .sw { border-radius: 4px 0 0 4px; }
.legend.ramp li:last-child .sw { border-radius: 0 4px 4px 0; }
.rampscale { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-secondary); margin-top: 4px; font-variant-numeric: tabular-nums; }

.detail { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--hairline); font-size: 13px; }
.detail h3 { margin: 0 0 6px; font-size: 15px; }
.detail dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; }
.detail dt { color: var(--text-secondary); }
.detail dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.tablewrap { margin-top: 16px; }
#tableBox { margin-top: 10px; overflow-x: auto; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 11px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child, th:nth-child(2), td:nth-child(2) { text-align: left; }
thead th { position: sticky; top: 0; background: var(--surface-1); color: var(--text-secondary);
  font-weight: 600; border-bottom: 1px solid var(--axis); cursor: pointer; }
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--hairline) 45%, transparent); }
td { font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--hairline); }
td .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px;
  vertical-align: -1px; border: 1px solid var(--border); }

footer { margin-top: 22px; max-width: 720px; }
