/* Inbraakhotspots Nederland — opmaak. Mobile-first; vanaf 768px zijpaneel links. */
:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #1b1f27;
  --muted: #5b6372;
  --line: #e2e6ee;
  --accent: #256abf;
  --accent-ink: #ffffff;
  --chip: #eef2f8;
  --focus: #256abf;
  --sel: #0b1220;          /* rand van het geselecteerde vlak */
  --edge: #ffffff;         /* dunne rand tussen vlakken */
  --bar: #2a78d6;          /* staven in de grafiek */
  --shadow: 0 6px 24px rgba(15, 23, 42, .14);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f172a;
    --panel: #161f33;
    --ink: #e8edf5;
    --muted: #9aa5b8;
    --line: #2a3650;
    --accent: #5598e7;
    --accent-ink: #0b1220;
    --chip: #1f2a44;
    --focus: #8fc0ff;
    --sel: #f8fafc;
    --edge: #0f172a;
    --bar: #5598e7;
    --shadow: 0 6px 24px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
  .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.82) contrast(.88); }
  .leaflet-container { background: #0b1220; }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.45; color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

#app { display: flex; flex-direction: column; height: 100dvh; height: 100vh; height: 100dvh; }

/* Kaart */
.map-wrap { position: relative; flex: 1 1 auto; min-height: 0; }
#map { position: absolute; inset: 0; z-index: 0; }
.leaflet-container { font: inherit; }
.leaflet-container .leaflet-control-attribution { font-size: 10px; background: color-mix(in srgb, var(--panel) 85%, transparent); color: var(--muted); }
.leaflet-container .leaflet-control-attribution a { color: var(--muted); }
.leaflet-tooltip { background: var(--panel); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow); font-size: 13px; }
.leaflet-tooltip-top:before { border-top-color: var(--line); }
.leaflet-bar a { background: var(--panel); color: var(--ink); border-bottom-color: var(--line); }
.leaflet-bar a:hover { background: var(--chip); }
.tip-name { font-weight: 600; display: block; }

.legend {
  position: absolute; left: 10px; bottom: 22px; z-index: 500;
  background: color-mix(in srgb, var(--panel) 92%, transparent); color: var(--ink);
  border-radius: 10px; padding: 8px 10px; box-shadow: var(--shadow); font-size: 12px; max-width: 220px;
}
.legend-title { font-weight: 600; }
.legend-sub { color: var(--muted); margin-bottom: 4px; }
.legend-list { list-style: none; margin: 0; padding: 0; }
.legend-list li { display: flex; align-items: center; gap: 7px; line-height: 1.5; }
.legend-list .sw { width: 18px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.08); flex: none; }
.legend-opacity { display: block; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.legend-opacity span { display: flex; justify-content: space-between; color: var(--muted); }
.legend-opacity output { font-variant-numeric: tabular-nums; color: var(--ink); }
.legend-opacity input { display: block; width: 100%; margin: 4px 0 0; accent-color: var(--accent); cursor: pointer; }
body.panel-expanded .legend { display: none; }
@media (max-width: 767.98px) { .hot-toggle { margin-top: 6px; } .hot-toggle small { display: none; } .status { top: calc(62px + env(safe-area-inset-top)); } .toast { top: calc(62px + env(safe-area-inset-top)); } }

.status {
  position: absolute; top: 10px; right: 10px; z-index: 600; font-size: 12px;
  background: color-mix(in srgb, var(--panel) 92%, transparent); color: var(--ink);
  border-radius: 999px; padding: 5px 10px 5px 8px; box-shadow: var(--shadow); display: flex; gap: 6px; align-items: center;
}
.toast {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 700; max-width: min(92%, 420px);
  background: var(--ink); color: var(--bg); padding: 9px 14px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow);
}
.loading { position: absolute; inset: 0; z-index: 800; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent); }
.loading-box { background: var(--panel); color: var(--ink); padding: 14px 18px; border-radius: 12px; box-shadow: var(--shadow); display: flex; gap: 10px; align-items: center; max-width: 90%; font-size: 14px; }
.loading.error .spinner { display: none; }
.spinner { width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Paneel */
.panel {
  position: relative; z-index: 2; flex: none; background: var(--panel); color: var(--ink);
  display: flex; flex-direction: column; box-shadow: 0 -4px 20px rgba(15, 23, 42, .12);
  max-height: 72dvh; max-height: 72vh; max-height: 72dvh;
  padding-bottom: env(safe-area-inset-bottom);
  border-radius: 16px 16px 0 0;
}
.grip { display: block; width: 100%; background: none; border: 0; padding: 10px 0 4px; cursor: pointer; }
.grip-bar { display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto; }
.panel-head { display: none; padding: 16px 16px 0; }
.panel-head h1 { font-size: 20px; }
.panel-head .sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

/* Zoeken */
.search { position: fixed; top: calc(8px + env(safe-area-inset-top)); left: 10px; right: 10px; z-index: 1100; }
.search-row { display: flex; gap: 6px; }
#q {
  flex: 1 1 auto; min-width: 0; font-size: 16px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); box-shadow: var(--shadow); appearance: none; -webkit-appearance: none;
}
#q::placeholder { color: var(--muted); }
.icon-btn {
  flex: none; width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow);
}
.icon-btn:hover { background: var(--chip); }
.suggest {
  list-style: none; margin: 4px 0 0; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); max-height: 50vh; overflow: auto;
}
.suggest li { padding: 8px 10px; border-radius: 7px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--chip); }
.suggest .kind { color: var(--muted); font-size: 12px; flex: none; }

/* Laagkeuze */
.layers { padding: 4px 16px 0; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin: 0; gap: 3px; background: var(--chip); }
.seg label { flex: 1; position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.seg span { display: block; text-align: center; padding: 7px 4px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; color: var(--muted); }
.seg input:checked + span { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }
.layer-desc { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); display: none; }

.hot-toggle { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; margin: 8px 0 0; cursor: pointer; font-size: 14px; }
.hot-toggle input { margin: 0; width: 18px; height: 18px; accent-color: #e11d48; grid-row: 1 / span 2; }
.hot-toggle small { display: block; color: var(--muted); font-size: 12px; }
.legend-hot { display: flex; align-items: center; gap: 7px; margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--line); flex-wrap: wrap; cursor: pointer; }
.legend-hot input { margin: 0; width: 16px; height: 16px; accent-color: #e11d48; flex: none; }
.legend-hot .sw { width: 18px; height: 12px; border-radius: 3px; border: 2px solid #e11d48; flex: none; }
.legend-hot .hint { flex-basis: 100%; color: var(--muted); }

/* Samenvattingsregel (alleen smartphone) */
.summary {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; background: none; border: 0; border-top: 1px solid var(--line);
  margin-top: 10px; padding: 12px 16px; text-align: left; cursor: pointer;
}
.summary-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary-text strong { font-weight: 600; }
.summary-action { flex: none; color: var(--accent); font-weight: 600; font-size: 14px; }

.panel-body { display: none; flex: 1 1 auto; min-height: 0; overflow: auto; padding: 0 16px 16px; overscroll-behavior: contain; }
.panel.expanded .panel-body { display: block; }
.panel.expanded .summary { border-bottom: 1px solid var(--line); }

/* Ranglijst */
.ranking h2, .detail h2 { font-size: 16px; margin: 14px 0 8px; }
.ranking-list { list-style: none; margin: 0; padding: 0; }
.ranking-list li { margin: 0 0 4px; }
.rank-btn {
  display: grid; grid-template-columns: 22px 1fr auto; grid-template-rows: auto auto; column-gap: 8px; align-items: center;
  width: 100%; background: none; border: 0; padding: 7px 6px; border-radius: 8px; text-align: left; cursor: pointer;
}
.rank-btn:hover { background: var(--chip); }
.rank-no { grid-row: 1 / span 2; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.rank-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-name small { font-weight: 400; color: var(--muted); }
.rank-val { grid-row: 1 / span 2; font-weight: 700; font-variant-numeric: tabular-nums; }
.rank-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.rank-bar { flex: 1; height: 6px; background: var(--chip); border-radius: 3px; overflow: hidden; }
.rank-bar span { display: block; height: 100%; border-radius: 3px; }

/* Detailpaneel */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-top: 14px; }
.detail-head h2 { margin: 0; font-size: 18px; }
.detail-kind { color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.close-btn { flex: none; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-size: 18px; line-height: 1; }
.close-btn:hover { background: var(--chip); }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 10px; }
.tile { background: var(--chip); border-radius: 10px; padding: 9px 10px; min-width: 0; }
.tile .lbl { font-size: 11.5px; color: var(--muted); display: block; }
.tile .val { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; display: block; }
.tile .chg { font-size: 11.5px; color: var(--muted); display: block; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rate-line { margin: 0 0 8px; }
.rate-line strong { font-size: 18px; }
.warn { margin: 0 0 8px; font-size: 13px; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, #f59e0b 16%, var(--panel)); }
.btn {
  display: inline-block; margin: 10px 0 0; padding: 9px 14px; border-radius: 10px; border: 0; background: var(--accent); color: var(--accent-ink);
  font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }
.detail .bt, .detail .ext { font-size: 13.5px; margin: 10px 0 0; }

/* Grafiek */
.chart { margin-top: 12px; }
.chart-cap { font-size: 13px; margin: 0 0 4px; min-height: 1.4em; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .bar { fill: var(--bar); }
.chart .bar-f { fill: none; stroke: var(--bar); stroke-width: 1; stroke-dasharray: 2 2; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .col.dim .bar, .chart .col.dim .bar-f { opacity: .3; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid { stroke: var(--line); stroke-dasharray: 2 3; }
.chart text { font-size: 10px; fill: var(--muted); }
.chart-leg { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 4px; }
.chart-leg span::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 5px; vertical-align: -1px; background: var(--bar); border-radius: 2px; }
.chart-leg .f::before { background: none; border: 1px dashed var(--bar); }
.detail details, .notes details { margin-top: 8px; font-size: 13.5px; }
.detail summary, .notes summary { cursor: pointer; color: var(--accent); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.tbl td { padding: 3px 4px; border-bottom: 1px solid var(--line); }
.tbl td:last-child { text-align: right; }

.notes { margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; }
.notes p { margin: 0 0 6px; }
.src { padding-left: 18px; margin: 6px 0; }
.src li { margin-bottom: 4px; }

/* Desktop en tablet */
@media (min-width: 768px) {
  #app { flex-direction: row; }
  .panel { order: 1; width: 320px; max-height: none; height: 100%; border-radius: 0; box-shadow: 2px 0 16px rgba(15, 23, 42, .08); padding-bottom: 0; }
  .map-wrap { order: 2; }
  .grip, .summary { display: none; }
  .panel-head { display: block; }
  .search { position: relative; top: auto; left: auto; right: auto; z-index: 20; padding: 12px 16px 0; }
  #q, .icon-btn { box-shadow: none; }
  .suggest { position: absolute; left: 16px; right: 16px; z-index: 30; }
  .layers { padding-top: 12px; }
  .layer-desc { display: block; }
  .panel-body { display: block; flex: 1 1 auto; min-height: 0; margin-top: 6px; }
  .legend { bottom: 24px; }
  body.panel-expanded .legend { display: block; }
}
@media (min-width: 1024px) {
  .panel { width: 416px; }
}
