/*
 * MhanDoctor office. Every colour, radius, space step, font size and shadow below comes from design/tokens.json,
 * defined once in the two :root blocks (test/tokens.test.ts fails on drift). Nothing else in this file or in
 * admin.js may carry a literal colour, radius or font size: use the variables.
 * Spacing (SPEC v8 §25): the --space-* scale, picked by role. 1 inside a line; 2 between controls in a row, between
 * thumbnails, above and below a table cell and a bubble; --pad inside a card, bubble, the sidebar, the sides of a
 * cell; --gap between cards, thread items, fields; --gutter the page's sides and between panes; --section between a
 * page's sections and inside a dialog; 6 under a page. No card inside a card.
 */
:root {
  --ground: #FBF7EF;
  --card: #FFFFFF;
  --ink: #33302A;
  --ink-muted: #655C51;
  --ink-faint: #B4AA98;
  --line: #E9E1D2;
  --field-border: #968B79;
  --action: #2B7A52;
  --action-foreground: #FFFFFF;
  --action-accent: #34885E;
  --action-wash: #E3F1E8;
  --action-wash-foreground: #1F6A45;
  --warn-wash: #FBEFD9;
  --warn-wash-foreground: #7A5210;
  --warn: #B87A1A;
  --problem-wash: #F8E1DC;
  --problem-wash-foreground: #9A3322;
  --problem: #B5412D;
  --problem-foreground: #FFFFFF;
  --plate: #16181A;
  --plate-foreground: #FFFFFF;
  --scrim: #16181A;
  --placeholder-a: #EFE8DA;
  --placeholder-b: #E6DDCB;

  --radius-card: 18px;
  --radius-control: 14px;
  --radius-field: 12px;
  --radius-badge: 8px;
  --radius-chip: 6px;
  --radius-round: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;

  --text-11: 11px;
  --text-12: 12px;
  --text-13: 13px;
  --text-14: 14px;
  --text-15: 15px;
  --text-16: 16px;
  --text-17: 17px;
  --text-20: 20px;
  --text-26: 26px;
  --text-32: 32px;

  --shadow-card: 0 2px 16px rgba(0,0,0,0.05);
  --shadow-pop: 0 8px 24px rgba(0,0,0,0.12);

  --size-touch-min: 48px;
  --size-button: 56px;
  --size-field: 60px;

  --pad: var(--space-3);
  --gap: var(--space-3);
  --gutter: var(--space-4);
  --section: var(--space-5);
  --row: 40px; /* sidebar links, the page header, buttons in a table row and the detail header, the pin, Void */
  --thumb: 96px;
  --chip-pad: 2px; /* a chip's and a map tooltip's top and bottom: off the space scale on purpose, they sit in a line of text */
  --backdrop: color-mix(in srgb, var(--scrim) 55%, transparent); /* behind a dialog and the open sidebar */

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Myanmar", "Myanmar Text", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, "Roboto Mono", monospace;
}
/* Light only, by the owner. The dark values are kept: <html data-theme="dark"> switches them on. */
:root[data-theme="dark"] {
  --ground: #1C1915;
  --card: #26221E;
  --ink: #F0E8D8;
  --ink-muted: #B9AF9E;
  --ink-faint: #6E655A;
  --line: #3A342D;
  --field-border: #574F44;
  --action: #5DBB8A;
  --action-foreground: #10231A;
  --action-accent: #5DBB8A;
  --action-wash: #1E3A2B;
  --action-wash-foreground: #A8E0C0;
  --warn-wash: #40300F;
  --warn-wash-foreground: #F2CE85;
  --warn: #D9962E;
  --problem-wash: #4A1F18;
  --problem-wash-foreground: #F4B3A6;
  --problem: #E0705A;
  --problem-foreground: #FFFFFF;
  --plate: #16181A;
  --plate-foreground: #FFFFFF;
  --scrim: #000000;
  --placeholder-a: #2E2923;
  --placeholder-b: #38322B;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font: var(--text-15)/1.4 var(--sans); }
[hidden] { display: none !important; }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1 { font-size: var(--text-20); font-weight: 700; line-height: 1.25; }
h2 { font-size: var(--text-17); font-weight: 700; line-height: 1.25; }
h3 { font-size: var(--text-14); font-weight: 700; color: var(--ink-muted); }
a { color: var(--action); }
.muted { color: var(--ink-muted); }
.small { font-size: var(--text-13); }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.top, main { max-width: 1280px; margin: 0 auto; padding: 0 var(--gutter); }
.top { display: flex; align-items: center; justify-content: space-between; gap: var(--gap); padding-top: var(--gap); padding-bottom: var(--gap); }
.brand { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-17); font-weight: 700; }
main { padding-bottom: var(--space-6); }

/* Icons (SPEC v8 §35): Lucide files in icons/ (its README names the source and licence), each painted through a mask
   by this one class, so an icon has the colour of the text around it. admin.js: icon("house"). */
.icon { flex: none; display: inline-block; width: var(--space-5); height: var(--space-5); background: currentColor;
  -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.i-house { -webkit-mask-image: url(icons/house.svg); mask-image: url(icons/house.svg); }
.i-clipboard-list { -webkit-mask-image: url(icons/clipboard-list.svg); mask-image: url(icons/clipboard-list.svg); }
.i-car { -webkit-mask-image: url(icons/car.svg); mask-image: url(icons/car.svg); }
.i-map { -webkit-mask-image: url(icons/map.svg); mask-image: url(icons/map.svg); }
.i-hand-coins { -webkit-mask-image: url(icons/hand-coins.svg); mask-image: url(icons/hand-coins.svg); }
.i-chart-column { -webkit-mask-image: url(icons/chart-column.svg); mask-image: url(icons/chart-column.svg); }
.i-users { -webkit-mask-image: url(icons/users.svg); mask-image: url(icons/users.svg); }
.i-smartphone { -webkit-mask-image: url(icons/smartphone.svg); mask-image: url(icons/smartphone.svg); }
.i-calendar-clock { -webkit-mask-image: url(icons/calendar-clock.svg); mask-image: url(icons/calendar-clock.svg); }
.i-settings { -webkit-mask-image: url(icons/settings.svg); mask-image: url(icons/settings.svg); }
.i-history { -webkit-mask-image: url(icons/history.svg); mask-image: url(icons/history.svg); }
.i-shield { -webkit-mask-image: url(icons/shield.svg); mask-image: url(icons/shield.svg); }
.i-chevron-right { -webkit-mask-image: url(icons/chevron-right.svg); mask-image: url(icons/chevron-right.svg); }
.i-chevron-down { -webkit-mask-image: url(icons/chevron-down.svg); mask-image: url(icons/chevron-down.svg); }
.i-check { -webkit-mask-image: url(icons/check.svg); mask-image: url(icons/check.svg); }
.i-chevron-left { -webkit-mask-image: url(icons/chevron-left.svg); mask-image: url(icons/chevron-left.svg); }
.i-x { -webkit-mask-image: url(icons/x.svg); mask-image: url(icons/x.svg); }
.i-locate-fixed { -webkit-mask-image: url(icons/locate-fixed.svg); mask-image: url(icons/locate-fixed.svg); }
.i-map-pin { -webkit-mask-image: url(icons/map-pin.svg); mask-image: url(icons/map-pin.svg); }
.i-map-pin-off { -webkit-mask-image: url(icons/map-pin-off.svg); mask-image: url(icons/map-pin-off.svg); }
.i-play { -webkit-mask-image: url(icons/play.svg); mask-image: url(icons/play.svg); }
.i-pause { -webkit-mask-image: url(icons/pause.svg); mask-image: url(icons/pause.svg); }
.i-plus { -webkit-mask-image: url(icons/plus.svg); mask-image: url(icons/plus.svg); }
.i-arrow-up { -webkit-mask-image: url(icons/arrow-up.svg); mask-image: url(icons/arrow-up.svg); }
.i-arrow-down { -webkit-mask-image: url(icons/arrow-down.svg); mask-image: url(icons/arrow-down.svg); }
.i-menu { -webkit-mask-image: url(icons/menu.svg); mask-image: url(icons/menu.svg); }

/* Buttons */
.btn { font: inherit; font-weight: 600; font-size: var(--text-14); color: var(--ink); background: var(--card); border: 1px solid var(--field-border);
  border-radius: var(--radius-field); padding: var(--space-2) var(--gutter); min-height: var(--size-touch-min); cursor: pointer; }
td .btn, .detail-top .btn, .page-head .btn, .quick .btn, .more .btn, .pager .btn { min-height: var(--row); padding: var(--space-2) var(--pad); white-space: nowrap; }
.btn:hover { border-color: var(--ink-muted); }
.btn .icon { width: var(--space-4); height: var(--space-4); vertical-align: -3px; margin-right: var(--space-1); }
.btn.primary { background: var(--action); border-color: var(--action); color: var(--action-foreground); }
.btn.quiet { border-color: transparent; background: none; color: var(--action); }
.btn.danger { color: var(--problem-wash-foreground); }
.btn.danger.solid { background: var(--problem); border-color: var(--problem); color: var(--problem-foreground); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--action-accent); outline-offset: 2px; }

/* The console: a sidebar that stays put on the left, the page scrolling beside it. The top bar is for the sign-in
   states, and for narrow screens (below), where it holds the Menu button. */
.menu, .scrim { display: none; }
.menu { align-items: center; gap: var(--space-2); }
main:has(> .sidebar) { max-width: none; padding: 0; display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: start; }
body:has(.sidebar) .top { display: none; }
.sidebar { position: sticky; top: 0; height: 100dvh; overflow-y: auto; display: flex; flex-direction: column; gap: var(--gap);
  padding: var(--pad); background: var(--card); box-shadow: var(--shadow-card); }
/* The brand row and .page-head are both --row high from the same top: the logo and the page's name share a line. */
.sidebar .brand { min-height: var(--row); padding: 0 var(--space-2); font-size: var(--text-15); white-space: nowrap; }
.brand img { width: var(--space-8); height: var(--space-8); }
.sidebar nav { display: flex; flex-direction: column; gap: var(--space-1); flex: 1; }
.sidebar a, .sidebar summary { display: flex; align-items: center; gap: var(--space-2); min-height: var(--row); padding: var(--space-2) var(--pad);
  border-radius: var(--radius-control); font-weight: 600; font-size: var(--text-15); color: var(--ink-muted); text-decoration: none; cursor: pointer; }
.sidebar a:hover, .sidebar summary:hover { color: var(--ink); background: var(--ground); }
.sidebar a[aria-current] { color: var(--action-wash-foreground); background: var(--action-wash); }
/* The Admin group: a chevron that turns when it opens, its pages indented under it. */
.sidebar details { display: flex; flex-direction: column; gap: var(--space-1); }
.sidebar summary { list-style: none; margin: 0; }
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary .i-chevron-right { width: var(--space-4); height: var(--space-4); margin-left: auto; }
.sidebar details[open] > summary .i-chevron-right { transform: rotate(90deg); }
.sidebar details[open] > summary { margin-bottom: var(--space-1); }
.sidebar details a { margin: var(--space-1) 0 0 var(--pad); }
.sidebar .who { display: flex; flex-direction: column; padding: var(--pad) var(--space-2) 0; border-top: 1px solid var(--line); color: var(--ink-muted); font-size: var(--text-13); overflow-wrap: anywhere; }
.sidebar .who strong { color: var(--ink); font-size: var(--text-14); }
.count { display: inline-block; padding: 0 var(--space-2); border-radius: var(--radius-chip); font-size: var(--text-12);
  font-weight: 700; background: var(--warn-wash); color: var(--warn-wash-foreground); white-space: nowrap; }
.content { min-width: 0; max-width: 1280px; padding: var(--gap) var(--gutter) var(--space-6); }
/* The page header: the page's name (or the way back, in a work order) and when the page last refreshed. */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--gap); min-height: var(--row); margin-bottom: var(--gap); }
.updated { color: var(--ink-muted); font-size: var(--text-13); }
/* Before it, whether changes arrive by themselves (SPEC v8 §16.6): a green dot and Live, an amber one while reconnecting. */
.fresh { display: flex; align-items: center; gap: var(--gap); }
.live { display: inline-flex; align-items: center; gap: var(--space-1); color: var(--ink-muted); font-size: var(--text-13); }
.live:empty { display: none; }
/* The one status dot: Live, and the Dispatch banner. */
.live::before, .banner::before { content: ""; flex: none; width: var(--space-2); height: var(--space-2); border-radius: var(--radius-round); background: var(--action); }
.live[data-state="reconnecting"]::before { background: var(--warn); }

section + section { margin-top: var(--section); }
section > h2, .head { margin-bottom: var(--gap); }
.head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--gap); }
.head h2 { margin: 0; }
/* A card's surface; a chart and a table sit on the same one. */
.card, .chart, .table-wrap { background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.card, .chart { padding: var(--pad); }
.empty { padding: var(--pad); border: 2px dashed var(--line); border-radius: var(--radius-card); color: var(--ink-muted); }
.loading { color: var(--ink-muted); padding: var(--pad) 0; }
/* Notices: amber by default, .good green, .bad red (errorBox, the toast); the Dispatch banner and the toast are notices too. */
.notice, .banner, .toast { padding: var(--space-2) var(--pad); border-radius: var(--radius-field); background: var(--warn-wash); color: var(--warn-wash-foreground);
  font-weight: 600; overflow-wrap: anywhere; }
.notice { margin-bottom: var(--gap); }
.notice.good, .banner { background: var(--action-wash); color: var(--action-wash-foreground); }
.notice.bad, .toast { background: var(--problem-wash); color: var(--problem-wash-foreground); }
/* The line under a field that says what goes in it (SPEC v8 §38). */
.help { display: block; font-weight: 400; color: var(--ink-muted); font-size: var(--text-13); margin-top: var(--space-1); }

/* Chips, as on the phone: green for good, amber for waiting, red for problems. */
.chip { display: inline-block; font-size: var(--text-12); font-weight: 700; line-height: 1.35; padding: var(--chip-pad) var(--space-2); border-radius: var(--radius-chip);
  white-space: nowrap; background: var(--placeholder-a); color: var(--ink-muted); vertical-align: middle; }
.chip.good { background: var(--action-wash); color: var(--action-wash-foreground); }
.chip.warn { background: var(--warn-wash); color: var(--warn-wash-foreground); }
.chip.bad { background: var(--problem-wash); color: var(--problem-wash-foreground); }
.chip.plain { background: none; box-shadow: inset 0 0 0 1px var(--line); }

/* The licence plate: white characters on the plate black, region small above the serial. The one loud thing. */
.plate { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; background: var(--plate); color: var(--plate-foreground);
  border-radius: var(--radius-badge); padding: var(--space-1) var(--space-3); font-family: var(--mono); white-space: nowrap; vertical-align: middle; }
.region { font-family: var(--mono); font-size: var(--text-14); font-weight: 700; letter-spacing: 1px; white-space: nowrap; }
/* ponytail: padding-left 2px is an optical nudge, balancing the letter-spacing left after the last character */
.plate .serial { font-size: var(--text-20); line-height: 24px; font-weight: 800; letter-spacing: 2px; padding-left: 2px; }
.plate.lg .serial { font-size: var(--text-26); line-height: 30px; }
.plate .serial.my { line-height: 1.9; letter-spacing: 0; } /* Burmese: see plateBadge */
.plate.code .serial { font-size: var(--text-20); letter-spacing: 4px; }
.plate.code.lg .serial { font-size: var(--text-32); line-height: 1.2; letter-spacing: 6px; }
.plate.code.lg { padding: var(--space-3) var(--space-5); }

/* Waiting devices */
.pending { display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-2) var(--gutter); align-items: center; padding: var(--pad);
  background: var(--card); border: 2px dashed var(--warn); border-radius: var(--radius-card); }
.pending + .pending { margin-top: var(--gap); }
.pending .name { font-weight: 700; font-size: var(--text-16); overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
/* ---- Reports and Home (SPEC v8 §33). A chart is SVG sized by its attributes; only its paint is here: one green,
   the rest neutral; red and amber stay for problems, never for a series. ---- */
.sect { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--section); min-width: 0; }
.sect > p, .sect > .head { margin: 0; }
.cols > .sect { margin-top: 0; } /* side by side: no "section after a section" gap */
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 0 var(--gutter); align-items: start; }
.chart { overflow-x: auto; }
.chart svg { display: block; margin: 0 auto; }
.chart text, .timeline text { font-size: var(--text-12); fill: var(--ink-muted); font-variant-numeric: tabular-nums; }
.chart text.value { fill: var(--ink); font-weight: 700; }
.chart .axis, .timeline .axis { stroke: var(--field-border); }
.chart .bar, .meter .bar, .timeline .bar, .chart .dot { fill: var(--action); }
/* ponytail: rx as a CSS property (Chrome, Firefox); Safari ignores it and draws square bars */
.chart .bar, .meter .bar, .timeline .bar { rx: var(--radius-chip); }
.chart .bar.open, .timeline .bar.open, .chart .dot.open { fill: var(--action-wash); stroke: var(--action); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .trend { fill: none; stroke: var(--action); stroke-width: 2; }
.chart .trend.open { stroke-dasharray: 4 3; }
.meter { display: block; margin-top: var(--space-1); max-width: 100%; }
@media (min-width: 721px) { .chart svg { max-width: 100%; height: auto; } } /* shrinks to its card; on a phone it scrolls sideways instead */

.pending .actions { justify-content: flex-end; }

/* Tables */
.table-wrap { overflow-x: auto; } /* a value too long for its column scrolls instead of being cut off */
.table-wrap ~ .hint { margin-top: var(--space-2); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: var(--text-13); font-weight: 600; color: var(--ink-muted); padding: var(--space-2) var(--pad); border-bottom: 1px solid var(--line); }
td { padding: var(--space-2) var(--pad); vertical-align: middle; border-bottom: 1px solid var(--line); overflow-wrap: break-word; } /* not anywhere: that let a narrow column split dates and names mid-word */
tr:last-child td { border-bottom: 0; }
td.actions-cell { width: 1%; white-space: nowrap; }
td .actions { flex-wrap: nowrap; justify-content: flex-end; }
td strong { font-weight: 700; }
td.right, th.right { text-align: right; }
td.nowrap { white-space: nowrap; }
tr.off td:not(.actions-cell) { color: var(--ink-muted); }
tr:has(details[open]) td { vertical-align: top; } /* a Devices row with its Details open */
tr.link { cursor: pointer; }
tr.link:hover td { background: var(--ground); }
.code-inline { font-family: var(--mono); letter-spacing: 1px; }

details > summary { cursor: pointer; font-weight: 600; color: var(--ink-muted); padding: var(--space-2) 0; }
details[open] > summary { margin-bottom: var(--space-2); }

/* Whole-page states: waiting, removed, not for the office, unsupported, error */
.state { max-width: 34rem; margin: 9vh auto 0; text-align: center; }
.state h2 { font-size: var(--text-26); margin-bottom: var(--space-2); }
.state p + p, .state .plate, .state form, .state .btn { margin-top: var(--section); }
.state form .btn { margin-top: 0; } /* beside the name field: the same height */
.state form { display: flex; gap: var(--space-2); justify-content: center; flex-wrap: wrap; }

/* Forms and dialogs */
dialog { width: min(28rem, calc(100vw - 2 * var(--gutter))); padding: var(--section); color: var(--ink); background: var(--card);
  border: 0; border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
dialog::backdrop { background: var(--backdrop); }
dialog h2 { font-size: var(--text-20); margin-bottom: var(--gap); }
dialog p { margin-bottom: var(--gap); }
label { display: block; font-weight: 600; font-size: var(--text-14); margin-bottom: var(--gap); }
input[type="text"], input[type="tel"], input[type="search"], input[type="date"], input[type="time"], input[type="datetime-local"], input[type="number"], select, textarea {
  display: block; width: 100%; margin-top: var(--space-1); font: inherit; font-size: var(--text-16); color: var(--ink); background: var(--card);
  border: 2px solid var(--field-border); border-radius: var(--radius-field); padding: var(--space-1) var(--pad); min-height: var(--size-touch-min);
  line-height: 1.9; } /* Burmese reaches well above and below Latin: a field clips what its line does not hold */
input:focus, select:focus, textarea:focus { border-color: var(--action-accent); outline: none; }
::placeholder { color: var(--ink-muted); opacity: 1; }
/* The dropdown (admin.js dropdown()): a button like a field, and a card list under it, the TapDone "How often" picker.
   The native <select> inside stays the model, never shown. */
.dd { position: relative; margin-top: var(--space-1); }
.dd > select { display: none; }
.dd-button { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); width: 100%; font: inherit;
  font-size: var(--text-16); font-weight: 400; line-height: 1.9; color: var(--ink); text-align: left; background: var(--card);
  border: 2px solid var(--field-border); border-radius: var(--radius-field); padding: var(--space-1) var(--pad); min-height: var(--size-touch-min); cursor: pointer; }
.dd-button:hover { border-color: var(--ink-muted); }
.dd-button:focus-visible, .dd-button[aria-expanded="true"] { border-color: var(--action-accent); outline: none; }
.dd-button:disabled { opacity: 0.5; cursor: default; }
.dd-button .icon { color: var(--ink-muted); }
.dd-button[aria-expanded="true"] .icon { transform: rotate(180deg); }
.dd-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
dialog .dd-list { position: static; margin-top: var(--space-1); } /* a modal dialog clips overflow: open in flow */
.dd-list { position: absolute; z-index: 40; top: calc(100% + var(--space-1)); left: 0; min-width: 100%; max-width: min(28rem, 90vw); max-height: calc(8 * var(--row));
  overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-field);
  box-shadow: var(--shadow-pop); outline: none; }
.dd-item { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) var(--pad);
  min-height: var(--row); font-size: var(--text-15); font-weight: 400; line-height: 1.6; color: var(--ink); white-space: nowrap; cursor: pointer;
  border-bottom: 1px solid var(--line); }
.dd-item:last-child { border-bottom: 0; }
/* The row the keys (or the pointer) are on: its own channel, a green edge, so it still shows on the chosen row. */
.dd-item.active { background: var(--placeholder-b); box-shadow: inset 3px 0 0 var(--action-accent); }
.dd-item[aria-selected="true"] { background: var(--action-wash); color: var(--action-wash-foreground); font-weight: 600; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--action); width: var(--space-5); height: var(--space-5); margin: 0; vertical-align: middle; }
textarea { resize: vertical; min-height: calc(2 * var(--row)); }
.state input[type="text"] { width: 15rem; margin-top: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--section); }
.form-error { color: var(--problem-wash-foreground); font-weight: 600; margin: 0; }
.check { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 600; margin: 0; cursor: pointer; min-height: var(--space-8); }
/* A square icon button: the viewer's, Recenter, the round ones, play. Each sets its size, shape and paint below. */
.viewer button, .recenter, .round, .play { flex: none; display: grid; place-items: center; padding: 0; border: 0; cursor: pointer; }
.viewer button:disabled, .recenter:disabled, .round:disabled { opacity: 0.5; cursor: not-allowed; }

/* The photo viewer (SPEC v8 §25): the whole window, the page dimmed behind the picture. */
dialog.viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: var(--pad) var(--gutter) var(--gutter); border-radius: 0; box-shadow: none;
  background: color-mix(in srgb, var(--scrim) 92%, transparent); color: var(--plate-foreground); grid-template-rows: auto minmax(0, 1fr); gap: var(--gap); cursor: zoom-out; }
dialog.viewer[open] { display: grid; }
dialog.viewer::backdrop { background: none; }
.viewer p { margin: 0; }
.viewer > div { display: flex; align-items: center; justify-content: space-between; gap: var(--gutter); min-height: 0; }
.viewer .counter { font-size: var(--text-17); font-weight: 700; font-variant-numeric: tabular-nums; }
.viewer button { width: var(--size-touch-min); height: var(--size-touch-min); border-radius: var(--radius-control); background: var(--card); color: var(--ink); }

.viewer figure { flex: 1; min-width: 0; height: 100%; margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--gap); }
.viewer img { flex: 0 1 auto; min-height: 0; max-width: 100%; object-fit: contain; border-radius: var(--radius-field); cursor: default; }
.viewer figcaption { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); text-align: center; font-size: var(--text-13); cursor: default; overflow-wrap: anywhere; }
.viewer figcaption .body { font-size: var(--text-16); white-space: pre-wrap; }

.toast { position: fixed; left: 50%; bottom: var(--section); transform: translateX(-50%); max-width: calc(100vw - 2 * var(--gutter)); box-shadow: var(--shadow-card); z-index: 2000; }

/* ---- Dispatch: map left, the Mobile Agents nearest the customer right ---- */
/* The map and the list fill the window under the page header: --row, the gaps above and below it, the room under a page. */
.dispatch { --fill: calc(100dvh - var(--row) - 2 * var(--gap) - var(--space-6)); display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--gutter); align-items: start; }
.map { height: var(--fill); min-height: 420px; border-radius: var(--radius-card); box-shadow: var(--shadow-card); background: var(--placeholder-a); z-index: 0; }
.side { display: flex; flex-direction: column; gap: var(--gap); max-height: var(--fill); min-height: 420px; }
.banner { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-13); }
.banner.idle { background: var(--placeholder-a); color: var(--ink-muted); }
.banner.idle::before { background: var(--ink-faint); }
.pin-form { display: flex; gap: var(--space-2); align-items: end; }
.pin-form label { flex: 1; margin: 0; }
.pin-help { font-size: var(--text-13); color: var(--ink-muted); }
.pin { display: flex; flex-direction: column; gap: var(--space-2); }
.side .head { margin: 0; }
/* ponytail: 2px = the width of the .nearest ring, room for it inside the scrolling list */
.agents { overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-2); padding: 2px; margin: -2px; }
.agent { display: grid; grid-template-columns: 1fr auto; gap: var(--space-1) var(--gap); padding: var(--space-2) var(--pad); background: var(--card);
  border-radius: var(--radius-control); box-shadow: var(--shadow-card); cursor: pointer; }
.agent:hover { box-shadow: var(--shadow-card), inset 0 0 0 1px var(--field-border); }
.agent .name { font-weight: 700; font-size: var(--text-16); overflow-wrap: anywhere; }
.agent .dist { font-weight: 800; font-size: var(--text-17); text-align: right; font-variant-numeric: tabular-nums; }
.agent .meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); font-size: var(--text-13); color: var(--ink-muted); }
.agent .meta .check { margin-left: auto; font-size: var(--text-13); min-height: 0; }
.agent .today { grid-column: 1 / -1; font-size: var(--text-13); }
.agent.stale .dist, .agent.stale .when { color: var(--ink-muted); }
.agent.off .name { color: var(--ink-muted); font-weight: 600; }
.agent.nearest { box-shadow: var(--shadow-card), inset 0 0 0 2px var(--action-accent); }

/* Leaflet paths carry these classes; CSS wins over the stroke/fill attributes Leaflet writes. */
.mk-on { stroke: var(--card); fill: var(--action); stroke-width: 3; fill-opacity: 1; }
.mk-stale { stroke: var(--card); fill: var(--ink-faint); stroke-width: 3; fill-opacity: 1; }
.mk-acc { stroke: var(--action-accent); fill: var(--action-accent); stroke-width: 1; fill-opacity: 0.12; }
.mk-acc.stale { stroke: var(--ink-faint); fill: var(--ink-faint); }
.mk-customer { stroke: var(--ink); fill: var(--warn); stroke-width: 3; fill-opacity: 1; }
.mk-trail { stroke: var(--action-accent); stroke-width: 3; stroke-dasharray: 6 6; fill: none; }
.mk-spot { stroke: var(--card); fill: var(--ink); stroke-width: 3; fill-opacity: 1; }
.leaflet-container { font: var(--text-13)/1.35 var(--sans); background: var(--placeholder-a); }
.leaflet-tooltip.tip { background: var(--card); color: var(--ink); border: 0; border-radius: var(--radius-chip); box-shadow: var(--shadow-card);
  font-size: var(--text-13); font-weight: 600; padding: var(--chip-pad) var(--space-2); }
.leaflet-tooltip.tip::before { display: none; }
.leaflet-tooltip.tip.stale { color: var(--ink-muted); }
.leaflet-tooltip.tip .t { display: block; font-weight: 400; font-size: var(--text-12); color: var(--ink-muted); }
.leaflet-control-attribution { font-size: var(--text-11); }
/* Leaflet's zoom buttons and attribution, on the palette instead of the vendor's white, grey and blue. */
.leaflet-bar, .leaflet-touch .leaflet-bar { border: 0; border-radius: var(--radius-field); box-shadow: var(--shadow-card); overflow: hidden; }
.leaflet-bar a, .leaflet-bar a.leaflet-disabled { background: var(--card); color: var(--ink); border-bottom-color: var(--line); }
.leaflet-bar a:hover, .leaflet-bar a:focus { background: var(--placeholder-b); }
.leaflet-bar a.leaflet-disabled { opacity: 0.5; cursor: not-allowed; } /* the one disabled look */
.leaflet-container .leaflet-control-attribution { background: color-mix(in srgb, var(--card) 80%, transparent); color: var(--ink-muted); }
.leaflet-control-attribution a { color: var(--action); }
.map-note { position: absolute; z-index: 1000; left: var(--space-2); right: var(--space-2); top: var(--space-2); margin: 0; padding: var(--space-2) var(--pad);
  border-radius: var(--radius-field); background: var(--card); color: var(--ink-muted); font-size: var(--text-13); box-shadow: var(--shadow-card); }
/* A map with its Recenter button on it, top right. */
.map-box { position: relative; }
.recenter { position: absolute; z-index: 1; top: var(--space-2); right: var(--space-2); width: var(--size-touch-min); height: var(--size-touch-min);
  border-radius: var(--radius-control); background: var(--card); color: var(--ink); box-shadow: var(--shadow-card); }
.recenter .icon, .play .icon { width: var(--space-6); height: var(--space-6); }
.recenter:hover { color: var(--action); }

/* ---- Work orders ---- */
.filters { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--gap); align-items: end; margin-bottom: var(--space-2); }
/* Compact: a small muted caption over a --row high field, so the filters sit in one row above the list. */
.filters label, .filters .range > span { margin: 0; min-width: 9rem; font-size: var(--text-12); color: var(--ink-muted); }
.filters label.grow { flex: 1; min-width: 12rem; max-width: 22rem; }
.filters label.date { min-width: 0; width: 8.5rem; }
.filters label.date:has(input[name="older"]) { width: 12rem; }
.filters :is(input, select, .dd-button) { min-height: var(--row); padding: var(--space-1) var(--space-2); font-size: var(--text-14); border-width: 1px; }
.filters .dd-item { font-size: var(--text-14); }
.filters .range > span { display: block; }
.filters .range > div { display: flex; align-items: center; gap: var(--space-1); }
.filters .range input { width: 6rem; }
.filters > .btn, .filters .quick .btn { min-height: var(--row); padding: var(--space-1) var(--pad); }
.filters .quick { display: flex; flex-wrap: wrap; gap: var(--space-2); flex: 1 1 100%; }
.quick .btn[aria-pressed="true"], .views .btn[aria-current] { background: var(--action-wash); color: var(--action-wash-foreground); border-color: var(--action-accent); }
/* Work order views, payment filters, the count line (SPEC v8 §31) */
.views { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--gap); }
.views .view { display: inline-flex; align-items: center; }
.filters label.narrow { min-width: 7rem; flex: 0 1 8rem; }
.list-sum { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--gap); margin-bottom: var(--gap); }
.sum-line { font-size: var(--text-14); font-variant-numeric: tabular-nums; }
td .chip { margin-top: var(--space-1); }
.hint { font-size: var(--text-13); color: var(--ink-muted); margin-bottom: var(--gap); }
.price { font-weight: 700; font-size: var(--text-16); white-space: nowrap; font-variant-numeric: tabular-nums; }
.amount { font-weight: 800; font-size: var(--text-26); line-height: 1.2; white-space: nowrap; font-variant-numeric: tabular-nums; }
.more { display: flex; justify-content: center; gap: var(--space-2); margin-top: var(--gap); }
/* The pager (SPEC v8 §39): the count on the left; rows a page, Previous and Next on the right. */
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-2); margin: var(--gap) 0; }
.pager > span { margin-right: auto; font-size: var(--text-13); color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.pager .dd { margin-top: 0; }
.pager .dd-button { width: auto; min-height: var(--row); padding-top: 0; padding-bottom: 0; font-size: var(--text-14); }
.pager .dd-list, .send-row .dd-list { top: auto; bottom: calc(100% + var(--space-1)); } /* near the page's foot: open upwards */
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--gap); }

.detail-top { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--gutter); padding: var(--pad) var(--gutter); margin-bottom: var(--gap); }
.detail-top .info { min-width: 0; }
.detail-top .grow { flex: 1; }
.detail-top .car { font-size: var(--text-17); font-weight: 700; overflow-wrap: anywhere; }
.detail-top .right { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-1); }
/* Two panes under the header: the messages (thread + composer) and the side pane (Item details, other work orders). */
.detail { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); gap: var(--gutter); align-items: start; }
.detail > div { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
/* A wide window: the page is exactly one window high and does not scroll; the thread and the side pane scroll inside
   themselves. :has() keeps this to the work-order detail, so every other view scrolls as before.
   ponytail: the thread never goes under 240 high (the note composer is tall); a shorter window scrolls the page a
   little instead. */
@media (min-width: 901px) {
  .content:has(.detail) { display: flex; flex-direction: column; height: 100dvh; min-height: 640px; padding-bottom: var(--gap); }
  .panel:has(> .detail) { display: flex; flex-direction: column; flex: 1; min-height: 0; }
  .detail { flex: 1; min-height: 0; grid-template-rows: minmax(0, 1fr); align-items: stretch; }
  .detail > div { min-height: 0; }
  .thread { flex: 1 1 0; min-height: 240px; }
  .side-pane { overflow-y: auto; }
}
/* Room for the cards' shadows inside the scrolling boxes, which would cut them off. */
.thread, .side-pane { padding: var(--pad); margin: calc(-1 * var(--pad)); }
.side-card { display: flex; flex-direction: column; gap: var(--space-2); }
.mini-map { height: 200px; border-radius: var(--radius-control); z-index: 0; }
/* Name / value lists: the phone's permissions on an item, a device's reported details. A problem row is marked. */
.perms { display: flex; flex-direction: column; gap: var(--space-1); padding-top: var(--space-2); border-top: 1px solid var(--line); }
.perms dl, .report dl, .money dl { margin: 0; font-size: var(--text-13); }
.perms dl > div, .report dl > div, .money dl > div { display: flex; justify-content: space-between; gap: var(--gap); padding: var(--space-1) 0; }
.perms dt, .report dt, .money dt { color: var(--ink-muted); }
.perms dd, .report dd, .money dd { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.perms .problem dt { color: var(--problem-wash-foreground); font-weight: 700; }
.report { max-width: 22rem; }
.report > summary { font-size: var(--text-13); min-height: var(--space-8); padding: var(--space-1) 0; }
.report-line::first-letter { text-transform: uppercase; }
.history li + li { border-top: 1px solid var(--line); }
/* A work order's History (SPEC v8 §29): one plain sentence a row. */
.audit { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); font-size: var(--text-13); overflow-wrap: anywhere; }
.history button { display: flex; align-items: center; gap: var(--gap); width: 100%; min-height: var(--row); padding: var(--space-2) 0; background: none; border: 0;
  font: inherit; color: inherit; text-align: left; cursor: pointer; }
.history button:hover .car { text-decoration: underline; }
.history .car { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* The item thread: the Mobile Agent's items sit right on white cards, the office's left on the green wash. */
.thread { display: flex; flex-direction: column; gap: var(--gap); overflow-y: auto; overscroll-behavior: contain; }
.thread > * { flex: none; }
.item { align-self: flex-end; max-width: min(100%, 460px); background: var(--card); border-radius: var(--radius-card) var(--radius-card) var(--radius-chip) var(--radius-card);
  box-shadow: var(--shadow-card); padding: var(--space-2) var(--pad); display: flex; flex-direction: column; gap: var(--space-1); }
.item.wide { width: 460px; } /* a voice note: room for its player */
.item.money { width: 300px; }
.item.office { align-self: flex-start; background: var(--action-wash); box-shadow: none; border-radius: var(--radius-card) var(--radius-card) var(--radius-card) var(--radius-chip); }
.item .who, .shots .who { font-size: var(--text-12); font-weight: 700; color: var(--ink-muted); }
.item.office .who, .item.office .meta { color: var(--action-wash-foreground); }
.item .pay { display: flex; align-items: center; justify-content: space-between; gap: var(--gap); }
.item .body { font-size: var(--text-16); white-space: pre-wrap; overflow-wrap: anywhere; }
.item .meta { font-size: var(--text-12); color: var(--ink-muted); align-self: flex-end; display: flex; gap: var(--space-2); align-items: center; }
/* A photo is a small cropped square that opens the viewer (SPEC v8 §25). A payment's photo sits left of its note. */
.thumb { position: relative; flex: none; display: block; width: var(--thumb); height: var(--thumb); padding: 0; border: 0; border-radius: var(--radius-field); overflow: hidden; cursor: zoom-in;
  font: inherit; font-size: var(--text-12); font-weight: 700; color: var(--ink);
  background: repeating-linear-gradient(135deg, var(--placeholder-a) 0 12px, var(--placeholder-b) 12px 24px); }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb span { position: absolute; left: var(--space-1); bottom: var(--space-1); padding: 0 var(--space-1); border-radius: var(--radius-chip); background: var(--card); font-variant-numeric: tabular-nums; }
.thumb span:empty { display: none; }
.thumb span + span { bottom: auto; top: var(--space-1); color: var(--problem-wash-foreground); }
.item .shot { display: flex; align-items: flex-start; gap: var(--gap); }
.item .shot .body { flex: 1; min-width: 0; }
/* Photos sent one after another by one person: the name once, then a wrapping row of tiles. A tile is still one item. */
.shots { align-self: flex-end; max-width: 100%; display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-1); }
.shots.office { align-self: flex-start; align-items: flex-start; }
.shots > div { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: flex-start; gap: var(--space-2); }
.shots.office > div { justify-content: flex-start; }
.item.tile { width: calc(var(--thumb) + 2 * var(--space-2)); padding: var(--space-2); border-radius: var(--radius-card); }
.item.tile .body { font-size: var(--text-13); white-space: normal; }
.item.tile .meta { align-self: stretch; justify-content: space-between; min-height: var(--space-8); }
.item.tile .where { margin: calc(-1 * var(--space-1)); }
/* The pin of an item from a phone: pressed while the item is shown in the Item details card; crossed (.none) when the
   item has no location. */
.where { display: grid; place-items: center; flex: none; width: var(--row); height: var(--row); margin: calc(-1 * var(--space-2)) calc(-1 * var(--space-1)); border: 0;
  border-radius: var(--radius-field); background: none; color: inherit; cursor: pointer; }
.where:hover { color: var(--action); }
.where[aria-pressed="true"] { background: var(--action); color: var(--action-foreground); }
/* A voided item stays where it was, crossed out; "Voided by" says it in words. */
.item.voided, .item.office.voided { background: var(--ground); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-muted); }
.item.voided .amount, .item.voided .body { text-decoration: line-through; }
.item.voided .thumb { opacity: 0.5; } /* its "Voided by" line says it in words */
.item.selected, .item.office.selected { box-shadow: var(--shadow-card), inset 0 0 0 2px var(--action-accent); }
.item .gone { font-size: var(--text-13); font-weight: 600; color: var(--problem-wash-foreground); }
.del { font: inherit; font-size: var(--text-13); font-weight: 600; color: var(--problem-wash-foreground); background: none; border: 0; min-height: var(--row);
  padding: 0 var(--space-1); margin: calc(-1 * var(--space-2)) calc(-1 * var(--space-1)) calc(-1 * var(--space-2)) 0; cursor: pointer; }
.del:hover { text-decoration: underline; }
.del.undo { color: var(--action); }

/* Voice note: one big button (play, a spinner or pause by data-state), a bar to drag, the time, the speed. */
.player { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: var(--space-2) var(--gap); }
.player .form-error { grid-column: 1 / -1; }
.play { width: var(--size-button); height: var(--size-button); border-radius: var(--radius-round); background: var(--action); color: var(--action-foreground); }
.play[data-state="playing"] .icon { -webkit-mask-image: url(icons/pause.svg); mask-image: url(icons/pause.svg); }
.play[data-state="loading"] { cursor: progress; }
.play[data-state="loading"] .icon { background: none; -webkit-mask-image: none; mask-image: none; border: 3px solid currentColor; border-right-color: transparent; border-radius: var(--radius-round); }
.track { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.seek { display: block; width: 100%; height: 24px; margin: 0; accent-color: var(--action); cursor: pointer; }
.seek:disabled { opacity: 0.5; cursor: default; }
.speed { min-width: var(--size-button); font-weight: 700; padding-left: 0; padding-right: 0; }

/* The composer (SPEC v8 §39, after the phone's §36): one rounded card of two rows, the message over its buttons.
   No blur, no translucency. The card takes the field's focus ring, since the field inside has no border. */
.composer { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-2); background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.composer:has(textarea:focus) { border-color: var(--action-accent); }
.composer input, .composer .dd-button, .composer .btn { margin: 0; min-height: var(--row); padding-top: var(--space-1); padding-bottom: var(--space-1); }
/* ponytail: grows with the text where field-sizing exists (Chrome, Edge, Safari 26); elsewhere it stays one line and scrolls */
.composer textarea { margin: 0; border: 0; background: none; resize: none; field-sizing: content; min-height: var(--row); max-height: 160px;
  padding: var(--space-2) var(--space-2) var(--space-1); }
.send-row, .pay-fields { display: flex; align-items: center; gap: var(--space-2); }
.pay-fields { padding-bottom: var(--space-2); border-bottom: 1px solid var(--line); }
.pay-fields[hidden] { display: none; }
.send-row .grow { flex: 1; }
.send-row .dd, .pay-fields .dd { flex: none; width: auto; margin-top: 0; }
.send-row .dd-button { border-width: 1px; border-color: var(--line); border-radius: var(--radius-round); background-color: var(--ground); font-size: var(--text-14); }
.send-row .dd-button:focus-visible, .send-row .dd-button[aria-expanded="true"] { border-color: var(--action-accent); } /* after the pale border above */
.send-row .dd-list { left: auto; right: 0; }
.pay-fields input[name="amount"] { flex: 0 1 150px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pay-fields input[name="note"] { flex: 1 1 0; min-width: 0; }
/* A round button: the composer's + and Send, and the jump to the latest message. */
.round { width: var(--row); height: var(--row); border: 1px solid var(--line); border-radius: var(--radius-round); background: var(--ground); color: var(--ink); }
.round:hover { border-color: var(--ink-muted); }
.round.send { background: var(--action); border-color: var(--action); color: var(--action-foreground); }
/* Over the bottom right of the message pane, from a row of no height between the pane and the composer. */
.jump-row { position: relative; z-index: 1; height: 0; margin-top: calc(-1 * var(--gap)); }
.jump { position: absolute; right: 0; bottom: var(--space-2); background: var(--card); box-shadow: var(--shadow-card); }
.jump[hidden] { display: none; }
.views .view .btn.quiet { display: grid; place-items: center; }

/* ---- Close-out (SPEC v8 §32): the day's tiles and lines; one line's payments beside its sign-off ---- */
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.views label { margin: 0 0 0 auto; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
/* A tile: the name small, the number large, at most two quiet lines; a number that needs a look is coloured. */
.stat { gap: var(--space-1); container-type: inline-size; }
.stat h3 { font-size: var(--text-13); font-weight: 600; }
.stat .amount { font-size: var(--text-32); line-height: 1.15; white-space: nowrap; }
@container (max-width: 200px) { .stat .amount { font-size: var(--text-26); } } /* a narrow tile: the number still fits */
@container (max-width: 150px) { .stat .amount { font-size: var(--text-20); } }
.stat .split { font-size: var(--text-13); font-variant-numeric: tabular-nums; }
.stat.warn .amount { color: var(--warn-wash-foreground); }
.stat.bad .amount { color: var(--problem-wash-foreground); }
tr.total td { background: var(--ground); font-weight: 700; }
tr.late td { background: var(--problem-wash); } /* §35: an agent on shift whose location is overdue */
td.struck { text-decoration: line-through; }
td.num { white-space: nowrap; }
.plate-link { display: inline-flex; align-items: center; gap: var(--space-2); color: inherit; text-decoration: none; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); color: var(--ink-muted); }
.closeout { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 4fr); gap: var(--gutter); align-items: start; }
.closeout .sign { display: flex; flex-direction: column; gap: var(--gap); }
.closeout .side-card .head, .closeout .side-card label { margin: 0; }
.closeout form.side-card { gap: var(--gap); }
.closeout input[name="counted"] { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- Shifts (SPEC v8 §35): today on a timeline (SVG, sized by its attributes), the weekly pattern as a table; the
   days and hours below are the Edit dialog's ---- */
.timeline { display: block; max-width: 100%; height: auto; }
.timeline .now { stroke: var(--ink); stroke-width: 2; }
th .timeline { font-weight: 400; }
.days { display: flex; flex-wrap: wrap; gap: var(--space-1); border: 0; padding: 0; margin: 0; }
.days legend { font-weight: 600; font-size: var(--text-14); margin-bottom: var(--space-1); padding: 0; }
.day { position: relative; margin: 0; }
.day input { position: absolute; opacity: 0; width: 100%; height: 100%; inset: 0; cursor: pointer; }
.day span { display: inline-flex; align-items: center; justify-content: center; min-width: var(--size-touch-min); min-height: var(--size-touch-min); padding: 0 var(--space-2); border-radius: var(--radius-chip);
  font-size: var(--text-13); font-weight: 700; background: var(--ground); color: var(--ink-muted); box-shadow: inset 0 0 0 1px var(--field-border); }
.day input:checked + span { background: var(--action-wash); color: var(--action-wash-foreground); box-shadow: inset 0 0 0 1px var(--action-accent); }
.day input:focus-visible + span { outline: 3px solid var(--action-accent); outline-offset: 2px; }
.times { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }
.times label { margin: 0; }

/* ---- Settings ---- */
.settings { max-width: 34rem; }
.settings .sect { margin-bottom: var(--gap); }
.settings label { margin: 0; }
input.code-inline { font-family: var(--mono); }

/* Narrow screens: one column; table rows become stacked blocks, each value named by its column. */
@media (max-width: 900px) {
  :root { --row: var(--size-touch-min); } /* a finger, not a pointer */
  /* The sidebar hides behind the Menu button of a slim top bar and slides over the content. Closed, it is out of
     sight and out of the tab order (visibility); admin.js makes the content inert while it is open. */
  body:has(.sidebar) .top { display: flex; justify-content: flex-start; position: sticky; top: 0; z-index: 1100; max-width: none; padding-top: var(--space-2); padding-bottom: var(--space-2); background: var(--ground); }
  body:has(.sidebar) .menu { display: inline-flex; }
  main:has(> .sidebar) { display: block; }
  .sidebar { position: fixed; z-index: 1500; left: 0; width: min(280px, 85vw); transform: translateX(-100%); visibility: hidden; }
  .sidebar.open { transform: none; visibility: visible; }
  .sidebar.open + .scrim { display: block; position: fixed; z-index: 1400; inset: 0; background: var(--backdrop); }
  .content { padding: var(--space-2) var(--gutter) var(--space-6); }
  .dispatch, .detail, .closeout { grid-template-columns: 1fr; }
  .thread { max-height: 70vh; } /* stacked: still a chat box, with the composer and then the Location card under it */
  .map { height: 55vh; min-height: 300px; }
  .side { max-height: none; min-height: 0; }
}
@media (max-width: 720px) {
  .top { padding-top: var(--space-2); padding-bottom: var(--space-2); }
  main:has(> .sidebar) { padding: 0; }
  .pending { grid-template-columns: 1fr; }
  .pending .actions { justify-content: flex-start; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tr, td { display: block; }
  tr { padding: var(--space-2) var(--pad); border-bottom: 1px solid var(--line); }
  tr:last-child { border-bottom: 0; }
  td { padding: var(--space-1) 0; border: 0; }
  td.right { text-align: left; }
  td[data-label]::before { content: attr(data-label) ": "; color: var(--ink-muted); font-size: var(--text-13); }
  td.bare::before { content: none; }
  td[data-label]:empty { display: none; } /* a stacked row shows no label without a value */
  td.actions-cell { width: auto; white-space: normal; padding-top: var(--space-2); }
  td .actions { flex-wrap: wrap; justify-content: flex-start; }
  .filters label, .filters label.grow { min-width: 0; flex: 1 1 100%; }
  .item, .item.wide, .item.money { max-width: 100%; }
  .detail-top .right { align-items: flex-start; }
}
@media (prefers-reduced-motion: no-preference) {
  dialog[open] { animation: rise 0.14s ease-out; }
  .sidebar { transition: transform 0.16s ease-out, visibility 0.16s; }
  .sidebar.open { transition: transform 0.16s ease-out; } /* visible at once, so the first link can take the focus */
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } }
  .play[data-state="loading"] .icon { animation: spin 0.8s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
}
