/* ===========================================================================
   Koopman compound — design tokens (single source of truth)
   Red = action (buttons, primary CTA, alerts, logo).
   Brass = accent ONLY: active-nav rail, the "next" badge, the gate-code underline.
   UI text + headings: Source Sans 3. Plate / gate code / metric numbers: Source
   Code Pro.
   =========================================================================== */
:root {
  --ink:#14161A;  --ink-2:#1F232B;            /* dark side rail */
  --red:#DA281C;  --red-700:#B71F15;          /* PRIMARY actions, alerts, logo */
  --brass:#C2A100; --brass-soft:#F4EFCF;      /* ACCENT ONLY */
  --paper:#F6F5F2; --card:#FFFFFF; --line:#E8E6E1; --text:#23272E; --muted:#6E727A;

  /* State scale (colourblind-safe, always paired with a text label + icon) */
  --s-registered:#64748B; --s-called:#B08A02; --s-arrived:#2563EB;
  --s-completed:#15803D;  --s-archived:#9AA0A6;
  --dock-free:#15803D; --dock-occupied:#B08A02; --dock-oos:#9AA0A6;

  --radius-card:14px; --radius-ctl:10px;
  --shadow:0 1px 2px rgba(20,22,26,.06),0 8px 24px -12px rgba(20,22,26,.18);

  --font-ui:"Source Sans 3", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:"Source Code Pro", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  background: var(--paper);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
}

/* Headings: weight for hierarchy, never forced condensed/uppercase. */
h1, h2, h3, h4, .display-head {
  font-family: var(--font-ui);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.01em;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }

/* Small eyebrow labels — the only place we uppercase. */
.eyebrow, .metric .k, .lang-code,
.column > header, .state-badge, .dock-chip {
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* Numbers / identifiers in monospace. */
.mono, .metric .v, .bigcode, .plate-input, .rcard .plate,
.kpi-num, .avgwait-val, .step-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Skip-to-content link, visible only when focused (keyboard users) */
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 1000;
  background: var(--ink); color: #fff; padding: .5rem .9rem; border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; }

/* Top bar (kiosk + driver brand header) --------------------------------- */
.topbar {
  background: var(--ink);
  color: #fff;
  padding: .6rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.topbar a { color: #fff; text-decoration: none; }
.topbar .brand { display: inline-flex; align-items: center; gap: .5rem; }
.topbar-eyebrow { color: #B8BCC4; font-size: .85rem; }
.logo-x {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; background: var(--red);
  color: #fff; font-weight: 700; border-radius: 8px;
  font-family: var(--font-ui);
}
.brandword { font-weight: 700; letter-spacing: .02em; font-size: 1.1rem; }

.content { max-width: 1180px; margin: 1.5rem auto; padding: 0 1rem; }

/* Buttons — red is the action colour --------------------------------------- */
.btn { border-radius: var(--radius-ctl); font-weight: 600; transition: background .15s ease, box-shadow .15s ease, color .15s ease; }
.btn-koop {
  background: var(--red); color: #fff; border: none;
}
.btn-koop:hover, .btn-koop:focus { background: var(--red-700); color: #fff; }
.btn-ink { background: var(--ink); color: #fff; border: none; }
.btn-ink:hover { background: var(--ink-2); color: #fff; }
.btn-outline-ink { border: 1.5px solid var(--ink); color: var(--ink); background: transparent; }
.btn-outline-ink:hover { background: var(--ink); color: #fff; }

/* Cards & panels ----------------------------------------------------------- */
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-card); box-shadow: var(--shadow);
}

/* Kanban ------------------------------------------------------------------- */
.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: .9rem; }
.column { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card); min-height: 220px; box-shadow: var(--shadow); }
.column > header {
  display: flex; justify-content: space-between; align-items: center;
  padding: .6rem .8rem; border-bottom: 1px solid var(--line);
  font-weight: 700; font-size: .78rem; color: var(--muted);
}
.column .count { background: var(--paper); border-radius: 999px; padding: 0 .55rem; font-size: .8rem; color: var(--text); }
.rcard { border: 1px solid var(--line); border-left: 4px solid var(--s-registered); border-radius: var(--radius-ctl); padding: .55rem .65rem; margin: .55rem; background: var(--card); transition: box-shadow .15s ease, transform .15s ease; }
.rcard:hover { box-shadow: var(--shadow); }
.rcard .plate { font-weight: 700; letter-spacing: .03em; text-decoration: none; color: var(--ink); }
.rcard .meta { font-size: .78rem; color: var(--muted); }
.rcard.state-called_off { border-left-color: var(--s-called); }
.rcard.state-arrived { border-left-color: var(--s-arrived); }
.rcard.state-completed { border-left-color: var(--s-completed); }
.rcard.next { border-left-color: var(--brass); box-shadow: inset 3px 0 0 var(--brass); }
.rcard.stale { border-left-color: var(--red); background: #FCEFEE; }
.rcard .stale-flag { color: var(--red); font-weight: 600; }
/* "next" badge — a permitted brass accent. */
.badge-next { background: var(--brass); color: #fff; font-size: .65rem; padding: .05rem .45rem; border-radius: 999px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.cards { min-height: 40px; }
.sortable-ghost { opacity: .4; }
.sortable-drag { box-shadow: 0 6px 16px rgba(0,0,0,.18); }

/* Card kebab menu */
.card-menu { position: relative; display: inline-block; }
.menu-btn { background: none; border: none; font-size: 1.2rem; line-height: 1; color: var(--muted); padding: 0 .3rem; cursor: pointer; }
.menu-list { position: absolute; right: 0; top: 1.4rem; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-ctl); box-shadow: var(--shadow); min-width: 150px; display: flex; flex-direction: column; overflow: hidden; }
.menu-item { display: block; text-align: left; background: none; border: none; padding: .5rem .7rem; font-size: .9rem; color: var(--ink); text-decoration: none; cursor: pointer; }
.menu-item:hover { background: var(--paper); }

/* Dock dialog + toasts */
.dock-dialog { border: none; border-radius: var(--radius-card); min-width: 320px; box-shadow: var(--shadow); }
.dock-dialog::backdrop { background: rgba(20,22,26,.45); }
.toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 1080; display: flex; flex-direction: column; gap: .5rem; }
.toast-msg { background: var(--ink); color: #fff; padding: .6rem .9rem; border-radius: var(--radius-ctl); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; max-width: 320px; }
.toast-msg.show { opacity: 1; transform: translateY(0); }
.toast-msg.success { background: var(--s-completed); }
.toast-msg.warning { background: var(--s-called); }
.toast-msg.danger { background: var(--red); }

/* Shared legend + dock chips */
.legend summary { cursor: pointer; font-weight: 600; font-size: .8rem; color: var(--muted); }
.legend-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.dock-chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; padding: .12rem .5rem; border-radius: 999px; color: #fff; font-weight: 700; }
.dock-chip.dock-free { background: var(--dock-free); }
.dock-chip.dock-occupied { background: var(--dock-occupied); }
.dock-chip.dock-oos { background: var(--dock-oos); }

/* Audit list (detail page) */
.audit-list { list-style: none; padding: 0; margin: 0; max-height: 520px; overflow-y: auto; }
.audit-list li { border-left: 2px solid var(--line); padding: .35rem .7rem; margin-left: .25rem; }
.audit-when { font-size: .72rem; color: var(--muted); }
.audit-what { font-size: .9rem; }

/* State badges — fill the BADGE only (cards use a left-border accent). */
.state-badge { font-size: .72rem; padding: .08rem .5rem; border-radius: 999px; color: #fff; font-weight: 700; display: inline-flex; align-items: center; gap: .25rem; }
.state-badge.state-registered { background: var(--s-registered); }
.state-badge.state-called_off { background: var(--s-called); }
.state-badge.state-arrived { background: var(--s-arrived); }
.state-badge.state-completed { background: var(--s-completed); }
.state-badge.state-archived { background: var(--s-archived); }

/* Dock tiles --------------------------------------------------------------- */
.dock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; }
.dock-tile { border-radius: var(--radius-card); padding: .9rem; color: #fff; min-height: 96px; box-shadow: var(--shadow); }
.dock-tile h3 { color: #fff; margin: 0 0 .25rem; }
.dock-tile a.dock-occupant { color: #fff; font-weight: 700; text-decoration: none; }
.dock-tile a.dock-occupant:hover { text-decoration: underline; }
.dock-tile.dock-free { background: var(--dock-free); }
.dock-tile.dock-occupied { background: var(--dock-occupied); }
.dock-tile.dock-oos { background: var(--dock-oos); }

/* Metric cards — size to content, no clipping ------------------------------ */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; align-items: start; }
.metric {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-card); box-shadow: var(--shadow);
  padding: .85rem .95rem;
  display: flex; flex-direction: column; gap: .25rem;
}
.metric .v { font-size: 1.75rem; font-weight: 700; color: var(--ink); line-height: 1.1; }
.metric .k {
  font-size: .7rem; color: var(--muted); font-weight: 600;
  /* Wrapping eyebrow: up to two lines, never truncate the meaning. */
  white-space: normal; overflow-wrap: anywhere; line-height: 1.25;
}

/* Kiosk / driver big-touch ------------------------------------------------- */
.kiosk-wrap { max-width: 720px; margin: 1.75rem auto; padding: 0 1rem; }
.lang-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; }
.lang-option {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .4rem; padding: 1.1rem .5rem; text-decoration: none; color: var(--ink);
  min-height: 96px; border: 1px solid var(--line); border-radius: var(--radius-card);
  background: var(--card); box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.lang-option:hover, .lang-option:focus-visible { border-color: var(--brass); transform: translateY(-1px); }
.lang-option.is-current { border-color: var(--brass); box-shadow: inset 0 0 0 2px var(--brass-soft), var(--shadow); }
.lang-option .lang-code { font-weight: 700; color: var(--muted); font-size: .75rem; }
.lang-option .lang-name { font-weight: 600; }
/* Tasteful rounded-rect flags with a hairline border. */
.flag {
  display: inline-block; width: 30px; height: 22px; border-radius: 4px;
  border: 1px solid var(--line); background-size: cover; background-position: center;
  box-shadow: 0 1px 1px rgba(20,22,26,.08);
}
.flag.fi { line-height: 22px; }
.flag-sm { width: 22px; height: 16px; border-radius: 3px; }

.bigcode {
  font-size: 2.8rem; font-weight: 700; letter-spacing: .18em; color: var(--ink);
  display: inline-block; padding-bottom: .15rem;
  /* gate-code underline — a permitted brass accent. */
  border-bottom: 4px solid var(--brass);
}
.callbanner { background: var(--red); color: #fff; padding: 1.4rem; border-radius: var(--radius-card); text-align: center; }
.callbanner .dock { font-size: 2.4rem; font-weight: 700; font-family: var(--font-mono); }
.callbanner.pulse { animation: callpulse 1.6s ease-in-out 1; }
@keyframes callpulse {
  0% { box-shadow: 0 0 0 0 rgba(218,40,28,.55); }
  70% { box-shadow: 0 0 0 18px rgba(218,40,28,0); }
  100% { box-shadow: 0 0 0 0 rgba(218,40,28,0); }
}
.avgwait { margin-top: 1rem; padding: .8rem; background: var(--paper); border-radius: var(--radius-card); }
.avgwait-val { font-size: 1.8rem; font-weight: 700; color: var(--ink); }

/* No-parking warning (kiosk confirmation) */
.notice-warn {
  display: flex; gap: .7rem; align-items: flex-start; text-align: left;
  background: #FCEFEE; border: 1px solid var(--red); border-left: 5px solid var(--red);
  color: var(--red-700); border-radius: var(--radius-card); padding: .9rem 1rem;
}
.notice-warn .bi { font-size: 1.5rem; line-height: 1; flex: 0 0 auto; }
.notice-warn strong { color: var(--red-700); }

/* Kiosk wizard ------------------------------------------------------------- */
.wizard-progress { display: flex; gap: .5rem; justify-content: center; margin: .25rem 0 1rem; }
.wizard-progress .dot { width: 36px; height: 6px; border-radius: 3px; background: var(--line); }
.wizard-progress .dot.on { background: var(--brass); }
.action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.action-card {
  position: relative; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: .5rem; padding: 1.6rem .5rem; min-height: 130px;
  border: 2px solid var(--line); border-radius: var(--radius-card); cursor: pointer; background: var(--card);
  font-weight: 600;
}
.action-card i { font-size: 2rem; color: var(--ink); }
.action-card input { position: absolute; opacity: 0; pointer-events: none; }
.action-card:has(input:checked) { border-color: var(--red); box-shadow: inset 0 0 0 2px var(--red); }
.action-card:has(input:focus-visible) { outline: 3px solid var(--brass); outline-offset: 2px; }
.stepper { display: flex; align-items: stretch; gap: .5rem; max-width: 280px; }
.step-btn {
  width: 64px; min-height: 64px; font-size: 2rem; font-weight: 700; line-height: 1;
  border: 2px solid var(--ink); background: var(--card); color: var(--ink); border-radius: var(--radius-ctl);
}
.step-btn:active { background: var(--paper); }
.step-value {
  flex: 1; text-align: center; font-size: 1.8rem; font-weight: 700; border: 2px solid var(--line);
  border-radius: var(--radius-ctl); background: var(--card); -moz-appearance: textfield;
}
.step-value::-webkit-outer-spin-button, .step-value::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.plate-input { text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }
.shake { animation: shake .35s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }

/* Generic top-bar nav links (kiosk/driver use the topbar; backoffice uses the
   side rail defined in this file below). */
.topbar .nav-link { color: #D7D7D5; padding: .25rem .6rem; }
.topbar .nav-link:hover, .topbar .nav-link.active { color: #fff; }

/* ===========================================================================
   Backoffice dark left side rail (desktop-first; off-canvas under ~960px)
   =========================================================================== */
.app-shell { display: flex; min-height: 100vh; align-items: stretch; }
.rail {
  flex: 0 0 248px; width: 248px;
  background: var(--ink-2); color: #E7E9ED;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.rail-brand {
  display: flex; align-items: center; gap: .55rem;
  padding: 1rem 1.1rem; color: #fff; text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.rail-brand .brandword { font-size: 1.1rem; }
.rail-register {
  margin: .9rem 1rem .4rem; display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem; padding: .6rem .9rem; border-radius: var(--radius-ctl);
  background: var(--red); color: #fff; font-weight: 700; text-decoration: none;
  transition: background .15s ease;
}
.rail-register:hover { background: var(--red-700); color: #fff; }
.rail-nav { display: flex; flex-direction: column; padding: .4rem .6rem; gap: 2px; }
.rail-link {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .7rem; border-radius: var(--radius-ctl);
  color: #C7CAD1; text-decoration: none; font-weight: 600;
  border-left: 3px solid transparent;
  transition: background .15s ease, color .15s ease;
}
.rail-link .bi { font-size: 1.1rem; width: 1.2rem; text-align: center; flex: 0 0 auto; }
.rail-link:hover { background: rgba(255,255,255,.06); color: #fff; }
/* active-nav rail — a permitted brass accent. */
.rail-link.active {
  background: rgba(194,161,0,.14); color: #fff;
  border-left-color: var(--brass);
}
.rail-spacer { flex: 1 1 auto; }
.rail-bottom { padding: .6rem .8rem 1rem; border-top: 1px solid rgba(255,255,255,.08); }
.rail-langs { display: flex; gap: .5rem; align-items: center; margin-bottom: .6rem; }
.rail-lang {
  display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .5rem;
  border-radius: 999px; text-decoration: none; color: #C7CAD1; font-size: .8rem;
  border: 1px solid transparent;
}
.rail-lang.active { border-color: var(--brass); color: #fff; }
.rail-logout { display: inline-flex; align-items: center; gap: .5rem; color: #C7CAD1; text-decoration: none; font-weight: 600; }
.rail-logout:hover { color: #fff; }

.rail-main { flex: 1 1 auto; min-width: 0; }
.rail-main .content { margin-top: 1.25rem; }

/* Mobile bar with hamburger (hidden on desktop) */
.rail-mobilebar { display: none; }
.rail-scrim { display: none; }

@media (max-width: 960px) {
  .rail {
    position: fixed; top: 0; left: 0; z-index: 1090;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  #rail-toggle:checked ~ .app-shell .rail { transform: translateX(0); }
  #rail-toggle:checked ~ .app-shell .rail-scrim {
    display: block; position: fixed; inset: 0; z-index: 1080; background: rgba(20,22,26,.45);
  }
  .rail-mobilebar {
    display: flex; align-items: center; gap: .7rem;
    background: var(--ink); color: #fff; padding: .55rem .9rem;
  }
  .rail-mobilebar .brand { display: inline-flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; }
  .hamburger {
    display: inline-grid; place-items: center; width: 40px; height: 40px;
    border: none; background: transparent; color: #fff; font-size: 1.4rem; cursor: pointer;
  }
}

@media (max-width: 820px) {
  .board { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .lang-grid { grid-template-columns: repeat(2, 1fr); }
  .action-grid { grid-template-columns: 1fr; }
}

/* Accessibility: visible keyboard focus, reduced motion -------------------- */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, .btn:focus-visible {
  outline: 3px solid var(--brass); outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
