:root {
  --bg: hsl(210 20% 96%);
  --fg: hsl(215 28% 17%);
  --card: hsl(0 0% 100%);
  --card-border: hsl(214 14% 89%);
  --muted-fg: hsl(215 10% 42%);
  --primary: hsl(174 84% 30%);
  --primary-hover: hsl(174 84% 25%);
  --primary-fg: #ffffff;
  --sidebar: hsl(215 28% 17%);
  --sidebar-2: hsl(215 28% 14%);
  --sidebar-fg: hsl(210 20% 96%);
  --sidebar-muted: hsl(210 14% 65%);
  --sidebar-active: hsl(174 84% 32%);
  --danger: hsl(0 72% 46%);
  --danger-bg: hsl(0 80% 96%);
  --ok: hsl(152 60% 32%);
  --ok-bg: hsl(152 55% 94%);
  --warn: hsl(38 92% 40%);
  --warn-bg: hsl(45 90% 94%);
  --ring: hsl(174 84% 32%);
  --radius: 12px;
  --radius-sm: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--fg); font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-fg);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  padding: 22px 20px 16px; font-weight: 800; font-size: 19px; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--sidebar-2);
}
.sidebar .brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--sidebar-active); box-shadow: 0 0 0 4px hsl(174 84% 32% / .2); }
.sidebar nav { padding: 12px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.sidebar .navlabel { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-muted); padding: 14px 12px 6px; font-weight: 700; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px; min-height: 46px; padding: 8px 14px;
  border-radius: var(--radius-sm); color: var(--sidebar-fg); text-decoration: none; font-weight: 500; font-size: 15px;
}
.sidebar nav a .ic { width: 20px; text-align: center; opacity: .9; font-size: 17px; }
.sidebar nav a:hover { background: var(--sidebar-2); }
.sidebar nav a.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.sidebar .userbox { padding: 14px 16px; border-top: 1px solid var(--sidebar-2); font-size: 14px; color: var(--sidebar-muted); }
.sidebar .userbox .uname { color: var(--sidebar-fg); font-weight: 600; display: block; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--card-border);
  padding: 16px 28px; display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
.topbar form { margin-left: auto; }
main { padding: 26px 28px 60px; width: 100%; }

/* ---------- mobile / tablet ---------- */
.menu-toggle { display: none; }
.sidebar-close { display: none; }
.sidebar-backdrop { display: none; }
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -260px; z-index: 40; transition: left .2s; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  #nav-toggle:checked ~ .layout .sidebar { left: 0; }
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: var(--radius-sm); background: var(--card); border: 1px solid var(--card-border); font-size: 22px; cursor: pointer; }
  main { padding: 18px 16px 60px; }
  .topbar { padding: 12px 16px; }
  /* Close controls for the mobile menu (02/09/2026) — previously there was no scrim and no X,
     and the open sidebar sat on top of its own hamburger toggle, so there was no visible way
     out except navigating away or the browser back button. */
  .sidebar-close {
    display: inline-flex; align-items: center; justify-content: center; margin-left: auto;
    width: 32px; height: 32px; min-height: 32px; min-width: 32px; border-radius: 50%;
    background: var(--sidebar-2); color: var(--sidebar-fg); font-size: 20px; line-height: 1;
    cursor: pointer; flex-shrink: 0;
  }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 39; background: transparent; cursor: pointer; }
  #nav-toggle:checked ~ .layout .sidebar-backdrop { display: block; background: rgba(15,23,32,.45); }
}

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 22px; margin-bottom: 20px; box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.card h2 { font-size: 17px; margin: 0 0 16px; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 24px; margin: 4px 0 18px; font-weight: 800; letter-spacing: -0.02em; }
.muted { color: var(--muted-fg); font-size: 14px; }
.section-intro { color: var(--muted-fg); margin: -8px 0 20px; max-width: 70ch; }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; margin: 14px 0 5px; font-size: 14px; }
input, select, textarea {
  width: 100%; font-size: 16px; padding: 11px 13px; min-height: 46px;
  border: 1.5px solid var(--card-border); border-radius: var(--radius-sm); background: #fff; color: var(--fg);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus, button:focus, a:focus-visible {
  outline: 3px solid hsl(174 84% 32% / .35); outline-offset: 1px; border-color: var(--primary);
}
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; min-width: 46px; padding: 10px 20px; font-size: 15px; font-weight: 600;
  border-radius: var(--radius-sm); border: 1.5px solid var(--primary); background: var(--primary);
  color: var(--primary-fg); cursor: pointer; text-decoration: none; margin-top: 14px; transition: background .12s;
}
button:hover, .btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
button.secondary, .btn.secondary { background: #fff; color: var(--primary); }
button.secondary:hover, .btn.secondary:hover { background: hsl(174 60% 96%); }
button.ghost { background: transparent; color: var(--fg); border-color: var(--card-border); }
button.ghost:hover { background: var(--bg); }
button.small { min-height: 38px; padding: 6px 14px; font-size: 14px; margin-top: 0; }
button.danger { background: var(--danger); border-color: var(--danger); }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: end; }
form.inline { display: inline; margin: 0; }
fieldset { border: 1.5px solid var(--card-border); border-radius: var(--radius-sm); padding: 10px 14px; margin: 12px 0 0; }
fieldset legend { font-weight: 600; font-size: 14px; padding: 0 6px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 22px; height: 22px; min-height: 22px; }
.check label { margin: 0; }
/* v451: an alert row -- a full-width tap target with its explanation UNDER the label, never
   beside it. .check cannot do this: at touch widths its label is inline-flex, which turns a
   <br> into a second column and leaves the note reading as a separate stray sentence. */
.alert-row { display: flex; align-items: flex-start; gap: 12px; padding: 11px 0; min-height: 44px; border-top: 1px solid var(--card-border); }
.alert-row:first-of-type { border-top: 0; }
.alert-row input[type=checkbox] { width: 24px; height: 24px; min-height: 24px; flex: none; margin: 2px 0 0; }
.alert-row label { display: block; margin: 0; line-height: 1.45; cursor: pointer; font-weight: 500; }
.alert-row .alert-note { display: block; color: var(--muted-fg); font-size: 13px; font-weight: 400; margin-top: 3px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--card-border); vertical-align: top; }
th { background: var(--bg); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-fg); font-weight: 700; }
tr:last-child td { border-bottom: none; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 3px 11px; border-radius: 999px; font-weight: 600; font-size: 13px; white-space: nowrap; }
/* v393: a badge inside a form-row cell wraps instead of pushing the page wider (the new tablet rail leaves the page a little narrower) */
.form-row > div > .badge { white-space: normal; border-radius: 12px; line-height: 1.35; }
/* v372: a badge used as a full-width notice (display:block) must wrap, or one long warning widens the whole page on a tablet */
.badge[style*="display:block"] { white-space: normal; border-radius: 10px; line-height: 1.45; font-weight: 500; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--danger-bg); color: var(--danger); }
.badge.open { background: var(--warn-bg); color: var(--warn); }
.badge.neutral { background: var(--bg); color: var(--muted-fg); }
.badge.teal { background: hsl(174 60% 94%); color: var(--primary); }

/* ---------- stats ---------- */
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.stat { text-align: left; }
.stat .num { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.stat .lbl { color: var(--muted-fg); font-size: 14px; margin-top: 4px; }
.stat.bad .num { color: var(--danger); }
.stat.ok .num { color: var(--ok); }

/* ---------- flash ---------- */
.flash { background: hsl(174 60% 95%); border: 1.5px solid var(--primary); color: hsl(174 84% 18%); padding: 13px 16px; border-radius: var(--radius-sm); font-weight: 600; margin-bottom: 18px; }
/* v394: a warning box (amber), for things that need attention rather than good news, e.g. a rejected delivery */
.callout-warn { background: var(--warn-bg); border: 1.5px solid var(--warn); color: hsl(32 90% 22%); padding: 13px 16px; border-radius: var(--radius-sm); font-weight: 600; line-height: 1.5; }
.callout-warn .btn { margin-left: 4px; vertical-align: middle; }

.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.trace-arrow { color: var(--primary); font-weight: 800; margin: 0 6px; }

/* ---------- SALSA document rendering ---------- */
.doclink { font-weight:600; text-decoration:none; border-bottom:1px dotted var(--primary); }
.token-unset { background:var(--warn-bg); color:var(--warn); padding:1px 6px; border-radius:4px; font-size:.9em; }
.doc-body { line-height:1.65; }
.doc-body h1 { font-size:24px; margin:6px 0 14px; }
.doc-body h2 { font-size:19px; margin:24px 0 10px; padding-bottom:6px; border-bottom:2px solid var(--card-border); background:none; }
.doc-body h3 { font-size:16px; margin:18px 0 8px; }
.doc-body table { margin:12px 0; font-size:14px; }
.doc-body th, .doc-body td { border:1px solid var(--card-border); }
.doc-body code { background:var(--bg); padding:2px 6px; border-radius:4px; font-size:.9em; }
.doc-body ul, .doc-body ol { padding-left:22px; }
.doc-body li { margin:4px 0; }
.doc-body blockquote { border-left:4px solid var(--primary); margin:12px 0; padding:4px 16px; color:var(--muted-fg); }
.badge.good { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
td.num, th.num { text-align: right; }
/* ---------- consistent page headers ---------- */
.page-head { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:12px; margin-bottom:14px; }
.page-head h1 { margin:0; }
.page-head .section-intro { margin:2px 0 0; }
.page-actions { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
/* ---------- collapsible sidebar nav ---------- */
.mainnav a.toplink { display:flex; align-items:center; gap:11px; min-height:46px; padding:8px 14px; border-radius:var(--radius-sm); color:var(--sidebar-fg); text-decoration:none; font-weight:600; font-size:15px; }
.mainnav a.toplink:hover { background:var(--sidebar-2); }
.mainnav a.toplink.active { background:var(--sidebar-active); color:#fff; }
.mainnav details { margin-top:2px; }
.mainnav details > summary { list-style:none; cursor:pointer; display:flex; align-items:center; gap:11px; min-height:46px; padding:8px 14px; border-radius:var(--radius-sm); color:var(--sidebar-fg); font-weight:600; font-size:15px; user-select:none; }
.mainnav details > summary::-webkit-details-marker { display:none; }
.mainnav details > summary::after { content:"›"; margin-left:auto; transform:rotate(0deg); transition:transform .15s; opacity:.6; font-size:18px; }
.mainnav details[open] > summary::after { transform:rotate(90deg); }
.mainnav details > summary:hover { background:var(--sidebar-2); }
.mainnav details[open] > summary { color:#fff; }
.mainnav .subnav { display:flex; flex-direction:column; gap:2px; margin:2px 0 6px 10px; padding-left:8px; border-left:1px solid var(--sidebar-2); }
.mainnav .subnav a { display:flex; align-items:center; gap:10px; min-height:44px; padding:7px 12px; border-radius:var(--radius-sm); color:var(--sidebar-muted); text-decoration:none; font-weight:500; font-size:14px; }
.mainnav .subnav a .ic { width:18px; text-align:center; }
.mainnav .subnav a:hover { background:var(--sidebar-2); color:var(--sidebar-fg); }
.mainnav .subnav a.active { background:var(--sidebar-active); color:#fff; font-weight:600; }
.manage-block { border:1px solid var(--card-border); border-radius:var(--radius); margin-bottom:18px; background:var(--card); }
.manage-block > summary { list-style:none; cursor:pointer; padding:14px 18px; font-weight:700; color:var(--muted-fg); min-height:48px; display:flex; align-items:center; gap:8px; }
.manage-block > summary::-webkit-details-marker { display:none; }
.manage-block > summary::after { content:"\203A"; margin-left:auto; font-size:20px; opacity:.5; transition:transform .15s; }
.manage-block[open] > summary::after { transform:rotate(90deg); }
.manage-block > div { padding:0 18px 8px; }


/* v146 polish */
.ti.ic { font-size: 16px; width: 20px; display: inline-block; text-align: center; vertical-align: -2px; }
.sidebar summary .ti.ic { font-size: 17px; }
@media (pointer: coarse) {
  table td, table th { padding: 12px 10px; }
  .btn.small, button.small { min-height: 44px; } /* Line Check A5 (07/09/2026): was 40px, below the 44px touch-target floor used everywhere else in this block */
  a.btn, button { min-height: 44px; }
  select.small { min-height: 44px; } /* Line Check A8 (07/09/2026): equipment/chemicals condition dropdowns hard-coded 38px inline, bypassing A5 above */
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; }
}
.select-filter { margin-bottom: 4px; width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1.5px solid var(--card-border); border-radius: var(--radius-sm); font-size: 14px; }

/* ---------- sticky first column (Line Check A6, 07/09/2026) ---------- */
/* Keeps the Date column in view while a wide table (e.g. temps.ejs, 12 columns) scrolls
   sideways inside .table-wrap on a phone/portrait tablet, so a scrolled row is still readable. */
#temps-table .sticky-col { position: sticky; left: 0; background: var(--card); z-index: 1; }
#temps-table th.sticky-col { background: var(--bg); z-index: 2; }

/* ---------- clickable table rows (02/09/2026) ---------- */
/* A <tr data-href="..."> is tap-to-open anywhere in the row — see footer.ejs for the handler.
   Fixes the My-actions "Open" button being unreachable without a sideways scroll on a phone. */
tr[data-href] { cursor: pointer; }
tr[data-href]:hover { background: var(--bg); }

/* ---------- Ask assistant pop-up (02/09/2026) ---------- */
.ask-fab { position: fixed; right: 16px; bottom: 16px; z-index: 900; background: var(--primary); color: #fff; border: none; font-weight: 700; padding: 12px 18px; border-radius: 999px; box-shadow: 0 4px 14px rgba(0,0,0,.25); font-size: 15px; cursor: pointer; }
.ask-fab:hover { background: var(--primary-hover); }
.ask-modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,32,.55); z-index: 950; display: none; align-items: flex-end; justify-content: center; }
.ask-modal-backdrop.open { display: flex; }
.ask-modal { background: var(--card); width: 100%; max-width: 480px; max-height: 82vh; border-radius: var(--radius) var(--radius) 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.3); display: flex; flex-direction: column; overflow: hidden; }
@media (min-width: 640px) {
  .ask-modal-backdrop { align-items: center; padding: 20px; }
  .ask-modal { border-radius: var(--radius); max-height: 80vh; }
}
.ask-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--card-border); flex: none; }
.ask-modal-head strong { font-size: 16px; }
.ask-modal-close { background: transparent; border: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted-fg); min-height: 36px; min-width: 36px; padding: 0; margin: 0; }

/* ---------- Cleaning "due today" nudge (Line Check C3, 07/09/2026) ---------- */
/* Opposite corner to .ask-fab so the two floating buttons never overlap. */
.clean-nudge-fab { position: fixed; left: 16px; bottom: 16px; z-index: 900; background: #1f6f4a; color: #fff; border: none; font-weight: 700; padding: 12px 18px; border-radius: 999px; box-shadow: 0 4px 14px rgba(0,0,0,.25); font-size: 15px; cursor: pointer; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clean-nudge-fab:hover { background: #17573a; }
.clean-nudge-panel { position: fixed; left: 16px; bottom: 72px; z-index: 900; background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); box-shadow: 0 8px 30px rgba(0,0,0,.25); width: min(360px, calc(100vw - 32px)); max-height: 60vh; overflow-y: auto; display: none; }
.clean-nudge-panel.open { display: block; }
.clean-nudge-panel-head { padding: 12px 14px; border-bottom: 1px solid var(--card-border); font-weight: 700; position: sticky; top: 0; background: var(--card); }
.clean-nudge-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--card-border); min-height: 44px; }
.clean-nudge-row:last-child { border-bottom: none; }
.clean-nudge-empty { padding: 16px 14px; color: var(--muted-fg); }
/* v435: the quick list answers Pass or Fail, exactly as the round does, with room for a gloved
   hand and a line to say what is wrong. The row wraps on a phone rather than squeezing. */
.clean-nudge-row { flex-wrap: wrap; }
.clean-nudge-acts { display: flex; gap: 8px; flex: 0 0 auto; }
.clean-nudge-acts .btn { min-height: 44px; min-width: 64px; }
.clean-nudge-why { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; width: 100%; margin-top: 8px; }
/* display:flex above beats the browser's own [hidden] rule, so say it again here or every row
   opens its "what is wrong?" box at once */
.clean-nudge-why[hidden], .clean-nudge-acts[hidden] { display: none; }
.clean-nudge-why label { font-size: 12px; color: var(--muted-fg); width: 100%; margin: 0; }
.clean-nudge-why input { flex: 1 1 150px; min-height: 44px; margin: 0; }
.clean-nudge-why .btn { min-height: 44px; }
.clean-nudge-err { color: #B3402E; font-size: 12px; width: 100%; }
.clean-nudge-close { position: absolute; top: 6px; right: 10px; width: 44px; height: 44px; line-height: 1;
  font-size: 22px; border: none; border-radius: 10px; background: transparent;
  color: var(--muted-fg); cursor: pointer; }
.clean-nudge-close:hover { background: var(--card-border); color: var(--fg); }
.clean-nudge-panel-head { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding-right: 60px; }
.ask-modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.ask-modal-foot { padding: 12px 18px 16px; border-top: 1px solid var(--card-border); flex: none; }
.ask-modal-foot textarea { min-height: 46px; }
.ask-modal-foot button { width: 100%; }
.ask-answer { background: var(--bg); border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 8px; white-space: pre-wrap; font-size: 15px; line-height: 1.55; }
.ask-question-echo { font-weight: 600; margin-top: 16px; }
.ask-question-echo:first-child { margin-top: 0; }
.ask-loading { color: var(--muted-fg); font-size: 14px; margin-top: 8px; }

/* ---------- Print / Save-as-PDF for controlled documents (07/09/2026) ---------- */
/* .print-only: the inverse of .no-print -- hidden on screen, shown only in the printed/PDF
   output. 21/09/2026, Daniel: on the mock-recall export, the Doc Reference box was too narrow
   for the (now often longer, auto-linked) text -- an <input>/<textarea> value can be clipped or
   cut off mid-print since form controls don't reliably print their full content past the visible
   box. Fix is the standard pattern: keep the editable control on screen (hidden in print via
   .no-print), and print a plain wrapping block with the same text instead, so the PDF always
   shows everything regardless of box size. */
.print-only { display: none; }
@media print {
  .sidebar, .sidebar-backdrop, .topbar, .no-print, .flash, .sitebanner, .ask-fab, .clean-nudge-fab, .clean-nudge-panel { display: none !important; }
  .print-only { display: block !important; }
  body, .content { margin: 0 !important; padding: 0 !important; background: #fff !important; }
  main { padding: 0 !important; max-width: none !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; break-inside: avoid; page-break-inside: avoid; }
  .doc-body { break-inside: auto; page-break-inside: auto; }
  .doc-body table, .doc-body tr { break-inside: avoid; page-break-inside: avoid; }
  a.doclink { color: #000 !important; text-decoration: underline; }
  a[href]:after { content: none !important; }
}

/* v353: live list search (partials/livefilter.ejs + footer.ejs) */
.livefilter{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:6px 0 8px}
.livefilter input[type=search]{flex:1 1 220px;max-width:360px;min-height:44px;font-size:1rem;padding:8px 12px;border:1px solid #cfd6d2;border-radius:8px;background:#fff}
.livefilter input[type=search]:focus{outline:2px solid #1a7f4b;outline-offset:1px}
.livefilter .lf-count{white-space:nowrap}

/* v372: internal recipe/product numbers, admin-only (idTag helper) */
.idtag{display:inline-block;margin-left:6px;padding:1px 7px;border-radius:6px;background:#eef3f2;color:#4f6670;font-size:.72rem;font-weight:600;letter-spacing:.01em;white-space:nowrap;vertical-align:middle}

/* v385 (Daniel, 08/10/2026: the Recent dispatch notes list was hard to read on a phone). A table marked class="stack-sm" turns each row
   into its own small card on a phone, with the column name beside each value (the cell's data-label). On a tablet or laptop nothing changes. */
@media (max-width: 640px) {
  table.stack-sm, table.stack-sm tbody { display: block; width: 100%; }
  table.stack-sm tr.stack-head { display: none; }
  table.stack-sm tr { display: block; border: 1px solid var(--card-border); border-radius: var(--radius-sm); margin: 0 0 10px; padding: 6px 12px; background: var(--card); }
  table.stack-sm td { display: flex; justify-content: space-between; align-items: center; gap: 14px; border: 0; padding: 7px 0; min-height: 44px; text-align: right; }
  table.stack-sm td::before { content: attr(data-label); flex: 0 0 34%; text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-fg); }
  table.stack-sm td:not([data-label])::before { display: none; }
  table.stack-sm td + td { border-top: 1px solid var(--card-border); }
}

/* v395: Goods in "Recent receipts": six columns, two lines per cell, so it fits a laptop window with real batch codes and names */
.gi-table { width: 100%; table-layout: fixed; border-collapse: collapse; }
.gi-table th, .gi-table td { vertical-align: top; overflow-wrap: anywhere; word-break: normal; padding: 10px 10px; text-align: left; }
.gi-table th { overflow-wrap: normal; hyphens: none; }
.gi-table .gi-c-ref { width: 20%; } .gi-table .gi-c-ing { width: 24%; } .gi-table .gi-c-sup { width: 21%; }
.gi-table .gi-c-qty { width: 9%; } .gi-table .gi-c-tmp { width: 10%; } .gi-table .gi-c-by { width: 16%; }
.gi-table .gi-code { display: block; margin-top: 2px; font-size: 12.5px; line-height: 1.35; color: var(--muted-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gi-table .gi-sub { display: block; margin-top: 2px; font-size: 12.5px; line-height: 1.35; color: var(--muted-fg); font-weight: 400; }
.gi-table .gi-name { font-weight: 700; }
.gi-table .gi-badge { display: inline-block; margin: 4px 4px 0 0; font-size: 12.5px; padding: 2px 9px; }
.gi-table .gi-nowrap { white-space: nowrap; }
.gi-table .gi-act { display: flex; width: fit-content; max-width: 100%; margin-top: 6px; min-height: 44px; padding: 4px 8px; align-items: center; justify-content: center; text-align: center; line-height: 1.2; white-space: normal; }
@media (max-width: 760px) { .gi-table { min-width: 680px; } }


/* v404 staff mobile pass (audit at 390 px of every page staff can open) ------------------------------------------------ */
.badge { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }          /* a long badge inside a sentence wrapped past the screen on Call-outs */
td .badge, th .badge { overflow-wrap: break-word; }
#bomTable th:first-child, #bomTable td:first-child { min-width: 190px; }                 /* v416: the ingredient name was squeezed to about 90 px beside the buttons on a tablet or phone */                               /* v416: a short tag such as "unknown" or "Milk" in a narrow table column was broken letter by letter (unk/no/wn); the column now stays wide enough for the word */
@media (max-width: 1100px), (pointer: coarse) {                                       /* tablets count: staff use them in the kitchen */
  main th { font-size: 13px; }                                                       /* column headings were 12 px */
  main th a { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; }         /* sortable headings (Ingredients) were 16 px high */
  main details > summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; }
  main .check { min-height: 44px; display: flex; align-items: center; gap: 10px; }
  main .check label { min-height: 44px; display: inline-flex; align-items: center; }
  main .check input[type=radio], main .check input[type=checkbox] { width: 24px; height: 24px; flex: none; }
  main a.muted.small { display: inline-flex; align-items: center; min-height: 44px; }
}

/* v404: Ingredients filters on a phone took the whole first screen as six stacked boxes; paired up so the list starts sooner */
@media (max-width: 700px) {
  main form[action="/ingredients"] .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; align-items: end; }
  main form[action="/ingredients"] .form-row > div { min-width: 0; flex: none; }
  main form[action="/ingredients"] .form-row > div:first-child, main form[action="/ingredients"] .form-row > div:nth-child(2) { grid-column: 1 / -1; }
  main form[action="/ingredients"] a.btn.ghost { background: #fff; color: var(--primary); border: 1.5px solid var(--border, #cfd6dc); }
}
/* v417: on the Recipes list the three actions (Make now, Edit, Staff view) stay in view at the right edge while the table scrolls sideways
   on a tablet, instead of being pushed off the screen. They stack, so the column stays narrow. */
@media (max-width: 1180px) {
  .recipes-table th.rc-actions, .recipes-table td.rc-actions { position: sticky; right: 0; background: var(--card); box-shadow: -10px 0 10px -10px rgba(20, 40, 50, .28); }
  .recipes-table td.rc-actions { display: table-cell; min-width: 126px; }
  .recipes-table td.rc-actions > a { display: block; width: fit-content; margin: 0 0 6px; }
}
/* v417: a long unbroken run of text in <code> (the "Columns: visit_date,name,company,..." import hints on Visitors, Pest control and other pages)
   used to stretch the whole page sideways on a phone. It now wraps inside the screen. */
code { overflow-wrap: anywhere; }

/* v418: a summary set to display:flex loses the browser's own triangle, so a folded section looked like plain text. Add class="fold-arrow" to give it an arrow that turns when it is open. */
details > summary.fold-arrow::before { content: '\25B8'; flex: none; width: 1em; margin-right: 8px; }
details[open] > summary.fold-arrow::before { content: '\25BE'; }


/* ------------------------------------------------------------------ v437: the question band
   Daniel, 19/11/2026: "Let's use the kind of flag alert a little bit more across the screen to
   post questions so that staff can't just ignore a number like an inbox." It spans the page, it
   carries its own answers, and it has no close button: it goes when it is answered. */
.tidy-band { border-radius: 10px; margin: 0 0 14px; padding: 12px 14px; border: 1px solid transparent; }
.tidy-amber { background: #FDF3DA; border-color: #E4C56A; color: #4A3708; }
.tidy-red   { background: #FBE7E3; border-color: #E0A79B; color: #5A1D12; }
.tidy-band-in { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; }
.tidy-q { flex: 1 1 320px; min-width: 0; }
.tidy-area { display: inline-block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  opacity: .8; margin-right: 8px; }
.tidy-q strong { font-weight: 600; }
.tidy-detail { display: block; font-size: 14px; opacity: .85; margin-top: 2px; }
.tidy-acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.tidy-btn { min-height: 44px; padding: 10px 16px; border-radius: 9px; border: 1px solid currentColor;
  background: #1F6F4A; color: #fff; border-color: #1F6F4A; font: inherit; font-weight: 600; cursor: pointer; }
.tidy-btn.ghost { background: transparent; color: inherit; border-color: currentColor; }
.tidy-btn:hover { filter: brightness(1.06); }
.tidy-more { align-self: center; font-size: 13px; text-decoration: underline; color: inherit; opacity: .85; }
/* v438: the comment box lives in the band, so a reason can be given where it is asked for */
.tidy-note { flex: 1 1 220px; min-width: 160px; min-height: 44px; padding: 10px 12px; border-radius: 9px;
  border: 1px solid rgba(0,0,0,.25); background: #fff; color: #22262E; font: inherit; }
.tidy-note::placeholder { color: #6b7280; }
.tidy-err { flex: 1 1 100%; font-size: 13px; font-weight: 600; color: #8c2017; }
@media (max-width: 640px) {
  .tidy-acts { width: 100%; }
  .tidy-btn { flex: 1 1 140px; }
  .tidy-note { flex: 1 1 100%; }
}
@media print { .tidy-band { display: none !important; } }

/* ---------- v452: the tasting form ----------
   Used in the customer portal and on the project page. Built for a chef holding a phone next
   to four open jars: big targets, one question visible at a time, nothing to read twice. */
.tasting .tst-set { border: 1px solid var(--card-border); border-radius: 10px; padding: 12px 14px; margin: 0 0 14px; }
.tasting .tst-set legend { font-weight: 600; padding: 0 6px; }
.tasting .tst-opt { display: flex; align-items: flex-start; gap: 12px; min-height: 48px; padding: 9px 0;
                    border-top: 1px solid var(--card-border); margin: 0; cursor: pointer; }
.tasting .tst-opt:first-of-type { border-top: 0; }
.tasting .tst-opt input { width: 24px; height: 24px; min-height: 24px; flex: none; margin: 2px 0 0; }
.tasting .tst-diff { display: block; color: var(--muted-fg); font-size: 13px; margin-top: 2px; }
.tasting .tst-h { margin: 0 0 2px; font-size: 16px; }
.tasting .tst-dials { border: 1px solid var(--card-border); border-radius: 10px; padding: 12px 14px; margin: 0 0 14px; }
.tasting .tst-row { border-top: 1px solid var(--card-border); padding: 10px 0; }
.tasting .tst-row:first-child { border-top: 0; }
.tasting .tst-name { font-weight: 600; margin-bottom: 6px; }
/* Three across -- less | about right | more -- so it reads as a slider and six dials still
   fit on a phone screen. "Like another one" is a different kind of answer and spans its own
   row underneath. A flex column per option made the form 24 rows long on a 390px screen. */
.tasting .tst-moves { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tasting .tst-move { margin: 0; }
.tasting .tst-move-like { grid-column: 1 / -1; }
.tasting .tst-move input { position: absolute; opacity: 0; pointer-events: none; }
.tasting .tst-move span { display: block; text-align: center; min-height: 44px; line-height: 44px;
                          padding: 0 12px; border: 1px solid var(--card-border); border-radius: 8px;
                          background: var(--card-bg, #fff); cursor: pointer; font-size: 14px; }
/* "About right" is the default on every row, so colouring it would paint the whole form green
   and bury the one or two things they actually moved. A change is what stands out. */
.tasting .tst-move input:checked + span { background: var(--bg, #f4f6f8); border-color: #9aa3ae; font-weight: 600; }
.tasting .tst-move input[data-change]:checked + span { background: var(--brand, #0f6b4f); border-color: var(--brand, #0f6b4f); color: #fff; }
.tasting .tst-move input:focus-visible + span { outline: 2px solid var(--brand, #0f6b4f); outline-offset: 2px; }
.tasting .tst-like { margin-top: 8px; min-height: 44px; }
.tasting .tst-text { display: block; margin: 0 0 12px; }
@media (max-width: 400px) { .tasting .tst-move span { font-size: 13px; padding: 0 4px; } }
