/* =====================================================================
   The app's design system, hand-written CSS (ROADMAP 4.3). No build step,
   no utility framework: pages use the semantic classes below.

   1. Fonts       IBM Plex Sans (text) and Plex Mono (plates, numbers, codes),
                  self-hosted in public/fonts.
   2. Tokens      colours, type, space, radius. Light on :root, dark under
                  .dark (set on <html> before first paint). The accent is
                  the client's brand colour (Settings → General → Brand
                  colour), injected as --brand by partials/shell/head.
   3. Base        elements styled once, at zero specificity (:where), so a
                  page needs no classes on headings, links, inputs, tables.
   4. Layout      .page, .page-head, .grid, .split, .stack, .row
   5. Components  .card, .stats/.stat, .table, .badge, .btn, .field,
                  .filters, .tabs, .alert, .empty, .kv, .progress, .list
   6. Shell       sidebar, top bar, Ctrl+K palette
   7. Utilities   a handful of text helpers (.muted, .num, .mono, …)

   Reference: docs/design.md.
   ===================================================================== */

/* ------------------------------------------------------------ 1. Fonts */
@font-face {
  font-family: "Plex Sans"; font-style: normal; font-weight: 100 700; font-display: swap;
  src: url("../fonts/plex-sans-var.woff2") format("woff2-variations"), url("../fonts/plex-sans-var.woff2") format("woff2");
}
@font-face {
  font-family: "Plex Sans"; font-style: italic; font-weight: 100 700; font-display: swap;
  src: url("../fonts/plex-sans-var-italic.woff2") format("woff2-variations"), url("../fonts/plex-sans-var-italic.woff2") format("woff2");
}
@font-face { font-family: "Plex Mono"; font-weight: 400; font-display: swap; src: url("../fonts/plex-mono-400.woff2") format("woff2"); }
@font-face { font-family: "Plex Mono"; font-weight: 500; font-display: swap; src: url("../fonts/plex-mono-500.woff2") format("woff2"); }
@font-face { font-family: "Plex Mono"; font-weight: 600; font-display: swap; src: url("../fonts/plex-mono-600.woff2") format("woff2"); }

/* ------------------------------------------------------------ 2. Tokens */
:root {
  /* Neutrals: a faintly warm paper and ink, hairline borders. */
  --bg: #F4F4F1;
  --surface: #FFFFFF;
  --surface-2: #FAFAF8;
  --surface-3: #F0F0EC;
  --line: #E2E1DC;
  --line-strong: #CFCEC7;
  --ink: #15171C;
  --text: #2B2E35;
  --muted: #62666F;      /* 5.6:1 on white */
  --faint: #686C75;      /* 4.6:1 on the paper and surface-3, 5.3:1 on white: the lightest text allowed */

  /* Accent: the client's colour, else a deep cobalt. */
  --accent: var(--brand, #1F57B4);
  --accent-strong: color-mix(in oklab, var(--accent) 82%, #000);
  --accent-text: color-mix(in oklab, var(--accent) 90%, #000);
  --accent-soft: color-mix(in oklab, var(--accent) 9%, var(--surface));
  --accent-line: color-mix(in oklab, var(--accent) 35%, var(--surface));
  --on-accent: #FFFFFF;

  /* Meaning, never decoration. Text shades pass 4.5:1 on their soft fill. */
  --good: #17733F;  --good-soft: #E7F3EC;  --good-line: #B9DCC6;
  --warn: #8A5300;  --warn-soft: #FBF1DE;  --warn-line: #EBCD96;
  --bad: #B42318;   --bad-soft: #FCEAE8;   --bad-line: #F1B9B3;
  --info: #1F57B4;  --info-soft: #E8EFFA;  --info-line: #B8CBEC;

  --font: "Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --fs-xs: .75rem;    /* 12 */
  --fs-sm: .8125rem;  /* 13 */
  --fs-md: .875rem;   /* 14: body */
  --fs-lg: 1rem;      /* 16 */
  --fs-xl: 1.25rem;   /* 20 */
  --fs-2xl: 1.5rem;   /* 24: page titles */
  --fs-3xl: 1.875rem; /* 30: stat values */

  --r-sm: 4px; --r: 6px; --r-lg: 10px;
  --gap: 1rem; --gap-sm: .5rem; --gap-lg: 1.5rem;
  --control-h: 2.25rem;
  --shadow-pop: 0 12px 32px rgba(21, 23, 28, .14), 0 2px 6px rgba(21, 23, 28, .06);
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in oklab, var(--accent) 55%, transparent);
  --overlay: rgba(21, 23, 28, .45);

  /* Names the shell and the ported yard screens already read. */
  --app-bg: var(--bg); --app-surface: var(--surface); --app-surface-2: var(--surface-2); --app-surface-3: var(--surface-3);
  --app-border: var(--line); --app-border-strong: var(--line-strong); --app-ink: var(--ink); --app-text: var(--text);
  --app-muted: var(--muted); --app-faint: var(--faint); --app-accent: var(--accent); --app-accent-strong: var(--accent-strong);
  --app-accent-text: var(--accent-text); --app-accent-soft: var(--accent-soft); --app-accent-ring: color-mix(in oklab, var(--accent) 40%, transparent);
  --app-danger: var(--bad); --app-side-bg: var(--surface); --app-side-text: var(--text); --app-side-muted: var(--muted);
  --app-overlay: var(--overlay); --app-shadow-pop: var(--shadow-pop);

  color-scheme: light;
}

.dark {
  --bg: #0E0F12;
  --surface: #16181C;
  --surface-2: #1A1C21;
  --surface-3: #212329;
  --line: #2A2D34;
  --line-strong: #3A3E47;
  --ink: #F1F1EE;
  --text: #D4D5D2;
  --muted: #A2A5AC;
  --faint: #8E929A;

  --accent-strong: color-mix(in oklab, var(--accent) 80%, #fff);
  --accent-text: color-mix(in oklab, var(--accent) 52%, #fff);
  --accent-soft: color-mix(in oklab, var(--accent) 20%, var(--surface));
  --accent-line: color-mix(in oklab, var(--accent) 50%, var(--surface));

  --good: #6CCB94;  --good-soft: #13281D;  --good-line: #24513A;
  --warn: #E7B45C;  --warn-soft: #2B2112;  --warn-line: #5A4220;
  --bad: #F2867B;   --bad-soft: #2E1614;   --bad-line: #5E2A25;
  --info: #8DB0EA;  --info-soft: #15203A;  --info-line: #2D4374;

  --shadow-pop: 0 16px 40px rgba(0, 0, 0, .55);
  --overlay: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ------------------------------------------------------------ 3. Base */
*, *::before, *::after { box-sizing: border-box; border-width: 0; border-style: solid; border-color: var(--line); }
/* The reset the pages were built on (it came with the old utility CSS until 4.3), at zero specificity. */
:where(blockquote, dl, dd, h5, h6, figure, pre) { margin: 0; }
:where(h5, h6) { font-size: inherit; font-weight: 600; }
:where(button, input, select, optgroup, textarea) { font: inherit; letter-spacing: inherit; color: inherit; margin: 0; }
:where(button, [type=button], [type=reset], [type=submit]) { background: none; padding: 0; text-transform: none; -webkit-appearance: button; }
:where(img, svg, video, canvas, iframe, embed, object) { display: block; }
:where(img, video) { height: auto; }
:where(textarea) { resize: vertical; }
:where(:disabled) { cursor: default; }
:where(summary) { display: list-item; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { background: var(--bg); }
body {
  margin: 0; font-family: var(--font); font-size: var(--fs-md); line-height: 1.5; color: var(--text);
  font-feature-settings: "tnum" 0; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { margin: 0; color: var(--ink); line-height: 1.25; font-weight: 600; letter-spacing: -.005em; }
:where(h1) { font-size: var(--fs-2xl); }
:where(h2) { font-size: var(--fs-lg); }
:where(h3) { font-size: var(--fs-md); }
:where(p) { margin: 0; }
:where(ul, ol) { margin: 0; padding: 0; list-style: none; }
:where(.prose ul) { list-style: disc; padding-left: 1.25rem; }
:where(.prose ol) { list-style: decimal; padding-left: 1.25rem; }
:where(.prose) > * + * { margin-top: .5rem; }
:where(a) { color: inherit; text-decoration: none; }
.page a:not([class]), .prose a, .alert a { color: var(--accent-text); }
.page a:not([class]):hover, .prose a:hover { text-decoration: underline; text-underline-offset: 2px; }
:where(img, svg, video) { max-width: 100%; vertical-align: middle; }
:where(hr) { border: 0; border-top: 1px solid var(--line); margin: var(--gap) 0; }
:where(strong, b) { font-weight: 600; color: var(--ink); }
:where(small) { font-size: var(--fs-xs); }
:where(code, kbd, samp) { font-family: var(--font-mono); font-size: .92em; }
:where(table) { border-collapse: collapse; width: 100%; }
:where(fieldset) { margin: 0; padding: 0; border: 0; min-width: 0; }
:where(legend) { padding: 0; font-weight: 600; color: var(--ink); }
:where(button) { font: inherit; color: inherit; cursor: pointer; }
:where(details > summary) { cursor: pointer; }
:where(details > summary)::-webkit-details-marker { display: none; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
::selection { background: color-mix(in oklab, var(--accent) 25%, transparent); }

/* Form controls look the same everywhere without a class. */
input:not([type=checkbox], [type=radio], [type=range], [type=color], [type=file], [type=hidden], [type=submit], [type=button]), select, textarea {
  width: 100%; min-height: var(--control-h); padding: .4rem .65rem;
  font: inherit; font-size: var(--fs-md); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r);
  transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 5rem; resize: vertical; line-height: 1.45; }
select {
  appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2362666F' stroke-width='1.6'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .6rem center; background-size: 14px;
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in oklab, var(--line-strong) 60%, var(--ink)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-3); color: var(--muted); cursor: not-allowed; }
input::placeholder, textarea::placeholder { color: var(--faint); opacity: 1; text-transform: none; letter-spacing: normal; }
input[type=checkbox], input[type=radio] { width: 1rem; height: 1rem; margin: 0; accent-color: var(--accent); vertical-align: -2px; }
input[type=color] { width: 3rem; height: var(--control-h); padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); }
input[type=file] { font-size: var(--fs-sm); color: var(--muted); }
input[type=file]::file-selector-button {
  margin-right: .75rem; padding: .4rem .75rem; border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer;
}
select[multiple], select[size] { background-image: none !important; padding-right: .65rem; }
.dark select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23A2A5AC' stroke-width='1.6'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
}

/* ------------------------------------------------------------ 4. Layout */
.page { padding: 1.25rem 1rem 3rem; display: flex; flex-direction: column; gap: var(--gap-lg); min-width: 0; }
@media (min-width: 768px) { .page { padding: 1.75rem 2rem 3.5rem; } }
.page-narrow { max-width: 56rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .75rem 1.5rem; }
.page-head > :first-child { min-width: 0; flex: 1 1 24rem; }
.page-crumb { display: flex; gap: .4rem; margin-bottom: .35rem; font-size: var(--fs-sm); color: var(--muted); }
.page-crumb a { color: var(--muted); }
.page-crumb a:hover { color: var(--ink); }
.page-title { font-size: var(--fs-2xl); font-weight: 600; color: var(--ink); letter-spacing: -.01em; }
.page-intro { margin-top: .3rem; max-width: 52rem; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }

.stack { display: flex; flex-direction: column; gap: var(--gap); }
.stack-sm { display: flex; flex-direction: column; gap: var(--gap-sm); }
.stack-lg { display: flex; flex-direction: column; gap: var(--gap-lg); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-sm); }
.row-top { align-items: flex-start; }
.row-end { align-items: flex-end; }
.row-between { justify-content: space-between; }
.row-right { justify-content: flex-end; }
.row-nowrap { flex-wrap: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.push { margin-left: auto; }

.grid-2, .grid-3, .grid-4, .grid-5, .grid-6 { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) {
  .grid-2, .grid-3, .grid-4, .grid-5, .grid-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1280px) { .grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.span-2 { grid-column: span 2; } .span-all { grid-column: 1 / -1; }
@media (max-width: 639px) { .span-2 { grid-column: auto; } }
/* Main column with an aside (lists with a form, record pages). */
.split { display: grid; gap: var(--gap-lg); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr) 22rem; }
  .split.aside-wide { grid-template-columns: minmax(0, 1fr) 28rem; }
  .split.aside-left { grid-template-columns: 22rem minmax(0, 1fr); }
  .split.halves { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* The side column is narrow: its form grids use two columns at most. */
  .split:not(.halves) > :last-child .form-grid.cols-3, .split:not(.halves) > :last-child .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split:not(.halves) > :last-child .form-grid .span-all, .split:not(.halves) > :last-child .form-grid .span-2 { grid-column: 1 / -1; }
}

/* ------------------------------------------------------------ 5. Components */

/* Card: a bordered surface. Head (title + actions), body, foot. */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.card-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem;
  padding: .85rem 1.1rem; border-bottom: 1px solid var(--line);
}
.card-title { font-size: var(--fs-md); font-weight: 600; color: var(--ink); }
.card-title .muted { font-weight: 400; }
.card-sub { margin-top: .1rem; font-size: var(--fs-sm); color: var(--muted); }
.card-body { padding: 1.1rem; }
.card-body.tight { padding: .75rem 1.1rem; }
.card-foot { padding: .75rem 1.1rem; border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--muted); }
.card > .table-wrap:first-child .table thead th:first-child { border-top-left-radius: var(--r-lg); }
.card-quiet { background: var(--surface-2); }
.card-accent { border-color: var(--accent-line); background: var(--accent-soft); }
details.card > summary { list-style: none; padding: .85rem 1.1rem; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: .5rem; }
details.card > summary::before { content: ""; width: .45rem; height: .45rem; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
details.card[open] > summary::before { transform: rotate(45deg); }
details.card[open] > summary { border-bottom: 1px solid var(--line); }
details.card > .card-body { padding-top: 1rem; }

/* Stats: the figures at the top of a page. A linked stat filters the list
   below it; .is-active marks the one applied. */
.stats { display: grid; gap: var(--gap-sm); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 768px) { .stats { grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); } }
@media (min-width: 768px) { .stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } } /* eight figures: two even rows rather than six and an orphan pair */
.stat {
  display: flex; flex-direction: column; gap: .15rem; padding: .85rem 1rem; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); color: inherit; text-decoration: none;
}
a.stat:hover { border-color: var(--line-strong); text-decoration: none; }
a.stat.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.stat-label { font-size: var(--fs-sm); color: var(--muted); font-weight: 500; }
.stat-value { font-size: var(--fs-3xl); font-weight: 500; line-height: 1.15; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-value.is-long { font-size: var(--fs-2xl); overflow-wrap: anywhere; }
.stat-value small { font-size: var(--fs-md); font-weight: 400; color: var(--muted); letter-spacing: 0; margin-left: .2rem; }
.stat-note { font-size: var(--fs-xs); color: var(--muted); }
.stat.is-bad .stat-value { color: var(--bad); }
.stat.is-warn .stat-value { color: var(--warn); }
.stat.is-good .stat-value { color: var(--good); }

/* Tables: compact, figures right-aligned and tabular. */
.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; } /* relative: hidden labels (.sr-only) in a wide table stay inside it */
.table { width: 100%; font-size: var(--fs-md); }
.table th, .table td { padding: .6rem 1.1rem; text-align: left; vertical-align: top; }
.table thead th {
  font-size: var(--fs-xs); font-weight: 600; color: var(--muted); white-space: nowrap;
  background: var(--surface-2); border-bottom: 1px solid var(--line); padding-top: .55rem; padding-bottom: .55rem;
}
.table tbody tr + tr td, .table tbody tr + tr th { border-top: 1px solid var(--line); }
.table tbody tr:hover td { background: var(--surface-2); }
.table thead .sort { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: .25rem; }
.table thead .sort:hover { color: var(--ink); }
.table thead .sort.is-sorted { color: var(--ink); }
.table thead .sort.is-sorted::after { content: ""; border: 4px solid transparent; }
.table thead .sort.is-asc::after { border-bottom-color: currentColor; margin-top: -4px; }
.table thead .sort.is-desc::after { border-top-color: currentColor; margin-top: 4px; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.act, .table th.act { text-align: right; white-space: nowrap; width: 1%; }
.table .sub { display: block; font-size: var(--fs-xs); color: var(--muted); }
.table td .row { gap: .35rem; }
.table tfoot td { border-top: 1px solid var(--line-strong); font-weight: 600; color: var(--ink); }
.table-dense th, .table-dense td { padding: .4rem .8rem; }
.table tr.is-flagged td:first-child { box-shadow: inset 3px 0 0 var(--bad); }

/* Badges: state in words, with a dot. Tone by meaning. */
.badge {
  display: inline-flex; align-items: center; gap: .35rem; padding: .1rem .5rem; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 500; line-height: 1.35rem; white-space: nowrap;
  background: var(--surface-3); color: var(--text); border: 1px solid var(--line);
}
.badge::before { content: ""; width: .4rem; height: .4rem; border-radius: 50%; background: currentColor; opacity: .75; }
.badge.no-dot::before { display: none; }
.badge-good { background: var(--good-soft); color: var(--good); border-color: var(--good-line); }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.badge-bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: var(--info-line); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-line); }
.count { display: inline-block; min-width: 1.4rem; padding: 0 .4rem; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; line-height: 1.25rem; text-align: center; background: var(--surface-3); color: var(--muted); font-variant-numeric: tabular-nums; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: var(--control-h); padding: .4rem .9rem; border-radius: var(--r);
  font: inherit; font-size: var(--fs-md); font-weight: 500; line-height: 1.2; white-space: nowrap;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none; transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled, .btn[aria-disabled=true] { opacity: .55; cursor: not-allowed; }
.btn svg, .btn i[data-lucide] { width: 1rem; height: 1rem; flex: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-danger { background: var(--surface); border-color: var(--bad-line); color: var(--bad); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-danger-solid { background: #B42318; border-color: #B42318; color: #fff; }
.btn-danger-solid:hover { background: #912018; border-color: #912018; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--accent-text); }
.btn-quiet:hover { background: var(--accent-soft); }
.btn-sm { min-height: 1.875rem; padding: .25rem .65rem; font-size: var(--fs-sm); }
.btn-icon { padding: 0; width: var(--control-h); }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; }
.btn-group > .btn { border-radius: 0; }
.btn-group > .btn + .btn { margin-left: -1px; }
.btn-group > .btn:first-child { border-radius: var(--r) 0 0 var(--r); }
.btn-group > .btn:last-child { border-radius: 0 var(--r) var(--r) 0; }
.link { color: var(--accent-text); font-weight: 500; background: none; border: 0; padding: 0; cursor: pointer; font: inherit; }
.link:hover { text-decoration: underline; text-underline-offset: 2px; }
.link-danger { color: var(--bad); }

/* Forms */
.form { display: grid; gap: 1rem; }
.form-grid { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) {
  .form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field > label, .label { font-size: var(--fs-sm); font-weight: 500; color: var(--text); }
.field .opt, .label .opt { font-weight: 400; color: var(--muted); }
.hint { font-size: var(--fs-xs); color: var(--muted); }
.error { font-size: var(--fs-xs); color: var(--bad); font-weight: 500; }
.field.has-error :where(input, select, textarea) { border-color: var(--bad); }
.check { display: inline-flex; align-items: flex-start; gap: .5rem; font-size: var(--fs-md); color: var(--text); cursor: pointer; }
.check input { margin-top: .2rem; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.form-section + .form-section { border-top: 1px solid var(--line); padding-top: 1.25rem; }
.form-section > h3 { margin-bottom: .75rem; }
.form-section-head { margin-bottom: .9rem; }

/* Filters: a row of fields over a list. */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem .75rem; padding: .85rem 1.1rem; border-bottom: 1px solid var(--line); }
.filters .field { flex: 0 1 11rem; }
.filters .field.wide { flex: 1 1 16rem; }
.filters .field > label { font-size: var(--fs-xs); color: var(--muted); }
.filters .check { align-self: center; margin-bottom: .45rem; font-size: var(--fs-sm); }

/* Tabs: views of one list. Each shows its count. */
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--line); }
.tab {
  display: inline-flex; align-items: center; gap: .45rem; padding: .55rem .8rem; margin-bottom: -1px;
  font-size: var(--fs-md); font-weight: 500; color: var(--muted); text-decoration: none;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.is-active, .tab[aria-current] { color: var(--ink); border-bottom-color: var(--accent); }
.tab.is-active .count, .tab[aria-current] .count { background: var(--accent-soft); color: var(--accent-text); }
.card > .tabs { padding: 0 1.1rem; }

/* Segmented control: a small choice of views (period, theme). */
.segmented { display: inline-flex; padding: 2px; border-radius: var(--r); background: var(--surface-3); border: 1px solid var(--line); }
.segmented a, .segmented button, .segmented label { padding: .3rem .7rem; border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 500; color: var(--muted); border: 0; background: none; text-decoration: none; cursor: pointer; }
.segmented .is-active, .segmented [aria-current], .segmented input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* Toggle buttons: checkboxes shown as buttons (days of the week). */
.toggles { display: inline-flex; flex-wrap: wrap; gap: .35rem; }
.toggles label { position: relative; }
.toggles input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.toggles span { display: inline-block; min-width: 2.75rem; text-align: center; padding: .35rem .65rem; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); color: var(--text); font-size: var(--fs-sm); font-weight: 500; }
.toggles input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.toggles input:focus-visible + span { box-shadow: var(--focus); }

/* Alerts */
.alert { display: flex; gap: .65rem; align-items: flex-start; padding: .75rem 1rem; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-size: var(--fs-md); }
.alert > svg, .alert > i[data-lucide] { width: 1.1rem; height: 1.1rem; flex: none; margin-top: .1rem; }
.alert strong { color: inherit; }
.alert a { color: inherit; text-decoration: underline; text-underline-offset: 2px; font-weight: 500; }
.alert a.btn { color: var(--ink); text-decoration: none; }
.alert a.btn-primary, .alert a.btn-danger-solid { color: #fff; }
.alert-good { background: var(--good-soft); border-color: var(--good-line); color: var(--good); }
.alert-warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.alert-bad { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.alert-info { background: var(--info-soft); border-color: var(--info-line); color: var(--info); }
.alert ul { list-style: disc; padding-left: 1.1rem; }

/* Empty states: say what would appear and, when it helps, what to do. */
.empty { padding: 2.5rem 1.25rem; text-align: center; color: var(--muted); }
.empty strong { display: block; margin-bottom: .2rem; color: var(--ink); font-weight: 600; }
.empty .btn { margin-top: .9rem; }
.empty-sm { padding: 1.25rem; }

/* Key / value pairs on record pages. */
.kv { display: grid; grid-template-columns: minmax(8rem, 38%) minmax(0, 1fr); gap: .5rem 1rem; font-size: var(--fs-md); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.kv-cols { display: grid; gap: .25rem 1.5rem; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); }
.kv-cols > div { display: flex; flex-direction: column; padding: .4rem 0; }
.kv-cols dt { font-size: var(--fs-xs); color: var(--muted); }
.kv-cols dd { margin: 0; color: var(--ink); font-weight: 500; }

/* Progress and meters */
.progress { height: .4rem; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.progress.is-good > span { background: var(--good); }
.progress.is-warn > span { background: var(--warn); }
.progress.is-bad > span { background: var(--bad); }

/* Divided list (activity, alerts, files). */
.list > li { padding: .7rem 1.1rem; }
.list > li + li { border-top: 1px solid var(--line); }
.list-tight > li { padding: .5rem 1.1rem; }
.list .meta { font-size: var(--fs-xs); color: var(--muted); }

/* Timeline (history of a record). */
.timeline { position: relative; padding-left: 1.25rem; }
.timeline::before { content: ""; position: absolute; left: .3rem; top: .35rem; bottom: .35rem; width: 1px; background: var(--line-strong); }
.timeline > li { position: relative; padding: 0 0 1rem; }
.timeline > li::before { content: ""; position: absolute; left: -1.2rem; top: .4rem; width: .55rem; height: .55rem; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.timeline > li:last-child { padding-bottom: 0; }
.timeline > li.is-good::before { border-color: var(--good); background: var(--good); }
.timeline > li.is-bad::before { border-color: var(--bad); background: var(--bad); }

/* Status dot (live boards). */
.dot { display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--faint); }
.dot.is-good { background: var(--good); } .dot.is-warn { background: var(--warn); } .dot.is-bad { background: var(--bad); } .dot.is-info { background: var(--info); }

/* Plate: a vehicle's registration, as printed. */
.plate { display: inline-block; padding: .05rem .4rem; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface-2); font-family: var(--font-mono); font-weight: 600; font-size: .85em; letter-spacing: .04em; color: var(--ink); white-space: nowrap; }

/* Pagination (Laravel's links rendered by vendor/pagination). */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem 1.1rem; border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--muted); }
.pager-links { display: flex; gap: .25rem; flex-wrap: wrap; }
.pager-links a, .pager-links span { min-width: 2rem; padding: .3rem .55rem; border-radius: var(--r); text-align: center; border: 1px solid var(--line); color: var(--text); text-decoration: none; background: var(--surface); }
.pager-links a:hover { border-color: var(--line-strong); }
.pager-links .is-current { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.pager-links .is-disabled { color: var(--faint); background: var(--surface-2); }

/* Toasts and flash messages (shell). */
.flash { margin: 0; }

/* Modal dialog (<dialog class="modal">). */
dialog.modal { width: min(32rem, calc(100vw - 2rem)); padding: 0; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop); }
dialog.modal::backdrop { background: var(--overlay); }
.modal-head { padding: 1rem 1.25rem .5rem; }
.modal-body { padding: .5rem 1.25rem 1rem; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .85rem 1.25rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* Charts drawn as bars in HTML (reports). */
.bars > li { display: grid; grid-template-columns: minmax(6rem, 30%) minmax(0, 1fr) auto; gap: .75rem; align-items: center; padding: .3rem 0; font-size: var(--fs-sm); }
.bars .bar { height: .55rem; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bars .bar > span { display: block; height: 100%; background: var(--accent); }

/* ------------------------------------------------------------ 6. Shell */
.app-shell { min-height: 100vh; background: var(--bg); }
.app-sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 40; width: 15.5rem; display: flex; flex-direction: column;
  background: var(--app-side-bg); border-right: 1px solid var(--line);
  transform: translateX(-100%); transition: transform .2s ease;
}
.app-sidebar.is-open { transform: translateX(0); }
.app-backdrop { position: fixed; inset: 0; z-index: 35; background: var(--overlay); display: none; }
.app-backdrop.is-open { display: block; }
.app-main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
@media (min-width: 1024px) {
  .app-sidebar { transform: none; }
  .app-backdrop, .app-backdrop.is-open { display: none; }
  .app-main { margin-left: 15.5rem; }
  .app-menu-btn { display: none !important; }
}
.sb-brand {
  height: 3.5rem; flex: none; display: flex; align-items: center; gap: .6rem; padding: 0 1.1rem;
  border-bottom: 1px solid var(--line); color: var(--ink); font-weight: 600; font-size: var(--fs-md); text-decoration: none; line-height: 1.2;
}
.sb-brand:hover { text-decoration: none; }
.sb-brand-logo { max-height: 2rem; max-width: 3rem; width: auto; object-fit: contain; flex: none; }
.sb-brand-mark { width: 1.85rem; height: 1.85rem; border-radius: var(--r); display: grid; place-items: center; background: var(--ink); color: var(--bg); flex: none; font-weight: 600; font-size: var(--fs-md); }
.sb-brand-mark svg { width: 1rem; height: 1rem; }
.sb-brand-sub { display: block; font-size: var(--fs-xs); font-weight: 400; color: var(--muted); }
.sb-scroll { flex: 1; overflow-y: auto; padding: .6rem .6rem 1.5rem; scrollbar-width: thin; }
.sb-heading { margin: 1.1rem .65rem .35rem; font-size: var(--fs-xs); font-weight: 500; color: var(--faint); }
.sb-section:first-child .sb-heading { margin-top: .25rem; }
.sb-link, .sb-module-btn {
  width: 100%; display: flex; align-items: center; gap: .65rem; padding: .45rem .65rem; border-radius: var(--r);
  border: 0; background: none; color: var(--text); font-size: var(--fs-md); font-weight: 450; text-align: left;
  text-decoration: none; cursor: pointer; transition: background .12s, color .12s;
}
.sb-link:hover, .sb-module-btn:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.sb-link.is-active { background: var(--accent-soft); color: var(--accent-text); font-weight: 550; }
.sb-module.is-active > .sb-module-btn { color: var(--ink); font-weight: 550; }
.sb-module.is-active > .sb-module-btn .sb-icon { color: var(--accent-text); }
.sb-icon { width: 1rem; height: 1rem; flex: none; color: var(--muted); }
.sb-link.is-active .sb-icon { color: var(--accent-text); }
.sb-label { flex: 1; min-width: 0; line-height: 1.3; overflow-wrap: anywhere; }
.sb-toggle { width: .9rem; height: .9rem; flex: none; position: relative; color: var(--faint); }
.sb-toggle::before { content: ""; position: absolute; inset: .2rem .25rem .3rem; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; }
.sb-module.is-open .sb-toggle::before { transform: rotate(45deg); }
.sb-children { display: none; margin: .1rem 0 .35rem 1.15rem; padding-left: .7rem; border-left: 1px solid var(--line); }
.sb-module.is-open .sb-children { display: block; }
.sb-module.is-open .sb-module-badge { display: none; }
.sb-child { display: flex; align-items: center; gap: .5rem; padding: .35rem .55rem; border-radius: var(--r); color: var(--muted); font-size: var(--fs-sm); text-decoration: none; }
.sb-child:hover { color: var(--ink); background: var(--surface-3); text-decoration: none; }
.sb-child.is-active { color: var(--accent-text); background: var(--accent-soft); font-weight: 550; }
.sb-badge { min-width: 1.3rem; padding: 0 .4rem; border-radius: 999px; text-align: center; font-size: var(--fs-xs); font-weight: 600; line-height: 1.2rem; background: var(--surface-3); color: var(--muted); font-variant-numeric: tabular-nums; }
.sb-link.is-active .sb-badge, .sb-child.is-active .sb-badge { background: var(--surface); color: var(--accent-text); }

.app-topbar {
  position: sticky; top: 0; z-index: 30; height: 3.5rem; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 1rem; background: color-mix(in oklab, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
@media (min-width: 768px) { .app-topbar { padding: 0 2rem; } }
.tb-btn {
  position: relative; display: inline-grid; place-items: center; width: 2.125rem; height: 2.125rem; border-radius: var(--r);
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; transition: background .12s, color .12s;
}
.tb-btn:hover { background: var(--surface-3); color: var(--ink); }
.tb-btn svg { width: 1.05rem; height: 1.05rem; }
.tb-count { position: absolute; top: .1rem; right: .1rem; min-width: 1rem; height: 1rem; padding: 0 .25rem; border-radius: 999px; background: #B42318; color: #fff; font-size: .625rem; font-weight: 700; display: grid; place-items: center; }
.tb-jump {
  display: flex; align-items: center; gap: .6rem; width: min(24rem, 45vw); height: 2.125rem; padding: 0 .7rem; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface); color: var(--faint); font: inherit; font-size: var(--fs-md); cursor: pointer; text-align: left;
}
.tb-jump:hover { border-color: var(--line-strong); }
.tb-jump span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) { .tb-jump .tb-kbd { display: none; } }
.tb-jump svg { width: 1rem; height: 1rem; }
.tb-kbd, .pal-kbd { font: 500 .6875rem/1 var(--font-mono); padding: .2rem .35rem; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); }
.theme-icon-dark { display: none; }
.dark .theme-icon-dark { display: block; }
.dark .theme-icon-light { display: none; }
.tb-menu { position: absolute; right: 0; top: calc(100% + .4rem); z-index: 50; min-width: 13rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: .3rem; display: none; }
.tb-menu.is-open { display: block; }
.tb-menu-head { padding: .55rem .7rem; border-bottom: 1px solid var(--line); margin-bottom: .3rem; }
.tb-menu-head strong { display: block; color: var(--ink); font-size: var(--fs-md); }
.tb-menu-head span { color: var(--muted); font-size: var(--fs-xs); }
.tb-menu a, .tb-menu button.tb-menu-item { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .45rem .7rem; border-radius: var(--r); color: var(--text); font-size: var(--fs-md); text-decoration: none; background: none; border: 0; cursor: pointer; text-align: left; }
.tb-menu a:hover, .tb-menu button.tb-menu-item:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.tb-menu .is-danger { color: var(--bad); }
.tb-menu svg { width: 1rem; height: 1rem; }

.pal { position: fixed; inset: 0; z-index: 100; display: none; background: var(--overlay); padding: 12vh 1rem 1rem; }
.pal.is-open { display: block; }
.pal-box { max-width: 36rem; margin: 0 auto; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); overflow: hidden; }
.pal-search { display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.pal-search svg { width: 1.1rem; height: 1.1rem; color: var(--muted); flex: none; }
.pal-search input { flex: 1; border: 0 !important; outline: 0; box-shadow: none !important; background: transparent !important; color: var(--ink) !important; font-size: var(--fs-lg); padding: 0; min-height: 0; }
.pal-list { max-height: min(24rem, 60vh); overflow-y: auto; padding: .35rem; margin: 0; list-style: none; }
.pal-item { display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem; border-radius: var(--r); color: var(--text); text-decoration: none; font-size: var(--fs-md); }
.pal-item:hover { text-decoration: none; }
.pal-item small { margin-left: auto; color: var(--muted); font-size: var(--fs-xs); }
.pal-item.is-selected { background: var(--accent-soft); color: var(--accent-text); }
.pal-item.is-selected small { color: var(--accent-text); }
.pal-empty { padding: 1.25rem; text-align: center; color: var(--muted); font-size: var(--fs-md); }
.pal-foot { display: flex; gap: 1rem; padding: .5rem 1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: var(--fs-xs); }
@media (prefers-reduced-motion: reduce) { .app-sidebar, details.card > summary::before, .sb-toggle::before { transition: none; } }

/* Toasts (showToast) */
.toast-stack { position: fixed; top: 1rem; right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: .5rem; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: .6rem; width: min(26rem, calc(100vw - 2rem)); padding: .7rem .85rem;
  border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop);
  font-size: var(--fs-md); transform: translateX(110%); opacity: 0; transition: transform .25s ease, opacity .25s ease;
}
.toast.is-in { transform: none; opacity: 1; }
.toast-icon { flex: none; margin-top: .1rem; }
.toast-icon svg { width: 1.05rem; height: 1.05rem; }
.toast-text { flex: 1; min-width: 0; }
.toast-close { flex: none; border: 0; background: none; color: var(--muted); padding: .1rem; border-radius: var(--r-sm); }
.toast-close:hover { color: var(--ink); }
.toast.is-success .toast-icon { color: var(--good); }
.toast.is-error .toast-icon { color: var(--bad); }
.toast.is-warning .toast-icon { color: var(--warn); }
.toast.is-info .toast-icon { color: var(--info); }
.toast.is-error { border-color: var(--bad-line); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* Confirm dialog (showConfirm) */
.confirm { position: fixed; inset: 0; z-index: 9998; display: grid; place-items: center; padding: 1rem; background: var(--overlay); }
.confirm[hidden] { display: none; }
.confirm-box { width: min(28rem, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); }
.confirm-body { display: flex; gap: .85rem; padding: 1.25rem 1.25rem 1rem; }
.confirm-title { font-size: var(--fs-lg); margin-bottom: .2rem; }
.confirm-icon { flex: none; width: 2.25rem; height: 2.25rem; border-radius: 50%; display: grid; place-items: center; }
.confirm-icon svg { width: 1.1rem; height: 1.1rem; }
.confirm-icon.is-warn { background: var(--warn-soft); color: var(--warn); }
.confirm-icon.is-bad { background: var(--bad-soft); color: var(--bad); }
.confirm-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .85rem 1.25rem; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* Notifications dropdown (top bar) */
.notif { position: relative; }
.notif-menu { position: absolute; right: 0; top: calc(100% + .4rem); z-index: 50; width: min(24rem, calc(100vw - 2rem)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); overflow: hidden; }
.notif-head, .notif-foot { display: flex; align-items: center; justify-content: space-between; padding: .7rem 1rem; }
.notif-head { border-bottom: 1px solid var(--line); }
.notif-foot { border-top: 1px solid var(--line); justify-content: center; background: var(--surface-2); }
.notif-list { max-height: 26rem; overflow-y: auto; }
.notif-item { display: flex; gap: .7rem; padding: .75rem 1rem; color: var(--text); text-decoration: none; }
.notif-item + .notif-item { border-top: 1px solid var(--line); }
.notif-item:hover { background: var(--surface-2); text-decoration: none; }
.notif-item.is-unread { background: var(--accent-soft); }
.notif-item .dot { margin-top: .4rem; flex: none; }
.notif-text { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.notif-title { font-weight: 500; color: var(--ink); }
.notif-msg { font-size: var(--fs-sm); color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-time { font-size: var(--fs-xs); color: var(--faint); }
.notif-text .btn { align-self: flex-start; margin-top: .3rem; }

/* The running shift, at the foot of the sidebar */
.shift-strip { margin: 0 .6rem .6rem; padding: .7rem .8rem; display: flex; flex-direction: column; gap: .2rem; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface-2); font-size: var(--fs-sm); }
.shift-strip.is-on { border-color: var(--good-line); }
.shift-strip.is-break { border-color: var(--warn-line); background: var(--warn-soft); }
.shift-strip.is-off { border-style: dashed; }
.shift-strip-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; margin-top: .45rem; }
.shift-strip-start { margin-top: .45rem; }

/* Dashboard: items needing attention, and a column chart drawn in HTML. */
.attention { display: flex; align-items: center; justify-content: space-between; gap: .75rem; color: var(--text); text-decoration: none; }
.attention:hover { color: var(--ink); text-decoration: none; }
.attention-n { font-size: var(--fs-lg); font-weight: 600; color: var(--ink); }
.attention.is-bad .attention-n { color: var(--bad); }
.attention.is-warn .attention-n { color: var(--warn); }
.colchart { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: .4rem; align-items: end; height: 13rem; }
.colchart > li { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; gap: .25rem; }
.colchart-bar { display: flex; flex-direction: column-reverse; justify-content: flex-start; width: 100%; max-width: 2.25rem; height: calc(100% - 2.6rem); border-radius: var(--r-sm) var(--r-sm) 0 0; overflow: hidden; border-bottom: 1px solid var(--line-strong); }
.colchart-bar > .is-good { background: var(--good); }
.colchart-bar > .is-bad { background: var(--bad); }
.colchart-bar > .is-info { background: var(--info); }
.colchart-bar > .is-warn { background: var(--warn); }
.colchart-n { font-size: var(--fs-xs); color: var(--ink); line-height: 1; min-height: .75rem; }
.colchart-label { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; line-height: 1; }
@media (max-width: 640px) { .colchart-label { writing-mode: vertical-rl; transform: rotate(180deg); } .colchart { height: 15rem; } }

/* Dashboard: one panel per part of the business (lead figure, a split bar, the counts behind it). */
.section-title { font-size: var(--fs-lg); font-weight: 600; color: var(--ink); }
.modgrid { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .modgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1180px) { .modgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.mod { display: flex; flex-direction: column; }
.mod-body { display: grid; gap: .75rem; }
.mod-lead { display: grid; gap: .1rem; color: inherit; text-decoration: none; }
.mod-lead:hover { text-decoration: none; }
.mod-lead:hover .mod-label { color: var(--ink); }
.mod-value { font-size: var(--fs-3xl); font-weight: 500; line-height: 1.1; letter-spacing: -.02em; color: var(--ink); }
.mod-value small { margin-left: .3rem; font-size: var(--fs-md); font-weight: 400; letter-spacing: 0; color: var(--muted); }
.mod-label { font-size: var(--fs-sm); color: var(--muted); }
.mod-lead.is-warn .mod-value { color: var(--warn); }
.mod-lead.is-bad .mod-value { color: var(--bad); }
.mod-rows { margin-top: auto; border-top: 1px solid var(--line); font-size: var(--fs-sm); }
.mod-n { font-weight: 600; color: var(--ink); }
.attention.is-bad .mod-n { color: var(--bad); }
.attention.is-warn .mod-n { color: var(--warn); }
.segbar { display: flex; gap: 2px; height: .5rem; border-radius: 999px; overflow: hidden; background: var(--surface-3); }
.segbar > span { min-width: 3px; }
.segbar-legend { display: flex; flex-wrap: wrap; gap: .25rem .9rem; margin: 0; padding: 0; list-style: none; font-size: var(--fs-xs); color: var(--muted); }
.segbar-legend li { display: inline-flex; align-items: center; gap: .35rem; }
.segbar-legend .num { color: var(--ink); font-weight: 600; }
.segbar > .is-good { background: var(--good); }
.segbar > .is-warn { background: var(--warn); }
.segbar > .is-bad { background: var(--bad); }
.segbar > .is-accent, .dot.is-accent { background: var(--accent); }
.segbar > .is-muted, .dot.is-muted { background: var(--line-strong); }

/* Dashboard: the yards now (a map per yard, its figures, every yard in a table). */
.yard-now { display: grid; gap: var(--gap-lg); padding: 1.1rem; grid-template-columns: minmax(0, 1fr); }
.yard-now[hidden] { display: none; }
@media (min-width: 1100px) { .yard-now { grid-template-columns: minmax(0, 1fr) 19rem; } }
.yard-map-cell { min-width: 0; display: grid; gap: .6rem; padding: .75rem; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2); }
.yard-figs { display: flex; flex-direction: column; gap: 1rem; }
.yard-figs .btn { align-self: flex-start; }
.figs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--line); }
.figs > div { display: flex; flex-direction: column; gap: .15rem; padding: .65rem .8rem; background: var(--surface); }
.figs dt { font-size: var(--fs-xs); color: var(--muted); }
.figs dd { margin: 0; font-size: var(--fs-xl); font-weight: 600; color: var(--ink); }
.figs dd small { font-size: var(--fs-xs); font-weight: 400; color: var(--muted); }
.figs .is-bad dd { color: var(--bad); }
.figs .is-warn dd { color: var(--warn); }
.yard-table { border-top: 1px solid var(--line); }
.yardmap { display: block; width: 100%; height: auto; max-height: 26rem; margin: 0 auto; }
.yardmap-boundary { fill: none; stroke: var(--line-strong); stroke-width: 2; stroke-dasharray: 8 6; }
.yardmap-zone { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.5; }
.yardmap-zone-name { font-family: var(--font); font-size: 12px; font-weight: 600; fill: var(--muted); }
.bay rect { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1.25; }
.bay text { font-family: var(--font-mono); font-weight: 600; text-anchor: middle; dominant-baseline: central; fill: var(--muted); pointer-events: none; }
.bay.is-busy rect { fill: var(--accent); stroke: var(--accent-strong); }
.bay.is-busy text, .bay.is-late text { fill: var(--on-accent); }
.bay.is-late rect { fill: var(--bad); stroke: var(--bad); }
.bay.is-flagged rect { fill: var(--warn-soft); stroke: var(--warn); stroke-width: 2; }
.bay.is-flagged text { fill: var(--warn); }
.bay.is-reserved rect { fill: var(--accent-soft); stroke: var(--accent); stroke-dasharray: 3 2; }
.bay.is-reserved text { fill: var(--accent-text); }
.bay.is-closed rect { fill: var(--surface-3); stroke: var(--line); }
.bay.is-closed text { fill: var(--faint); }
.dark .bay.is-late text { fill: #1A0A08; }
.yardmap-legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin: 0; padding: 0; list-style: none; font-size: var(--fs-xs); color: var(--text); }
.yardmap-legend li { display: inline-flex; align-items: center; gap: .4rem; }
.bay-swatch { width: .8rem; height: .8rem; border-radius: 3px; border: 1.25px solid var(--line-strong); background: var(--surface); }
.bay-swatch.is-busy { background: var(--accent); border-color: var(--accent-strong); }
.bay-swatch.is-late { background: var(--bad); border-color: var(--bad); }
.bay-swatch.is-flagged { background: var(--warn-soft); border: 2px solid var(--warn); }
.bay-swatch.is-reserved { background: var(--accent-soft); border: 1.25px dashed var(--accent); }
.bay-swatch.is-closed { background: var(--surface-3); border-color: var(--line); }

/* Popover: a small form opened from a row (<details class="pop">). */
details.pop { position: relative; display: inline-block; text-align: left; }
details.pop > summary { list-style: none; }
.pop-panel {
  position: absolute; right: 0; top: calc(100% + .4rem); z-index: 20; width: min(32rem, 86vw); padding: 1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); white-space: normal;
}


/* A row's action menu: <details class="pop"><summary class="btn btn-sm btn-icon">…</summary><div class="pop-panel pop-menu">links and buttons</div></details> */
.pop-panel.pop-menu { width: 13rem; padding: .3rem; }
.pop-menu > a, .pop-menu > button, .pop-menu > form > button {
  display: flex; align-items: center; gap: .6rem; width: 100%; padding: .45rem .7rem; border: 0; border-radius: var(--r);
  background: none; color: var(--text); font: inherit; font-size: var(--fs-md); text-align: left; text-decoration: none; cursor: pointer;
}
.pop-menu > a:hover, .pop-menu > button:hover, .pop-menu > form > button:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.pop-menu .is-danger { color: var(--bad); }
.pop-menu hr { margin: .3rem 0; }
.pop-menu svg, .pop-menu i[data-lucide] { width: 1rem; height: 1rem; flex: none; }

/* A week, day by day (workshop schedule). */
.week { display: grid; gap: .6rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 700px) { .week { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .week { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.week-day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.week-day.is-today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.week-day-head { display: flex; align-items: center; justify-content: space-between; padding: .55rem .7rem; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.week-day.is-today .week-day-head { color: var(--accent-text); }
.week-day-list { padding: .45rem; display: flex; flex-direction: column; gap: .45rem; }
.week-item { padding: .5rem .55rem; border: 1px solid var(--line); border-radius: var(--r); font-size: var(--fs-xs); display: flex; flex-direction: column; gap: .15rem; background: var(--surface); }
.week-item.is-done { background: var(--surface-2); color: var(--muted); }
.week-item .badge { font-size: .6875rem; line-height: 1.1rem; padding: 0 .4rem; }



/* A route on the planning board. */
.route-card { display: flex; flex-direction: column; gap: .35rem; padding: .85rem 1rem; color: inherit; text-decoration: none; }
.route-card:hover { border-color: var(--line-strong); text-decoration: none; }


/* Maps (Leaflet). */
.map-card { overflow: hidden; }
.map { height: 20rem; width: 100%; background: var(--surface-3); }
.map-lg { height: 32rem; }
.map-pin { width: 1.6rem; height: 1.6rem; border-radius: 50%; display: grid; place-items: center; color: #fff; font: 600 .75rem/1 var(--font); border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.leaflet-container { font-family: var(--font); }
.dark .leaflet-tile-pane { filter: brightness(.82) contrast(1.05) saturate(.85); }
.pick-list { max-height: 18rem; overflow-y: auto; }


/* A choice between ways of doing something (New delivery). */
.choice { display: flex; flex-direction: column; gap: .3rem; padding: 1rem 1.1rem; color: inherit; text-decoration: none; }
.choice:hover { border-color: var(--line-strong); text-decoration: none; }
.choice.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.choice-title { display: flex; align-items: center; gap: .45rem; font-weight: 600; color: var(--ink); }


/* Forms with a summary on the side (the full delivery form). */
@media (min-width: 1100px) { .sticky-aside { position: sticky; top: 4.5rem; } }
.items-table td { padding-top: .45rem; padding-bottom: .45rem; vertical-align: middle; }
.items-table input { min-height: 2rem; }
input.num { text-align: right; font-variant-numeric: tabular-nums; }


/* A row that opens into its form (document types). */
details.doc-type + details.doc-type { border-top: 1px solid var(--line); }
details.doc-type > summary { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .75rem; padding: .8rem 1.1rem; }
details.doc-type > summary:hover { background: var(--surface-2); }
details.doc-type[open] > summary { border-bottom: 1px solid var(--line); }

/* ------------------------------------------------------------ 7. Utilities */
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.ink { color: var(--ink); }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }
.strong { font-weight: 600; color: var(--ink); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: .92em; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-good { color: var(--good); } .text-warn { color: var(--warn); } .text-bad { color: var(--bad); } .text-info { color: var(--info); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.icon { display: inline-block; width: 1rem; height: 1rem; flex: none; vertical-align: -.15em; } /* inline: the reset makes svg a block, which broke "icon + text" links onto two lines */
.icon-sm { width: .875rem; height: .875rem; }
.icon-lg { width: 1.25rem; height: 1.25rem; }
.mt-0 { margin-top: 0 !important; }

/* A person: initials or photo, then name and a line under it (drivers, users). */
.avatar { flex: none; display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 50%; overflow: hidden; background: var(--surface-3); color: var(--muted); font-size: var(--fs-xs); font-weight: 600; letter-spacing: .02em; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.avatar-lg { width: 3.5rem; height: 3.5rem; font-size: var(--fs-md); }
.person { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.person > div { min-width: 0; }

/* Roster: people down, days across; a shift is a chip coloured by role. */
.roster th:first-child, .roster td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 9.5rem; }
.roster th:not(:first-child), .roster td:not(:first-child) { min-width: 6.75rem; padding-left: .35rem; padding-right: .35rem; vertical-align: top; }
.roster .is-today { background: var(--accent-soft); }
.roster thead .is-today { color: var(--accent-text); }
.roster tfoot td { background: var(--surface-2); }
.chip { display: flex; flex-direction: column; gap: .05rem; padding: .3rem .45rem; font-size: var(--fs-xs); line-height: 1.35; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--chip, var(--line-strong)); border-radius: var(--r-sm); }
.chip.is-gate { --chip: var(--good); } .chip.is-dock { --chip: var(--info); } .chip.is-manager { --chip: var(--warn); }
.chip-x { border: 0; background: none; padding: 0 .15rem; color: var(--muted); font-size: 1rem; line-height: 1; cursor: pointer; }
.chip-x:hover { color: var(--bad); }
.slot-add { width: 100%; padding: .1rem; border: 1px dashed var(--line-strong); border-radius: var(--r-sm); background: none; color: var(--muted); font: inherit; font-size: var(--fs-xs); cursor: pointer; }
.slot-add:hover { background: var(--surface-2); color: var(--ink); }

/* Option cards: a radio choice with a title and a line under it (start a shift). */
.option { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem .9rem; border: 1px solid var(--line-strong); border-radius: var(--r-lg); background: var(--surface); cursor: pointer; }
.option:hover { background: var(--surface-2); }
.option:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.option > input { margin-top: .2rem; flex: none; }
.option-title { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-weight: 600; color: var(--ink); }
.option-sub { display: block; font-size: var(--fs-xs); color: var(--muted); }
.option[hidden] { display: none; }

/* Month calendar (my shifts). */
.cal { display: grid; gap: .35rem; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-name { text-align: center; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cal-day { min-height: 5.5rem; padding: .4rem; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); font-size: var(--fs-xs); display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.cal-day.is-today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day.is-outside { opacity: .45; }
.cal-num { font-weight: 600; color: var(--muted); }
.cal-day.is-today .cal-num { color: var(--accent-text); }
@media (max-width: 640px) { .cal { grid-template-columns: 1fr; } .cal-name, .cal-day.is-outside, .cal-day.is-off { display: none; } .cal-day { min-height: 0; } }

/* The gate code to print (yards): always black on white. */
.gate-code { display: inline-flex; flex-direction: column; align-items: center; gap: .5rem; max-width: 100%; padding: 1.5rem 2rem; background: #fff; color: #15171C; border: 1px dashed var(--line-strong); border-radius: var(--r-lg); }
.gate-code svg { max-width: 100%; height: auto; }
.gate-code span { font-size: var(--fs-xs); color: #62666F; }
@media print {
  body * { visibility: hidden; }
  .gate-code, .gate-code * { visibility: visible; }
  .gate-code { position: fixed; top: 20mm; left: 50%; transform: translateX(-50%); border: 0; }
}

/* Numbered steps (a list that explains how something works). */
.steps { counter-reset: step; }
.list.steps > li { position: relative; padding-left: 3rem; }
.steps > li::before { counter-increment: step; content: counter(step); position: absolute; left: 1.1rem; top: .75rem; width: 1.4rem; height: 1.4rem; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font-size: var(--fs-xs); font-weight: 600; }

/* A row of a single-series bar list (yard reports). */
.hbar { display: grid; grid-template-columns: minmax(6rem, 10rem) minmax(0, 1fr) auto; gap: .75rem; align-items: center; font-size: var(--fs-sm); }
.hbar.no-label { grid-template-columns: minmax(0, 1fr) auto; }
.hbar + .hbar { margin-top: .45rem; }
.hbar-track { height: .55rem; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.hbar-value { text-align: right; white-space: nowrap; color: var(--ink); font-variant-numeric: tabular-nums; }

/* SLA block (facility report): the score beside its measures. */
.sla { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1000px) { .sla { grid-template-columns: 16rem minmax(0, 1fr); } }
.sla-score { display: flex; flex-direction: column; gap: .4rem; }
.sla-value { font-size: 2.75rem; line-height: 1; font-weight: 500; letter-spacing: -.03em; color: var(--ink); font-variant-numeric: tabular-nums; }

/* Photo thumbnails (accident photos, inspection images). */
.thumbs { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); }
.thumbs li { display: flex; flex-direction: column; gap: .25rem; }
.thumbs img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-3); }
.thumbs a:focus-visible img { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Printable ID badge (drivers): credit-card size, always light so it prints true. */
.id-card-wrap { display: grid; place-items: center; padding: 1.5rem 0; }
.id-card { width: 85.6mm; height: 54mm; display: flex; flex-direction: column; overflow: hidden; background: #fff; color: #15171C; border: 1px solid #CFCEC7; border-radius: 3mm; box-shadow: var(--shadow-pop); }
.id-card-head { display: flex; align-items: center; gap: .4rem; padding: 2mm 3mm; background: var(--accent); color: #fff; font-size: 9pt; }
.id-card-logo { height: 5mm; width: auto; background: #fff; border-radius: 1mm; padding: .5mm; }
.id-card-org { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.id-card-kind { font-size: 7pt; text-transform: uppercase; letter-spacing: .08em; opacity: .9; }
.id-card-body { display: flex; align-items: center; gap: 3mm; padding: 2.5mm 3mm 1mm; }
.id-card .avatar { background: #F0F0EC; color: #62666F; }
.id-card-who { display: flex; flex-direction: column; min-width: 0; font-size: 8pt; color: #62666F; line-height: 1.35; }
.id-card-who strong { font-size: 11pt; color: #15171C; }
.id-card-code { margin-top: auto; display: grid; place-items: center; padding: 0 3mm 2mm; }
.id-card-code svg { max-width: 100%; height: auto; }
@media print {
  body * { visibility: hidden; }
  .id-card, .id-card * { visibility: visible; }
  .id-card { position: fixed; top: 10mm; left: 10mm; box-shadow: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Internal chat: conversations on the left, the open one on the right; one at a time on phones. */
.chat { display: grid; grid-template-columns: 20rem minmax(0, 1fr); height: calc(100vh - 3.5rem); height: calc(100dvh - 3.5rem); }
.chat-side { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--line); }
.chat-side-head { padding: 1rem; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: .65rem; }
.chat-list { flex: 1; overflow-y: auto; }
.chat-item { display: flex; gap: .7rem; align-items: flex-start; padding: .75rem 1rem; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.chat-item:hover { background: var(--surface-2); text-decoration: none; }
.chat-item.is-active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.chat-item-body { flex: 1; min-width: 0; }
.chat-item-body p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); color: var(--muted); }
.chat-item.is-unread .chat-item-body p { color: var(--ink); font-weight: 500; }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: .75rem; padding: .75rem 1.25rem; border-bottom: 1px solid var(--line); background: var(--surface); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 1.25rem; display: flex; flex-direction: column; gap: .55rem; }
.chat-day { align-self: center; margin: .75rem 0 .25rem; padding: .15rem .6rem; border-radius: 999px; background: var(--surface-3); font-size: var(--fs-xs); color: var(--muted); }
.msg { max-width: min(36rem, 85%); align-self: flex-start; }
.msg.is-mine { align-self: flex-end; }
.msg-bubble { padding: .55rem .85rem; border-radius: 12px 12px 12px 4px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.is-mine .msg-bubble { border-radius: 12px 12px 4px 12px; background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.msg-time { margin-top: .2rem; font-size: var(--fs-xs); color: var(--muted); }
.msg.is-mine .msg-time { text-align: right; }
.chat-compose { display: flex; gap: .6rem; align-items: flex-end; padding: .75rem 1.25rem; border-top: 1px solid var(--line); background: var(--surface); }
.chat-compose textarea { min-height: var(--control-h); max-height: 8rem; resize: none; }
.chat-blank { flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 2rem; }
@media (max-width: 767px) {
  .chat { grid-template-columns: minmax(0, 1fr); }
  .chat.has-open .chat-side, .chat:not(.has-open) .chat-main { display: none; }
}

/* Raw values (audit before/after, payloads): wrapped, monospaced. */
pre.code { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font-mono); font-size: var(--fs-xs); line-height: 1.5; color: var(--text); }
pre.code.is-old { color: var(--bad); }
pre.code.is-new { color: var(--good); }
tr.is-link { cursor: pointer; }

/* Sign-in pages. Office: a brand panel beside the form (.auth-split); gate
   tablet: one card on the paper, the brand above it (.auth.is-kiosk). */
.btn-lg { min-height: 2.75rem; padding: .55rem 1.1rem; font-size: var(--fs-lg); }
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 2rem 1rem; }
.auth-box { width: min(25rem, 100%); display: flex; flex-direction: column; gap: 1.25rem; }
.auth-brand { display: flex; align-items: center; gap: .65rem; font-weight: 600; font-size: var(--fs-lg); color: var(--ink); }
.auth-brand img { max-height: 2.5rem; max-width: 8rem; width: auto; object-fit: contain; }
.auth-brand .sb-brand-mark { width: 2.25rem; height: 2.25rem; font-size: var(--fs-lg); }
.auth-title { font-size: var(--fs-2xl); letter-spacing: -.01em; }
.auth-note { font-size: var(--fs-sm); color: var(--muted); text-align: center; }
.auth .card-body { padding: 1.5rem; }
.auth-head p { margin-top: .35rem; color: var(--muted); }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem 1rem; font-size: var(--fs-sm); }
.auth-links a, .auth-links .link { color: var(--accent-text); font-weight: 500; }

/* The brand panel keeps its own dark palette in both themes: it is the
   company's face, not part of the page's light or dark. */
.auth-split { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); background: var(--surface); }
.auth-aside {
  --aside-ink: #F3F3F0; --aside-text: #C9CBD0; --aside-muted: #9A9EA7; --aside-line: rgba(255, 255, 255, .09);
  position: relative; overflow: hidden; display: none; flex-direction: column; gap: 2.5rem;
  padding: 2.5rem 3rem; background: #111317; color: var(--aside-text); isolation: isolate;
}
.auth-aside .auth-brand { color: var(--aside-ink); }
.auth-aside .sb-brand-mark { background: var(--accent); color: var(--on-accent); }
.auth-pitch { position: relative; z-index: 1; max-width: 30rem; margin-top: auto; }
.auth-kicker { font-size: var(--fs-sm); font-weight: 500; color: color-mix(in oklab, var(--accent) 45%, #fff); }
.auth-pitch h2 { margin-top: .6rem; font-size: 2.125rem; line-height: 1.15; font-weight: 500; letter-spacing: -.02em; color: var(--aside-ink); text-wrap: balance; }
.auth-modules { display: flex; flex-wrap: wrap; gap: .4rem; margin: 1.5rem 0 0; padding: 0; list-style: none; }
.auth-modules li { padding: .25rem .6rem; border: 1px solid var(--aside-line); border-radius: 999px; font-size: var(--fs-sm); color: var(--aside-text); background: rgba(255, 255, 255, .03); }
.auth-assurance { position: relative; z-index: 1; display: grid; gap: .6rem; margin: 0; padding: 1.5rem 0 0; list-style: none; border-top: 1px solid var(--aside-line); font-size: var(--fs-sm); color: var(--aside-muted); }
.auth-assurance li { display: flex; align-items: center; gap: .6rem; }
.auth-assurance .icon { width: 1rem; height: 1rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; color: var(--aside-text); }
.auth-art { position: absolute; inset: 0 0 auto 0; width: 100%; height: 62%; z-index: -1; -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent); }
.auth-art-grid line { stroke: rgba(255, 255, 255, .035); stroke-width: 1; }
.auth-art-roads path { fill: none; stroke: rgba(255, 255, 255, .11); stroke-width: 2; }
.auth-art-run { fill: none; stroke: var(--accent); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: auth-draw 1.6s .2s cubic-bezier(.4, 0, .2, 1) forwards; }
.auth-art-flow { fill: none; stroke: rgba(255, 255, 255, .55); stroke-width: 1.25; stroke-linecap: round; stroke-dasharray: .006 .03; animation: auth-flow 6s linear infinite; }
.auth-art-traffic circle { fill: var(--aside-text); opacity: .5; }
.auth-art-depots circle { fill: #111317; stroke: rgba(255, 255, 255, .35); stroke-width: 2; }
.auth-art-origin { fill: var(--accent); stroke: #111317; stroke-width: 4; }
.auth-art-pulse { fill: none; stroke: var(--accent); stroke-width: 1.5; }
/* The yard, in the same line work as the roads. */
.auth-art-yard text { fill: var(--aside-muted); font-size: 8.5px; letter-spacing: .02em; }
.auth-art-fence { fill: rgba(255, 255, 255, .025); stroke: rgba(255, 255, 255, .22); stroke-width: 1.5; stroke-dasharray: 5 4; }
.auth-art-shed { fill: rgba(255, 255, 255, .05); stroke: rgba(255, 255, 255, .2); stroke-width: 1.25; }
.auth-art-door { fill: rgba(255, 255, 255, .14); }
.auth-art-door.is-busy, .auth-art-door.is-loading { fill: var(--accent); }
.auth-art-trailer { fill: rgba(255, 255, 255, .07); stroke: rgba(255, 255, 255, .28); stroke-width: 1; }
.auth-art-lane { fill: none; stroke: rgba(255, 255, 255, .14); stroke-width: 1; stroke-dasharray: 3 5; }
.auth-art-stall { stroke: rgba(255, 255, 255, .16); stroke-width: 1; }
.auth-art-gatehouse { fill: #111317; stroke: rgba(255, 255, 255, .35); stroke-width: 1.25; }
.auth-art-boom { stroke: #E7B45C; stroke-width: 2.25; stroke-linecap: round; }
.auth-art-truck rect { fill: var(--aside-ink); }
.auth-art-truck .auth-art-cab { fill: var(--accent); }
@keyframes auth-draw { to { stroke-dashoffset: 0; } }
@keyframes auth-flow { to { stroke-dashoffset: -1; } }
/* The panel's words and the form settle in once on load. */
@keyframes auth-rise { from { opacity: 0; transform: translateY(10px); } }
.auth-pitch > *, .auth-panel { animation: auth-rise .7s cubic-bezier(.2, .7, .2, 1) both; }
.auth-pitch > :nth-child(2) { animation-delay: .08s; }
.auth-pitch > :nth-child(3) { animation-delay: .16s; }
.auth-panel { animation-delay: .1s; }
@media (prefers-reduced-motion: reduce) {
  .auth-art-run, .auth-art-flow, .auth-pitch > *, .auth-panel { animation: none; }
  .auth-art-run { stroke-dashoffset: 0; }
}

.auth-main { display: flex; flex-direction: column; min-width: 0; padding: 1.5rem 1.25rem; }
.auth-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1.5rem; margin-bottom: 2.5rem; }
.auth-help { margin-left: auto; font-size: var(--fs-sm); color: var(--muted); }
.auth-help a { color: var(--accent-text); font-weight: 500; }
@media (max-width: 479px) { .auth-help > span { display: none; } }
.auth-panel { width: min(24rem, 100%); margin: auto; display: grid; gap: 1.75rem; padding: 1rem 0 2rem; }
.auth-panel > .form { gap: 1.1rem; }
.auth-panel input:not([type=checkbox]):not([type=radio]) { min-height: 2.75rem; }
.auth-panel .btn-lg { margin-top: .25rem; }
/* A label with its link on the right ("Forgot password?"). */
.field-label { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.field-label > label { font-size: var(--fs-sm); font-weight: 500; color: var(--text); }
.field-label > a { font-size: var(--fs-sm); font-weight: 500; color: var(--accent-text); }
/* An input with a glyph at its start, which takes the accent while focused. */
.input-icon { position: relative; }
.input-icon > svg { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); width: 1.05rem; height: 1.05rem; pointer-events: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; color: var(--muted); transition: color .15s; }
.input-icon > input { width: 100%; padding-left: 2.5rem; }
.input-icon:focus-within > svg { color: var(--accent-text); }
.auth-panel-foot { display: grid; gap: .6rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.auth-secure { display: flex; align-items: flex-start; gap: .5rem; font-size: var(--fs-sm); color: var(--text); }
.auth-secure svg { width: 1rem; height: 1rem; margin-top: .1rem; flex: none; fill: none; stroke: var(--good); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.auth-aside-note { font-size: var(--fs-sm); color: var(--muted); }
.auth-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .25rem 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--line); font-size: var(--fs-xs); color: var(--muted); }
.auth-foot a { color: var(--accent-text); }
.dark .auth-split { background: var(--bg); }
.dark .auth-aside { border-right: 1px solid var(--line); }
@media (min-width: 960px) {
  .auth-split { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
  .auth-aside { display: flex; }
  .auth-brand-top { display: none; }
  .auth-top { margin-bottom: 0; }
  .auth-main { padding: 2.5rem 3rem; }
}
@media (min-width: 1400px) { .auth-pitch h2 { font-size: 2.5rem; } .auth-aside { padding: 3rem 4rem; } }

/* A password with its Show button inside the box. */
.reveal { position: relative; }
.reveal input { width: 100%; padding-right: 4.25rem; }
.reveal-btn { position: absolute; top: 50%; right: .35rem; transform: translateY(-50%); padding: .3rem .6rem; border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 500; color: var(--accent-text); cursor: pointer; }
.reveal-btn:hover { background: var(--accent-soft); }
.reveal-btn:focus-visible { outline: none; box-shadow: var(--focus); }
.code-input { font-family: var(--font-mono); font-size: 1.5rem !important; letter-spacing: .5em; text-align: center; }
/* The gate tablet: bigger targets for gloved hands. */
.auth.is-kiosk { --control-h: 3rem; }
.auth.is-kiosk input, .auth.is-kiosk .btn { font-size: var(--fs-lg); }

/* Gate TV board: always dark, read from across the gate house. */
.board { min-height: 100vh; display: flex; flex-direction: column; font-size: var(--fs-lg); }
.board-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem 2rem; padding: 1.5rem 2rem 1.25rem; border-bottom: 1px solid var(--line); }
.board-head h1 { font-size: 2rem; }
.board-head p { color: var(--muted); }
.board-clock { font-family: var(--font-mono); font-size: 2.75rem; font-weight: 500; line-height: 1; color: var(--ink); text-align: right; }
.board-clock small { display: block; margin-top: .4rem; font-family: var(--font); font-size: var(--fs-md); color: var(--muted); }
.board-legend { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem; padding: .85rem 2rem; border-bottom: 1px solid var(--line); font-size: var(--fs-md); color: var(--text); }
.board-legend span { display: inline-flex; align-items: center; gap: .5rem; }
.board-legend .push { color: var(--muted); }
.board-grid { flex: 1; display: grid; gap: 1rem; align-content: start; grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); padding: 1.5rem 2rem 5rem; }
.board-card { display: flex; flex-direction: column; gap: .75rem; padding: 1.1rem 1.25rem; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--st, var(--faint)); border-radius: var(--r-lg); animation: board-in .3s ease-out; }
.board-card.is-urgent { border-color: var(--bad-line); border-left-color: var(--st, var(--faint)); }
.board-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.board-plate { font-family: var(--font-mono); font-size: 1.75rem; font-weight: 600; letter-spacing: .05em; color: var(--ink); line-height: 1.1; }
.board-state { display: inline-flex; align-items: center; gap: .45rem; font-size: var(--fs-md); font-weight: 600; color: var(--st, var(--muted)); white-space: nowrap; }
.board-state .dot, .board-legend .dot { width: .7rem; height: .7rem; background: var(--st, var(--faint)); }
.board-meta { display: flex; flex-wrap: wrap; gap: .25rem 1rem; font-size: var(--fs-md); color: var(--muted); font-variant-numeric: tabular-nums; }
.board-meta .is-late { color: var(--bad); font-weight: 600; }
.board-call { padding: .6rem .9rem; border-radius: var(--r); background: color-mix(in oklab, var(--st) 18%, var(--surface)); color: var(--ink); font-size: var(--fs-xl); font-weight: 600; text-align: center; }
/* Next to load (4.9): the loading line with estimated call times, across the top. */
.board-queue { display: flex; gap: .75rem; overflow-x: auto; padding: 1rem 2rem; border-bottom: 1px solid var(--line); }
.board-queue[hidden] { display: none; }
.board-queue-title { align-self: center; flex: none; font-size: var(--fs-md); font-weight: 600; color: var(--muted); margin-right: .5rem; }
.board-next { flex: none; display: grid; grid-template-columns: auto 1fr; gap: 0 .75rem; align-items: center; min-width: 13rem; padding: .6rem .9rem; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
.board-next-pos { grid-row: span 2; font-size: 1.6rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.board-next .board-plate { font-size: 1.25rem; }
.board-next-when { font-size: var(--fs-md); color: var(--muted); font-variant-numeric: tabular-nums; }
.board-next.is-called { border-color: var(--accent-text); }
.board-next.is-called .board-next-when { color: var(--accent-text); font-weight: 600; }
.board-empty { grid-column: 1 / -1; padding: 6rem 1rem; text-align: center; color: var(--muted); }
.board-empty h2 { font-size: var(--fs-2xl); margin-bottom: .5rem; }
.board-foot { position: fixed; inset: auto 0 0 0; display: flex; justify-content: space-between; gap: 1rem; padding: .75rem 2rem; background: var(--surface); border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--muted); }
.st-waiting { --st: var(--muted); } .st-called { --st: var(--warn); } .st-dock { --st: var(--accent-text); } .st-working { --st: #B79CF0; } .st-done { --st: var(--good); }
.st-working .dot { animation: board-pulse 1.5s ease-in-out infinite; }
@keyframes board-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes board-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .board-card, .st-working .dot { animation: none; } }
@media (max-width: 640px) { .board-head, .board-legend, .board-queue, .board-foot { padding-left: 1rem; padding-right: 1rem; } .board-grid { padding: 1rem 1rem 5rem; grid-template-columns: minmax(0, 1fr); } }

@media print {
  .app-sidebar, .app-topbar, .page-actions, .filters, .no-print { display: none !important; }
  .app-main { margin: 0 !important; }
  .card { break-inside: avoid; }
}
