/* Boodschappen — fase 0 */

:root {
  --paper:   #F4F7F3;
  --surface: #FFFFFF;
  --sunk:    #EAEFE9;
  --ink:     #101E19;
  --muted:   #5B6F66;
  --faint:   #8A9C93;
  --line:    #D9E2DB;
  --accent:  #0C6A56;
  --accent-hover: #0A5646;
  --accent-zacht: #E3F0EA;
  --amber:   #96540E;
  --amber-zacht: #F8EEDF;
  --rood:    #9C3226;
  --rood-zacht: #F8E7E3;
  --radius: 10px;
  --schaduw: 0 1px 2px rgba(16, 30, 25, .05), 0 4px 12px rgba(16, 30, 25, .04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:   #0B1411;
    --surface: #121D19;
    --sunk:    #16241F;
    --ink:     #E4EDE8;
    --muted:   #93A89E;
    --faint:   #6E837A;
    --line:    #23342C;
    --accent:  #4FCCA8;
    --accent-hover: #6FDCBD;
    --accent-zacht: #13332A;
    --amber:   #DFA85F;
    --amber-zacht: #2C2418;
    --rood:    #E58676;
    --rood-zacht: #2E1B18;
    --schaduw: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

/* Moet vóór alle display-regels staan: anders wint .kaart{display:flex}
   van de standaard [hidden]{display:none} en blijven verborgen schermen zichtbaar. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 1.5rem; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; letter-spacing: -.01em; }
p  { margin: 0; }

/* ---------- laadscherm ---------- */

.laadscherm {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: var(--paper);
  z-index: 50;
}
.spinner {
  width: 26px; height: 26px;
  border: 2.5px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: draai .7s linear infinite;
}
@keyframes draai { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
}

/* ---------- layout ---------- */

.scherm {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 16px 56px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.scherm.smal { max-width: 400px; padding-top: 48px; min-height: 100dvh; justify-content: center; }

.merk { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 8px; }
.merk .sub { color: var(--muted); font-size: .9rem; }

/* Zelfde beeldmerk als het app-icoon, zodat de tegel op je homescreen
   en de kop in de app hetzelfde zijn. */
.merk-icoon {
  width: 52px; height: 52px;
  display: inline-block;
  flex: none;
  background: url("/icons/icon-192.png") center/contain no-repeat;
  border-radius: 12px;
}
.merk-icoon.klein { width: 32px; height: 32px; border-radius: 8px; }

/* ---------- balk ---------- */

.balk {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.balk-links { display: flex; align-items: center; gap: 10px; min-width: 0; }
.balk-links strong { display: block; font-size: .95rem; }
.balk-sub { display: block; font-size: .75rem; color: var(--faint); }

.live { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; color: var(--muted); }
.live i {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--faint);
  flex: none;
}
.live.aan i { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-zacht); }
.live.uit i { background: var(--rood); }

/* ---------- kaarten ---------- */

.kaart {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
  box-shadow: var(--schaduw);
}
.kaart form { display: flex; flex-direction: column; gap: 10px; }
.kaart hr { border: none; border-top: 1px solid var(--line); margin: 6px 0; width: 100%; }

.uitleg { color: var(--muted); font-size: .9rem; }
.hint { color: var(--faint); font-size: .8rem; margin-top: -4px; }

/* ---------- formulieren ---------- */

label { font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: -6px; }

input {
  width: 100%;
  font: inherit;
  font-size: 16px; /* voorkomt inzoomen op iOS */
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
}
input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.knop {
  font: inherit;
  font-weight: 600;
  font-size: .92rem;
  padding: 11px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--sunk);
  color: var(--ink);
  cursor: pointer;
  transition: background .12s ease;
}
.knop:hover { background: var(--line); }
.knop:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.knop[disabled] { opacity: .55; cursor: progress; }

.knop.primair { background: var(--accent); border-color: var(--accent); color: #fff; }
.knop.primair:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
@media (prefers-color-scheme: dark) {
  .knop.primair { color: #06201A; }
}
.knop.stil { background: none; border-color: var(--line); color: var(--muted); }
.knop.klein { padding: 6px 11px; font-size: .82rem; }
.knop.gevaar { color: var(--rood); }

.knoppen { display: flex; flex-wrap: wrap; gap: 8px; }
.knoppen.einde { justify-content: center; margin-top: 8px; }

.fout, .goed {
  font-size: .85rem;
  border-radius: 7px;
  padding: 9px 11px;
}
.fout { color: var(--rood); background: var(--rood-zacht); }
.goed { color: var(--accent); background: var(--accent-zacht); }

.melding {
  border-radius: var(--radius);
  padding: 13px 15px;
  font-size: .9rem;
  border-left: 3px solid var(--amber);
  background: var(--amber-zacht);
  color: var(--ink);
}

/* ---------- statistiek ---------- */

.stat {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.stat > div { background: var(--surface); padding: 10px 12px; }
.stat dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); }
.stat dd {
  margin: 2px 0 0;
  font-size: .95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- lijsten ---------- */

.lijst { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.lijst li {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.lijst li:last-child { border-bottom: none; }
.lijst .naam { font-weight: 600; font-size: .93rem; }
.lijst .meta { font-size: .78rem; color: var(--faint); }
.badge {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  background: var(--accent-zacht); color: var(--accent);
  padding: 2px 7px; border-radius: 99px; font-weight: 700;
}

.code-regel {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  background: var(--sunk);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
}
.code-regel code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .78rem;
  word-break: break-all;
  flex: 1 1 200px;
  color: var(--muted);
}

/* ---------- lijstscherm ---------- */

.lijstscherm { gap: 0; padding-top: 12px; }

.icoonknop {
  font: inherit;
  font-size: 1.15rem;
  line-height: 1;
  background: none;
  border: 1px solid transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 7px 9px;
  cursor: pointer;
}
.icoonknop:hover { background: var(--sunk); }
.icoonknop:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.balk-titel { min-width: 0; }
.balk-rechts { display: flex; align-items: center; gap: 6px; }

/* ---------- toevoegen ---------- */

.toevoegen {
  position: sticky;
  top: calc(53px + env(safe-area-inset-top));
  z-index: 9;
  display: flex;
  gap: 8px;
  padding: 10px 0 12px;
  background: var(--paper);
}
.toevoegen input { flex: 1; }

.knop.rond {
  width: 44px; height: 44px;
  flex: none;
  border-radius: 10px;
  font-size: 1.35rem;
  line-height: 1;
  padding: 0;
  display: grid;
  place-items: center;
}

.suggesties {
  position: absolute;
  top: calc(100% - 6px);
  left: 0; right: 52px;
  z-index: 20;
  list-style: none;
  margin: 0;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(16, 30, 25, .12);
  max-height: 44vh;
  overflow-y: auto;
}
@media (prefers-color-scheme: dark) {
  .suggesties { box-shadow: 0 8px 24px rgba(0, 0, 0, .45); }
}
.suggestie {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 11px;
  border-radius: 7px;
  cursor: pointer;
}
.suggestie:hover, .suggestie.actief { background: var(--accent-zacht); }
.suggestie-naam { font-size: .93rem; font-weight: 500; }
.suggestie-cat { font-size: .72rem; color: var(--faint); white-space: nowrap; }

/* ---------- secties ---------- */

.sectiekop {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 2px 6px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--faint);
}
.sectiekop.afgerond { padding-top: 26px; }
.sectieaantal { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- items ---------- */

.items {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--schaduw);
}

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.item:last-child { border-bottom: none; }
.item:active { background: var(--sunk); }

.vink {
  width: 26px; height: 26px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: none;
  cursor: pointer;
  position: relative;
  padding: 0;
}
.vink:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.item.af .vink { background: var(--accent); border-color: var(--accent); }
.item.af .vink::after {
  content: "";
  position: absolute;
  left: 7px; top: 3px;
  width: 6px; height: 12px;
  border: solid var(--surface);
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}
@media (prefers-color-scheme: dark) {
  .item.af .vink::after { border-color: #06201A; }
}

.item-midden { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.item-naam { font-size: .97rem; font-weight: 500; }
.item-meta { font-size: .76rem; color: var(--faint); }
.item.af .item-naam { text-decoration: line-through; color: var(--faint); font-weight: 400; }

.item-rechts { display: flex; align-items: center; gap: 4px; flex: none; }
.aantal {
  font-size: .78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--accent-zacht);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
}
.meer {
  font: inherit;
  font-size: 1.1rem;
  line-height: 1;
  background: none;
  border: none;
  color: var(--faint);
  padding: 6px 4px;
  cursor: pointer;
  border-radius: 6px;
}
.meer:hover { color: var(--ink); background: var(--sunk); }
.meer:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.leeg {
  color: var(--muted);
  font-size: .92rem;
  text-align: center;
  padding: 40px 24px;
  max-width: 34ch;
  margin: 0 auto;
}

.voetnoot {
  font-size: .78rem;
  color: var(--amber);
  text-align: center;
  padding: 16px 0 0;
}

.terug { align-self: flex-start; margin-bottom: 4px; }

/* ---------- detailvenster ---------- */

.sheet-achtergrond {
  position: fixed; inset: 0;
  background: rgba(16, 30, 25, .4);
  z-index: 30;
}
.sheet {
  position: fixed;
  left: 50%; bottom: 0;
  transform: translateX(-50%);
  width: min(440px, 100%);
  z-index: 31;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: 14px 14px 0 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 -6px 28px rgba(0, 0, 0, .18);
}
.sheet h3 { font-size: 1.1rem; margin-bottom: 2px; }

.aantalregel { display: flex; align-items: center; gap: 12px; padding: 4px 0 8px; }
.aantalgetal {
  font-size: 1.4rem; font-weight: 700; min-width: 2ch; text-align: center;
  font-variant-numeric: tabular-nums;
}
.eenheid { color: var(--muted); font-size: .9rem; }

.sheet select {
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  width: 100%;
}
.sheet select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.sheet-knoppen { justify-content: space-between; margin-top: 8px; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: 99px;
  font-size: .87rem;
  z-index: 40;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  max-width: calc(100vw - 32px);
}
