/* wozansi warehouse — the screens.
 *
 * Every colour is a `--brand-*`, `--accent-*` or `--status-*` variable from
 * `packages/brand/tokens.css`, which is served at `/brand/tokens.css`
 * straight out of the package rather than copied in. **There is not one hex
 * code in this file**, per AGENTS.md §2 ("Never re-type a hex code or a
 * product name into an app").
 *
 * Selectors are `.wh-*`, never `.wozansi-*`. Two renames in a month is the
 * reason tokens.css's own header gives for `--brand-*` over `--ilima-*`, and
 * the same reasoning applies one layer up: a third rename must cost one file.
 *
 * Colour rules that travel with the brand and are honoured here:
 *   - coral is BRAND ONLY and is never a status. It appears nowhere in this
 *     file, because nothing here is decorative enough to need it and every
 *     state uses --status-*.
 *   - status always carries a WORD, never colour alone. Every `.wh-pill`
 *     and `.wh-flag` has text in it; the colour is the second signal.
 *   - --brand-teal is not for small text (3.3:1). Words use
 *     --brand-text-teal.
 *
 * Dark mode is `:root[data-theme="dark"]`, which tokens.css defines and
 * `app.js` sets. Honoured by using the variables and nothing else — there is
 * no `@media (prefers-color-scheme)` block here at all, because that would
 * be a second place the theme is decided and the toggle has to win.
 */

*, *::before, *::after { box-sizing: border-box; }

/* **The `hidden` attribute has to win, and without this it does not.**
 *
 * `hidden` is implemented in the UA stylesheet as `[hidden] { display: none }`,
 * which is the weakest origin there is — so an author rule setting `display`
 * on the same element beats it. `.wh-app { display: flex }` and
 * `.wh-gate { display: grid }` below do exactly that, so `el.hidden = true`
 * set the property, passed every check that read it, and painted the element
 * anyway.
 *
 * Found in the browser and only in the browser. `app.js` sets
 * `gate.hidden = true` and `app.hidden = false` on sign-in, the DOM agreed
 * that it had, every API call succeeded, and the sign-in card stayed on
 * screen over the top of a fully rendered application. Nothing in 388 tests
 * could see it: the markup was correct, the property was correct, and the
 * only thing wrong was which of two stylesheets won — which is a question
 * only a renderer answers.
 *
 * `!important` because that is the one thing that cannot be beaten by the
 * next `display` rule somebody adds to a container that also gets hidden.
 */
[hidden] { display: none !important; }

html { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--brand-ink);
  background: var(--brand-ground);
  /* Numbers line up in columns. Stock figures read in a table and a
   * proportional font makes 1 and 7 different widths, which is how a
   * mis-read quantity happens. */
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 600; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }

a { color: var(--brand-text-teal); }

.wh-skip {
  position: absolute; left: -9999px;
  background: var(--brand-surface); color: var(--brand-ink);
  padding: .5rem .75rem; z-index: 10; border-radius: 6px;
}
.wh-skip:focus { left: .5rem; top: .5rem; }

/* ----------------------------------------------------------------- shell */

.wh-app { min-height: 100vh; display: flex; flex-direction: column; }

.wh-header {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .6rem 1rem;
  background: var(--brand-surface);
  border-bottom: 1px solid var(--brand-line);
  position: sticky; top: 0; z-index: 5;
}

.wh-brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: inherit; }
.wh-mark { display: block; }
.wh-brand-text { display: flex; flex-direction: column; line-height: 1.1; }
/* Lower case always, including at the start — BRAND.lowercaseAlways. */
.wh-brand-name { font-weight: 300; font-size: 1.05rem; text-transform: lowercase; }
.wh-brand-product { font-size: .72rem; color: var(--brand-ink-muted); text-transform: lowercase; letter-spacing: .04em; }

.wh-nav { display: flex; gap: .15rem; flex-wrap: wrap; flex: 1; }
.wh-nav a {
  padding: .4rem .7rem; border-radius: 7px; text-decoration: none;
  color: var(--brand-ink-muted); font-weight: 500; font-size: .9rem;
}
.wh-nav a:hover { background: var(--accent-soft); color: var(--brand-ink); }
.wh-nav a[aria-current="page"] {
  background: var(--accent-soft); color: var(--accent-deep); font-weight: 600;
}

.wh-who { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.wh-who-name { color: var(--brand-ink-muted); }
.wh-theme {
  background: none; border: 1px solid var(--brand-line); border-radius: 7px;
  color: var(--brand-ink-muted); cursor: pointer; width: 2rem; height: 2rem; font-size: 1rem;
}
.wh-theme:hover { border-color: var(--accent-line); color: var(--brand-ink); }

.wh-main { flex: 1; padding: 1.25rem; max-width: 1400px; width: 100%; margin: 0 auto; }

.wh-footer {
  padding: .9rem 1rem; text-align: center;
  color: var(--brand-ink-muted); font-size: .8rem;
  border-top: 1px solid var(--brand-line);
}
.wh-footer-sep { margin: 0 .4rem; opacity: .5; }

/* ------------------------------------------------------------- the gate */

.wh-gate {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: var(--brand-ground);
}
.wh-gate-card {
  width: 100%; max-width: 26rem; padding: 2rem;
  background: var(--brand-surface);
  border: 1px solid var(--brand-line); border-radius: 14px;
}
.wh-gate-mark { display: block; margin: 0 auto 1rem; max-width: 100%; height: auto; }
:root[data-theme="dark"] .wh-gate-mark { content: url("/brand/lockup-dark.svg"); }
.wh-gate-title {
  text-align: center; font-weight: 300; text-transform: lowercase;
  color: var(--brand-ink-muted); font-size: 1rem; letter-spacing: .08em;
  margin-bottom: 1.5rem;
}
.wh-gate-credit {
  margin: 1.5rem 0 0; text-align: center;
  font-size: .75rem; color: var(--brand-ink-muted);
}

/* ------------------------------------------------------------- surfaces */

.wh-card {
  background: var(--brand-surface);
  border: 1px solid var(--brand-line);
  border-radius: 12px;
  padding: 1.1rem;
  margin-bottom: 1.1rem;
}
.wh-card-head {
  display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap;
  margin-bottom: .85rem;
}
.wh-card-head h2 { margin: 0; }
.wh-grid { display: grid; gap: 1.1rem; }
@media (min-width: 60rem) { .wh-grid-2 { grid-template-columns: 1fr 1fr; } }

.wh-stat-row { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.wh-stat-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--brand-ink-muted); }
.wh-stat-value { font-size: 1.5rem; font-weight: 600; }

.wh-muted { color: var(--brand-ink-muted); }
.wh-small { font-size: .82rem; }
.wh-right { text-align: right; }

/* "What this is counting" — on every report, deliberately. A figure like
 * 50 000.121 with no explanation of what it counts looks like a bug. */
.wh-counts {
  margin: 0 0 1rem; padding: .6rem .8rem;
  background: var(--accent-soft); border-left: 3px solid var(--accent-line);
  border-radius: 0 7px 7px 0;
  font-size: .85rem; color: var(--brand-ink);
}

/* ---------------------------------------------------------------- tables */

.wh-table-wrap { overflow-x: auto; }
table.wh-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.wh-table th, .wh-table td { padding: .45rem .6rem; text-align: left; border-bottom: 1px solid var(--brand-line); }
.wh-table th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--brand-ink-muted); font-weight: 600; white-space: nowrap;
}
.wh-table tbody tr:hover { background: var(--accent-soft); }
.wh-table td.wh-num, .wh-table th.wh-num { text-align: right; white-space: nowrap; }
.wh-table tfoot td { font-weight: 600; border-top: 2px solid var(--brand-line); border-bottom: none; }
.wh-table .wh-row-link { cursor: pointer; }

/* The note that is open above the list, on the one-page receiving screen.
 * A tint and a left rule, from the accent tokens the nav and the notes
 * already use — NOT a status colour: which note you are looking at is not a
 * state the stock is in, and AGENTS.md rule 4 keeps running/warning/alarm for
 * things that are. */
.wh-table .wh-row-open {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent-line);
}

.wh-empty { padding: 1.5rem; text-align: center; color: var(--brand-ink-muted); }

/* ----------------------------------------------------------------- forms */

.wh-field { display: block; margin-bottom: .8rem; }
.wh-field > span { display: block; font-size: .78rem; font-weight: 600; margin-bottom: .25rem; }
.wh-field > span .wh-hint { font-weight: 400; color: var(--brand-ink-muted); }

input, select, textarea {
  width: 100%; padding: .5rem .6rem; font: inherit;
  color: var(--brand-ink); background: var(--brand-ground);
  border: 1px solid var(--brand-line); border-radius: 8px;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { min-height: 4.5rem; resize: vertical; }

.wh-row { display: flex; gap: .7rem; flex-wrap: wrap; align-items: flex-end; }
.wh-row > .wh-field { flex: 1 1 10rem; margin-bottom: 0; }

/* A tick box with its words beside it rather than above it.
 *
 * The FIRST checkbox in this client (task 40's "back up every night"), which
 * is why `.wh-field`'s stacked layout had nothing to say about one: a label
 * on its own line above a lone tick box reads as a heading with a stray box
 * under it. `align-items: center` rather than `baseline` — a tick box has no
 * text baseline and Firefox and Chrome disagree about where to pretend it is.
 */
.wh-field-check { display: flex; align-items: center; gap: .5rem; }
.wh-field-check > span { display: inline; margin-bottom: 0; }
.wh-field-check > input { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.wh-actions { display: flex; gap: .55rem; flex-wrap: wrap; margin-top: .9rem; }

button {
  font: inherit; font-weight: 600; padding: .5rem .95rem;
  border-radius: 8px; cursor: pointer;
  border: 1px solid var(--brand-line);
  background: var(--brand-ground); color: var(--brand-ink);
}
button:hover:not(:disabled) { border-color: var(--accent-line); }
button:disabled { opacity: .5; cursor: not-allowed; }

button.wh-primary {
  background: var(--accent); border-color: var(--accent);
  /* In dark mode --accent is a light indigo, so the TEXT goes dark on it —
   * tokens.css says so in as many words beside the dark --accent. */
  color: var(--brand-surface);
}
:root[data-theme="dark"] button.wh-primary { color: var(--brand-ground); }
button.wh-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

button.wh-link {
  background: none; border: none; padding: .2rem .3rem;
  color: var(--brand-text-teal); font-weight: 500; text-decoration: underline;
}
button.wh-danger { border-color: var(--status-alarm); color: var(--status-alarm); }
button.wh-small { padding: .25rem .5rem; font-size: .8rem; }

/* ----------------------------------------------------- status and flags */

/* Every pill carries a WORD. The colour is the second signal, never the
 * only one — tokens.css's own rule. */
.wh-pill {
  display: inline-block; padding: .1rem .5rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600; white-space: nowrap;
  background: var(--accent-soft); color: var(--accent-deep);
}
.wh-pill-ok { background: var(--status-running-ground); color: var(--status-running); }
.wh-pill-warn { background: var(--status-warning-ground); color: var(--status-warning); }
.wh-pill-alarm { background: var(--status-alarm-ground); color: var(--status-alarm); }

/* §8's label. Deliberately looks like information rather than like a
 * warning: an imported lot is not a problem, its age is just a floor. */
.wh-flag {
  display: inline-block; margin-left: .35rem;
  padding: .05rem .4rem; border-radius: 4px;
  font-size: .68rem; font-weight: 600;
  background: var(--accent-soft); color: var(--accent-deep);
  cursor: help;
}

.wh-note {
  margin: .75rem 0; padding: .65rem .8rem; border-radius: 8px;
  font-size: .85rem;
  background: var(--accent-soft); border-left: 3px solid var(--accent-line);
}
.wh-note-warn { background: var(--status-warning-ground); border-left-color: var(--status-warning); }
.wh-note-alarm { background: var(--status-alarm-ground); border-left-color: var(--status-alarm); }
.wh-note-ok { background: var(--status-running-ground); border-left-color: var(--status-running); }
.wh-note strong { display: block; margin-bottom: .2rem; }

.wh-banner {
  padding: .55rem 1rem; font-size: .85rem; text-align: center;
  background: var(--status-warning-ground); color: var(--status-warning);
  border-bottom: 1px solid var(--brand-line);
}

/* The failed-backup line. The alarm colour, because unlike the licence line
 * this one is a thing that is actually broken and needs somebody to act —
 * and NOT coral: AGENTS.md §2 rule 4, coral is never a status. */
.wh-banner-alarm {
  background: var(--status-alarm-ground); color: var(--status-alarm);
}

.wh-bar {
  height: .55rem; border-radius: 999px; background: var(--accent-soft); overflow: hidden;
}
.wh-bar > span { display: block; height: 100%; background: var(--accent); }

.wh-busy { opacity: .55; pointer-events: none; }

/* ------------------------------------------------------------- the toast
 *
 * "That worked." See app.js's `toast()` for why this exists at all — before
 * stage 5 there was no success feedback anywhere in this client, which is
 * half of why eight identical materials got created.
 *
 * ---- Fixed to the top, under the header, not the bottom-right corner ----
 *
 * The usual place for a toast is bottom-right. Wrong here for two reasons
 * measured on the real screens: the forms that produce a confirmation are at
 * the BOTTOM of a long Setup page, so a bottom-right toast lands over the
 * next field the operator is about to type in; and on a 375 px tablet held
 * in one hand, the bottom third of the screen is where the thumb is. Top,
 * centred, clear of the header is the one position that is visible on both
 * and in the way on neither.
 *
 * ---- Colour is the SECOND signal ----
 *
 * AGENTS.md §2 rule 4. The toast always carries words ("Material added"), so
 * the tint is confirmation of something already said in text. `--status-*`
 * tokens only, never `--brand-coral`, which is never a status.
 *
 * `position: fixed` with `pointer-events: none` on the box and `auto` on the
 * close button: the toast must never swallow a click meant for the screen
 * under it, which a 6-second overlay otherwise does.
 */
/* `left: 0; right: 0; margin-inline: auto; width: fit-content` — NOT
 * `left: 50%; transform: translateX(-50%)`, which is what this was first
 * written as and which the browser caught at 375 px. A fixed element with
 * `width: auto` shrink-wraps to `min(max-content, available)`, and `left:
 * 50%` makes *available* only the remaining half of the viewport — so a
 * two-sentence confirmation came out 188 px wide and 133 px tall on a 375 px
 * tablet, five lines of text in a column, instead of the 343 px the
 * `max-width` was asking for. Measured, not eyeballed; it looked fine at
 * 1400 px because the content fitted either way.
 *
 * `top` comes from `--wh-toast-top`, which app.js sets from the header's own
 * measured height. A fixed 4.25rem was right at desktop and wrong on mobile,
 * where the nav wraps onto its own row and the header is 127 px tall — the
 * toast sat on top of it. The fallback is the desktop value, so a failure to
 * set the variable degrades to the old behaviour rather than to zero. */
.wh-toast {
  position: fixed; z-index: 40;
  top: var(--wh-toast-top, 4.25rem);
  left: 0; right: 0; margin-inline: auto;
  width: fit-content;
  display: flex; align-items: center; gap: .6rem;
  max-width: min(32rem, calc(100vw - 2rem));
  padding: .6rem .5rem .6rem .85rem;
  border-radius: 10px; font-size: .9rem;
  background: var(--brand-surface); color: var(--brand-ink);
  border: 1px solid var(--brand-line);
  border-left: 4px solid var(--accent-line);
  box-shadow: 0 6px 20px rgb(0 0 0 / 18%);
  pointer-events: none;
}

.wh-toast-ok { border-left-color: var(--status-running); background: var(--status-running-ground); }
.wh-toast-warn { border-left-color: var(--status-warning); background: var(--status-warning-ground); }
.wh-toast-alarm { border-left-color: var(--status-alarm); background: var(--status-alarm-ground); }

.wh-toast-body { flex: 1; }
.wh-toast-body strong { font-weight: 600; }

.wh-toast-close {
  pointer-events: auto;
  flex: none; width: 1.75rem; height: 1.75rem;
  display: grid; place-items: center;
  border: 0; border-radius: 6px; background: transparent;
  color: var(--brand-ink-muted); font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.wh-toast-close:hover { background: var(--accent-soft); color: var(--brand-ink); }

/* A print run must never carry a transient overlay onto paper. */
@media print { .wh-toast { display: none !important; } }

/* -------------------------------------------------------------- mobile */

@media (max-width: 48rem) {
  .wh-header { gap: .5rem; }
  .wh-nav { order: 3; width: 100%; }
  .wh-nav a { font-size: .85rem; padding: .35rem .55rem; }
  .wh-main { padding: .85rem; }
  .wh-who-name { display: none; }
}

/* ---------------------------------------------------- the in-place editor
 *
 * A correction opens under the row it corrects, inside the table, rather
 * than on a screen of its own: a correction is almost always one field, and
 * navigating away loses the row the operator was looking at. The cell spans
 * the full row, so the form lays out as a normal form rather than inside one
 * column's width. */
.wh-editor {
  padding: .75rem .25rem;
  border-left: 3px solid var(--accent-line);
  padding-left: .85rem;
}
.wh-editor h3 { margin: 0 0 .5rem; font-size: .95rem; }

/* A destructive action reads as a word with weight, not as a red button.
 * Retiring a material is usually the RIGHT thing to do and a scary button
 * teaches people not to press it — but it is also not undoable in one click,
 * so it is not a plain link either. Colour is the second signal; the label
 * ("retire", "close", "delete") is the first. */
.wh-danger-link {
  border-color: var(--status-alarm);
  color: var(--status-alarm);
  background: transparent;
}
.wh-danger-link:hover { background: var(--status-alarm-ground); }

/* The SMTP conversation on the settings screen.
 *
 * Monospace and scrollable in its own box: it is a protocol transcript, so
 * the alignment of the reply codes down the left is what makes it readable,
 * and a long server banner must scroll inside the box rather than widen the
 * page. `overflow-x: auto` on the element itself, per the rule that wide
 * content scrolls in its own container and the body never does. */
.wh-transcript {
  margin: 0;
  padding: 0.6rem 0.75rem;
  max-height: 20rem;
  overflow: auto;
  font: 0.78rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
  /* No `var(x, fallback)`: every one of these is already used elsewhere in
   * this file, so a fallback here would only hide a token going missing —
   * and AGENTS.md §2 says fix the brand file rather than work around it. */
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

/* The customer's own company name in the header.
 *
 * AGENTS.md §2 rule 5: wozansi is the product, the customer is the site.
 * Quieter than the product name deliberately — it is whose warehouse this
 * is, not what the software is called, and the two must not compete. On a
 * narrow screen the brand block is already tight, so this is the first thing
 * to drop. */
.wh-brand-site {
  display: block;
  font-size: .72rem;
  line-height: 1.2;
  color: var(--brand-ink-muted);
}
@media (max-width: 560px) { .wh-brand-site { display: none; } }

/* ------------------------------------- the printables, ON SCREEN
 *
 * `print.css` is linked `media="print"`, so none of its sizing applies to
 * the preview — and the preview is what the operator actually looks at
 * before pressing Print. Until these rules existed the customer's logo
 * rendered at its stored 1024 px and the small wozansi mark at 72 px,
 * measured in the browser: a page that prints correctly and looks absurd
 * on the way there.
 *
 * Deliberately NOT a copy of print.css's figures. There they are in mm
 * because the target is paper; here they are in rem because the target is a
 * screen, and the two are different questions about the same element rather
 * than one rule written twice. */
.wh-print-head img { max-height: 3rem; width: auto; height: auto; }
.wh-print-head .wh-print-logo { max-height: 3.5rem; max-width: 18rem; display: block; margin-bottom: .4rem; }
.wh-print-company { font-size: 1.05rem; font-weight: 600; margin-bottom: .15rem; }
.wh-print-site { max-width: 32rem; }
.wh-print-credit { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: var(--brand-ink-muted); }
.wh-print-mark { height: 1.1rem; width: auto; }

/* --------------------------------- attached photos and documents (task 40)
 *
 * No hex codes, same as the rest of this file: every colour here is a
 * `--brand-*` or `--status-*` variable. Coral appears nowhere, because a
 * file tile is not a state.
 *
 * `.wh-file-shot` carries a fixed box with `overflow: hidden` and the image
 * inside is `object-fit: contain`. A photograph of a delivery note off a
 * tablet is portrait and one off a phone held sideways is landscape, so a
 * row of tiles that sized itself to its contents would be a row of different
 * heights with the text under each at a different place. `contain` rather
 * than `cover`, because a photo of a document is useless cropped — the batch
 * number is as likely to be at the edge as in the middle.
 *
 * The loading placeholder is the same box, so the tile does not change size
 * when the image arrives and the page does not jump under a thumb. */
.wh-file-row { display: flex; flex-wrap: wrap; gap: 1rem; padding: 1rem 0; }

.wh-file {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  border: 1px solid var(--brand-line);
  border-radius: .5rem;
  padding: .6rem;
  background: var(--brand-surface);
  max-width: 24rem;
}

.wh-file-shot {
  flex: 0 0 auto;
  width: 5.5rem;
  height: 5.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: .35rem;
  background: var(--accent-soft);
}

.wh-file-shot img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* A PDF has no thumbnail — rendering one needs a PDF engine, which is a
 * dependency this product has turned down three times. So it says PDF, in
 * words, which is the second signal the brand rules ask for anyway. */
.wh-file-pdf {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--brand-ink-muted);
}

.wh-file-about { min-width: 0; }
.wh-file-about .wh-actions { margin-top: .35rem; gap: .75rem; }

/* The notes, when they are read rather than edited. `pre-wrap` so the line
 * breaks a storeman typed survive — a note saying what was wrong with three
 * pallets is a list, and reflowing it into one paragraph loses the list. */
.wh-prose {
  white-space: pre-wrap;
  padding: .75rem 0;
  max-width: 44rem;
  line-height: 1.5;
}

@media (max-width: 560px) {
  .wh-file { max-width: 100%; width: 100%; }
}

/* ======================================================= labels, on screen
 *
 * The geometry of a label lives HERE, not in `print.css`, and that is the
 * load-bearing decision in this block.
 *
 * A label is the one artefact in this product whose on-screen rendering is
 * meant to BE the thing: somebody looks at the preview and decides whether
 * the sizing is right before putting label stock in a printer. Keeping the
 * size, padding and type scale in the print stylesheet meant the preview and
 * the print were two different layouts — and this whole task exists because a
 * label looked fine and printed with its barcode 8 mm below the bottom edge.
 * One copy, live on screen. `print.css` adds only the `@page` box and the
 * forced black-on-white.
 *
 * Every dimension comes from a custom property the label screen sets from the
 * server's own `LABEL_SIZES` (see `screens.js`'s `labelVars`), so no size is
 * spelled out in CSS and a fourth size costs no rule here.
 *
 *   --wh-label-w / -h       the PRINTABLE area: paper minus the @page margin
 *   --wh-label-pad          ink-free space inside that
 *   --wh-label-bar-w / -h   the barcode's TRUE size in mm
 *   --wh-label-dt/-dd/-strong/-hero/-rack-hero   the type scale
 */

.wh-label {
  box-sizing: border-box;
  width: var(--wh-label-w);
  height: var(--wh-label-h);
  padding: var(--wh-label-pad);
  margin: 0 0 1rem;
  /* Black on white, in BOTH themes, because that is what comes out of the
   * printer. A preview that follows the dark theme would show white text on a
   * dark card for something that prints black on white, and the one judgement
   * this screen exists to support is "does that look right". */
  background: #fff;
  color: #000;
  /* The edge of the sticker. Removed on paper, where the die cut is the edge. */
  border: 1px solid var(--brand-line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1mm;
  /* VISIBLE, never hidden. Overflow has to show, so a label that does not fit
   * looks wrong on screen instead of looking fine and printing truncated. The
   * old rule was `overflow: hidden`, and it is what let a barcode sit 8 mm
   * below the bottom of its own label with nothing on screen to show for it. */
  overflow: visible;
}

/* The fields block may shrink and must never push the barcode off the label.
 * `min-height: 0` is what lets a flex item shrink below its content size, and
 * its absence is the single declaration behind the original defect. The
 * barcode is `flex: none`, so when something has to give it is the words and
 * not the machine-readable mark. */
.wh-label-fields {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.6mm;
  margin: 0;
  overflow: hidden;
}
.wh-label-fields div { margin: 0; display: block; }
.wh-label-fields dt {
  display: block;
  font-weight: 400;
  font-size: var(--wh-label-dt);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.1;
  opacity: 0.75;
}
.wh-label-fields dd {
  display: block;
  margin: 0;
  font-size: var(--wh-label-dd);
  line-height: 1.15;
}
/* The one or two fields that are the reason somebody is looking at the label
 * at all, sized from the LABEL rather than in points — which is what "legible
 * across a room" actually requires. Measured: a material name 6.2 mm tall on
 * the 100 mm label and 12.4 mm on the 200 mm one. */
.wh-label-fields .wh-label-emphasis dd {
  font-weight: 700;
  font-size: var(--wh-label-hero);
  line-height: 1.05;
}
.wh-label-fields .wh-label-strong dd {
  font-weight: 700;
  font-size: var(--wh-label-strong);
}
.wh-label-mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* A rack label is ONE thing read at distance, so its code fills the label
 * instead of sitting in a list of fields. Measured 29.4 mm tall at 200 x 100. */
.wh-label-rack .wh-label-fields { justify-content: center; }
.wh-label-rack .wh-label-fields .wh-label-emphasis dd {
  font-size: var(--wh-label-rack-hero);
  letter-spacing: -0.01em;
}

/* The barcode is scaled by the SVG's own viewBox, which is in MODULE units —
 * see `server/lib/label.js` for why that is load-bearing and must not change.
 * CSS gives it a box of the TRUE size and nothing else: drawing it at
 * `width: 100%` is what made the narrow bar depend on how long the payload
 * happened to be. `flex: none` so it is never what gets squeezed. */
.wh-label-barcode {
  flex: none;
  width: var(--wh-label-bar-w);
  height: var(--wh-label-bar-h);
  display: block;
  margin: 0 auto;
}
.wh-label-barcode svg { width: 100%; height: 100%; display: block; }

/* The code in words under the bars. A scanner reads the symbol; a person
 * reads this when the symbol is scuffed, and it is the difference between a
 * damaged label and a useless one. */
.wh-label-barcode-text {
  flex: none;
  text-align: center;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: var(--wh-label-dt);
  letter-spacing: 0.08em;
  line-height: 1.1;
  margin-top: 0.5mm;
}

/* No barcode could be drawn — see `routes/labels.js`'s `svgFor`. The label
 * still prints, with the code in words, because a sticker that names the lot
 * is worth having; what it must not do is print bars that will not scan. */
.wh-label-nobarcode {
  flex: none;
  text-align: center;
  font-size: var(--wh-label-dt);
  border: 0.3mm solid #000;
  padding: 1mm;
}

/* The labels' scroll container.
 *
 * A 200 mm label is 756 px and a phone is 375. The label must NOT shrink to
 * fit — it is a physical artefact at an exact size, and a preview that
 * reflowed to the viewport would be lying about the one thing it exists to
 * show. So it overflows, and THIS scrolls rather than the document: a
 * body-level sideways scroll shifts the header and the nav with it.
 * Measured before this existed: documentElement.scrollWidth 558 against a
 * clientWidth of 375. */
.wh-label-sheet {
  overflow-x: auto;
  overflow-y: hidden;
  /* So a label at the far right of the scroll still has its padding. */
  padding-right: 1px;
}
