/* Admin screens (#/admin...): desktop layout, mouse, drag and drop. Every rule is scoped to the admin screens
   (or the in-page dialog), so the TC22 screens in app.css are unchanged. */

body[data-screen^="admin"] main, body[data-screen="driver-order"] main { max-width: 1280px; margin: 0 auto; padding: 16px 24px 48px; }
body[data-screen^="admin"] .msg, body[data-screen="driver-order"] .msg { max-width: 1280px; margin: 0 auto; }
/* A driver's Load order on a TC22: a little less padding. */
@media (max-width: 600px) { body[data-screen="driver-order"] main { padding: 8px 8px 32px; } }

.admin { position: relative; font-size: 16px; }
.admin-title { font-size: 26px; margin: 4px 0 12px; }
.admin-date { font-size: 18px; font-weight: 400; color: var(--muted); }
.admin-h2 { font-size: 20px; margin: 24px 0 8px; }
.admin-hint { color: var(--muted); margin: 0 0 12px; }
.admin-back { color: var(--text); font-weight: 700; text-decoration: none; }
.admin-back:hover { text-decoration: underline; }
.admin-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.admin-head .admin-back { flex-basis: 100%; }
.admin-head .admin-title { flex: 1 1 auto; margin: 0; }
.admin-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.admin .btn { min-height: 40px; min-width: 40px; padding: 0 14px; font-size: 16px; }
.admin .btn-small { min-height: 30px; min-width: 30px; padding: 0 8px; font-size: 14px; }
.admin :focus-visible { outline: 3px solid #1a5fb4; outline-offset: 2px; }
.btn-danger { background: var(--bad); color: #fff; border-color: var(--bad); }

.admin-banner { background: var(--warn); color: #000; font-weight: 700; padding: 10px 12px; margin: 0 0 12px; }
/* Wrong-PIN alert across the top of every admin screen (GET /api/admin/security). */
.security-banner { background: #b00020; color: #fff; padding: 10px 16px; }
.security-banner[hidden] { display: none; }
.security-banner span { opacity: 0.9; margin-left: 8px; }
.pin-fields[hidden] { display: none; }
.flag-choice { display: flex; flex-direction: column; gap: 6px; }
.flag-choice .field-check input:disabled + * , .flag-choice input:disabled { opacity: 0.6; }
.admin-notice { display: flex; align-items: center; gap: 12px; background: #fff4d6; border: 2px solid var(--warn); padding: 10px 12px; margin-bottom: 12px; }
.admin-notice[hidden] { display: none; }

/* ---------- desktop top menu (body[data-topmenu]: a desktop browser at least 900px wide, on an admin screen) ----------
   Three columns: the six screens (left), Refresh with its status underneath (centred in the bar), then one row on the
   right: ONLINE, unsynced, who's logged in with LIVE/TEST, Settings and Log out. The two .topbar-row boxes (stacked on
   the TC22) dissolve with display: contents and `order` sets that sequence. A TC22, a phone or a narrow window never
   gets data-topmenu. */
body[data-topmenu] .topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px 24px; padding: 6px 20px; }
body[data-topmenu] .topbar-me { justify-self: end; display: flex; align-items: center; gap: 12px; white-space: nowrap; }
body[data-topmenu] .topbar-row { display: contents; }
body[data-topmenu] #btn-switch { order: 5; }
body[data-topmenu] #net { order: 1; }
body[data-topmenu] #unsynced { order: 2; flex: none; font-size: 14px; }
body[data-topmenu] #user-name { order: 3; flex: none; font-size: 14px; margin-left: 28px; }
body[data-topmenu] #env-badge { order: 4; }
body[data-topmenu] #refresh-off-badge { order: 4; } /* just left of LIVE / TEST (DOM order) */
body[data-topmenu] #btn-settings { order: 5; margin-left: 12px; }
body[data-topmenu] #btn-logout { order: 6; }
body[data-topmenu] .topbar-me .btn-small { min-height: 36px; min-width: 36px; padding: 0 12px; font-size: 15px; }
body[data-topmenu] .topbar-me .btn-gear { padding: 0; font-size: 18px; }
/* The top menu replaces the return link ("← Admin" stays on a TC22, a phone or under 900px, where the tile home is). */
body[data-topmenu] .admin-back { display: none; }
.topnav { flex: 1 1 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 2px; min-width: 0; }
.topnav-item { position: relative; display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; color: var(--topbar-fg);
  font-size: 16px; font-weight: 700; text-decoration: none; white-space: nowrap; border-bottom: 3px solid transparent; }
.topnav-item:hover, .topnav-item:focus-visible { background: rgba(255, 255, 255, 0.14); }
.topnav-item:focus-visible { outline: 3px solid var(--topbar-fg); outline-offset: -3px; }
.topnav-item[aria-current="page"] { background: rgba(255, 255, 255, 0.2); border-bottom-color: var(--topbar-fg); }
/* The old tile descriptions: shown on hover and on keyboard focus (aria-describedby, so screen readers read it too). */
.topnav-tip { display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; width: max-content; max-width: 280px;
  padding: 8px 10px; background: #fff; color: #000; border: 2px solid #000; font-size: 14px; font-weight: 400; white-space: normal;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); pointer-events: none; }
.topnav-item:hover .topnav-tip, .topnav-item:focus-visible .topnav-tip { display: block; }
.topbar-refresh { justify-self: center; }
.topbar-refresh.refresh-bar { flex-direction: column; align-items: center; gap: 2px; margin: 0; }
.topbar-refresh #btn-refresh { order: -1; min-height: 34px; padding: 0 14px; font-size: 15px; }
/* The status keeps a fixed room from the start, one line: 180 px (so the right-hand group still fits and Refresh stays
   centred at 1280), 300 px from 1600 px. Longer text ends in "…"; the full text, and the second line ("Showing data
   from 08:00" after a failure), are in its tooltip (refresh-bar.js). So the bar is the same height before and after
   the status arrives: otherwise the middle column widens when the text comes, the menu wraps, and the page jumps. */
.topbar-refresh .refresh-status { align-items: center; text-align: center; width: 180px; max-width: 180px; font-size: 13px; color: var(--topbar-muted); }
.topbar-refresh .refresh-text { display: block; max-width: 100%; min-height: 1lh; font-weight: 400;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-refresh .refresh-sub { display: none; }
@media (min-width: 1600px) {
  .topbar-refresh .refresh-status { width: 300px; max-width: 300px; }
}
.topbar-refresh .refresh-status[data-kind="bad"] .refresh-text { color: #ff9b9b; font-weight: 700; }
.topbar-refresh .refresh-status[data-kind="good"] .refresh-text { color: #8fe0b4; }

/* ---------- admin home ---------- */
.admin-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 20px; }
.admin-tile { display: flex; flex-direction: column; gap: 6px; padding: 24px; border: 3px solid #000; color: var(--text); text-decoration: none; background: #fff; }
.admin-tile:hover { background: #f2f2f2; }
.admin-tile-title { font-size: 22px; font-weight: 700; }
.admin-tile-sub { color: var(--muted); }

/* ---------- status badges (shared) ---------- */
.status-badge { display: inline-block; padding: 2px 8px; font-size: 14px; font-weight: 700; white-space: nowrap; border: 1px solid transparent; }
.status-badge[data-status="Complete"] { background: var(--good); color: #fff; }
.status-badge[data-status="InProgress"],
.status-badge[data-status="CompleteShort"] { background: var(--warn); color: #000; }
.status-badge[data-status="NotStarted"] { background: #e2e2e2; color: #333; }
.status-badge[data-status="NothingToPick"] { background: #fff; color: var(--muted); border-color: var(--line); }

/* ---------- picking status ---------- */
.last-loaded { color: var(--muted); font-size: 14px; }
.summary-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 16px; }
.summary-tile { border: 2px solid #000; padding: 10px 12px; display: flex; flex-direction: column; }
.summary-tile[data-status="Complete"] { border-color: var(--good); }
.summary-tile[data-status="InProgress"], .summary-tile[data-status="CompleteShort"] { border-color: var(--warn); }
.summary-tile[data-status="NotStarted"] { border-color: #999; }
.summary-tile[role="link"] { cursor: pointer; }   /* scrolls to its section; looks the same otherwise */
.summary-value { font-size: 28px; font-weight: 700; }
.summary-label { color: var(--muted); font-size: 14px; }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: 14px; padding: 4px 10px; border: 2px solid #000; background: #fff; cursor: pointer; }
.chip[aria-pressed="true"] { background: #000; color: #fff; }
.admin-search { font: inherit; padding: 6px 10px; border: 2px solid #000; min-width: 280px; }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.admin-table thead th { border-bottom: 2px solid #000; font-size: 14px; white-space: nowrap; }
.admin-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-table .data-row { cursor: pointer; }
.admin-table .data-row:hover { background: #f5f5f5; }
.admin-table .data-row[aria-expanded="true"] { background: #eef3fb; }
.status-cell[data-status="Complete"] { box-shadow: inset 4px 0 var(--good); }
.status-cell[data-status="InProgress"], .status-cell[data-status="CompleteShort"] { box-shadow: inset 4px 0 var(--warn); }
.status-cell[data-status="NotStarted"] { box-shadow: inset 4px 0 #bbb; }
.detail-row > td { background: #fafafa; padding: 8px 8px 12px 24px; }
.lines-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.lines-table th, .lines-table td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
.lines-table .num { text-align: right; }
.lines-table .line-nonpick td { color: var(--muted); }
.lines-table .qty-short { color: var(--bad); font-weight: 700; }
.lines-table .qty-over { color: #9a6700; font-weight: 700; }
.lines-table .qty-done { color: var(--good); font-weight: 700; }
.lines-table .lines-total td { font-weight: 700; border-top: 2px solid #000; border-bottom: 0; }
/* Kits, as on the paper: the kit row bold with a KIT badge, its components indented in italics beneath it. */
.lines-table .line-kit td { font-weight: 700; }
.lines-table .line-comp td { font-style: italic; }
.lines-table .line-comp td:first-child { padding-left: 24px; }
.kit-badge { display: inline-block; background: #000; color: #fff; font-size: 11px; font-weight: 700; font-style: normal; padding: 0 4px; margin-right: 6px; }
/* The order above its lines (all three admin screens): one summary line, then the special instructions in full. */
.order-summary { margin: 0 0 6px; }
.order-summary-line { margin: 0 0 4px; font-weight: 700; display: flex; align-items: center; gap: 12px; }
.order-summary-line .order-summary-text { flex: 1; min-width: 0; }
/* The order's special instructions: right-aligned on the summary line (under the card's ▲ / ▼), opens a modal. */
.btn-instructions {
  margin-left: auto;
  flex: none;
  padding: 3px 10px;
  border: 1px solid var(--accent-orange);
  border-radius: 2px;
  background: #fff;
  color: var(--accent-orange);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.btn-instructions:hover, .btn-instructions:focus-visible { background: var(--accent-orange-light); }
.order-instructions { margin: 0 0 4px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- picking note order ---------- */
.save-state { color: var(--muted); }
.save-state[data-dirty="true"] { color: #9a6700; font-weight: 700; }
.seq-list { display: flex; flex-direction: column; gap: 4px; min-height: 48px; }
.seq-group { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 6px 4px; border-bottom: 2px solid #000; }
.seq-group-name { font-weight: 700; font-size: 18px; }
.seq-group-count { color: var(--muted); font-size: 14px; font-weight: 400; }
.seq-group-actions { margin-left: auto; display: flex; gap: 6px; }
.seq-card {
  display: grid;
  grid-template-columns: 28px 24px 22px 40px 110px 120px minmax(120px, 1fr) 110px 130px 170px auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  background: #fff;
}
.seq-card:hover { border-color: #000; }
.seq-card.dragging, .seq-group.dragging { opacity: 0.4; }
/* A route (or van) heading's grip: only while the heading is fully ticked; its place is kept so nothing shifts. */
.seq-group-grip[hidden] { display: inline; visibility: hidden; }
.seq-group[draggable="true"] .seq-group-grip { cursor: grab; }
/* The drag image for a whole group ("EXE — 12 orders"): drawn off screen for the browser to copy, then removed. */
.group-drag-label { position: fixed; top: -100px; left: -1000px; padding: 6px 12px; background: #000; color: #fff;
  font-weight: 700; font-size: 16px; white-space: nowrap; }
.seq-card-new { background: #fff8e1; border-color: var(--warn); }
.new-tag { display: inline-block; margin-right: 6px; padding: 0 6px; border: 1px solid var(--warn); border-radius: 3px; background: #fff;
  font-size: 12px; font-weight: 700; white-space: nowrap; }
.admin-notice-link { width: 100%; text-align: left; font: inherit; cursor: pointer; text-decoration: underline; }
.assign-new { font-weight: 700; }
.grip { cursor: grab; color: #777; font-size: 18px; user-select: none; }
.seq-pos { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.seq-route { font-weight: 700; }
.seq-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seq-lines { color: var(--muted); font-size: 14px; }
/* An order's lines: the ▸ / ▾ toggle, and the lines inside the card (full width, below its row). */
.seq-toggle, .van-order-toggle { border: 0; background: transparent; cursor: pointer; font-size: 16px; line-height: 1; padding: 2px; min-width: 22px; }
.seq-toggle:hover, .van-order-toggle:hover { background: #eee; }
.seq-pos, .seq-route, .seq-order, .seq-name, .seq-lines, .seq-status { cursor: pointer; }
.seq-card .order-lines { grid-column: 1 / -1; background: #fafafa; padding: 8px 8px 10px 24px; cursor: auto; }
.seq-card.dragging .order-lines { display: none; }   /* a card being dragged shows collapsed */
.expand-all { display: inline-flex; gap: 6px; }
.seq-moves { display: flex; gap: 4px; }
.seq-placeholder { color: var(--muted); border: 2px dashed var(--line); padding: 12px; text-align: center; margin: 0; }
.seq-fresh { margin-top: 24px; padding: 12px; border: 3px solid var(--warn); background: #fffdf5; }
.seq-fresh-title { font-size: 18px; margin: 0 0 4px; }
.drop-line { position: absolute; left: 0; right: 0; height: 4px; background: #1a5fb4; pointer-events: none; z-index: 5; }
.drop-line[hidden] { display: none; }

/* Picking notes: putting orders on vans. */
.seq-tick { width: 22px; height: 22px; margin: 0; cursor: pointer; }
.seq-group .seq-tick { margin-left: 9px; }
/* A driver's Load order has no tick boxes: an empty cell the same size keeps every column where the admin card has it. */
.seq-tick-gap { display: block; width: 22px; height: 22px; }
.seq-group .seq-tick-gap { flex: none; margin-left: 9px; }
/* The Van cell: the van's name, then who is on it (" · Gary, Sam, Priya") on one line; the names truncate. */
.seq-van { display: flex; align-items: center; min-width: 0; white-space: nowrap; }
/* Picking status uses the same class on a table cell: keep it a cell so it lines up with the row. */
td.seq-van { display: table-cell; vertical-align: middle; }
.seq-van-name { flex: none; max-width: 60%; overflow: hidden; text-overflow: ellipsis; }
.seq-van[data-kind="none"] { color: var(--muted); }
.seq-van[data-kind="problem"] .seq-van-name { background: var(--warn); color: #000; padding: 2px 6px; font-weight: 700; }
.seq-crew, .seq-group-crew { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seq-group-name { flex: none; }
.seq-group-crew { font-size: 15px; }
.crew-part[data-kind="missing"] { background: var(--warn); color: #000; padding: 0 4px; font-weight: 700; }
.crew-part[data-kind="none"] { color: var(--muted); }
/* Picking status and Vans use the whole window too (24px each side). */
@media screen {
  body[data-screen="admin-status"] main, body[data-screen="admin-vans"] main { max-width: none; padding-left: 24px; padding-right: 24px; }
  body[data-screen="admin-status"] .msg, body[data-screen="admin-vans"] .msg { max-width: none; }
}
/* Picking notes uses the whole window; from 900px the extra width goes to the delivery name and the Van / crew cell.
   A driver's Load order keeps its 1280px cap but takes the same columns, so its cards line up with the admin's. */
@media screen {
  body[data-screen="admin-notes"] main { max-width: none; padding-left: 24px; padding-right: 24px; }
  body[data-screen="admin-notes"] .msg { max-width: none; }
}
@media screen and (min-width: 900px) {
  body[data-screen="admin-notes"] .seq-card, body[data-screen="driver-order"] .seq-card {
    grid-template-columns: 28px 24px 22px 40px 110px 120px minmax(160px, 2fr) 110px 130px minmax(220px, 3fr) auto;
  }
}
.assign-top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin: 8px 0 0; padding: 10px 12px; background: #fff; border: 2px solid var(--line);
}
.ord-hint { margin: 8px 0 0; }
.assign-loader select, .assign-filter select { margin-left: 6px; min-height: 36px; min-width: 200px; font: inherit; }
.assign-top #asg-apply { min-width: 160px; }
.assign-count { color: var(--muted); }
.assign-right { margin-left: auto; display: inline-flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.group-by { display: inline-flex; align-items: center; gap: 6px; }
.group-by .btn[aria-pressed="true"] { background: #000; color: #fff; }
.grp-note { margin: 8px 0; }
.seq-group-inactive .seq-group-name { background: var(--warn); padding: 0 6px; }
@media print { .assign-top { display: none; } }

/* Picking status and Picking notes: the top section stays under the app's top bar as the page scrolls (its top is
   set by stickUnderTopbar). Wide screens only: on a handset it would take most of the screen. */
@media screen and (min-width: 900px) {
  .admin-sticky {
    position: sticky; top: 0; z-index: 6; background: var(--bg, #fff);
    margin: 0 -24px; padding: 8px 24px 10px; border-bottom: 3px solid #000; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  }
}

/* ---------- users ---------- */
.toggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.users-table .actions-col { text-align: right; white-space: nowrap; }
.users-table .actions-col .btn { margin-left: 6px; }
.users-table .user-inactive td { color: #888; }
.user-form { max-width: 520px; display: grid; gap: 12px; }
.user-form .field { display: grid; gap: 4px; font-weight: 700; border: 0; padding: 0; margin: 0; }
.user-form .field input[type="text"], .user-form .field input[type="password"] { font: inherit; font-weight: 400; padding: 8px 10px; border: 2px solid #000; }
.user-form .field-check { display: flex; align-items: center; gap: 8px; }
.user-form .field-check input { width: 22px; height: 22px; }
.user-form .field-error { color: var(--bad); font-weight: 700; font-size: 14px; min-height: 0; }
.user-form .field-error:empty { display: none; }
.user-form .form-error { margin: 0; }
.user-form select { font: inherit; font-weight: 400; padding: 8px 10px; border: 2px solid #000; background: #fff; }

/* ---------- serial numbers (line views and the Picking status section) ---------- */
.lines-table .line-serials td { padding-top: 0; font-size: 13px; }
.serials-count { font-weight: 700; margin-right: 6px; }
.serials-count.serials-missing { color: #8a5a00; }
.serial-chip { display: inline-block; margin: 2px 4px 2px 0; padding: 2px 6px; border: 1px solid var(--line); }
.serial-chip.serial-missing, .serial-row-missing .serial-missing { background: var(--warn); color: #000; font-weight: 700; }
.serial-chip .btn-tiny { margin-left: 4px; }
.check-filter { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.check-filter input { width: 20px; height: 20px; }
.prompt-label { display: flex; flex-direction: column; gap: 4px; margin: 0 0 16px; font-weight: 700; }
.prompt-label input { font: inherit; font-weight: 400; padding: 8px 10px; border: 2px solid #000; }

/* ---------- in-page dialog (any screen) ---------- */
.dialog-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { background: #fff; max-width: 440px; width: 100%; padding: 20px; border: 3px solid #000; }
.dialog-title { font-size: 20px; margin: 0 0 8px; }
.dialog-text { margin: 0 0 16px; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 10px; }
.dialog .btn { min-height: 44px; padding: 0 16px; }

/* Admin screens don't beep: no "tap to turn on sound" banner, on any device. */
body[data-screen^="admin"] .sound-banner { display: none !important; }

/* ---------- print: just the report ---------- */
@media print {
  body[data-screen^="admin"] .topbar,
  body[data-screen^="admin"] .msg,
  body[data-screen^="admin"] .admin-back,
  body[data-screen^="admin"] .admin-actions,
  body[data-screen^="admin"] .filters,
  body[data-screen^="admin"] .sound-banner { display: none !important; }
  body[data-screen^="admin"] main { max-width: none; padding: 0; }
  .admin { font-size: 11px; }
  .admin-table th, .admin-table td { padding: 2px 4px; }
  .admin-table .data-row[aria-expanded="true"] { background: none; }
  .summary-tile { padding: 4px 6px; }
  .summary-value { font-size: 18px; }
  .status-badge { border: 1px solid #000; }
  tr { break-inside: avoid; }
}

/* Picking status: "Barcodes added in the app" (collapsible). */
.admin-section { margin-top: 24px; }
.admin-section > summary { cursor: pointer; }
.admin-section .count { font-weight: 400; color: var(--muted); }
.admin-note { color: var(--muted); margin: 4px 0 8px; }

/* ---------- Vans (#/admin/vans): one panel per van, its crew and warnings ---------- */
.vans-rota { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.vans-rota a { color: inherit; }
.vans-summary { display: flex; gap: 24px; flex-wrap: wrap; margin: 8px 0 12px; font-weight: 700; }
.vans-summary [data-count]:not([data-count="0"]) { background: var(--warn); padding: 2px 6px; }
.crew-board { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; align-items: start; }
.people-panel {
  position: sticky; top: 8px; border: 3px solid #000; background: #fff; padding: 10px;
  max-height: calc(100vh - 140px); overflow: auto;
}
.people-title { font-size: 18px; margin: 0 0 4px; }
.people-count { color: var(--muted); font-weight: 400; }
.people-list { display: grid; gap: 6px; }
.people-empty { color: var(--muted); margin: 8px 0; }
.people-tip { color: var(--muted); font-size: 13px; margin: 12px 0 0; }
.person-card { display: flex; align-items: center; gap: 6px; border: 2px solid #000; background: #fff; padding: 4px 8px; }
.person-text { display: flex; flex-direction: column; min-width: 0; }
.person-card .person-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Today's vans, small and grey: "Driver RCZ · Crew DYU". */
.person-tags { color: var(--muted); font-size: 12px; }
.person-tags:empty { display: none; }
.person-card, .crew-chip { cursor: grab; }
.person-card.dragging, .crew-chip.dragging { opacity: 0.4; }
.person-card.selected, .crew-chip.selected { outline: 3px solid #1a5fb4; outline-offset: 2px; }
.person-card:focus-visible, .crew-chip:focus-visible { outline: 3px solid #000; outline-offset: 2px; }
/* Drop targets: a van's Driver or Crew box, or the left panel for a chip. The hint shows only while dragging over it. */
.drop-hint { display: none; margin: 6px 0 0; font-weight: 700; color: #1a5fb4; }
.drop-over { outline: 3px dashed #1a5fb4; outline-offset: -3px; background: #eef4fb; }
.drop-over > .drop-hint { display: block; }
/* Under each van's header: a narrow Driver box and a wide Crew box side by side (stacked on a narrow screen). */
.van-boxes { display: grid; grid-template-columns: minmax(180px, 1fr) minmax(0, 3fr); gap: 8px; margin: 8px 0 0; }
.van-box { border: 3px solid #000; padding: 6px 8px; min-height: 44px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.van-box-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.van-box-body { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.van-driver-box .crew-none { font-weight: 700; color: #000; }
.van-box .drop-hint { flex-basis: 100%; margin: 0; }
.van-add { margin-left: auto; }
@media (max-width: 699px) { .van-boxes { grid-template-columns: minmax(0, 1fr); } }
.van-spinner { display: none; width: 16px; height: 16px; border: 3px solid #ccc; border-top-color: #000; border-radius: 50%; animation: van-spin 0.8s linear infinite; }
.van-saving .van-spinner { display: inline-block; }
@keyframes van-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .van-spinner { animation: none; } }
@media (max-width: 899px) {
  .crew-board { grid-template-columns: minmax(0, 1fr); }
  .people-panel { position: static; max-height: none; }
}
.van-panels { display: grid; gap: 12px; }
.van-panel { border: 2px solid #000; background: #fff; padding: 10px 12px; }
.van-panel.van-inactive { border-style: dashed; }
.van-panel.van-complete { border-color: var(--good, #1b7f3b); }
.van-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.van-name { font-size: 20px; margin: 0; }
.van-inactive .van-title { background: var(--warn); padding: 0 6px; }
.van-reg { font-weight: 400; color: var(--muted); font-size: 16px; }
.van-progress { color: var(--muted); }
.van-routes { margin-left: auto; font-weight: 700; }
.crew-none { color: var(--muted); }
.rota-hint { color: var(--muted); font-size: 12px; margin: 2px 0 0; }
.rota-hint[hidden] { display: none; }
.crew-chip { display: inline-flex; align-items: center; gap: 6px; border: 2px solid #000; padding: 2px 4px 2px 8px; }
.crew-driver { background: #f0f0f0; }
.crew-problem { background: var(--warn); }
.crew-badge { background: var(--warn); color: #000; font-size: 12px; font-weight: 700; padding: 1px 6px; text-transform: uppercase; }
.crew-remove { border: 0; background: transparent; font-size: 20px; line-height: 1; cursor: pointer; min-width: 28px; min-height: 28px; }
.crew-remove:hover { background: #000; color: #fff; }
.van-warnings { list-style: none; padding: 0; margin: 8px 0 0; display: flex; gap: 8px; flex-wrap: wrap; }
.van-warnings li { background: var(--warn); padding: 2px 8px; font-weight: 700; }
.van-warnings li.van-note, .crew-warning.van-note { background: none; color: var(--muted); font-weight: 400; padding: 2px 0; }
.crew-warning { background: var(--warn); padding: 0 6px; font-weight: 700; white-space: nowrap; }
.van-warnings:empty { display: none; }
.van-orders { margin-top: 8px; }
.van-orders summary { cursor: pointer; font-weight: 700; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.van-order-row { cursor: pointer; }
.van-order-row:hover { background: #f5f5f5; }
.van-order-lines { color: var(--muted); font-size: 14px; white-space: nowrap; }
.van-order-table .detail-row:hover { background: none; }
.copy-report { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; }
.copy-report-title { font-weight: 700; margin: 0; }
.copy-skipped { margin: 4px 0 0; padding-left: 20px; }
.vans-dialog { max-width: 760px; }
.vans-table input[type="text"], .vans-table input[type="number"] { font: inherit; padding: 4px 6px; border: 2px solid #000; width: 100%; box-sizing: border-box; }
.vans-table input[type="number"] { width: 80px; }
.vans-table input[type="checkbox"] { width: 22px; height: 22px; }
/* Picking status: the van table and "Orders with no van". */
.st-no-van { font-weight: 700; margin: 4px 0 8px; }
.st-no-van[data-count]:not([data-count="0"]) { display: inline-block; background: var(--warn); padding: 2px 8px; }
.st-vans { margin-bottom: 8px; }
.van-inactive-cell { background: var(--warn); font-weight: 700; }

/* ---------- claims and confirmed shorts in the lines tables ---------- */
.lines-table .qty-progress { color: #9a6700; font-weight: 700; }
.lines-table .short-confirmed { font-size: 12px; color: #9a6700; font-weight: 700; white-space: nowrap; }
/* Batch Pick "Not picked: …": a badge per reason (No Stock amber, Collection blue, Delayed Dispatch grey). */
.not-picked-badge { display: inline-block; margin-top: 2px; padding: 1px 6px; border-radius: 3px; font-size: 12px; font-weight: 700;
  white-space: nowrap; background: var(--warn); color: #000; }
.not-picked-badge[data-reason="Collection"] { background: #1f5fbf; color: #fff; }
.not-picked-badge[data-reason="DelayedDispatch"] { background: #6b6b6b; color: #fff; }
.lines-table .claim-cell { white-space: nowrap; }
.lines-table .claimed-by { font-size: 13px; }
.claims-bar { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.claims-bar .release-note { font-size: 13px; color: var(--good); font-weight: 700; }
.claims-bar .release-note.bad { color: var(--bad); }
.btn.btn-tiny { min-height: 28px; min-width: 0; padding: 2px 10px; font-size: 13px; }
@media print { .release-claim, .claims-bar { display: none !important; } }

/* ---------- exceptions ---------- */
.ex-tabs { display: flex; gap: 6px; margin: 4px 0 10px; }
.ex-tabs .chip { font-size: 16px; padding: 6px 14px; }
.ex-table .ex-kit { color: var(--muted); font-size: 13px; }
.ex-table .ex-subtotal td { font-weight: 700; border-bottom: 2px solid #000; background: #f6f6f6; }
@media print { .ex-tabs .chip[aria-pressed="false"] { display: none; } }

/* ---------- Rota (#/admin/rota): five day columns like the spreadsheet; stacked under 1100px ----------
   The full window width (16px each side), not the 1280px admin width. Everything in a column may shrink (min-width: 0)
   so nothing pushes a card out of its day; if five columns can't fit at 200px each, the week scrolls sideways. */
@media screen {
  body[data-screen="admin-rota"] main { max-width: none; padding-left: 16px; padding-right: 16px; }
  body[data-screen="admin-rota"] .msg { max-width: none; }
}
.rota-weeknav { display: flex; flex-wrap: wrap; gap: 6px; }
.rota-past { background: #e2e2e2; color: #333; font-weight: 700; padding: 8px 12px; margin: 8px 0 12px; }
.rota-past[hidden] { display: none; }
.rota-grid { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 12px; align-items: start; overflow-x: auto; }
@media (max-width: 1099px) { .rota-grid { grid-template-columns: minmax(0, 1fr); overflow-x: visible; } }
.rota-day { border: 2px solid #000; background: #fff; padding: 8px; min-height: 120px; min-width: 0; box-sizing: border-box; }
.rota-day-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin-bottom: 6px; }
.rota-day-name { font-size: 16px; margin: 0; flex-basis: 100%; }
.rota-loaded, .rota-count { color: var(--muted); font-size: 13px; }
.rota-day-warn { background: var(--warn); font-size: 13px; font-weight: 700; padding: 0 6px; }
.rota-day-warn[hidden] { display: none; }
.rota-slots { display: grid; gap: 6px; min-height: 24px; }
.rota-empty { color: var(--muted); border: 2px dashed var(--line); padding: 8px; text-align: center; margin: 0; font-size: 14px; }
.rota-card { border: 1px solid var(--line); background: #fff; padding: 6px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; min-width: 0; box-sizing: border-box; }
.rota-card:hover { border-color: #000; }
.rota-card.dragging { opacity: 0.4; }
.rota-card-warn { border-left: 6px solid var(--warn); }
.rota-card-top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
.rota-card-top .btn { flex-shrink: 0; }
.rota-pos { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 18px; text-align: right; }
.rota-label { font-weight: 700; font-size: 15px; line-height: 1.25; min-width: 0; overflow-wrap: anywhere; }
.rota-agency[hidden] { display: none; }
.rota-remove { margin-left: auto; }
.rota-drop-hint { position: absolute; z-index: 5; pointer-events: none; background: #1a5fb4; color: #fff; font-size: 13px; font-weight: 700; padding: 2px 6px; }
.rota-drop-hint[hidden] { display: none; }
/* One grid for the card's fields: labels in the first column (as wide as the widest), drop-downs take the rest. */
.rota-fields { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 4px; min-width: 0; }
.rota-field { display: contents; font-size: 13px; color: var(--muted); }
.rota-field select { font: inherit; font-size: 14px; color: var(--text); padding: 3px 4px; border: 2px solid #000; background: #fff;
  box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rota-field select:disabled { border-color: var(--line); background: #f6f6f6; color: var(--text); }
.rota-reverse { grid-column: 2; font-size: 13px; display: flex; align-items: center; gap: 4px; }
.rota-reverse[hidden] { display: none; }
.rota-reverse input { width: 18px; height: 18px; }
.rota-warnings { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.rota-warnings li { background: var(--warn); font-size: 12px; font-weight: 700; padding: 1px 6px; }
.rota-warnings:empty { display: none; }
.rota-applied { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.rota-applied[hidden] { display: none; }
.rota-add { margin-top: 6px; }
.rota-add[hidden] { display: none; }
.rota-notes { margin-top: 16px; display: grid; gap: 4px; }
.rota-notes label { font-weight: 700; }
.rota-notes textarea { font: inherit; padding: 6px 8px; border: 2px solid #000; resize: vertical; }
.routes-dialog { max-width: 900px; }
.routes-scroll { max-height: 60vh; overflow: auto; }
.routes-table input[type="text"] { min-width: 180px; }
.routes-table tr.route-inactive input[type="text"] { background: #fff4d6; }
/* The print-only sheet: one landscape A4 page, five columns, then the notes. */
.rota-sheet { display: none; }
@page rota { size: A4 landscape; margin: 10mm; }
@media print {
  body[data-screen="admin-rota"] .admin-rota { display: none !important; }
  body[data-screen="admin-rota"] .rota-sheet { display: block; page: rota; font-size: 11px; }
  .rota-sheet h1 { font-size: 16px; margin: 0 0 6px; }
  .rota-sheet table { width: 100%; border-collapse: collapse; table-layout: fixed; }
  .rota-sheet th, .rota-sheet td { border: 1px solid #000; padding: 4px; vertical-align: top; text-align: left; }
  .rota-sheet th { background: #e8e8e8; }
  .rota-sheet td strong { display: block; margin-top: 2px; }
  .rota-sheet-notes { white-space: pre-wrap; margin-top: 8px; }
}

/* Vans: the "Agency driver" tick on a van's header, and the agency driver shown as its driver. */
.van-agency { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 15px; cursor: pointer; }
.van-agency input { width: 20px; height: 20px; }
.crew-agency { display: inline-flex; align-items: center; gap: 6px; border: 2px solid #000; padding: 2px 8px; }

/* Users: roles as chips (Admin · WH · Batch Pick) and the roles tick boxes. */
.role-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.role-chip { display: inline-block; padding: 2px 8px; border: 1px solid #000; font-size: 13px; font-weight: 700; white-space: nowrap; }
.role-chip-Admin { background: #000; color: #fff; }
.role-choice { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Carried orders and Remove from list ---------- */
/* "From Wed 25 Nov": a picking note imported on an earlier day, still outstanding (grey, like the other small tags). */
.from-tag { display: inline-block; margin-right: 6px; padding: 0 6px; border: 1px solid #bbb; border-radius: 3px; background: #f2f2f2;
  color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.admin-count { font-size: 18px; font-weight: 400; color: var(--muted); }
.btn-danger-outline { color: var(--bad); border-color: var(--bad); }
.btn-danger-outline:disabled { color: var(--muted); border-color: #bbb; }
.remove-dialog { max-width: 520px; }
.remove-orders { margin: 0 0 12px; padding-left: 20px; }
.remove-warning { margin: 0 0 8px; padding: 6px 10px; background: #fff4d6; border-left: 4px solid var(--warn); font-weight: 700; }
.remove-reasons { border: 0; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.remove-reasons legend { font-weight: 700; margin-bottom: 4px; }
.remove-note-label { display: flex; flex-direction: column; gap: 4px; margin: 0 0 16px; font-weight: 700; }
.remove-note-label textarea { font: inherit; font-weight: 400; padding: 8px 10px; border: 2px solid #000; resize: vertical; }
/* Picking status: removed orders (collapsed) */
.st-removed { margin-top: 24px; }
.st-removed summary { font-weight: 700; font-size: 18px; cursor: pointer; padding: 6px 0; }
.st-removed .admin-table { margin-top: 8px; }

/* ---------- Buckets (#/admin/buckets) ---------- */
.buckets-table .actions-col { text-align: right; white-space: nowrap; }
.buckets-table .actions-col .btn { margin-left: 6px; }
.buckets-table .bucket-inactive td { color: #888; }
.bucket-barcode { font-family: ui-monospace, Consolas, monospace; }
.bucket-flag { display: inline-block; padding: 0 6px; background: var(--warn); color: #000; font-weight: 700; font-family: inherit; }
.bucket-detail-h { font-size: 15px; margin: 8px 0 4px; }
.bucket-form { min-width: min(420px, 90vw); }
.bucket-chips { margin: 4px 0 8px; }
.lines-table .bucket-cell { white-space: nowrap; }
.from-bucket { display: inline-block; margin-top: 2px; padding: 0 6px; background: #ffe680; font-size: 13px; font-weight: 700; white-space: nowrap; }
