/* Korterikaart — light + dark from the validated palette.
   Choropleth = sequential blue ramp (one hue, magnitude). On the light surface
   low values take the lightest step; on the dark surface the ramp is reversed
   so "near zero" still recedes toward the surface. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --hairline: #e1e0d9;
  --baseline: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.1);
  --series: #2a78d6;
  --series-soft: rgba(42, 120, 214, 0.12);
  --nodata: #f0efec;
  --tipbg: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --hairline: #2c2c2a;
    --baseline: #383835;
    --ring: rgba(255, 255, 255, 0.1);
    --series: #3987e5;
    --series-soft: rgba(57, 135, 229, 0.16);
    --nodata: #2c2c2a;
    --tipbg: #242423;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.45;
  min-height: 100svh;
}
.wrap { max-width: 680px; margin: 0 auto; padding: 20px 16px 40px; }

.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.brand { font-weight: 700; font-size: 18px; }
.lang {
  background: none; border: 1px solid var(--hairline); color: var(--ink-2);
  border-radius: 8px; padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer;
}
.lede { color: var(--ink-2); font-size: 15px; margin-bottom: 16px; max-width: 56ch; }

.card {
  background: var(--surface); border: 1px solid var(--ring);
  border-radius: 16px; padding: 16px; margin-top: 12px;
}

/* controls */
.controls { display: grid; gap: 10px; }
.yearbox { margin-top: 0; padding: 12px 16px 8px; }
.yearrow { display: flex; align-items: center; justify-content: center; gap: 18px; }
.yearval { font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 110px; text-align: center; }
.stepbtn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--hairline);
  background: none; color: var(--ink-2); font-size: 20px; cursor: pointer; line-height: 1;
}
.stepbtn:hover { border-color: var(--muted); }
.stepbtn:disabled { opacity: 0.35; cursor: default; }

input[type="range"] {
  width: 100%; margin-top: 8px; appearance: none; -webkit-appearance: none;
  height: 26px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--baseline); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--series); border: 3px solid var(--surface); margin-top: -10px;
  box-shadow: 0 0 0 1px var(--ring);
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--baseline); }
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%; background: var(--series);
  border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--ring);
}

.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tab {
  font: inherit; font-size: 14px; font-weight: 600; padding: 10px;
  border-radius: 12px; border: 1px solid var(--hairline);
  background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.tab.active { border-color: var(--series); color: var(--ink); background: var(--series-soft); }

/* map */
.mapcard { padding: 10px; }
#mapHolder svg { display: block; width: 100%; height: auto; }
.omav { stroke: var(--surface); stroke-width: 0.6; cursor: pointer; transition: filter 0.1s; }
.omav:hover { stroke: var(--ink); stroke-width: 1.2; }
.omav.sel { stroke: var(--ink); stroke-width: 1.6; }

.legend {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px;
  padding: 10px 8px 4px; font-size: 11px; color: var(--ink-2);
}
.leg-item { display: flex; align-items: center; gap: 4px; }
.leg-sw { width: 18px; height: 10px; border-radius: 3px; border: 1px solid var(--ring); }
.leg-cap { color: var(--muted); }

/* table view */
.listtitle { font-size: 14px; font-weight: 600; color: var(--ink-2); margin-bottom: 10px; }
.rows { list-style: none; display: grid; gap: 2px; }
.row {
  display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center;
  padding: 7px 8px; border-radius: 10px; cursor: pointer;
}
.row:hover { background: var(--series-soft); }
.row-rank { color: var(--muted); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.row-mid { min-width: 0; }
.row-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-track { display: block; height: 7px; border-radius: 0 4px 4px 0; background: var(--series); min-width: 3px; margin-top: 4px; }
.row-val { text-align: right; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.row-n { display: block; color: var(--muted); font-size: 11px; }

/* detail */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.detail-name { font-size: 20px; font-weight: 800; }
.detail-county { color: var(--muted); font-size: 12px; }
.closebtn {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--hairline);
  background: none; color: var(--muted); font-size: 17px; cursor: pointer; line-height: 1;
}
.sumgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sumval { font-size: 20px; font-weight: 800; }
.sumlab { color: var(--muted); font-size: 11px; }
.minichart { display: flex; gap: 3px; align-items: flex-end; height: 80px; margin-top: 14px; }
.mini-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 3px; cursor: pointer; }
.mini-fill { background: var(--series); border-radius: 3px 3px 0 0; min-height: 2px; }
.mini-fill.gap { background: var(--baseline); min-height: 2px; height: 2px !important; }
.mini-fill.cur { outline: 2px solid var(--ink); outline-offset: -1px; }
.mini-lab { color: var(--muted); font-size: 9px; text-align: center; }

.foot { margin-top: 22px; color: var(--muted); font-size: 12px; }
.foot a { color: var(--ink-2); }

.tip {
  position: fixed; z-index: 10; background: var(--tipbg); color: var(--ink);
  border: 1px solid var(--ring); border-radius: 10px; padding: 9px 11px;
  font-size: 12.5px; pointer-events: none; max-width: 260px; white-space: pre-line;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.tip b { font-variant-numeric: tabular-nums; }

@media (max-width: 460px) {
  .sumgrid { grid-template-columns: 1fr 1fr; }
  .yearval { font-size: 28px; }
}
