/* vPOD 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. */

:root {
  color-scheme: light;
  /* Each device's own interface font: nothing to download, and familiar on every phone. */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --bg: #f7f7f8;          /* page */
  --surface: #ffffff;     /* panels */
  --subtle: #f1f2f4;      /* pressed, delivered tag */
  --border: #dcdfe3;      /* dividers */
  --border-strong: #7d8590; /* control outlines: 3.3:1 or more on page, panel and subtle (WCAG 1.4.11) */
  --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 */
  --success: #15803d;     /* 5.0:1 on surface; a right door scanned */
  --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;
    --success: #3fb96b;   /* 6.9:1 */
  }
}
: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;
  --success: #3fb96b;
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-bottom: 88px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 1rem/1.55 var(--font); }
h1, h2, h3, 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 ──
   Two views, chosen once per device and marked on <html> (view-phone, view-desktop; see
   layout.VIEWS), not by the window's width: turning a phone or zooming a desktop window keeps
   the view, and each fits itself to the space it has. Phone: the bottom navigation in thumb
   reach (drivers). Desktop: a fixed side menu (stores desk). */
:root { --sidebar: 256px; --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__nav, .sidebar__foot { display: none; }

/* Who is signed in: the whole name, wrapping however long, never cut short; the role beneath;
   theme and Sign out on their own row. In the side menu's foot, or a phone's account menu. */
.account { display: grid; gap: 12px; min-width: 0; }
.account__who { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.account__who .icon { flex: none; margin-top: 2px; color: var(--muted); }
.account__text { display: grid; gap: 2px; min-width: 0; }
.account__name { font-weight: 700; overflow-wrap: anywhere; }
.account__role { color: var(--muted); font-size: 0.875rem; }
.account__actions { display: flex; gap: 8px; }
.account__actions form { flex: 1; }
.account__sign-out { width: 100%; }

/* A phone's account menu: one button in the top bar, opening a panel beneath it. */
.account-menu { position: relative; }
.account-menu > summary { list-style: none; }
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu[open] > summary { background: var(--subtle); }
.account-menu__panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 10; display: grid; gap: 12px;
  width: min(320px, calc(100vw - 2 * var(--gap))); padding: 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgb(0 0 0 / 0.14);
}
.account-menu__close { justify-self: end; }

/* 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)); }

.view-desktop body.app { padding-bottom: 0; padding-left: var(--sidebar); }
.view-desktop .bottom-nav, .view-desktop .account-menu { display: none; }
.view-desktop .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;
}
.view-desktop .sidebar__head { padding: 0 8px; margin-bottom: 12px; }
.view-desktop .sidebar__nav { display: block; flex: 1; overflow-y: auto; }
.view-desktop .sidebar__foot { display: block; padding: 16px 8px 0; border-top: 1px solid var(--border); }
.view-desktop .container { padding: 20px 24px 32px; }
/* A desktop window made narrow (or zoomed) keeps its side menu, slimmer. */
@media (max-width: 720px) { .view-desktop { --sidebar: 200px; } }
.view-switch .btn { width: 100%; }
.nav-group + .nav-group { margin-top: 24px; }
.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: 48px; 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); }

/* 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; }
.sign-in h1 { margin-bottom: 4px; }
.sign-in > .hint { margin-top: 0; }
.sign-in__help { margin: 16px 0 0; }
.field__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* 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; }



/* 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; margin: 6px 0 0; }
/* A field a refused form says is wrong: the same red as its message beside it. */
[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }

/* Receipt: a goods-in desk with label and recent work alongside entry. */
.receipt-workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.receipt-support { display: grid; gap: 16px; min-width: 0; }
.receipt-support .panel { margin: 0; }
.receipt-label { display: grid; gap: 16px; }
.receipt-label .label { margin: 0; }
.receipt-label-empty { padding: 20px 0; }
.receipt-label-empty p { font-weight: 700; }
.recent-receipts { list-style: none; padding: 0 16px; }
.recent-receipts li { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: 2px 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.recent-receipts__dept { overflow-wrap: anywhere; }
.combo__chosen { display: grid; gap: 2px; margin: 8px 0 0; overflow-wrap: anywhere; }
.combo__chosen span { color: var(--muted); font-size: 0.9rem; }
.print-status { margin: 4px 0 8px; }
.recent-receipts li:last-child { border-bottom: 0; }
.recent-receipts li > .cell-note { grid-column: 1 / -1; }
.browser--receipt .pane__body--form { padding: 24px; }
.browser--receipt .stack > * + * { margin-top: 24px; }
@media (min-width: 1100px) {
  .receipt-workspace { grid-template-columns: minmax(0, 1.1fr) minmax(0, 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: 1200px) {
  .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: 1199px) { .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: 1200px) {
  .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; }

/* One column as wide as the pane, never as wide as its longest name: long names wrap (so
   similar ones stay distinguishable) while counts and chevrons keep their size. */
.picker { list-style: none; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.picker__item {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 6px 6px 6px 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-wrap: anywhere; }
.picker__count { flex: none; color: var(--muted); font-weight: 400; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.picker__chevron { flex: none; line-height: 0; color: var(--border-strong); }
.picker__chevron .icon { width: 1.1em; height: 1.1em; }
/* The chosen building or level: a quiet tint and a marker, keeping strong blue for actions. */
.picker__item[aria-current="true"] {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--text);
  box-shadow: inset 3px 0 0 var(--accent);
}
.picker__item[aria-current="true"] .picker__chevron { color: var(--accent); }

/* On a phone the three lists stack: one at a time, with where you are above it. */
.crumbs ol { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 4px 0; }
.crumbs li { display: flex; align-items: center; min-width: 0; }
.crumbs li + li::before { content: "›"; color: var(--muted); padding: 0 8px; }
.crumbs a { display: inline-flex; align-items: center; min-height: 44px; overflow-wrap: anywhere; }
.crumbs a[aria-current="page"] { color: var(--text); font-weight: 700; text-decoration: none; }
@media (max-width: 1199px) {
  .browser[data-focus] > .pane { display: none; }
  .browser[data-focus="buildings"] > .pane--buildings,
  .browser[data-focus="levels"] > .pane--levels,
  .browser[data-focus="departments"] > .pane--departments { display: flex; }
  .browser[data-focus] > .pane + .pane { border-top: 0; }
}
@media (min-width: 1200px) { .crumbs { display: none; } }

.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__hint { margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.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: 44px; 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: 44px; }
.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: 1200px) {
  .browser--split { grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); min-height: 0; }
  .users__add { display: none; } /* the form is in view beside the list */
}
.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); }
/* A name wraps (however long, and with nowhere to break) rather than push its actions off. */
.person .dept__name { overflow-wrap: anywhere; }
/* Jumped to by Add user: clear of the phone's top bar. */
#new-user-heading { scroll-margin-top: 16px; }
.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; font-variant-numeric: slashed-zero; }
.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: 44px; 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); }
/* Worth a second look, not an error: a delivery that may be at the wrong department. */
.notice--warn { border-left-color: var(--warn, #b45309); font-weight: 400; }
.notice--warn strong { font-weight: 700; }
.place-doubt__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

/* ── 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 numbers are read aloud and typed in: a slashed zero keeps 0 apart from O where the font has one. */
.order-no { overflow-wrap: anywhere; font-weight: 800; letter-spacing: 0.03em; font-variant-numeric: tabular-nums slashed-zero; }
.order-no .parcel { font-weight: 600; letter-spacing: 0; color: var(--muted); white-space: nowrap; }
.table time { white-space: nowrap; }
a.order-no { font-size: 1.05rem; }
/* In a table, a reference keeps room for an ordinary one on one line ("NH-2026-1845"): may
   break anywhere lets the table squeeze its column to a few characters a line. Longer ones
   still wrap rather than widen the table. */
.table .order-no { display: inline-block; min-width: 13ch; }
/* Who did what, under a value: a name with nowhere to break mustn't widen its column. */
.table .cell-note { overflow-wrap: anywhere; }
.loc, .facts dd, .dept__name, .timeline__meta { overflow-wrap: anywhere; }
.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 minmax(0, 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; }
.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__text { min-width: 0; overflow-wrap: anywhere; }
.label__order { font-size: 1.6rem; font-weight: 800; letter-spacing: 0.03em; }
.label__parcel { font-size: 1.1rem; font-weight: 700; }
.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 { margin-top: 8px; }
/* A drop-off: the destination once, then each order going there. A box (it holds Remove
   buttons, so it can't be one link): pointer and hover say a tap opens it, as before. */
.card--drop-off { cursor: pointer; }

/* An order row that can be removed. Without swiping (a mouse, no JavaScript) its Remove
   button sits at the end of the row; on a touch screen (.swipe-ready) it waits under the row,
   shown by swiping left or by keyboard focus. */
.swipe-row { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.swipe-row__body { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; flex: 1; min-width: 0; }
.dept__renames { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 2px; }
.swipe-hint { margin-top: 8px; text-align: center; }
.btn--remove { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.swipe-row.swipe-ready { overflow: hidden; touch-action: pan-y; border-radius: 6px; }
.swipe-ready .swipe-row__body {
  position: relative; z-index: 1; background: var(--surface); padding: 4px 0;
  transition: transform 180ms ease;
}
.swipe-ready .swipe-row__body.dragging { transition: none; }
/* Out of sight until the row is swiped, dragged or focused: under the row it showed
   through at the row's rounded corners. It goes once the row has slid back over it. */
.swipe-ready .swipe-row__action {
  position: absolute; inset: 0 0 0 auto; display: flex; align-items: stretch;
  opacity: 0; transition: opacity 0s linear 180ms;
}
.swipe-ready.swiped .swipe-row__action, .swipe-ready:has(.dragging) .swipe-row__action,
.swipe-ready .swipe-row__action:focus-within { opacity: 1; transition-delay: 0s; }
/* Swiping isn't the only way: a handle at the row's end slides it open, showing Remove. */
.swipe-ready .swipe-row__body { flex-wrap: nowrap; align-items: center; padding: 0; }
.card__orders:has(.swipe-ready) { gap: 0; padding-top: 4px; }
.swipe-row__text { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 12px; flex: 1; min-width: 0; }
.swipe-row__handle {
  flex: none; display: grid; place-items: center; width: 44px; height: 44px; margin-right: -10px; padding: 0;
  border: 0; border-radius: var(--radius); background: transparent; color: var(--muted); cursor: pointer;
}
.swipe-row__handle .icon { width: 22px; height: 22px; }
.swipe-ready .btn--remove { border-radius: 0 6px 6px 0; background: var(--danger); color: var(--on-accent); border-color: var(--danger); }
@media (prefers-reduced-motion: reduce) { .swipe-ready .swipe-row__body { transition: none; } }
/* A drop-off: the destination once, then each order going there. */
.card__orders { list-style: none; padding: 8px 0 0; margin: 8px 0 0; display: grid; gap: 6px; border-top: 1px solid var(--border); }
.card__orders li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; }
.card--drop-off .card__orders .order-no { font-size: 1.1rem; }
.card--drop-off .card__orders .cell-note { display: inline; }
/* Orders still in stores for a carried destination: attached beneath its card. */
.drop-off { display: grid; position: relative; }
/* Read the destination aloud: in the card's corner (outside its link), the text kept clear. */
/* Big and in the action colour: it's for someone who can't read the words beside it. */
.drop-off__speak {
  position: absolute; top: 8px; right: 8px; z-index: 1; width: 48px; height: 48px;
  background: var(--surface); color: var(--accent); border-color: var(--accent);
}
.drop-off__speak .icon { width: 26px; height: 26px; }
.drop-off__speak[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.drop-off:has(.drop-off__speak:not([hidden])) .card--drop-off .loc { padding-right: 56px; }
/* Speech failed: said beside the card, under its button. */
.speak-failed {
  position: absolute; top: 60px; right: 8px; z-index: 1; max-width: min(240px, calc(100% - 16px)); margin: 0;
  padding: 6px 10px; background: var(--surface); border: 1px solid var(--danger); border-radius: var(--radius);
  color: var(--danger); font-size: 0.875rem; font-weight: 600;
}
.drop-off:has(.drop-off__waiting) > .card { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.drop-off__waiting {
  display: grid; gap: 6px; padding: 10px 14px; background: var(--subtle);
  border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--radius) var(--radius);
}
.drop-off__waiting p { margin: 0; }
.drop-off__waiting details { display: grid; gap: 6px; }
.drop-off__waiting:has(> details) { padding-top: 0; padding-bottom: 0; }
.drop-off__waiting details[open] { padding-bottom: 12px; }
.drop-off__waiting summary { display: flex; align-items: center; gap: 8px; min-height: 48px; cursor: pointer; font-weight: 600; list-style: none; }
.drop-off__waiting summary::-webkit-details-marker { display: none; }
.drop-off__waiting summary::after, .also__change::after {
  content: ""; flex: none; width: 8px; height: 8px; margin-left: auto; border: solid currentColor; border-width: 0 2px 2px 0;
  transform: translateY(-2px) rotate(45deg);
}
.drop-off__waiting details[open] > summary::after, details.also[open] .also__change::after { transform: translateY(2px) rotate(-135deg); }
/* The stop itself is what's read at arm's length, walking: its name is the biggest thing on the card. */
.card--drop-off .loc__dept { font-size: 1.2rem; line-height: 1.25; font-weight: 800; }
/* The load in a line, under the title. */
.trip-head { margin-bottom: var(--gap); }
.trip-head h1 { margin-bottom: 2px; }
.trip { color: var(--muted); font-variant-numeric: tabular-nums; }
.scan__how { margin: 0 0 var(--gap); }
/* On a phone the scanner is docked at the foot of the screen, just above the navigation:
   where the thumb is. Its camera panel opens from there. With no button to show (no camera,
   no JavaScript) there's no dock, and the sentence on collecting stays in the page. */
.view-phone .scan--dock {
  position: fixed; inset: auto 0 calc(var(--bottom-nav) + env(safe-area-inset-bottom)) 0; z-index: 5;
  padding: 8px var(--gap); background: var(--surface); border-top: 1px solid var(--border);
}
.view-phone .scan.scan--dock { max-width: none; margin: 0; }
.view-phone .scan--dock:not(:has(> [data-scan-start]:not([hidden]), > [data-scan-panel]:not([hidden]))) { display: none; }
.view-phone .scan--dock .scanner { border: 0; padding: 4px 0; }
.view-phone .scan--dock .scanner__video { max-height: 45vh; }
.view-phone body.app:has(.scan--dock > :not([hidden])) { padding-bottom: calc(var(--bottom-nav) + 73px + env(safe-area-inset-bottom)); }
html.view-phone:has(.scan--dock > :not([hidden])) { scroll-padding-bottom: 160px; }
.view-phone body:has(.scan--dock > :not([hidden])) .scan__how { display: none; }
.panel.empty { display: grid; gap: 8px; }
.empty__lead { color: var(--text); font-weight: 700; font-size: 1.05rem; }
.panel.empty .btn { margin-top: 4px; }
.drop-off__waiting ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.drop-off__waiting li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; }
.drop-off__waiting .cell-note { display: inline; }
/* A department or reference with nowhere to break wraps rather than widen the page. */
.drop-off__waiting li > * { min-width: 0; overflow-wrap: anywhere; }
.sig { position: relative; }
/* Until the first stroke: where to sign. */
.sig__hint {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  color: var(--muted); font-size: 1.1rem;
}
.sig--signed .sig__hint { display: none; }
/* What this delivery covers, before anything else on the form. */
.delivery-summary { margin: 0; font-weight: 700; font-size: 1.05rem; overflow-wrap: anywhere; min-width: 0; }
details.also > summary { cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 4px 12px; min-height: 44px; margin: -8px 0; list-style: none; }
details.also > summary::-webkit-details-marker { display: none; }
details.also[open] > summary { margin-bottom: 0; }
.also__change { flex: none; display: inline-flex; align-items: center; gap: 8px; color: var(--accent); font-weight: 600; }
.also__change::after { margin-left: 0; }
.deliver-to { margin-bottom: 2px; overflow-wrap: anywhere; }
/* Recording a delivery is one job, finished or left by its back link: no bar under the
   signature for a signing hand to catch, taking the photo and signature with it. */
body.app:has(form[data-deliver]) .bottom-nav { display: none; }
body.app:has(form[data-deliver]) { padding-bottom: env(safe-area-inset-bottom); }
.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; }
.deliver > .geo-send-now { grid-column: 1 / -1; justify-self: start; }
.geo-check .btn { margin-top: 8px; }

/* ── Analytics ── */
/* Two by two on a phone where they fit, one column at the narrowest or with larger text. */
.tiles { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 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); } }

/* Order tables between a phone and a wide desk: once the table itself has under 760px (a
   container query, so the side menu counts), each row becomes two columns, the reference on
   the left and its details stacked beside it, rather than squeezing every column to a few
   words a line. Below about 520px the phone's single column (above) takes over. */
.table-wrap:has(> .table--stacks) { container-type: inline-size; }
@container (min-width: 520px) and (max-width: 759px) {
  .table--stacks thead { display: none; }
  .table--stacks, .table--stacks tbody { display: block; }
  .table--stacks tr {
    display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 20px; align-items: start;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
  }
  .table--stacks tbody tr:last-child { border-bottom: 0; }
  .table.table--stacks td, .table.table--stacks td:first-child { display: block; border: 0; padding: 0; grid-column: 2; }
  .table.table--stacks td:first-child { grid-column: 1; grid-row: 1 / span 6; }
  .table--stacks td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); }
}


/* A department's door label: big enough to read and scan from a step away. Black on white. */
.door-labels { display: grid; gap: var(--gap); justify-items: start; }
.door-label {
  background: var(--paper); color: var(--ink); border: 1px dashed var(--border-strong); border-radius: var(--radius);
  padding: 24px; width: min(100%, 420px); text-align: center; overflow-wrap: anywhere;
}
.door-label__for { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.08em; }
.door-label__dept { font-size: 2rem; font-weight: 800; line-height: 1.15; margin: 4px 0; }
.door-label__context { font-size: 1rem; }
.door-label__qr { width: min(100%, 260px); margin: 16px auto; }
.door-label__qr svg { width: 100%; height: auto; display: block; }
.door-label__how { font-size: 0.95rem; }
/* The door step of the delivery form. */
.door__status { margin: 0 0 8px; }
.door [data-door-clear] { align-self: flex-start; margin-left: -12px; }
.pane__more { margin: 12px 0 0; }
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; }
.pager .cell-note { margin-right: auto; }
.place-check { display: grid; gap: 8px; margin-top: 12px; font-weight: 400; }
.place-check__note { display: grid; gap: 4px; }
.place-check__note input { width: 100%; }
.place-check__choices { display: flex; flex-wrap: wrap; gap: 8px; }
.collect-again { margin-top: 12px; }
.report-wrong { margin-bottom: var(--gap); }
.card--collect { display: grid; gap: 6px; }
.card--collect p { margin: 0; }
.collect__from strong { font-size: 1.1rem; }
.collect__to { display: grid; gap: 2px; padding-top: 8px; border-top: 1px solid var(--border); }
.card--collect .btn { justify-self: start; }
.report-wrong summary { cursor: pointer; color: var(--muted); }
.report-wrong[open] summary { margin-bottom: 8px; }
.timeline__note { display: block; color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.door--ok .door__status { color: var(--success, #15803d); font-weight: 600; }
.door--wrong .door__status { color: var(--danger); font-weight: 600; }

/* ── Print: just the label, or the door labels, one a page ── */
@media print {
  @page { margin: 8mm; }
  body { background: #fff; }
  body * { visibility: hidden; }
  .label, .label * { visibility: visible; }
  .label { position: absolute; left: 0; top: 0; border: 0; }
  .door-labels, .door-labels * { visibility: visible; }
  .door-labels { position: absolute; left: 0; top: 0; width: 100%; display: block; }
  .door-label { width: 100%; border: 0; padding: 8mm 10mm; break-after: page; break-inside: avoid; }
  .door-label:last-child { break-after: auto; }
  .door-label__dept { font-size: 40pt; }
  .door-label__context, .door-label__for, .door-label__how { font-size: 16pt; }
  .door-label__qr { width: 100mm; margin: 8mm auto; }
}

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

/* ── vPOD refinements ── */

/* History: a rail of events, newest last; who and when on their own line. */
.timeline { list-style: none; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 14px 22px; display: grid; gap: 1px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: 0; top: 0.45em; width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong);
}
.timeline li:last-child::before { background: var(--accent); border-color: var(--accent); }
/* Each event draws the rail down to the next one's dot. */
.timeline li:not(:last-child)::after {
  content: ""; position: absolute; left: 4px; top: calc(0.45em + 12px); bottom: calc(-0.45em + 2px);
  border-left: 2px solid var(--border);
}
.timeline__meta { color: var(--muted); font-size: 0.9rem; }

/* Admin pages on a narrow screen, where the side menu isn't: Users / Locations / Analytics
   as tabs above each. (Phones offer only Deliveries and Stores in the bottom bar.) */
.admin-tabs { margin-bottom: 16px; padding: 4px; background: var(--subtle); border-radius: calc(var(--radius) + 2px); width: fit-content; }
.admin-tabs .segmented__item[aria-current="page"] { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.view-desktop .admin-tabs { display: none; }

/* Receipt: the one action on the page reaches edge to edge on a phone. */
@media (max-width: 640px) { .receipt-submit .btn { width: 100%; } }

/* Errors keep the person moving: a clear way on. */
.error-panel { margin-top: 24px; }
.error-panel p { margin-bottom: 16px; }

/* Analytics: a place wraps in the open-orders table; stage timings needn't span the page. */
.oldest .loc__context { white-space: normal; }
.stages { max-width: 760px; }

/* Task-sized forms and flexible content, including long order numbers. */
input.order-input--big { font-size: 1.75rem; font-weight: 700; min-height: 64px; }
.receipt-submit { align-items: start; flex-direction: column; }
.receipt-submit .cell-note { flex: auto; max-width: 55ch; }
.receipt-submit .btn { width: 100%; }
.deliver { max-width: 1100px; }
@media (min-width: 1100px) {
  .deliver { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px 24px; }
  .deliver > * + * { margin-top: 0; }
  .deliver > p:first-child, .deliver > .also, .deliver > .geo-status, .deliver > .form-error, .deliver > button { grid-column: 1 / -1; }
}
.scan { max-width: 640px; }

/* Stores on a phone is a driver's: what's waiting and where it's going, then scanning it.
   The scanner is the phone's (collecting isn't done at the desk); the desk's hint goes. */
.view-desktop .scan--phone { display: none; }
.view-phone .hint--desk { display: none; }
@media (max-width: 640px) {
  /* The four filters on one line, scrolled sideways, rather than two rows of the screen. */
  .pane__head--toolbar .segmented { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .pane__head--toolbar .segmented::-webkit-scrollbar { display: none; }
  .pane__head--toolbar .segmented__item { flex: none; white-space: nowrap; }
}
/* A phone's order row: the reference with when it came in beside it, then where it's going
   (and, among all orders, where it has got to). Who receipted it is on the order's page. */
@container (max-width: 519px) {
  .table.orders.table--stacks tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 0 12px; padding: 6px 16px 12px; }
  .table.orders.table--stacks td { grid-column: 1 / -1; }
  .table.orders.table--stacks td:first-child { grid-area: 1 / 1; }
  .table.orders.table--stacks .orders__received { grid-area: 1 / 2; color: var(--muted); font-size: 0.9rem; }
  .table.orders.table--stacks .orders__received::before, .orders__received .cell-note { display: none; }
  .table.orders.table--stacks .orders__status { margin-top: 6px; }
  .orders__status .cell-note:empty { display: none; }
}
@media (max-width: 640px) {
  .browser--receipt .pane__body--form { padding: 16px; }
  .label { flex-direction: column; align-items: flex-start; }
  .recent-receipts li { grid-template-columns: minmax(0, 1fr); }
  .search { flex-basis: 100%; }
  .table.orders .order-no { display: inline-block; padding: 8px 0; }
  .person .actions { padding-left: 0; }
}

/* ── A phone's screen, all of it ──
   No top bar: it held only the mark and the account button, which sits in the navigation
   at the foot instead, with everything else a thumb uses. The two driver screens need no
   title (the navigation says which one this is), and their lists and the delivery form run
   edge to edge. */
.view-phone .sidebar { border-bottom: 0; }
.view-phone .sidebar__head { min-height: 0; padding: 0; }
.view-phone .sidebar .brand { display: none; }
.view-phone .bottom-nav { padding-right: 33.333%; }
.view-phone .account-menu {
  position: fixed; z-index: 6; right: 0; bottom: env(safe-area-inset-bottom); width: 33.333%;
}
.view-phone .account-menu > summary.icon-btn {
  flex-direction: column; gap: 2px; width: 100%; height: var(--bottom-nav); border: 0; border-radius: 0;
  color: var(--muted); font-size: 0.8rem; font-weight: 600;
}
.view-phone .account-menu > summary .icon { width: 24px; height: 24px; }
.view-phone .account-menu[open] > summary { background: transparent; color: var(--accent); box-shadow: inset 0 2px 0 var(--accent); }
.view-phone .account-menu__panel { top: auto; bottom: calc(100% + 8px); right: var(--gap); }
.view-phone body.app:has(form[data-deliver]) .account-menu { display: none; }
.view-phone .title--desk { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 640px) {
  .cards, .container > .browser--single, .container > form.deliver { margin-left: calc(-1 * var(--gap)); margin-right: calc(-1 * var(--gap)); }
  .card--drop-off, .drop-off__waiting, .container > .browser--single, .container > form.deliver { border-left: 0; border-right: 0; border-radius: 0; }
  .drop-off:has(.drop-off__waiting) > .card { border-radius: 0; }
  .container > .browser--single .pane__head { border-radius: 0; }
  .drop-off__speak { right: 12px; }
  .container:has(> .browser--single) { padding-top: 0; }
  .container > .browser--single { border-top: 0; }
}
/* With no top bar, the page itself keeps clear of a phone's notch. */
.view-phone body.app { padding-top: env(safe-area-inset-top); }

/* Receipt items: counting a delivery against a vPROC purchase order. */
.steps { list-style: none; padding: 0; margin: 0 0 var(--gap); display: flex; flex-wrap: wrap; gap: 8px 20px; }
.steps__item { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; }
.steps__n {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 999px;
  border: 1px solid var(--border-strong); font-variant-numeric: tabular-nums; font-size: 0.9rem;
}
.steps__item[aria-current="step"] { color: var(--text); }
.steps__item[aria-current="step"] .steps__n { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.steps__item--done .steps__n { background: var(--subtle); }
.items-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.items-table td { vertical-align: middle; }
.items-table .num, .items-table tfoot { font-variant-numeric: tabular-nums; }
.items-table tfoot tr { border-top: 1px solid var(--border-strong); }
.items-table tfoot th, .items-table tfoot td { border-bottom: 0; padding-top: 10px; }
/* The items screen's steps are panes on their own, not inside a browser. */
.record__main > .pane { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.record__main > .pane > .pane__head { border-radius: var(--radius) var(--radius) 0 0; }
.product { display: grid; gap: 2px; min-width: 0; }
.product__code { overflow-wrap: anywhere; }
.product__desc { overflow-wrap: anywhere; }
.qty { display: flex; align-items: center; gap: 8px; }
input.qty__input {
  font: inherit; font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 8px 10px; min-height: 44px; width: 7.5ch; text-align: right;
}
.qty-cell .field-error { max-width: 36ch; }
.line-state { color: var(--muted); }
.line-state--complete { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-weight: 600; }
.items-summary { margin: var(--gap) 0 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.items-summary:empty { display: none; }
.items-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 16px; }
.finished-lines { margin-top: var(--gap); }
.finished-lines summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.pending-items li { grid-template-columns: minmax(0, 1fr) auto; }
@media (max-width: 640px) {
  .items-table td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: 0.85rem; }
  .items-table td:first-child::before { content: none; }
  .items-table tfoot { display: block; }
  .items-table tfoot tr { display: flex; gap: 12px; }
}
