/* Kleuren: categoriaal palet uit de dataviz-richtlijnen, gevalideerd op kleurenblindheid in licht en donker. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --s1: #2a78d6;
  --s2: #eb6834;
  --warning: #fab219;
  --glow-1: rgba(42, 120, 214, 0.22);
  --glow-2: rgba(235, 104, 52, 0.16);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 12px 32px -14px rgba(11, 11, 11, 0.14);
  --radius: 20px;
  --pad: clamp(16px, 3vw, 28px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242422;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --s1: #3987e5;
    --s2: #d95926;
    --glow-1: rgba(57, 135, 229, 0.26);
    --glow-2: rgba(217, 89, 38, 0.18);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -18px rgba(0, 0, 0, 0.7);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #242422;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --s1: #3987e5;
  --s2: #d95926;
  --glow-1: rgba(57, 135, 229, 0.26);
  --glow-2: rgba(217, 89, 38, 0.18);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px -18px rgba(0, 0, 0, 0.7);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  transition: background-color 0.3s, color 0.3s;
}

h1, h2, h3, p { margin: 0; }
a { color: inherit; text-underline-offset: 3px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; border-radius: 6px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }

/* Kop */
.topbalk { display: flex; align-items: center; justify-content: space-between; padding-block: 18px; }
.merk { display: inline-flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -0.01em; text-decoration: none; }
.merk svg { width: 28px; height: 28px; }
.thema-knop {
  border: 1px solid var(--border); background: var(--surface); border-radius: 999px;
  padding: 6px 14px; font-size: 14px; font-weight: 550; cursor: pointer; color: var(--ink-2);
  transition: background-color 0.2s, color 0.2s;
}
.thema-knop:hover { color: var(--ink); background: var(--surface-2); }
.thema-knop span::before { content: "◐"; margin-right: 6px; }

/* Hero */
.hero { position: relative; isolation: isolate; padding: clamp(28px, 6vw, 64px) 0 clamp(28px, 5vw, 48px); }
.hero-gloed {
  position: absolute; z-index: -1; inset: -140px calc(50% - 50vw) auto; height: 560px; pointer-events: none;
  background:
    radial-gradient(38% 46% at 18% 42%, var(--glow-1), transparent 70%),
    radial-gradient(34% 42% at 82% 28%, var(--glow-2), transparent 70%);
  animation: drijf 16s ease-in-out infinite alternate;
}
@keyframes drijf {
  from { transform: translate3d(-3%, 0, 0) scale(1); }
  to { transform: translate3d(3%, 4%, 0) scale(1.1); }
}
.bovenregel { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.hero h1 {
  font-size: clamp(2.1rem, 5.4vw, 3.9rem); line-height: 1.04; letter-spacing: -0.035em;
  font-weight: 750; margin: 0.25em 0 0.4em; max-width: 15ch; text-wrap: balance;
}
.intro { font-size: clamp(1.05rem, 1.6vw, 1.25rem); color: var(--ink-2); max-width: 40ch; text-wrap: pretty; }
.intro strong { color: var(--ink); font-weight: 650; }
.hero-cijfer {
  margin-top: clamp(24px, 4vw, 40px); padding: clamp(20px, 3vw, 28px); max-width: 640px;
  border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 72%, transparent);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
}
.hero-label { color: var(--ink-2); max-width: 46ch; }
.hero-getal { font-size: clamp(2.8rem, 8.5vw, 5.2rem); font-weight: 750; letter-spacing: -0.045em; line-height: 1.02; margin: 0.12em 0; }

/* Filters */
.filters {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--page) 80%, transparent);
  backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-block: 1px solid var(--border);
}
.filters-binnen { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; padding-block: 12px; }
.segment, .keuze { display: inline-flex; align-items: center; gap: 10px; }
.segment-label { font-size: 13px; color: var(--ink-2); font-weight: 550; }
.segment-knoppen {
  display: inline-flex; padding: 3px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.segment-knoppen label { position: relative; }
.segment-knoppen input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segment-knoppen span {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 550; color: var(--ink-2); white-space: nowrap;
  transition: background-color 0.25s var(--ease), color 0.25s, box-shadow 0.25s;
}
.segment-knoppen input:checked + span {
  background: var(--surface); color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--border);
}
.segment-knoppen input:focus-visible + span { outline: 2px solid var(--s1); outline-offset: 1px; }
.keuze select {
  appearance: none; border: 1px solid var(--border); background-color: var(--surface);
  border-radius: 999px; padding: 7px 34px 7px 14px; font-size: 14px; font-weight: 550; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23898781' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; background-size: 11px;
  max-width: 220px;
}
.chip {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border);
  background: var(--ink); color: var(--page); border-radius: 999px; padding: 6px 12px;
  font-size: 13px; font-weight: 600; cursor: pointer; max-width: 100%;
  animation: pop 0.35s var(--ease);
}
.chip[hidden] { display: none; }
.chip #markering-naam { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 26ch; }
.chip-x { opacity: 0.7; }

/* Staaltjes en legende */
.staal { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.t-verzekering { fill: var(--s1); background-color: var(--s1); }
.t-fonds { fill: var(--s2); background-color: var(--s2); }
.legende { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; margin: 0; padding: 0; font-size: 13px; color: var(--ink-2); }
.legende li { display: inline-flex; align-items: center; gap: 7px; }
.legende-aantal { color: var(--muted); font-variant-numeric: tabular-nums; }

/* Inhoud */
.inhoud { display: flex; flex-direction: column; gap: 16px; padding-block: 20px 8px; }
.melding {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px;
  background: color-mix(in srgb, var(--warning) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warning) 45%, transparent);
  animation: pop 0.35s var(--ease);
}
.melding[hidden] { display: none; }
.melding-icoon {
  flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--warning); color: #0b0b0b; font-weight: 800; font-size: 14px;
}

.kerncijfers { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.kpi {
  padding: 18px 20px; border-radius: 16px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow); min-width: 0;
}
.kpi-label { font-size: 13px; color: var(--ink-2); font-weight: 550; }
.kpi-waarde { font-size: clamp(1.6rem, 3.2vw, 2.1rem); font-weight: 700; letter-spacing: -0.03em; margin: 4px 0 2px; }
.kpi-sub { font-size: 13px; color: var(--ink-2); text-wrap: pretty; }

.kaart {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--pad); box-shadow: var(--shadow); min-width: 0;
}
.kaart-kop { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 24px; margin-bottom: 18px; }
.kaart h2 { font-size: clamp(1.2rem, 2.2vw, 1.45rem); letter-spacing: -0.02em; font-weight: 700; }
.kaart-intro { color: var(--ink-2); font-size: 14.5px; margin-top: 4px; max-width: 62ch; }
.duo { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 920px) { .duo { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

/* Scroll-animatie zonder JavaScript; browsers zonder ondersteuning tonen alles meteen. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .verschijn { animation: verschijn linear both; animation-timeline: view(); animation-range: entry 0% entry 40%; }
  }
}
@keyframes verschijn { from { opacity: 0; transform: translateY(28px) scale(0.985); } }
@keyframes pop { from { opacity: 0; transform: scale(0.96); } }
@keyframes infaden { from { opacity: 0; } }

/* Grafieken */
.grafiek { position: relative; width: 100%; }
.grafiek-svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.lijn-raster { stroke: var(--grid); stroke-width: 1; }
.lijn-nul { stroke: var(--axis); stroke-width: 1; }
.lijn-mediaan { stroke: var(--ink-2); stroke-width: 1; }
.lijn-mediaan-zacht { stroke: var(--muted); stroke-width: 1; }
.tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.as-label { fill: var(--ink-2); font-size: 12px; font-weight: 600; }
.as-titel { fill: var(--ink-2); font-size: 12px; }
.kwadrant-vlak { fill: var(--ink); opacity: 0.045; }
.punt-label {
  fill: var(--ink); font-size: 12.5px; font-weight: 650; paint-order: stroke;
  stroke: var(--surface); stroke-width: 5px; stroke-linejoin: round; pointer-events: none;
  animation: infaden 0.4s 0.5s both;
}
.dot {
  stroke: var(--surface); stroke-width: 2;
  transition: transform 0.85s var(--ease), opacity 0.45s ease, r 0.25s var(--ease);
}
.dot.is-hover { stroke: var(--ink); }
.dot.is-gemarkeerd { stroke: var(--ink); stroke-width: 2.5; }
.heeft-markering .dot:not(.is-gemarkeerd):not(.is-hover) { opacity: 0.5; }

/* Top-lijst */
.top { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.balk-rij {
  width: 100%; display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) auto;
  grid-template-areas: "nr tekst waarde" "nr spoor spoor"; gap: 2px 12px; align-items: center;
  padding: 9px 10px; border: 0; border-radius: 12px; background: none; text-align: left; cursor: pointer;
  transition: background-color 0.2s;
}
.balk-rij:hover, .balk-rij.is-gemarkeerd { background: var(--surface-2); }
.balk-nr { grid-area: nr; align-self: start; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 1px; }
.balk-tekst { grid-area: tekst; min-width: 0; }
.balk-naam { display: block; font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.balk-sub { display: block; font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.balk-waarde { grid-area: waarde; text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; font-size: 14.5px; }
.balk-waarde small { display: block; font-weight: 500; font-size: 12.5px; color: var(--ink-2); }
.balk-spoor { grid-area: spoor; height: 8px; margin-top: 6px; }
.balk { display: block; height: 100%; width: 0; border-radius: 0 4px 4px 0; transition: width 0.9s var(--ease); }
.top .leeg, .mlijst .leeg { color: var(--ink-2); font-size: 14px; padding: 12px 0; }

/* Per maatschappij */
.mlijst { display: flex; flex-direction: column; }
.m-rij {
  display: grid; grid-template-columns: minmax(90px, 9.5rem) minmax(0, 1fr) 3.4rem; gap: 12px; align-items: center;
  width: 100%; padding: 7px 8px; border: 0; border-radius: 10px; background: none; text-align: left; cursor: pointer;
  transition: background-color 0.2s;
}
.m-rij:hover, .m-rij[aria-pressed="true"] { background: var(--surface-2); }
.m-naam { font-size: 13.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-spoor { position: relative; height: 20px; }
.m-nul { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--axis); }
.m-bereik { position: absolute; top: 50%; height: 2px; transform: translateY(-50%); background: var(--axis); border-radius: 2px; }
.m-dot {
  position: absolute; top: 50%; width: 8px; height: 8px; border-radius: 50%;
  transform: translate(-50%, -50%); box-shadow: 0 0 0 1.5px var(--surface);
  animation: pop 0.5s var(--ease) both;
}
.m-dot.is-gemarkeerd { width: 12px; height: 12px; box-shadow: 0 0 0 2px var(--ink); z-index: 1; }
.m-mediaan { position: absolute; top: 1px; bottom: 1px; width: 3px; border-radius: 2px; background: var(--ink); transform: translateX(-50%); z-index: 2; }
.m-waarde { text-align: right; font-size: 13.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.m-as { display: grid; grid-template-columns: minmax(90px, 9.5rem) minmax(0, 1fr) 3.4rem; gap: 12px; padding: 6px 8px 0; }
.m-as-ticks { position: relative; height: 16px; }
.m-as-ticks span { position: absolute; transform: translateX(-50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.m-as-ticks .is-begin { transform: none; }
.m-as-ticks .is-eind { transform: translateX(-100%); }
.m-as-label { font-size: 11px; color: var(--muted); text-align: right; }

/* Tabel */
.zoek input {
  width: min(320px, 100%); border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 999px; padding: 9px 16px; font-size: 14px; transition: border-color 0.2s, background-color 0.2s;
}
.zoek input:focus { outline: none; border-color: var(--s1); background: var(--surface); }
.zoek { flex: 0 1 320px; }
.tabel-wrap {
  overflow: auto; max-height: min(72vh, 760px); border: 1px solid var(--border); border-radius: 14px;
  overscroll-behavior: contain;
}
.tabel { width: 100%; min-width: 780px; border-collapse: collapse; font-size: 14px; }
.tabel th {
  position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left;
  font-weight: 600; font-size: 12.5px; color: var(--ink-2); border-bottom: 1px solid var(--border); padding: 0;
}
.tabel th button {
  width: 100%; border: 0; background: none; padding: 11px 12px; text-align: inherit; cursor: pointer;
  font-weight: inherit; color: inherit; white-space: nowrap;
}
.tabel th button:hover { color: var(--ink); }
.tabel th[aria-sort="descending"] button::after { content: " ↓"; }
.tabel th[aria-sort="ascending"] button::after { content: " ↑"; }
.tabel th[aria-sort="descending"], .tabel th[aria-sort="ascending"] { color: var(--ink); }
.tabel td { padding: 10px 12px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.tabel tbody tr { cursor: pointer; transition: background-color 0.15s; }
.tabel tbody tr:hover { background: var(--surface-2); }
.tabel tbody tr.is-gemarkeerd { background: color-mix(in srgb, var(--s1) 12%, var(--surface)); }
.tabel tbody tr:focus-visible { outline: 2px solid var(--s1); outline-offset: -2px; }
.tabel .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabel th.num { text-align: right; }
.tabel .is-periode { background: color-mix(in srgb, var(--s1) 6%, transparent); font-weight: 650; }
.tabel th.is-periode { background: color-mix(in srgb, var(--s1) 8%, var(--surface)); }
.cel-naam { min-width: 240px; }
.cel-titel { display: block; font-weight: 600; }
.cel-sub { display: block; font-size: 12.5px; color: var(--ink-2); }
.cel-type { white-space: nowrap; color: var(--ink-2); }
.cel-type .staal { margin-right: 7px; vertical-align: 0; }
.mini { display: block; height: 3px; margin: 5px 0 0 auto; border-radius: 2px; max-width: 100%; }
.mini.is-negatief { background-color: var(--muted); }

/* Uitleg en voet */
.uitleg { padding: clamp(8px, 2vw, 16px) 0 0; }
.uitleg h2 { font-size: clamp(1.2rem, 2.2vw, 1.45rem); letter-spacing: -0.02em; margin-bottom: 14px; }
.uitleg-raster { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.uitleg article { padding: 18px 20px; border-radius: 16px; border: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 60%, transparent); }
.uitleg h3 { font-size: 15px; margin-bottom: 6px; }
.uitleg p, .uitleg-noot { color: var(--ink-2); font-size: 14px; }
.uitleg-noot { margin-top: 14px; max-width: 90ch; }
.voet { padding: 32px 0 48px; color: var(--ink-2); font-size: 13px; }
.voet p { max-width: 90ch; }

/* Tooltip */
.tip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 290px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; box-shadow: 0 16px 40px -10px rgba(0, 0, 0, 0.3); font-size: 13px;
}
.tip[hidden] { display: none; }
.tip-titel { display: flex; align-items: center; gap: 8px; font-weight: 650; }
.tip-key { width: 14px; height: 3px; border-radius: 2px; flex: none; }
.tip-sub { color: var(--ink-2); margin: 2px 0 8px; }
.tip-rij { display: flex; gap: 10px; align-items: baseline; }
.tip-rij strong { font-variant-numeric: tabular-nums; min-width: 4.5em; }
.tip-rij span { color: var(--ink-2); }

/* Detailvenster */
dialog {
  width: min(680px, 100% - 32px); max-height: calc(100% - 32px); overflow: auto;
  border: 1px solid var(--border); border-radius: 24px; padding: clamp(20px, 4vw, 32px);
  background: var(--surface); color: var(--ink); box-shadow: 0 30px 90px rgba(0, 0, 0, 0.3);
}
dialog[open] { animation: verschijn 0.4s var(--ease); }
dialog::backdrop { background: rgba(10, 10, 10, 0.45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
dialog h2 { font-size: clamp(1.3rem, 3vw, 1.75rem); letter-spacing: -0.025em; margin: 6px 40px 2px 0; }
.detail-sluit {
  position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; font-size: 14px;
}
.detail-sub { color: var(--ink-2); }
.detail-periodes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 22px 0 14px; }
.detail-periode { padding: 14px; border-radius: 14px; background: var(--surface-2); min-width: 0; }
.detail-label { font-size: 12.5px; color: var(--ink-2); font-weight: 550; }
.detail-netto { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.03em; margin: 2px 0; }
.detail-kapitaal, .detail-plaats, .detail-leeg { font-size: 13px; color: var(--ink-2); }
.percentiel { height: 6px; border-radius: 3px; background: var(--grid); margin: 10px 0 6px; overflow: hidden; }
.percentiel span { display: block; height: 100%; width: 0; border-radius: 3px; transition: width 0.9s var(--ease); }
.detail-noot { font-size: 12.5px; color: var(--muted); }

@media (max-width: 640px) {
  .filters { position: static; }
  .filters-binnen { gap: 10px 14px; }
  .segment, .keuze { width: 100%; justify-content: space-between; }
  .segment-knoppen span { padding: 6px 11px; font-size: 13px; }
  .keuze select { max-width: 64%; }
  .detail-periodes { grid-template-columns: minmax(0, 1fr); }
  .m-rij, .m-as { grid-template-columns: minmax(70px, 6.5rem) minmax(0, 1fr) 3rem; gap: 8px; }
  .zoek { flex-basis: 100%; }
  .zoek input { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0s !important; scroll-behavior: auto !important; }
}
