/* tokens.css — Werkbank design system (white-label)
   Twee onafhankelijke lagen:
   - thema:   html[data-thema="donker"|"licht"]  (donker is standaard)
   - merk:    --accent / --accent-ink, per omgeving instelbaar (omgeving.js)
   Dichtheid: html[data-dichtheid="compact"] verkleint het ritme. */

:root {
  /* merk (instelbaar per omgeving; JS overschrijft bij afwijkend accent) */
  --accent:     #2DD4BF;
  --accent-ink: #10201C;
  --accent-dim: color-mix(in srgb, var(--accent) 14%, transparent);

  /* thema: donker (standaard) — diepe groenzwarte werkvloer */
  --bg:        #0C1613;
  --panel:     #12201C;
  --panel-2:   #17261F;
  --line:      #25352E;
  --ink:       #E4EFEA;
  --ink-dim:   #8FA69E;

  /* semantiek (status/waarschuwing — losstaand van het merk-accent) */
  --amber:     #FFB300;
  --green:     #43C982;
  --orange:    #FF7A45;
  --blue:      #5B8DEF;
  --red:       #F2555A;

  /* getinte vlakken voor chips/badges */
  --amber-dim:  rgba(255, 179, 0, .14);
  --green-dim:  rgba(67, 201, 130, .14);
  --orange-dim: rgba(255, 122, 69, .16);
  --blue-dim:   rgba(91, 141, 239, .16);
  --red-dim:    rgba(242, 85, 90, .14);
  --grey-dim:   rgba(143, 166, 158, .14);

  /* type */
  --font-head: "Figtree", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", monospace;

  /* ritme */
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  --pad: 1;

  /* stalen locatieplaatjes (signatuur) — per thema */
  --plate-line: #39544A;
  --plate-top:  #1E312A;
  --plate-bot:  #14231E;
  --plate-shine: rgba(255, 255, 255, .06);
}

html[data-thema="licht"] {
  --bg:        #F1F0EC;
  --panel:     #FFFFFF;
  --panel-2:   #F7F6F2;
  --line:      #E0DED7;
  --ink:       #26282E;
  --ink-dim:   #6C7076;

  /* semantische tekstkleuren donkerder voor contrast op licht */
  --amber:     #A87500;
  --green:     #2E8F58;
  --orange:    #C45A2C;
  --blue:      #3B6FBF;
  --red:       #C24440;

  --amber-dim:  rgba(168, 117, 0, .13);
  --green-dim:  rgba(46, 143, 88, .13);
  --orange-dim: rgba(196, 90, 44, .13);
  --blue-dim:   rgba(59, 111, 191, .13);
  --red-dim:    rgba(194, 68, 64, .12);
  --grey-dim:   rgba(108, 112, 118, .13);

  --shadow: 0 8px 24px rgba(40, 40, 36, .12);

  --plate-line: #C9C6BC;
  --plate-top:  #FBFAF7;
  --plate-bot:  #ECEAE3;
  --plate-shine: rgba(255, 255, 255, .8);
}

html[data-dichtheid="compact"] { --pad: .68; }

*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-head); text-wrap: balance; margin: 0; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.dim { color: var(--ink-dim); }

/* ── labels / eyebrows ─────────────────────────────────────────────────── */
.eyebrow {
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

/* ── buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: calc(9px * var(--pad)) 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  color: var(--ink);
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .05s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--ink-dim); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.06); }

.btn-danger { border-color: var(--red); color: var(--red); background: transparent; }
.btn-danger:hover { background: var(--red-dim); }

.btn-ghost { background: transparent; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── form fields ───────────────────────────────────────────────────────── */
label.field { display: block; }
label.field > span {
  display: block;
  margin-bottom: 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

input[type="text"], input[type="search"], input[type="number"], input[type="email"],
input[type="password"], input[type="date"], select, textarea {
  width: 100%;
  padding: calc(9px * var(--pad)) 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
}
input.mono, .mono input { font-family: var(--font-mono); }
input::placeholder, textarea::placeholder { color: var(--ink-dim); opacity: .7; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-dim) 50%), linear-gradient(135deg, var(--ink-dim) 50%, transparent 50%); background-position: calc(100% - 16px) 55%, calc(100% - 11px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }

/* ── chips & badges ────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.chip-in       { background: var(--green-dim);  color: var(--green); }
.chip-out      { background: var(--orange-dim); color: var(--orange); }
.chip-transfer { background: var(--blue-dim);   color: var(--blue); }
.chip-count    { background: var(--grey-dim);   color: var(--ink-dim); }
.chip-corr     { background: var(--amber-dim);  color: var(--amber); }
.chip-red      { background: var(--red-dim);    color: var(--red); }
.chip-expected { background: var(--blue-dim);   color: var(--blue); }
.chip-partial  { background: var(--amber-dim);  color: var(--amber); }
.chip-received { background: var(--green-dim);  color: var(--green); }
.chip-cancelled{ background: var(--grey-dim);   color: var(--ink-dim); }
.chip-accent   { background: var(--accent-dim); color: var(--accent); }

/* stalen magazijnplaat voor locatiecodes — de signatuur van het portaal */
.loc-plate {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 8px;
  border: 1px solid var(--plate-line);
  border-radius: 4px;
  background: linear-gradient(180deg, var(--plate-top) 0%, var(--plate-bot) 100%);
  box-shadow: inset 0 1px 0 var(--plate-shine);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--ink);
  white-space: nowrap;
}
.loc-plate::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #5A6878 0%, #4A5766 45%, #2B333E 100%);
  box-shadow: inset 0 0 1px rgba(0,0,0,.7);
  flex: none;
}
html[data-thema="licht"] .loc-plate::before {
  background: radial-gradient(circle at 35% 30%, #B9C2CC 0%, #97A2AE 45%, #6B7682 100%);
}

/* ── voorraadbalk t.o.v. minimum ───────────────────────────────────────── */
.stockbar {
  position: relative;
  width: 100%;
  min-width: 90px;
  height: 8px;
  border-radius: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.stockbar > i {
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  border-radius: 3px;
}
.stockbar > i.ok   { background: var(--green); }
.stockbar > i.warn { background: var(--amber); }
.stockbar > i.low  { background: var(--red); }
.stockbar > b {
  /* minimum-markering op 50% van de balk (balk = 2 × min_stock) */
  position: absolute;
  left: 50%;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--ink-dim);
  opacity: .9;
}

/* ── tabellen ──────────────────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  padding: 8px 10px;
  text-align: left;
  font-family: var(--font-head);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-dim);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl td {
  padding: calc(9px * var(--pad)) 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.tbl tbody tr:hover { background: var(--panel-2); }
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ── panelen ───────────────────────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px * var(--pad)) 16px;
  border-bottom: 1px solid var(--line);
}
.panel > header h3 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.panel > .panel-body { padding: calc(14px * var(--pad)) 16px; }
.panel > .panel-body.flush { padding: 0; }

/* ── modal ─────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px 16px;
  background: rgba(4, 8, 7, .72);
  overflow-y: auto;
}
html[data-thema="licht"] .modal-backdrop { background: rgba(38, 40, 46, .45); }
.modal {
  width: 100%;
  max-width: 560px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.modal.modal-wide { max-width: 860px; }
.modal > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.modal > header h3 { font-size: 15px; font-weight: 700; }
.modal .modal-body { padding: 18px; display: grid; gap: 14px; }
.modal > footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}
.modal .x {
  background: none;
  border: 0;
  color: var(--ink-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.modal .x:hover { color: var(--ink); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 540px) { .form-row { grid-template-columns: 1fr; } }

/* ── toasts ────────────────────────────────────────────────────────────── */
#toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
}
.toast {
  padding: 11px 14px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--ink-dim);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toast-in .18s ease-out;
}
.toast.ok    { border-left-color: var(--green); }
.toast.err   { border-left-color: var(--red); }
.toast.info  { border-left-color: var(--blue); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ── lege staten ───────────────────────────────────────────────────────── */
.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--ink-dim);
  font-size: 13px;
}
.empty::before {
  content: "▢";
  display: block;
  font-size: 22px;
  margin-bottom: 6px;
  opacity: .6;
}

/* ── overig ────────────────────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.right { margin-left: auto; }

.skel {
  display: inline-block;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--panel-2) 25%, var(--line) 50%, var(--panel-2) 75%);
  background-size: 200% 100%;
  animation: skel 1.1s infinite linear;
}
@keyframes skel { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
