/* InvSys application styles, built on the Nocturne tokens in nocturne.css.
   The prototype's inline styles live here as classes. Colours, fonts, spacing, radii and
   shadows come from Nocturne tokens; sizes are in rem. The :root block below holds the only two
   exceptions, both values Nocturne does not carry:
   1. layout dimensions in px (and the physical label sizes in mm);
   2. the tone tokens. Nocturne is a mono palette and cannot tell the 7 item statuses, or a
      warning from a failure, apart; these are the prototype's exact OKLCH values (its TONE map
      plus the In Repair dot). */

:root {
  --app-sidebar-width: 236px; /* the prototype's sidebar */
  --app-touch-target: 44px; /* minimum height of a mobile touch target */
  --app-drawer-width: 400px; /* the prototype's notification drawer */
  --app-category-tree-basis: 520px; /* the prototype's category tree column */
  --app-category-form-basis: 280px; /* the prototype's "Add a category" card */
  --app-settings-card-max: 640px; /* the prototype's settings card */
  --app-item-photo-width: 280px; /* the prototype's S-03 photo column */
  --app-form-max: 880px; /* the item form's reading width (WW-05) */
  --app-stock-search-max: 320px; /* the Stock search field (AM-02, CA-11) */
  --app-purchase-settings-max: 980px; /* the prototype's CA-07 column */
  --app-po-side-width: 360px; /* the prototype's AM-10 hint column */
  --app-camera-layer: 60; /* the full-screen camera sits above the tab bar and the alerts */

  /* Physical label sizes (F-25): the Avery L7160 / J8160 A4 sheet of 3 x 7 labels, and a
     50 x 25 mm thermal roll. The @page rules in the labels section repeat these literally,
     because @page cannot read custom properties. */
  --label-sheet-width: 210mm;
  --label-sheet-height: 297mm;
  --label-sheet-margin-top: 15.15mm;
  --label-sheet-margin-side: 7.25mm;
  --label-width: 63.5mm;
  --label-height: 38.1mm;
  --label-gap: 2.54mm;
  --label-roll-width: 50mm;
  --label-roll-height: 25mm;
  --label-padding: 2mm;
  --label-line-gap: 0.5mm;
  /* Labels print black on white whatever the screen theme. */
  --label-ink: black;
  --label-paper: white;
  --app-font-mono: ui-monospace, monospace; /* the sticker code on a label */

  --tone-ok: oklch(0.76 0.11 155);
  --tone-warn: oklch(0.82 0.12 85);
  --tone-caution: oklch(0.76 0.13 55);
  --tone-bad: oklch(0.7 0.15 25);
  --tone-info: oklch(0.76 0.1 235);
}

/* Tone classes set only a local --tone; each component decides where it paints it. */
.tone-ok { --tone: var(--tone-ok); }
.tone-warn { --tone: var(--tone-warn); }
.tone-caution { --tone: var(--tone-caution); }
.tone-bad { --tone: var(--tone-bad); }
.tone-info { --tone: var(--tone-info); }
.tone-accent { --tone: var(--color-accent); }
.tone-accent-soft { --tone: var(--color-accent-200); }
.tone-mute { --tone: var(--color-neutral-500); }

[x-cloak] {
  display: none !important;
}

html {
  color-scheme: dark;
  scrollbar-color: var(--color-neutral-700) transparent;
}

html,
body {
  height: 100%;
}

a {
  color: var(--color-accent-300);
}

a:hover {
  color: var(--color-accent-200);
}

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

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 100;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  transform: translateY(-200%);
}

.skip-link:focus-visible {
  transform: none;
}

/* — alert region (HTMX error fragments are swapped in here) — */
.app-alerts {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(26rem, calc(100% - 2 * var(--space-6)));
}

.app-alerts:empty {
  display: none;
}

/* — htmx request indicators. htmx used to inject these rules as a <style>; the CSP's
   `style-src 'self'` forbids that (`includeIndicatorStyles: false` in base.html). — */
.htmx-indicator {
  opacity: 0;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
  transition: opacity 200ms ease-in;
}

/* — slow networks (F-92): the global progress bar and the offline banner (app.js) — */
.app-progress {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 60;
  height: 0.1875rem;
  background: var(--color-accent);
  transform: scaleX(0);
  transform-origin: left;
  opacity: 0;
  pointer-events: none;
}

.app-progress.is-active {
  opacity: 1;
  animation: app-progress 1.6s ease-out infinite;
}

@keyframes app-progress {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(0.9);
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-progress.is-active {
    animation: none;
    transform: scaleX(1);
  }
}

.app-offline {
  --tone: var(--tone-warn);
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: 0.8125rem;
  color: var(--color-text);
  background: var(--color-surface);
  box-shadow: inset 0 -0.1875rem 0 var(--tone);
}

.app-offline[hidden] {
  display: none;
}

/* — the offline page (pwa/offline.html) — */
.offline-page {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
}

.offline-icon {
  font-size: 2.5rem;
  color: var(--tone-warn);
}

/* — a mobile form's primary action, kept above the tab bar while the form scrolls — */
.m-action-bar {
  position: sticky;
  bottom: calc(var(--app-touch-target) + var(--space-4) + env(safe-area-inset-bottom));
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  background: var(--color-bg);
}

.alert {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-md), inset 0.1875rem 0 0 var(--color-accent);
}

.alert-title {
  font-weight: 500;
}

.alert-detail {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--color-neutral-300);
}

.alert-fields {
  margin: 0;
  padding-left: var(--space-6);
  font-size: 0.8125rem;
  color: var(--color-neutral-300);
}

/* — desktop shell — */
.app-shell {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  font-size: 0.875rem;
  color: var(--color-text);
  background: var(--color-bg);
}

.app-sidebar {
  position: relative;
  z-index: 3;
  display: flex;
  flex: none;
  flex-direction: column;
  width: var(--app-sidebar-width);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-6) var(--space-6) var(--space-4);
}

.app-brand-mark {
  display: grid;
  flex: none;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 0.1rem solid var(--color-accent);
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-accent-300);
}

.app-brand-text {
  min-width: 0;
}

.app-brand-name {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.1;
}

.app-brand-company {
  overflow: hidden;
  font-size: 0.6875rem;
  color: var(--color-neutral-500);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.app-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-3);
  overflow: auto;
}

.app-nav-section {
  display: flex;
  flex-direction: column;
  gap: 0.0625rem;
}

.app-nav-label {
  padding: var(--space-2) var(--space-3);
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-neutral-500);
}

.app-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: 0.4375rem var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--color-neutral-300);
  text-decoration: none;
}

.app-nav-item:hover {
  color: var(--color-neutral-200);
  background: color-mix(in srgb, var(--color-text) 6%, transparent);
}

.app-nav-item[aria-current="page"] {
  color: var(--color-accent-100);
  background: var(--color-accent-900);
  box-shadow: inset 0.125rem 0 0 var(--color-accent);
}

.app-nav-item .ph {
  font-size: 1rem;
}

.app-nav-text {
  flex: 1;
}

.app-nav-badge {
  min-width: 1.125rem;
  padding: 0.0625rem 0.375rem;
  border-radius: 0.5625rem;
  font-size: 0.6875rem;
  text-align: center;
  color: var(--color-accent-100);
  background: var(--color-accent-800);
}

.app-user {
  position: relative;
  padding: var(--space-3);
  box-shadow: 0 -0.0625rem 0 var(--color-divider);
}

.app-user:empty {
  display: none;
}

.app-main-column {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.app-topbar {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--space-4);
  height: 3.5rem;
  padding: 0 var(--space-8);
  box-shadow: 0 0.0625rem 0 var(--color-divider);
}

.app-topbar-spacer {
  flex: 1;
}

.app-main {
  /* The containing block for absolutely positioned content (.sr-only text, segmented radios,
     file inputs): without it they are placed against the page, stretch the document past the
     viewport and make the whole shell scroll when they receive focus. */
  position: relative;
  flex: 1;
  padding: var(--space-8) var(--space-8) 4rem;
  overflow: auto;
}

.app-container {
  max-width: 82.5rem;
}

/* — page header — */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.page-header-text {
  flex: 1;
  min-width: 15rem;
}

.page-kicker {
  margin-bottom: var(--space-2);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-accent-300);
}

.page-title {
  margin: 0;
  font-size: 1.625rem;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* — mobile shell — */
.m-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  font-size: 0.875rem;
  color: var(--color-text);
  background: var(--color-bg);
}

.m-topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 3.5rem;
  padding: 0 var(--space-6);
  padding-top: env(safe-area-inset-top);
  background: var(--color-surface);
  box-shadow: 0 0.0625rem 0 var(--color-divider);
}

.m-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: 1.0625rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.m-main {
  flex: 1;
  padding: var(--space-6) var(--space-6)
    calc(var(--app-touch-target) + var(--space-8) + env(safe-area-inset-bottom));
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 3;
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--color-surface);
  box-shadow: 0 -0.0625rem 0 var(--color-divider);
}

.tabbar-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-width: 0;
  min-height: var(--app-touch-target);
  padding: var(--space-2) var(--space-1);
  font-size: 0.6875rem;
  color: var(--color-neutral-400);
  text-decoration: none;
}

.tabbar-item:hover {
  color: var(--color-neutral-200);
}

.tabbar-item[aria-current="page"] {
  color: var(--color-accent-300);
  box-shadow: inset 0 0.125rem 0 var(--color-accent);
}

.tabbar-item .ph {
  font-size: 1.375rem;
}

.tabbar-label {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tabbar-badge {
  position: absolute;
  top: var(--space-1);
  left: 50%;
  transform: translateX(0.5rem);
  min-width: 1rem;
  padding: 0 0.25rem;
  border-radius: 0.5rem;
  font-size: 0.625rem;
  text-align: center;
  color: var(--color-bg);
  background: var(--color-accent);
}

/* — error page — */
.error-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--space-8);
}

.error-card {
  width: min(28rem, 100%);
  padding: var(--space-8);
  gap: var(--space-3);
}

.error-title {
  margin: 0;
  font-size: 1.625rem;
}

.error-detail {
  margin: 0;
  color: var(--color-neutral-300);
}

/* ══════ Shared components (templates/components/) ══════ */

/* — empty state — */
.empty-state {
  align-items: flex-start;
  padding: var(--space-6);
  font-size: 0.8125rem;
  color: var(--color-neutral-400);
  background: transparent;
  box-shadow: inset 0 0 0 0.0625rem var(--color-divider);
}

.empty-state-icon {
  font-size: 1.5rem;
  color: var(--color-neutral-500);
}

.empty-state .card-title {
  font-size: 1rem;
  color: var(--color-text);
}

/* — chips — */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3125rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  line-height: 1;
  white-space: nowrap;
  color: var(--color-neutral-200);
  background: var(--color-neutral-900);
}

.chip-dot {
  flex: none;
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 50%;
  background: var(--tone);
}

.state-dot {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  white-space: nowrap;
}

.badge-booked {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.4375rem;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  line-height: 1;
  white-space: nowrap;
  color: var(--color-accent-300);
  box-shadow: inset 0 0 0 0.0625rem var(--color-accent-600);
}

/* — project stepper — */
.stepper {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.stepper-step {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.stepper-bar {
  height: 0.1875rem;
  border-radius: 0.125rem;
  background: var(--color-neutral-800);
}

.stepper-text {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.stepper-num {
  font-size: 0.6875rem;
  /* neutral-600 failed WCAG AA contrast on the surface (F-92 audit). */
  color: var(--color-neutral-500);
}

.stepper-label {
  font-size: 0.8125rem;
  line-height: 1.3;
  color: var(--color-neutral-500);
}

.stepper-step.is-done .stepper-bar {
  background: var(--color-accent-600);
}

.stepper-step.is-done .stepper-label {
  color: var(--color-neutral-400);
}

.stepper-step.is-current .stepper-bar {
  background: var(--color-accent);
}

.stepper-step.is-current .stepper-num {
  color: var(--color-accent-300);
}

.stepper-step.is-current .stepper-label {
  font-weight: 500;
  color: var(--color-text);
}

.stepper.is-compact {
  gap: var(--space-1);
}

.stepper-current {
  margin-top: var(--space-2);
  font-size: 0.75rem;
  color: var(--color-neutral-300);
}

/* — data table — */
.data-table {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.data-table-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}

.data-table-scroll {
  overflow-x: auto;
}

.data-table .table th,
.data-table .table td {
  white-space: nowrap;
}

.table th.is-end,
.table td.is-end {
  text-align: right;
}

.table-loading {
  height: 0.125rem;
  border-radius: 0.0625rem;
  background: linear-gradient(90deg, transparent, var(--color-accent), transparent) no-repeat;
  background-size: 50% 100%;
  animation: table-loading 1s linear infinite;
}

/* Hidden from assistive technology except while a request runs. */
.table-loading:not(.htmx-request) {
  visibility: hidden;
}

@keyframes table-loading {
  from {
    background-position: -100% 0;
  }
  to {
    background-position: 200% 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .table-loading {
    animation: none;
    background: var(--color-accent);
  }
}

.table th .sort-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: inherit;
  text-decoration: none;
}

.table th .sort-link:hover,
.table th[aria-sort="ascending"] .sort-link,
.table th[aria-sort="descending"] .sort-link {
  color: var(--color-text);
}

.table th .sort-link .ph {
  font-size: 0.875rem;
  opacity: 0.7;
}

.table th.is-end .sort-link {
  flex-direction: row-reverse;
}

.table tbody tr.is-clickable {
  cursor: pointer;
}

.cell-sub {
  font-size: 0.75rem;
  color: var(--color-neutral-500);
}

/* A sub-line that warns: an expiry or an inspection due soon, or past. */
.cell-sub.cell-tone-warn {
  color: var(--tone-warn);
}

.cell-sub.cell-tone-bad {
  color: var(--tone-bad);
}

.cell-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* A muted line under the page header that says what the page is for. */
.page-subtitle {
  margin: calc(var(--space-4) * -1) 0 var(--space-6);
  font-size: 0.875rem;
  color: var(--color-neutral-400);
}

/* The main text of a cell (a name or a code), above a .cell-sub line. */
.cell-strong {
  font-weight: 500;
  color: var(--color-neutral-100);
}

/* Icon actions at the end of a row; posting actions are tiny forms. */
.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-1);
}

.row-action {
  display: inline-flex;
}

/* Removable chips, e.g. a warehouse's zones. */
.chip-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  min-height: 2rem;
}

.zone-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.zone-chip-remove {
  display: inline-flex;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: pointer;
  opacity: 0.7;
}

.zone-chip-remove:hover {
  opacity: 1;
}

.zone-add {
  display: flex;
  gap: var(--space-2);
}

.zone-add .input {
  flex: 1;
}

/* Categories (F-15): the tree beside the add card. */
.category-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-8);
}

.category-tree {
  flex: 1 1 var(--app-category-tree-basis);
  min-width: 0;
}

.category-add {
  flex: 0 1 var(--app-category-form-basis);
}

.category-group {
  margin: 0;
  padding: 0;
  list-style: none;
}

.category-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
}

.category-row:hover {
  background: var(--color-neutral-800);
}

.category-row[data-level="2"] {
  padding-left: calc(var(--space-3) + var(--space-8));
}

.category-row[data-level="3"] {
  padding-left: calc(var(--space-3) + var(--space-8) * 2);
}

.category-name {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.category-row[data-level="1"] .category-name {
  font-weight: 500;
}

.category-interval {
  font-size: 0.75rem;
  color: var(--color-neutral-500);
  white-space: nowrap;
}

/* A date input's focus sits on its inner day, month and year segments, where Chrome does not
   match :focus-visible on the input itself: show the ring whenever the input holds the focus. */
.input[type="date"]:focus-within {
  outline: 0.125rem solid var(--color-accent);
  outline-offset: 0;
}

/* A fieldset that only groups (and can disable) fields, without its own box (F-102). */
.fieldset-plain {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

/* Settings pages (F-16): label block on the left, the input on the right. */
.settings-card {
  max-width: var(--app-settings-card-max);
  gap: var(--space-4);
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-top: 0.0625rem solid var(--color-neutral-800);
}

.settings-label label {
  font-weight: 500;
}

.input-suffixed {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.input-suffixed .input {
  width: 6rem;
}

.input-suffix {
  font-size: 0.875rem;
  color: var(--color-neutral-500);
}

@media (max-width: 40rem) {
  .settings-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Cards stacked on a detail page (company detail). */
.detail-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.detail-stack > .card {
  gap: var(--space-4);
}

/* Form rows of two or three fields side by side; one column on narrow screens. */
.form-grid-2,
.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 40rem) {
  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }
}

.data-table-empty td {
  padding: var(--space-4) 0;
  white-space: normal;
}

.data-table-error td {
  white-space: normal;
}

.data-table-error-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  font-size: 0.8125rem;
}

.data-table-error-body > .ph {
  font-size: 1rem;
  color: var(--tone-bad);
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: 0.8125rem;
}

.pagination-summary {
  color: var(--color-neutral-400);
}

.pagination-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
}

.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-width: 2rem;
  height: 2rem;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--color-neutral-300);
  text-decoration: none;
}

.page-link:hover:not(.is-disabled) {
  color: var(--color-text);
  background: color-mix(in srgb, var(--color-text) 7%, transparent);
}

.page-link[aria-current="page"] {
  color: var(--color-accent-100);
  background: var(--color-accent-900);
  box-shadow: inset 0 0 0 0.0625rem var(--color-accent-700);
}

.page-link.is-disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.page-gap {
  padding: 0 var(--space-1);
  color: var(--color-neutral-500);
}

/* — column picker — */
.column-picker {
  position: relative;
}

.column-picker-popover {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  z-index: 10;
  min-width: 14rem;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
}

.column-picker-popover fieldset {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.column-picker-title {
  margin-bottom: var(--space-2);
  padding: 0;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-neutral-500);
}

.column-picker-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.8125rem;
  cursor: pointer;
}

.column-picker-option input,
.checkbox input {
  accent-color: var(--color-accent);
}

/* The Stock export dialog's column boxes (F-136): two columns of options. */
.export-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2) var(--space-4);
}

.export-column-actions {
  display: flex;
  gap: var(--space-2);
}

/* — form fields — */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

fieldset.field {
  margin: 0;
  padding: 0;
  border: 0;
}

.field-label,
.field > legend {
  display: block;
  margin-bottom: 0.3125rem;
  padding: 0;
  font-size: 0.75rem;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
}

.field-required {
  margin-left: 0.125rem;
  color: var(--color-accent-300);
}

.field-hint {
  margin: var(--space-1) 0 0;
  font-size: 0.75rem;
  color: var(--color-neutral-500);
}

.field-error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-1);
  margin: var(--space-1) 0 0;
  font-size: 0.75rem;
  color: var(--tone-bad);
}

.field-error .ph {
  margin-top: 0.125rem;
}

.input[aria-invalid="true"] {
  border-color: var(--tone-bad);
  box-shadow: 0 0 0 0.0625rem var(--tone-bad);
}

select.input {
  min-height: 2.25rem;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.875rem;
  cursor: pointer;
}

.segmented-field .seg {
  align-self: flex-start;
}

.form-errors {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  background: color-mix(in oklch, var(--tone-bad) 9%, var(--color-bg));
  box-shadow: inset 0 0 0 0.0625rem color-mix(in oklch, var(--tone-bad) 35%, transparent);
}

.form-errors > .ph {
  margin-top: 0.125rem;
  color: var(--tone-bad);
}

.form-errors ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* — tabs — */
.tabs {
  display: flex;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
  overflow-x: auto;
  box-shadow: inset 0 -0.0625rem 0 var(--color-divider);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-1);
  font-size: 0.8125rem;
  white-space: nowrap;
  color: var(--color-neutral-500);
  text-decoration: none;
}

.tab:hover {
  color: var(--color-neutral-200);
}

.tab[aria-selected="true"] {
  color: var(--color-text);
  box-shadow: inset 0 -0.125rem 0 var(--color-accent);
}

.tab-count {
  min-width: 1.125rem;
  padding: 0.0625rem 0.375rem;
  border-radius: 0.5625rem;
  font-size: 0.6875rem;
  text-align: center;
  color: var(--color-accent-100);
  background: var(--color-accent-800);
}

/* — dialog (native <dialog> with the Nocturne .dialog surface) — */
dialog.dialog {
  max-height: calc(100dvh - 2 * var(--space-8));
  padding: var(--space-6);
  overflow: auto;
  border: 0;
  color: var(--color-text);
}

/* Nocturne's .dialog sets display: flex, which would override the closed dialog's display. */
dialog.dialog:not([open]) {
  display: none;
}

dialog.dialog::backdrop {
  background: color-mix(in srgb, var(--color-neutral-900) 50%, transparent);
}

dialog.dialog-sm {
  width: min(22rem, 100%);
}

dialog.dialog-md {
  width: min(27.5rem, 100%);
}

dialog.dialog-lg {
  width: min(40rem, 100%);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.dialog-header .dialog-title {
  flex: 1;
  margin: 0;
  font-size: 1.25rem;
}

dialog.dialog .dialog-body {
  opacity: 1;
}

/* — toasts — */
.toast-region {
  position: fixed;
  bottom: var(--space-8);
  left: 50%;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: max-content;
  max-width: min(42.5rem, 90vw);
  transform: translateX(-50%);
  pointer-events: none;
}

body:has(.tabbar) .toast-region {
  bottom: calc(var(--app-touch-target) + var(--space-8) + env(safe-area-inset-bottom));
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  max-width: 100%;
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
}

.toast-icon {
  font-size: 1.125rem;
  color: var(--tone);
}

.toast-text {
  flex: 1;
}

.toast-link {
  padding: var(--space-1) var(--space-3);
  font-size: 0.75rem;
}

.toast-close {
  width: 1.75rem;
  height: 1.75rem;
}

/* — approvals inbox (CA-06, AM-11) — */
.approvals-filter {
  margin-bottom: var(--space-4);
}

.approvals-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* — approval card — */
.approval-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-6);
  align-items: start;
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.approval-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.approval-kicker {
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent-300);
}

.approval-what {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.3;
}

.approval-reason {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--color-neutral-300);
}

.approval-meta {
  font-size: 0.75rem;
  color: var(--color-neutral-500);
}

.approval-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-3);
}

.approval-value {
  font-size: 1.375rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.approval-actions {
  display: flex;
  gap: var(--space-2);
}

.approval-decision {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
  text-align: right;
}

.approval-note {
  max-width: 20rem;
  margin: 0;
  font-size: 0.8125rem;
  color: var(--color-neutral-300);
}

.approval-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.approval-dialog-what {
  margin: 0 0 var(--space-4);
  font-weight: 500;
}

/* — history timeline — */
.timeline {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline-item {
  display: grid;
  grid-template-columns: 0.875rem minmax(0, 1fr);
  gap: var(--space-4);
}

.timeline-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.timeline-marker::after {
  content: "";
  flex: 1;
  width: 0.0625rem;
  background: var(--color-neutral-800);
}

.timeline-item:last-child .timeline-marker::after {
  background: transparent;
}

.timeline-dot {
  flex: none;
  width: 0.5625rem;
  height: 0.5625rem;
  margin-top: 0.375rem;
  border: 0.09375rem solid var(--color-accent);
  border-radius: 50%;
  background: var(--color-bg);
}

.timeline-marker .ph {
  margin-top: 0.1875rem;
  font-size: 0.875rem;
  color: var(--color-accent-300);
}

.timeline-body {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding-bottom: var(--space-6);
}

.timeline-text {
  font-size: 0.8125rem;
}

.timeline-text strong {
  font-weight: 500;
}

.timeline-note {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--color-neutral-300);
}

.timeline-time {
  font-size: 0.75rem;
  color: var(--color-neutral-500);
}

/* — warning banners — */
.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  background: color-mix(in oklch, var(--tone) 9%, var(--color-bg));
  box-shadow: inset 0 0 0 0.0625rem color-mix(in oklch, var(--tone) 35%, transparent);
}

.banner-icon {
  flex: none;
  font-size: 1rem;
  color: var(--tone);
}

.banner-text {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 0 var(--space-3);
  min-width: 12rem;
}

.banner-title {
  font-weight: 500;
}

.banner-detail {
  color: var(--color-neutral-300);
}

.banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* — confidence highlight — */
.conf-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.25rem;
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  background: var(--color-bg);
  box-shadow: inset 0 0 0 0.0625rem var(--color-divider);
}

.conf-text {
  flex: 1;
  min-width: 0;
}

.conf-field.conf-low {
  background: color-mix(in oklch, var(--tone) 8%, var(--color-bg));
  box-shadow: inset 0 0 0 0.0625rem var(--tone);
}

/* On an input the ring belongs to the input, and the icon sits beside it. */
.conf-field.conf-input {
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.conf-field.conf-input .input {
  flex: 1;
}

.conf-field.conf-input.conf-low .input {
  border-color: var(--tone);
  background: color-mix(in oklch, var(--tone) 8%, var(--color-bg));
}

.conf-hint {
  position: relative;
  display: inline-flex;
}

.conf-icon {
  display: inline-grid;
  place-items: center;
  min-width: 1.75rem;
  min-height: 1.75rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 1rem;
  color: var(--tone);
  background: transparent;
  cursor: help;
}

.conf-tooltip {
  position: absolute;
  right: 0;
  bottom: calc(100% + var(--space-2));
  z-index: 10;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  white-space: nowrap;
  color: var(--color-text);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
  visibility: hidden;
  opacity: 0;
}

.conf-hint:hover .conf-tooltip,
.conf-icon:focus-visible + .conf-tooltip,
.conf-tooltip.is-open {
  visibility: visible;
  opacity: 1;
}

.marker {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: var(--space-2);
  padding: 0.0625rem 0.375rem;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  vertical-align: middle;
  color: var(--color-neutral-400);
  box-shadow: inset 0 0 0 0.0625rem var(--color-divider);
}

/* — photo and file upload — */
.upload-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 7rem;
  padding: var(--space-6);
  border: 0.0625rem dashed var(--color-divider);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  color: var(--color-neutral-300);
  text-align: center;
  cursor: pointer;
}

.upload-drop:hover {
  border-color: color-mix(in srgb, var(--color-text) 45%, transparent);
}

.upload-drop:focus-within,
.upload-drop.is-dragover {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 0.0625rem var(--color-accent);
}

.upload-drop.is-dragover {
  background: color-mix(in srgb, var(--color-accent) 8%, transparent);
}

.upload-icon {
  font-size: 1.75rem;
  color: var(--color-accent-300);
}

.upload-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.upload-thumb img {
  width: 8rem;
  max-height: 6rem;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.upload-file {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 8rem;
}

.upload-name {
  overflow: hidden;
  font-size: 0.8125rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.upload-size {
  font-size: 0.75rem;
  color: var(--color-neutral-500);
}

/* — notifications (S-02: the bell, the desktop drawer and the list) — */
.notification-bell {
  display: inline-flex;
}

.notification-bell .btn {
  position: relative;
}

/* The tones of .app-nav-badge. */
.notification-bell-badge {
  position: absolute;
  top: -0.125rem;
  right: -0.125rem;
  min-width: 1.125rem;
  padding: 0.125rem 0.3125rem;
  border-radius: 0.5625rem;
  font-size: 0.6875rem;
  line-height: 1;
  text-align: center;
  color: var(--color-accent-100);
  background: var(--color-accent-800);
}

/* The drawer: docked right at full height; the header stays put while the list scrolls. */
dialog.dialog-drawer {
  inset: 0 0 0 auto;
  width: min(var(--app-drawer-width), 100%);
  max-width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  overflow: hidden;
  border-radius: 0;
}

dialog.dialog-drawer .dialog-body {
  flex: 1;
  min-height: 0;
  margin: 0 calc(-1 * var(--space-3));
  overflow: auto;
}

.notification-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

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

.notification-group-label {
  margin: 0;
  padding: var(--space-4) var(--space-3) var(--space-2);
  font-size: 0.625rem;
  font-weight: inherit;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-neutral-500);
}

.notification-group:first-child .notification-group-label {
  padding-top: var(--space-2);
}

.notification-form {
  margin: 0;
}

.notification-item {
  position: relative;
  display: grid;
  grid-template-columns: 0.5rem 1.375rem minmax(0, 1fr);
  gap: var(--space-3);
  align-items: start;
  width: 100%;
  padding: var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  font: inherit;
  text-align: left;
  color: var(--color-text);
  background: transparent;
  cursor: pointer;
}

.notification-item:hover {
  background: color-mix(in srgb, var(--color-text) 5%, transparent);
}

.notification-item:focus-visible {
  outline: 0.125rem solid var(--color-accent);
  outline-offset: -0.125rem;
}

.notification-item.is-read {
  color: var(--color-neutral-400);
}

.notification-dot {
  width: 0.375rem;
  height: 0.375rem;
  margin-top: 0.4375rem;
  border-radius: 50%;
  background: var(--color-accent);
}

.notification-item.is-read .notification-dot {
  background: transparent;
}

.notification-icon {
  font-size: 1.125rem;
  color: var(--color-accent-300);
}

.notification-content {
  min-width: 0;
}

.notification-text {
  display: block;
  font-size: 0.8125rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.notification-time {
  display: block;
  margin-top: 0.125rem;
  font-size: 0.6875rem;
  color: var(--color-neutral-500);
}

.notification-more {
  margin-top: var(--space-3);
}

/* — scanner (F-08: camera viewport, guide frame, status and manual entry) — */
.scanner {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.scanner-title {
  margin: 0;
  font-size: 1rem;
}

.scanner-viewport {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  max-height: 60vh;
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.scanner-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The guide box: the accent as a line, never a fill. */
.scanner-frame {
  position: absolute;
  inset: 22% 12%;
  border: 0.125rem solid var(--color-accent);
  border-radius: var(--radius-md);
  pointer-events: none;
}

.scanner-placeholder {
  font-size: 3rem;
  color: var(--color-neutral-600);
}

.scanner-torch {
  position: absolute;
  right: var(--space-3);
  bottom: var(--space-3);
  min-width: var(--app-touch-target);
  min-height: var(--app-touch-target);
}

.scanner-torch[aria-pressed="true"] {
  color: var(--color-accent-200);
}

.scanner-actions {
  display: flex;
  gap: var(--space-2);
}

.scanner-actions .btn,
.scanner-form .btn {
  flex: 1;
  min-height: var(--app-touch-target);
}

.scanner-form .input {
  min-height: var(--app-touch-target);
}

.scanner-status {
  margin: 0;
  font-size: 0.875rem;
  color: var(--tone, var(--color-neutral-300));
}

.scanner-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.scan-result-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}

.scan-result-line .ph {
  color: var(--tone-ok);
}

/* — touch targets on phones — */
@media (max-width: 40rem), (pointer: coarse) {
  .upload-drop,
  .seg-opt,
  .tab,
  .page-link,
  .btn-touch,
  .notification-item {
    min-height: var(--app-touch-target);
  }

  .page-link,
  .conf-icon {
    min-width: var(--app-touch-target);
  }

  .conf-icon {
    min-height: var(--app-touch-target);
  }

  .approval-card {
    grid-template-columns: minmax(0, 1fr);
  }

  .approval-side,
  .approval-decision {
    align-items: flex-start;
    text-align: left;
  }
}

/* Every control of the phone shell is a touch target (F-92: the accessibility audit found the
   bell, small buttons, filter fields, crumbs and row checkboxes under 44 px). */
.m-shell .btn,
.m-shell .input,
.m-shell .dispatch-row-check {
  min-height: var(--app-touch-target);
}

.m-shell .btn-icon,
.m-shell .dispatch-row-check {
  min-width: var(--app-touch-target);
}

.m-shell .dispatch-row-check {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.m-crumbs a {
  display: inline-flex;
  align-items: center;
  min-width: var(--app-touch-target);
  min-height: var(--app-touch-target);
}

/* — auth layout (S-01: form left, brand panel right, one column on a phone) — */
.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--color-text);
  background: var(--color-bg);
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--space-8);
  padding: var(--space-8) 10%;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: inherit;
  text-decoration: none;
}

.auth-brand:hover {
  color: inherit;
}

.auth-brand-mark {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 0.09375rem solid var(--color-accent);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-accent-300);
}

.auth-brand-name {
  font-size: 1.375rem;
  font-weight: 500;
}

.auth-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  width: 100%;
  max-width: 22.5rem;
}

.auth-title {
  margin: 0;
  font-size: 2rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.auth-text {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-neutral-300);
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  font-size: 0.8125rem;
}

.auth-art {
  display: grid;
  place-items: center;
  padding: var(--space-8);
  background: repeating-linear-gradient(
    135deg,
    var(--color-surface) 0 0.625rem,
    var(--color-bg) 0.625rem 1.25rem
  );
}

.auth-art-caption {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-neutral-500);
}

@media (max-width: 40rem) {
  .auth-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-panel {
    justify-content: flex-start;
    padding: var(--space-8) var(--space-6);
  }

  .auth-art {
    display: none;
  }

  .auth-form .btn {
    min-height: var(--app-touch-target);
  }
}

/* — user menu (desktop sidebar foot) and account button (mobile top bar) — */
.app-brand {
  color: inherit;
  text-decoration: none;
}

.app-brand:hover {
  color: inherit;
}

.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  font: inherit;
  text-align: left;
  color: var(--color-text);
  background: transparent;
  cursor: pointer;
}

.user-menu-trigger:hover {
  background: color-mix(in srgb, var(--color-text) 6%, transparent);
}

.user-menu-trigger > .ph {
  color: var(--color-neutral-500);
}

.user-avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-accent-100);
  background: var(--color-accent-800);
}

.user-avatar-lg {
  width: 2.5rem;
  height: 2.5rem;
  font-size: 0.875rem;
}

.user-menu-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.user-menu-name {
  overflow: hidden;
  font-size: 0.8125rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.user-menu-role {
  font-size: 0.6875rem;
  color: var(--color-neutral-500);
}

.user-menu-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + var(--space-2));
  left: 0;
  z-index: 10;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-md);
}

.user-menu-popover form {
  margin: 0;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.8125rem;
  text-align: left;
  color: var(--color-neutral-200);
  background: transparent;
  cursor: pointer;
}

.user-menu-item:hover {
  color: var(--color-text);
  background: color-mix(in srgb, var(--color-text) 7%, transparent);
}

.m-account {
  flex: none;
  min-width: var(--app-touch-target);
  min-height: var(--app-touch-target);
}

.account-summary {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.account-summary + form .btn {
  width: 100%;
}

/* — item detail (S-03) — */
.item-header {
  display: grid;
  grid-template-columns: var(--app-item-photo-width) minmax(0, 1fr);
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}

.item-photo {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.item-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-photo.is-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-size: 0.8125rem;
  color: var(--color-neutral-500);
  background: repeating-linear-gradient(
    135deg,
    var(--color-surface) 0 0.75rem,
    var(--color-section) 0.75rem 1.5rem
  );
}

.item-photo.is-empty .ph {
  font-size: 2rem;
}

.item-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.item-path {
  font-size: 0.8125rem;
  color: var(--color-accent-300);
  letter-spacing: 0.02em;
}

.item-subline {
  color: var(--color-neutral-300);
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.item-meta-text {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.8125rem;
  color: var(--color-neutral-300);
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.item-action-form {
  display: contents;
}

.item-banners {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.detail-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  font-size: 0.8125rem;
  color: var(--color-neutral-400);
}

.detail-groups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  gap: var(--space-4);
}

.detail-card .card-title {
  margin-bottom: var(--space-3);
}

.detail-rows {
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: var(--space-2) var(--space-3);
  margin: 0;
  font-size: 0.875rem;
}

.detail-rows dt {
  color: var(--color-neutral-400);
}

.detail-rows dd {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
  margin: 0;
  overflow-wrap: anywhere;
}

.detail-empty {
  color: var(--color-neutral-500);
}

.detail-multiline {
  white-space: pre-line;
}

.tab-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: var(--space-4);
}

.photo-tile {
  margin: 0;
}

.photo-tile img {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-md);
  object-fit: cover;
}

.photo-tile figcaption {
  margin-top: var(--space-1);
  font-size: 0.75rem;
  color: var(--color-neutral-400);
}

@media (max-width: 40rem) {
  .item-header {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
  }

  .detail-groups {
    grid-template-columns: minmax(0, 1fr);
  }

  .detail-rows {
    grid-template-columns: 7.5rem minmax(0, 1fr);
  }
}

/* — item form (WW-05) and add stock (WW-02 shell) — */
.item-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: var(--app-form-max);
}

.item-form-subtitle {
  max-width: var(--app-form-max);
}

.form-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.form-card .card-title {
  margin: 0;
}

.field-static {
  margin: 0;
  padding: var(--space-2) 0;
  font-size: 0.875rem;
}

.field-static.is-muted {
  color: var(--color-neutral-500);
}

details.form-group {
  padding: 0;
}

details.form-group > summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  list-style: none;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-md);
}

details.form-group > summary::-webkit-details-marker {
  display: none;
}

details.form-group > summary:focus-visible {
  outline: 0.125rem solid var(--color-accent);
  outline-offset: 0.125rem;
}

.form-group-caret {
  transition: transform 0.15s ease;
}

details.form-group[open] .form-group-caret {
  transform: rotate(90deg);
}

.form-group-count {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--color-neutral-500);
}

.form-group-body {
  padding: 0 var(--space-4) var(--space-4);
}

.field-with-hint .field-hint {
  margin-top: var(--space-1);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

.form-saving {
  font-size: 0.8125rem;
  color: var(--color-neutral-400);
}

.photo-upload {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.add-stock {
  max-width: var(--app-form-max);
}

.add-stock-title {
  margin: 0 0 var(--space-4);
  font-family: var(--font-heading);
  font-size: 1.125rem;
}

.add-stock-kicker {
  display: none;
}

.choice-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.choice-card {
  display: flex;
  flex-direction: row; /* .card stacks its content */
  align-items: center;
  gap: var(--space-4);
  min-height: calc(var(--app-touch-target) * 1.75);
  color: var(--color-text);
  text-decoration: none;
}

.choice-card:hover {
  color: var(--color-text);
  box-shadow: 0 0 0 0.0625rem var(--color-accent);
}

.choice-card-icon {
  font-size: 1.75rem;
  color: var(--color-accent-300);
}

.choice-card-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-1);
}

.choice-card-title {
  font-weight: 500;
}

.choice-card-detail {
  font-size: 0.8125rem;
  color: var(--color-neutral-400);
}

@media (max-width: 40rem) {
  .add-stock-kicker {
    display: block;
    margin-bottom: var(--space-2);
  }

  .add-stock-kicker + .item-form-subtitle {
    margin-top: 0;
  }

  .form-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .form-actions .btn {
    justify-content: center;
  }
}

/* — stock (AM-02, CA-11) — */
.stock-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.stock-filters .field {
  min-width: 10rem;
  margin: 0;
}

.stock-search {
  flex: 1 1 14rem;
  max-width: var(--app-stock-search-max);
}

.stock-filter-actions {
  display: flex;
  gap: var(--space-2);
}

.stock-results {
  position: relative;
}

.stock-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.stock-summary {
  font-size: 0.875rem;
  color: var(--color-neutral-300);
}

.stock-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.stock-toolbar-actions .btn[aria-pressed="true"] {
  border-color: var(--color-accent);
  color: var(--color-accent-200);
}

.qty-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

/* — scan (WW-06) — */
/* .page-subtitle pulls itself up under a page header; here it follows the kicker. */
.scan-subtitle {
  margin-top: var(--space-2);
}

.scan-result {
  margin-top: var(--space-4);
}

.scan-message {
  margin: 0 0 var(--space-3);
}

.scan-match-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.scan-match {
  display: flex;
  flex-direction: row; /* .card stacks its content */
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  color: var(--color-text);
  text-decoration: none;
}

.scan-match-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.scan-help {
  margin-top: var(--space-4);
}

.item-note {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.8125rem;
  color: var(--color-accent-300);
}

/* — labels (F-25) — */
.label-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.label-toolbar-title {
  font-family: var(--font-heading);
  font-weight: 600;
}

.label-layouts,
.label-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.label-layouts .btn[aria-current="page"] {
  border-color: var(--color-accent);
  color: var(--color-accent-200);
}

.labels {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-6) var(--space-4);
  overflow-x: auto;
  background: var(--color-bg);
}

.label-page {
  flex: none;
  background: var(--label-paper);
  color: var(--label-ink);
  box-shadow: var(--shadow-lg);
  break-after: page;
}

.labels-sheet .label-page {
  display: grid;
  grid-template-columns: repeat(3, var(--label-width));
  grid-auto-rows: var(--label-height);
  column-gap: var(--label-gap);
  align-content: start;
  width: var(--label-sheet-width);
  height: var(--label-sheet-height);
  padding: var(--label-sheet-margin-top) var(--label-sheet-margin-side);
  box-sizing: border-box;
}

.labels-roll .label-page {
  page: roll;
  width: var(--label-roll-width);
  height: var(--label-roll-height);
}

.label {
  display: flex;
  align-items: center;
  gap: var(--label-padding);
  height: 100%;
  padding: var(--label-padding);
  overflow: hidden;
  box-sizing: border-box;
}

.label-qr {
  flex: none;
  height: 100%;
  aspect-ratio: 1;
}

.label-text {
  display: flex;
  flex-direction: column;
  gap: var(--label-line-gap);
  min-width: 0;
  font-family: var(--font-body);
  font-size: 0.5rem;
  line-height: 1.2;
}

.label-code {
  font-family: var(--app-font-mono);
  font-size: 0.75rem;
  font-weight: 700;
}

.labels-roll .label-code {
  font-size: 0.625rem;
}

.label-path,
.label-ident {
  overflow: hidden;
  text-overflow: ellipsis;
}

@page {
  size: A4;
  margin: 0;
}

@page roll {
  size: 50mm 25mm;
  margin: 0;
}

@media print {
  .label-toolbar,
  .app-alerts,
  .toast-region,
  .skip-link {
    display: none !important;
  }

  html,
  body,
  .labels {
    background: var(--label-paper);
  }

  .labels {
    display: block;
    padding: 0;
  }

  .label-page {
    box-shadow: none;
  }
}

/* — development previews — */
.media-result img {
  display: block;
  max-width: 100%;
  height: auto;
}

.kit {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  max-width: 67.5rem;
}

.kit-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.kit-heading {
  margin: 0;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-neutral-500);
}

.kit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.kit-row-wide {
  gap: var(--space-4);
}

.kit-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.kit-grid-2,
.kit-grid-3,
.kit-grid-wide {
  display: grid;
  gap: var(--space-8);
  align-items: start;
}

.kit-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.kit-grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: var(--space-6);
}

.kit-grid-wide {
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
}

.kit-narrow {
  max-width: 36rem;
  gap: var(--space-4);
}

@media (max-width: 60rem) {
  .kit-grid-2,
  .kit-grid-wide {
    grid-template-columns: minmax(0, 1fr);
  }
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: var(--space-4);
}

.sample-values {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-2) var(--space-4);
  margin: 0;
  font-size: 0.8125rem;
}

.sample-values dt {
  color: var(--color-neutral-500);
}

.sample-values dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.outbox-text {
  max-width: 50rem;
  margin: 0;
  padding: var(--space-6);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.875rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

/* — list toolbar: a search box and filters above a data table (suppliers, purchase orders) — */
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.list-toolbar .field {
  margin: 0;
}

.list-toolbar-search {
  flex: 1 1 14rem;
  max-width: var(--app-stock-search-max);
}

/* — purchase settings (CA-07, F-30) — */
.purchase-settings {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  max-width: var(--app-purchase-settings-max);
}

.purchase-card {
  gap: var(--space-6);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.purchase-card .card-body {
  /* Lighter than neutral-500: Nocturne's .card-body opacity left it under AA contrast. */
  color: var(--color-neutral-400);
}

/* — photo processing settings (SA-05, F-40) — */
.photo-settings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  align-items: start;
  gap: var(--space-6);
  max-width: var(--app-purchase-settings-max);
}

/* The slider grows; the number input keeps its width after it. */
.threshold-control {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.threshold-range {
  flex: 1;
  min-width: 0;
  accent-color: var(--color-accent);
}

.threshold-input {
  width: 6rem;
}

.threshold-scale {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: 0.75rem;
  color: var(--color-neutral-500);
}

.photo-preview {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.photo-preview .field {
  margin: 0;
}

.conf-preview-icon {
  color: var(--tone);
}

.conf-score {
  font-size: 0.75rem;
  color: var(--color-neutral-500);
}

/* Two amount fields side by side; stacked on narrow screens. */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-6);
  max-width: 35rem;
}

.settings-grid .field {
  margin: 0;
}

/* The three-step approval ladder. */
.ladder {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.ladder-step {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 0.0625rem var(--color-divider);
}

.ladder-range {
  font-size: 0.75rem;
  color: var(--color-accent-300);
}

.ladder-who {
  font-size: 0.875rem;
  font-weight: 500;
}

.ladder-note {
  font-size: 0.75rem;
  color: var(--color-neutral-500);
}

@media (max-width: 40rem) {
  .settings-grid,
  .ladder {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* A period-limit meter: a styled <progress>, never a style width. */
.limit-meter {
  --meter-fill: var(--color-accent);
  appearance: none;
  display: block;
  width: 100%;
  min-width: 6rem;
  height: var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--color-neutral-800);
  overflow: hidden;
}

.limit-meter::-webkit-progress-bar {
  background: var(--color-neutral-800);
  border-radius: var(--radius-sm);
}

.limit-meter::-webkit-progress-value {
  background: var(--meter-fill);
  border-radius: var(--radius-sm);
}

.limit-meter::-moz-progress-bar {
  background: var(--meter-fill);
  border-radius: var(--radius-sm);
}

.limit-meter.is-over {
  --meter-fill: var(--tone-bad);
}

.limit-meter.is-projected {
  --meter-fill: var(--tone-warn);
}

/* — purchase orders (AM-09, AM-10, WW-12; F-31) — */
.po-period {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  padding: var(--space-4) var(--space-6);
}

.po-period-text {
  font-size: 0.875rem;
  color: var(--color-neutral-300);
}

.po-period .limit-meter {
  flex: 1 1 12rem;
  max-width: 20rem;
}

.po-received {
  margin-top: var(--space-1);
  margin-left: auto;
  max-width: 6rem;
}

/* The form: the fields and lines, and the hint card beside them. */
.po-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--app-po-side-width);
  align-items: start;
  gap: var(--space-8);
}

.po-form-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  min-width: 0;
}

.po-form-side {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.po-no-suppliers {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}

.po-lines-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  border: 0;
}

.po-lines-field legend {
  margin-bottom: var(--space-2);
  font-weight: 500;
}

/* One row per line on desktop: category, description, qty, price, total, remove. */
.po-lines-head,
.po-line {
  display: grid;
  grid-template-columns:
    minmax(0, 1.1fr) minmax(0, 1.4fr) minmax(4.5rem, 0.45fr) minmax(6rem, 0.6fr)
    minmax(6rem, 0.55fr) var(--app-touch-target);
  align-items: start;
  gap: var(--space-2);
}

.po-lines-head {
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-neutral-500);
}

.po-lines-head .is-end,
.po-line-total {
  text-align: end;
}

.po-lines {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.po-line .field {
  margin: 0;
}

.po-line-qty .input,
.po-line-price .input {
  text-align: end;
}

.po-line-total {
  padding-top: var(--space-3);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

/* The column headings label the inputs on desktop; each row's own labels are for screen
   readers there, and visible once rows stack. */
.po-line-label {
  position: absolute;
  width: 0.0625rem;
  height: 0.0625rem;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* The only row cannot be removed. */
.po-line:only-child .po-line-remove {
  visibility: hidden;
}

.po-add-line {
  align-self: flex-start;
}

/* The approval hint. */
.po-hint {
  --tone: var(--tone-info);
  gap: var(--space-4);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm), inset 0.1875rem 0 0 var(--tone);
}

.po-hint.is-ok { --tone: var(--tone-ok); }
.po-hint.is-warn { --tone: var(--tone-warn); }
.po-hint.is-caution { --tone: var(--tone-caution); }
.po-hint.is-bad { --tone: var(--tone-bad); }
.po-hint.is-info { --tone: var(--tone-info); }

.po-hint-total {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.po-hint-label {
  font-size: 0.75rem;
  color: var(--color-neutral-500);
}

.po-hint-amount {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-variant-numeric: tabular-nums;
}

.po-hint-route {
  display: flex;
  gap: var(--space-3);
}

.po-hint-icon {
  font-size: 1.5rem;
  color: var(--tone);
}

.po-hint-title {
  font-weight: 500;
}

.po-hint-why {
  margin: var(--space-1) 0 0;
  font-size: 0.8125rem;
  color: var(--color-neutral-400);
}

.po-hint-period {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* The worker's list: one card per order. */
.po-mobile {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.po-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.po-card {
  gap: var(--space-2);
  color: var(--color-text);
  text-decoration: none;
}

.po-card:hover {
  color: var(--color-text);
  box-shadow: 0 0 0 0.0625rem var(--color-accent);
}

.po-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.po-card-title {
  font-weight: 500;
}

.po-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  font-size: 0.8125rem;
  color: var(--color-neutral-400);
}

/* The detail page. */
.po-detail {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.po-detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.po-detail-total {
  margin-left: auto;
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.po-decision {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.po-review {
  align-self: flex-start;
  margin-top: var(--space-1);
}

/* The form stacks by its own width (a container query), so it fits narrow desktop windows and
   the worker's mobile shell alike. */
.po-form {
  container-type: inline-size;
}

@container (max-width: 60rem) {
  .po-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .po-form-side {
    position: static;
  }
}

@container (max-width: 40rem) {
  .po-lines-head {
    display: none;
  }

  .po-line {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: var(--space-3);
    border-radius: var(--radius-md);
    background: var(--color-surface);
  }

  .po-line-category,
  .po-line-description {
    grid-column: 1 / -1;
  }

  .po-line-label {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    font-size: 0.75rem;
    color: var(--color-neutral-400);
  }

  .po-line-total {
    display: flex;
    flex-direction: column;
    padding-top: 0;
    text-align: start;
  }

  .po-line-remove {
    justify-self: end;
  }
}

/* The lines table becomes one card per line on phones. */
@media (max-width: 40rem) {
  .po-lines-table thead {
    display: none;
  }

  .po-lines-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-1) var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 0.0625rem solid var(--color-neutral-800);
  }

  .po-lines-table td,
  .po-lines-table th {
    display: block;
    padding: 0;
    border: 0;
    text-align: start;
  }

  .po-lines-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.6875rem;
    color: var(--color-neutral-500);
  }
}

/* — photo intake (WW-02 to WW-04, F-42) — */

/* A tag with a tone (e.g. "Sent to QA review"). */
.tag[class*="tone-"] {
  background: color-mix(in oklch, var(--tone) 18%, transparent);
  color: var(--tone);
}

.choice-card[aria-current="true"] {
  box-shadow: 0 0 0 0.0625rem var(--color-accent);
}

.add-stock-manual {
  margin-top: var(--space-8);
}

.intake-start {
  margin-top: var(--space-4);
}

/* Purchase orders to receive against: radio cards. */
.po-pick {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  border: 0;
}

/* `.po-pick` is a `.field`, whose label rule would make these labels blocks. */
.po-pick .po-pick-card {
  display: flex;
  flex-direction: row; /* .card stacks its content */
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
}

.po-pick-card:has(input:checked) {
  box-shadow: 0 0 0 0.0625rem var(--color-accent);
}

.po-pick-card input {
  margin-top: var(--space-1);
  accent-color: var(--color-accent);
}

.po-pick-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.po-pick-title {
  font-weight: 500;
}

.po-pick-meter {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.8125rem;
  color: var(--color-neutral-400);
}

.po-pick-meter .limit-meter {
  flex: 1;
}

/* — the Add Stock grid (F-111) — */
.intake-grid-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.intake-pickers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

/* A label styled as a button: its file input is visually hidden but still focusable. */
.intake-picker {
  justify-content: center;
  cursor: pointer;
}

.intake-picker:focus-within {
  outline: 0.125rem solid var(--color-accent);
  outline-offset: 0.125rem;
}

.intake-uploads {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.intake-upload {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-2) 0;
  border-top: 0.0625rem solid var(--color-neutral-800);
}

.intake-upload[class*="tone-"] > .ph {
  color: var(--tone);
}

.intake-upload-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.intake-upload-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.intake-upload-actions {
  display: flex;
  gap: var(--space-2);
}

.intake-grid-title {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
  font-family: var(--font-heading);
  font-size: 1.125rem;
}

.intake-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 40rem) {
  .intake-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.intake-tile {
  height: 100%;
}

.intake-tile-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--color-neutral-800);
}

.intake-tile-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
}

.intake-tile-error {
  margin: 0;
  overflow-wrap: anywhere;
}

.intake-tile-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: auto;
}

.intake-tile-actions .btn {
  justify-content: center;
}

.intake-capture,
.intake-review-page,
.intake-result {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* The full-screen camera, above the tab bar. */
.camera-sheet {
  position: fixed;
  inset: 0;
  z-index: var(--app-camera-layer);
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
}

.camera-video,
.camera-still {
  flex: 1;
  width: 100%;
  min-height: 0;
  object-fit: contain;
}

.camera-guide {
  position: absolute;
  inset: 12% 8% 22%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  border-radius: var(--radius-lg);
  box-shadow: inset 0 0 0 0.1875rem var(--color-accent), 0 0 0 100vmax color-mix(in oklch, var(--color-bg) 35%, transparent);
  pointer-events: none;
}

.camera-guide-text {
  margin-top: var(--space-3);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--color-text);
  background: color-mix(in oklch, var(--color-bg) 70%, transparent);
}

/* Close on the left, the shutter centred; after a capture, Retake and Use photo on the right. */
.camera-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
  background: var(--color-bg);
}

.camera-shutter {
  display: grid;
  place-items: center;
  width: calc(var(--app-touch-target) * 1.6);
  height: calc(var(--app-touch-target) * 1.6);
  padding: 0;
  border: 0.25rem solid var(--color-text);
  border-radius: 50%;
  font-size: 2.5rem;
  color: var(--color-text);
  background: transparent;
  cursor: pointer;
}

.camera-bar > .btn {
  justify-self: start;
}

.camera-shutter {
  grid-column: 2;
}

.camera-choice {
  display: flex;
  grid-column: 2 / 4;
  justify-self: end;
  gap: var(--space-2);
}

.camera-choice .btn {
  white-space: nowrap;
}

/* The tag photo with SVG outlines laid over it; positions come from SVG attributes. */
.tag-photo {
  position: relative;
  margin: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg);
}

.tag-photo img {
  display: block;
  width: 100%;
  height: auto;
}

.tag-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Zoom and pan (`photoZoom`): the canvas carries one transform for the photo and its outlines.
   A page scroll still works over a photo that is not zoomed; a zoomed one takes every touch. */
.tag-photo-stage {
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  cursor: zoom-in;
}

.tag-photo.is-zoomed .tag-photo-stage {
  touch-action: none;
  cursor: grab;
}

.tag-photo.is-zoomed .tag-photo-stage:active {
  cursor: grabbing;
}

.tag-photo-canvas {
  position: relative;
  transform-origin: 0 0;
  will-change: transform;
}

.tag-photo-tools {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  display: flex;
  gap: var(--space-1);
}

/* A manufacturing date (`monthYear`): one text input without JavaScript, a year box and an
   optional month list with it. */
.month-year-parts {
  display: none;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: var(--space-2);
}

.month-year.is-enhanced .month-year-parts {
  display: grid;
}

.month-year.is-enhanced .month-year-text {
  display: none;
}

.tag-region {
  fill: color-mix(in oklch, var(--color-accent) 8%, transparent);
  stroke: var(--color-accent-200);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.tag-badge {
  fill: var(--color-surface);
  stroke: var(--color-accent-200);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.tag-number {
  font-weight: 700;
  fill: var(--color-text);
}

.tag-mark[role="button"] {
  cursor: pointer;
}

.tag-mark:focus-visible {
  outline: none;
}

.tag-mark.is-active .tag-region,
.tag-mark:focus-visible .tag-region {
  fill: color-mix(in oklch, var(--color-accent) 18%, transparent);
  stroke: var(--color-accent);
  stroke-width: 4;
}

.tag-mark.is-active .tag-badge {
  fill: var(--color-accent);
}

.tag-mark.is-active .tag-number {
  fill: var(--color-bg);
}

/* The reading panel. */
.intake-status {
  flex-direction: row;
  align-items: center;
  gap: var(--space-4);
}

.intake-status-icon {
  font-size: 2rem;
  color: var(--color-accent-300);
  animation: intake-spin 1.2s linear infinite;
}

@keyframes intake-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .intake-status-icon {
    animation: none;
  }
}

/* The review: photo beside the cards when wide, above them on a phone (a container query, so it
   fits both shells). */
.intake-body {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.intake-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

@container (min-width: 48rem) {
  .intake-layout {
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    align-items: start;
  }

  .intake-photo {
    position: sticky;
    top: var(--space-4);
  }
}

.intake-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.draft-tabs {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-1);
}

.draft-tab {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-start;
  min-height: var(--app-touch-target);
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  font: inherit;
  color: var(--color-neutral-300);
  background: var(--color-surface);
  cursor: pointer;
}

.draft-tab[aria-selected="true"] {
  color: var(--color-text);
  box-shadow: inset 0 0 0 0.0625rem var(--color-accent);
}

.draft-tab-title {
  font-weight: 500;
}

.draft-tab-sub {
  font-size: 0.75rem;
  color: var(--color-neutral-500);
}

.draft-card {
  gap: var(--space-4);
}

.draft-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.draft-fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.draft-fields .field {
  margin: 0;
}

.draft-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.draft-status {
  padding: var(--space-2) 0;
  color: var(--color-neutral-300);
}

.draft-section {
  margin: var(--space-2) 0 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-neutral-300);
}

/* The optional fields by dot-notation key (F-112): the key above the input on a phone, the ×
   at the row's end, and the "Add a detail" picker. */
.draft-opt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.draft-opt-head label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.draft-opt-remove {
  min-width: var(--app-touch-target);
  min-height: var(--app-touch-target);
  justify-content: center;
}

.field-path {
  font-family: var(--app-font-mono);
  font-size: 0.8125rem;
}

.draft-picker-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.draft-picker-row .input {
  flex: 1 1 10rem;
  width: auto;
}

/* One marker shows: "extracted" until the worker changes the value, then "edited". */
.draft-field .marker-edited,
.draft-field.is-edited .marker-extracted {
  display: none;
}

.draft-field.is-edited .marker-edited {
  display: inline;
}

.conf-note {
  color: var(--tone-warn);
}

.receipts {
  gap: var(--space-3);
}

.receipt-input {
  width: 6rem;
}

/* The receiving table becomes one card per line on phones. */
@media (max-width: 40rem) {
  .receipt-table thead {
    display: none;
  }

  .receipt-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-1) var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 0.0625rem solid var(--color-neutral-800);
  }

  .receipt-table td {
    display: block;
    padding: 0;
    border: 0;
    text-align: start;
  }

  .receipt-table td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.6875rem;
    color: var(--color-neutral-500);
  }
}

.intake-footer {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* The result page. */
.intake-items {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.intake-item {
  gap: var(--space-1);
  color: var(--color-text);
  text-decoration: none;
}

.intake-item:hover {
  color: var(--color-text);
  box-shadow: 0 0 0 0.0625rem var(--color-accent);
}

.intake-item-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.intake-item-title {
  font-weight: 500;
}

.intake-item .tag {
  align-self: flex-start;
}

.intake-order {
  gap: var(--space-3);
}

/* — QA review (QA-01, QA-02; F-43) — */
.qa-lead {
  margin: 0 0 var(--space-4);
  color: var(--color-neutral-400);
}

.qa-review {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.qa-decided {
  margin: 0;
  color: var(--color-neutral-300);
}

.qa-no-next {
  align-self: center;
}

/* The photo column beside the table from 64rem; stacked below. */
.qa-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
}

@media (min-width: 64rem) {
  .qa-layout {
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  }

  .qa-photo {
    position: sticky;
    top: var(--space-4);
  }
}

.qa-photo {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.qa-compare-card {
  gap: var(--space-4);
  overflow-x: auto;
}

.qa-compare tr.is-changed {
  background: color-mix(in oklch, var(--tone-warn) 8%, transparent);
}

.qa-compare th[scope="row"] {
  font-weight: 500;
  text-align: start;
}

.qa-compare .conf-cell {
  white-space: nowrap;
}

.qa-compare .conf-cell.conf-low {
  color: var(--tone);
}

.qa-compare .input {
  min-width: 10rem;
}

/* — accuracy report (QA-03, F-44) — */
.accuracy {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

/* The summary beside the chart, then the two lists side by side, from 64rem. */
.accuracy-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
}

@media (min-width: 64rem) {
  .accuracy-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  }

  .accuracy-lists {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.accuracy-card {
  gap: var(--space-3);
}

.accuracy-overall {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  line-height: 1.1;
  color: var(--color-accent-200);
}

.accuracy-facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  font-size: 0.875rem;
  color: var(--color-neutral-300);
}

.chart {
  margin: 0;
}

.chart-svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-grid {
  stroke: var(--color-divider);
  stroke-width: 0.15;
}

.chart-bar {
  fill: color-mix(in oklch, var(--color-accent) 55%, transparent);
}

.chart-bar.is-current {
  fill: var(--color-accent);
}

.chart-slot {
  fill: var(--color-neutral-700);
}

.chart-value,
.chart-label,
.chart-axis {
  fill: var(--color-neutral-400);
}

.chart-value {
  fill: var(--color-text);
}

.rate-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.rate-row {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) 3.5rem;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.875rem;
}

.rate-value {
  text-align: end;
  font-variant-numeric: tabular-nums;
}

.rate-row.is-warn .rate-meter {
  --meter-fill: var(--tone);
}

.rate-row.is-warn .rate-value {
  color: var(--tone);
}

/* — projects (F-50): AM-03 list, AM-04 wizard — */
.state-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3125rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  line-height: 1;
  white-space: nowrap;
  color: var(--color-neutral-200);
  background: var(--color-neutral-900);
}

.state-pill-step {
  font-variant-numeric: tabular-nums;
  color: var(--tone);
}

.gap-note {
  margin-top: var(--space-1);
  font-size: 0.75rem;
  color: var(--tone-warn);
}

.project-form {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: var(--app-form-max);
}

.wizard-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.wizard-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.wizard-step {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  cursor: pointer;
}

.wizard-step.is-todo {
  cursor: default;
}

.wizard-step-bar {
  height: 0.1875rem;
  border-radius: 0.125rem;
  background: var(--color-neutral-800);
}

.wizard-step.is-done .wizard-step-bar {
  background: var(--color-accent-600);
}

.wizard-step.is-current .wizard-step-bar {
  background: var(--color-accent);
}

.wizard-step-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-neutral-400);
}

.wizard-step.is-current .wizard-step-title {
  color: var(--color-text);
}

.wizard-step-subtitle {
  font-size: 0.75rem;
  color: var(--color-neutral-500);
}

.site-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-3);
}

.site-row-num {
  padding-top: 2rem;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  color: var(--color-neutral-500);
}

.site-row-remove {
  margin-top: 1.5rem;
}

.supervisor-picks {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.supervisor-pick {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.supervisor-pick-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
}

.supervisor-pick-name {
  flex: 1;
  color: var(--color-text);
}

.supervisor-pick-status {
  font-size: 0.75rem;
  color: var(--color-neutral-400);
}

.supervisor-pick.is-busy {
  opacity: 0.6;
}

.supervisor-pick.is-busy .supervisor-pick-head {
  cursor: not-allowed;
}

.supervisor-sites {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  padding-inline-start: var(--space-6);
}

.wizard-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  background: var(--color-bg);
}

.wizard-summary {
  flex: 1;
  font-size: 0.8125rem;
  color: var(--color-neutral-400);
}

@container (max-width: 40rem) {
  .site-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .site-row-num {
    display: none;
  }

  .wizard-steps {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* — the project page (F-51, AM-05) — */
.project-head-line {
  margin: 0 0 var(--space-4);
  font-size: 0.875rem;
  color: var(--color-neutral-400);
}

.project-page {
  container-type: inline-size;
}

.state-card {
  container-type: inline-size;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4) var(--space-6);
  margin-bottom: var(--space-6);
}

.state-card-stepper {
  flex: 1 1 32rem;
  min-width: 0;
}

.state-card-action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}

.state-blocker {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  font-size: 0.8125rem;
  color: var(--tone);
}

.state-blockers {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
}

@media (min-width: 64rem) {
  .overview-grid {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    align-items: start;
  }
}

.person-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.person-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.person-name {
  flex: 1;
  color: var(--color-text);
}

/* — material requests and work orders (F-52) — */
.tab-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.material-request {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.material-table td.is-end,
.material-table th.is-end {
  text-align: end;
  font-variant-numeric: tabular-nums;
}

.material-table tr.is-sub td:first-child {
  padding-inline-start: var(--space-6);
}

.qty-input {
  max-width: 7rem;
  margin-inline-start: auto;
  text-align: end;
}

.short-note,
.gap-cell {
  margin: var(--space-1) 0 0;
  font-size: 0.75rem;
  color: var(--tone-warn);
}

.gap-cell {
  font-size: inherit;
}

.source-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.source-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.4375rem;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  line-height: 1;
  white-space: nowrap;
  color: var(--color-neutral-200);
  background: var(--color-neutral-900);
}

.awaiting-note {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: var(--space-1);
  font-size: 0.75rem;
  color: var(--color-neutral-400);
}

.warehouse-pick {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: var(--space-3);
}

.warehouse-card {
  cursor: pointer;
}

.warehouse-card:has(input:checked) {
  box-shadow: 0 0 0 0.0625rem var(--color-accent);
}

.task-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.task-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.task-card .btn {
  margin-top: var(--space-2);
}

.task-card-title {
  font-weight: 500;
  color: var(--color-text);
}

.m-crumbs {
  font-size: 0.75rem;
  color: var(--color-neutral-400);
}

.work-order-page {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.work-order-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.wo-line {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.wo-line-head {
  display: flex;
  flex-direction: column;
}

.wo-line-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
  margin: 0;
}

.wo-line-facts dt {
  font-size: 0.6875rem;
  color: var(--color-neutral-500);
}

.wo-line-facts dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.wo-line-book {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.wo-line-book .input {
  max-width: 7rem;
}

.wo-line-status,
.wo-footer-text {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--tone);
}

.wo-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  background: var(--color-bg);
}

/* — dispatch and transfers (F-54) — */
.dispatch-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.dispatch-head {
  display: flex;
  justify-content: flex-end;
}

.dispatch-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.dispatch-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  min-height: var(--app-touch-target);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.dispatch-row > .cell-sub:last-child {
  grid-column: 2 / -1;
}

.dispatch-row.is-scanned {
  box-shadow: inset 0.1875rem 0 0 var(--tone-ok);
}

.dispatch-row-check input {
  width: 1.25rem;
  height: 1.25rem;
}

.dispatch-row-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dispatch-row-qty {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.scan-message:empty {
  display: none;
}

/* WW-16 (F-130): a loaded or found item; text, quantity, then the add or remove control. */
.dispatch-row.is-load {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.dispatch-row.is-load > .cell-sub:last-child {
  grid-column: 1 / -1;
}

.scan-result {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin: 0;
  font-size: 0.8125rem;
  color: var(--tone);
}

.transfer-toggle {
  padding-inline: 0;
}

.transfer-toggle .ph {
  transition: transform 0.15s ease;
}

.transfer-toggle .ph.is-open {
  transform: rotate(90deg);
}

.transfer-item-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.transfer-item-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

/* — receipts and the supervisor home (F-55) — */
.receive-list .dispatch-row.is-short {
  box-shadow: inset 0.1875rem 0 0 var(--tone-warn);
}

.home-project {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

/* — resolve gaps (F-53, AM-07) — */
.gap-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.gap-card {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.gap-card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2);
}

.gap-count {
  font-size: 0.8125rem;
  color: var(--tone-warn);
}

.gap-options {
  align-self: flex-start;
}

.gap-options .ph {
  margin-inline-end: 0.25rem;
}

.gap-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.gap-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.gap-row-text {
  display: flex;
  flex-direction: column;
}

.gap-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.gap-form .qty-input {
  margin-inline-start: 0;
}

.gap-form .field-error {
  flex-basis: 100%;
}

.hidden-note {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.8125rem;
  color: var(--color-neutral-500);
}

.btn-gaps {
  color: var(--tone);
}

@container (max-width: 40rem) {
  .gap-row {
    flex-direction: column;
    align-items: stretch;
  }
}

/* — transfer requests (F-57) — */
.request-card .page-kicker {
  margin: 0;
}

.request-card .approval-reason {
  margin: 0;
  font-style: italic;
  color: var(--color-neutral-300);
}

/* — project closure (AM-08, F-59) — */
.closure-choices {
  flex-direction: row;
}

.closure-choices .choice-card {
  flex: 1;
}

.returns-preview {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.returns-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 0.0625rem solid var(--color-neutral-800);
}

.returns-row-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.returns-fixed {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--color-neutral-300);
}

.returns-dest {
  min-width: 14rem;
}

.closing-note {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  max-width: 22rem;
  margin: 0;
  font-size: 0.8125rem;
  color: var(--tone);
}

@media (max-width: 40rem) {
  .closure-choices {
    flex-direction: column;
  }

  .returns-dest {
    min-width: 0;
    flex-basis: 100%;
  }
}

/* — inspections (WW-10, F-60) — */
.inspection-page,
.inspection-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.inspection-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.inspection-item .cell-sub {
  margin: 0;
}

.inspection-choices {
  margin: 0;
  padding: 0;
  border: 0;
}

.inspection-choice {
  cursor: pointer;
}

.inspection-choice:has(input:checked) {
  box-shadow: 0 0 0 0.0625rem var(--color-accent);
}

.inspection-choice:has(input:focus-visible) {
  outline: 0.125rem solid var(--color-accent);
  outline-offset: 0.125rem;
}

.photo-slot-filled {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.photo-slot-thumb,
.inspection-thumb {
  width: 4rem;
  height: 4rem;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.photo-slot-text {
  display: flex;
  flex: 1;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.8125rem;
  color: var(--tone-ok);
}

.photo-slot.htmx-request .upload-drop {
  opacity: 0.6;
}

.task-when {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--tone);
}

.task-section {
  margin: var(--space-4) 0 var(--space-2);
}

/* — site inspection (SS-03, F-62) — */
.site-modes {
  display: flex;
  gap: var(--space-2);
}

.site-modes .btn {
  flex: 1;
  justify-content: center;
}

.dispatch-row.is-flagged {
  box-shadow: inset 0.1875rem 0 0 var(--tone-bad);
}

.flag-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.flag-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.flag-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}

.return-note {
  color: var(--tone);
}

/* — stock take (WW-11, AM-13; F-70) — */
.badge-missing {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.4375rem;
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  line-height: 1;
  white-space: nowrap;
  color: var(--tone-bad);
  box-shadow: inset 0 0 0 0.0625rem var(--tone-bad);
}

.st-cats {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.st-cat {
  gap: var(--space-2);
}

.st-cat-summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--app-touch-target);
  list-style: none;
  cursor: pointer;
}

.st-cat-summary::-webkit-details-marker {
  display: none;
}

.st-caret {
  transition: transform 0.15s ease;
}

.st-cat[open] .st-caret {
  transform: rotate(180deg);
}

.st-cat-head {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-1) var(--space-3);
  min-width: 0;
}

.st-cat-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.st-cat-numbers {
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  color: var(--color-neutral-300);
}

.st-diff {
  color: var(--tone);
  font-variant-numeric: tabular-nums;
}

.st-cat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.st-records-list,
.st-review-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.st-record {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-top: 0.0625rem solid var(--color-divider);
}

.st-record.is-different {
  box-shadow: inset 0.1875rem 0 0 var(--tone-warn);
  padding-left: var(--space-2);
}

.st-record-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.st-record-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.st-record-system {
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  color: var(--color-neutral-300);
}

.st-count {
  width: 6rem;
  min-height: var(--app-touch-target);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.st-found {
  min-height: var(--app-touch-target);
}

.st-error {
  grid-column: 1 / -1;
}

.st-implied {
  color: var(--tone);
}

.st-footer {
  position: sticky;
  /* Above the fixed tab bar (a touch-sized row plus its padding), not behind it. */
  bottom: calc(var(--app-touch-target) + var(--space-3) + env(safe-area-inset-bottom));
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  background: var(--color-bg);
}

.st-footer-actions {
  display: flex;
  gap: var(--space-2);
}

.st-footer-actions .btn {
  flex: 1;
  justify-content: center;
}

.st-review-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-top: 0.0625rem solid var(--color-divider);
}

.st-review-cat {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.st-compare td,
.st-compare th {
  font-variant-numeric: tabular-nums;
}

.st-compare-row td:first-child {
  padding-left: var(--space-6);
}

.st-effect {
  color: var(--color-neutral-300);
}

.st-stale {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--tone);
}

@media (max-width: 40rem) {
  .st-record {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .st-record-system {
    grid-column: 1;
  }
}

/* — dashboards and home screens (CA-01, AM-01, WW-01, SS-01; F-80 to F-83) — */
.dash-top {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: var(--space-4);
  align-content: start;
}

.dash-top .stat-tiles {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
}

.stat-tiles.is-compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.stat-tile {
  gap: var(--space-2);
  padding: var(--space-6);
  color: var(--color-text);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.stat-tiles.is-compact .stat-tile {
  padding: var(--space-4);
}

a.stat-tile:hover {
  color: var(--color-text);
  box-shadow: 0 0 0 0.0625rem var(--color-accent);
}

a.stat-tile:focus-visible,
.dash-row:focus-visible,
.status-legend-row:focus-visible,
.dash-project:focus-visible {
  outline: 0.125rem solid var(--color-accent);
  outline-offset: 0.125rem;
}

.stat-tile-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: 0.75rem;
  color: var(--color-neutral-400);
}

.stat-tile-label .ph {
  flex: none;
  font-size: 1rem;
  color: var(--color-accent-300);
}

.stat-tile-value {
  font-size: 2rem;
  font-weight: 500;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stat-tiles.is-compact .stat-tile-value {
  font-size: 1.625rem;
}

.stat-tile-value[class*="tone-"] {
  color: var(--tone);
}

.stat-tile-detail {
  font-size: 0.75rem;
  color: var(--color-neutral-500);
  overflow-wrap: anywhere;
}

.dash-card {
  gap: var(--space-3);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.dash-card .card-title {
  margin: 0;
  font-size: 0.9375rem;
}

.dash-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}

.status-breakdown {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin: 0;
}

.status-bar {
  display: block;
  width: 100%;
  height: var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-neutral-800);
}

.status-seg {
  fill: var(--tone);
}

.status-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2) var(--space-6);
  margin: 0;
  padding: 0;
  list-style: none;
}

.status-legend-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.8125rem;
  color: var(--color-neutral-300);
  text-decoration: none;
}

.status-legend-row:hover {
  color: var(--color-text);
}

.status-legend-label {
  flex: 1;
  min-width: 0;
}

.status-legend-count {
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-6);
  align-items: start;
  margin-bottom: var(--space-8);
}

/* A card left alone (CA-01 with its approvals hidden, F-120) fills the row. */
.dash-grid > :only-child {
  grid-column: 1 / -1;
}

@media (max-width: 64rem) {
  .dash-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.dash-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dash-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-2);
  border-bottom: 0.0625rem solid var(--color-divider);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  text-decoration: none;
}

li:last-child > .dash-row {
  border-bottom: 0;
}

a.dash-row:hover {
  color: var(--color-text);
  background: color-mix(in srgb, var(--color-text) 4%, transparent);
}

.dash-row-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  font-size: 0.8125rem;
}

.dash-row > .cell-sub {
  flex: none;
  white-space: nowrap;
}

.dash-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}

.dash-section-title {
  margin: 0;
  font-size: 0.9375rem;
}

.dash-spend {
  min-width: 12rem;
}

.dash-spend-text {
  display: block;
  margin-bottom: var(--space-1);
  font-size: 0.75rem;
}

.home-greeting {
  margin: 0;
  font-size: 1.375rem;
}

/* AM-01: tiles above a wide project column and a narrow side column. */
.dash-tiles {
  margin-bottom: var(--space-8);
}

.dash-grid.is-wide-left {
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
}

@media (max-width: 64rem) {
  .dash-grid.is-wide-left {
    grid-template-columns: minmax(0, 1fr);
  }
}

.dash-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  min-width: 0;
}

.dash-project {
  gap: var(--space-4);
  padding: var(--space-6);
  color: var(--color-text);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.dash-project:hover {
  color: var(--color-text);
  box-shadow: 0 0 0 0.0625rem var(--color-accent);
}

.dash-project-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}

.dash-project-name {
  font-size: 1rem;
  font-weight: 500;
}

.dash-gap {
  flex: none;
}

.dash-progress {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
}

.dash-progress-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-1) var(--space-2);
  font-size: 0.6875rem;
  color: var(--color-neutral-400);
}

.dash-progress-row .limit-meter {
  grid-column: 1 / -1;
  min-width: 0;
}

.dash-progress-value {
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 40rem) {
  .dash-progress {
    grid-template-columns: minmax(0, 1fr);
  }
}

.dash-limit h2 {
  margin: 0;
  font-weight: 400;
}

.dash-limit p {
  margin: 0;
}

.dash-limit-amount {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.dash-limit-spent {
  font-size: 1.5rem;
  font-weight: 500;
}

/* WW-01 and SS-01: the greeting, the action row and "Next up". */
.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.home-actions .btn {
  flex: 1 1 auto;
}

.home-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.home-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.home-section .card-title {
  margin: 0;
  font-size: 1rem;
}

.next-task {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.next-task-icon {
  font-size: 1.25rem;
  color: var(--color-accent-300);
}

.next-task-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.task-card.next-task .btn {
  grid-column: 1 / -1;
  margin-top: 0;
}

.stat-tiles.is-compact .stat-tile-label {
  align-items: flex-start;
}

/* SS-06: one item record per card; the reference and path, quantity, chips, site and due. */
.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-2) var(--space-3);
  min-height: var(--app-touch-target);
  color: var(--color-text);
  text-decoration: none;
}

.item-row:hover {
  color: var(--color-text);
  box-shadow: 0 0 0 0.0625rem var(--color-accent);
}

.item-row:focus-visible {
  outline: 0.125rem solid var(--color-accent);
  outline-offset: 0.125rem;
}

.item-row-ref,
.item-row-due {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.item-row-qty {
  font-size: 0.8125rem;
  color: var(--color-neutral-300);
  white-space: nowrap;
}

.item-row-due {
  align-items: flex-end;
  font-size: 0.8125rem;
  text-align: right;
}

.project-items {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.project-items .task-cards > li {
  display: block;
}

/* WW-14 View Stock (F-113): the zone cards are a list; the back link sits above the page. */
.zone-cards {
  margin: 0;
  padding: 0;
  list-style: none;
}

.item-back {
  align-self: flex-start;
}

/* WW-15 Todo (F-114): a round toggle, the note with its due mark, and the row's actions. */
.todo-page,
.todo-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.todo-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.todo-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: var(--space-2) var(--space-3);
}

.todo-row.is-editing {
  display: block;
}

.todo-toggle-form {
  margin: 0;
}

.todo-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--app-touch-target);
  min-height: var(--app-touch-target);
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-accent);
  font-size: 1.75rem;
  cursor: pointer;
}

.todo-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  padding-top: var(--space-2);
}

.todo-note {
  margin: 0;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.todo-row.is-done .todo-note {
  color: var(--color-neutral-400);
  text-decoration: line-through;
}

.todo-actions {
  display: flex;
  grid-column: 2;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.todo-done summary {
  min-height: var(--app-touch-target);
  padding: var(--space-2) 0;
  color: var(--color-neutral-300);
  cursor: pointer;
}

/* CA-10: the details column wraps; dates fit the toolbar. */
.data-table .table td .audit-details {
  min-width: 16rem;
  max-width: 32rem;
  white-space: normal;
}

.audit-filters .field input[type="date"] {
  min-width: 10rem;
}

.audit-total {
  margin: 0 0 var(--space-2);
}
