/* Componenten die door web/js/ui.js en web/js/chart.js worden gemaakt, plus de bouwstenen uit het
   goedgekeurde ontwerp (dashboard-ontwerp/ontwerp.css). Pagina-specifieke stijl hoort in web/css/pages/<gebied>.css.

   Zekerheid zie je aan de VORM, niet alleen aan de kleur:
     werkelijk / gecontroleerd  -> doorgetrokken lijn of rand, vol vlak       (.cert-actual)
     verwacht / schatting       -> gestreepte lijn of rand, gearceerd vlak    (.cert-est)
     onbekend                   -> gestippelde rand, grijze arcering, ?       (.cert-unk, .unk-value)
     scenario                   -> paars, gestreepte rand, schuine strepen    (.cert-scen)
*/

/* ---------- Iconen voor labels (masker, kleur = tekstkleur) ---------- */
:root {
  --i-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
  --i-person: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 21v-1a5 5 0 0 0-5-5H9a5 5 0 0 0-5 5v1'/%3E%3Ccircle cx='12' cy='8' r='4'/%3E%3C/svg%3E");
  --i-approx: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9.5c2.3-2.3 4.7-2.3 8 0s5.7 2.3 8 0M4 15.5c2.3-2.3 4.7-2.3 8 0s5.7 2.3 8 0'/%3E%3C/svg%3E");
  --i-question: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='M9.3 9.3a2.8 2.8 0 0 1 5.4 1c0 1.9-2.7 2.4-2.7 4.1'/%3E%3Cpath d='M12 17.6h.01'/%3E%3C/svg%3E");
  --i-alert: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 4.2L2.6 17.6A2 2 0 0 0 4.3 20.6h15.4a2 2 0 0 0 1.7-3L13.7 4.2a2 2 0 0 0-3.4 0z'/%3E%3Cpath d='M12 9.5v4.5M12 17.2h.01'/%3E%3C/svg%3E");
  --i-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='M12 11v5.5M12 7.8h.01'/%3E%3C/svg%3E");
  --i-clock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9.5'/%3E%3Cpath d='M12 7v5l3.2 2'/%3E%3C/svg%3E");
  --i-scale: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v16M7 20h10M5 7h14M5 7l-3 6.5a3 3 0 0 0 6 0zM19 7l-3 6.5a3 3 0 0 0 6 0z'/%3E%3C/svg%3E");
  --i-mail: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Cpath d='M3.5 6.5L12 13l8.5-6.5'/%3E%3C/svg%3E");
  --i-calendar: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='5' width='17' height='15' rx='2'/%3E%3Cpath d='M3.5 10h17M8 3v4M16 3v4'/%3E%3C/svg%3E");
  --i-cross: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round'%3E%3Cpath d='M6.5 6.5l11 11M17.5 6.5l-11 11'/%3E%3C/svg%3E");
  --i-pause: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.8' stroke-linecap='round'%3E%3Cpath d='M9 6v12M15 6v12'/%3E%3C/svg%3E");
  --i-dash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.8' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E");
  --i-folder: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/%3E%3C/svg%3E");
  --i-branch: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='6' cy='18' r='2.5'/%3E%3Ccircle cx='18' cy='6' r='2.5'/%3E%3Cpath d='M6 3v12.5M18 8.5c0 5-12 2.5-12 7'/%3E%3C/svg%3E");
}

/* ---------- Kaart ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad-card);
  min-width: 0;
  transition: transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out);
}
.card.interactive {
  cursor: pointer;
}
@media (hover: hover) and (min-width: 721px) {
  .card.interactive:hover,
  .grid > .card:hover,
  .g > .card:hover,
  .tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    border-color: var(--line-strong);
  }
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.card-head > div:first-child {
  min-width: 0;
}
.card-title,
.card-head h3 {
  font-size: 15px;
  line-height: 20px;
  font-weight: 650;
  color: var(--ink-2);
  margin: 0;
}
.card-head .subtle {
  margin-top: 2px;
}
.card-foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: var(--fs-sm);
  line-height: 18px;
  color: var(--ink-3);
}
.card.glass,
.card.hero {
  background: var(--surface);
}
.card.hero {
  position: relative;
}
.card.scenario,
.card.cert-scen {
  border: 2px dashed var(--scen-line);
}

/* ---------- Kerngetal (KPI) ---------- */
.kpi {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  color: inherit;
  width: 100%;
  border-radius: var(--radius-sm);
  font: inherit;
}
.kpi:focus-visible {
  outline-offset: 4px;
}
.kpi-label {
  font-size: 14px;
  line-height: 20px;
  color: var(--ink-2);
  font-weight: 650;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}
.kpi-value {
  font-family: var(--font);
  font-size: var(--fs-3xl);
  line-height: 1.18;
  font-weight: 750;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums lining-nums;
  white-space: nowrap;
  margin-top: 2px;
  color: var(--ink);
  max-width: 100%;
  border-radius: 6px;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
  text-decoration-color: var(--line-strong);
  transition: color var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out), text-decoration-color var(--dur-1) var(--ease-out);
}
.kpi-value.md {
  font-size: 24px;
  line-height: 30px;
}
.kpi-value.sm {
  font-size: 19px;
  line-height: 26px;
}
/* Geen rood voor gewone negatieve bedragen; rood alleen bij een echt tekort (.is-short) */
.kpi-value.negative {
  color: var(--ink);
}
.kpi-value.is-short,
.is-short {
  color: var(--danger);
}
.kpi-value.cert-est {
  text-decoration-style: dashed;
  text-decoration-color: var(--warn-line);
}
.kpi-value.cert-scen {
  color: var(--scen);
  text-decoration-style: dashed;
  text-decoration-color: var(--scen-line);
}
/* Onbekend is nooit € 0: gestippeld, gearceerd vak met vraagteken */
.kpi-value.unknown,
.kpi-value.cert-unk {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: normal;
  font-size: 17px;
  line-height: 22px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--unk);
  padding: 6px 12px;
  border: 1.5px dotted var(--unk-line);
  border-radius: var(--radius-sm);
  background: repeating-linear-gradient(135deg, var(--unk-soft) 0 6px, transparent 6px 12px);
  text-decoration: none;
}
.kpi-value.unknown::before,
.kpi-value.cert-unk::before {
  content: '';
  width: 18px;
  height: 18px;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--i-question) center / contain no-repeat;
  mask: var(--i-question) center / contain no-repeat;
}
.kpi-value.md.unknown,
.kpi-value.sm.unknown {
  font-size: 15px;
  line-height: 20px;
}
.kpi-meta {
  font-size: var(--fs-sm);
  line-height: 18px;
  color: var(--ink-3);
  margin-top: 6px;
}
.kpi-meta:empty {
  display: none;
}
.kpi-why {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--accent);
  margin-top: 6px;
  min-height: 24px;
}
.kpi-why .ic {
  width: 14px;
  height: 14px;
  transition: transform var(--dur-2) var(--ease-out);
}
@media (hover: hover) {
  .kpi:hover .kpi-value:not(.unknown):not(.cert-unk) {
    color: var(--accent);
    text-decoration-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 4px var(--accent-soft);
  }
  .kpi:hover .kpi-why .ic,
  .why:hover .ic:last-child,
  a.arrow:hover .ic:last-child {
    transform: translateX(3px);
  }
}
.kpi-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* Klikbaar bedrag in lopende tekst (§6.5) */
a.amt,
button.amt {
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
  text-decoration-color: var(--line-strong);
  border-radius: 6px;
  transition: color var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}
a.amt:hover,
button.amt:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.why {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  min-height: 28px;
}
.why .ic:last-child {
  transition: transform var(--dur-2) var(--ease-out);
}

/* ---------- Bedragen en zekerheid ---------- */
.amount.neg {
  color: inherit;
}
.amount.pos {
  color: inherit;
}
.amount.cert-est {
  text-decoration: underline dashed var(--warn-line);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}
.amount.cert-scen {
  color: var(--scen);
  text-decoration: underline dashed var(--scen-line);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}
.amount-range {
  white-space: nowrap;
}
/* Onbekend bedrag: op de plek waar anders het bedrag zou staan */
.unknown-amount,
.unk-value {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 650;
  font-size: 0.92em;
  color: var(--unk);
  padding: 0 8px 0 6px;
  border: 1.5px dotted var(--unk-line);
  border-radius: 6px;
  background: repeating-linear-gradient(135deg, var(--unk-soft) 0 5px, transparent 5px 10px);
  white-space: nowrap;
  font-variant-numeric: normal;
  vertical-align: baseline;
}
.unknown-amount::before,
.unk-value::before {
  content: '';
  width: 13px;
  height: 13px;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--i-question) center / contain no-repeat;
  mask: var(--i-question) center / contain no-repeat;
}
/* Vakken in zekerheidsvorm (voor pagina's die het zelf willen gebruiken) */
.cert-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.cert-box.cert-est {
  border: 1.5px dashed var(--warn-line);
  background: repeating-linear-gradient(135deg, var(--surface) 0 8px, var(--warn-soft) 8px 9px);
}
.cert-box.cert-unk {
  border: 1.5px dotted var(--unk-line);
  background: repeating-linear-gradient(135deg, var(--unk-soft) 0 6px, var(--surface) 6px 12px);
}
.cert-box.cert-scen {
  border: 2px dashed var(--scen-line);
}
.cert-line {
  display: inline-block;
  width: 28px;
  height: 0;
  border-top: 2.5px solid var(--c-actual);
  vertical-align: middle;
}
.cert-line.cert-est {
  border-top-style: dashed;
}
.cert-line.cert-unk {
  border-top: 2.5px dotted var(--unk-line);
}
.cert-line.cert-scen {
  border-top: 3px dotted var(--c-scen);
}

/* ---------- Statuslabels (invoerstatus en kwaliteit) ---------- */
.badge,
.q {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 650;
  line-height: 16px;
  white-space: nowrap;
  vertical-align: middle;
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.badge::before,
.q::before {
  content: '';
  display: none;
  width: 12px;
  height: 12px;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--bi) center / contain no-repeat;
  mask: var(--bi) center / contain no-repeat;
}
/* uit document gecontroleerd: doorgetrokken, groen, vinkje */
.badge.ok,
.badge.document,
.badge.positive,
.badge.success,
.q-doc {
  --bi: var(--i-check);
  background: var(--ok-soft);
  color: var(--ok);
  border-color: var(--ok-line);
}
/* door Patrick opgegeven: doorgetrokken, blauw, persoon */
.badge.opgegeven,
.q-own {
  --bi: var(--i-person);
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-line);
}
.badge.info {
  --bi: var(--i-info);
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-line);
}
/* schatting / onvolledig: gestreept, oranje, ≈ */
.badge.schatting,
.badge.warning,
.badge.onvolledig,
.badge.voorstel,
.q-est {
  --bi: var(--i-approx);
  background: var(--warn-soft);
  color: var(--warn);
  border-color: var(--warn-line);
  border-style: dashed;
}
.badge.warning {
  --bi: var(--i-alert);
}
/* onbekend: gestippeld, grijs, vraagteken */
.badge.onbekend,
.badge.unknown,
.q-unk {
  --bi: var(--i-question);
  background: var(--unk-soft);
  color: var(--unk);
  border: 1.5px dotted var(--unk-line);
  padding: 1.5px 7.5px;
}
/* berekend: doorgetrokken, neutraal, geen icoon */
.badge.afgeleid,
.q-calc {
  background: transparent;
  color: var(--ink-2);
  border-color: var(--line-strong);
}
/* tekort / fout */
.badge.negative,
.badge.danger,
.badge.error {
  --bi: var(--i-alert);
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-line);
}
/* scenario: paars, gestreept */
.badge.scenario,
.q-scen {
  --bi: var(--i-branch);
  background: var(--scen-soft);
  color: var(--scen);
  border-color: var(--scen-line);
  border-style: dashed;
}
.badge.demo {
  background: var(--demo-soft);
  color: var(--demo);
  border-color: var(--demo-line);
}
.badge.ok::before,
.badge.document::before,
.badge.positive::before,
.badge.success::before,
.badge.opgegeven::before,
.badge.info::before,
.badge.schatting::before,
.badge.warning::before,
.badge.onvolledig::before,
.badge.voorstel::before,
.badge.onbekend::before,
.badge.unknown::before,
.badge.negative::before,
.badge.danger::before,
.badge.error::before,
.badge.scenario::before,
.q-doc::before,
.q-own::before,
.q-est::before,
.q-unk::before,
.q-scen::before {
  display: block;
}
.badge.plain::before,
.badge.no-icon::before {
  display: none;
}

/* Actiestatus en deadline-soort (§6.11) */
.st {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}
.st::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: var(--line-strong);
  flex: none;
}
.st-busy::before {
  background: var(--accent);
}
.st-wait::before {
  background: var(--warn-line);
  border-radius: 50%;
}
.st-done::before {
  background: var(--ok-line);
}
.dl {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.dl-date {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.dl-kind {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--fs-xs);
  line-height: 16px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  border: 1px solid;
  white-space: nowrap;
}
.dl-kind::before {
  content: '';
  width: 13px;
  height: 13px;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--bi, none) center / contain no-repeat;
  mask: var(--bi, none) center / contain no-repeat;
}
.dl-legal {
  --bi: var(--i-scale);
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}
.dl-letter {
  --bi: var(--i-mail);
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-line);
}
.dl-internal {
  --bi: var(--i-calendar);
  background: transparent;
  color: var(--ink-2);
  border-color: var(--line-strong);
  border-style: dashed;
}
.dl-none {
  color: var(--ink-3);
  font-size: var(--fs-sm);
}

/* ---------- Knoppen ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-weight: 650;
  font-size: 14px;
  line-height: 20px;
  cursor: pointer;
  text-decoration: none !important;
  white-space: nowrap;
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
a.btn:hover {
  color: var(--ink);
}
.btn:hover {
  background: var(--surface-2);
}
@media (hover: hover) {
  .btn:hover {
    box-shadow: var(--shadow-hover);
  }
}
.btn:active {
  transform: scale(0.97);
}
.btn.primary,
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn.primary:hover,
.btn-primary:hover,
a.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-ink);
}
.btn.primary:active {
  box-shadow: none;
}
.btn.danger {
  color: var(--danger);
  border-color: var(--danger-line);
}
.btn.danger:hover {
  background: var(--danger-soft);
}
.btn.ghost,
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--accent);
}
.btn.ghost:hover {
  background: var(--surface-2);
  box-shadow: none;
}
.btn.scen,
.btn.scenario,
.btn-scen {
  background: var(--scen);
  border-color: var(--scen);
  color: var(--surface);
}
.btn.scen:hover,
.btn.scenario:hover,
.btn-scen:hover {
  background: var(--scen);
  color: var(--surface);
  filter: brightness(1.08);
}
.btn.small,
.btn-sm {
  min-height: 32px;
  padding: 0 10px;
  font-size: var(--fs-sm);
}
.btn.large,
.btn-lg {
  min-height: 56px;
  padding: 0 22px;
  font-size: 17px;
  border-radius: var(--radius);
}
.btn.block,
.btn-block {
  width: 100%;
}
.btn[disabled],
.btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn .ic {
  width: 16px;
  height: 16px;
}
.btn .spinner,
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: none;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  flex: none;
  transition: background-color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.icon-btn:active {
  transform: scale(0.95);
}
@media (max-width: 720px) {
  .btn.small,
  .btn-sm {
    min-height: 40px;
  }
}

/* ---------- Formulieren (§6.22) ---------- */
.form {
  display: grid;
  gap: var(--space-4);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: var(--space-4);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field.wide {
  grid-column: 1 / -1;
}
.field > label,
.field label,
.flabel {
  font-size: 14px;
  line-height: 20px;
  font-weight: 650;
  color: var(--ink-2);
}
.field .hint,
.hint {
  font-size: var(--fs-sm);
  line-height: 18px;
  color: var(--ink-3);
}
.field .error {
  font-size: var(--fs-sm);
  line-height: 18px;
  font-weight: 600;
  color: var(--danger);
  animation: fade var(--dur-2) var(--ease-out) backwards;
}
.input,
.select,
.textarea,
.field input:not([type='checkbox']):not([type='radio']):not([type='file']),
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
  line-height: 22px;
  transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}
select.input,
.select,
.field select {
  padding-right: 32px;
}
.field input::placeholder,
.field textarea::placeholder,
.input::placeholder {
  color: var(--ink-3);
  opacity: 1;
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea,
.textarea {
  min-height: 96px;
  resize: vertical;
}
.field input[type='file'] {
  font-size: 14px;
  max-width: 100%;
}
.field.invalid input,
.field.invalid select,
.field.invalid textarea {
  border-color: var(--danger);
}
.field .money-input {
  position: relative;
}
.field .money-input input,
.field .money-input input:not([type='checkbox']):not([type='radio']):not([type='file']) {
  padding-left: 34px;
  font-variant-numeric: tabular-nums;
}
.field .money-input::before {
  content: '€';
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  pointer-events: none;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 14px;
  min-height: 32px;
  cursor: pointer;
}
input[type='checkbox'],
input[type='radio'] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex: none;
  margin: 0;
}
.form-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  flex-wrap: wrap;
}
@media (max-width: 720px) {
  .form-actions > .btn {
    flex: 1 1 auto;
  }
}
/* Segmenten en pillen: knoppen met aria-pressed */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 3px;
  background: var(--surface);
  gap: 2px;
}
.seg button {
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  padding: 6px 14px;
  border-radius: 7px;
  min-height: 36px;
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.seg button:hover {
  background: var(--surface-2);
}
.seg button[aria-pressed='true'],
.seg button[aria-checked='true'] {
  background: var(--accent-soft);
  color: var(--accent);
}
.seg button:active,
.pill:active,
.choice:active {
  transform: scale(0.97);
}
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pill {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.pill[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.choice {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  align-items: flex-start;
  cursor: pointer;
  min-width: 0;
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.choice.is-on {
  border: 2px solid var(--accent);
  background: var(--accent-soft);
  padding: 13px 15px;
}
.choice .t {
  font-weight: 700;
  font-size: 15px;
  line-height: 21px;
}
.choice .d {
  font-size: var(--fs-sm);
  line-height: 18px;
  color: var(--ink-2);
  margin-top: 2px;
}
/* Schakelaar (§6.31) */
.switch {
  position: relative;
  width: 46px;
  height: 28px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line-strong);
  background: var(--surface-3);
  cursor: pointer;
  flex: none;
  padding: 0;
  transition: background-color var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out);
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform var(--dur-2) var(--ease-spring);
}
.switch[aria-checked='true'] {
  background: var(--accent);
  border-color: var(--accent);
}
.switch[aria-checked='true']::after {
  transform: translateX(18px);
  background: var(--accent-ink);
}
.setrow {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}
.setrow:first-child {
  border-top: 0;
}
.setrow .t {
  font-weight: 650;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.filters .field {
  min-width: 160px;
}
.picker {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.secret {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  letter-spacing: 0.04em;
  color: var(--ink-2);
}

/* ---------- Tabellen (§6.15) ---------- */
.table-wrap,
.tbl-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  max-width: 100%;
}
table.table,
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 20px;
}
.table th,
.table td,
.tbl th,
.tbl td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table th,
.tbl th {
  font-size: var(--fs-xs);
  line-height: 16px;
  font-weight: 700;
  color: var(--ink-3);
  background: var(--surface-2);
  white-space: nowrap;
  text-transform: none;
  letter-spacing: 0;
}
.table td.right,
.table th.right,
.tbl .r {
  text-align: right;
}
.table td.right,
.tbl td.r {
  font-variant-numeric: tabular-nums lining-nums;
}
.table td,
.tbl td {
  transition: background-color var(--dur-1) var(--ease-out);
}
.table tbody tr:hover td,
.tbl tbody tr:hover td {
  background-color: var(--surface-2);
}
.table tbody tr.clickable {
  cursor: pointer;
}
.table tbody tr:last-child td,
.tbl tr:last-child td {
  border-bottom: 0;
}
/* Toekomstrijen zijn gearceerd (verwacht), niet gekleurd */
.table tr.forecast td,
.table tr.fc td,
.tbl tr.fc td {
  background-image: repeating-linear-gradient(135deg, transparent 0 8px, var(--surface-2) 8px 9px);
}
.table tr.hl td,
.tbl tr.hl td {
  background: var(--warn-soft);
}
.table tr.sh td,
.tbl tr.sh td {
  background: var(--danger-soft);
}
.table tr.scen td {
  background-image: repeating-linear-gradient(135deg, transparent 0 8px, var(--scen-soft) 8px 10px);
}
.table tr.total td,
.table tr.tot td,
.tbl .tot td {
  font-weight: 700;
  background: var(--surface-2);
}
/* Telefoon: responsive tabellen worden kaartjes; andere tabellen scrollen met vaste eerste kolom */
@media (max-width: 720px) {
  .table-wrap:has(> .table.responsive) {
    border: 0;
    background: transparent;
    overflow: visible;
    border-radius: 0;
  }
  .table.responsive,
  .table.responsive tbody {
    display: block;
  }
  .table.responsive thead {
    display: none;
  }
  .table.responsive tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 6px 0;
    margin-bottom: 8px;
  }
  .table.responsive tr:last-child {
    margin-bottom: 0;
  }
  .table.responsive td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-3);
    border: 0;
    padding: 6px 14px;
    text-align: right;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .table.responsive td > * {
    min-width: 0;
  }
  .table.responsive td::before {
    content: attr(data-label);
    color: var(--ink-3);
    font-size: var(--fs-xs);
    font-weight: 650;
    text-align: left;
    flex: 0 0 auto;
    max-width: 45%;
  }
  .table.responsive td[data-label='']::before {
    display: none;
  }
  .table.responsive td:first-child {
    font-weight: 650;
  }
  .table.responsive tbody tr:hover td {
    background-color: transparent;
  }
  .table.responsive tr.forecast,
  .table.responsive tr.fc {
    border-style: dashed;
    background-image: repeating-linear-gradient(135deg, transparent 0 8px, var(--surface-2) 8px 9px);
  }
  .table.responsive tr.forecast td,
  .table.responsive tr.fc td {
    background-image: none;
  }
  .table.responsive tr.total {
    background: var(--surface-2);
  }
  .table:not(.responsive) th:first-child,
  .table:not(.responsive) td:first-child,
  .tbl th:first-child,
  .tbl td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background-color: var(--surface);
    box-shadow: 1px 0 0 var(--line);
  }
  .table:not(.responsive) th:first-child,
  .tbl th:first-child {
    background-color: var(--surface-2);
  }
}
.mini {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  line-height: 18px;
}
.mini th {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--ink-3);
  text-align: right;
  padding: 0 0 6px 8px;
  white-space: nowrap;
}
.mini th:first-child {
  text-align: left;
  padding-left: 0;
}
.mini td {
  padding: 6px 0 6px 8px;
  border-top: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.mini td:first-child {
  text-align: left;
  padding-left: 0;
  white-space: normal;
  color: var(--ink-2);
}
.mini .tot td {
  font-weight: 700;
  color: var(--ink);
  border-top: 2px solid var(--line-strong);
}

/* ---------- Tabs (§6.24) ---------- */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
  margin-bottom: var(--space-5);
  max-width: 100%;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tab {
  font: inherit;
  font-size: 15px;
  line-height: 20px;
  font-weight: 600;
  color: var(--ink-2);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 12px 14px;
  min-height: 46px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 8px 8px 0 0;
  flex: none;
  transition: color var(--dur-1) var(--ease-out), border-color var(--dur-2) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}
.tab:hover {
  color: var(--ink);
  background: var(--surface-2);
}
.tab[aria-selected='true'] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab:focus-visible {
  outline-offset: -2px;
}
.tab .count,
.count-warn {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid var(--warn-line);
  font-size: var(--fs-xs);
  font-weight: 700;
  display: inline-grid;
  place-items: center;
}
.tab-panel,
.tabpanel {
  animation: fade var(--dur-2) var(--ease-out) backwards;
  min-width: 0;
}
@media (max-width: 720px) {
  .tab {
    padding: 10px 12px;
    font-size: 14px;
    min-height: 44px;
  }
  .tabs {
    margin-bottom: var(--space-4);
  }
}

/* ---------- Uitlegpaneel "Hoe is dit berekend?" (§6.13) ---------- */
.drawer-scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 50;
  animation: fade var(--dur-3) var(--ease-out) backwards;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-overlay);
  z-index: 51;
  display: flex;
  flex-direction: column;
  animation: drawer-in var(--dur-3) var(--ease-out) backwards;
  outline: none;
}
.drawer.closing {
  animation: drawer-out var(--dur-2) var(--ease-in) forwards;
}
.drawer-scrim.closing {
  animation: fade-out var(--dur-2) var(--ease-in) forwards;
}
.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 {
  margin: 0;
  font-size: 19px;
  line-height: 26px;
  outline: none;
}
.drawer-head .eyebrow {
  margin-bottom: 2px;
}
.drawer-body {
  padding: 20px 24px 28px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overscroll-behavior: contain;
}
.drawer-body > * {
  animation: rise var(--dur-3) var(--ease-out) backwards;
}
.drawer-body > :nth-child(1) {
  animation-delay: 140ms;
}
.drawer-body > :nth-child(2) {
  animation-delay: 190ms;
}
.drawer-body > :nth-child(3) {
  animation-delay: 240ms;
}
.drawer-body > :nth-child(n + 4) {
  animation-delay: 290ms;
}
/* Een pagina die eigen inhoud in het paneel zet (één omhulsel) */
.drawer-body > :only-child {
  min-width: 0;
}
@media (max-width: 720px) {
  .drawer {
    top: 56px;
    left: 0;
    width: auto;
    border-left: 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation-name: sheet-in;
  }
  .drawer.closing {
    animation-name: sheet-out;
  }
  .drawer::before {
    content: '';
    position: absolute;
    top: 7px;
    left: 50%;
    width: 40px;
    height: 4px;
    margin-left: -20px;
    border-radius: 4px;
    background: var(--line-strong);
  }
  .drawer-head {
    padding: 18px 16px 12px;
  }
  .drawer-body {
    padding: 16px 16px 28px;
  }
}
.ex-sec > h3,
.ex-h {
  font-size: var(--fs-xs);
  line-height: 16px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 10px;
}
.ex-amount {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.ex-amount .kpi-value {
  text-decoration: none;
  font-size: 30px;
  line-height: 36px;
}
.ex-amount .kpi-value.unknown {
  font-size: 16px;
}
.ex-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  margin-top: 8px;
  font-size: var(--fs-sm);
  color: var(--ink-3);
}
.formula,
.explain-formula {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 15px;
  line-height: 22px;
}
.formula .f-text {
  font-size: var(--fs-sm);
  line-height: 18px;
  color: var(--ink-2);
  margin-bottom: 4px;
}
.formula .fr {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  animation: rise var(--dur-2) var(--ease-out) backwards;
}
.formula .fr > :first-child {
  min-width: 0;
  display: flex;
}
.formula .fr > :first-child > .op {
  flex: none;
}
.formula .fr:nth-child(1) { animation-delay: 260ms; }
.formula .fr:nth-child(2) { animation-delay: 320ms; }
.formula .fr:nth-child(3) { animation-delay: 380ms; }
.formula .fr:nth-child(4) { animation-delay: 440ms; }
.formula .fr:nth-child(5) { animation-delay: 500ms; }
.formula .fr:nth-child(6) { animation-delay: 560ms; }
.formula .fr:nth-child(7) { animation-delay: 620ms; }
.formula .fr:nth-child(n + 8) { animation-delay: 680ms; }
.formula .op {
  color: var(--ink-3);
  display: inline-block;
  width: 18px;
  font-weight: 700;
}
.formula .res {
  border-top: 2px solid var(--ink);
  padding-top: 8px;
  margin-top: 4px;
  font-weight: 750;
}
.formula .amount {
  text-align: right;
}
.src {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.src li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}
.src li:first-child {
  border-top: 0;
}
.src .nm {
  font-weight: 650;
  font-size: 14px;
  line-height: 20px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.src .bd {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.src .meta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  font-size: var(--fs-sm);
  line-height: 18px;
  color: var(--ink-3);
}
.src a {
  font-weight: 600;
}
.ex-trust {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  line-height: 20px;
  color: var(--ink-2);
}
.ex-trust ul {
  margin: 0;
  padding-left: 20px;
}
.ex-trust .row {
  gap: 6px;
}
/* Oude klassen uit explain() blijven werken */
.explain-parts {
  list-style: none;
  margin: 0;
  padding: 0;
}
.explain-total {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  border-top: 2px solid var(--ink);
  padding-top: var(--space-2);
}

/* ---------- Nog niet betrouwbaar / ontbreekt nog / leeg (§6.16) ---------- */
.not-reliable,
.miss {
  border: 1.5px dotted var(--unk-line);
  background: var(--unk-soft);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.not-reliable > strong,
.not-reliable .nr-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--unk);
  font-weight: 700;
  font-size: 15px;
  line-height: 20px;
}
.not-reliable > strong::before,
.not-reliable .nr-title::before {
  content: '';
  width: 20px;
  height: 20px;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--i-question) center / contain no-repeat;
  mask: var(--i-question) center / contain no-repeat;
}
.not-reliable .nr-why {
  font-size: 14px;
  line-height: 20px;
  color: var(--ink-2);
  margin: 0;
}
.not-reliable ul {
  margin: 0;
  padding-left: var(--space-5);
  font-size: 14px;
}
.miss-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.miss-i {
  display: flex;
  gap: 8px 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  font-size: 14px;
  line-height: 20px;
}
.miss-i > span {
  min-width: 0;
  flex: 1 1 180px;
}
.miss-i .btn {
  flex: none;
}
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: var(--space-6) var(--space-4);
  color: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
}
.empty::before {
  content: '';
  width: 28px;
  height: 28px;
  background: var(--ink-3);
  -webkit-mask: var(--i-folder) center / contain no-repeat;
  mask: var(--i-folder) center / contain no-repeat;
  margin-bottom: 2px;
}
.empty .empty-title {
  font-weight: 650;
  color: var(--ink);
  font-size: 15px;
}
.empty .row,
.empty > .btn {
  justify-content: center;
  margin-top: 4px;
}

/* ---------- Meldingen (§6.14) ---------- */
.alert,
.note {
  position: relative;
  border-radius: 10px;
  padding: 12px 14px 12px 42px;
  font-size: 14px;
  line-height: 20px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  min-width: 0;
  overflow-wrap: anywhere;
}
.alert::before,
.note::before {
  content: '';
  position: absolute;
  left: 14px;
  top: 13px;
  width: 18px;
  height: 18px;
  background: var(--ink-3);
  -webkit-mask: var(--ni, var(--i-info)) center / contain no-repeat;
  mask: var(--ni, var(--i-info)) center / contain no-repeat;
}
.alert.info,
.note-info {
  --ni: var(--i-info);
  background: var(--accent-soft);
  border-color: var(--accent-line);
}
.alert.info::before,
.note-info::before {
  background: var(--accent);
}
.alert.warning,
.note-warn {
  --ni: var(--i-alert);
  background: var(--warn-soft);
  border-color: var(--warn-line);
}
.alert.warning::before,
.note-warn::before {
  background: var(--warn);
}
.alert.error,
.alert.danger,
.note-short {
  --ni: var(--i-alert);
  background: var(--danger-soft);
  border-color: var(--danger-line);
}
.alert.error::before,
.alert.danger::before,
.note-short::before {
  background: var(--danger);
}
.alert.unknown,
.note-unk {
  --ni: var(--i-question);
  background: var(--unk-soft);
  border: 1.5px dotted var(--unk-line);
}
.alert.unknown::before,
.note-unk::before {
  background: var(--unk);
}
.alert.scenario {
  --ni: var(--i-branch);
  background: var(--scen-soft);
  border: 1.5px dashed var(--scen-line);
}
.alert.scenario::before {
  background: var(--scen);
}
.alert.success,
.alert.ok {
  --ni: var(--i-check);
  background: var(--ok-soft);
  border-color: var(--ok-line);
}
.alert.success::before,
.alert.ok::before {
  background: var(--ok);
}
.alert.demo {
  background: var(--demo-soft);
  border-color: var(--demo-line);
  color: var(--ink);
}
.alert.demo::before {
  background: var(--demo);
}
.alert > :last-child,
.note > :last-child {
  margin-bottom: 0;
}
.alert .btn,
.note .btn {
  margin-top: 6px;
}

/* Toast (korte bevestiging) */
.toast-host {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  display: grid;
  gap: var(--space-2);
  z-index: 70;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: var(--bg);
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow-overlay);
  font-size: 14px;
  line-height: 20px;
  font-weight: 550;
  max-width: 400px;
  pointer-events: auto;
  animation: rise var(--dur-3) var(--ease-out) backwards;
}
.toast.error {
  background: var(--danger);
  color: var(--surface);
}
.toast.leaving {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--dur-2) var(--ease-in), transform var(--dur-2) var(--ease-in);
}
@media (max-width: 720px) {
  .toast-host {
    left: var(--space-4);
    right: var(--space-4);
    bottom: var(--space-4);
  }
  .toast {
    max-width: none;
  }
}

/* ---------- Dialoog ---------- */
dialog.modal {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  padding: 0;
  width: min(640px, calc(100vw - 24px));
  max-height: calc(100dvh - 48px);
  box-shadow: var(--shadow-overlay);
}
dialog.modal[open] {
  animation: rise var(--dur-3) var(--ease-out) backwards;
}
dialog.modal::backdrop {
  background: var(--scrim);
}
.modal-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
}
.modal-head h2 {
  margin: 0;
  font-size: 19px;
  line-height: 26px;
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(100dvh - 150px);
}
@media (max-width: 720px) {
  dialog.modal {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 24px);
  }
  .modal-body {
    padding: 16px;
    max-height: calc(100dvh - 110px);
  }
}

/* ---------- Skelet tijdens laden (§6.23, §7.3: pas na 300 ms zichtbaar) ---------- */
.skeleton,
.sk {
  display: block;
  border-radius: 6px;
  min-height: 12px;
  background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 45%, var(--surface-3) 90%);
  background-size: 200% 100%;
  animation: sk-reveal var(--dur-2) var(--ease-out) 300ms backwards, shimmer 1400ms linear 300ms infinite;
}
.skeleton.block,
.sk-chart {
  height: 220px;
  border-radius: 10px;
}
.sk-line {
  height: 12px;
}
.sk-line-lg {
  height: 18px;
}
.sk-kpi {
  height: 36px;
  width: 62%;
  border-radius: 8px;
}
.sk-pill {
  height: 22px;
  width: 46%;
  border-radius: var(--radius-pill);
}
.sk-row {
  height: 52px;
  border-radius: 8px;
}
.sk-page {
  display: flex;
  flex-direction: column;
  gap: var(--gap-section);
}
.sk-page .card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.route-loader .sk,
.route-loader .skeleton {
  animation: shimmer 1400ms linear infinite;
}

/* ---------- Grafiek (§6.10) ---------- */
.chart {
  width: 100%;
  position: relative;
  min-width: 0;
}
.chart svg.chart-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  touch-action: pan-y;
}
.chart text {
  font-family: var(--font);
  font-size: 12px;
  fill: var(--ink-3);
}
.chart .t-strong {
  fill: var(--ink-2);
  font-weight: 650;
}
.chart .t-short {
  fill: var(--danger);
  font-weight: 700;
}
.chart .t-scen {
  fill: var(--scen);
  font-weight: 700;
}
.chart .t-warn {
  fill: var(--warn);
  font-weight: 650;
}
.chart .t-halo {
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 4px;
  stroke-linejoin: round;
}
.ln {
  fill: none;
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.ln-actual {
  stroke: var(--c-actual);
}
.ln-base {
  stroke: var(--c-actual);
  stroke-dasharray: 7 5;
  stroke-linecap: butt;
}
.ln-careful {
  stroke: var(--c-careful);
  stroke-dasharray: 2 4 9 4;
  stroke-linecap: butt;
}
.ln-scen {
  stroke: var(--c-scen);
  stroke-dasharray: 1 5;
  stroke-width: 3;
}
.ln-grid {
  stroke: var(--c-grid);
  stroke-width: 1;
}
.ln-zero {
  stroke: var(--line-strong);
  stroke-width: 1.5;
}
.ln-buffer {
  stroke: var(--warn);
  stroke-width: 1.5;
  stroke-dasharray: 3 4;
}
.ln-today {
  stroke: var(--ink-3);
  stroke-width: 1.25;
}
.ln-guide {
  stroke: var(--ink-3);
  stroke-width: 1;
  stroke-dasharray: 2 3;
}
.area-actual {
  fill: var(--c-area);
}
.area-unreliable {
  fill: url(#chart-hatch);
  stroke: var(--unk-line);
  stroke-width: 1.5;
  stroke-dasharray: 2 3;
}
.dot {
  stroke: var(--surface);
  stroke-width: 2;
}
.dot-actual,
.dot-base {
  fill: var(--c-actual);
}
.dot-careful {
  fill: var(--c-careful);
}
.dot-scen {
  fill: var(--c-scen);
}
.dot-warn {
  fill: var(--warn);
}
.dot-short {
  fill: var(--danger);
}
.dot-hover {
  fill: var(--surface);
  stroke-width: 2.5;
}
/* Grafiek tekent zich: werkelijk eerst, daarna prognose; stippen en labels als laatste */
.chart.play .draw {
  animation: wipe 700ms var(--ease-in-out) 250ms backwards;
}
.chart.play .draw.d2 {
  animation-duration: var(--dur-draw);
  animation-delay: 900ms;
}
.chart.play .late-1 {
  animation: fade var(--dur-2) var(--ease-out) 900ms backwards;
}
.chart.play .late-2 {
  animation: fade var(--dur-3) var(--ease-out) 1900ms backwards;
}
.chart.play circle.late-1,
.chart.play circle.late-2 {
  transform-box: fill-box;
  transform-origin: center;
  animation-name: pop;
  animation-timing-function: var(--ease-spring);
}
.chart.paused .draw,
.chart.paused .late-1,
.chart.paused .late-2 {
  animation-play-state: paused;
}
.chart-legend,
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: var(--fs-sm);
  line-height: 18px;
  color: var(--ink-2);
  margin: 0 0 10px;
}
.chart-legend > span,
.legend > span {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.chart-legend svg,
.legend svg {
  width: 28px;
  height: 10px;
  flex: none;
  overflow: visible;
}
.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-overlay);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: var(--fs-xs);
  line-height: 16px;
  white-space: nowrap;
  z-index: 2;
  transition: opacity var(--dur-1) var(--ease-out);
  display: grid;
  gap: 2px;
}
.chart-tooltip .tt-date {
  font-weight: 700;
  color: var(--ink);
}
.chart-tooltip .tt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}
.chart-tooltip .tt-row b {
  font-variant-numeric: tabular-nums;
}
.chart-empty {
  padding: var(--space-5);
}
.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 8px;
}
.chart-head .chart-legend {
  margin: 0;
}
.chart-switch {
  margin-left: auto;
}
.swap {
  animation: fade var(--dur-2) var(--ease-out) backwards;
}

/* ---------- Diversen ---------- */
.chip,
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: var(--fs-xs);
  font-weight: 650;
  line-height: 16px;
  color: var(--ink-2);
  white-space: nowrap;
}
.period-note {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-size: var(--fs-xs);
  line-height: 16px;
  color: var(--ink-3);
}
.period-note .ic {
  width: 13px;
  height: 13px;
}
.sub-line {
  font-size: var(--fs-sm);
  line-height: 18px;
  color: var(--ink-3);
}
.stmt {
  font-size: var(--fs-xl);
  line-height: 1.3333;
  font-weight: 750;
  letter-spacing: -0.005em;
}
.divider {
  height: 1px;
  background: var(--line);
  margin: var(--space-4) 0;
}
.progress {
  height: 10px;
  background: var(--surface-3);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--ok-line);
  border-radius: inherit;
  transform-origin: left center;
  transition: width var(--dur-4) var(--ease-out);
  animation: grow-x var(--dur-4) var(--ease-out) 300ms backwards;
}
.progress-legend {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: var(--fs-sm);
  line-height: 18px;
  color: var(--ink-2);
}
.kv {
  display: grid;
  grid-template-columns: minmax(120px, 40%) minmax(0, 1fr);
  gap: 0 var(--space-4);
  font-size: 14px;
  line-height: 20px;
  margin: 0;
}
.kv > dt,
.kv > dd {
  padding: 8px 0;
  border-top: 1px solid var(--line);
  margin: 0;
  min-width: 0;
}
.kv > dt {
  color: var(--ink-2);
  font-weight: 600;
}
.kv > dt:first-of-type,
.kv > dt:first-of-type + dd {
  border-top: 0;
}
.kv dd .badge,
.kv dd .unknown-amount {
  margin-left: 6px;
}
@media (max-width: 720px) {
  .kv {
    grid-template-columns: minmax(0, 1fr);
  }
  .kv > dd {
    border-top: 0;
    padding-top: 0;
  }
}
.dropzone {
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: var(--space-6);
  text-align: center;
  color: var(--ink-2);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
.dropzone.over {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.01);
}
.status-line {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.lines {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.lines li {
  display: flex;
  gap: 8px 12px;
  align-items: baseline;
  justify-content: space-between;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
  line-height: 20px;
  flex-wrap: wrap;
}
.lines li:first-child {
  border-top: 0;
}
.lines .lab {
  flex: 1 1 140px;
  min-width: 0;
  color: var(--ink-2);
}

/* ---------- Ontwerp-bouwstenen voor pagina's (klassen uit ontwerp.css) ---------- */
/* Toestandstrook: financieel en administratie naast elkaar, nooit één cijfer (§6.4) */
.state {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.state > div {
  padding: 14px 20px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-width: 0;
}
.state > div + div {
  border-left: 1px solid var(--line);
}
.state .ttl {
  font-weight: 700;
  font-size: 16px;
  line-height: 22px;
}
/* Balk vrij / buffer / bestemd (§6.7) */
.bar-split {
  display: flex;
  gap: 2px;
  height: 14px;
}
.bar-split > span {
  border-radius: 3px;
  min-width: 4px;
  transform-origin: left center;
  animation: grow-x var(--dur-4) var(--ease-out) backwards;
}
.bar-split > span:nth-child(1) { animation-delay: 300ms; }
.bar-split > span:nth-child(2) { animation-delay: 380ms; }
.bar-split > span:nth-child(3) { animation-delay: 460ms; }
.seg-free,
.seg-real {
  background: var(--c-actual);
}
.seg-buffer {
  background: var(--accent-soft);
  border: 1.5px solid var(--c-actual);
}
.seg-held {
  background: repeating-linear-gradient(135deg, var(--line-strong) 0 3px, var(--surface-2) 3px 7px);
}
.seg-exp {
  background: repeating-linear-gradient(135deg, var(--c-actual) 0 2px, var(--accent-soft) 2px 6px);
}
.key {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--fs-sm);
  line-height: 18px;
}
.key > div {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}
.key i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex: none;
}
/* Actielijst (§6.11) */
.acts {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.act {
  display: grid;
  grid-template-columns: 32px minmax(0, 2.4fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 16px;
  padding: 16px 20px;
  align-items: start;
  animation: rise var(--dur-3) var(--ease-out) backwards;
}
.act + .act {
  border-top: 1px solid var(--line);
}
.acts > .act:nth-child(2) { animation-delay: 120ms; }
.acts > .act:nth-child(3) { animation-delay: 180ms; }
.acts > .act:nth-child(4) { animation-delay: 240ms; }
.acts > .act:nth-child(5) { animation-delay: 300ms; }
.acts > .act:nth-child(n + 6) { animation-delay: 360ms; }
.act .nr {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--line-strong);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.act .what {
  font-weight: 650;
  font-size: 15px;
  line-height: 21px;
}
.act .reason {
  font-size: 14px;
  line-height: 20px;
  color: var(--ink-2);
  margin-top: 4px;
}
.act .k {
  display: none;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--ink-3);
  margin-right: 6px;
}
.act .c {
  font-size: 14px;
  line-height: 20px;
  color: var(--ink-2);
}
@media (max-width: 980px) {
  .act {
    grid-template-columns: 32px minmax(0, 1fr);
  }
  .act > .c {
    grid-column: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
  }
  .act .k {
    display: inline;
  }
  .act .dl {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
}
/* Bedrijfstegel (§6.12) */
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad-card);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  transition: transform var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), border-color var(--dur-2) var(--ease-out);
}
.tile-name {
  font-size: var(--fs-lg);
  line-height: 24px;
  font-weight: 750;
}
.fresh {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-size: var(--fs-sm);
  line-height: 18px;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}
.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 24px;
  margin: 0;
}
.fact {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.fact dt {
  font-size: var(--fs-sm);
  line-height: 18px;
  color: var(--ink-2);
  font-weight: 600;
}
.fact dd {
  margin: 0;
  font-size: var(--fs-lg);
  line-height: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.fact .per {
  display: block;
  font-size: var(--fs-xs);
  line-height: 16px;
  color: var(--ink-3);
  font-weight: 500;
}
/* Scenario-blok (§6.17) */
.scen {
  border: 2px dashed var(--scen-line);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}
.scen-band {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 10px 16px;
  color: var(--scen);
  font-weight: 650;
  font-size: 14px;
  line-height: 20px;
  background: repeating-linear-gradient(135deg, var(--scen-soft) 0 10px, var(--surface) 10px 20px);
  border-bottom: 1px solid var(--scen-line);
}
.scen-tag {
  background: var(--scen);
  color: var(--surface);
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
}
.scen-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
/* Status van een betalingsregeling (§6.27) */
.rs {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  line-height: 16px;
  font-weight: 700;
  padding: 3px 9px 3px 7px;
  border-radius: var(--radius-pill);
  border: 1px solid;
  white-space: nowrap;
}
.rs::before {
  content: '';
  width: 13px;
  height: 13px;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--bi, var(--i-dash)) center / contain no-repeat;
  mask: var(--bi, var(--i-dash)) center / contain no-repeat;
}
.rs-none { color: var(--ink-2); border-color: var(--line-strong); background: transparent; }
.rs-req { --bi: var(--i-clock); color: var(--warn); border-color: var(--warn-line); background: var(--warn-soft); border-style: dashed; }
.rs-ok { --bi: var(--i-check); color: var(--ok); border-color: var(--ok-line); background: var(--ok-soft); }
.rs-no { --bi: var(--i-cross); color: var(--danger); border-color: var(--danger-line); background: var(--danger-soft); }
.rs-delay { --bi: var(--i-pause); color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); border-style: dashed; }
.signal {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: start;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--danger-line);
  background: var(--danger-soft);
}
.signal-warn {
  border-color: var(--warn-line);
  background: var(--warn-soft);
}
.plan-next {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
/* Wizardstappen (§6.18) */
.steps {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.steps li {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 20px;
  color: var(--ink-3);
  min-width: 0;
}
.steps li + li {
  border-left: 1px solid var(--line);
}
.steps .done {
  color: var(--ink-2);
}
.steps .cur {
  color: var(--ink);
  font-weight: 700;
  background: var(--accent-soft);
}
/* Bevestiging: rondje springt in, vinkje tekent zich (§7.2 #13) */
.done-mark {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-pill);
  background: var(--ok-soft);
  color: var(--ok);
  display: grid;
  place-items: center;
  border: 2px solid var(--ok-line);
  animation: pop var(--dur-3) var(--ease-spring) 80ms backwards;
}
.done-mark .ic {
  width: 36px;
  height: 36px;
  stroke-width: 2.2;
}
.done-mark path {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: draw-stroke 420ms var(--ease-out) 300ms backwards;
}
/* Postvak-regel schuift iets op bij hover (§7.2 #21) */
.msg {
  transition: background-color var(--dur-1) var(--ease-out), transform var(--dur-1) var(--ease-out);
}
@media (hover: hover) {
  .msg:hover {
    transform: translateX(2px);
  }
}
/* Instellingenmenu (§6.25) */
.settings {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
.setnav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 6px;
}
@media (max-width: 980px) {
  .settings {
    grid-template-columns: minmax(0, 1fr);
  }
  .setnav {
    flex-direction: row;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 4px;
  }
}
@media (max-width: 720px) {
  .state {
    grid-template-columns: minmax(0, 1fr);
  }
  .state > div + div {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .state > div {
    padding: 14px 16px;
  }
  .act {
    padding: 14px 16px;
    gap: 10px 12px;
  }
  .facts {
    gap: 12px 16px;
  }
  .steps li:not(.cur) .t {
    display: none;
  }
  .steps li:not(.cur) {
    flex: 0 0 auto;
  }
  .seg {
    max-width: 100%;
  }
}
