:root {
  --kleur: #2e7d4f;
  --kleur-donker: #23613d;
  --kleur-licht: #e6f2ea;
  --bg: #f4f5f3;
  --kaart: #ffffff;
  --tekst: #1d2420;
  --zacht: #6b746f;
  --lijn: #e2e5e1;
  --gevaar: #c0392b;
  --radius: 14px;
  --tabbar-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --kleur: #4caf7a;
    --kleur-donker: #3d9467;
    --kleur-licht: #1f3328;
    --bg: #121513;
    --kaart: #1c201d;
    --tekst: #e8ece9;
    --zacht: #9aa39e;
    --lijn: #2c322e;
    --gevaar: #e5736a;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--tekst);
  font-size: 16px;
  line-height: 1.35;
  overscroll-behavior-y: contain;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }

.laden { display: grid; place-items: center; min-height: 100vh; color: var(--zacht); }

/* ---------- Knoppen & velden ---------- */
.knop {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--kleur); color: #fff; border: 0; border-radius: 12px;
  padding: 12px 18px; font-weight: 600; min-height: 46px;
}
.knop:active { background: var(--kleur-donker); }
.knop:disabled { opacity: .6; }
.knop.breed { width: 100%; }
.knop.sec { background: var(--kleur-licht); color: var(--kleur-donker); }
@media (prefers-color-scheme: dark) { .knop.sec { color: var(--tekst); } }
.knop.tekst { background: none; color: var(--zacht); padding: 8px 10px; min-height: 0; font-weight: 500; }
.knop.gevaar { background: none; color: var(--gevaar); border: 1px solid var(--gevaar); }
.knop.klein { padding: 7px 12px; min-height: 36px; font-size: 14px; border-radius: 10px; }

label { display: block; font-size: 14px; color: var(--zacht); margin: 0 0 14px; }
input:not([type=checkbox]):not([type=file]), textarea, select {
  display: block; width: 100%; margin-top: 6px;
  padding: 12px; border: 1px solid var(--lijn); border-radius: 12px;
  background: var(--kaart); font-size: 16px; /* 16px voorkomt inzoomen op iPhone */
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--kleur); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 80px; resize: vertical; }
label.check { display: flex; align-items: center; gap: 10px; color: var(--tekst); font-size: 16px; }
label.check input { width: 22px; height: 22px; accent-color: var(--kleur); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-kaart { width: 100%; max-width: 380px; background: var(--kaart); border-radius: 20px; padding: 28px 24px; box-shadow: 0 6px 30px rgba(0,0,0,.08); text-align: center; }
.login-kaart form { text-align: left; margin-top: 18px; }
.login-logo { width: 72px; height: 72px; border-radius: 18px; }
.login h1 { margin: 12px 0 2px; }
.sub { color: var(--zacht); margin: 0; }
.fout { color: var(--gevaar); font-size: 14px; margin: 12px 0 0; }

/* ---------- Layout ---------- */
.kop {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 10px;
  background: var(--kleur); color: #fff;
}
.kop h1 { font-size: 20px; margin: 0; }
.offline { background: rgba(0,0,0,.25); padding: 3px 10px; border-radius: 99px; font-size: 13px; }
main { padding: 0 0 calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 90px); max-width: 720px; margin: 0 auto; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--kaart); border-top: 1px solid var(--lijn);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; height: var(--tabbar-h); background: none; border: 0; position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; color: var(--zacht);
}
.tabbar .ico { font-size: 22px; filter: grayscale(1); opacity: .7; }
.tabbar button.actief { color: var(--kleur); font-weight: 600; }
.tabbar button.actief .ico { filter: none; opacity: 1; }
.badge {
  position: absolute; top: 6px; left: calc(50% + 6px);
  background: var(--gevaar); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; display: grid; place-items: center;
}

.zoekbalk { padding: 12px 16px 6px; position: sticky; top: calc(env(safe-area-inset-top) + 50px); z-index: 5; background: var(--bg); }
.zoekbalk input { margin: 0; border-radius: 99px; padding-left: 16px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 6px 16px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--lijn); background: var(--kaart); border-radius: 99px;
  padding: 7px 14px; font-size: 14px; white-space: nowrap;
}
.chip.actief { background: var(--kleur); border-color: var(--kleur); color: #fff; }
.chip .n { opacity: .7; margin-left: 4px; }

.groep-titel { margin: 14px 16px 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--zacht); font-weight: 700; display: flex; justify-content: space-between; align-items: center; }

.kaartlijst { background: var(--kaart); border-radius: var(--radius); margin: 0 12px; overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--lijn); min-height: 68px; }
.item:last-child { border-bottom: 0; }
.thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex: none; background: var(--kleur-licht); display: grid; place-items: center; font-size: 22px; }
.info { flex: 1; min-width: 0; cursor: pointer; }
.naam { font-weight: 600; overflow-wrap: anywhere; }
.aantal { display: inline-block; background: var(--kleur-licht); color: var(--kleur-donker); border-radius: 6px; padding: 0 7px; font-size: 13px; font-weight: 700; margin-left: 4px; vertical-align: 1px; }
@media (prefers-color-scheme: dark) { .aantal { color: var(--tekst); } }
.omschr { color: var(--zacht); font-size: 14px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.meta { color: var(--zacht); font-size: 12px; margin-top: 2px; }

.vink {
  flex: none; width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--kleur); background: transparent; color: transparent;
  font-size: 20px; font-weight: 700; display: grid; place-items: center;
}
.item.gekocht .vink { background: var(--kleur); color: #fff; }
.item.gekocht .naam { text-decoration: line-through; color: var(--zacht); }
.item.gekocht .thumb { opacity: .5; }

.plusknop { flex: none; border: 0; border-radius: 10px; padding: 8px 12px; background: var(--kleur); color: #fff; font-weight: 600; font-size: 14px; white-space: nowrap; }
.plusknop.op { background: var(--kleur-licht); color: var(--kleur-donker); }
@media (prefers-color-scheme: dark) { .plusknop.op { color: var(--tekst); } }

.leeg-melding { text-align: center; color: var(--zacht); padding: 40px 24px; }
.leeg-melding .groot { font-size: 46px; }

.zoekresultaten { background: var(--kaart); margin: 4px 12px 10px; border-radius: var(--radius); box-shadow: 0 4px 18px rgba(0,0,0,.08); overflow: hidden; }
.zoekresultaten .item { min-height: 60px; }
.zoekresultaten .thumb { width: 42px; height: 42px; font-size: 18px; }
.nieuw-rij { color: var(--kleur); font-weight: 600; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 18px); z-index: 15;
  width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: var(--kleur); color: #fff; font-size: 30px; box-shadow: 0 6px 18px rgba(0,0,0,.25);
}

/* ---------- Instellingen ---------- */
.sectie { background: var(--kaart); border-radius: var(--radius); margin: 14px 12px; padding: 16px; }
.sectie h2 { font-size: 17px; margin: 0 0 12px; }
.sectie p { margin: 0 0 10px; color: var(--zacht); font-size: 14px; }
.winkel-rij { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--lijn); }
.winkel-rij:last-of-type { border-bottom: 0; }
.winkel-rij span { flex: 1; }
.inline-form { display: flex; gap: 8px; margin-top: 12px; }
.inline-form input { margin: 0 !important; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal-achtergrond { position: absolute; inset: 0; background: rgba(0,0,0,.45); }
.modal-blad {
  position: relative; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  background: var(--bg); border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(env(safe-area-inset-bottom) + 20px);
  animation: omhoog .2s ease-out;
}
@media (min-width: 600px) { .modal { align-items: center; } .modal-blad { border-radius: 20px; } }
@keyframes omhoog { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
.modal-blad h2 { margin: 0 0 16px; font-size: 20px; }
.acties { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.acties .knop { flex: 1; }

.foto-veld { width: 100%; aspect-ratio: 4 / 3; border-radius: var(--radius); background: var(--kleur-licht); display: grid; place-items: center; overflow: hidden; margin-bottom: 10px; color: var(--zacht); }
.foto-veld img { width: 100%; height: 100%; object-fit: cover; }
.foto-knoppen { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.foto-knoppen .knop { flex: 1; }
.waarschuwing { background: #fff4d6; color: #6b5200; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: -6px 0 14px; }
@media (prefers-color-scheme: dark) { .waarschuwing { background: #3a3218; color: #f1dc9b; } }
.waarschuwing button { background: none; border: 0; color: inherit; text-decoration: underline; padding: 0; font-weight: 600; }

.detail-foto { width: 100%; max-height: 50vh; object-fit: contain; border-radius: var(--radius); background: var(--kaart); margin-bottom: 14px; cursor: zoom-in; }
.detail-omschr { white-space: pre-wrap; margin: 0 0 8px; }
.detail-meta { color: var(--zacht); font-size: 14px; margin-bottom: 16px; }

/* ---------- Lightbox & toast ---------- */
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.92); display: grid; place-items: center; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 70;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 90px);
  background: #222; color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 15px;
  max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.3); text-align: center;
}
.toast.fout { background: var(--gevaar); }
