:root {
  --bg: #f6f4f0;
  --surface: #ffffff;
  --surface-2: #ecebe6;
  --text: #1b1f1e;
  --muted: #5f6b67;
  --line: #dcdad4;
  --brand: #144d43;
  --brand-text: #ffffff;
  --accent: #7ad1b4;
  --danger: #a8332a;
  --warn: #8a5a12;
  --radius: 14px;
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --surface: #1b2220;
    --surface-2: #252e2b;
    --text: #eef2f0;
    --muted: #9aa8a3;
    --line: #313b38;
    --brand: #7ad1b4;
    --brand-text: #0d1614;
    --accent: #7ad1b4;
    --danger: #ef8a80;
    --warn: #e0b661;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- structuur ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--brand);
  color: var(--brand-text);
  padding: max(env(safe-area-inset-top), 10px) 16px 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar h1 { font-size: 1.15rem; margin: 0; flex: 1; font-weight: 650; }

.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 9;
}
.tabs button {
  flex: 1;
  min-height: var(--tap);
  border: 0;
  background: none;
  padding: 12px 4px;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--brand); font-weight: 600; }

main { padding: 14px 14px 96px; max-width: 780px; margin: 0 auto; }

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

.grid { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .grid { grid-template-columns: 1fr 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  align-items: center;
}
.card.low { border-color: var(--warn); }

.thumb {
  width: 64px; height: 64px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--surface-2);
  display: grid; place-items: center;
  color: var(--muted);
  font-size: 1.4rem;
  border: 0;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
}

.card-body { min-width: 0; text-align: left; background: none; border: 0; padding: 0; cursor: pointer; }
.card-body .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-body .meta {
  color: var(--muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-body .meta.warn { color: var(--warn); }

.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button {
  width: var(--tap); height: var(--tap);
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 1.3rem;
  cursor: pointer;
}
.stepper button:active { background: var(--brand); color: var(--brand-text); }
.stepper .qty { min-width: 3ch; text-align: center; font-variant-numeric: tabular-nums; font-weight: 650; }

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

label { display: block; margin: 12px 0 4px; font-size: 0.88rem; color: var(--muted); }
input, select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
textarea { min-height: 78px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.btn {
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  cursor: pointer;
}
.btn.primary { background: var(--brand); color: var(--brand-text); border-color: transparent; font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  width: 58px; height: 58px;
  border-radius: 50%;
  border: 0;
  background: var(--brand);
  color: var(--brand-text);
  font-size: 1.9rem;
  line-height: 1;
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.22);
  cursor: pointer;
  z-index: 20;
}

/* ---------- lijst en overig ---------- */

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.list li.done { opacity: 0.55; }
.list li.done .label { text-decoration: line-through; }
.list input[type="checkbox"] { width: 24px; height: 24px; min-height: 0; flex: none; }
.list .label { flex: 1; min-width: 0; }

h2 { font-size: 1rem; margin: 22px 0 8px; color: var(--muted); font-weight: 600; }
.empty { color: var(--muted); text-align: center; padding: 40px 16px; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 6px 0 0; }
.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.78rem;
  color: var(--muted);
}
.pill.warn { background: var(--warn); color: #fff; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface-2);
  padding: 3px 6px;
  border-radius: 6px;
  word-break: break-all;
  font-size: 0.9em;
}

dialog {
  border: 0;
  border-radius: 16px 16px 0 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  width: 100%;
  max-width: 620px;
  max-height: 92vh;
  margin: auto auto 0;
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
.sheet { padding: 16px 16px calc(20px + env(safe-area-inset-bottom)); overflow-y: auto; max-height: 92vh; }
.sheet h2 { margin-top: 0; color: var(--text); font-size: 1.1rem; }

.centre { max-width: 380px; margin: 12vh auto; padding: 0 20px; text-align: center; }
.centre img { width: 76px; height: 76px; }
.centre p { color: var(--muted); }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 40;
  max-width: 88vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.offline-banner {
  background: var(--warn);
  color: #fff;
  text-align: center;
  padding: 6px 12px;
  font-size: 0.85rem;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Hulpklassen. Bewust geen style-attributen in de JavaScript: het
   Content-Security-Policy staat alleen stylesheets van de eigen site toe. */
.gap-lg { margin-top: 16px; }
.gap-md { margin-top: 10px; }
.hidden { display: none; }

.photo-preview {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 12px;
}

.scanner {
  width: 100%;
  border-radius: 12px;
  background: #000;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}
