/**
 * MICS component styles.
 *
 * Tokens live in tokens.css, extracted verbatim from the implementation the theme
 * spec was measured against. This file is the vocabulary built on them: §8 of
 * THEME.MD, plus the layout rules in §6 and the physical constraints in §11.
 *
 * The environment this is designed for is a handheld, held in one hand, in a drug
 * room or a vehicle, by someone who is tired. Not a desk.
 */

@import url("./tokens.css");

/* ── Reset ─────────────────────────────────────────────────────────────── */

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

html, body {
  margin: 0;
  padding: 0;
  /* §6.3: the backstop, not the fix. The four rules below are the fix. */
  overflow-x: clip;
}

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font);
  /* The bottom bar and the home-indicator strip must never cover content. */
  padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + var(--s5));
  -webkit-font-smoothing: antialiased;
  /* §6.3: a GS1 payload or a 32-character product id is otherwise one very wide
     word, and the viewport shifts under a thumb mid-count. */
  overflow-wrap: anywhere;
}

/* §6.3: min-width:auto is the flex default and refuses to shrink below its
   content - the classic cause of a page that scrolls sideways. */
main, .row, .card, .tile, .stack > * { min-width: 0; }

h1, h2, h3, p, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { max-width: 100%; }

/* §13: styled globally, never removed. */
:focus-visible {
  outline: 2px solid var(--brand-text);
  outline-offset: 2px;
  border-radius: 6px;
}
:focus:not(:focus-visible) { outline: none; }

/* ── Layout ────────────────────────────────────────────────────────────── */

main {
  max-width: 820px;
  margin: 0 auto;
  padding: var(--s4) var(--s4) 0;
}

.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s2); }
.row { display: flex; align-items: center; gap: var(--s3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.grow { flex: 1 1 auto; }
.spacer { flex: 1 1 auto; }

/* §6.3: wide content scrolls inside its own card. The page never does. */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Typography ────────────────────────────────────────────────────────── */

h1 { font-size: 21px; font-weight: 720; letter-spacing: -0.02em; line-height: 1.25; }
h2 { font-size: 14.5px; font-weight: 680; }

.hint { font-size: 12.5px; color: var(--muted); line-height: 1.45; }

/* §3.2: --muted is for LABELS, never for a value. */
.lbl {
  font: 750 10px/1.2 var(--font);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.wordmark, .tag {
  font: 750 10.5px/1 var(--font);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.wordmark { color: var(--ink-2); }
.wordmark-lg { font: 750 22px/1 var(--font); letter-spacing: 0.06em; color: var(--ink-2); }
.tagline { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* §7: proportional figures make a column of quantities unreadable, and this
   system is mostly columns of quantities. */
.num, td.num, .stat, .counter, .qty { font-variant-numeric: tabular-nums; }

.stat { font: 730 23px/1.1 var(--font); font-variant-numeric: tabular-nums; }

/* §11: the run counter is read at arm's length while scanning. */
.counter {
  font: 730 48px/1 var(--font);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.mono { font-family: var(--mono); font-size: 13px; }

/* ── Status bar ────────────────────────────────────────────────────────── */
/* §6.1: the top bar carries state you READ. Nothing you press in a hurry. */

.statusbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: calc(env(safe-area-inset-top) + var(--s2)) var(--s4) var(--s2);
  background: color-mix(in srgb, var(--raised) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brandbtn {
  display: flex;
  align-items: center;
  gap: var(--s2);
  background: none;
  border: 0;
  padding: 4px;
  cursor: pointer;
  border-radius: var(--r-sm);
  min-height: var(--tap);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  font: 600 11.5px/1 var(--font);
  color: var(--ink-2);
  white-space: nowrap;
}
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.chip.ok { color: var(--good); background: var(--good-wash); border-color: var(--good-wash); }
.chip.degraded { color: var(--warn); background: var(--warn-wash); border-color: var(--warn-wash); }
.chip.off { color: var(--muted); background: var(--sunken); border-color: var(--line); }
.chip.busy { color: var(--brand-text); background: var(--brand-wash); border-color: var(--brand-edge); }

/* §8: sync age is the first thing dropped on a narrow screen. */
@media (max-width: 430px) { .chip.drop-first { display: none; } }

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  border: 0;
  background: none;
  color: var(--ink-2);
  border-radius: var(--r-sm);
  cursor: pointer;
}
.iconbtn:hover { background: var(--brand-wash); color: var(--brand-text); }
.iconbtn svg { width: 21px; height: 21px; }

/* ── Cards and tiles ───────────────────────────────────────────────────── */

.card {
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--s4);
  box-shadow: var(--shadow);
}

/* §10: every board opens with a conclusion in words, then the evidence. */
.headline {
  background: var(--raised);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--r);
  padding: var(--s4);
  box-shadow: var(--shadow);
}
.headline .sentence { font-size: 16px; font-weight: 600; line-height: 1.4; }
.headline .sentence + .sentence { margin-top: var(--s2); }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--s3);
}

.tile {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  text-align: left;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--s4);
  box-shadow: var(--shadow);
  cursor: pointer;
  min-height: 118px;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--brand-edge); }
.tile:active { transform: translateY(0); }
.tile .ic { color: var(--brand-text); }
.tile .ic svg { width: 24px; height: 24px; }
.tile .name { font: 750 11px/1.2 var(--font); letter-spacing: 0.08em; text-transform: uppercase; }
.tile .sub { font-size: 12.5px; color: var(--muted); }
.tile .stat { margin-top: auto; }

/* ── Rows ──────────────────────────────────────────────────────────────── */

.list { display: flex; flex-direction: column; }

.item {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  text-align: left;
  padding: var(--s3) var(--s2);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  min-height: 56px;
  color: inherit;
}
.item:last-child { border-bottom: 0; }
.item:hover { background: var(--line-soft); }
.item .title { font-weight: 560; }
/* §6.3: detail belonging to a row goes UNDER its subject, not into a column. */
.item .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.item .go { color: var(--muted); flex: none; }
.item .go svg { width: 18px; height: 18px; display: block; }
.item[aria-disabled="true"] { opacity: 1; cursor: default; }

/* ── Buttons ───────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: 11px 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--ink);
  font: 600 13.5px/1.2 var(--font);
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease, transform .06s ease;
}
.btn:hover { background: var(--brand-wash); border-color: var(--brand-edge); }
.btn:active { transform: translateY(1px); }

/* §3.1: a filled control is a PAIR - the fill and the ink on it flip together. */
.btn.primary {
  background: var(--brand-fill);
  border-color: var(--brand-fill);
  color: var(--on-brand);
  font-weight: 680;
  padding: 13px 22px;
}
.btn.primary:hover { background: var(--brand-fill-hover); border-color: var(--brand-fill-hover); }

.btn.danger { color: var(--crit); border-color: var(--crit-wash); }
.btn.danger:hover { background: var(--crit-wash); border-color: var(--crit); }

/**
 * §8: repainted neutral, never faded.
 *
 * A blanket opacity drags the label down at the same rate as the fill, so
 * "Commit" ends up unreadable rather than obviously unavailable.
 */
.btn:disabled,
.btn[aria-disabled="true"] {
  background: var(--sunken);
  border-color: var(--line);
  color: var(--muted);
  cursor: not-allowed;
  transform: none;
}

/* §11: primary actions in the bottom third, at 56px. */
.btn.lg { min-height: 56px; font-size: 15px; padding: 16px 24px; width: 100%; }

/**
 * Actions sit at their natural width, left-aligned.
 *
 * Stretching them to fill the row makes a single button read as an empty input
 * field rather than something to press - and a full-width control implies it is
 * the only thing on the screen, which in an action queue it is not.
 */
.btn-row { display: flex; gap: var(--s2); flex-wrap: wrap; }
.btn-row .btn { flex: 0 1 auto; }

/* ── Inputs ────────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 6px; }

.input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--sunken);
  color: var(--ink);
  /* §11: 16px minimum, or iOS zooms the viewport on focus. */
  font-size: 16px;
  transition: background .14s ease, border-color .14s ease;
}
.input:focus {
  outline: none;
  border-color: var(--brand-edge);
  background: var(--raised);
  box-shadow: 0 0 0 3px var(--brand-wash);
}
.input::placeholder { color: var(--muted); }
.input.num { font-variant-numeric: tabular-nums; }

/* A number that matters is read at arm's length (§11). */
.input.big {
  font: 730 32px/1.2 var(--font);
  font-variant-numeric: tabular-nums;
  text-align: center;
  min-height: 64px;
}

.seg {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--sunken);
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
}
.seg button {
  flex: 1 1 0;
  min-height: 40px;
  border: 0;
  background: none;
  border-radius: 7px;
  font: 600 13px/1 var(--font);
  color: var(--ink-2);
  cursor: pointer;
}
/* §8: a radiogroup marks the choice with aria-checked and a tablist with
   aria-selected, and the control looks identical either way. */
.seg button[aria-checked="true"],
.seg button[aria-selected="true"] {
  background: var(--raised);
  color: var(--brand-text);
  box-shadow: var(--shadow);
}

/* ── Status marks ──────────────────────────────────────────────────────── */
/* §13: never colour alone. Always colour AND icon AND label. */

.mark {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 600 12.5px/1.3 var(--font);
}
.mark .glyph { flex: none; font-size: 12px; }
/* Inside a row each mark is a line of its own, glyph then words, never two
   marks run together on one line. */
.item .mark { display: flex; margin-top: 4px; }
.mark.good { color: var(--good); }
.mark.warn { color: var(--warn); }
.mark.serious { color: var(--serious); }
.mark.crit { color: var(--crit); }

.banner {
  display: flex;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--sunken);
  align-items: flex-start;
}
.banner.warn { background: var(--warn-wash); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.banner.crit { background: var(--crit-wash); border-color: color-mix(in srgb, var(--crit) 35%, transparent); }
.banner.good { background: var(--good-wash); border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.banner .glyph { flex: none; font-weight: 700; }
.banner .body { flex: 1 1 auto; min-width: 0; }
.banner .body strong { display: block; margin-bottom: 2px; }

/* ── Bottom bar ────────────────────────────────────────────────────────── */
/* §6.1: a one-handed device, so the primary controls belong where the thumb is.
   Scanning is centred and raised because it is the primary act of the system. */

.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: flex;
  justify-content: center;
  padding: 0 var(--s3) calc(env(safe-area-inset-bottom) + var(--s2));
  /* Only the inner surfaces catch taps. */
  pointer-events: none;
}

.nav {
  pointer-events: auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  width: 100%;
  max-width: 560px;
  height: var(--bar-h);
  padding: 0 var(--s2);
  background: color-mix(in srgb, var(--raised) 92%, transparent);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}

.nav a, .nav button.navitem {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 48px;
  border: 0;
  background: none;
  border-radius: var(--r-sm);
  color: var(--muted);
  font: 600 10px/1 var(--font);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
}
.nav .navitem svg { width: 22px; height: 22px; }
.nav .navitem[aria-current="page"] { color: var(--brand-text); background: var(--brand-wash); }

/* A gap in the nav where the scan button sits. The button itself is not in the
   nav - see .scanfab - so it can stay reachable above a dialog. */
.nav .scan-slot { min-height: 48px; }

/**
 * The scan button: 56px, teal-filled, with a teal glow.
 *
 * Fixed and ABOVE the dialog scrim, deliberately. §6.1 puts scanning in the
 * centre because it is the primary act of the whole system, and §6.2 keeps it
 * available even while a run holds the shell. A scan button that disappears the
 * moment a dialog asks for a scan is the opposite of that. So it floats over
 * everything, sitting in the notch the nav leaves for it, and it is the same
 * button whether the nav, the process bar, or a dialog is underneath.
 */
.scanfab {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + var(--s2) + 12px);
  transform: translateX(-50%);
  z-index: 200;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  background: var(--brand-fill);
  color: var(--on-brand);
  box-shadow: 0 4px 18px color-mix(in srgb, var(--brand) 45%, transparent);
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease;
}
.scanfab svg { width: 26px; height: 26px; }
.scanfab:hover { box-shadow: 0 6px 24px color-mix(in srgb, var(--brand) 55%, transparent); }
.scanfab:active { transform: translateX(-50%) translateY(2px); }

/* When something is waiting for a scan, the button says so - a slow pulse of
   the glow, nothing more. Still never colour alone: the label beneath changes. */
.scanfab.listening { animation: scan-ready 1.8s ease-in-out infinite; }
@keyframes scan-ready {
  0%, 100% { box-shadow: 0 4px 18px color-mix(in srgb, var(--brand) 45%, transparent); }
  50% { box-shadow: 0 4px 28px color-mix(in srgb, var(--brand) 80%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion=full]) .scanfab.listening { animation: none; }
}

/**
 * Below the scrim when the open dialog is not the one listening: a location
 * picker, a confirmation, Settings. The button is still there, dimmed with
 * everything else, and a tap on it cannot start a second task over the first.
 */
.scanfab.below { z-index: 90; }
.scanfab-label.below { z-index: 91; }

/* The label under the button: what a scan means right now, in two words. */
.scanfab-label {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + var(--s2) + 1px);
  transform: translateX(-50%);
  z-index: 201;
  font: 600 10px/1 var(--font);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand-text);
  pointer-events: none;
  white-space: nowrap;
}

/* Where a dialog is waiting for a scan: a big, calm prompt, not a form field. */
.scan-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  padding: var(--s5) var(--s4);
  border: 2px dashed var(--brand-edge);
  border-radius: var(--r);
  background: var(--brand-wash);
  text-align: center;
}
.scan-prompt .glyph { color: var(--brand-text); }
.scan-prompt .glyph svg { width: 36px; height: 36px; }
.scan-prompt .big { font: 680 16px/1.3 var(--font); }
.scan-prompt .hint { max-width: 32ch; }

/* Progress through a multi-step registration: "which medicine → which pack → label". */
.steps {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s2);
  /* Its own row, clear of the head above and whatever the step asks below. */
  margin: 0 0 var(--s4);
  font: 650 11.5px/1 var(--font);
  color: var(--muted);
}
.steps span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 5px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--sunken);
  white-space: nowrap;
}
/* The number, or the tick once the stage is behind them. */
.steps span::before {
  content: attr(data-n);
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--line);
  color: var(--ink-2);
  font: 750 10px/1 var(--font);
}
.steps .done { color: var(--good); border-color: transparent; background: var(--good-wash); }
.steps .done::before { content: "✓"; background: var(--good); color: #fff; }
.steps .now { color: var(--on-brand); background: var(--brand-fill); border-color: var(--brand-fill); }
.steps .now::before { background: rgba(255, 255, 255, 0.28); color: var(--on-brand); }

/* First-run explainer on Home. Dismissable; never comes back once dismissed. */
.coach { border-left-color: var(--brand); }
.coach ol { margin: var(--s2) 0 0; padding-left: 1.2em; }
.coach li { margin-bottom: var(--s1); }
.coach li:last-child { margin-bottom: 0; }

/* ── User guide ─────────────────────────────────────────────────────────────
   The one place in MICS that is prose. Screens say a sentence and show rows;
   the guide explains a whole task, so it carries its own measure. */
.guide .card p { font-size: 14px; color: var(--ink-2); max-width: 62ch; }
.guide ol.steps { margin: 0; padding-left: 1.3em; font-size: 14px; color: var(--ink-2); line-height: 1.55; max-width: 60ch; }
.guide ol.steps li { margin-bottom: var(--s2); }
.guide ol.steps li:last-child { margin-bottom: 0; }
.guide .card .mark { max-width: 62ch; }

/* ── Settings ───────────────────────────────────────────────────────────────
   One door for everything configured rather than done. A rail beside the
   pane on a desk; on a handheld the list IS the screen (§6.3), a section
   opens over it, and "All settings" is the way back. */
.settings-nav { display: flex; flex-direction: column; gap: 3px; }
.settings-nav > .lbl { margin: var(--s3) var(--s2) var(--s1); }
.settings-nav > .lbl:first-child { margin-top: 0; }
.settings-navitem {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; text-align: left;
  background: var(--raised); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: var(--s2) var(--s3);
  min-height: var(--tap); cursor: pointer;
  font-size: 14px; font-weight: 600;
}
.settings-navitem .ic { display: inline-flex; color: var(--brand-text); }
.settings-navitem .ic svg { width: 20px; height: 20px; }
.settings-navitem[aria-current="page"] { border-color: var(--brand-edge); background: var(--brand-wash); }
.settings-badge {
  flex: none; min-width: 22px; text-align: center;
  font: 700 12px/1 var(--font); font-variant-numeric: tabular-nums;
  padding: 4px 6px; border-radius: var(--r-pill);
}
.settings-badge.warn { color: var(--warn); background: var(--warn-wash); }
.settings-back { margin-bottom: var(--s3); }
@media (max-width: 640px) {
  .settings-layout:not(.open) .settings-pane { display: none; }
  .settings-layout.open .settings-nav { display: none; }
}
@media (min-width: 641px) {
  .settings-layout {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    gap: var(--s4);
    align-items: start;
  }
}

/* ── Shell update banner ────────────────────────────────────────────────────
   A deploy landed while the app was open. Offered, never forced - and never
   while a run holds the shell (§6.2): the reload would drop the basket. */
.update-banner {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: calc(min(820px, 100%) - var(--s4) * 2);
  margin: var(--s3) auto 0;
  padding: var(--s2) var(--s2) var(--s2) var(--s4);
  background: var(--brand-wash);
  border: 1px solid var(--brand-edge);
  border-radius: var(--r);
  color: var(--brand-text);
  font-size: 13.5px;
  font-weight: 600;
}

/* ── Process bar ───────────────────────────────────────────────────────── */
/**
 * §6.2: while a run is open the destinations are REPLACED by the run itself.
 *
 * A safety rule, not a layout preference: tapping a tab mid-run abandons the
 * basket and leaves the door unlocked. Leaving has to be a decision.
 */

.processbar {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  max-width: 560px;
  min-height: var(--bar-h);
  padding: var(--s2) var(--s3);
  background: var(--raised);
  border: 1px solid var(--brand-edge);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}
.processbar .state {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
  flex: none;
}
.processbar .state::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: var(--brand-wash);
}
.processbar .where { font-weight: 620; font-size: 13.5px; }
.processbar .count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.processbar .btn { min-height: 48px; flex: none; }

/* ── Modal ─────────────────────────────────────────────────────────────── */
/* §9.3: one shell for every dialog. */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(6, 14, 14, 0.6);
  backdrop-filter: blur(3px);
  padding: var(--s3);
  animation: scrim-in .18s ease both;
}
@media (min-width: 560px) { .scrim { align-items: center; } }

.panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  max-height: min(84vh, 760px);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: panel-in .2s cubic-bezier(.2, .8, .3, 1) both;
}
.panel .head {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s4);
  border-bottom: 1px solid var(--line);
}
.panel .head h2 { font-size: 16px; font-weight: 660; }
.panel .head .hint { margin-top: 4px; }
.panel .body { padding: var(--s4); overflow-y: auto; flex: 1 1 auto; }
.panel .foot {
  display: flex;
  gap: var(--s2);
  padding: var(--s3) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom));
  background: var(--sunken);
  border-top: 1px solid var(--line);
}
.panel .foot .btn { flex: 1 1 auto; }

@keyframes scrim-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes panel-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* §5: every reduced-motion rule is guarded on :not([data-motion=full]), or the
   Full setting silently fails to honour itself. */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion=full]) .scrim,
  :root:not([data-motion=full]) .panel,
  :root:not([data-motion=full]) .tile { animation: none; transition: none; }
}

/* ── Scan run ──────────────────────────────────────────────────────────── */

.runhead {
  display: flex;
  align-items: baseline;
  gap: var(--s3);
  padding: var(--s4) 0 var(--s2);
}
.runhead .counter { color: var(--ink); }
.runhead .unit { font: 750 11px/1 var(--font); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

/* The scanned list. A line appearing IS the confirmation (§9.2). */
.scanned .item { animation: row-in .22s ease both; }
@keyframes row-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion=full]) .scanned .item { animation: none; }
}

.empty {
  padding: var(--s6) var(--s4);
  text-align: center;
  color: var(--muted);
}
.empty .glyph { color: var(--brand); opacity: .5; }
.empty .glyph svg { width: 40px; height: 40px; }
.empty p { margin-top: var(--s3); font-size: 14px; }

/* ── Lockup ────────────────────────────────────────────────────────────── */

.lockup { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.lockup-text { flex: 1 1 auto; min-width: 0; }
.lockup-words {
  display: flex;
  gap: var(--s2);
  font: 750 9.5px/1 var(--font);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
}
.lockup-words span + span::before { content: "·"; margin-right: var(--s2); }
/* §2.4: below 620px the three words are dropped entirely rather than wrapped. */
@media (max-width: 620px) { .lockup-words { display: none; } }

/* ── Tables ────────────────────────────────────────────────────────────── */
/* §6.3: two columns, not four. At 390px four columns are narrower than the
   words inside them. */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px var(--s2); border-bottom: 1px solid var(--line-soft); }
th { font: 750 10px/1.2 var(--font); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── Boards ────────────────────────────────────────────────────────────── */
/* §10: glance (the sentence) → scan (the figures) → drill (the rows). Each of
   the four destinations is built from these three, in that order. */

.eyebrow {
  font: 750 10.5px/1.2 var(--font);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand-text);
}

/* The sentence is the largest thing on the page, because it is the answer. */
.headline {
  position: relative;
  overflow: hidden;
  padding: var(--s5) var(--s5) var(--s4);
}
.headline::after {
  content: "";
  position: absolute;
  right: -70px;
  bottom: -90px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--brand-wash), transparent);
  pointer-events: none;
}
.headline > * { position: relative; }
.headline .eyebrow { margin-bottom: var(--s2); }
.headline .sentence { font-size: 19px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.35; }
.headline .sentence + .sentence { margin-top: var(--s2); }
.headline .hint { margin-top: var(--s2); max-width: 56ch; }
.headline .btn-row { margin-top: var(--s4); }

/* Figures. A strip of them reads left to right in order of urgency. */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: var(--s2);
}
.kpi {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 6px;
  min-height: 84px;
  padding: var(--s3) var(--s4);
  text-align: left;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  color: inherit;
}
button.kpi { cursor: pointer; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
button.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--brand-edge); }
button.kpi:active { transform: translateY(0); }
.kpi-value { display: flex; align-items: baseline; gap: 5px; min-width: 0; }
.kpi .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value .num { font: 730 30px/1 var(--font); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-value .unit { font: 600 12px/1 var(--font); color: var(--muted); }
.kpi.warn .num { color: var(--warn); }
.kpi.crit .num { color: var(--crit); }
.kpi.good .num { color: var(--good); }

/* Action rows: the ways into a flow. The row is the button. */
.actions { display: flex; flex-direction: column; gap: var(--s2); }
.action {
  display: flex;
  align-items: center;
  gap: var(--s3);
  width: 100%;
  min-height: 76px;
  padding: var(--s3) var(--s4);
  text-align: left;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  color: inherit;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.action:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--brand-edge); }
.action:active { transform: translateY(0); }
.action-ic {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: var(--r-sm);
  background: var(--brand-wash);
  color: var(--brand-text);
  transition: background .16s ease, color .16s ease;
}
.action-ic svg { width: 23px; height: 23px; }
.action-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.action-title { font: 650 15.5px/1.25 var(--font); }
.action-sub { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.action-stat { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.action-stat .num { font: 730 24px/1 var(--font); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.action-stat.warn .num { color: var(--warn); }
.action-stat.crit .num { color: var(--crit); }
.action .go { color: var(--muted); flex: none; }
.action .go svg { width: 18px; height: 18px; display: block; }
/* The most likely next thing is filled, so the eye lands on it first. */
.action.primary { border-color: var(--brand-edge); }
.action.primary .action-ic { background: var(--brand-fill); color: var(--on-brand); }

/* Case number entry on Dispense: big, mono, one field, one button. */
.case-entry { display: flex; gap: var(--s2); }
.case-entry .input {
  flex: 1 1 auto;
  min-height: 56px;
  font: 600 20px/1.2 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.case-entry .input::placeholder { text-transform: none; font: 500 15px/1.2 var(--font); letter-spacing: 0; }
.case-entry .btn { flex: none; min-height: 56px; }
@media (max-width: 430px) { .case-entry { flex-direction: column; } .case-entry .btn { width: 100%; } }

/* A card's title row, with the count at the end. */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); }
.section-head .lbl { flex: none; }

/* Home tiles carry a live figure at the bottom (§8). */
.tile .stat { font-size: 20px; }
.tile .stat .lbl { display: inline; margin-left: 5px; font-size: 10px; }

/* ── Goods in: the batch ───────────────────────────────────────────────── */
/* Set up once, then every label scanned books a pack in. The card is the
   context the operator is working inside, so it reads as a single fact block:
   what, which batch, until when, how many so far. */
.batchcard.active { border-color: var(--brand-edge); }
.batch-facts { display: flex; align-items: flex-start; gap: var(--s3); }
.batch-facts h2 { font-size: 17px; }
.batch-facts .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.batch-count { flex: none; display: flex; flex-direction: column; align-items: flex-end; }
.batch-count .num { font: 730 40px/1 var(--font); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.batch-line { display: flex; gap: var(--s5); flex-wrap: wrap; padding: var(--s2) 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.batch-line > span { display: inline-flex; align-items: baseline; gap: var(--s2); font-weight: 600; }
.batch-line .mono { font-size: 15px; }

/* ── The door (DOOR_ANIMATION.MD) ─────────────────────────────────────── */
/* Ported from door_resources/code/door.css. One deliberate change, per the
   spec's open question in §3.2: the recess is painted from fixed dark values
   rather than --ink, so the cavity stays dark in both themes - it depicts an
   absence of light, not a surface. */
/* The door animation, extracted verbatim from mics_wonder/web/style.css.
   Depends on the MICS design tokens (see ../../theme_resources/code/tokens.css):
   --ink --ink-2 --muted --raised --sunken --line --brand --brand-fill --good --crit
   --s2 --s3 --s4 --s5 --s6 --r-pill */

/* ── the door dialog (§6.4a) ───────────────────────────────────────────────
   A lock has a physical delay you cannot design away, and on the way out a
   human has to actually push the door shut. The picture tracks that state
   rather than decorating it. */
.panel.door-panel{max-width:380px}
.door-body{padding:var(--s6) var(--s5) var(--s5);text-align:center}

.door-art{width:100%;height:150px;margin:0 auto var(--s4);
  display:grid;place-items:center}

/* ── the 3D cabinet ──────────────────────────────────────────────────────
   Perspective is the whole point: a hinge without it is a rectangle getting
   narrower, which is what the flat SVG version actually looked like. The
   distance is short (520px) so the swing is pronounced rather than orthographic.

   Everything here is transform/opacity only, so it composites on the GPU and
   stays smooth on a low-end handheld while the poll runs. */
.door-art{--door-swing:1400ms}  /* read by door.js - the dialog waits this out */
.d3-stage{position:relative;width:126px;height:126px;
  perspective:520px;perspective-origin:38% 46%}

/* the carcass: a dark recess with shelves, revealed as the leaf swings */
.d3-cabinet{position:absolute;inset:0;border-radius:8px;
  background:
    linear-gradient(180deg,rgba(10,18,18,.92),
                          rgba(10,18,18,.74));
  border:1px solid var(--line);overflow:hidden;
  box-shadow:inset 0 0 22px rgba(0,0,0,.55)}
.d3-shelf{position:absolute;left:6px;right:6px;height:3px;border-radius:2px;
  background:color-mix(in srgb,var(--muted) 45%,transparent)}
.d3-shelf:nth-child(1){top:38%}
.d3-shelf:nth-child(2){top:66%}
/* two boxes on the shelves - the cupboard reads as stocked, not empty */
.d3-box{position:absolute;width:26px;height:17px;border-radius:2px;
  background:color-mix(in srgb,var(--brand) 55%,transparent);
  left:16px;top:calc(38% - 17px)}
.d3-box-b{left:52px;width:20px;height:15px;top:calc(66% - 15px);
  background:color-mix(in srgb,var(--muted) 55%,transparent)}

/* the leaf, hinged on its LEFT edge */
.d3-leaf{position:absolute;inset:0;transform-style:preserve-3d;
  transform-origin:left center;
  /* No transition. The swing is a keyframe animation with a known duration,
     so the dialog can WAIT for it - a transition gets cut off the moment the
     next state is painted, which is why the old version barely registered. */
  transition:none}
.d3-face{position:absolute;inset:0;border-radius:8px;backface-visibility:hidden;
  border:1px solid var(--line)}
.d3-front{background:linear-gradient(135deg,
    color-mix(in srgb,var(--raised) 96%,var(--brand)),var(--sunken));
  box-shadow:0 2px 10px rgba(0,0,0,.16)}
/* the reverse of the door, seen once it is more than half open */
.d3-back{transform:rotateY(180deg);
  background:linear-gradient(135deg,var(--sunken),
    color-mix(in srgb,var(--ink) 22%,var(--sunken)))}
/* a sliver of thickness on the opening edge, so the leaf is a slab not a sheet */
.d3-edge{position:absolute;top:0;bottom:0;right:0;width:7px;border-radius:0 8px 8px 0;
  background:color-mix(in srgb,var(--ink) 30%,var(--sunken));
  transform:rotateY(90deg);transform-origin:right center}

.d3-handle{position:absolute;right:9px;top:50%;width:4px;height:22px;
  margin-top:-11px;border-radius:2px;background:var(--ink-2);opacity:.75}
/* the lock: the only thing that moves while UNLOCKING, because the door itself
   has not opened yet - animating the leaf there would be a lie */
.d3-lock{position:absolute;right:22px;top:50%;width:11px;height:11px;
  margin-top:-5.5px;border-radius:50%;
  border:2px solid color-mix(in srgb,var(--ink-2) 60%,transparent);
  display:grid;place-items:center}
.d3-lock i{display:block;width:2px;height:5px;border-radius:1px;
  background:var(--ink-2);transform-origin:center top}

/* ── states ──────────────────────────────────────────────────────────────── */
/* UNLOCKING - the leaf stays shut and the bolt works. It is the lock that is
   busy; the door opens only once the controller says so. */
.door-art[data-state=opening] .d3-lock{border-color:var(--brand);
  animation:d3pulse 1.1s ease-in-out infinite}
.door-art[data-state=opening] .d3-lock i{background:var(--brand);
  animation:d3bolt 1.1s ease-in-out infinite}

/* OPEN - swings wide and stays there */
.door-art[data-state=open] .d3-leaf{transform:rotateY(-104deg)}
.door-art[data-state=open] .d3-lock{border-color:var(--good)}
.door-art[data-state=open] .d3-lock i{background:var(--good)}

/* PLEASE CLOSE - the loop IS the instruction: it shows the door being pushed
   shut and springing back, which is the action being asked for. */
.door-art[data-state=closing] .d3-leaf{transform:rotateY(-104deg)}
/* The "push me" hint moved OFF the leaf and onto the handle. Nudging the door
   itself meant the swing could begin from wherever the loop happened to be,
   and a close that starts anywhere but fully open is a close that looks like it
   started half way through. The handle carries the instruction; the door stays
   honestly where it is. */
.door-art[data-state=closing] .d3-handle{animation:d3handle 1.9s ease-in-out infinite}

/* ── the swings ──────────────────────────────────────────────────────────
   These are the animation. They run ONLY after the controller has actually
   reported, so what you watch is the real event, not a guess - and the dialog
   waits for them to finish before it dismisses. */
.door-art[data-state=swingopen] .d3-leaf{
  animation:d3open var(--door-swing) cubic-bezier(.22,.72,.24,1) forwards}
.door-art[data-state=swingshut] .d3-leaf{
  animation:d3shut var(--door-swing) cubic-bezier(.45,.02,.24,1) forwards}
.door-art[data-state=swingopen] .d3-lock,
.door-art[data-state=swingshut] .d3-lock{border-color:var(--good)}
.door-art[data-state=swingopen] .d3-lock i,
.door-art[data-state=swingshut] .d3-lock i{background:var(--good)}

/* SHUT - closed and latched */
.door-art[data-state=shut] .d3-leaf{transform:rotateY(0deg)}
.door-art[data-state=shut] .d3-lock{border-color:var(--good)}
.door-art[data-state=shut] .d3-lock i{background:var(--good)}

/* FAILED - held ajar, and it shakes once rather than pulsing forever */
.door-art[data-state=failed] .d3-leaf{transform:rotateY(-62deg);
  animation:d3shake .5s ease-in-out 1}
.door-art[data-state=failed] .d3-front{border-color:var(--crit)}
.door-art[data-state=failed] .d3-lock{border-color:var(--crit)}
.door-art[data-state=failed] .d3-lock i{background:var(--crit)}

/* Waiting to be closed: the HANDLE hints at the push. Small, on a small
   element, and it leaves the leaf sitting exactly where the closing swing
   starts - so the two join seamlessly. */
@keyframes d3handle{
  0%,100%{transform:translateX(0);opacity:.75}
  50%    {transform:translateX(-5px);opacity:1}
}
/* Opening: swings past and settles back, the way a door on a sprung hinge does */
@keyframes d3open{
  0%   {transform:rotateY(0deg)}
  70%  {transform:rotateY(-112deg)}
  100% {transform:rotateY(-104deg)}
}
/* The reduced-motion pair. Same journey, slower, and with the bounce taken out
   - the overshoot and the latch rebound are the parts most likely to bother
   someone who asked for less movement, not the travel itself. */
@keyframes d3openCalm{
  0%{transform:rotateY(0deg)} 100%{transform:rotateY(-104deg)}
}
@keyframes d3shutCalm{
  0%{transform:rotateY(-104deg)} 100%{transform:rotateY(0deg)}
}
/* Closing: travels, then a short rebound as it meets the frame and latches */
@keyframes d3shut{
  0%   {transform:rotateY(-104deg)}
  78%  {transform:rotateY(-2deg)}
  88%  {transform:rotateY(-9deg)}
  100% {transform:rotateY(0deg)}
}
@keyframes d3bolt{
  0%,100%{transform:translateX(0) scaleY(1)}
  50%    {transform:translateX(-3px) scaleY(.55)}
}
@keyframes d3pulse{
  0%,100%{box-shadow:0 0 0 0 color-mix(in srgb,var(--brand) 55%,transparent)}
  70%    {box-shadow:0 0 0 7px transparent}
}
@keyframes d3shake{
  0%,100%{transform:rotateY(-62deg)}
  25%    {transform:rotateY(-56deg)}
  75%    {transform:rotateY(-68deg)}
}

/* §20.6 - every animation has a no-motion equivalent. The door still shows the
   right POSITION, it simply does not travel there. */
@media (prefers-reduced-motion:reduce){
  /* Every rule here is guarded on :not([data-motion=full]) so a user who
     explicitly asks for animation gets it even when the OS says otherwise -
     their own setting is a more specific statement of intent than the
     system-wide one (§20.2d). */
  :root:not([data-motion=full]) .d3-leaf{transition:none}

  /* The handle hint is a LOOP, and loops are the part this setting most
     reliably exists to stop. The leaf itself needs nothing disabled - it
     already rests at -104deg, exactly where the closing swing begins. */
  :root:not([data-motion=full]) .door-art[data-state=closing] .d3-handle{animation:none}

  /* The swings still RUN. "Reduced" is not "none": what the setting guards
     against is fast, large-area, parallax and above all REPEATING motion, and
     the loops are all disabled above. A single slow travel across a 126px
     square is none of those, and is gentler than a jump cut - it is also the
     one moment the user is here to see. So: slower, and without the overshoot
     or the latch rebound. The script reads --door-swing, so its wait lengthens
     to match automatically. */
  :root:not([data-motion=full]) .door-art{--door-swing:1900ms}
  :root:not([data-motion=full]) .door-art[data-state=swingopen] .d3-leaf{
    animation-name:d3openCalm;animation-timing-function:cubic-bezier(.33,0,.2,1)}
  :root:not([data-motion=full]) .door-art[data-state=swingshut] .d3-leaf{
    animation-name:d3shutCalm;animation-timing-function:cubic-bezier(.33,0,.2,1)}
  :root:not([data-motion=full]) .door-art[data-state=failed] .d3-leaf{animation:none}
  :root:not([data-motion=full]) .door-art[data-state=opening] .d3-lock,
  :root:not([data-motion=full]) .door-art[data-state=opening] .d3-lock i{animation:none}
}

.door-body h2{font-size:19px;font-weight:720;letter-spacing:-.02em}
.door-where{color:var(--muted);font-size:12.5px;margin-top:3px}
.door-say{color:var(--ink-2);font-size:14px;margin-top:var(--s3);min-height:1.5em}

/* an indeterminate wait - it does NOT pretend to know how long the lock takes */
.door-bar{height:4px;border-radius:var(--r-pill);background:var(--sunken);
  overflow:hidden;margin-top:var(--s4)}
.door-bar span{display:block;height:100%;border-radius:var(--r-pill);
  background:var(--brand-fill)}
.door-bar span.working{width:40%;animation:doorslide 1.15s ease-in-out infinite}
.door-bar span.done{width:100%;background:var(--good);transition:width .3s}
.door-bar span.failed{width:100%;background:var(--crit)}
@keyframes doorslide{
  0%{transform:translateX(-100%)} 100%{transform:translateX(250%)}}
@media (prefers-reduced-motion:reduce){
  :root:not([data-motion=full]) .door-bar span.working{animation:none;width:100%;opacity:.5}}

.door-foot{display:flex;justify-content:flex-end;gap:var(--s2);padding:var(--s3) var(--s4);background:var(--sunken);border-top:1px solid var(--line)}
.door-foot .btn{flex:1 1 auto}



/* The failure actions exist only in the failed state. display:flex above would
   otherwise beat the hidden attribute. */
.door-foot[hidden] { display: none; }

/* ── Monitor and reports ───────────────────────────────────────────────── */
.report-params { padding: var(--s3) var(--s4); }
.report-params .field { flex-direction: row; align-items: center; gap: var(--s3); }
.report-params .field .lbl { flex: 0 0 110px; }
.report-params .input { flex: 1 1 auto; }

/* §6.3: a real table on a desk, scrolling inside its card; on a handheld each
   row is its subject with the detail under it. */
.report-table { min-width: 640px; }
.report-table th { white-space: nowrap; }
.report-table td { vertical-align: top; font-size: 13px; }
.report-table td.mark-cell { font-weight: 650; color: var(--warn); }
.wide-only { display: block; }
.narrow-only { display: none; }
@media (max-width: 640px) {
  .wide-only { display: none; }
  .narrow-only { display: flex; }
}

/* ── Forms in administration ───────────────────────────────────────────── */
.check { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s2) 0; cursor: pointer; font-size: 14px; line-height: 1.4; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brand-fill); flex: none; }
select.input { appearance: auto; }

.item .lbl { white-space: nowrap; }

/* Signed out, there is nothing to scan into. display above would otherwise beat hidden. */
.scanfab[hidden], .scanfab-label[hidden] { display: none; }

/* ── Administration ────────────────────────────────────────────────────── */
/* A statement with a control beside it, not a checkbox with a sentence. */
.setting { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line-soft); }
.setting:last-child { border-bottom: 0; }
.setting .what { flex: 1 1 auto; min-width: 0; }
.setting .what .title { font-weight: 600; font-size: 14.5px; }
.setting .what .hint { margin-top: 2px; }
.setting .seg { flex: 0 0 auto; width: auto; min-width: 220px; }
.setting .input { flex: 0 0 110px; text-align: right; }
@media (max-width: 520px) { .setting { flex-direction: column; align-items: stretch; } .setting .seg, .setting .input { width: 100%; flex: 1 1 auto; } }

/* Labels in admin forms are sentences, not tags. */
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.form-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }

/* The one time a password is shown. Big, mono, copyable, unmistakable. */
.secret { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--r); background: var(--sunken); }
.secret .val { font: 700 22px/1.2 var(--mono); letter-spacing: 0.06em; overflow-wrap: anywhere; }
.secret .lbl { margin-bottom: 2px; }

/* A dangerous action lives in its own card, apart from Save. */
.danger-zone { border-color: color-mix(in srgb, var(--crit) 35%, transparent); }
.danger-zone .btn.danger { align-self: flex-start; }

.role-chip { text-transform: none; letter-spacing: 0; }

/* A segmented control with more than three choices wraps to rows rather than clipping. */
.seg.wrap { display: flex; flex-wrap: wrap; }
.seg.wrap button { flex: 1 1 30%; min-width: 120px; }

/* ── Sign in ───────────────────────────────────────────────────────────── */

/**
 * One narrow column, centred. A sign-in form stretched across the 820px main
 * column reads as a settings page; 400px holds a user name comfortably and
 * nothing else, which is the point.
 */
.signin {
  max-width: 400px;
  margin: 0 auto;
  padding-top: clamp(var(--s4), 6vh, 56px);
  display: flex;
  flex-direction: column;
  gap: var(--s5);
}
.signin-brand .lockup { justify-content: center; }
.signin-brand .lockup-text { flex: 0 1 auto; }
/* The three words are brand copy for a board, not for a door. */
.signin-brand .lockup-words { display: none; }
.signin-head { display: flex; flex-direction: column; gap: 4px; }
.signin-form { display: flex; flex-direction: column; gap: var(--s3); }
.signin-form .btn.lg { margin-top: var(--s2); }
.signin-links { display: flex; justify-content: center; }

/**
 * Why the sign-in failed, above the button, in the line of sight.
 *
 * Red when it is worth attention (wrong password, locked, the system down);
 * calm when the person merely left a field empty or the network is away,
 * which is a state, not a fault.
 */
.signin-problem {
  padding: var(--s3) var(--s4);
  border-radius: var(--r-sm);
  border: 1px solid color-mix(in srgb, var(--crit) 35%, transparent);
  border-left: 3px solid var(--crit);
  background: var(--crit-wash);
  font-size: 13.5px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.signin-problem strong { display: block; color: var(--crit); margin-bottom: 2px; }
.signin-problem .mono { margin-top: var(--s2); font-size: 12px; color: var(--muted); }
.signin-problem.calm { background: var(--sunken); border-color: var(--line); border-left-color: var(--muted); }
.signin-problem.calm strong { color: var(--ink); }
.signin-problem[hidden] { display: none; }

/* A quiet, text-only action: for the one thing on a screen that is not the job. */
.btn.link {
  background: transparent;
  border-color: transparent;
  color: var(--brand);
  padding: 8px 12px;
}
.btn.link:hover { background: var(--brand-wash); border-color: transparent; }

/* Two steps, one column: the button does not move when the step changes. */
.signin-step { display: flex; flex-direction: column; gap: var(--s4); }

/* Step two names who is signing in, with the way back beside it. */
.signin-who {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  background: var(--sunken);
  border: 1px solid var(--line);
}
.signin-who .who { font-weight: 640; overflow-wrap: anywhere; }
.signin-who .btn.link { flex: none; padding: 6px 10px; min-height: 0; }

/* ── The pack card: what a scanned pack is, before choosing what to do ──── */
.packfacts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3) var(--s4); margin-bottom: var(--s4); }
.packfact .val { font-size: 15px; font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }


/* ── Scanned lists grouped by batch ─────────────────────────────────────── */
/**
 * A carton of twenty is one thing with twenty labels on it, so the list says
 * so: one head per medicine, batch and expiry, the labels beneath. A box from
 * another batch gets its own head, which is how it is noticed. The group the
 * run is currently working through is edged in the brand colour.
 */
.batchgroup + .batchgroup { margin-top: var(--s3); }
.batchgroup-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-sm);
  background: var(--sunken);
  border-left: 3px solid var(--line);
}
.batchgroup.active .batchgroup-head { border-left-color: var(--brand); background: var(--brand-wash); }
.batchgroup-head .title { font-weight: 620; }
.batchgroup-head .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.batchgroup-head .eyebrow { margin-bottom: 2px; }
.batchgroup-head .tally { flex: none; text-align: right; font-variant-numeric: tabular-nums; }
.batchgroup-head .tally .stat { font-size: 18px; font-weight: 700; line-height: 1; }
.batchgroup-head .tally .lbl { margin-top: 2px; }
.batchgroup .list { padding-left: var(--s3); }
.batchgroup .item { padding-top: 8px; padding-bottom: 8px; }
.batchgroup .item .title { font-family: var(--mono); font-size: 13px; font-weight: 500; }

/* dm+d matches offered under the name field, as it is typed. */
.dmd-suggestions { border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--raised); max-height: 260px; overflow-y: auto; }
.dmd-suggestions[hidden] { display: none; }


/* ── The splash ─────────────────────────────────────────────────────────── */
/* Shown from the first paint; the app's first render fades it away. */
#splash {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--ground);
  color: var(--ink);
  transition: opacity .28s ease;
}
#splash.leaving { opacity: 0; pointer-events: none; }
#splash svg { margin-bottom: 6px; }
.splash-wordmark { font-size: 28px; font-weight: 800; letter-spacing: .18em; }
.splash-tagline { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.splash-version { margin-top: 14px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 16px; }
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion=full]) #splash { transition: none; }
}


/* ── Activity trail ─────────────────────────────────────────────────────── */
.activity-range { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.activity-range select { flex: 1 1 160px; }
.activity-range input[type="date"] { flex: 0 1 150px; }
.activity-range .lbl { flex: none; }

/* An inline-flex button still honours the hidden attribute. */
.btn[hidden] { display: none; }
