/* Pallet Weigh-Up: shipping-label look, built for phones in the warehouse and a desk in the office */
:root {
  --bg: #eceff2; --surface: #ffffff; --sunk: #f4f6f8; --ink: #18212b; --muted: #5a6875; --line: #d3d9df;
  --kraft: #a8743c; --kraft-soft: #f3e7d8; --steel: #1f4a80; --steel-soft: #e1eaf5;
  --ok: #2b7a4b; --ok-soft: #dff1e6; --warn: #9a5c00; --warn-soft: #fbefd9; --bad: #b3261e; --bad-soft: #f9e0de;
  --font-display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c; --surface: #19212a; --sunk: #141b22; --ink: #e5eaef; --muted: #95a3b0; --line: #2c3742;
    --kraft: #d6a368; --kraft-soft: #2e2519; --steel: #82aee6; --steel-soft: #1b2a3c;
    --ok: #6cc592; --ok-soft: #16301f; --warn: #e3a64a; --warn-soft: #2f2414; --bad: #f08a83; --bad-soft: #3a1a18;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.45; }
a { color: var(--steel); }
h1, h2 { font-family: var(--font-display); font-weight: 700; margin: 0; text-wrap: balance; text-transform: uppercase; }
h1 { font-size: 30px; line-height: 1.05; letter-spacing: .01em; }
h2 { font-size: 20px; letter-spacing: .04em; }
code { font-family: var(--font-mono); font-size: .92em; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--steel); outline-offset: 2px; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.foot { font-size: 12px; color: var(--muted); margin: 0; }
.crumb { margin: 0; font-size: 14px; }

/* Top bar */
.topnav { background: var(--ink); color: var(--surface); padding-top: env(safe-area-inset-top, 0px);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.navin { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 6px 18px; flex-wrap: wrap; padding-block: 10px; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 18px; text-transform: uppercase; letter-spacing: .06em; }
.links { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.links a { color: var(--surface); text-decoration: none; padding: 5px 10px; border-radius: 4px; font-weight: 500; opacity: .8; }
.links a:hover { opacity: 1; }
.links a.on { background: color-mix(in srgb, var(--surface) 16%, transparent); opacity: 1; }
.topnav .who { font-size: 13px; opacity: .8; }
.topnav .who a { color: var(--surface); }

.wrap { max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 20px calc(48px + env(safe-area-inset-bottom, 0px)); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.sec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.fields { display: grid; grid-template-columns: minmax(0, 1.4fr) 110px minmax(0, 1.2fr); gap: 10px; flex: 1 1 520px; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; min-width: 0; }
.t { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; width: 100%; min-width: 0; font-size: 15px; }
.t.narrow { width: auto; }
.t:focus { border-color: var(--steel); outline: none; }
label.check { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
label.check input { width: 18px; height: 18px; accent-color: var(--steel); }

/* Totals strip, styled like a carton label */
.label-strip { background: var(--surface); border: 2px solid var(--ink); border-radius: 4px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.label-strip > div { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.label-strip > div + div { border-left: 2px solid var(--ink); }
.big { font-family: var(--font-display); font-weight: 700; font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }
.big small { font-size: 16px; font-weight: 600; margin-left: 2px; }
.label-strip .strip-note { grid-column: 1 / -1; border-top: 2px solid var(--ink); border-left: 0; font-size: 13px; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px 10px; }

.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.stats > div { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.pill { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.pill.tiny { font-size: 10px; padding: 1px 6px; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--steel-soft); color: var(--steel); }

/* Sides */
.sides { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.side { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.side .ph { aspect-ratio: 3 / 4; max-width: 100%; background: var(--sunk); display: grid; place-items: center; position: relative; }
.side .ph a, .side .ph img { display: block; width: 100%; height: 100%; }
.side .ph img { object-fit: cover; }
.side .ph .empty { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; text-align: center; padding: 10px; }
.side .tag { position: absolute; top: 8px; left: 8px; background: var(--ink); color: var(--surface); font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: .06em; text-transform: uppercase; padding: 2px 8px; border-radius: 3px; }
.side .count { position: absolute; top: 8px; right: 8px; }
.side .secs { position: absolute; bottom: 8px; right: 8px; background: var(--ink); color: var(--surface); font-family: var(--font-mono); font-size: 12px; padding: 2px 6px; border-radius: 3px; }
.side .act { padding: 10px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); }
.side .msg { font-size: 12px; color: var(--muted); min-height: 1.2em; overflow-wrap: anywhere; }
.side .msg.err { color: var(--bad); }

.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 9px 12px; font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-align: center; text-decoration: none; color: var(--ink); }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--steel); border-color: var(--steel); color: var(--surface); }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.big-btn { padding: 13px 20px; font-size: 16px; }
.danger-btn { border-color: var(--bad); color: var(--bad); }
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-actions form { margin: 0; }

.callout { background: var(--warn-soft); border: 1px solid var(--warn); border-radius: 6px; padding: 10px 12px; font-size: 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.callout.info { background: var(--steel-soft); border-color: var(--steel); justify-content: flex-start; }
.callout.good { background: var(--ok-soft); border-color: var(--ok); justify-content: flex-start; }

/* Case list */
.cases { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.case { display: grid; grid-template-columns: 28px minmax(0, 1fr) 108px auto; gap: 10px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--line); }
.case:first-child { border-top: 0; }
.case.off { opacity: .55; }
.case.off .kgbox input { text-decoration: line-through; }
.case.flagged { background: var(--warn-soft); }
.case > input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--steel); }
.case .who { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.case .line1 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.case input.code { width: 8ch; border: 0; background: none; padding: 0; font-weight: 600; font-size: 15px; }
.case .name { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.case .meta, .user-row .meta { font-size: 11px; color: var(--muted); letter-spacing: .02em; }
.case .flag { grid-column: 2 / -1; font-size: 12px; color: var(--warn); margin-top: -4px; }
.kgbox { display: flex; align-items: center; gap: 4px; }
.kgbox input { width: 100%; min-width: 0; text-align: right; padding: 8px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; border: 1px solid var(--line); border-radius: 5px; background: var(--sunk); font-size: 15px; }
.kgbox span { font-size: 12px; color: var(--muted); }
.rowbtns { display: flex; gap: 2px; }
.x, .okbtn { border: 0; background: none; color: var(--muted); font-size: 20px; line-height: 1; padding: 6px; border-radius: 4px; min-width: 32px; }
.x:hover { color: var(--bad); background: var(--sunk); }
.okbtn { color: var(--ok); font-size: 18px; border: 1px solid var(--ok); }
.empty-list { padding: 22px 16px; text-align: center; color: var(--muted); font-size: 14px; }

.submit-box { background: var(--surface); border: 2px solid var(--ink); border-radius: 4px; padding: 14px; }
.issues { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.issues li { display: flex; gap: 8px; align-items: baseline; }

/* Tables */
.tbl { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
table.bd { width: 100%; border-collapse: collapse; font-size: 14px; }
table.bd th, table.bd td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.bd tr:last-child td { border-bottom: 0; }
table.bd th { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; white-space: nowrap; }
table.bd .n { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.bd tr.dim td { color: var(--muted); }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover td { background: var(--sunk); }
table.list a { text-decoration: none; font-weight: 600; }

.prod-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px 10px; border-top: 1px solid var(--line); margin: 0; }
.prod-row:first-child { border-top: 0; }
.code-cell { font-weight: 600; }
.user-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-top: 1px solid var(--line); }
.user-row:first-child { border-top: 0; }
.user-row.off { opacity: .6; }
.user-row .who { display: flex; flex-direction: column; }
.user-row .t { width: 170px; padding: 6px 10px; font-size: 14px; }
.add-user { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 10px; align-items: end; }
.check-row { display: grid; grid-template-columns: 60px minmax(0, 220px) minmax(0, 1fr); gap: 10px; align-items: baseline; padding: 10px 12px; border-top: 1px solid var(--line); }
.check-row:first-child { border-top: 0; }
.check-row .pill { text-align: center; }
details summary { cursor: pointer; font-weight: 600; }
details.danger summary { color: var(--bad); }
.login { max-width: 380px; width: 100%; margin: 6vh auto 0; display: flex; flex-direction: column; gap: 12px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 6px; font-size: 14px; z-index: 20; max-width: calc(100% - 32px); }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

@media (max-width: 860px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats > div:first-child { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .links { order: 3; flex: 1 1 100%; margin-left: -10px; }
  .navin { justify-content: space-between; }
  .sides { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fields { grid-template-columns: minmax(0, 1fr) 100px; }
  .fields label:last-child { grid-column: 1 / -1; }
  .add-user { grid-template-columns: 1fr; }
  .check-row { grid-template-columns: 56px minmax(0, 1fr); }
  .check-row .muted { grid-column: 2; }
}
@media (max-width: 420px) {
  .big { font-size: 27px; }
  h1 { font-size: 26px; }
  .case { grid-template-columns: 24px minmax(0, 1fr) 92px auto; gap: 8px; padding: 10px; }
  .label-strip > div { padding: 8px 9px 10px; }
  .user-row .t { width: 100%; }
}

/* Barcode mode */
body.mode-barcode .photo-only, body.mode-photo .barcode-only { display: none !important; }
.modes { display: inline-flex; margin-top: 10px; border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; }
.modes button { border: 0; background: var(--surface); padding: 8px 14px; font-weight: 600; font-size: 14px; color: var(--ink); }
.modes button + button { border-left: 2px solid var(--ink); }
.modes button.on { background: var(--ink); color: var(--surface); }
.scanbox { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.scanbox .row-actions { align-items: flex-end; }
.wedge { flex: 1 1 260px; margin: 0; }
.cam { position: relative; background: #000; border-radius: 6px; overflow: hidden; max-width: 100%; }
#reader { width: 100%; }
#reader video { width: 100% !important; height: auto !important; display: block; }
#reader img[alt="Info icon"], #reader__dashboard_section_csr span { display: none !important; }
.cam-flash { position: absolute; inset: 0; pointer-events: none; opacity: .35; }
.cam-flash.ok { background: var(--ok); }
.cam-flash.warn { background: var(--warn); }
.cam-flash.bad { background: var(--bad); }
.lastscan { min-height: 1.6em; font-size: 15px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; overflow-wrap: anywhere; }
.namerow { display: grid; grid-template-columns: 100px minmax(0, 1fr) auto; gap: 8px; align-items: center; margin: 0; }
@media (max-width: 700px) { .modes { display: flex; } .modes button { flex: 1; } }
.lastscan { display: block; line-height: 1.6; }
@media (max-width: 700px) { .pagehead > div:first-child { width: 100%; } }

/* Barcode labels setup */
.setup .f { gap: 6px; }
#lpreview { max-width: 280px; max-height: 220px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; margin-top: 6px; }
.sample { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.digits { display: flex; flex-wrap: wrap; font-size: 17px; letter-spacing: .02em; gap: 1px; }
.digits span { padding: 3px 2px; border-radius: 3px; min-width: 1.05em; text-align: center; }
.f-prod { background: var(--sunk); outline: 1px solid var(--muted); }
.f-net { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.f-gross { background: var(--steel-soft); color: var(--steel); font-weight: 600; }
.f-tare { background: var(--kraft-soft); color: var(--kraft); font-weight: 600; }
.f-date { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.f-pieces { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.legend { display: flex; gap: 6px; flex-wrap: wrap; }
.legend span { padding: 2px 8px; border-radius: 3px; }
.lab { padding: 0 6px; border-radius: 3px; align-self: flex-start; }
.vgrid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.vgrid .wide { grid-column: span 5; }
@media (max-width: 700px) { .vgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .vgrid .wide { grid-column: 1 / -1; } }
.cam.vertical #reader video { max-height: 70vh; object-fit: cover; }
.topnav .who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.3; }
.topnav .who .ver { font-family: var(--font-mono); font-size: 11px; opacity: .75; }
.linkbtn { border: 0; background: none; color: var(--steel); text-decoration: underline; padding: 4px 0; font-size: 13px; }
.scantest pre { margin: 0; background: var(--sunk); border: 1px solid var(--line); border-radius: 6px; padding: 10px; font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto; }

/* Users and permissions */
table.roles th.c, table.roles td.c { text-align: center; white-space: normal; font-size: 12px; }
table.roles th.c { min-width: 0; font-size: 10px; letter-spacing: .04em; padding-left: 3px; padding-right: 3px; }
table.roles td.c { padding-left: 3px; padding-right: 3px; }
.user-card { border-top: 1px solid var(--line); }
.user-card:first-child { border-top: 0; }
.user-card.off { opacity: .65; }
.user-card summary { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px; list-style: none; cursor: pointer; }
.user-card summary::-webkit-details-marker { display: none; }
.user-card summary::after { content: "Edit ▾"; font-size: 12px; color: var(--steel); font-weight: 600; }
.user-card[open] summary::after { content: "Close ▴"; }
.user-card summary .who { display: flex; flex-direction: column; align-items: flex-start; }
.perm-sum { flex: 1 1 260px; }
.user-body { padding: 0 12px 14px; display: flex; flex-direction: column; gap: 14px; }
.user-body .t.pw { width: 200px; }
.perm-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.perm { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--line); border-radius: 6px; padding: 8px; background: var(--surface); cursor: pointer; }
.perm input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--steel); flex: none; }
.perm span { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.perm small { color: var(--muted); font-size: 11px; line-height: 1.3; }
.perm:has(input:checked) { border-color: var(--steel); background: var(--steel-soft); }
.add-user { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 700px) { .add-user { grid-template-columns: 1fr; } }
.add-user-form h3 { margin: 6px 0 0; font-size: 15px; }
@media (max-width: 860px) { .perm-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .perm-grid { grid-template-columns: 1fr; } .user-body .t.pw { width: 100%; } }

/* Install as app */
.installbtn { border: 1px solid color-mix(in srgb, var(--surface) 45%, transparent); background: none; color: var(--surface); border-radius: 4px; padding: 3px 8px; font-size: 12px; font-weight: 600; margin-top: 3px; }
.install-help { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); width: min(420px, calc(100% - 32px)); background: var(--surface); color: var(--ink); border: 2px solid var(--ink); border-radius: 8px; padding: 14px; z-index: 30; box-shadow: 0 8px 30px rgba(0,0,0,.25); font-size: 14px; display: flex; flex-direction: column; gap: 8px; }
.install-help ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.role-select { max-width: 280px; }
.scanner-type { display: flex; flex-direction: column; gap: 6px; }
.scanner-type .modes { margin-top: 0; align-self: flex-start; }

/* Anything marked hidden stays hidden, whatever its display style (fixes empty message bars) */
[hidden] { display: none !important; }

/* Scan page, v1.4: scan box first */
.scanhead { display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; flex-wrap: wrap; }
.scantitle { font-size: 26px; }
.scanhead .modes { margin-top: 0; }
.wedge .t { font-size: 19px; padding: 14px 14px; border-width: 2px; }
.wedge .t:focus { border-color: var(--steel); box-shadow: 0 0 0 3px var(--steel-soft); }
.modes.three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-self: stretch; }
.modes.three button { padding: 9px 6px; font-size: 14px; }
.modes.three button + button { border-left: 2px solid var(--ink); }
.cam-area { display: flex; flex-direction: column; gap: 10px; }
.scanbox { gap: 10px; }
.lastscan:empty { display: none; }

@media (max-width: 700px) {
  .wrap { gap: 16px; padding-block: 14px calc(40px + env(safe-area-inset-bottom, 0px)); }
  /* top bar: one line of links that scrolls sideways instead of wrapping */
  .navin { padding-block: 8px 6px; gap: 4px 12px; }
  .brand { font-size: 16px; }
  .links { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .links::-webkit-scrollbar { display: none; }
  .links a { padding: 5px 9px; white-space: nowrap; font-size: 15px; }
  .topnav .who { font-size: 12px; }
  /* scan page: the nav already says Scan, so the big title goes */
  .scantitle { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .scanhead .modes { width: 100%; }
  .label-strip .big { font-size: 26px; }
  .label-strip > div { padding: 7px 9px 8px; }
  .label-strip .eyebrow { font-size: 10px; letter-spacing: .08em; }
  .scanbox { padding: 10px; }
}
body.mode-barcode .fields { grid-template-columns: minmax(0, 1fr) 140px; }
.wrap > .fields, .scanbox > .wedge { flex: none; }
@media (min-width: 861px) { .perm-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Settings page */
.settings-form { padding: 0; }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px; border-top: 1px solid var(--line); cursor: pointer; }
.setting-row:first-of-type { border-top: 0; }
.setting-row > span:first-child { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.setting-row small { color: var(--muted); font-size: 12.5px; line-height: 1.4; max-width: 62ch; }
.setting-save { padding: 12px 14px; border-top: 1px solid var(--line); }
.switch { position: relative; flex: none; width: 48px; height: 28px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--steel); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .switch span, .switch span::after { transition: none; } }

/* Weight sheet selection on the Office page */
.ws-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0; }
.ws-count { font-size: 14px; font-weight: 600; flex: 1 1 220px; }
.ws-bar .t { flex: 2 1 280px; width: auto; }
table.list th.sel, table.list td.sel { width: 36px; text-align: center; cursor: default; }
table.list td.sel input, table.list th.sel input { width: 20px; height: 20px; accent-color: var(--steel); cursor: pointer; }

/* Labels page tabs and product names */
.modes.tabs { margin-top: 0; align-self: flex-start; }
.modes.tabs a { padding: 9px 16px; font-weight: 600; font-size: 14px; color: var(--ink); background: var(--surface); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.modes.tabs a + a { border-left: 2px solid var(--ink); }
.modes.tabs a.on { background: var(--ink); color: var(--surface); }
.pn-row { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(0, 2fr) auto; gap: 10px; align-items: center; padding: 10px 12px; border-top: 1px solid var(--line); margin: 0; }
.pn-list .pn-row:first-child { border-top: 0; }
.pn-row.add { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.pn-code { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pn-code .mono { font-weight: 600; overflow-wrap: anywhere; }
.pn-code .meta { font-size: 11.5px; color: var(--muted); }
.pn-row.saved { background: var(--ok-soft); }
.pn-row .t:invalid:not(:focus) { border-color: var(--warn); }
@media (max-width: 700px) {
  .pn-row { grid-template-columns: minmax(0, 1fr) auto; }
  .pn-row .pn-code { grid-column: 1 / -1; }
  .modes.tabs { display: flex; width: 100%; }
  .modes.tabs a { flex: 1; justify-content: center; text-align: center; padding: 9px 8px; }
}

/* Product names: sub-tabs, delete */
.pn-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pn-tools .t { flex: 1 1 240px; width: auto; }
.modes.tabs.sub button { border: 0; background: var(--surface); padding: 9px 14px; font-weight: 600; font-size: 14px; color: var(--ink); display: inline-flex; gap: 6px; align-items: center; }
.modes.tabs.sub button + button { border-left: 2px solid var(--ink); }
.modes.tabs.sub button.on { background: var(--ink); color: var(--surface); }
.cnt { font-family: var(--font-mono); font-size: 12px; opacity: .75; }
.pn-panel { display: flex; flex-direction: column; gap: 8px; }
.pn-btns { display: flex; gap: 6px; }
.del-btn { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.del-btn.armed { background: var(--bad); border-color: var(--bad); color: var(--surface); }
@media (max-width: 700px) { .modes.tabs.sub { width: 100%; display: flex; } .modes.tabs.sub button { flex: 1; justify-content: center; padding: 9px 6px; } }
.pn-row.add .t:invalid:not(:focus) { border-color: var(--line); }
@media (max-width: 700px) { .pn-row.add { grid-template-columns: 1fr; } .pn-row.add .btn { justify-self: start; } }

/* Columns menus */
.col-off { display: none !important; }
.colmenu { position: absolute; z-index: 40; width: min(300px, calc(100vw - 16px)); max-height: 70vh; overflow: auto; background: var(--surface); color: var(--ink); border: 2px solid var(--ink); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.2); padding: 10px 12px; display: flex; flex-direction: column; gap: 12px; }
.colmenu-sec { display: flex; flex-direction: column; gap: 6px; }
.colmenu .check { color: var(--ink); font-size: 14px; }
.colmenu-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.label-strip:has(> .col-off) { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Manual entry page */
.manualbox { gap: 12px; }
.picker { position: relative; display: flex; flex-direction: column; gap: 4px; }
.prodlist { position: absolute; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none; z-index: 30; max-height: 320px; overflow: auto; background: var(--surface); border: 2px solid var(--ink); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.prodlist li { padding: 9px 10px; border-radius: 5px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.prodlist li:hover, .prodlist li.act { background: var(--steel-soft); }
.prodlist .pname { font-weight: 600; }
.prodlist .pmeta { font-size: 12px; color: var(--muted); }
.prodlist .newopt { color: var(--steel); }
.prodlist .empty { cursor: default; color: var(--muted); }
.recent { display: flex; gap: 6px; flex-wrap: wrap; }
.recent:empty { display: none; }
.chip { border: 1px solid var(--line); background: var(--sunk); color: var(--ink); border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 500; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.weightrow { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.modes.unit { margin-top: 0; }
.modes.unit button { padding: 13px 16px; font-size: 15px; }
.wform { display: flex; gap: 8px; align-items: flex-end; flex: 1 1 260px; margin: 0; }
.wform .f { flex: 1; }
.wform .t { font-size: 24px; padding: 11px 14px; border-width: 2px; font-weight: 600; }
.wform .t:focus { border-color: var(--steel); box-shadow: 0 0 0 3px var(--steel-soft); outline: none; }
.mrow { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto 32px; gap: 10px; align-items: center; padding: 9px 12px; border-top: 1px solid var(--line); }
.mrow:first-child { border-top: 0; }
.mrow .who { display: flex; flex-direction: column; min-width: 0; }
.mrow .meta { font-size: 11.5px; color: var(--muted); }
.mno { color: var(--muted); font-size: 13px; }
.mkg { font-size: 16px; font-weight: 600; }
@media (max-width: 700px) {
  .weightrow { flex-direction: column; align-items: stretch; }
  .modes.unit { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
}
.fields.two { grid-template-columns: minmax(0, 1fr) 140px; }
.fields.two label:last-child { grid-column: auto; }
@media (max-width: 700px) { .fields.two { grid-template-columns: minmax(0, 1fr) 110px; } .weightrow > .wform { flex: none; } }

/* Audit log */
.audit-filters .t[type=search] { flex: 1 1 200px; width: auto; }
table.audit td { vertical-align: top; }
.nowrap { white-space: nowrap; }
.audit-filters select.t { flex: 0 1 auto; }

/* Settings: weight sheet logo */
.logo-box { display: flex; flex-direction: row; gap: 18px; align-items: flex-start; flex-wrap: wrap; padding: 14px; }
.logo-box > div:last-child { flex: 1 1 260px; min-width: 0; }
.logo-preview { width: 240px; max-width: 100%; min-height: 80px; display: flex; align-items: center; justify-content: center; background: #fff; border: 1px dashed var(--line, #c9d1d9); border-radius: 8px; padding: 10px; }
.logo-preview img { max-width: 100%; max-height: 90px; display: block; }

/* Users: one row per login, laid out like the roles table */
table.logins td, table.logins th { vertical-align: middle; padding-left: 6px; padding-right: 6px; }
table.logins th.c { min-width: 0; font-size: 10px; letter-spacing: .04em; padding-left: 3px; padding-right: 3px; }
table.logins td.c { padding-left: 3px; padding-right: 3px; }
table.logins .usr { min-width: 112px; white-space: nowrap; position: sticky; left: 0; background: var(--surface); z-index: 1; padding-left: 12px; }
table.logins .usr input.ref { display: block; margin-top: 4px; }
table.logins input.ref { width: 70px; font-family: var(--font-mono); font-size: 13px; text-transform: uppercase; padding: 4px 7px; }
table.logins input.ref::placeholder { text-transform: none; }
table.logins .rolecell select { width: 108px; padding: 6px 6px; font-size: 14px; }
table.logins input.tick { width: 20px; height: 20px; accent-color: var(--steel); cursor: pointer; margin: 0; }
table.logins .act { white-space: nowrap; text-align: right; padding-right: 12px; }
table.logins .act .btn + .btn { margin-left: 4px; }
table.logins tr.off td { opacity: .6; }
table.logins tr.off td.act, table.logins tr.off td.usr { opacity: 1; }
table.logins tr.dirty td { background: var(--steel-soft); }
table.logins .save:disabled { opacity: .4; }
table.logins tr.umore td { background: var(--sunk); padding: 8px 12px; }
table.logins tr.umore .t.pw { width: 200px; }

/* Settings: Manual page product lists */
div.setting-row { border-top: 1px solid var(--line); cursor: default; }
.ticks { display: flex; flex-direction: column; gap: 6px; flex: none; }
.tickopt { display: flex; align-items: center; gap: 8px; font-size: 14px; white-space: nowrap; cursor: pointer; }
.tickopt input { width: 18px; height: 18px; accent-color: var(--steel); margin: 0; }
@media (max-width: 560px) { div.setting-row { flex-direction: column; align-items: flex-start; } }

/* Invoice numbers */
input.t.inv { width: 130px; padding: 5px 8px; font-family: var(--font-mono); font-size: 13px; transition: border-color .2s, background .2s; }
input.t.inv.busy { border-color: var(--steel); }
input.t.inv.ok { border-color: var(--ok); background: var(--ok-soft); }
input.t.inv.bad { border-color: var(--bad); background: var(--bad-soft); }
.invcell { white-space: nowrap; }
.invbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.invbar input.t.inv { width: 200px; font-size: 15px; padding: 7px 10px; }

/* Invoices page */
table.invoices td { vertical-align: top; }
table.invoices input.invtick { width: 22px; height: 22px; accent-color: var(--ok); cursor: pointer; margin: 2px 0 0; }
table.invoices .tickform { margin: 0; }
table.invoices tr.done td { background: var(--ok-soft); }
table.invoices tr.changed td { background: var(--warn-soft); }
table.invoices .prodlines { min-width: 260px; }
table.invoices .prodlines > div { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 2px 0; }
table.invoices .prodlines > div + div { border-top: 1px dashed var(--line); }
table.invoices tfoot td { border-top: 2px solid var(--line); }

/* Office list: hover (or tap) the Note tag to read the scan note */
.notetip { position: relative; display: inline-block; margin-left: 4px; cursor: help; outline: none; }
.notetip .tip { display: none; position: fixed; left: 0; top: 0; z-index: 50; width: max-content; max-width: min(320px, 70vw);
  background: var(--ink); color: var(--surface); font-size: 13px; line-height: 1.4; font-weight: 400; text-transform: none; letter-spacing: 0;
  padding: 8px 10px; border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.18); white-space: normal; overflow-wrap: anywhere; }
.notetip:hover .tip, .notetip:focus .tip, .notetip:focus-within .tip { display: block; }

/* Office > Product names: search and sort */
.pn-tools input[type=search] { flex: 1 1 260px; min-width: 0; }
.prod-row.pn-head { padding-top: 6px; padding-bottom: 6px; background: var(--sunk); border-radius: 8px 8px 0 0; }
.sortbtn { border: 0; background: none; padding: 4px 0; font: inherit; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); cursor: pointer; text-align: left; }
.sortbtn.on { color: var(--steel); }
.sortbtn .arr { font-size: 10px; margin-left: 2px; }
.code-cell { overflow-wrap: anywhere; }
.prod-row.pn-item[hidden] { display: none; }

/* Heading with a button on the right (Users > All users) */
.h2row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.h2row h2 { margin-bottom: 0; }
table.invoices .pallist { min-width: 120px; }

/* Users > Edit roles */
table.rolesedit input.rname { width: 130px; padding: 6px 8px; font-weight: 600; }
table.rolesedit tfoot .usr input.rname { display: block; margin-top: 4px; font-weight: 400; }
table.rolesedit .delrole.confirm { background: var(--bad); color: #fff; border-color: var(--bad); }
table.rolesedit input.tick:disabled { opacity: .55; cursor: default; }
table.rolesedit tfoot td { border-top: 2px solid var(--line); background: var(--sunk); }
.deluser.confirm { background: var(--bad); color: #fff; border-color: var(--bad); }

/* Green "saved" messages fade out */
.callout.good { transition: opacity .6s ease; }
.callout.good.fade { opacity: 0; }
/* Users: filter bar */
.user-filter input[type=search] { flex: 1 1 220px; min-width: 0; }
table.logins tr.urow[hidden], table.logins tr.umore[hidden] { display: none; }
.user-filter select { flex: 0 1 220px; width: auto; }
