/* ---------- Tokens ---------- */
:root {
  --bg: #FAFAF7;
  --bg-card: #FFFFFF;
  --bg-sunk: #F3F2EC;
  --ink: #1a1a17;
  --ink-strong: #0d0d0b;
  --ink-muted: #6B6760;
  --ink-faint: #9A958B;
  --line: rgba(26,26,23,0.10);
  --line-strong: rgba(26,26,23,0.18);
  --green: #1F6B43;
  --green-deep: #144d2f;
  --green-soft: #E3EFE7;
  --yellow: #D4A017;
  --yellow-soft: #FAF1D8;
  --gray: #B8B2A8;
  --gray-soft: #E8E5DD;
  --red: #B23A2A;
  --shadow-sm: 0 1px 2px rgba(26,26,23,0.06);
  --shadow-md: 0 4px 14px rgba(26,26,23,0.08), 0 1px 2px rgba(26,26,23,0.04);
  --radius: 6px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --h-top: 56px;
  --h-kpi: 132px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  height: 100%;
  overflow: hidden;
}
body {
  display: grid;
  grid-template-rows: var(--h-top) var(--h-kpi) 1fr;
  height: 100vh;
  /* Perforatie-hint: subtiele rasterpunten op de hele pagina */
  background-image:
    radial-gradient(circle at 1px 1px, rgba(26,26,23,0.045) 1px, transparent 1.4px);
  background-size: 16px 16px;
  background-position: 0 0;
}
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ---------- Topbar ---------- */
.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(260px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--line);
  z-index: 30;
  position: relative;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--ink-strong);
}
.brand-mark { width: 26px; height: 26px; }
.brand-name {
  font-weight: 700; font-size: 16px; letter-spacing: -0.01em;
}
.brand-tld { font-weight: 500; color: var(--ink-muted); }
.brand-tag {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-faint);
  padding-left: 10px; margin-left: 6px; border-left: 1px solid var(--line);
}

.data-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-muted);
  white-space: nowrap;
}
.meta-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(31,107,67,0.18);
}
.meta-value {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.meta-label { color: var(--ink-faint); }
.meta-sep { color: var(--ink-faint); }

.search {
  position: relative;
  justify-self: end;
  width: 100%;
  max-width: 360px;
}
.search input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 0 12px 0 36px;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--ink-faint); }
.search input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31,107,67,0.12);
  background: var(--bg-card);
}
.search-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--ink-faint);
  pointer-events: none;
}
.search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 320px;
  overflow-y: auto;
  z-index: 50;
}
.search-result {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.search-result:last-child { border-bottom: 0; }
.search-result:hover, .search-result.active { background: var(--bg-sunk); }
.search-result .sr-name { flex: 1; }
.search-result .sr-pct {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 12px; color: var(--ink-muted);
}
.search-result .sr-prov { font-size: 11px; color: var(--ink-faint); }

/* ---------- KPIs ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.kpi {
  background: var(--bg-card);
  padding: 16px 22px 14px;
  display: flex; flex-direction: column; justify-content: space-between;
  min-width: 0;
}
.kpi-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
}
.kpi-value {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 56px;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink-strong);
  display: flex; align-items: baseline; gap: 6px;
  margin-top: 6px;
}
.kpi-unit {
  font-size: 16px;
  font-weight: 500;
  color: var(--ink-muted);
  letter-spacing: 0;
}
.kpi-countdown { font-size: 44px; gap: 4px; }
.kpi-countdown .kpi-unit { margin-right: 8px; }
.kpi-foot {
  display: flex; align-items: center; gap: 10px;
  font-size: 11px; color: var(--ink-muted);
  margin-top: 8px;
}
.kpi-foot-note { font-size: 11px; color: var(--ink-faint); white-space: nowrap; }
.delta {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--green-soft);
  color: var(--green-deep);
}
.delta.up::before  { content: "▲ "; font-size: 9px; }
.delta.down { background: #F8E4DF; color: var(--red); }
.delta.down::before { content: "▼ "; font-size: 9px; }
.delta.flat { background: var(--gray-soft); color: var(--ink-muted); }
.delta.flat::before { content: "— "; }

.bar {
  flex: 1; height: 4px; background: var(--gray-soft);
  border-radius: 2px; overflow: hidden;
  min-width: 60px;
}
.bar-fill { height: 100%; transition: width .4s cubic-bezier(.2,.7,.2,1); }
.bar-fill-green  { background: var(--green); }
.bar-fill-yellow { background: var(--yellow); }
.bar-fill-time   { background: linear-gradient(90deg, var(--green) 0%, var(--yellow) 60%, var(--red) 100%); }

/* ---------- Main layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(340px, 3fr);
  min-height: 0;
  border-bottom: 1px solid var(--line);
}
.map-region {
  position: relative;
  min-height: 0;
  background: var(--bg-sunk);
  overflow: hidden;
  border-right: 1px solid var(--line);
}
#map {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 1px 1px, rgba(26,26,23,0.06) 1px, transparent 1.4px) 0 0 / 12px 12px,
    var(--bg-sunk);
}
.maplibregl-canvas { outline: none; }

.map-status {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  color: var(--ink-muted);
  background: var(--bg-card);
  border: 1px solid var(--line);
  padding: 8px 14px;
  border-radius: var(--radius);
  pointer-events: none;
  z-index: 5;
}
.map-status.error { color: var(--red); border-color: var(--red); }
.map-status.hidden { display: none; }

.map-overlay {
  position: absolute;
  background: var(--bg-card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 10;
}

/* Mode toggle */
.map-toggle {
  top: 14px; left: 14px;
  display: flex;
  padding: 3px;
  gap: 2px;
}
.seg {
  border: 0; background: transparent;
  font-size: 12px; font-weight: 500;
  padding: 6px 12px;
  border-radius: 4px;
  color: var(--ink-muted);
  letter-spacing: 0.01em;
}
.seg:hover { color: var(--ink); }
.seg.active {
  background: var(--ink-strong); color: var(--bg-card);
}

/* Legend */
.legend {
  top: 14px; right: 14px;
  padding: 10px 12px 8px;
  width: 220px;
}
.legend-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-weight: 500;
  margin-bottom: 6px;
}
.legend-bar {
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(90deg, #FAF1D8 0%, #ECD27A 30%, #B5C66D 55%, #5FA063 75%, #1F6B43 100%);
  margin-bottom: 4px;
}
.legend-scale {
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.legend-extra {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-muted);
}
.sw {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 2px;
}
.sw-gray { background: var(--gray); }
.sw-green { background: var(--green); }
.sw-yellow { background: var(--yellow); }

/* Tooltip */
.tooltip {
  pointer-events: none;
  padding: 10px 12px;
  min-width: 180px;
  font-size: 12px;
  z-index: 20;
}
.tt-name {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--ink-strong);
}
.tt-row {
  display: flex; justify-content: space-between;
  padding: 2px 0;
  color: var(--ink-muted);
}
.tt-row b {
  font-family: var(--mono); font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Leaderboard */
.leaderboard {
  bottom: 14px; right: 14px;
  width: 280px;
  max-height: calc(100% - 100px);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.lb-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px 8px 6px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-card);
}
.lb-toggle {
  width: 22px; height: 22px;
  border: 0; background: transparent;
  display: grid; place-items: center;
  color: var(--ink-muted);
  border-radius: 3px;
  transition: transform .2s;
}
.lb-toggle:hover { background: var(--bg-sunk); color: var(--ink); }
.lb-toggle svg { width: 12px; height: 12px; }
.leaderboard.collapsed .lb-toggle { transform: rotate(-90deg); }
.leaderboard.collapsed .lb-list { display: none; }
.lb-title {
  font-size: 12px; font-weight: 600;
  color: var(--ink-strong);
  letter-spacing: 0.02em;
  flex: 1;
}
.lb-tabs { display: flex; gap: 2px; }
.lb-tab {
  border: 0; background: transparent;
  font-size: 11px; color: var(--ink-muted);
  padding: 4px 8px; border-radius: 3px;
}
.lb-tab:hover { background: var(--bg-sunk); color: var(--ink); }
.lb-tab.active { background: var(--ink-strong); color: var(--bg-card); }
.lb-list {
  list-style: none; margin: 0; padding: 4px 0;
  overflow-y: auto;
  font-size: 12px;
  max-height: 320px;
}
.lb-row {
  display: grid;
  grid-template-columns: 22px 1fr 56px;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 10px;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.lb-row:hover { background: var(--bg-sunk); border-left-color: var(--green); }
.lb-row.selected { background: var(--green-soft); border-left-color: var(--green); }
.lb-rank {
  font-family: var(--mono); font-size: 11px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.lb-name { color: var(--ink); }
.lb-pct {
  font-family: var(--mono); font-size: 11px;
  color: var(--ink-strong);
  text-align: right;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; gap: 4px;
  justify-content: flex-end;
}
.lb-pct-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
}

/* ---------- Right panel ---------- */
.panel {
  background: var(--bg-card);
  overflow-y: auto;
  padding: 0;
  display: flex; flex-direction: column;
}
.panel-head {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0;
  background: var(--bg-card);
  z-index: 2;
}
.panel-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}
.panel-back {
  border: 0; background: transparent;
  color: var(--green);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  padding: 0;
  display: inline-flex; align-items: center; gap: 4px;
}
.panel-back:hover { text-decoration: underline; }
.panel-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 6px 0 0;
  color: var(--ink-strong);
}
.panel-subtitle {
  font-size: 13px;
  color: var(--ink-muted);
  margin-top: 2px;
}

.panel-body {
  padding: 18px 22px 22px;
  flex: 1;
  display: flex; flex-direction: column;
  gap: 18px;
}

.headline-stat {
  display: flex; align-items: baseline; gap: 10px;
}
.headline-stat .hs-value {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 48px;
  letter-spacing: -0.02em;
  color: var(--ink-strong);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.headline-stat .hs-unit {
  font-size: 14px; color: var(--ink-muted); font-weight: 500;
}
.headline-stat .hs-delta { margin-left: auto; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.stat-cell {
  background: var(--bg-card);
  padding: 10px 12px;
}
.stat-cell .sc-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-weight: 500;
}
.stat-cell .sc-value {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink-strong);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.stat-cell .sc-sub {
  font-size: 11px; color: var(--ink-faint);
  margin-top: 1px;
}

.section-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-weight: 600;
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.chart {
  height: 130px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 8px 6px 4px;
  position: relative;
}
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart-axis {
  font-family: var(--mono);
  font-size: 9px;
  fill: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}

/* Province bars (national view) */
.prov-list {
  display: flex; flex-direction: column;
  gap: 4px;
}
.prov-row {
  display: grid;
  grid-template-columns: 120px 1fr 48px;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  padding: 3px 0;
}
.prov-name { color: var(--ink); }
.prov-bar {
  height: 6px; background: var(--gray-soft);
  border-radius: 2px; overflow: hidden;
  position: relative;
}
.prov-bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: 2px;
}
.prov-pct {
  font-family: var(--mono); font-size: 11px;
  color: var(--ink-strong);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.punch-list {
  display: flex; flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.punch-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  padding: 8px 12px;
  align-items: center;
  font-size: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-card);
}
.punch-row:last-child { border-bottom: 0; }
.punch-idx {
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.punch-name { color: var(--ink); }
.punch-date {
  font-family: var(--mono); font-size: 11px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.dso-link {
  margin-top: auto;
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--green);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
}
.dso-link:hover { text-decoration: underline; }

.disclaimer {
  font-size: 11px;
  color: var(--ink-faint);
  line-height: 1.5;
  padding: 12px 14px;
  background: var(--bg-sunk);
  border-radius: var(--radius);
  border: 1px dashed var(--line-strong);
}

/* ---------- Timeline ---------- */
.timeline {
  background: var(--bg-card);
  padding: 10px 20px 12px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 4px;
  position: relative;
  z-index: 5;
}
.tl-head {
  display: flex; align-items: center; justify-content: space-between;
}
.tl-current {
  display: flex; align-items: baseline; gap: 8px;
}
.tl-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  font-weight: 500;
}
.tl-date {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-strong);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.tl-mode {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--green-soft);
  color: var(--green-deep);
  font-weight: 500;
}
.tl-mode[data-mode="projection"] { background: var(--yellow-soft); color: #8a6800; }
.tl-mode[data-mode="historical"] { background: var(--gray-soft); color: var(--ink-muted); }
.tl-controls { display: flex; gap: 6px; }
.tl-btn {
  border: 1px solid var(--line-strong);
  background: var(--bg-card);
  color: var(--ink);
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 4px;
  display: inline-flex; align-items: center; gap: 4px;
}
.tl-btn:hover { background: var(--bg-sunk); }
.tl-btn svg { width: 10px; height: 10px; }
.tl-btn.playing svg { display: none; }
.tl-btn.playing::before {
  content: ""; width: 8px; height: 10px;
  background: linear-gradient(to right, currentColor 38%, transparent 38%, transparent 62%, currentColor 62%);
}

.tl-track {
  position: relative;
  height: 24px;
  cursor: pointer;
  user-select: none;
}
.tl-rail {
  position: absolute;
  left: 0; right: 0; top: 50%;
  transform: translateY(-50%);
  height: 6px;
  background: var(--gray-soft);
  border-radius: 3px;
  overflow: visible;
}
.tl-rail-fill {
  position: absolute; top: 0; left: 0;
  height: 100%;
  background: linear-gradient(90deg, #ECD27A 0%, #B5C66D 50%, var(--green) 100%);
  border-radius: 3px;
}
.tl-rail-projection {
  position: absolute; top: 0;
  height: 100%;
  background: repeating-linear-gradient(
    45deg,
    var(--gray-soft) 0 4px,
    transparent 4px 8px
  );
  border-radius: 3px;
  opacity: 0.8;
}
.tl-ticks {
  position: absolute;
  left: 0; right: 0; top: 0; bottom: 0;
  pointer-events: none;
}
.tl-tick {
  position: absolute;
  top: 50%; transform: translate(-50%, -50%);
  width: 1px; height: 12px;
  background: rgba(26,26,23,0.12);
}
.tl-tick.major { height: 16px; background: rgba(26,26,23,0.25); }
.tl-marker {
  position: absolute;
  top: 50%; transform: translate(-50%, -50%);
  width: 2px; height: 18px;
  background: var(--ink-strong);
  pointer-events: none;
}
.tl-marker::after {
  content: attr(title);
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink-muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tl-marker-deadline { background: var(--red); }
.tl-marker-deadline::after { color: var(--red); }
.tl-handle {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 18px; height: 18px;
  background: var(--green);
  border: 2px solid var(--bg-card);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  padding: 0;
  z-index: 4;
}
.tl-handle:hover { transform: translate(-50%, -50%) scale(1.1); }
.tl-handle:active { cursor: grabbing; }

.tl-axis {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  padding: 0 2px;
}
.tl-axis span.deadline { color: var(--red); }
.tl-axis span.now { color: var(--ink-strong); font-weight: 600; }

/* ---------- Scrollbar styling ---------- */
.panel::-webkit-scrollbar,
.lb-list::-webkit-scrollbar,
.search-results::-webkit-scrollbar { width: 8px; }
.panel::-webkit-scrollbar-thumb,
.lb-list::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb {
  background: var(--gray-soft); border-radius: 4px;
}
.panel::-webkit-scrollbar-thumb:hover,
.lb-list::-webkit-scrollbar-thumb:hover {
  background: var(--gray);
}

/* ---------- Tiny utilities ---------- */
.kv {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12px; padding: 4px 0;
  border-bottom: 1px dashed var(--line);
}
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--ink-muted); }
.kv .v {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  color: var(--ink-strong);
}

/* mute MapLibre attribution */
.maplibregl-ctrl-attrib {
  font-size: 10px !important;
  background: rgba(255,255,255,0.85) !important;
}

@media (max-width: 1100px) {
  .kpi-value { font-size: 44px; }
  .kpi-countdown { font-size: 36px; }
  .brand-tag { display: none; }
}
