/* tokens.css — Werkplaats Portaal design system (§10)
   Dark-first by design: workshop floor, gloves, glare. No light theme. */

:root {
  /* palette */
  --bg:        #0F1216;
  --panel:     #161B22;
  --panel-2:   #1C232C;
  --line:      #29323D;
  --ink:       #E8EDF2;
  --ink-dim:   #8B98A5;
  --amber:     #FFAA2B;
  --green:     #43C982;
  --orange:    #FF7A45;
  --blue:      #5B8DEF;
  --red:       #F2555A;

  /* tinted surfaces for chips/badges */
  --amber-dim:  rgba(255, 170, 43, .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(139, 152, 165, .14);

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

  /* rhythm */
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

*, *::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: 9px 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(--amber);
  outline-offset: 1px;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: var(--amber);
  border-color: var(--amber);
  color: #17130A;
}
.btn-primary:hover { border-color: var(--amber); filter: brightness(1.08); }

.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: 9px 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(--amber); 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); }

/* steel warehouse plate for location codes — the portal's signature */
.loc-plate {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 3px 10px 3px 8px;
  border: 1px solid #3A4654;
  border-radius: 4px;
  background: linear-gradient(180deg, #232B35 0%, #1A212A 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
  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;
}

/* ── stock bar vs minimum — recurring element ──────────────────────────── */
.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 marker sits at 50% of the track (track = 2 × min_stock) */
  position: absolute;
  left: 50%;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--ink-dim);
  opacity: .9;
}

/* ── tables ────────────────────────────────────────────────────────────── */
.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: 9px 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; }

/* ── panels ────────────────────────────────────────────────────────────── */
.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: 12px 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: 14px 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(6, 8, 11, .72);
  overflow-y: auto;
}
.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); } }

/* ── empty states ──────────────────────────────────────────────────────── */
.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;
}

/* ── misc ──────────────────────────────────────────────────────────────── */
.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%, #232b35 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; }
}
