/* POD v2. Swiss-minimal: neutrals, one blue, red for errors only.
   Components use only the tokens below, so a theme is just a block of values. */

@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/AtkinsonHyperlegibleNext-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --font: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #f7f7f8;          /* page */
  --surface: #ffffff;     /* panels */
  --subtle: #f1f2f4;      /* pressed, delivered tag */
  --border: #dcdfe3;      /* dividers */
  --border-strong: #8a919c; /* control outlines: 3:1 on surface */
  --text: #16181d;        /* 17:1 */
  --muted: #555c67;       /* 6.9:1 */
  --accent: #1d4ed8;      /* 6.7:1; links, primary, focus */
  --accent-hover: #1e40af;
  --on-accent: #ffffff;
  --danger: #b42318;      /* 6.4:1; errors only */
  --paper: #ffffff;       /* label and signature: white in every theme */
  --ink: #000000;
  --radius: 8px;
  --gap: 12px;
}

/* Dark: the device's choice unless the person picked light; or picked dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111317;
    --surface: #181b20;
    --subtle: #20242a;
    --border: #2d3239;
    --border-strong: #7d8590;
    --text: #eceef1;      /* 15:1 */
    --muted: #a3aab4;     /* 7.6:1 */
    --accent: #7ea6ff;    /* 7.4:1 */
    --accent-hover: #a3c0ff;
    --on-accent: #111317;
    --danger: #ff8b80;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111317;
  --surface: #181b20;
  --subtle: #20242a;
  --border: #2d3239;
  --border-strong: #7d8590;
  --text: #eceef1;
  --muted: #a3aab4;
  --accent: #7ea6ff;
  --accent-hover: #a3c0ff;
  --on-accent: #111317;
  --danger: #ff8b80;
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 1rem/1.55 var(--font); }
h1, h2, p, dl, dd, ol, ul, figure { margin: 0; }
h1 { font-size: 1.5rem; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; margin-bottom: var(--gap); }
h2 { font-size: 1.05rem; line-height: 1.3; font-weight: 700; margin-bottom: 10px; }
a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 10; background: var(--surface); padding: 8px 12px; border: 2px solid var(--accent); }
.skip-link:focus { left: 8px; }
.muted, .hint, .cell-note { color: var(--muted); }
.hint { margin-bottom: var(--gap); max-width: 75ch; }
.cell-note { display: block; font-size: 0.875rem; }
.icon { width: 1.25em; height: 1.25em; flex: none; }

/* ── Shell ──
   Phone first: slim top bar + bottom navigation in thumb reach (drivers).
   900px and up: a fixed side menu (stores desk). */
:root { --sidebar: 248px; --bottom-nav: 64px; }
.container { padding: 16px var(--gap) 32px; }
body.bare .container { max-width: 1120px; margin: 0 auto; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: 0.02em; min-height: 44px; }
.brand:hover { color: var(--text); }

.sidebar { background: var(--surface); border-bottom: 1px solid var(--border); }
.sidebar__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 60px; padding: 0 12px 0 var(--gap); }
.sidebar__compact-actions { display: flex; gap: 8px; }
.sidebar__nav, .sidebar__foot { display: none; }

/* Counts, like a warehouse board: plain figures, not alarms. */
.count {
  margin-left: auto; min-width: 1.75em; padding: 1px 8px; border-radius: 999px; text-align: center;
  font-size: 0.875rem; font-weight: 700; font-variant-numeric: tabular-nums; background: var(--subtle); color: var(--text);
}

.bottom-nav {
  position: fixed; inset: auto 0 0 0; z-index: 5; display: flex; background: var(--surface);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav__item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--bottom-nav); color: var(--muted); text-decoration: none; font-size: 0.8rem; font-weight: 600;
}
.bottom-nav__item[aria-current="page"] { color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }
.bottom-nav__icon { position: relative; line-height: 0; }
.bottom-nav__icon .icon { width: 24px; height: 24px; }
.count--dot { position: absolute; top: -6px; left: 16px; margin: 0; padding: 0 5px; font-size: 0.75rem; line-height: 1.4; background: var(--text); color: var(--surface); }
/* Keep the last content clear of the fixed bar. */
body.app { padding-bottom: calc(var(--bottom-nav) + env(safe-area-inset-bottom)); }

@media (min-width: 900px) {
  body.app { padding-bottom: 0; padding-left: var(--sidebar); }
  .bottom-nav, .sidebar__compact-actions { display: none; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar); display: flex; flex-direction: column;
    border-bottom: 0; border-right: 1px solid var(--border); padding: 12px 12px 16px;
  }
  .sidebar__head { padding: 0 8px; margin-bottom: 12px; }
  .sidebar__nav { display: block; flex: 1; overflow-y: auto; }
  .sidebar__foot { display: flex; align-items: center; gap: 6px; padding: 12px 4px 0 8px; border-top: 1px solid var(--border); }
  .container { padding: 20px 24px 32px; }
}
.nav-group + .nav-group { margin-top: 16px; }
.nav-group__heading { color: var(--muted); font-size: 0.875rem; font-weight: 600; padding: 0 12px 6px; }
.nav-list { list-style: none; padding: 0; display: grid; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 10px; border-radius: var(--radius);
  color: var(--text); text-decoration: none; font-weight: 600; transition: background-color 150ms ease;
}
.nav-item .icon { color: var(--muted); }
.nav-item:hover { background: var(--subtle); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--subtle); box-shadow: inset 3px 0 0 var(--accent); }
.nav-item[aria-current="page"] .icon { color: var(--accent); }
.sidebar__user { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; color: var(--muted); }
.sidebar__user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Signed out: just the mark and the theme switch. */
.bare__head { display: flex; align-items: center; justify-content: space-between; max-width: 1120px; margin: 0 auto; padding: 8px var(--gap); }
body.bare .container { padding-top: 8vh; }

/* Theme toggle: shows the theme you'd switch to. */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px;
  border-radius: var(--radius); border: 1px solid var(--border); background: transparent; color: var(--text);
  cursor: pointer; transition: background-color 150ms ease;
}
.icon-btn:hover { background: var(--subtle); }
.icon-moon, .icon-sun { line-height: 0; }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: inline; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: inline; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

/* ── Panels and layout ── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: var(--gap); }
.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
/* A desk: the work in a wide main column, a supporting column beside it (Receipt, Locations). */
.desk { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); align-items: start; }
.desk__main { display: grid; gap: var(--gap); min-width: 0; }
.desk__main > *, .desk > .panel { margin-bottom: 0; }
@media (min-width: 1200px) {
  .desk { grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); }
  .desk__side { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; }
}
.panel-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 8px var(--gap); margin-bottom: 8px; }
.panel-head h2 { margin: 0; align-self: center; }
.panel-head .filters { margin-bottom: 0; flex: 1 1 auto; justify-content: flex-end; }
.panel-head .filters .field { flex: 0 1 220px; min-width: 150px; }
.page-head--split { justify-content: space-between; }

/* Receipt: the order number is the thing being typed all day, so it is big. */
.order-input--big { font-size: 1.6rem; min-height: 60px; }
.ledger { list-style: none; padding: 0; display: grid; gap: 2px; }
.ledger__row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  padding: 8px 10px; border-radius: 6px; color: var(--text); text-decoration: none;
}
.ledger__row:hover { background: var(--subtle); color: var(--text); }
.ledger__time { color: var(--muted); font-size: 0.875rem; text-align: right; white-space: nowrap; }
.ledger__place { font-size: 0.9rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ledger__status { justify-self: end; }

/* Department picker: type to filter. */
.combo { position: relative; }
.combo input { width: 100%; }
.combo__list {
  position: absolute; left: 0; right: 0; z-index: 4; margin: 4px 0 0; padding: 4px; list-style: none;
  max-height: 320px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
}
.combo__option {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  min-height: 44px; padding: 10px 12px; border-radius: 6px; cursor: pointer;
}
.combo__option span { color: var(--muted); font-size: 0.9rem; text-align: right; }
.combo__option:hover { background: var(--subtle); }
.combo__option[aria-selected="true"] { background: var(--accent); color: var(--on-accent); }
.combo__option[aria-selected="true"] span { color: var(--on-accent); }
.combo__empty { padding: 10px 12px; color: var(--muted); }
.field-error { color: var(--danger); font-weight: 600; }

/* Receipt: the form and the last label on the left, today's receipts on the right. */
@media (min-width: 900px) {
  .browser.browser--receipt { grid-template-columns: minmax(0, 1.15fr) minmax(320px, 1fr); }
}
.pane__section { border-top: 1px solid var(--border); padding: 14px 16px 16px; display: grid; gap: 12px; }
.pane__section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.pane__section-head h3 { margin: 0; font-size: 1rem; }
.pane__section .label { margin: 0; }
.receipt-submit { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.receipt-submit .cell-note { flex: 1 1 220px; }
.pane__body--form .notice { margin-bottom: 12px; }

/* Locations: one browser, three panes worked left to right (Buildings › Levels › Departments). */
.browser {
  display: grid; grid-template-columns: minmax(0, 1fr); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: visible;
}
@media (min-width: 900px) {
  .browser { grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr) minmax(0, 1.8fr); min-height: min(68vh, 640px); }
  .pane + .pane { border-left: 1px solid var(--border); }
}
@media (max-width: 899px) { .pane + .pane { border-top: 1px solid var(--border); } }
.pane { display: flex; flex-direction: column; min-width: 0; }
.pane__head {
  display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--border); background: var(--subtle);
}
.browser > .pane:first-child .pane__head { border-radius: var(--radius) var(--radius) 0 0; }
@media (min-width: 900px) {
  .browser > .pane:first-child .pane__head { border-radius: var(--radius) 0 0 0; }
  .browser > .pane:last-child .pane__head { border-top-right-radius: var(--radius); }
}
.pane__head > .icon { color: var(--muted); }
.pane__title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.pane__title h2 { margin: 0; font-size: 1rem; }
.pane__within { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane__count { color: var(--muted); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.pane__body { flex: 1; padding: 8px; }
.pane__empty { color: var(--muted); padding: 12px 8px; }
.pane__add { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.pane__add input { flex: 1; min-width: 0; }
.pane__add .btn { padding-left: 12px; padding-right: 14px; gap: 4px; }

.picker { list-style: none; padding: 0; display: grid; gap: 2px; }
.picker__item {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 6px 0 12px;
  border-radius: 6px; color: var(--text); text-decoration: none; font-weight: 600;
}
.picker__item:hover { background: var(--subtle); color: var(--text); }
.picker__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker__count { color: var(--muted); font-weight: 400; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.picker__chevron { line-height: 0; color: var(--border-strong); }
.picker__chevron .icon { width: 1.1em; height: 1.1em; }
.picker__item[aria-current="true"] { background: var(--accent); color: var(--on-accent); }
.picker__item[aria-current="true"] .picker__count,
.picker__item[aria-current="true"] .picker__chevron { color: var(--on-accent); }

.dept-list { list-style: none; padding: 0 8px; }
.dept { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.dept:last-child { border-bottom: 0; }
.dept__main { min-width: 0; display: grid; gap: 2px; }
.dept__name { font-weight: 700; }
.dept.inactive .dept__name { color: var(--muted); }
.dept__flag { justify-self: start; font-size: 0.8rem; font-weight: 700; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 999px; padding: 0 8px; }
.dept__stats { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.875rem; color: var(--muted); }
.stat strong { color: var(--text); font-variant-numeric: tabular-nums; }
.stat--zero strong { color: var(--muted); font-weight: 400; }

/* Stores: one pane with a toolbar (status tabs + search), the table, and a footer. */
.browser.browser--single { grid-template-columns: minmax(0, 1fr); min-height: 0; }
.pane__head--toolbar { flex-wrap: wrap; justify-content: space-between; gap: 10px 16px; padding: 10px 12px; }
.pane__body--flush { padding: 0; }
.pane__foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px; border-top: 1px solid var(--border); min-height: 56px;
}
.pane__foot .pager { margin: 0; }

.segmented { display: flex; flex-wrap: wrap; gap: 4px; }
.segmented__item {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px;
  border-radius: 6px; border: 1px solid transparent; color: var(--muted); text-decoration: none; font-weight: 600;
}
.segmented__item:hover { color: var(--text); background: var(--surface); }
.segmented__item[aria-current="true"] { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.segmented__count { font-weight: 400; font-variant-numeric: tabular-nums; color: var(--muted); }

.search { position: relative; display: flex; align-items: center; gap: 8px; flex: 0 1 320px; }
.search input[type="search"] { padding-left: 38px; min-height: 40px; }
.search__icon { position: absolute; left: 12px; line-height: 0; color: var(--muted); pointer-events: none; }
.search__icon .icon { width: 1.1em; height: 1.1em; }

.table.orders th, .table.orders td,
.table.orders th:first-child, .table.orders td:first-child { padding-left: 16px; padding-right: 16px; }
.table.orders th { padding-top: 10px; padding-bottom: 10px; }
.table.orders tbody tr:hover { background: var(--subtle); }
@media (max-width: 640px) {
  .table.orders tr { padding: 10px 16px; }
  .table.orders td, .table.orders td:first-child { padding: 2px 0; }
}

.empty-state { display: grid; justify-items: center; gap: 8px; padding: 48px 16px; color: var(--muted); text-align: center; }
.empty-state .icon { width: 32px; height: 32px; }

/* Users: the same browser, split into the list and the add form. */
@media (min-width: 900px) {
  .browser--split { grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); min-height: 0; }
}
.pane__body--form { padding: 16px; }
.people { list-style: none; padding: 0 8px; }
.person { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.person:last-child { border-bottom: 0; }
.person__main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.person__name { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.person.inactive .avatar { opacity: 0.55; }
.dept__stats > span { white-space: nowrap; }
@media (max-width: 640px) {
  .person .actions { flex-basis: 100%; padding-left: 54px; }
}
.person.inactive .dept__name { color: var(--muted); }
.avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--subtle); border: 1px solid var(--border); font-weight: 700; font-size: 0.9rem; color: var(--text);
}

/* Edit pop-over (rename / delete). */
.reveal { position: relative; }
.edit-panel {
  position: absolute; right: 0; z-index: 3; width: min(340px, 80vw); margin-top: 6px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18); display: grid; gap: 10px;
}
.add-form { display: grid; gap: 6px; }
.add-form label { font-size: 0.95rem; }
.add-form__row { display: flex; gap: 8px; }
.add-form__row input { flex: 1; min-width: 0; }

/* A record: the goods (label, photos) in a wide main column, facts and history beside. */
.record { display: grid; gap: var(--gap); grid-template-columns: 1fr; align-items: start; }
.record__main, .record__side { display: grid; gap: var(--gap); min-width: 0; }
.record .panel { margin-bottom: 0; }
.record__main:empty { display: none; }
@media (min-width: 1100px) {
  .record { grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); }
  .record:has(.record__main:empty) { grid-template-columns: minmax(340px, 560px); }
}
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: var(--gap); }
.page-head h1 { margin: 0; }
.back { margin-bottom: 8px; }
.eyebrow { color: var(--muted); font-size: 0.875rem; font-weight: 600; margin-bottom: 4px; }
.empty { color: var(--muted); }
.stack > * + * { margin-top: var(--gap); }

/* ── Forms ── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
label, .field-label { font-weight: 600; }
input[type="text"], input[type="password"], input[type="search"], select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 8px 12px; min-height: 44px; width: 100%;
}
input:focus-visible, select:focus-visible { outline-offset: 0; border-color: var(--accent); }
input[type="file"] { font: inherit; color: var(--text); min-height: 48px; max-width: 100%; }
input[type="file"]::file-selector-button {
  font: inherit; font-weight: 600; color: var(--text); background: var(--subtle);
  border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 8px 14px; margin-right: 12px; cursor: pointer;
}
.order-input { font-size: 1.2rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.receipt { display: grid; gap: var(--gap); grid-template-columns: 1fr; align-items: end; }
@media (min-width: 800px) { .receipt { grid-template-columns: minmax(180px, 280px) minmax(240px, 480px) auto; justify-content: start; } }
.filters, .inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: var(--gap); }
.filters .field, .inline-form .field { flex: 0 1 280px; min-width: 180px; }

/* ── Buttons: one filled style, everything else outlined or plain ── */
.btn {
  font: inherit; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 16px; border-radius: var(--radius); border: 1px solid transparent;
  cursor: pointer; text-decoration: none; touch-action: manipulation;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.btn--sm { min-height: 36px; padding: 4px 12px; font-size: 0.95rem; }
.btn--lg { min-height: 56px; font-size: 1.1rem; }
.btn--block { width: 100%; }
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn--secondary, .btn--ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn--secondary:hover, .btn--ghost:hover { background: var(--subtle); color: var(--text); }
.btn--subtle { background: transparent; color: var(--accent); }
.btn--subtle:hover { background: var(--subtle); }
.btn--danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn--danger:hover { background: var(--subtle); }
.btn[disabled] { opacity: 0.6; cursor: progress; }

/* ── Notices ── */
.notice { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 12px 14px; margin-bottom: var(--gap); font-weight: 600; }
.notice--error { border-left-color: var(--danger); color: var(--danger); }

/* ── Status tags: told apart by icon and words, not colour ── */
.tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 0.875rem; font-weight: 700; white-space: nowrap; border: 1px solid var(--border-strong); color: var(--text);
}
.tag .icon { width: 1em; height: 1em; }
.tag--at_stores { color: var(--muted); border-color: var(--border-strong); }
.tag--out_for_delivery { color: var(--accent); border-color: var(--accent); }
.tag--delivered { background: var(--subtle); border-color: var(--subtle); }

/* ── Order numbers and locations ── */
.order-no { font-weight: 800; letter-spacing: 0.03em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table time { white-space: nowrap; }
a.order-no { font-size: 1.05rem; }
.loc { display: flex; flex-direction: column; }
.loc__dept { font-weight: 700; }
.loc__context { color: var(--muted); font-size: 0.9rem; }
.big-location { margin-bottom: var(--gap); font-size: 1.05rem; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 0.875rem; font-weight: 600; color: var(--muted); padding: 6px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th:first-child, .table td:first-child { padding-left: 0; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.inactive td { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: start; }
.reveal > summary { list-style: none; }
.reveal > summary::-webkit-details-marker { display: none; }
.reveal[open] > form { margin-top: 12px; margin-bottom: 0; }
.pager { display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin-top: var(--gap); }
.pager__page { color: var(--muted); }

/* On a phone, each table row becomes a stacked block. */
@media (max-width: 640px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr { padding: 8px 0; border-bottom: 1px solid var(--border); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: 2px 0; }
}

/* ── Detail page ── */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; }
.facts dt { color: var(--muted); }
.evidence { display: grid; gap: var(--gap); grid-template-columns: 1fr; margin-top: 12px; }
@media (min-width: 640px) { .evidence { grid-template-columns: 1fr 1fr; } }
.evidence img { border-radius: var(--radius); border: 1px solid var(--border); width: 100%; height: auto; }
.evidence img.signature { background: var(--paper); }
figcaption { color: var(--muted); font-size: 0.875rem; margin-top: 4px; }
.timeline { padding-left: 20px; }
.timeline li + li { margin-top: 6px; }
.danger-zone { margin-top: var(--gap); }
.danger-zone summary { cursor: pointer; color: var(--danger); font-weight: 600; min-height: 44px; display: inline-flex; align-items: center; }
.danger-zone p { margin-bottom: 12px; }

/* The label: always black on white, as it prints. */
.label {
  display: flex; gap: 16px; align-items: center; background: var(--paper); color: var(--ink);
  border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 12px; margin-bottom: var(--gap);
}
.label__qr { flex: 0 0 auto; width: 132px; }
.label__qr svg { width: 100%; height: auto; display: block; }
.label__order { font-size: 1.6rem; font-weight: 800; letter-spacing: 0.03em; }
.label__dept { font-size: 1.15rem; font-weight: 700; }
.label__context, .label__meta { font-size: 0.9rem; }
.label-panel .hint { margin: 12px 0 0; }

/* ── Driver ── */
.cards { list-style: none; padding: 0; display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.card {
  display: grid; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; color: var(--text); text-decoration: none; transition: border-color 150ms ease;
}
.card:hover { border-color: var(--accent); color: var(--text); }
.card .order-no { font-size: 1.25rem; }
.card__action { color: var(--accent); font-weight: 700; margin-top: 6px; }
.sig { position: relative; }
.sig__pad { width: 100%; height: 200px; background: var(--paper); border: 1px solid var(--border-strong); border-radius: var(--radius); touch-action: none; display: block; }
.sig__clear { position: absolute; top: 6px; right: 6px; background: var(--paper); color: var(--ink); }
.sig__clear:hover { background: var(--paper); text-decoration: underline; }
.photo-preview { max-height: 220px; width: auto; border-radius: var(--radius); margin-top: 8px; }
/* The real file input stays focusable and validated; its label is the visible button. */
.camera-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.camera-input:focus-visible + .btn { outline: 2px solid var(--accent); outline-offset: 2px; }
.scan { margin-bottom: var(--gap); }
.scanner { display: grid; gap: var(--gap); margin-bottom: 0; }
.scanner__video { width: 100%; max-height: 60vh; background: var(--ink); border-radius: var(--radius); object-fit: cover; }
.scanner__status { font-weight: 600; }
.scanner__status:empty { display: none; }
.scanner__actions { position: relative; display: flex; flex-wrap: wrap; gap: 8px; }
.scanner__actions .btn { flex: 1 1 auto; }
.also { border: 0; padding: 0; margin: 0; }
.also legend { padding: 0; }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; font-weight: 400; cursor: pointer; }
.check input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }
.geo-status { color: var(--muted); font-size: 0.95rem; }

/* ── Analytics ── */
.tiles { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); margin-bottom: var(--gap); }
.tile { display: grid; align-content: start; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.tile__label { color: var(--muted); font-size: 0.875rem; font-weight: 600; }
.tile__value { font-size: 1.75rem; line-height: 1.2; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin-bottom: 10px; }
.chart__head h2 { margin: 0; }
.legend { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.9rem; color: var(--muted); }
.legend strong { color: var(--text); font-variant-numeric: tabular-nums; }
.legend__key { display: inline-block; width: 22px; margin-right: 6px; vertical-align: middle; border-top: 2px solid var(--accent); }
.legend__key--received { border-top: 2px dashed var(--muted); }
.chart { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 8px; }
.chart__y { display: flex; flex-direction: column; justify-content: space-between; height: 240px; margin: -0.6em 0; text-align: right; color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.chart__plot { display: block; width: 100%; height: 240px; overflow: hidden; }
.chart__x { grid-column: 2; display: flex; justify-content: space-between; margin-top: 4px; color: var(--muted); font-size: 0.8rem; }
.chart__grid, .chart__base, .chart__line { vector-effect: non-scaling-stroke; }
.chart__grid { stroke: var(--border); stroke-width: 1; }
.chart__base { stroke: var(--border-strong); stroke-width: 2; }
.chart__line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart__line--received { stroke: var(--muted); stroke-dasharray: 5 4; }
.chart__line--delivered { stroke: var(--accent); }
.chart__hit { fill: transparent; }
.chart__hit:hover { fill: var(--text); fill-opacity: 0.08; }
.chart__data { margin-top: 10px; }
.chart__data summary { cursor: pointer; min-height: 44px; display: inline-flex; align-items: center; color: var(--accent); font-weight: 600; }
.nowrap { white-space: nowrap; }
@media (max-width: 640px) { .table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); } }
/* Administrators have six items in the bottom bar. */
@media (max-width: 400px) { .bottom-nav__item { min-width: 0; font-size: 0.7rem; } }
.analytics-grid { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); align-items: start; }
.analytics-grid .panel { margin-bottom: 0; }
@media (min-width: 1200px) { .analytics-grid { grid-template-columns: minmax(340px, 2fr) minmax(0, 3fr); } }

/* ── Print: just the label ── */
@media print {
  @page { margin: 8mm; }
  body { background: #fff; }
  body * { visibility: hidden; }
  .label, .label * { visibility: visible; }
  .label { position: absolute; left: 0; top: 0; border: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
