/* ===== Contractkompas – opmaak ===== */

/* Lettertypes staan in de app zelf (map fonts/), dus geen verbinding met Google nodig.
   Beide vallen onder de SIL Open Font License (zie fonts/LICENSE-*.txt). */
@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('../fonts/bricolage-grotesque-latin-opsz-normal.woff2') format('woff2');
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --achtergrond: #F3F4EF;
  --kaart: #FFFFFF;
  --tekst: #17201C;
  --tekst-zacht: #5B635F;
  --tekst-midden: #3F4743;
  --lijn: #F0F1EC;
  --rand: #E8EAE4;
  --donker: #10392F;
  --donker-2: #1A4A3E;
  --donker-zacht: #B9D3C9;
  --lime: #C6F36B;
  --lime-zacht: #E9F8CF;
  --rood: #B42318;   --rood-bg: #FDE8E5;
  --oranje: #9A4A00; --oranje-bg: #FDF0DC;
  --groen: #2F5E0E;  --groen-bg: #E9F8CF;
  --grijs: #3F4743;  --grijs-bg: #EEF0EA;
  --schaduw: 0 1px 2px rgba(16, 57, 47, 0.06);
  --kop: 'Bricolage Grotesque', Inter, system-ui, sans-serif;
  --veilig-onder: env(safe-area-inset-bottom, 0px);
  --veilig-boven: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
/* De pagina zelf scrolt niet: alleen het middengedeelte (.scherm). Zo blijft de tabbalk altijd staan. */
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--achtergrond);
  color: var(--tekst);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input::placeholder, textarea::placeholder { color: #6B736F; }
:focus-visible { outline: 3px solid #5B8DEF; outline-offset: 2px; }

.verborgen {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.app {
  max-width: 520px; margin: 0 auto; position: relative;
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
}
.scherm {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain;
  padding: calc(20px + var(--veilig-boven)) 20px 100px;
  display: flex; flex-direction: column; gap: 18px;
  outline: none;
}
/* Niets in het scrollgebied mag in elkaar gedrukt worden; ook niet de onderdelen
   van formulieren (die staan via display: contents direct in het scherm). */
.scherm > *, .scherm > form > * { flex-shrink: 0; }
.scherm.met-kop { padding-top: 0; }

/* ----- Koppen ----- */
.paginakop { display: flex; align-items: center; gap: 10px; padding-top: 12px; }
.logo {
  width: 38px; height: 38px; border-radius: 12px; background: var(--lime); color: var(--donker);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
h1 { margin: 0; font-family: var(--kop); font-size: 30px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.sectiekop {
  margin: 0; font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--tekst-zacht);
}
.sectiekop.waarschuwing { color: var(--oranje); }
.kaartkop { margin: 0; font-family: var(--kop); font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.sectie { display: flex; flex-direction: column; gap: 8px; }
.uitleg { margin: 0; color: var(--tekst-zacht); line-height: 1.5; font-size: 14px; }

/* ----- Samenvatting ----- */
.samenvatting {
  padding: 16px 18px; border-radius: 20px; background: var(--donker); color: #fff;
  display: flex; justify-content: space-between; align-items: flex-end; gap: 12px;
}
.samenvatting .label { font-size: 13px; color: var(--donker-zacht); }
.samenvatting .groot { display: block; font-family: var(--kop); font-size: 30px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.samenvatting .rechts { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.samenvatting .klein { font-size: 15px; font-weight: 600; }

/* ----- Zoeken en filters ----- */
.zoekveld {
  display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 14px;
  background: var(--kaart); border-radius: 14px; box-shadow: var(--schaduw); color: var(--tekst-zacht);
}
.zoekveld input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 16px; color: var(--tekst); }
.chips {
  display: flex; gap: 8px; overflow-x: auto; margin: 0 -20px; padding: 2px 20px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; height: 36px; padding: 0 14px; border-radius: 18px; border: 0;
  background: var(--kaart); color: var(--tekst); font-size: 14px; font-weight: 600;
}
.chip[aria-pressed="true"] { background: var(--donker); color: #fff; }

/* ----- Contractrijen ----- */
.lijst { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rij {
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  background: var(--kaart); border: 0; border-radius: 18px; box-shadow: var(--schaduw); text-align: left;
}
.rij-midden { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.rij-naam {
  font-weight: 600; font-size: 16px; line-height: 1.25; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: break-word;
  -webkit-hyphens: auto; hyphens: auto;
}
.rij-sub { font-size: 13px; line-height: 1.3; color: var(--tekst-zacht); }
.rij-bedrag { font-weight: 600; flex-shrink: 0; }
.rij-bedrag small { font-size: 12px; font-weight: 400; color: var(--tekst-zacht); }
.rij.opgezegd .rij-naam { color: var(--tekst-zacht); text-decoration: line-through; }

.tegel {
  width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg, #ECEEEA); color: var(--fg, #3F4743);
}
.tegel.klein { width: 40px; height: 40px; border-radius: 12px; }
.tegel.groot { width: 60px; height: 60px; border-radius: 18px; background: #fff; }

.dagentegel { flex-direction: column; gap: 0; line-height: 1; }
.dagentegel strong { font-family: var(--kop); font-size: 18px; font-weight: 800; }
.dagentegel span { font-size: 10px; font-weight: 600; margin-top: 2px; }

.chips { cursor: grab; user-select: none; -webkit-user-select: none; }
.chips:active { cursor: grabbing; }

.dagenblok {
  flex-shrink: 0; min-width: 64px; padding: 6px 10px; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center;
}
.dagenblok strong { font-family: var(--kop); font-size: 22px; font-weight: 800; line-height: 1.1; }
.dagenblok span { font-size: 11px; font-weight: 600; }

.toon-rood   { background: var(--rood-bg);   color: var(--rood); }
.toon-oranje { background: var(--oranje-bg); color: var(--oranje); }
.toon-groen  { background: var(--groen-bg);  color: var(--groen); }
.toon-grijs  { background: var(--grijs-bg);  color: var(--grijs); }

.leeg {
  text-align: center; padding: 32px 16px; display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: var(--kaart); border-radius: 20px; box-shadow: var(--schaduw);
}
.leeg p { margin: 0; color: var(--tekst-zacht); line-height: 1.5; }

/* ----- Zwevende knop ----- */
.fab {
  position: fixed; right: max(20px, calc(50% - 240px)); bottom: calc(100px + var(--veilig-onder));
  width: 60px; height: 60px; border-radius: 20px; border: 0; background: var(--lime); color: var(--donker);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 20px rgba(16, 57, 47, 0.25);
  z-index: 5;
}

/* ----- Knoppen ----- */
.knop {
  height: 52px; border-radius: 16px; border: 0; padding: 0 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 16px; font-weight: 600;
}
.knop-primair { background: var(--donker); color: #fff; }
.knop-secundair { background: var(--kaart); color: var(--tekst); box-shadow: 0 1px 2px rgba(16, 57, 47, 0.08); }
.knop-lime { background: var(--lime); color: var(--donker); }
.knop-gevaar { background: var(--rood-bg); color: var(--rood); }
.knop-klein { height: 44px; border-radius: 14px; font-size: 15px; padding: 0 16px; }
.knop-rond { width: 44px; height: 44px; padding: 0; border-radius: 14px; }
.knop-blok { width: 100%; }

.balk-boven { display: flex; justify-content: space-between; align-items: center; padding-top: calc(12px + var(--veilig-boven)); }

/* ----- Detail ----- */
.detailkop {
  margin: 0 -20px; padding: 16px 20px 24px; border-radius: 0 0 32px 32px;
  background: var(--bg); display: flex; flex-direction: column; gap: 18px;
}
.detailkop .balk-boven .knop { background: #fff; color: var(--tekst); }
.detail-titel { display: flex; align-items: center; gap: 14px; }
.detail-titel > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.detail-cat { font-size: 13px; font-weight: 600; color: var(--fg); }
.detail-aanbieder { font-size: 14px; color: var(--tekst-midden); }
.tweeluik { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mini { padding: 12px 14px; border-radius: 16px; background: #fff; display: flex; flex-direction: column; gap: 2px; }
.mini span { font-size: 12px; color: var(--tekst-zacht); }
.mini strong { font-size: 20px; }

.statusbalk { padding: 14px 16px; border-radius: 16px; display: flex; align-items: center; gap: 10px; }
.statusbalk .stip { width: 10px; height: 10px; border-radius: 5px; background: currentColor; flex-shrink: 0; }
.statusbalk .tekst { display: flex; flex-direction: column; gap: 2px; }
.statusbalk .titel { font-size: 14px; font-weight: 600; }
.statusbalk .sub { font-size: 13px; color: var(--tekst-midden); }

.feiten { margin: 0; background: var(--kaart); border-radius: 20px; overflow: hidden; box-shadow: var(--schaduw); }
.feiten > div { display: flex; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--lijn); }
.feiten > div:last-child { border-bottom: 0; }
.feiten dt { color: var(--tekst-zacht); }
.feiten dd { margin: 0; font-weight: 600; text-align: right; }

.kaart { padding: 16px; background: var(--kaart); border-radius: 20px; box-shadow: var(--schaduw); display: flex; flex-direction: column; gap: 8px; }
.notitie { margin: 0; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ----- Formulieren ----- */
form { display: contents; }
.veldgroep {
  margin: 0; padding: 0; border: 0; background: var(--kaart); border-radius: 20px;
  box-shadow: var(--schaduw); display: flex; flex-direction: column; overflow: hidden;
}
.veldgroep legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.veld { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; border-bottom: 1px solid var(--lijn); min-width: 0; }
.veld:last-child { border-bottom: 0; }
.veld > span { font-size: 12px; color: var(--tekst-zacht); }
.veld input, .veld select, .veld textarea {
  border: 0; outline: none; background: transparent; font-size: 16px; padding: 2px 0;
  width: 100%; min-width: 0; color: var(--tekst);
}
.veld textarea { resize: vertical; }
.veld input[type="date"] { min-height: 24px; -webkit-appearance: none; appearance: none; }
.veldrij { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-bottom: 1px solid var(--lijn); }
.veldrij:last-child { border-bottom: 0; }
.veldrij .veld { border-bottom: 0; }
.veldrij .veld:first-child { border-right: 1px solid var(--lijn); }
.schakel { flex-direction: row; justify-content: space-between; align-items: center; padding: 14px 16px; }
.schakel > span { font-size: 15px; color: var(--tekst); }
.schakel input { width: 24px; height: 24px; accent-color: var(--donker); flex-shrink: 0; }
.veld-fout { color: var(--rood); font-size: 13px; margin: 0; }

.tip { display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: var(--lime-zacht); color: var(--donker); }
.tip p { margin: 0; font-size: 13px; line-height: 1.5; }
.tip svg { flex-shrink: 0; }

/* Keuzetegels (categorie, kleur, icoon) */
.keuze-raster { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.keuze { position: relative; }
.keuze input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.keuze .vak {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; min-height: 72px;
  border-radius: 16px; border: 2px solid transparent; background: var(--kaart); color: var(--fg);
  text-align: center; justify-content: center;
}
.keuze .vak span {
  font-size: 11px; font-weight: 600; line-height: 1.2; color: var(--tekst);
  -webkit-hyphens: auto; hyphens: auto; overflow-wrap: break-word; max-width: 100%;
}
.keuze input:checked + .vak { background: var(--bg); border-color: var(--fg); }
.keuze input:focus-visible + .vak { outline: 3px solid #5B8DEF; outline-offset: 2px; }

.kleuren { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.kleuren .vak { width: 100%; max-width: 48px; aspect-ratio: 1; height: auto; min-height: 0; padding: 0; margin: 0 auto; border-radius: 50%; border: 3px solid #fff; background: var(--balk); box-shadow: var(--schaduw); }
.kleuren input:checked + .vak { border-color: var(--tekst); background: var(--balk); }

.iconen { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; padding: 12px; background: var(--kaart); border-radius: 20px; box-shadow: var(--schaduw); }
.iconen .vak { min-height: 46px; padding: 0; border-radius: 14px; background: var(--achtergrond); color: var(--tekst-midden); }
.iconen input:checked + .vak { background: var(--bg); color: var(--fg); border-color: var(--fg); }

.voorbeeld { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 20px; background: var(--bg); }
.voorbeeld .tegel.groot { color: var(--fg); }
.voorbeeld small { font-size: 12px; color: var(--tekst-midden); }
.voorbeeld strong { display: block; font-size: 18px; color: var(--fg); }

/* ----- Overzicht ----- */
.totalen { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.totaal { padding: 16px; border-radius: 20px; display: flex; flex-direction: column; gap: 4px; }
.totaal span { font-size: 13px; }
.totaal strong { font-family: var(--kop); font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.totaal.donker { background: var(--donker); color: #fff; }
.totaal.donker span { color: var(--donker-zacht); }
.totaal.licht { background: var(--lime); color: var(--donker); }
.totaal.licht span { color: #24503F; }

.verdeling { display: flex; height: 14px; border-radius: 7px; overflow: hidden; gap: 3px; }
.verdeling div { height: 14px; border-radius: 4px; }
.catregel { display: flex; align-items: center; gap: 12px; }
.catregel .midden { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.catregel .midden span:first-child { font-weight: 600; }
.catregel .midden span:last-child { font-size: 12px; color: var(--tekst-zacht); }

.moment {
  display: flex; align-items: center; gap: 12px; padding: 10px 0; border: 0; border-bottom: 1px solid var(--lijn);
  background: transparent; text-align: left; width: 100%;
}
.moment:last-of-type { border-bottom: 0; }
.datumblok { width: 52px; flex-shrink: 0; padding: 6px 0; border-radius: 12px; display: flex; flex-direction: column; align-items: center; }
.datumblok strong { font-size: 16px; line-height: 1.1; }
.datumblok span { font-size: 11px; font-weight: 600; }
.moment .midden { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.moment .midden span:first-child { font-weight: 600; }
.moment .midden span:last-child { font-size: 12px; color: var(--tekst-zacht); }

/* ----- Instellingen ----- */
.lijstkaart { display: flex; flex-direction: column; background: var(--kaart); border-radius: 20px; overflow: hidden; box-shadow: var(--schaduw); }
.lijstregel {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--lijn);
  background: transparent; text-align: left; width: 100%; min-height: 56px;
}
.lijstregel:last-child { border-bottom: 0; }
.lijstregel .midden { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lijstregel .midden span:first-child { font-weight: 600; }
.lijstregel .midden span:last-child { font-size: 12px; color: var(--tekst-zacht); }
.lijstregel.toevoegen { color: var(--donker); font-weight: 600; }
.stippelvak { width: 40px; height: 40px; border-radius: 12px; border: 2px dashed #B9C2BC; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.instelregel { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--lijn); }
.instelregel:last-child { border-bottom: 0; }
.instelregel > span { font-weight: 500; }
.instelregel select { border: 0; background: transparent; color: var(--donker); font-size: 15px; font-weight: 600; text-align: right; }
.instelregel input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--donker); }
.instel-uitleg { padding: 0 16px 14px; margin: -6px 0 0; font-size: 13px; color: var(--tekst-zacht); line-height: 1.5; }
.voetnoot { text-align: center; font-size: 12px; color: var(--tekst-zacht); margin: 8px 0 0; }

/* ----- Tabbalk ----- */
.tabbalk {
  flex-shrink: 0; width: 100%;
  padding: 8px 12px calc(14px + var(--veilig-onder)); background: #fff; border-top: 1px solid var(--rand);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); z-index: 10;
}
.tab {
  border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: #6B736F; font-size: 11px; font-weight: 600; padding: 2px 0;
}
.tab-pil { width: 56px; height: 30px; border-radius: 15px; display: flex; align-items: center; justify-content: center; }
.tab[aria-current="page"] { color: var(--donker); }
.tab[aria-current="page"] .tab-pil { background: var(--lime); }

/* ----- Melding ----- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(100px + var(--veilig-onder));
  width: calc(100% - 40px); max-width: 480px; padding: 14px 16px; border-radius: 16px;
  background: var(--donker); color: #fff; font-size: 14px; display: flex; align-items: center; gap: 10px;
  box-shadow: 0 8px 20px rgba(16, 57, 47, 0.3); z-index: 20;
}
.toast[hidden] { display: none; }
.toast svg { flex-shrink: 0; color: var(--lime); }

@media (prefers-reduced-motion: no-preference) {
  .toast:not([hidden]) { animation: omhoog 0.2s ease-out; }
  @keyframes omhoog { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
}
