/* ─────────────────────────────────────────────────────────
   SMK Voorraad — Smaakverkenners huisstijl
   Palette geplukt van smaakverkenners.nl:
     cream #fcf7ea · terra #ee7b3e · teal #3e827a / #1f5046 · deep #1e3d35
   ───────────────────────────────────────────────────────── */

:root {
  /* grond en oppervlak */
  --bg:          #fcf7ea;
  --bg-elev:     #fffbf8;
  --bg-soft:     #f6ead4;
  --bg-band:     #f2e6cf;
  --border:      #ecdfc4;
  --border-strong: #d9c8a2;

  /* tekst */
  --text:        #1e3d35;
  --text-muted:  #3e827a;
  --text-dim:    #7ba99e;

  /* accent + secundair */
  --accent:       #ee7b3e;
  --accent-hov:   #d96924;
  --accent-soft:  #fbe4cf;
  --accent-tint:  #f3c189;

  --teal:        #3e827a;
  --teal-deep:   #1f5046;

  /* semantic */
  --good:        #3e827a;
  --warn:        #ee7b3e;
  --crit:        #c8452e;
  --info:        #1a5579;

  --good-bg:     #dfeceb;
  --warn-bg:     #fbe4cf;
  --crit-bg:     #f5d5cc;
  --info-bg:     #dce6ee;

  /* flags — V (voldoende) in teal, N (nieuw) in warm-purple */
  --v-flag:      #1a5579;
  --v-flag-bg:   #dce6ee;
  --n-flag:      #7a4a8a;
  --n-flag-bg:   #ecdcf0;

  --radius:      6px;
  --radius-lg:   12px;
  --shadow:      0 1px 2px rgba(30, 60, 50, 0.05),
                 0 8px 24px rgba(30, 60, 50, 0.06);

  --font-display: "Voltaire", "Trebuchet MS", ui-sans-serif, system-ui, sans-serif;
  --font-body:    "Lora", Georgia, "Times New Roman", serif;
  --font-ui:      ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, sans-serif;
}

/* Dark mode blijft on-brand: donkere teal grond, cream tekst, accent oranje */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #16302a;
    --bg-elev:     #1e3d35;
    --bg-soft:     #24463d;
    --bg-band:     #1a3830;
    --border:      #2f5a4e;
    --border-strong: #457066;
    --text:        #f6ead4;
    --text-muted:  #b6cfc4;
    --text-dim:    #7ba99e;
    --accent:      #ff8c42;
    --accent-hov:  #ff9d5c;
    --accent-soft: #4a3524;
    --accent-tint: #f3c189;
    --good:        #7bc3b1;
    --warn:        #ff8c42;
    --crit:        #e07a63;
    --info:        #8ab3d0;
    --good-bg:     #1f4a41;
    --warn-bg:     #4a3524;
    --crit-bg:     #4a2a24;
    --info-bg:     #1e3a4d;
    --v-flag:      #8ab3d0;
    --v-flag-bg:   #1e3a4d;
    --n-flag:      #b78bc5;
    --n-flag-bg:   #3a2643;
    --shadow:      0 1px 2px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.25);
  }
}

/* Expliciete theme-overrides — user's toggle wint van OS preference */
:root[data-theme="light"] {
  --bg: #fcf7ea; --bg-elev: #fffbf8; --bg-soft: #f6ead4; --bg-band: #f2e6cf;
  --border: #ecdfc4; --border-strong: #d9c8a2;
  --text: #1e3d35; --text-muted: #3e827a; --text-dim: #7ba99e;
  --accent: #ee7b3e; --accent-hov: #d96924; --accent-soft: #fbe4cf; --accent-tint: #f3c189;
  --good: #3e827a; --warn: #ee7b3e; --crit: #c8452e; --info: #1a5579;
  --good-bg: #dfeceb; --warn-bg: #fbe4cf; --crit-bg: #f5d5cc; --info-bg: #dce6ee;
  --v-flag: #1a5579; --v-flag-bg: #dce6ee; --n-flag: #7a4a8a; --n-flag-bg: #ecdcf0;
}
:root[data-theme="dark"] {
  --bg: #16302a; --bg-elev: #1e3d35; --bg-soft: #24463d; --bg-band: #1a3830;
  --border: #2f5a4e; --border-strong: #457066;
  --text: #f6ead4; --text-muted: #b6cfc4; --text-dim: #7ba99e;
  --accent: #ff8c42; --accent-hov: #ff9d5c; --accent-soft: #4a3524; --accent-tint: #f3c189;
  --good: #7bc3b1; --warn: #ff8c42; --crit: #e07a63; --info: #8ab3d0;
  --good-bg: #1f4a41; --warn-bg: #4a3524; --crit-bg: #4a2a24; --info-bg: #1e3a4d;
  --v-flag: #8ab3d0; --v-flag-bg: #1e3a4d; --n-flag: #b78bc5; --n-flag-bg: #3a2643;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtiele warm-cream 'washi'-textuur op de body — heel licht dot-pattern */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  background-image: radial-gradient(circle at 1px 1px, rgba(62, 130, 122, 0.04) 1px, transparent 0);
  background-size: 28px 28px;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px 32px 40px;
  max-width: 1400px;
  margin: 0 auto;
  min-height: 100vh;
}
@media (max-width: 1100px) { .app { padding: 20px; gap: 16px; } }
@media (max-width: 640px)  { .app { padding: 14px 12px 24px; gap: 14px; } }

/* Whitespace-fix: verstop echt weggeschakelde kaarten */
.is-hidden { display: none !important; }

/* ── Header ────────────────────────────────────────────── */
header.top {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 4px 4px 20px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
header.top::after {
  /* accentstreepje links onder de titel, verwijzing naar hun paginatabs */
  content: "";
  position: absolute;
  left: 4px; bottom: -1px;
  width: 56px; height: 3px;
  background: var(--accent);
  border-radius: 2px;
}
header.top h1 {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--text);
  margin: 0;
}
header.top h1 .sub {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 12px;
  font-size: 14px;
  letter-spacing: 0;
}
header.top .actions { display: flex; gap: 12px; align-items: center; }

/* ── Legenda: kleine ? met hover-popover ────────────────── */
.legend-info {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 13px;
  cursor: help;
  outline: none;
}
.legend-info:hover, .legend-info:focus { color: var(--accent); border-color: var(--accent); }
.legend-pop {
  position: absolute;
  top: calc(100% + 10px);
  right: -6px;
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(30, 60, 50, 0.15);
  white-space: nowrap;
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-muted);
  z-index: 30;
}
.legend-info:hover .legend-pop,
.legend-info:focus-within .legend-pop { display: flex; }
.legend-pop .chip { display: inline-flex; align-items: center; gap: 8px; }
.legend-pop .swatch { width: 10px; height: 10px; border-radius: 2px; border: 1px solid rgba(30, 60, 50, 0.15); }
.legend-pop .swatch.good { background: var(--good); }
.legend-pop .swatch.warn { background: var(--warn); }
.legend-pop .swatch.crit { background: var(--crit); }
.legend-pop .swatch.v    { background: var(--v-flag); }
.legend-pop .swatch.n    { background: var(--n-flag); }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  font-family: var(--font-ui);
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text);
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:hover  { background: var(--bg-soft); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary {
  background: var(--accent); border-color: var(--accent); color: white;
  box-shadow: 0 1px 2px rgba(238, 123, 62, 0.25);
}
.btn.primary:hover { background: var(--accent-hov); border-color: var(--accent-hov); }
.btn.danger {
  background: transparent;
  border-color: transparent;
  color: var(--crit);
}
.btn.danger:hover { background: var(--crit-bg); color: var(--crit); }
.btn.danger[hidden] { display: none; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn.ghost:hover { background: var(--bg-soft); color: var(--text); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.icon { padding: 5px 9px; }

/* ── Tabs ──────────────────────────────────────────────── */
.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  padding: 0 4px;
  margin-bottom: -8px;
}
.tab {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: transparent;
  border: none;
  padding: 12px 18px 14px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  transition: color .1s ease, border-color .1s ease;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}
.tab-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--crit);
  color: white;
  font-family: var(--font-ui);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}
.tab-badge[hidden] { display: none; }
.tab-spacer { flex: 1; }
.sync-pill { margin-right: 4px; }

.tab-panel { display: block; }
.tab-panel[hidden] { display: none; }

@media (max-width: 640px) {
  .tabs { overflow-x: auto; padding: 0; margin-bottom: -6px; }
  .tab { padding: 10px 14px 12px; font-size: 13px; letter-spacing: 0.04em; white-space: nowrap; }
  .sync-pill { display: none; }
}

/* ── Card ──────────────────────────────────────────────── */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card > header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-elev), var(--bg));
  display: flex; justify-content: space-between; align-items: center;
}
.card > header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.card > .body { padding: 6px; }

.pill {
  font-family: var(--font-ui);
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  background: var(--bg-soft);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ── Meldingen ──────────────────────────────────────────── */
.notify-card { margin-bottom: 20px; }
.notify-body { padding: 8px 14px 14px; display: grid; gap: 10px; }
.notify {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border-left: 4px solid var(--warn);
  background: var(--warn-bg);
  color: var(--text);
}
.notify.crit { border-left-color: var(--crit); background: var(--crit-bg); }
.notify .body { flex: 1; font-family: var(--font-body); font-size: 14px; line-height: 1.45; }
.notify .body .city { font-weight: 600; }
.notify .body .meta { font-family: var(--font-ui); color: var(--text-muted); font-size: 12px; margin-top: 3px; }
.notify .actions { display: flex; gap: 8px; }
.notify .level {
  font-family: var(--font-ui);
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; padding: 3px 8px; border-radius: 3px;
  background: var(--warn); color: white;
}
.notify.crit .level { background: var(--crit); }

/* ── Tabel ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; padding: 0 2px; }
table.grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
}
table.grid thead th {
  position: sticky; top: 0; z-index: 3;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border-strong);
  text-align: left;
  padding: 14px 12px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  white-space: nowrap;
}
table.grid tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
table.grid tbody tr:hover td { background: var(--bg-band); }
table.grid td.city, table.grid th.city {
  position: sticky; left: 0; z-index: 2;
  background: var(--bg-elev);
  border-right: 1px solid var(--border-strong);
  min-width: 170px;
}
table.grid tbody tr:hover td.city { background: var(--bg-band); }
table.grid th.city { z-index: 4; }
table.grid td.num, table.grid th.num { text-align: right; }
table.grid td.center, table.grid th.center { text-align: center; }
table.grid td.actions { text-align: right; white-space: nowrap; }
table.grid tbody tr:last-child td { border-bottom: none; }

.city-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: 0.02em;
  line-height: 1.15;
}

/* ── Voorraad-cellen ────────────────────────────────────── */
.qty-cell {
  display: inline-flex; align-items: center; justify-content: flex-end;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  min-width: 60px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter .1s ease, border-color .1s ease;
}
.qty-cell:hover { filter: brightness(.97); border-color: var(--border-strong); }
.qty-cell.good { background: var(--good-bg); color: var(--good); }
.qty-cell.warn { background: var(--warn-bg); color: var(--accent-hov); }
.qty-cell.crit { background: var(--crit-bg); color: var(--crit); }
.qty-cell.v    { background: var(--v-flag-bg); color: var(--v-flag); }
.qty-cell.n    { background: var(--n-flag-bg); color: var(--n-flag); }
.qty-cell.empty { color: var(--text-dim); background: transparent; border-color: var(--border); }
.qty-cell .est { font-weight: 500; font-size: 10.5px; color: currentColor; opacity: .75; }

.free-text {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 11.5px;
  color: var(--text-muted);
  margin-left: 6px;
  font-style: italic;
}

/* ── Contract-badge ─────────────────────────────────────── */
.contract {
  font-family: var(--font-ui);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.contract:hover { background: var(--bg-soft); }
.contract .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.contract.normal   { color: var(--text-muted); }
.contract.soon     { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.contract.urgent   { color: var(--crit); background: var(--crit-bg); border-color: transparent; }
.contract.renewed  { color: var(--good); background: var(--good-bg); border-color: transparent; }
.contract.empty    {
  color: var(--text-dim);
  border: 1px dashed var(--border);
  background: transparent;
  padding: 4px 10px;
  min-height: 22px; min-width: 40px;
  opacity: 0;
  transition: opacity .15s ease;
}
tr:hover .contract.empty { opacity: 1; }
.contract.empty::before { content: "+ zet"; font-family: var(--font-body); font-style: italic; font-size: 11px; }

/* ── Wijzigingslog ──────────────────────────────────────── */
.log { max-height: calc(100vh - 260px); overflow-y: auto; padding: 10px 14px; }
.log.log-wide { max-height: none; padding: 16px 24px; }
.log.log-wide .entry { grid-template-columns: 180px 1fr; padding: 14px 4px; }
.log .entry {
  padding: 12px 4px;
  border-bottom: 1px dashed var(--border);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 12px;
}
.log .entry:last-child { border-bottom: none; }
.log .time {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-top: 2px;
}
.log .msg {
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.4;
}
.log .msg .city  { font-weight: 600; color: var(--text); }
.log .msg .kind  {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-right: 4px;
}
.log .msg .by {
  display: block;
  margin-top: 2px;
  font-family: var(--font-body);
  font-style: italic;
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ── Beheer-tab: kaartjes per stad ──────────────────────── */
.manage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  padding: 14px;
}
.manage-city {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 14px 16px;
  display: flex; flex-direction: column;
  gap: 10px;
}
.manage-city header {
  display: flex; align-items: center; gap: 12px;
  border: none; padding: 0; background: none;
}
.manage-city .thumb {
  width: 40px; height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-soft);
  color: var(--text-dim);
  cursor: pointer;
}
.manage-city .thumb img { width:100%; height:100%; object-fit:cover; display:block; }
.manage-city .thumb:hover { border-color: var(--accent); }
.manage-city h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 400;
  color: var(--text);
  margin: 0;
  flex: 1;
}
.manage-city .edit-city {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 4px 6px;
  cursor: pointer;
  font-size: 14px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity .15s ease, color .1s ease, background .1s ease;
}
.manage-city:hover .edit-city { opacity: 1; }
.manage-city .edit-city:hover { color: var(--accent); background: var(--accent-soft); }
@media (hover: none) { .manage-city .edit-city { opacity: 1; } }
.manage-city .row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0;
  font-family: var(--font-ui);
  font-size: 12.5px;
  color: var(--text-muted);
  border-top: 1px dashed var(--border);
}
.manage-city .row .lbl {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.manage-city .row .warn-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--crit);
}
.manage-city .row .val {
  color: var(--text);
  font-family: var(--font-body);
}
.manage-city .row button {
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 12px;
}
.manage-city .row button:hover { color: var(--accent); border-color: var(--accent); }
.manage-city .row .warn { color: var(--crit); font-weight: 600; }

.manage-city.add-tile {
  display: flex;
  align-items: center; justify-content: center;
  gap: 12px;
  min-height: 200px;
  border-style: dashed;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
  font: inherit;
}
.manage-city.add-tile:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.manage-city.add-tile .plus {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1;
}
.manage-city.add-tile .lbl {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(30, 60, 50, 0.42);
  display: none; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg-elev);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(30, 60, 50, 0.28);
  width: min(500px, 100%);
  padding: 24px 26px;
}
.modal h3 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--text);
}
.modal .sub {
  font-family: var(--font-body);
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
  margin: 0 0 18px;
}
.modal .field { display: grid; gap: 6px; margin-bottom: 14px; }
.modal label {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.modal input, .modal select, .modal textarea {
  font-family: var(--font-ui);
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  width: 100%;
  transition: border-color .1s ease, box-shadow .1s ease;
}
.modal input:focus, .modal select:focus, .modal textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.modal .row { display: flex; gap: 12px; }
.modal .row > * { flex: 1; }
.modal .footer { display: flex; justify-content: space-between; gap: 8px; margin-top: 20px; }
.modal .footer .spacer { flex: 1; }

/* ── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg-elev);
  padding: 12px 18px; border-radius: 8px;
  opacity: 0; transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
  font-family: var(--font-ui);
  font-size: 13px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(30, 60, 50, 0.2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Login-scherm ───────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.login-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 32px 28px;
  width: min(400px, 100%);
  box-shadow: var(--shadow);
  position: relative;
}
.login-card::before {
  content: "";
  position: absolute;
  left: 32px; top: 24px;
  width: 40px; height: 3px;
  background: var(--accent);
  border-radius: 2px;
}
.login-card h1 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--text);
  margin: 12px 0 4px;
}
.login-card .sub {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 20px;
}
.login-card .field { display: grid; gap: 6px; margin-bottom: 14px; }
.login-card label {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.login-card input {
  font-family: var(--font-ui);
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  width: 100%;
  transition: border-color .1s ease, box-shadow .1s ease;
}
.login-card input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.login-card .btn.full { width: 100%; margin-top: 8px; padding: 11px 12px; font-size: 14px; }
.login-err {
  background: var(--crit-bg);
  color: var(--crit);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-family: var(--font-ui);
  font-size: 13px;
  margin-bottom: 14px;
}
.login-tip {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  margin: 18px 0 0;
}
.login-tip code {
  font-family: var(--font-mono, ui-monospace, monospace);
  background: var(--bg-soft);
  color: var(--text);
  padding: 1px 6px;
  border-radius: 3px;
  font-style: normal;
  font-size: 12px;
}

/* ── User-chip in header ────────────────────────────────── */
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 12px;
}
.user-chip .user-name {
  font-weight: 600;
  color: var(--text);
}
.user-chip .user-name::before {
  content: "•";
  color: var(--good);
  margin-right: 6px;
  font-size: 14px;
  vertical-align: middle;
}
.user-chip .user-logout {
  color: var(--text-muted);
  text-decoration: none;
  border-left: 1px solid var(--border-strong);
  padding-left: 8px;
  transition: color .1s ease;
}
.user-chip .user-logout:hover { color: var(--accent); }

/* ── Product-icoon in kolomkop ──────────────────────────── */
.col-icon { font-size: 14px; margin-right: 6px; }

/* ── Doosje-thumbnail + stad-blok ───────────────────────── */
.city-block {
  display: flex;
  gap: 10px;
  align-items: center;
}
.box-thumb {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  overflow: hidden;
  transition: border-color .1s ease, transform .05s ease, opacity .15s ease;
}
.box-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.box-thumb:hover { border-color: var(--accent); }
.box-thumb:active { transform: scale(0.97); }
.box-thumb.ghost {
  background: transparent;
  border-style: dashed;
  border-color: var(--border);
  color: var(--text-dim);
  font-size: 16px;
  opacity: 0;
}
tr:hover .box-thumb.ghost { opacity: 1; }
tr:hover .box-thumb.ghost:hover { border-color: var(--accent); color: var(--accent); }
.city-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

/* ── Boekje-chip: compact ───────────────────────────────── */
.booklet-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-ui);
  font-size: 10.5px;
  color: var(--text-muted);
  width: fit-content;
  line-height: 1;
}
.booklet-chip .v {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px 0;
}
.booklet-chip .v:hover { text-decoration: underline; }
.booklet-chip .warn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 13px; height: 13px;
  background: var(--crit);
  color: white;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  padding: 0;
}
.booklet-chip .edit {
  border: none; background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0 4px;
  font-size: 14px;
  line-height: 1;
  opacity: 0;
  transition: opacity .15s ease;
}
tr:hover .booklet-chip .edit { opacity: 1; }
.booklet-chip .edit:hover { color: var(--accent); }

.booklet-chip.empty {
  display: inline-block;
  padding: 0;
  border: none; background: transparent;
  color: var(--text-dim);
  font-style: italic;
  font-family: var(--font-body);
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s ease;
}
tr:hover .booklet-chip.empty { opacity: 1; }
.booklet-chip.empty:hover { color: var(--accent); text-decoration: underline; }

/* ── Voucher-knop bij voucher-cel ───────────────────────── */
.voucher-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 4px;
  min-width: 28px; height: 22px;
  padding: 0 8px;
  margin-left: 8px;
  border-radius: 999px;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  vertical-align: middle;
}
.voucher-btn:hover { border-style: solid; border-color: var(--accent); color: var(--accent); }
.voucher-btn.empty { color: var(--text-dim); }
.voucher-btn.warn {
  border-style: solid;
  border-color: var(--warn);
  background: var(--warn-bg);
  color: var(--crit);
}
.voucher-btn .warn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 12px; height: 12px;
  background: var(--crit);
  color: white;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 700;
}

/* ── Depletion-indicator naast qty ──────────────────────── */
.depletion {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--info-bg);
  color: var(--info);
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
  cursor: help;
}
.depletion.urgent { background: var(--crit-bg); color: var(--crit); }

/* ── Modals — extra styling voor boekje/voucher/box ────── */
.modal.wide { width: min(600px, 100%); }
.modal h4.mini-title {
  margin: 22px 0 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.modal label.check {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  margin: 8px 0 4px;
  padding: 4px 0;
}
.modal label.check input { width: auto; margin: 0; }

.booklet-list { display: grid; gap: 8px; margin-bottom: 4px; }
.booklet-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.booklet-row.warn { border-color: var(--warn); background: var(--warn-bg); }
.booklet-row .v {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
}
.booklet-row .meta { display: grid; gap: 2px; min-width: 0; }
.booklet-row .meta a { color: var(--accent); text-decoration: none; font-family: var(--font-ui); font-size: 13px; }
.booklet-row .meta a:hover { text-decoration: underline; }
.booklet-row .meta .sub { color: var(--text-muted); font-size: 11.5px; font-family: var(--font-body); font-style: italic; }

.voucher-list { display: grid; gap: 8px; margin-bottom: 4px; }
.voucher-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.voucher-row.warn { border-color: var(--warn); background: var(--warn-bg); }
.voucher-row .body { min-width: 0; }
.voucher-row .name {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--text);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.voucher-row .tag {
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 6px;
  background: var(--crit);
  color: white;
  border-radius: 3px;
}
.voucher-row .desc { font-family: var(--font-body); font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.voucher-row .row-actions { display: flex; gap: 6px; flex-shrink: 0; }

.box-preview {
  width: 100%;
  aspect-ratio: 16/9;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-soft);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
  overflow: hidden;
}
.box-preview img { width: 100%; height: 100%; object-fit: cover; }
.box-preview .placeholder {
  font-family: var(--font-body);
  color: var(--text-dim);
  font-style: italic;
  font-size: 13px;
}

/* Mobiel: geen hover, dus lege staten altijd zichtbaar */
@media (hover: none) {
  .box-thumb.ghost,
  .booklet-chip.empty,
  .booklet-chip .edit,
  .contract.empty { opacity: 1 !important; }
}
@media (max-width: 640px) {
  .city-block { gap: 10px; }
  .box-thumb { width: 40px; height: 40px; }
  .modal.wide { width: 100%; }
  .box-thumb.ghost,
  .booklet-chip.empty,
  .booklet-chip .edit,
  .contract.empty { opacity: 1 !important; }
}

/* ─────────────────────────────────────────────────────────
   Tablet (≤ 900px): compactere padding, header wrapt
   ───────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  header.top {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }
  header.top h1 { font-size: 28px; }
  header.top h1 .sub { display: block; margin-left: 0; margin-top: 2px; }
  header.top .actions { flex-wrap: wrap; }
  .legend { flex-wrap: wrap; row-gap: 6px; }
  table.grid thead th { padding: 12px 10px; font-size: 11px; }
  table.grid tbody td { padding: 10px 8px; }
  .card > header { padding: 14px 16px; }
  .log { max-height: none; }
}

/* ─────────────────────────────────────────────────────────
   Telefoon (≤ 640px): tabel wordt een kaart-per-stad
   ───────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  body { font-size: 15px; }
  header.top h1 { font-size: 24px; letter-spacing: 0.02em; }
  header.top h1 .sub { font-size: 13px; }
  header.top::after { width: 40px; }

  .card > header {
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .card > header h2 { font-size: 13px; letter-spacing: 0.1em; }
  .card > .body { padding: 0; }

  /* Tabel transformeert naar kaart-per-rij */
  .table-wrap { overflow-x: visible; padding: 0; }
  table.grid, table.grid tbody, table.grid tr, table.grid td { display: block; width: 100%; }
  table.grid thead { display: none; }

  table.grid tbody tr {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 10px 12px;
    padding: 14px 4px 8px;
    box-shadow: 0 1px 2px rgba(30, 60, 50, 0.03);
  }
  table.grid tbody tr:hover td { background: transparent; }

  table.grid td {
    border-bottom: 1px solid var(--border);
    padding: 10px 14px !important;
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    text-align: right;
    min-height: 40px;
    background: transparent !important;
  }
  table.grid td:last-child { border-bottom: none; }

  /* Label uit data-label voor elke cel */
  table.grid td::before {
    content: attr(data-label);
    font-family: var(--font-display);
    font-size: 11.5px;
    font-weight: 400;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    text-align: left;
    flex-shrink: 0;
    margin-right: 12px;
  }

  /* De stad-cel is de kaart-header — grote naam, geen "STAD"-label */
  table.grid td.city {
    position: static;
    border-right: none;
    border-bottom: 2px solid var(--border);
    display: block !important;
    text-align: left;
    padding-bottom: 12px !important;
    background: transparent !important;
  }
  table.grid td.city::before { display: none; }
  .city-name { font-size: 22px; }

  /* Acties-cel: knop links vullend */
  table.grid td.actions { padding: 12px 14px !important; }
  table.grid td.actions::before { display: none; }
  table.grid td.actions .btn {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    background: var(--bg-soft);
  }

  /* Voorraad-badges rechts uitgelijnd op mobiel */
  .qty-cell { min-width: auto; padding: 5px 12px; }
  .qty-cell .est { display: block; margin-top: 1px; }
  .free-text { margin-left: 8px; }

  /* Meldingen: verticaal stapelen op mobiel */
  .notify {
    flex-wrap: wrap;
    padding: 12px 14px;
    gap: 10px;
  }
  .notify .body { flex-basis: 100%; }
  .notify .level { order: -1; }
  .notify .actions {
    flex-basis: 100%;
    justify-content: flex-end;
  }
  .notify .actions .btn { flex: 1; }

  /* Wijzigingslog compacter */
  .log { padding: 6px 12px; }
  .log .entry {
    grid-template-columns: 1fr;
    gap: 2px 0;
    padding: 10px 4px;
  }

  /* Modal: bijna full-screen op mobiel */
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal {
    width: 100%;
    max-width: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 22px 20px 28px;
    max-height: 92vh;
    overflow-y: auto;
  }
  .modal .row { flex-direction: column; }
  .modal .footer { flex-wrap: wrap; gap: 10px; }
  .modal .footer .btn { flex: 1; min-height: 42px; }
  .modal input, .modal select, .modal textarea {
    font-size: 16px; /* voorkomt zoom in Safari iOS */
    padding: 11px 12px;
  }

  /* Grotere tap-targets */
  .btn { min-height: 38px; }
  .btn.small { min-height: 34px; }
}
