/* Klunen Draaiboek — mobile-first, want de app wordt vooral op straat gebruikt. */

:root {
  color-scheme: light dark;

  --accent: #d13c31;
  --accent-strong: #b32f26;
  --accent-soft: rgba(209, 60, 49, 0.12);

  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #dfe2e8;
  --text: #16181d;
  --muted: #626a78;
  --ok: #1f8a53;
  --ok-soft: rgba(31, 138, 83, 0.12);
  --warn: #a86b00;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 18, 24, 0.06), 0 6px 20px rgba(16, 18, 24, 0.07);
  --tap: 44px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #f0655a;
    --accent-strong: #ff7d72;
    --accent-soft: rgba(240, 101, 90, 0.16);
    --bg: #14161c;
    --surface: #1c1f27;
    --surface-2: #232733;
    --border: #313745;
    --text: #eef0f4;
    --muted: #9aa3b2;
    --ok: #4ade80;
    --ok-soft: rgba(74, 222, 128, 0.14);
    --warn: #fbbf24;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

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%;
  overscroll-behavior-y: none;
}

h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }

/* ---------- app shell ---------- */

.app { min-height: 100%; display: flex; flex-direction: column; }

.boot {
  min-height: 70vh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--muted);
}

.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar__brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar__logo { width: 30px; height: 30px; flex: none; }
.topbar__title { font-size: 17px; font-weight: 680; white-space: nowrap; }
.topbar__spacer { margin-left: auto; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  max-width: 46vw;
}
.chip__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip--role { font-variant: small-caps; letter-spacing: 0.04em; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot--live { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.dot--offline { background: var(--warn); }

.main { flex: 1; padding: 16px 14px calc(84px + var(--safe-bottom)); }
.view { max-width: 940px; margin: 0 auto; display: grid; gap: 14px; }

.view__head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.view__head h2 { font-size: 22px; }
.view__sub { color: var(--muted); font-size: 14px; }
.view__actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- navigatie ---------- */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 6px 6px calc(6px + var(--safe-bottom));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}

.tabbar__item {
  display: grid;
  justify-items: center;
  gap: 3px;
  padding: 7px 2px;
  min-height: var(--tap);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.tabbar__item svg { width: 21px; height: 21px; }
.tabbar__item[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

@media (min-width: 860px) {
  .tabbar {
    position: sticky;
    top: 51px;
    bottom: auto;
    grid-auto-flow: row;
    grid-auto-columns: auto;
    width: 210px;
    align-self: start;
    background: transparent;
    border: 0;
    backdrop-filter: none;
    padding: 16px 8px;
  }
  .tabbar__item {
    grid-auto-flow: column;
    justify-items: start;
    justify-content: start;
    gap: 11px;
    font-size: 14px;
    padding: 10px 12px;
  }
  .layout { display: grid; grid-template-columns: 210px 1fr; align-items: start; }
  .main { padding: 20px 20px 40px; }
}

/* ---------- knoppen en velden ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; }

.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--danger { color: #fff; background: #c0392b; border-color: #c0392b; }
.btn--sm { min-height: 34px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn--block { width: 100%; }
.btn--icon { padding: 0; width: var(--tap); }

.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }

.input,
.textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.textarea { min-height: 84px; resize: vertical; }
.input:focus-visible,
.textarea:focus-visible,
.btn:focus-visible,
.tabbar__item:focus-visible,
.row__check:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.searchbar { position: relative; display: flex; gap: 8px; flex-wrap: wrap; }
.searchbar .input { flex: 1 1 200px; }

/* ---------- kaarten en lijsten ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-weight: 650;
  font-size: 14px;
}
.card__body { padding: 12px 14px; display: grid; gap: 10px; }

.list { display: grid; gap: 10px; }

.row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.row--now { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.row--done .row__what { text-decoration: line-through; color: var(--muted); }
.row--done { opacity: 0.72; }

.row__check {
  width: 26px; height: 26px;
  margin-top: 2px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--surface);
  display: grid;
  place-content: center;
  cursor: pointer;
  flex: none;
  color: transparent;
}
.row__check[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }
.row__check svg { width: 15px; height: 15px; }
.row__check:disabled { cursor: default; opacity: 0.6; }

.row__main { min-width: 0; display: grid; gap: 3px; }
.row__when { font-size: 13px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.row__what { font-weight: 560; overflow-wrap: anywhere; }
.row__who { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.row__side { display: flex; gap: 4px; align-items: center; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.badge--muted { background: var(--surface-2); color: var(--muted); }

/* ---------- bands ---------- */

.slot { display: grid; gap: 0; }
.slot__grid { display: grid; gap: 1px; background: var(--border); }
.slot__cell { display: grid; gap: 2px; padding: 10px 14px; background: var(--surface); }
.slot__loc { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.slot__band { overflow-wrap: anywhere; }
.slot__cell--empty .slot__band { color: var(--muted); font-style: italic; }

@media (min-width: 720px) {
  .slot__grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

/* ---------- plattegrond ---------- */

.map { display: grid; gap: 10px; }
.map__frame {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: auto;
  box-shadow: var(--shadow);
  max-height: 72vh;
  touch-action: pan-x pan-y pinch-zoom;
}
.map__img { display: block; width: 100%; height: auto; transform-origin: 0 0; }
.map__img--zoom { width: auto; max-width: none; cursor: zoom-out; }

/* ---------- notities ---------- */

.note { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: start; }
.note__text { white-space: pre-wrap; overflow-wrap: anywhere; }
.note__meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.note--done .note__text { text-decoration: line-through; color: var(--muted); }

/* ---------- login ---------- */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 18px; }
.login__card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 26px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.login__brand { display: grid; justify-items: center; gap: 10px; text-align: center; }
.login__brand svg { width: 54px; height: 54px; }
.login__brand p { color: var(--muted); font-size: 14px; }
.login__divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}
.login__divider::before,
.login__divider::after { content: ""; height: 1px; background: var(--border); }

/* ---------- meldingen ---------- */

.alert {
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 14px;
}
.alert--error { border-color: color-mix(in srgb, #c0392b 45%, var(--border)); background: rgba(192, 57, 43, 0.1); }
.alert--warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); background: rgba(168, 107, 0, 0.1); }

.empty { padding: 26px 16px; text-align: center; color: var(--muted); display: grid; gap: 6px; }

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(88px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 60;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100vw - 28px));
  pointer-events: none;
}
.toast {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: toast-in 0.18s ease;
}
.toast--error { border-color: color-mix(in srgb, #c0392b 55%, var(--border)); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (min-width: 860px) {
  .toasts { bottom: 22px; }
}

/* ---------- bewerken ---------- */

.editor { display: grid; gap: 10px; }
.editor__row {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.editor__grid { display: grid; gap: 8px; }
.editor__tools { display: flex; gap: 6px; justify-content: flex-end; }

@media (min-width: 720px) {
  .editor__grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
}

.sticky-actions {
  position: sticky;
  bottom: calc(78px + var(--safe-bottom));
  display: flex;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 10;
}
@media (min-width: 860px) { .sticky-actions { bottom: 14px; } }

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