:root {
  --background: #f3f5f7;
  --surface: #fff;
  --surface-soft: #f7f9fb;
  --sidebar: #14202b;
  --sidebar-hover: #223442;
  --on-sidebar: #fff;
  --text: #1b2732;
  --muted: #5f6e79;
  --border: #dfe5ea;
  --border-strong: #c7d0d8;
  --line: var(--border);
  --surface-alt: var(--surface-soft);
  --surface-strong: #eef1f4;
  --primary: #176c74;
  --primary-dark: #10575e;
  --primary-soft: #e5f3f3;
  --accent: #168267;
  --accent-text: #168267;
  --on-primary: #fff;
  --warning: #8a5000;
  --warning-soft: #fff4db;
  --danger: #ad2445;
  --danger-soft: #fff0f3;
  --info: #175ac7;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px #14202b0b, 0 12px 32px #14202b10;
  --focus: #2e8993;
  /* 0.6.1 token foundation: semantic names for values this stylesheet already used. Values reproduce 0.6.0
     except where a V2 value is marked.
     The brand colours above (--primary ... --text) are still overwritten inline by shared/js/branding.js
     from the Web Studio configuration; nothing below is, so these stay the same for every installation.
     V2 light values (here and --warning/--danger/--info above): astra_design_v2 COLOR_SYSTEM.md. */
  /* Status families: badges and operational state (always paired with a text label). */
  --status-neutral: #50616e;   --status-neutral-soft: #edf2f5;
  /* 0.6.1 V2 operational colours (astra_design_v2 COLOR_SYSTEM.md); dark values below are still 0.6.0's. */
  --status-info: #175ac7;      --status-info-soft: #eaf2ff;
  --status-progress: #8a5000;  --status-progress-soft: #fff4db;
  --status-pickup: #6934b5;    --status-pickup-soft: #f1eafe;
  --status-receiving: #006c83; --status-receiving-soft: #e2f7fb;
  --status-held: #ad2445;      --status-held-soft: #fff0f3;
  --status-success: #08763f;   --status-success-soft: #e5f8ee;
  --status-inactive: #52647a;  --status-inactive-soft: #edf1f6;
  /* Shape and elevation. */
  --radius-field: 8px;
  --radius-control: 9px;
  --radius-card: var(--radius-lg);
  --radius-dialog: 16px;
  --radius-pill: 999px;
  --shadow-flat: 0 1px 2px #14202b08;
  --shadow-dialog: 0 24px 80px #0d182557;
  /* Type. */
  --font-sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --text-base: 15px;
  --leading-base: 1.5;
  /* Density: the presentation values a display mode can tune (desktop; narrow-viewport rules keep their own). */
  --page-pad-top: 28px;
  --page-pad-x: 30px;
  --page-pad-bottom: 60px;
  --control-height: 38px;
  --field-height: 39px;
  --panel-pad: 18px;
  --card-pad: 17px;
  --grid-gap: 12px;
  --touch-target: 44px;
  color-scheme: light;
}

/* Dark mode is opt-in only: applied via [data-theme="dark"] (the sidebar
   toggle), persisted in a `theme` cookie shared by every page. With no
   cookie set, the app always starts in light mode regardless of the
   operator's OS/browser preference. */
:root[data-theme="dark"] {
  --background: #10161c;
  --surface: #1a232c;
  --surface-soft: #212b34;
  --sidebar: #0b1117;
  --sidebar-hover: #1c2731;
  --on-sidebar: #fff;
  --text: #e6ecf1;
  --muted: #93a2ad;
  --border: #2b3742;
  --border-strong: #3e4c58;
  --line: var(--border);
  --surface-alt: var(--surface-soft);
  --surface-strong: #2a3641;
  --primary: #2a9aa4;
  --primary-dark: #6fd0d9;
  --primary-soft: #123338;
  --accent: #2fb08d;
  --accent-text: #4fd1ab;
  --on-primary: #04191b;
  --warning: #e3a94e;
  --warning-soft: #3a2c14;
  --danger: #e2707a;
  --danger-soft: #3c1a1e;
  --info: #6ba8de;
  --shadow: 0 1px 2px #00000040, 0 12px 32px #00000055;
  --focus: #4fbac4;
  --status-neutral: #93a2ad;   --status-neutral-soft: #212b34;
  --status-info: #7db8e6;      --status-info-soft: #16283a;
  --status-receiving: #7db8e6; --status-receiving-soft: #16283a;
  --status-progress: #e3a94e;  --status-progress-soft: #3a2c14;
  --status-pickup: #c9a6e6;    --status-pickup-soft: #2b1f38;
  --status-held: #e2707a;      --status-held-soft: #3c1a1e;
  --status-success: #4fd1ab;   --status-success-soft: #123328;
  --status-inactive: #93a2ad;  --status-inactive-soft: #242e37;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--background); }
body {
  margin: 0;
  min-width: 320px;
  background: var(--background);
  color: var(--text);
  font: var(--text-base)/var(--leading-base) var(--font-sans);
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--primary-dark); }
h1, h2, h3, h4, p { margin-top: 0; }
h3 { font-size: clamp(1.45rem, 2vw, 1.85rem); letter-spacing: -.025em; }
h4 { font-size: 1.05rem; }
small { font-weight: 500; color: var(--muted); }
[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link {
  position: fixed;
  z-index: 1000;
  left: 12px;
  top: -80px;
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
}
.skip-link:focus { top: 12px; }

.app {
  --sidebar-width: clamp(270px, 22vw, 340px);
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns .18s ease;
}
.side {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px 18px;
  background: linear-gradient(175deg, var(--sidebar-hover), var(--sidebar) 70%);
  color: var(--on-sidebar);
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow: hidden;
}
/* .side itself no longer scrolls -- .side-top (logo) and .idle-controls
   (bottom Hide/Unhide button) are fixed flex items, and only .side-scroll
   (the nav + session-controls in between) scrolls, so the logo and the
   collapse toggle stay put no matter how long the menu gets. */
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: 0 0 auto; }
.side-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
  scrollbar-width: thin;
  scrollbar-color: #ffffff40 transparent;
}
.side-scroll::-webkit-scrollbar { width: 6px; }
.side-scroll::-webkit-scrollbar-track { background: transparent; }
.side-scroll::-webkit-scrollbar-thumb { background: #ffffff40; border-radius: 99px; }
.side-scroll::-webkit-scrollbar-thumb:hover { background: #ffffff66; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand > div { flex: 1 1 auto; min-width: 0; }
.btn.nav-toggle { display: none; flex: 0 0 auto; }
.mark {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: #e55045;
  color: #fff;
  font-weight: 900;
  font-size: 1.2rem;
  box-shadow: inset 0 0 0 1px #ffffff20;
}
.mark.has-logo {
  position: relative;
  overflow: hidden;
  padding: 0;
  background: transparent;
  color: transparent;
  font-size: 0;
  box-shadow: none;
}
/* Absolutely positioned so height:100% resolves reliably -- as a plain
   percentage height on a grid item that isn't stretched (place-items:center
   above means align-self defaults to center, not stretch), the browser falls
   back to sizing the image by its own intrinsic aspect ratio against the
   100% width, which for a wide/short mark (the sidebar's system-logo-only
   banner mode) produced an image far taller than its box, silently clipped
   by overflow:hidden into a cropped-looking center slice. */
.mark.has-logo > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.brand.uploaded-logo-only:not(.company-logo-only) > :not(.mark) { display: none; }
.side .brand.system-logo-only:not(.company-logo-only) {
  /* flex: 0 0 auto (not 1 1 auto) -- .side is itself a column flex
     container, and a flex-grow item here would consume all of the
     sidebar's leftover vertical space instead of just the logo's own
     96px, pushing nav/footer far down and leaving a large blank gap. */
  flex: 0 0 auto;
  justify-content: flex-end;
  min-height: 96px;
  width: 100%;
}
.side .brand.system-logo-only:not(.company-logo-only) > :not(.mark) { display: none; }
.side .brand.system-logo-only:not(.company-logo-only) .mark {
  width: 100%;
  height: 96px;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.side .brand.system-logo-only:not(.company-logo-only) .mark.has-logo > img { object-position: left center; }
.brand[data-company-brand].company-logo-only { justify-content: flex-end; min-height: 96px; width: 100%; }
.brand[data-company-brand].company-logo-only > :not([data-company-logo]) { display: none; }
.brand [data-company-logo] { display: none; width: 100%; height: 96px; object-fit: contain; object-position: left center; }
.brand[data-company-brand].company-logo-only [data-company-logo] { display: block; }
.brand h1 { margin: 1px 0 0; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eyebrow {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: .69rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .085em;
}
.side .eyebrow { color: var(--on-sidebar); }
.company-logo-thumb { display: block; width: 72px; height: 36px; object-fit: contain; object-position: center; border-radius: 6px; background: var(--surface-soft); }
/* The sidebar is a fixed-height flex column with `overflow: hidden`, so
   whatever sits between the logo and the session controls has to do its own
   scrolling. Nothing did: an account holding every permission renders 21 nav
   entries, which already exceeded a 900px-tall viewport and were simply
   clipped -- the last items were unreachable, with no scrollbar to say so.
   (The stylesheet anticipated a `.side-scroll` wrapper for this, but neither
   portal has ever had that element.) UpgradeUI-2's group headings made the
   column taller, so the nav now scrolls on its own. */
.nav { display: grid; gap: 3px; align-content: start; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #ffffff40 transparent; }   /* 0.6.6 M8: a short menu keeps its rows at their height, not stretched over the sidebar */
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav::-webkit-scrollbar-thumb { background: #ffffff40; border-radius: 99px; }
.nav button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  padding: 10px 13px 10px 16px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--on-sidebar);
  text-align: left;
  font-weight: 650;
  cursor: pointer;
}
.nav-icon, .side-action-icon {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.nav-icon svg, .side-action-icon svg { width: 18px; height: 18px; }
.nav-label, .side-action-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}
.nav button::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 50%;
  width: 3px;
  height: 0;
  border-radius: 99px;
  background: #68c5c7;
  transform: translateY(-50%);
  transition: height .16s ease;
}
.nav button:hover { background: #ffffff12; color: var(--on-sidebar); }
.nav button.active { background: var(--sidebar-hover); color: var(--on-sidebar); }
.nav button.active::before { height: 20px; }

/* UpgradeUI-2 -- grouped navigation.
   Daily warehouse work and system administration are both in this sidebar;
   the headings are what stop them reading as one undifferentiated list. */
/* UX-2A (§12) -- a secondary Account group inside the vendor rail.
 *
 * Ordered with `order` rather than by moving the buttons, because the vendor
 * shell lets a person DRAG its navigation into their own sequence and stores
 * it in a cookie; `applySavedNavigationOrder()` re-appends every
 * `button[data-page]` straight onto `.nav` on each start, which would pull any
 * markup group apart. `order` survives that: the two groups stay separated,
 * and a drag still reorders freely WITHIN a group. `.nav` is a grid, where
 * `order` applies to items exactly as it does in flex.
 *
 * This is the grouping only. Moving pages between groups, and the Addresses
 * and Team redesigns, belong to the later waves. */
.nav [data-nav-group-title] {
  order: 1;
  margin: 14px 0 1px;
  padding: 0 11px;
  color: var(--on-sidebar);
  opacity: .62;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.nav button[data-nav-group="account"] { order: 2; }

.nav-group { display: grid; gap: 3px; }
.nav-group + .nav-group { margin-top: 14px; }
.nav-group-items { display: grid; gap: 3px; }
.nav-group-title {
  margin: 0 0 2px;
  padding-inline: 16px;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--on-sidebar);
  opacity: .55;
}
/* Collapsed to icons, a heading has nothing to label and only eats height.
   The groups stay as spacing, which is what still separates them. */
@media (min-width: 1051px) {
  .app[data-sidebar-collapsed="true"] .nav-group-title { display: none; }
  .app[data-sidebar-collapsed="true"] .nav-group + .nav-group { margin-top: 10px; }
}
.side-footer {
  display: grid;
  gap: 14px;
  flex: 0 0 auto;
}
.side-actions { display: grid; grid-template-columns: auto 1fr 1fr; gap: 8px; }
.side-actions .btn {
  min-width: 0;
  min-height: 38px;
  padding: 8px 9px;
  border-color: #ffffff33;
  background: #ffffff0d;
  color: var(--on-sidebar);
  font-size: .78rem;
}
.side-actions .btn:hover, .side-actions .btn:focus-visible { border-color: #ffffff66; background: #ffffff1c; }
.side-actions #themeToggle { padding: 8px 11px; font-size: .95rem; }
.side-context-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.side-context-actions .btn {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 8px 10px;
  justify-content: center;
  border-color: #ffffff33;
  background: #ffffff0d;
  color: var(--on-sidebar);
  font-size: .78rem;
}
.side-context-actions .btn:hover,
.side-context-actions .btn:focus-visible {
  border-color: #ffffff66;
  background: #ffffff1c;
  color: var(--on-sidebar);
}
.side-context-actions .company-switch-button[hidden] + .tile-layout-button { grid-column: 1 / -1; }
.side-context-actions .tile-layout-button:only-child { grid-column: 1 / -1; }
.account {
  border-top: 1px solid #ffffff1c;
  padding: 16px 4px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.account .avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #ffffff16;
  color: var(--on-sidebar);
  font-size: .74rem;
  font-weight: 800;
}
.account .avatar.has-image { overflow: hidden; padding: 0; }
.account .avatar img { width: 100%; height: 100%; object-fit: cover; }
.account div { min-width: 0; }
.account strong, .account span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account div span { color: var(--on-sidebar); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
.idle-timer {
  margin: 8px 4px 0;
  font-size: .72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #ffffff80;
  letter-spacing: .02em;
}
.idle-timer::before { content: "Idle sign-out in "; font-weight: 500; }
.idle-timer.idle-timer-warning { color: #ff9d92; }
.idle-controls { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 0 0 auto; padding-top: 14px; border-top: 1px solid #ffffff1c; }
.idle-controls .idle-timer { flex: 1 1 auto; min-width: 0; }
.sidebar-collapse-toggle {
  flex: 0 0 auto;
  min-width: 38px;
  min-height: 34px;
  padding: 5px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid #ffffff33;
  border-radius: 8px;
  background: #ffffff0d;
  color: var(--on-sidebar);
  font-size: .7rem;
  font-weight: 700;
  cursor: pointer;
}
.sidebar-collapse-toggle:hover, .sidebar-collapse-toggle:focus-visible { border-color: #ffffff66; background: #ffffff1c; }
.sidebar-collapse-icon { font-size: 1.25rem; line-height: 1; transition: transform .18s ease; }
/* Unscoped (not just the >=801px collapsed-rail rules below) so Hide/Unhide
   gives the same icon-flip + label-swap feedback at every width, including
   inside the mobile menu, where the rest of the collapsed-sidebar treatment
   (icon-only rail) doesn't apply. */
.app[data-sidebar-collapsed="true"] .sidebar-collapse-label { display: none; }
.app[data-sidebar-collapsed="true"] .sidebar-collapse-icon { transform: rotate(180deg); }
/* Also unscoped: shrinking the logo down to just its icon mark is the one
   part of the collapsed-rail treatment that still makes sense on a
   full-width mobile header (it reclaims header height) -- unlike the
   sidebar-width/nav-column changes below, which only apply once there's an
   actual narrow icon rail to collapse into (>=801px). Without this, tapping
   Hide on mobile flips the button's own label but changes nothing else you
   can see. */
.app[data-sidebar-collapsed="true"] .brand > :not(.mark),
.app[data-sidebar-collapsed="true"] .brand[data-company-brand] [data-company-logo] { display: none; }
.app[data-sidebar-collapsed="true"] .brand[data-company-brand] > .mark { display: grid; }
.app[data-sidebar-collapsed="true"] .side .brand,
.app[data-sidebar-collapsed="true"] .side .brand.system-logo-only:not(.company-logo-only),
.app[data-sidebar-collapsed="true"] .side .brand[data-company-brand].company-logo-only {
  width: 44px;
  min-height: 44px;
  margin-inline: auto;
}
.app[data-sidebar-collapsed="true"] .side .brand .mark,
.app[data-sidebar-collapsed="true"] .side .brand.system-logo-only:not(.company-logo-only) .mark {
  width: 42px;
  height: 42px;
  border-radius: 11px;
}

@media (min-width: 801px) {
  .app[data-sidebar-collapsed="true"] { --sidebar-width: 76px; }
  .app[data-sidebar-collapsed="true"] .side { padding-inline: 10px; gap: 16px; overflow-x: hidden; }
  .app[data-sidebar-collapsed="true"] .side-top,
  .app[data-sidebar-collapsed="true"] .brand,
  .app[data-sidebar-collapsed="true"] .account,
  .app[data-sidebar-collapsed="true"] .idle-controls { justify-content: center; }
  .app[data-sidebar-collapsed="true"] .brand > :not(.mark),
  .app[data-sidebar-collapsed="true"] .nav-label,
  /* DEF-SHELL-01: the rail's own labels only -- 0.6.1 moved Refresh, Unlock layout, the idle timer, Switch company and
     Sign out into the top bar, which never collapses with the rail */
  .app[data-sidebar-collapsed="true"] .side .side-action-label,
  .app[data-sidebar-collapsed="true"] .account > div,
  .app[data-sidebar-collapsed="true"] .side .idle-timer,
  .app[data-sidebar-collapsed="true"] .sidebar-collapse-label,
  .app[data-sidebar-collapsed="true"] .brand[data-company-brand] [data-company-logo] { display: none; }
  .app[data-sidebar-collapsed="true"] .brand[data-company-brand] > .mark { display: grid; }
  .app[data-sidebar-collapsed="true"] .side .brand,
  .app[data-sidebar-collapsed="true"] .side .brand.system-logo-only:not(.company-logo-only),
  .app[data-sidebar-collapsed="true"] .side .brand[data-company-brand].company-logo-only {
    width: 44px;
    min-height: 44px;
    margin-inline: auto;
  }
  .app[data-sidebar-collapsed="true"] .side .brand .mark,
  .app[data-sidebar-collapsed="true"] .side .brand.system-logo-only:not(.company-logo-only) .mark {
    width: 42px;
    height: 42px;
    border-radius: 11px;
  }
  .app[data-sidebar-collapsed="true"] .nav button { justify-content: center; padding: 11px 8px; }
  .app[data-sidebar-collapsed="true"] .nav button::before { left: 1px; }
  .app[data-sidebar-collapsed="true"] .side-actions { grid-template-columns: 1fr; }
  .app[data-sidebar-collapsed="true"] .side-actions .btn {
    width: 44px;
    margin-inline: auto;
    padding-inline: 8px;
    font-size: 0;
  }
  .app[data-sidebar-collapsed="true"] .side-actions .btn > span { font-size: 1rem; }
  .app[data-sidebar-collapsed="true"] .side-context-actions { grid-template-columns: 1fr; }
  .app[data-sidebar-collapsed="true"] .side-context-actions .btn {
    width: 44px;
    margin-inline: auto;
    padding-inline: 8px;
    justify-content: center;
  }
  .app[data-sidebar-collapsed="true"] .account { padding-inline: 0; }
  .app[data-sidebar-collapsed="true"] .sidebar-collapse-icon { transform: rotate(180deg); }
}

.work { min-width: 0; padding: var(--page-pad-top) var(--page-pad-x) var(--page-pad-bottom); }
.top {
  margin: calc(-1 * var(--page-pad-top)) calc(-1 * var(--page-pad-x)) 26px;
  padding: 16px var(--page-pad-x);
  min-height: 80px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  background: var(--background);
  background: var(--background);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}
.top h2 { margin: 2px 0 0; font-size: 1.35rem; letter-spacing: -.02em; }
.breadcrumb { display: flex; gap: 7px; align-items: center; color: var(--muted); font-size: .72rem; }
.breadcrumb strong { color: var(--text); }
.actions, .split-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn {
  min-height: var(--control-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  padding: 8px 13px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  line-height: 1.2;
  cursor: pointer;
}
.btn:hover { border-color: var(--border-strong); background: var(--surface-soft); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.danger { color: var(--danger); border-color: #e5b9bd; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.icon { min-width: 38px; padding: 6px 10px; font-size: 1.2rem; }
.btn.small { min-height: 31px; padding: 6px 9px; font-size: .8rem; }
.btn[disabled], .btn[aria-disabled="true"] {
  /* Plain opacity used to wash light-on-light buttons out to
     near-invisible (text/border/fill all faded toward the page
     background at once, unlike colored variants which stayed
     legible). Explicit muted colors keep contrast readable while
     still looking clearly disabled. */
  opacity: 1;
  background: var(--surface-soft);
  color: var(--muted);
  border-color: var(--border);
  cursor: not-allowed;
}
.btn[disabled]:hover, .btn[aria-disabled="true"]:hover { background: var(--surface-soft); border-color: var(--border); }
.btn:focus-visible, .nav button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [role="button"]:focus-visible, tr[tabindex]:focus-visible,
a:focus-visible, .table[tabindex]:focus-visible, .sort-button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.page { display: none; width: 100%; min-width: 0; }
.page.active { display: block; }
.page-heading {
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
}
.page-heading h3 { margin: 0 0 4px; }
.page-heading p { margin: 0; max-width: 740px; color: var(--muted); }
/* Every page used to name itself three times -- breadcrumb, top-bar <h2>, then
   a page-heading <h3> repeating it verbatim ("Orders / Orders / ORDER
   PROCESSING / Orders"). The top bar is the page title; the section heading
   below it now carries the eyebrow's words, which were the only ones that said
   anything new. Keeps a heading in the outline and buys back a line above the
   fold on every page. */
.page-heading h3.eyebrow, .head h3.eyebrow { margin: 0; }
.page-heading h3.eyebrow + p, .head h3.eyebrow + p { margin-top: 5px; }
/* Compatibility for the vendor portal and first-start screen. */
.head {
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
}
.head h3 { margin: 0; }
.panel, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
}
.panel { padding: var(--panel-pad); margin-bottom: 18px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.panel-heading h4 { margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--grid-gap); margin-bottom: 18px; }
.card { padding: var(--card-pad); }
.dashboard-tiles-unlocked .dashboard-tile,
.dashboard-tiles-unlocked .workspace-tile {
  border-style: dashed;
  cursor: grab;
  user-select: none;
}
.dashboard-tiles-unlocked .dashboard-tile:active,
.dashboard-tiles-unlocked .workspace-tile:active { cursor: grabbing; }
.dashboard-tile-dragging {
  opacity: .48;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.navigation-tiles-unlocked button[data-page] {
  box-shadow: inset 0 0 0 1px #ffffff2e;
  cursor: grab;
}
.navigation-tiles-unlocked button[data-page]:active { cursor: grabbing; }
.navigation-tiles-unlocked button.navigation-tile-dragging {
  opacity: .48;
  box-shadow: inset 0 0 0 2px #68c5c7;
}
.checkout-layout-unlocked > .checkout-layout-tile {
  position: relative;
  outline: 1px dashed color-mix(in srgb, var(--primary) 65%, var(--border));
  outline-offset: 5px;
  border-radius: 7px;
  cursor: grab;
}
.checkout-layout-unlocked > .checkout-layout-tile::after {
  content: "⋮⋮";
  position: absolute;
  top: -2px;
  right: 2px;
  color: var(--primary);
  font-weight: 900;
  letter-spacing: -2px;
  pointer-events: none;
}
.checkout-layout-unlocked > .checkout-layout-tile:active { cursor: grabbing; }
.checkout-layout-tile-dragging { opacity: .5; }
.checkout-stage #orderHeaderForm {
  padding: 14px;
  gap: 9px 12px;
}
.checkout-stage #orderHeaderForm .field { gap: 3px; }
.checkout-stage #orderHeaderForm .field > span { font-size: .72rem; }
.checkout-stage #orderHeaderForm input,
.checkout-stage #orderHeaderForm select,
.checkout-stage #orderHeaderForm textarea {
  min-height: 34px;
  padding: 6px 9px;
}
.checkout-stage #orderHeaderForm textarea { min-height: 70px; }
.checkout-stage #orderHeaderForm .field.checkbox { min-height: 32px; }
.checkout-stage #orderHeaderForm .section-divider { margin: 9px 0 3px; }
.checkout-stage #orderHeaderForm > .section-divider:first-child { margin-top: 1px; }
.checkout-stage #checkoutAddressStatus { font-size: .78rem; line-height: 1.25; }
.checkout-stage #checkoutAddressActions { margin-top: 1px; }
.multiline-text { white-space: pre-wrap; }
.card span { display: block; color: var(--muted); font-size: .78rem; font-weight: 700; }
.card strong { display: block; margin-top: 5px; font-size: 1.75rem; line-height: 1.1; }
.cards .card strong { max-width: 100%; overflow-wrap: anywhere; }
.metric-card, .status-card { text-align: left; }
button.card { width: 100%; color: inherit; cursor: pointer; }
button.card:hover { border-color: #a8bec1; box-shadow: 0 2px 4px #14202b0d, 0 16px 34px #14202b13; }
.metric-card[data-tone="warning"] { border-top: 3px solid #d79338; }
.metric-card[data-tone="info"] { border-top: 3px solid #5e8dbb; }
.metric-card[data-tone="success"] { border-top: 3px solid #49a087; }
.status-card.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.queue-panel { min-height: 160px; }
.company-card-grid {
  width: 100%;
  max-width: 1040px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.company-choice-card {
  width: 100%;
  min-height: 92px;
  padding: 16px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
}
.company-choice-card:hover { border-color: var(--primary); background: var(--primary-soft); transform: translateY(-1px); }
.company-choice-card:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.company-choice-card.current { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 2px var(--primary-soft); }
.company-choice-card.current:disabled { opacity: 1; cursor: default; transform: none; }
.company-choice-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: .8rem;
  font-weight: 900;
  letter-spacing: .04em;
}
.company-choice-copy { min-width: 0; }
.company-choice-copy strong, .company-choice-copy small { display: block; overflow: hidden; text-overflow: ellipsis; }
.company-choice-copy strong { font-size: 1rem; }
.company-choice-copy small { margin-top: 4px; color: var(--muted); font-size: .72rem; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.company-choice-arrow { color: var(--primary); font-size: 1.35rem; }
.company-choice-status { color: var(--primary-dark); font-size: .68rem; font-weight: 850; text-transform: uppercase; letter-spacing: .04em; }
.company-card-grid[aria-busy="true"] { opacity: .65; pointer-events: none; }
dialog.company-switch-dialog { width: min(760px, calc(100vw - 28px)); height: auto; max-height: min(82vh, 760px); }

.filter-toolbar {
  display: flex;
  align-items: flex-end;
  gap: 11px;
  flex-wrap: wrap;
  box-shadow: none;
}
.filter-toolbar.compact { margin-bottom: 14px; padding: 0; border: 0; box-shadow: none; }
.filter-toolbar .field { min-width: 150px; flex: 1 1 150px; }
.filter-toolbar .search-field { min-width: min(280px, 100%); flex-grow: 2; }
.field { display: grid; gap: 6px; }
.field.checkbox {
  min-height: 39px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.field.checkbox input { width: 17px; min-height: 17px; height: 17px; margin: 0; }
.field > span, .check-field > span {
  color: var(--muted);
  font-size: .76rem;
  font-weight: 750;
}
.check-field { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; }
.check-field input { width: 17px; height: 17px; margin: 0; }
input, select, textarea {
  width: 100%;
  min-height: var(--field-height);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-field);
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-soft); color: var(--muted); }
.material-search { position: relative; min-width: min(320px, 52vw); }
.order-material-results, .material-search-results { margin-top: 6px; overflow: auto; max-height: 220px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.material-search-result { display: grid; width: 100%; gap: 1px; padding: 9px 10px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.material-search-result:last-child { border-bottom: 0; }
.material-search-result:hover, .material-search-result:focus-visible { background: var(--primary-soft); outline: 0; }
.material-search-result strong { font-size: .84rem; }
.material-search-result span { font-weight: 650; }
.material-search-result small { font-size: .72rem; }
.material-search-empty { margin: 0; padding: 10px; color: var(--muted); font-size: .82rem; }
/* UpgradeUI-8 second closure (B3): a truncated list has to be able to say so. */
.assignee-note { min-height: 0; margin-top: 5px; font-size: .74rem; font-weight: 700; }
.line-material-selection { display: block; min-height: 1.25em; margin-top: 5px; }
.form-stack { display: grid; gap: 14px; }
.form-stack.narrow { width: min(560px, 100%); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; align-items: end; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.span-2 { grid-column: 1 / -1; }
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: center; }
.form-sections { display: grid; gap: 17px; }
fieldset { margin: 0; padding: 15px; border: 1px solid var(--border); border-radius: 12px; }
legend { padding: 0 7px; color: var(--text); font-size: .86rem; font-weight: 800; }
.form-error {
  padding: 10px 12px;
  border: 1px solid #e5b9bd;
  border-radius: 8px;
  background: var(--danger-soft);
  color: #8e2831;
  font-weight: 650;
}
.form-error:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
.form-error[data-kind="conflict"] { border-color: #e1c185; background: var(--warning-soft); color: #73501e; }
.form-error[data-kind="forbidden"] { border-color: #c6cbd1; background: #f2f4f6; color: #4c5964; }
:root[data-theme="dark"] .form-error { color: #f3b6bd; }
:root[data-theme="dark"] .form-error[data-kind="conflict"] { color: #f0c78c; }
:root[data-theme="dark"] .form-error[data-kind="forbidden"] { border-color: var(--border-strong); background: var(--surface-soft); color: var(--muted); }

.table {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  contain: layout paint;
  overflow: auto;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-flat);
}
table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: .84rem; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; vertical-align: middle; }
th {
  position: sticky;
  z-index: 1;
  top: 0;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}
tbody tr:last-child td { border-bottom: 0; }
.selectable-table tbody tr[data-record-id] { cursor: pointer; }
.selectable-table tbody tr[data-record-id]:hover td { background: var(--surface-soft); }
.selectable-table tbody tr.selected td { background: var(--primary-soft); }
.selectable-table tbody tr.selected td:first-child { box-shadow: inset 4px 0 var(--primary); }
.selectable-table tbody tr:focus-visible td { background: var(--primary-soft); }
.primary-cell { font-weight: 800; color: var(--text); }
.secondary-cell { display: block; color: var(--muted); font-size: .74rem; font-weight: 500; }
.number { text-align: right; font-variant-numeric: tabular-nums; }
.empty-cell { padding: 28px; text-align: center; color: var(--muted); white-space: normal; }
.loading-cell, .error-cell { padding: 28px; text-align: center; color: var(--muted); white-space: normal; }
.loading-cell::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 9px;
  vertical-align: -2px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.error-cell { color: var(--danger); }
.grid-table { margin-bottom: 12px; }
.grid-table table { min-width: 980px; }
.grid-table th, .grid-table td { padding: 6px; }
.grid-table input, .grid-table select, .grid-table textarea { min-width: 90px; padding: 7px 8px; font-size: .82rem; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: var(--radius-pill);
  padding: 4px 8px;
  background: var(--status-neutral-soft);
  color: var(--status-neutral);
  font-size: .68rem;
  font-weight: 850;
  line-height: 1.2;
  letter-spacing: .025em;
  text-transform: uppercase;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge.ACTIVE, .badge.AVAILABLE, .badge.RECEIVED, .badge.SHIPPED, .badge.APPROVED, .badge.COMPLETED, .badge.ACCEPTED {
  background: var(--status-success-soft); color: var(--status-success);
}
.badge.ORDERED, .badge.SUBMITTED, .badge.OPEN, .badge.DRAFT { background: var(--status-info-soft); color: var(--status-info); }
.badge.WORKING, .badge.RECEIVING, .badge.IN_PROGRESS, .badge.PARTIALLY_RECEIVED { background: var(--status-progress-soft); color: var(--status-progress); }
.badge.PACKED, .badge.WAITING_FOR_PICKUP, .badge.PENDING_APPROVAL, .badge.QUARANTINE { background: var(--status-pickup-soft); color: var(--status-pickup); }
.badge.ON_HOLD, .badge.HOLD, .badge.REJECTED, .badge.DAMAGED { background: var(--status-held-soft); color: var(--status-held); }
.badge.CANCELLED, .badge.VOIDED, .badge.INACTIVE { background: var(--status-inactive-soft); color: var(--status-inactive); }
.badge.urgent { background: var(--status-held-soft); color: var(--status-held); }
.badge.standard { background: var(--status-neutral-soft); color: var(--status-neutral); }

/* Status badges take their colours from the --status-* tokens, whose dark values live in the dark :root
   block, so a badge reads correctly on a dark page without a second rule set. One exception kept from 0.6.0:
   in dark mode the `standard` priority chip uses the inactive pair, not the neutral one. */
:root[data-theme="dark"] .badge.standard { background: var(--status-inactive-soft); color: var(--status-inactive); }

.pagination { min-height: 44px; display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: .8rem; }
.pagination-size { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; white-space: nowrap; }
.pagination-size input {
  width: 78px;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.pagination-size input:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.queue-tabs { display: flex; gap: 4px; margin-bottom: 12px; padding: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); }
.queue-tabs button {
  flex: 0 0 auto;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
  cursor: pointer;
}
.queue-tabs button[aria-selected="true"] { background: var(--surface); color: var(--primary-dark); box-shadow: inset 0 -2px var(--primary); }
.sort-button {
  width: 100%;
  min-width: max-content;
  margin: -7px -8px;
  padding: 7px 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-align: left;
  text-transform: inherit;
  cursor: pointer;
}
.sort-button:hover { background: var(--surface-soft); color: var(--text); }
.sort-button.number { justify-content: flex-end; }
.sort-indicator { width: 10px; color: var(--primary-dark); font-size: .8rem; line-height: 1; }
.sort-button[data-active-sort="true"] .sort-indicator::before { content: "▲"; }
.sort-button[data-active-sort="true"][data-sort-direction="desc"] .sort-indicator::before { content: "▼"; }
.progress { display: inline-flex; align-items: center; gap: 8px; }
.progress-track { width: 70px; height: 6px; overflow: hidden; border-radius: 99px; background: var(--border); }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }

.page-state {
  position: fixed;
  z-index: 50;
  left: 50%;
  top: 88px;
  transform: translateX(-50%);
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 750;
}
.page[aria-busy="true"] { cursor: progress; }
.page-feedback {
  margin: 0 0 18px;
  padding: 15px 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid #e4b8bc;
  border-left: 5px solid var(--danger);
  border-radius: 11px;
  background: var(--danger-soft);
  color: #842c34;
}
.page-feedback[data-kind="conflict"] { border-color: #e6ca96; border-left-color: var(--warning); background: var(--warning-soft); color: #73501e; }
.page-feedback[data-kind="forbidden"] { border-color: #cbd3da; border-left-color: #667582; background: #f1f4f6; color: #46545f; }
.page-feedback strong { display: block; font-size: 1rem; }
.page-feedback p { margin: 3px 0 0; color: inherit; }
:root[data-theme="dark"] .page-feedback { color: #f3b6bd; }
:root[data-theme="dark"] .page-feedback[data-kind="conflict"] { color: #f0c78c; }
:root[data-theme="dark"] .page-feedback[data-kind="forbidden"] { border-color: var(--border-strong); border-left-color: var(--muted); background: var(--surface-soft); color: var(--muted); }
.toast-region { position: fixed; z-index: 100; right: 22px; top: 90px; width: min(380px, calc(100vw - 44px)); display: grid; gap: 8px; }
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--info);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-weight: 650;
}
.toast-message { min-width: 0; overflow-wrap: anywhere; }
.toast-close {
  flex: 0 0 auto;
  margin: -4px -5px -4px auto;
  padding: 0;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
}
.toast-close:hover, .toast-close:focus-visible { background: var(--surface-alt); }
.toast.success { border-left-color: var(--accent); }
.toast.error { border-left-color: var(--danger); }
.empty-state { padding: 26px; color: var(--muted); text-align: center; }
.info-banner, .warning-box {
  margin-bottom: 16px;
  padding: 12px 14px;
  display: flex;
  gap: 8px 16px;
  flex-wrap: wrap;
  border: 1px solid #b8d8da;
  border-radius: 10px;
  background: var(--primary-soft);
  color: #234c50;
}
.warning-box { border-color: #edd1a5; background: var(--warning-soft); color: #77501c; }
.section-divider { margin: 24px 0 10px; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .72rem; font-weight: 850; text-transform: uppercase; letter-spacing: .05em; }
.section-divider small { font-size: .68rem; font-weight: 700; letter-spacing: 0; text-transform: none; }
.section-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.record-summary { margin-bottom: 14px; }
.record-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section-head h4 { margin: 0; }
.material-images { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.material-images figure { margin: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.material-images img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--surface-soft); }
.material-images figcaption { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px; color: var(--muted); font-size: .78rem; }
/* Row actions must stay on one line. `.actions` wraps by design, which is right
   in a panel footer but wrong inside a table cell: with up to seven buttons in
   a ~120px column it turned every account row into a vertical button stack,
   inflating rows from ~44px to 288px and pushing four records off a 1000px
   screen. The table already scrolls horizontally when the actions need it. */
tbody td .actions { flex-wrap: nowrap; gap: 6px; }

/* With `nowrap` on every cell, the single longest value in a column sets that
   column's width forever: one 90-character audit actor claimed 432px and a
   41-character company name 355px, pushing later columns off-screen on six
   pages. Cap the ordinary cells and clip instead -- table-tools puts the full
   value in a title on any cell that actually got clipped. Cells holding row
   actions or form controls are exempt: their width is real, not runaway. */
.table:not(.grid-table) table td,
.table:not(.grid-table) table th { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
/* These must out-specify the cap above, or the exemption silently loses and the
   row actions get clipped -- which is the one thing the exploded view forbids. */
.table:not(.grid-table) table td:has(input, select, textarea, .actions) { max-width: none; }
.table:not(.grid-table) table .empty-cell,
.table:not(.grid-table) table .loading-cell,
.table:not(.grid-table) table .error-cell { max-width: none; overflow: visible; }

/* Column reordering and resizing, enabled by the Unlock layout button. */
table.columns-unlocked thead th { cursor: grab; position: relative; }
table.columns-unlocked thead th:hover { background: var(--primary-soft); }
table.columns-unlocked thead th:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
thead th.column-dragging { opacity: .55; cursor: grabbing; }
/* The grip sits wholly inside its own header. Straddling the column edge gave
   it a ~4px hit area, because the neighbouring header won the hit test for
   everything past the boundary. */
.col-resize {
  position: absolute;
  top: 0;
  right: 0;
  width: 11px;
  height: 100%;
  cursor: col-resize;
  z-index: 3;
}
.col-resize::after {
  content: "";
  position: absolute;
  top: 18%;
  right: 3px;
  width: 2px;
  height: 64%;
  border-radius: 2px;
  background: var(--primary);
  opacity: .35;
}
.col-resize:hover::after { opacity: 1; }
body.resizing-column { cursor: col-resize; user-select: none; }

/* Hidden columns. A column is only gone while the layout is locked; unlock and
   it returns as a narrow stub carrying the button that brings it back, so a
   column can never go missing with no way to find it again. */
.col-hidden { display: none; }
table.columns-unlocked th.col-hidden,
table.columns-unlocked td.col-hidden {
  display: table-cell;
  width: 24px;
  min-width: 24px;
  max-width: 24px;
  padding-left: 0;
  padding-right: 0;
  overflow: hidden;
  background: var(--surface-soft);
}
table.columns-unlocked th.col-hidden > :not(.col-hide),
table.columns-unlocked td.col-hidden > * { visibility: hidden; }
table.columns-unlocked th.col-hidden { color: transparent; }
table.columns-unlocked td.col-hidden { color: transparent; }
.col-hide {
  position: absolute;
  top: 50%;
  right: 13px;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}
.col-hide:hover { background: var(--danger-soft); color: var(--danger); }
table.columns-unlocked th.col-hidden .col-hide {
  right: 50%;
  transform: translate(50%, -50%);
  background: var(--primary);
  color: var(--on-primary);
}
table.columns-unlocked th.col-hidden .col-hide:hover { background: var(--primary-dark); }
/* Once a column has an explicit width, its content must clip rather than
   force the column back open. */
table.columns-sized th, table.columns-sized td { overflow: hidden; text-overflow: ellipsis; }
table.columns-sized td .actions { overflow: visible; }
/* Denser data rows: the person cell is only 40px tall, so the old 11px cell
   padding plus a 40px avatar was most of the row height for no information. */
.table thead th { padding-top: 9px; padding-bottom: 9px; }
.table tbody td { padding-top: 7px; padding-bottom: 7px; }
.table .person-cell { min-width: 0; }
.table .person-avatar { width: 30px; height: 30px; font-size: .68rem; }
.table .person-cell small { font-size: .78rem; opacity: .85; }

.person-cell { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.person-cell > div { min-width: 0; }
.person-cell strong, .person-cell small { display: block; overflow: hidden; text-overflow: ellipsis; }
.person-avatar {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: .75rem;
  font-weight: 850;
}
.person-avatar img { width: 100%; height: 100%; object-fit: cover; }
.record-grid > div { padding: 10px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-soft); }
.record-grid span { display: block; margin-bottom: 3px; color: var(--muted); font-size: .7rem; font-weight: 750; text-transform: uppercase; }
.record-grid strong { overflow-wrap: anywhere; }
.editable-detail-card {
  position: relative;
  min-width: 0;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.editable-detail-card > small {
  position: absolute;
  right: 9px;
  top: 7px;
  color: var(--primary);
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  opacity: 0;
}
.editable-detail-card:hover,
.editable-detail-card:focus-visible {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 18%, transparent);
  outline: none;
}
.editable-detail-card:hover > small,
.editable-detail-card:focus-visible > small { opacity: 1; }
.editable-description-card {
  min-height: 56px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-soft);
}
.editable-description-card p { margin: 0; padding-right: 34px; white-space: pre-wrap; overflow-wrap: anywhere; }
.inline-detail-form { display: grid; gap: 8px; width: 100%; cursor: default; }
.inline-detail-form input,
.inline-detail-form textarea { width: 100%; min-width: 0; }
.inline-detail-form .actions { margin-top: 0; }
.inline-dimension-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.inline-dimension-grid label { display: grid; gap: 3px; min-width: 0; }
.record-grid .inline-detail-form span,
.record-grid .inline-dimension-grid span { margin: 0; font-size: .66rem; }
.record-grid .inline-detail-form .check-field span { font-size: .76rem; text-transform: none; }
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { position: relative; padding: 0 0 17px 25px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--primary); }
.timeline li::after { content: ""; position: absolute; left: 9px; top: 16px; width: 1px; bottom: 0; background: var(--border-strong); }
.timeline li:last-child::after { display: none; }
.timeline p { margin: 2px 0 0; color: var(--muted); font-size: .78rem; }
.detail-columns { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(260px, .7fr); gap: 18px; }
.detail-section { margin-bottom: 20px; }
.detail-section h4 { margin: 0 0 9px; }
.order-address-lines { padding: 3px 0 4px; }
.order-address-lines p { margin: 0; padding: 3px 0; overflow-wrap: anywhere; }
.order-address-lines p + p { color: var(--muted); }
.receipt-line-list { display: grid; gap: 12px; }
.receipt-line-card { padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: 0 1px 2px #14202b08; }
.receipt-line-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.receipt-line-head h5 { margin: 2px 0; font-size: 1rem; }
.receipt-line-head p, .receipt-line-note p { margin: 0; color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.receipt-line-head > strong { flex: 0 0 auto; color: var(--primary-dark); font-size: .88rem; }
.receipt-line-card .record-grid { grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); }
.receipt-line-note { margin-top: 10px; padding: 10px 11px; border-radius: 9px; background: var(--surface-soft); }
.receipt-line-note strong { display: block; margin-bottom: 3px; font-size: .72rem; }
.quantity-comparison { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quantity-comparison > div { padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); }
.quantity-comparison span { display: block; color: var(--muted); font-size: .7rem; font-weight: 750; text-transform: uppercase; }
.quantity-comparison strong { display: block; margin-top: 4px; font-size: 1.35rem; }
.audit-builder { max-height: 340px; }
.audit-options { margin-top: 15px; }
.selection-count { margin-right: auto; color: var(--muted); font-weight: 700; }
.validation-result { margin-top: 16px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-soft); }
.validation-result ul { margin: 8px 0 0; padding-left: 20px; max-height: 220px; overflow: auto; }
.steps { display: flex; gap: 5px; list-style: none; padding: 0; margin: 0 0 18px; overflow-x: auto; }
.steps li { flex: 1 0 auto; padding: 7px 9px; border-bottom: 2px solid var(--border); color: var(--muted); font-size: .72rem; font-weight: 750; text-align: center; }
.steps li.active { border-color: var(--primary); color: var(--primary-dark); }

.warehouse-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, .6fr);
  gap: 18px;
  align-items: start;
}
.warehouse-map, .label-workbench { margin-bottom: 0; }
.label-workbench { position: sticky; top: 102px; }
.location-tree { display: grid; gap: 14px; }
.warehouse-group {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}
.warehouse-group-header {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.warehouse-group-header h5 { margin: 0; font-size: .96rem; }
.warehouse-group-header p { margin: 2px 0 0; color: var(--muted); font-size: .75rem; }
.warehouse-group-actions { display: flex; align-items: center; gap: 8px; }
.warehouse-location-panel { position: relative; }
.warehouse-location-panel.is-collapsed { max-height: 390px; overflow: hidden; }
.warehouse-location-panel.is-collapsed::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 58px;
  content: "";
  pointer-events: none;
  background: linear-gradient(transparent, var(--surface-soft));
}
.warehouse-location-panel.is-expanded {
  max-height: min(64vh, 680px);
  overflow-y: auto;
  scrollbar-gutter: stable;
}
.warehouse-list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.warehouse-list-footer span { color: var(--muted); font-size: .75rem; text-align: right; }
.location-list { display: grid; gap: 7px; margin: 0; padding: 10px; list-style: none; }
.location-children { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.location-node { display: grid; gap: 6px; }
.location-node[data-depth="1"] { margin-left: 24px; }
.location-node[data-depth="2"] { margin-left: 48px; }
.location-card {
  width: 100%;
  min-height: 54px;
  padding: 9px 11px;
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.location-card:hover, .location-card[aria-current="true"] { border-color: #9fc2c5; background: var(--primary-soft); }
.location-type-icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #edf2f5;
  color: #50616e;
  font-size: .67rem;
  font-weight: 900;
}
.location-card[data-type="RACK"] .location-type-icon { background: #eaf1f8; color: #356d9d; }
.location-card > span:nth-child(2) { min-width: 0; flex: 1; }
.location-card strong, .location-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.location-card small { color: var(--muted); }
.location-card .badge { flex: 0 0 auto; }
.location-label-preview { display: grid; gap: 14px; }
.location-label-preview img {
  display: block;
  width: min(100%, 360px);
  margin: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.location-label-preview h5 { margin: 0; font-size: 1.15rem; text-align: center; }
.location-label-preview p { margin: 0; color: var(--muted); text-align: center; }
.stock-label-section { display: grid; gap: 10px; }
.stock-label-section .section-divider { margin-top: 6px; }
.stock-label-section > .muted { margin: 0; font-size: .78rem; }
.stock-label-list { display: grid; gap: 8px; max-height: 460px; overflow: auto; }
.stock-label-card { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 9px; align-items: center; padding: 9px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-soft); }
.stock-label-card img { width: 62px; height: 62px; padding: 3px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.stock-label-card strong, .stock-label-card span, .stock-label-card small { display: block; overflow-wrap: anywhere; }
.stock-label-card span, .stock-label-card small { color: var(--muted); font-size: .72rem; }
.stock-label-card .actions { grid-column: 1 / -1; }
.empty-state.compact { padding: 14px; font-size: .8rem; }

.data-console textarea {
  min-height: 130px;
  font: .84rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.data-query-result { margin-top: 16px; }
.raw-data-table { min-height: 180px; }
.raw-data-table table, .data-query-result table { min-width: max-content; }
.raw-data-table td, .data-query-result td { max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
.print-frame {
  position: fixed;
  width: 1px;
  height: 1px;
  right: 0;
  bottom: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}
.raw-null { color: var(--muted); font-style: italic; }
.raw-json { font: .76rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
/* An identifier is read character by character against something written down
   elsewhere, so it gets a monospace face -- a proportional font makes l/1 and
   O/0 a guessing game. `.record-grid strong` already wraps these; inside a
   table the shared cell cap ellipsizes them and the full value is on `title`. */
.identifier-cell { font: .76rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 460px);
  gap: 20px;
  align-items: start;
}
.settings-editor { min-width: 0; }
.settings-preview { position: sticky; top: 102px; }
.theme-controls { display: grid; grid-template-columns: repeat(4, minmax(100px, 1fr)); gap: 10px; }
.color-field {
  padding: 10px;
  display: grid;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .74rem;
  font-weight: 750;
}
.color-field input { min-height: 42px; padding: 3px; }
.media-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.media-control {
  padding: 12px;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
}
.media-control p { margin: 2px 0 8px; font-size: .75rem; }
.media-preview {
  min-height: 96px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: #fff;
}
.media-preview.landscape { background: linear-gradient(145deg, #182b36, #24404b); }
.media-preview img { width: 100%; height: 100%; object-fit: contain; }
.media-preview.landscape img { object-fit: cover; }
.settings-savebar {
  position: sticky;
  z-index: 10;
  bottom: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.mini-login {
  min-height: 390px;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 30px #14202b12;
}
.mini-login-hero, .mini-login-form { padding: 24px; display: flex; flex-direction: column; justify-content: space-between; }
.mini-login-hero { background: var(--sidebar); color: var(--preview-on-sidebar, var(--on-sidebar)); }
.mini-login-hero h5 { margin: 0 0 10px; font-size: 1.08rem; }
.mini-login-hero p { margin: 0; color: inherit; font-size: .76rem; }
.mini-brand { display: flex; align-items: center; gap: 10px; }
.mini-brand small, .mini-brand strong { display: block; }
.mini-login-form { justify-content: center; gap: 10px; background: #fff; color: #17212b; }
.mini-login-form h5 { margin: 0 0 8px; font-size: 1.15rem; color: inherit; }
.mini-login-form > small { color: #5f6e79; }
.fake-input { display: block; height: 34px; border: 1px solid var(--border-strong); border-radius: 7px; }
.fake-button { display: block; margin-top: 8px; padding: 8px; border-radius: 7px; background: var(--primary); color: var(--preview-on-primary, var(--on-primary)); font-weight: 800; text-align: center; }

dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: min(90vh, 920px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-dialog);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-dialog);
}
dialog::backdrop { background: #0d1825a8; backdrop-filter: blur(2px); }
dialog[open] { display: block; }
dialog.wide-dialog { width: min(1180px, calc(100vw - 28px)); }
dialog.drawer {
  width: min(760px, 94vw);
  height: 100vh;
  max-height: 100vh;
  margin: 0 0 0 auto;
  border-radius: 16px 0 0 16px;
}
dialog.order-drawer { width: min(880px, 96vw); }
dialog.receipt-drawer { width: min(940px, 96vw); }
dialog.order-summary-dialog { width: min(960px, calc(100vw - 28px)); height: min(90vh, 920px); }
.dialog-shell { display: flex; flex-direction: column; max-height: inherit; height: 100%; min-height: 0; }
.dialog-header, .dialog-footer { flex: 0 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 16px 18px; }
.dialog-header { border-bottom: 1px solid var(--border); }
.dialog-header h3 { margin: 0; font-size: 1.25rem; }
.dialog-body { flex: 1 1 auto; min-height: 0; padding: 18px; overflow: auto; }
.dialog-body { overscroll-behavior: contain; }
/* 0.6.6 M4.1: while a modal is open the page behind does not scroll -- a wheel or a swipe over the backdrop moved it
   (overscroll-behavior on the dialog stops Chromium, not WebKit). Screen only: printing an open order is not clipped. */
@media screen { html:has(dialog:modal) { overflow: hidden; scrollbar-gutter: stable; } }
.dialog-footer { border-top: 1px solid var(--border); justify-content: flex-end; flex-wrap: wrap; background: var(--surface-soft); }
.dialog-action-error { flex: 0 0 100%; margin-bottom: 12px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type="file"] { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.permission-dialog-layout { display: grid; grid-template-columns: 1fr 320px; gap: 22px; align-items: start; margin-top: 10px; }
.permission-dialog-fields .form-stack { position: sticky; top: 0; }
.permission-groups { margin-top: 12px; max-height: 60vh; overflow: auto; border: 1px solid var(--border); border-radius: 9px; padding: 4px 14px; }
.permission-group { padding: 10px 0; border-bottom: 1px solid var(--border); columns: 2; column-gap: 20px; }
.permission-group:last-child { border-bottom: 0; }
.permission-group h4 { margin: 0 0 7px; color: var(--muted); font-size: .73rem; text-transform: uppercase; letter-spacing: .05em; column-span: all; }
.permission-group label { display: flex; align-items: center; gap: 8px; padding: 4px 1px; cursor: pointer; break-inside: avoid; }
.permission-group input { width: auto; min-height: auto; }
.permission-group label[hidden] { display: none; }

/* --------------------------------------------------------------------------
   M10.5 -- the outbound email operator surface.

   The colour choices here are the honesty requirement expressed in CSS.

   ACCEPTED_BY_PROVIDER deliberately does NOT reuse the green that .ACCEPTED,
   .SHIPPED and .COMPLETED share. Those mean the work finished; this one means
   Microsoft Graph answered 202 -- "accepted for processing", which its own
   documentation says "doesn't indicate that the request processing has
   completed". Painting it the same green as a completed order would make the
   page assert a delivery this system cannot observe, so it gets its own
   restrained teal-blue: progress, not completion.

   DELIVERY_UNKNOWN gets a colour nothing else on the page uses, plus a dashed
   border and an inline "operator required" affordance. It must not read as a
   failure (it may have reached the customer) and must not read as a success
   (it may not have). A state that is genuinely neither should look like
   neither, and should look like it is waiting for a person.
   -------------------------------------------------------------------------- */
.badge.QUEUED, .badge.CLAIMED { background: #eaf1f8; color: #356d9d; }
.badge.DISPATCHING { background: #e7f1f4; color: #2c6b7b; }
.badge.RETRY_WAIT { background: #fff2dc; color: #966017; }
.badge.ACCEPTED_BY_PROVIDER, .badge.RESOLVED_ACCEPTED { background: #e2eff3; color: #245f70; }
.badge.FAILED_PERMANENT { background: #fdebed; color: #a8333e; }
.badge.CANCELLED, .badge.RESOLVED_NOT_SENT { background: #f0f1f2; color: #707c85; }
.badge.DELIVERY_UNKNOWN {
  border: 1px dashed #8a63b8;
  background: #f4edfb;
  color: #61407f;
  font-weight: 850;
}
.badge.DELIVERY_UNKNOWN::before { border-radius: 0; opacity: 1; }
:root[data-theme="dark"] .badge.QUEUED, :root[data-theme="dark"] .badge.CLAIMED { background: #16283a; color: #7db8e6; }
:root[data-theme="dark"] .badge.DISPATCHING { background: #12303a; color: #6fc3d6; }
:root[data-theme="dark"] .badge.RETRY_WAIT { background: #3a2c14; color: #e3a94e; }
:root[data-theme="dark"] .badge.ACCEPTED_BY_PROVIDER,
:root[data-theme="dark"] .badge.RESOLVED_ACCEPTED { background: #13303a; color: #74bed3; }
:root[data-theme="dark"] .badge.FAILED_PERMANENT { background: #3c1a1e; color: #e2707a; }
:root[data-theme="dark"] .badge.CANCELLED,
:root[data-theme="dark"] .badge.RESOLVED_NOT_SENT { background: #242e37; color: #93a2ad; }
:root[data-theme="dark"] .badge.DELIVERY_UNKNOWN { border-color: #a887d6; background: #2a1f3a; color: #d3b9f0; }

/* The state pills above the health cards. */
.email-state-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.email-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: .78rem;
  font-weight: 800;
}
.email-pill small { color: var(--muted); font-weight: 700; }
.email-pill[data-tone="ok"] { border-color: #9ac9b8; background: #e6f4ee; color: #14614b; }
.email-pill[data-tone="info"] { border-color: #a8c6dd; background: #eaf1f8; color: #2c5c85; }
.email-pill[data-tone="warning"] { border-color: #e3c48d; background: var(--warning-soft); color: #77501c; }
.email-pill[data-tone="danger"] { border-color: #e2a5ab; background: var(--danger-soft); color: #8f2c35; }
.email-pill[data-tone="attention"] { border: 1px dashed #8a63b8; background: #f4edfb; color: #61407f; }
:root[data-theme="dark"] .email-pill[data-tone="ok"] { border-color: #2f6b58; background: #12312a; color: #6fd6b4; }
:root[data-theme="dark"] .email-pill[data-tone="info"] { border-color: #2f5375; background: #16283a; color: #7db8e6; }
:root[data-theme="dark"] .email-pill[data-tone="warning"] { border-color: #6d5426; background: #3a2c14; color: #e3a94e; }
:root[data-theme="dark"] .email-pill[data-tone="danger"] { border-color: #6f3339; background: #3c1a1e; color: #e2707a; }
:root[data-theme="dark"] .email-pill[data-tone="attention"] { border-color: #a887d6; background: #2a1f3a; color: #d3b9f0; }

.email-health-cards { margin-bottom: 14px; }
/* Narrower than the 160px default so six counts stay two-up on a phone. Six
   full-width cards is a screen and a half of scrolling before the outbox --
   which defeats the point of a summary an operator reads at a glance when
   something is wrong. */
.email-health-cards { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }
.email-health-cards .card { padding: 13px; }
.email-health-cards .card strong { font-size: 1.5rem; }
.email-health-cards .metric-card[data-tone="attention"] { border-top: 3px dashed #8a63b8; }
.email-health-cards .metric-card[data-tone="danger"] { border-top: 3px solid var(--danger); }
.email-health-cards .metric-card[data-tone="neutral"] { border-top: 3px solid var(--border-strong); }
.email-health-cards .metric-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: normal;
}
.email-acceptance-note { margin: 4px 0 0; font-size: .78rem; line-height: 1.5; }
.email-quick-windows { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 12px; }

/* THE THRESHOLDS, DRAWN. The health payload already ranks these worst-first;
   this only gives "somebody has to act on this" a heavier weight than "this is
   unusual", using the banner idiom the page already has rather than a second
   one. `alert` is the severity a blocked credential and a stalled queue carry. */
.email-alert { margin-bottom: 10px; flex-direction: column; gap: 3px; }
.email-alert strong { font-size: .86rem; }
.email-alert span { font-size: .78rem; line-height: 1.5; }
.email-alert[data-severity="alert"] {
  border-color: #e2a5ab;
  background: var(--danger-soft);
  color: #8f2c35;
  border-left-width: 4px;
}
:root[data-theme="dark"] .email-alert[data-severity="alert"] {
  border-color: #6f3339; background: #3c1a1e; color: #e2707a;
}
/* The drain estimate is a duration, not a count, so it does not inherit the
   metric card's tabular figure sizing -- "3h 20m" at 1.5rem overflows the
   132px column the cards are laid out in. */
.email-eta { font-size: 1.15rem !important; }

/* Bulk actions. Hidden until something is ticked (the `hidden` attribute), so
   the page is unchanged for the ordinary one-message case. Sticky at the top of
   its panel because a selection made on row 48 is acted on by a button that
   would otherwise have scrolled away. */
.email-bulk-bar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 12px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-alt);
}
.email-bulk-bar[hidden] { display: none; }
.email-bulk-bar > strong { margin-right: auto; font-size: .82rem; }
.email-bulk-bar .btn[disabled] { opacity: .45; cursor: not-allowed; }
/* The checkbox column. Narrow and centred, and the input is given a real hit
   area because ticking forty rows with a 13px target is the reason people go
   back to doing it one at a time. */
.select-cell { width: 38px; text-align: center; padding-right: 0 !important; }
.select-cell input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

/* Settings groups. Each one states whether THIS screen can write it, so the
   badge is load-bearing rather than decoration: a read-only group is a fact
   with its authority named, not a disabled input pretending it will save. */
.email-settings-group { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.email-settings-group:first-of-type { margin-top: 4px; padding-top: 0; border-top: 0; }
.email-settings-group h5 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 4px; }
.email-settings-group > p.muted { margin: 0 0 10px; font-size: .78rem; line-height: 1.5; }
.email-settings-group .record-grid small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.email-settings-group[data-editable="false"] .record-grid > div { background: var(--surface); }

/* The preview is fully sandboxed and framed so it can never be mistaken for a
   live message: no scripts, no forms, no navigation, and no send control
   anywhere in the panel. */
.email-preview { margin-top: 4px; }
.email-preview-banner { align-items: center; }
.email-preview-frame-wrap { margin-top: 14px; }
.email-preview-frame-wrap h5 { margin: 0 0 8px; }
.email-preview-frame {
  display: block;
  width: 100%;
  height: 420px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
}
.email-preview-source { margin-top: 14px; }
.email-preview-source summary { cursor: pointer; color: var(--muted); font-size: .8rem; font-weight: 800; }
.email-preview-source h5 { margin: 12px 0 6px; }
.email-preview-source pre {
  max-height: 280px;
  margin: 0;
  padding: 11px 12px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  font-size: .76rem;
}

/* Detail drawer. The attempt table is the widest thing on the page, so it gets
   its own scroll container rather than widening the drawer. */
.email-attempt-detail { color: var(--muted); font-size: .76rem; white-space: normal; }
.email-state-history { margin: 0; padding: 0; list-style: none; }
.email-state-history li {
  padding: 9px 0 9px 16px;
  border-left: 2px solid var(--border-strong);
  position: relative;
}
.email-state-history li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 15px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
}
.email-state-history li p { margin: 4px 0 0; color: var(--muted); font-size: .78rem; }
.email-unknown-callout {
  border-color: #8a63b8;
  border-style: dashed;
  background: #f4edfb;
  color: #4f3369;
}
:root[data-theme="dark"] .email-unknown-callout { border-color: #a887d6; background: #2a1f3a; color: #d3b9f0; }
.email-secret-state { display: block; margin-top: 5px; font-size: .74rem; font-weight: 700; }
.email-secret-state[data-configured="true"] { color: var(--accent-text); }
.email-secret-state[data-configured="false"] { color: var(--warning); }
.field-hint { display: block; margin-top: 5px; color: var(--muted); font-size: .74rem; font-weight: 700; }

@media (max-width: 900px) {
  .permission-dialog-layout { grid-template-columns: 1fr; }
  .permission-dialog-fields .form-stack { position: static; }
  .permission-group { columns: 1; }
}

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: clamp(20px, 5vw, 72px); }
.auth { width: min(1180px, 100%); min-height: min(720px, calc(100vh - 80px)); display: grid; grid-template-columns: 1.1fr 1fr; overflow: hidden; border-radius: 24px; background: var(--surface); box-shadow: 0 18px 55px #14202b20; }
.auth-info {
  padding: clamp(38px, 6vw, 72px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-color: var(--sidebar);
  background-image: linear-gradient(145deg, var(--sidebar-hover), var(--sidebar));
  background-position: center;
  background-size: cover;
  color: var(--on-sidebar);
}
.auth-info p, .auth-info .eyebrow { color: inherit; }
.auth-info.has-background, .auth-info.has-background p,
.auth-info.has-background .eyebrow { color: #fff; }
.auth-info .brand h1 { font-size: 1.25rem; }
.auth-info .mark.has-logo { width: 72px; height: 72px; border-radius: 16px; }
.auth-info .brand.uploaded-logo-only {
  width: 100%;
  min-height: 112px;
}
.auth-info .brand.uploaded-logo-only .mark.has-logo {
  width: min(100%, 440px);
  height: 112px;
  border-radius: 0;
}
.auth-info .brand.uploaded-logo-only .mark.has-logo > img {
  object-position: left center;
}
.auth-copy { max-width: 620px; }
.auth-copy h2 { margin-bottom: 22px; font-size: clamp(2rem, 3.8vw, 3.15rem); line-height: 1.25; letter-spacing: -.04em; }
.auth-copy p { margin: 0; font-size: clamp(1rem, 1.7vw, 1.22rem); }
.auth-form { padding: clamp(38px, 7vw, 76px); display: flex; flex-direction: column; justify-content: center; }
.auth-form > h2 { margin: 7px 0 36px; font-size: clamp(2rem, 4vw, 2.65rem); letter-spacing: -.04em; }
.auth-form .field > span { font-size: .95rem; }
.auth-form input { min-height: 54px; font-size: 1.05rem; }
.auth-submit { width: 100%; min-height: 52px; margin-top: 15px; font-size: 1.05rem; }
.auth-switch { margin: 4px 0 0; font-size: 1rem; }
.stack { display: grid; gap: 14px; }
.message { min-height: 20px; font-weight: 700; }
.message.error { color: var(--danger); }
.message.success { color: var(--accent-text); }
.muted { color: var(--muted); }

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

@media (max-width: 1050px) {
  .app { --sidebar-width: clamp(240px, 27vw, 290px); }
  .work { padding-left: 22px; padding-right: 22px; }
  .top { margin-left: -22px; margin-right: -22px; padding-left: 22px; padding-right: 22px; }
  .detail-columns { grid-template-columns: minmax(0, 1fr); }   /* 0.6.4: a 1fr track grew to the Items table, so the order drawer scrolled sideways on phones */
  .warehouse-layout, .settings-layout { grid-template-columns: 1fr; }
  .label-workbench, .settings-preview { position: static; }
  .settings-preview { order: -1; }
}
@media (max-width: 800px) {
  .app { display: block; }
  /* .side becomes a wrapping flex ROW on mobile: the logo takes its own
     line, then a single line carries the session-control icons and the Menu
     button. .side-top / .side-footer / .side-actions / .side-context-actions
     / .idle-controls are display:contents so their buttons become direct
     flex items of that row -- the controls stay inside .side-footer in the
     DOM (where desktop wants them, pinned at the bottom of the rail), and
     display:contents relocates them visually without moving any DOM, so both
     layouts share one structure and every existing selector still matches.
     height must stay auto (not the base rule's 100vh) or the closed header
     alone reserves a full screen of blank space above the page content. */
  .side {
    position: sticky;
    z-index: 40;
    top: 0;
    width: 100%;
    height: auto;
    max-height: 100vh;
    padding: 12px 15px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    align-content: flex-start;
    gap: 8px;
    box-shadow: 0 5px 18px #0d18252b;
  }
  /* .side-top and .idle-controls dissolve so the logo, Hide and Menu share
     one line. .side-actions / .side-context-actions stay real grid boxes so
     their buttons keep their text labels on full-width lines below. */
  .side-top,
  .side-footer,
  .idle-controls { display: contents; }
  /* Sized to its content rather than a full-width band -- the logo image is
     only ~150px wide, so the rest of that line was dead space that Hide and
     Menu can use instead. Same specificity as the logo-only brand rules
     above, which force width:100%. */
  .side .brand,
  .side .brand.system-logo-only:not(.company-logo-only),
  .side .brand[data-company-brand].company-logo-only {
    order: 1;
    flex: 0 1 auto;
    width: auto;
    max-width: 46%;
    min-height: 0;
    margin-bottom: 0;
  }
  .side .brand.system-logo-only:not(.company-logo-only) .mark,
  .side .brand[data-company-brand].company-logo-only [data-company-logo] {
    width: 150px;
    max-width: 100%;
    height: 52px;
  }
  .sidebar-collapse-toggle { order: 2; margin-left: auto; display: none; }
  .btn.nav-toggle { display: inline-flex; order: 3; min-height: 42px; border-color: currentColor; background: transparent; color: var(--on-sidebar); }
  .btn.nav-toggle:hover { border-color: currentColor; background: #ffffff1c; }
  /* Labels stay on while expanded: a bare row of icons gave no clue which
     one was "Unlock layout" or "Sign out". Icon-only is the collapsed
     (Hide) state's job, below. Hidden by default: the session controls and
     the Hide toggle live inside the Menu collapse (shown when open, below),
     so a closed mobile header is just the logo and the Menu button. */
  /* UX-2A (F-11). The orders below are the fix, not decoration. Before it the
     utility row sat at order 4 and the page navigation at order 5, so opening
     Menu on a phone put the theme switch, Refresh, Sign out and Unlock layout
     ABOVE the links the person opened the menu to reach. Navigation now comes
     first and the utilities follow it -- primary work, then account, then
     utilities, top to bottom. */
  .side-actions,
  .side-context-actions { order: 5; flex: 1 1 100%; display: none; }
  .side-footer .account { display: none; }
  .side-scroll { order: 4; flex: 1 1 100%; display: none; max-height: min(62vh, 480px); padding-top: 10px; border-top: 1px solid #ffffff1c; }
  .side-scroll:has(.nav[data-open="true"]) { display: flex; }
  /* Menu open: reveal the session controls and the Hide toggle alongside the
     page-nav links and idle timer. */
  .side-scroll:has(.nav[data-open="true"]) ~ .side-footer .side-actions,
  .side-scroll:has(.nav[data-open="true"]) ~ .side-footer .side-context-actions { display: grid; }
  /* UX-2A (F-11). "Hide" used to be revealed here too. It collapses the
     desktop rail to icons -- on a phone the rail is already a drawer, so the
     control did nothing a person could see, in a menu where every other item
     does something. The desktop and tablet collapse toggle is untouched; it is
     only absent below 800px, where it has no meaning. */
  /* UpgradeUI-2: the mobile drawer lays nav out in columns. The GROUPS must
     stack full-width and their BUTTONS take the columns -- otherwise each
     group box becomes a grid cell and the drawer reads as a ragged mosaic. */
  .nav { grid-template-columns: 1fr; gap: 5px; overflow-y: visible; }
  .nav-group-items { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .nav-group + .nav-group { margin-top: 10px; }
  .nav button { justify-content: flex-start; padding: 9px; text-align: left; font-size: .78rem; }
  .nav button::before { display: none; }
  /* Status text, not a control -- so it gets its own line under the nav
     rather than a slot in the header row, and only while the menu is open. */
  .idle-timer { order: 6; flex: 1 1 100%; display: none; margin: 0; }
  .side-scroll:has(.nav[data-open="true"]) ~ .idle-controls .idle-timer { display: block; }

  /* Collapsed ("Hide") on mobile: every label drops away and the whole
     header condenses to one icon line -- the action groups dissolve so
     their buttons join the logo/Hide/Menu row, and the nav icons flow in
     rows across the panel (a horizontal bar has no narrow rail to shrink
     into). This is the only state that goes icon-only; expanded keeps text. */
  .app[data-sidebar-collapsed="true"] .nav-label,
  .app[data-sidebar-collapsed="true"] .side .side-action-label,   /* DEF-SHELL-01: not the top bar */
  .app[data-sidebar-collapsed="true"] .sidebar-collapse-label { display: none; }
  .app[data-sidebar-collapsed="true"] .nav {
    grid-template-columns: repeat(auto-fit, minmax(46px, 1fr));
  }
  .app[data-sidebar-collapsed="true"] .nav button { justify-content: center; padding: 11px 8px; }
  /* Collapsed = a persistent icon toolbar. The compact session-control icons
     and the Show/Hide chevron stay pinned on top regardless of the menu state;
     tapping Menu only drops the nav links in below them. (The roomy labelled
     mode still tucks its controls away when closed -- see the show-on-open
     rules above.) */
  .app[data-sidebar-collapsed="true"] .side-actions,
  .app[data-sidebar-collapsed="true"] .side-context-actions { display: contents; }
  .app[data-sidebar-collapsed="true"] .sidebar-collapse-toggle { display: inline-flex; }
  .app[data-sidebar-collapsed="true"] .side-footer .btn,
  .app[data-sidebar-collapsed="true"] .sidebar-collapse-toggle,
  .app[data-sidebar-collapsed="true"] .btn.nav-toggle {
    order: 2;
    width: 44px;
    min-width: 44px;
    min-height: 40px;
    padding-inline: 0;
    justify-content: center;
  }
  .app[data-sidebar-collapsed="true"] .side-actions #themeToggle { padding-inline: 0; }
  /* Menu loses its text here too, or logo + 5 icons + "Menu" overflows a
     ~390px line and wraps the button onto a row of its own. sidebar.js gives
     it an aria-label, so hiding the text costs it no accessible name. */
  .app[data-sidebar-collapsed="true"] .btn.nav-toggle { order: 3; }
  .app[data-sidebar-collapsed="true"] .btn.nav-toggle > span:last-child { display: none; }
  /* Shrunk logo joins that same line instead of holding one to itself. */
  .app[data-sidebar-collapsed="true"] .side .brand,
  .app[data-sidebar-collapsed="true"] .side .brand.system-logo-only:not(.company-logo-only),
  .app[data-sidebar-collapsed="true"] .side .brand[data-company-brand].company-logo-only { flex: 0 0 auto; margin-inline: 0; }
  .work { padding: 18px 16px 42px; }
  .top { position: relative; margin: -18px -16px 20px; padding: 14px 16px; }
  .breadcrumb { display: none; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .head { align-items: flex-start; flex-direction: column; }
  .grid, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .theme-controls, .media-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-toolbar { align-items: stretch; }
  .filter-toolbar .field, .filter-toolbar .search-field { flex-basis: calc(50% - 8px); min-width: 0; }
  .auth { grid-template-columns: 1fr; }
  .auth { min-height: auto; }
  .auth-info, .auth-form { padding: 30px; }
  .auth-info { min-height: 330px; background-position: top center; }
  dialog.drawer { width: 100vw; border-radius: 0; }
  .page-feedback { align-items: flex-start; }
}
@media (max-width: 560px) {
  .email-preview-frame { height: 320px; }
  .email-quick-windows .btn { flex: 1 1 calc(50% - 8px); }
  .email-state-row { gap: 6px; }
  /* The health counts stay two-up rather than collapsing to one per row: the
     whole panel then fits a phone screen and can be read as a summary. */
  .email-health-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .email-health-cards .card strong { font-size: 1.3rem; }
  .email-health-cards .card small { font-size: .66rem; }
  .nav-group-items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top { align-items: flex-start; }
  .top .actions { justify-content: flex-end; }
  .icon-text { font-size: 0; }
  .icon-text span { font-size: 1rem; }
  .filter-toolbar .field, .filter-toolbar .search-field { flex-basis: 100%; }
  .theme-controls, .media-controls { grid-template-columns: 1fr; }
  .media-control { grid-template-columns: 82px minmax(0, 1fr); }
  .mini-login { grid-template-columns: 1fr; }
  .mini-login-hero { min-height: 210px; }
  .settings-savebar { align-items: stretch; flex-direction: column; }
  .settings-savebar .btn { width: 100%; }
  .quantity-comparison { grid-template-columns: 1fr; }
  .receipt-line-head { flex-direction: column; }
  .receipt-line-head > strong { flex-basis: auto; }
  .dialog-header, .dialog-footer { padding: 13px 14px; }
  .dialog-body { padding: 14px; }
  .dialog-footer { align-items: stretch; }
  .dialog-footer .selection-count { flex: 0 0 100%; margin: 0 0 2px; }
  .dialog-footer > .btn { min-height: 44px; }
  .btn.small { min-height: 38px; }
  .page-feedback { flex-direction: column; }
  .page-feedback .btn { width: 100%; }
  .inline-dimension-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
@media (forced-colors: active) {
  .selectable-table tbody tr.selected td:first-child { border-left: 4px solid Highlight; }
  .badge { border: 1px solid currentColor; }
}
@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .side, .toast-region, .page-state, .page-feedback, dialog { display: none !important; }
  .app { display: block !important; min-height: 0; }
  .work { min-height: 0; padding: 0; }
  .work > * { display: none !important; }
  #orderDetailDialog[open] {
    position: static;
    display: block !important;
    width: 100%;
    height: auto;
    max-height: none;
    overflow: visible;
    border-radius: 0;
    box-shadow: none;
  }
  #orderDetailDialog .dialog-shell, #orderDetailDialog .dialog-body { height: auto; max-height: none; overflow: visible; }
  #orderDetailDialog .dialog-header { padding: 0 0 10px; border-bottom: 2px solid #17212b; }
  #orderDetailDialog .dialog-body { padding: 14px 0 0; }
  #orderDetailDialog .dialog-header button, #orderDetailDialog .dialog-footer, #orderDetailActions { display: none !important; }
  /* M10.5 Part B. "Print Summary" prints THIS DIALOG (that is the whole
     mechanism above), and operators hand the printed summary to drivers and
     carriers at pickup. What the warehouse has said to the CUSTOMER -- their
     email address, the wording, who sent it -- is not for that audience, so
     the Communications section is excluded from the printed sheet while
     staying fully present on screen. The .no-print class is also on the
     section itself so the intent is visible in the markup, not only here. */
  #orderCommunicationsSection, #orderDetailDialog .no-print { display: none !important; }
  #orderDetailDialog .record-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 16px; }
  #orderDetailDialog .record-grid > div { padding: 3px 0 7px; border: 0; border-radius: 0; background: transparent; }
  #orderDetailDialog .detail-section { margin-bottom: 14px; break-inside: avoid; }
  #orderDetailDialog .order-items-section { break-inside: auto; }
  #orderDetailDialog .table { overflow: visible; border-color: #bfc6cc; }
  #orderDetailDialog table { font-size: 9pt; }
  #orderDetailDialog th, #orderDetailDialog td { padding: 6px 7px; }
  #orderDetailDialog .order-address-lines { padding: 0; }
  #orderDetailDialog .order-address-lines p { color: #17212b; }
}

/* Two-factor overlay (shared by both portals). Fixed and above everything so a
   required enrolment cannot be scrolled past or clicked around. */
/* A9-001: the two-factor and step-up prompts are native <dialog>s opened with
   showModal(), so they sit in the top layer above any dialog already open. */
.totp-panel::backdrop { background: #0d1825d9; }
.totp-panel { width: min(460px, calc(100vw - 40px)); max-height: 90vh; overflow: auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px;
  box-shadow: 0 18px 50px #0d182559; }
.totp-panel h2 { margin: 4px 0 8px; font-size: 1.15rem; }
.totp-secret { display: block; padding: 10px 12px; margin-top: 4px; border-radius: 8px;
  background: var(--surface-strong, #eef1f4); border: 1px solid var(--line);
  font-size: .95rem; letter-spacing: .06em; word-break: break-all; user-select: all; }
.totp-codes { list-style: none; margin: 10px 0 0; padding: 0; display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.totp-codes code { display: block; padding: 7px 9px; border-radius: 6px;
  background: var(--surface-strong, #eef1f4); border: 1px solid var(--line);
  font-size: .88rem; text-align: center; user-select: all; }


/* Account actions menu -- one dialog replacing a row of up to nine buttons. */
.account-menu-list { display: grid; gap: 8px; }
.account-menu-list .account-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  line-height: 1.35;
}
.account-menu-list .account-menu-item strong { display: block; }
.account-menu-list .account-menu-item small { display: block; opacity: 0.75; font-weight: 400; }

/* Account settings: the photo sits above the identity fields. */
.account-settings-photo { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.person-avatar.large { width: 64px; height: 64px; font-size: 1.35rem; }
/* The sidebar profile is a button now; keep it looking like the block it was. */
button.account { background: none; border: 0; width: 100%; text-align: left; cursor: pointer; font: inherit; color: inherit; }
button.account:hover, button.account:focus-visible { opacity: 0.85; }

/* Table cells that are also the way to edit what they show. Styled as text
   rather than as a button so the table stays readable at a glance. */
.link-cell {
  background: none; border: 0; padding: 0; font: inherit; color: inherit;
  text-align: left; cursor: pointer; text-decoration: underline;
  text-decoration-style: dotted; text-underline-offset: 3px;
}
.link-cell:hover, .link-cell:focus-visible { text-decoration-style: solid; }
.link-cell.person-cell { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.link-cell.person-cell strong { text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
.link-cell.person-cell:hover strong { text-decoration-style: solid; }


/* ==========================================================================
   M10.5 Part B -- order communications.

   APPEND-ONLY. Nothing above this comment was modified, with one approved
   exception recorded in the @media print block: the print exclusion for
   #orderCommunicationsSection, which has to live inside that block to be part
   of the same cascade that reveals the order dialog for printing.

   Responsiveness is INHERITED, not reinvented: these surfaces are built from
   .panel, .form-grid/.span-2, .filter-toolbar.compact and .table, all of which
   already collapse at the existing 800px and 560px breakpoints. The only new
   responsive rules here are for the two genuinely new components (the variable
   chip bar and the attachment picker), which have no ancestor to inherit from.
   ========================================================================== */

/* Two statuses the badge palette did not previously carry. DUPLICATE is not a
   failure -- it means the engine's dedupe did its job -- so it is styled as
   information rather than as an error. */
.badge.DUPLICATE { background: #eaf1f8; color: #356d9d; }
.badge.FAILED { background: #fdebed; color: #a8333e; }
:root[data-theme="dark"] .badge.DUPLICATE { background: #16283a; color: #7fb2de; }
:root[data-theme="dark"] .badge.FAILED { background: #3c1a1e; color: #e2707a; }

/* ---- the order drawer's Communications section ---- */
.comm-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.comm-section-head h4 { margin: 0; }

/* ---- Insert Variable ---- */
.comm-var-bar {
  margin: 0 0 14px; padding: 12px 14px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-soft);
}
.comm-var-bar-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 9px; }
.comm-var-bar-head strong { font-size: .85rem; }
.comm-var-bar-head span { font-size: .78rem; }
.comm-var-chips { display: grid; gap: 8px; }
.comm-var-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.comm-var-group-name {
  flex: 0 0 auto; min-width: 92px; color: var(--muted);
  font-size: .68rem; font-weight: 750; text-transform: uppercase; letter-spacing: .04em;
}
.btn.comm-var-chip { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .76rem; }
.comm-var-help { margin-top: 10px; }
.comm-var-help summary { cursor: pointer; font-size: .8rem; font-weight: 700; }
.comm-var-help > div { margin-top: 10px; }

/* The live readout of which variables the wording actually uses. A convenience:
   the server is the authority and refuses an unknown name regardless. */
code.comm-var-used {
  display: inline-block; padding: 1px 6px; margin: 0 2px 3px 0; border-radius: 5px;
  background: var(--surface-strong, #eef1f4); font-size: .78rem;
}
code.comm-var-used.is-unknown { background: var(--danger-soft); color: #8f2c35; }
:root[data-theme="dark"] code.comm-var-used.is-unknown { background: #3c1a1e; color: #e2707a; }
.comm-var-warning { margin: 6px 0 0; color: var(--danger); font-size: .8rem; font-weight: 700; }

/* ---- the attachment picker ---- */
.comm-attachment-list { display: grid; gap: 8px; }
.comm-attachment {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface-soft);
  cursor: pointer;
}
/* The global `input { width: 100% }` stretched this checkbox across the card (BrowserLab D1). */
.comm-attachment input { margin-top: 3px; flex: 0 0 auto; width: 17px; height: 17px; min-height: 17px; padding: 0; }
.comm-attachment-body { display: grid; gap: 2px; min-width: 0; }
.comm-attachment-body strong { overflow-wrap: anywhere; }
.comm-attachment-meta { color: var(--muted); font-size: .76rem; }

/* An unusable candidate stays VISIBLE and says why. Hiding it would make an
   order whose BOL is too large to email look identical to an order that never
   had a BOL, and those are very different things to tell a customer. */
.comm-attachment.is-unusable { cursor: not-allowed; opacity: .72; border-style: dashed; }
.comm-attachment-refusal { color: var(--danger); font-size: .76rem; font-weight: 700; }
.comm-over-limit { color: var(--danger); font-weight: 700; }

@media (max-width: 560px) {
  /* The group label stops holding its own column and sits above its chips;
     below this width a 92px label leaves too little room for the chip itself. */
  .comm-var-group { display: block; }
  .comm-var-group-name { display: block; margin-bottom: 4px; }
  .comm-section-head { align-items: flex-start; flex-direction: column; }
}

/* ------------------------------------------------------------------ *
 * UpgradeUI-2 -- the task-first Home.
 *
 * Bounded to the launcher and the navigation it introduces. The broad
 * responsive/touch pass over the rest of the app is UpgradeUI-7's job, so the
 * pointer-coarse rules below deliberately only reach these controls.
 * ------------------------------------------------------------------ */
.home-tasks { display: grid; gap: 20px; margin-bottom: 26px; }
.home-group { display: grid; gap: 10px; }
.home-group-title {
  margin: 0;
  font-size: .74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
}
.home-task-grid {
  display: grid;
  gap: 12px;
  /* auto-fit keeps a full row on a desktop and folds to one column on a
     handheld without a breakpoint per size. */
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.home-task {
  display: grid;
  align-content: start;
  gap: 4px;
  /* Space for the count is reserved whether or not there is one, so a tile
     does not change height when the number arrives and shift what is under
     the operator's finger. */
  grid-template-rows: auto auto 1.15rem;
  min-height: 96px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color .14s ease, transform .14s ease, box-shadow .14s ease;
}
.home-task:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.home-task:active { transform: translateY(1px); }
.home-task:focus-visible { outline: var(--focus); outline-offset: 2px; }
.home-task-label { font-size: 1.02rem; font-weight: 700; line-height: 1.25; }
.home-task-hint { color: var(--muted); font-size: .84rem; line-height: 1.35; }
.home-task-count {
  align-self: end;
  justify-self: start;
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: .76rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .home-task { transition: none; }
  .home-task:active { transform: none; }
}

/* Handheld and scanner widths: one task per row, nothing clipped. */
@media (max-width: 560px) {
  .home-task-grid { grid-template-columns: 1fr; }
  .home-tasks { gap: 16px; }
}

/* Touch and scanner screens: the launcher is the one surface an operator taps
   with a glove on, so its targets get real size regardless of viewport. */
@media (pointer: coarse) {
  .home-task { min-height: 108px; padding: 16px; }
  .nav button { padding-block: 13px; }
  .nav-group + .nav-group { margin-top: 16px; }
  /* UX-2A (§13). MEASURED at UX-1: the mobile menu's own controls came in
     under the 44px a finger needs -- the nav entries at 40px and the sidebar
     actions at 38px. `min-height` rather than more padding, so a label that
     wraps to two lines is not pushed out of its button. */
  .nav button { min-height: 44px; }
  .btn.nav-toggle { min-height: 44px; }
  .side-actions .btn,
  .side-context-actions .btn { min-height: 44px; }
}

@media (forced-colors: active) {
  .home-task { border: 1px solid CanvasText; }
  .home-task-count { border: 1px solid CanvasText; }
}

/* ------------------------------------------------------------------ *
 * UpgradeUI-3 -- plain-English errors and readable activity.
 *
 * Error meaning never rests on colour alone: the summary is a sentence, the
 * next step is prefixed with the word "Next:", and the technical detail is a
 * native <details> so keyboard and screen-reader behaviour come for free.
 * ------------------------------------------------------------------ */
.error-summary { margin: 0; font-weight: 600; line-height: 1.4; }
.error-next-step {
  margin: 6px 0 0;
  font-weight: 400;
  line-height: 1.4;
  /* Inherits the surrounding error colour; the label below is what carries
     the meaning for anyone who cannot see that colour. */
  opacity: .92;
}
.error-next-label { font-weight: 700; }

.advanced-details {
  margin-top: 8px;
  /* Also used inside table cells, which are globally `nowrap`. Without this
     the backend message and the raw details run off the edge of the panel --
     the exact information the disclosure exists to make readable. */
  white-space: normal;
}
.advanced-details > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 2px;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  /* A comfortable hit area on a scanner screen without moving the layout. */
  min-height: 28px;
  color: inherit;
  opacity: .85;
}
.advanced-details > summary:hover { opacity: 1; }
.advanced-details > summary:focus-visible { outline: var(--focus); outline-offset: 2px; }
.advanced-details[open] > summary { margin-bottom: 6px; }
.advanced-details-body {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  font-size: .8rem;
  white-space: normal;
  /* Bounded so a long raw payload cannot stretch a table column off-screen;
     it wraps and, if it is genuinely huge, scrolls inside its own box. */
  max-width: 46ch;
  max-height: 16rem;
  overflow: auto;
}
.advanced-details-row {
  display: grid;
  grid-template-columns: minmax(96px, auto) 1fr;
  gap: 4px 10px;
  align-items: start;
}
.advanced-details-row dt { font-weight: 700; opacity: .75; }
.advanced-details-row dd {
  margin: 0;
  /* A backend sentence or a request id must wrap, never widen the page. */
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .76rem;
}

/* Activity rows: the sentence leads, everything else supports it.

   Table cells are `white-space: nowrap` globally, which is right for the dense
   data tables it was written for and wrong for a sentence -- it truncated the
   activity line mid-word, which is the one thing this column exists to show.
   Only this cell opts out. */
.audit-what {
  white-space: normal;
  line-height: 1.4;
  min-width: 22ch;
  max-width: 52ch;
}
/* An object id is evidence, not headline text: it may wrap and it stays quiet. */
.audit-what .secondary-cell {
  white-space: normal;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.audit-reason {
  display: block;
  margin-top: 3px;
  font-weight: 400;
  font-size: .82rem;
  color: var(--muted);
}
.audit-reason-label { font-weight: 700; }

@media (max-width: 560px) {
  .advanced-details-row { grid-template-columns: 1fr; gap: 1px; }
  .advanced-details-body { padding: 8px; }
}

@media (forced-colors: active) {
  .advanced-details-body { border: 1px solid CanvasText; }
}

/* ------------------------------------------------------------------ *
 * UpgradeUI-4 -- inventory workflow surfaces.
 *
 * Bounded to the new workflow screens. The broad responsive pass is still
 * UpgradeUI-7's; what is here is what a scanner screen needs to be usable.
 * ------------------------------------------------------------------ */
.workflow-panel { display: grid; gap: 16px; }
.workflow-form { display: grid; gap: 16px; }
.workflow-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* The scan field is the thing an operator aims at; make it unmissable. */
.workflow-scan-field input {
  font-size: 1.05rem;
  padding-block: 12px;
}

/* Status lines keep a fixed slot so accepting a scan never shifts the layout
   under a finger that is already moving to the next control. */
.workflow-status,
.workflow-feedback {
  margin: 0;
  min-height: 1.4rem;
  font-weight: 600;
  line-height: 1.4;
}
/* Meaning is in the words; the colour is a second channel, never the only one. */
.workflow-status[data-tone="ok"],
.workflow-feedback[data-tone="ok"] { color: var(--primary-dark); }
.workflow-feedback[data-tone="bad"] { color: var(--danger); }
/* 0.6.4 (owner): the Pack screen's save state -- Unsaved changes / Saving… / Saved successfully / Save failed */
#packWorkspace .pack-save-state { margin: 0; font-weight: 600; }
#packWorkspace .pack-save-state[data-state="dirty"] { color: var(--warning); }
#packWorkspace .pack-save-state[data-state="saved"] { color: var(--primary-dark); }
#packWorkspace .pack-save-state[data-state="failed"] { color: var(--danger); }
.workflow-feedback[data-tone="ask"],
.workflow-feedback[data-tone="busy"] { color: var(--muted); }

.move-source {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}
.move-source-item { font-size: 1rem; }
.move-source-where { color: var(--muted); font-size: .86rem; }

.move-candidates-title { margin: 0 0 8px; font-weight: 700; }
.move-candidate-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.move-candidate {
  display: grid;
  gap: 4px;
  width: 100%;
  /* Comfortably above the 44px minimum: this is chosen with a gloved finger. */
  min-height: 60px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.move-candidate:hover { border-color: var(--primary); }
.move-candidate:focus-visible { outline: var(--focus); outline-offset: 2px; }
.move-candidate-main { display: grid; gap: 2px; }
.move-candidate-main strong { font-size: 1rem; }
.move-candidate-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  color: var(--muted);
  font-size: .82rem;
}
.move-candidate-qty { font-weight: 700; font-variant-numeric: tabular-nums; }

.serial-status { margin: 6px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.serial-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  /* A long scan loop scrolls inside its own box rather than pushing the
     submit button off the screen mid-flow. */
  max-height: 9rem;
  overflow-y: auto;
}
.serial-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 10px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface-soft);
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
}
.serial-chip-remove {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 99px;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
}
.serial-chip-remove:hover { color: var(--danger); }
.serial-chip-remove:focus-visible { outline: var(--focus); outline-offset: 1px; }

@media (max-width: 560px) {
  .workflow-row { grid-template-columns: 1fr; }
  .move-candidate-qty { justify-self: start; }
}

@media (pointer: coarse) {
  .workflow-scan-field input,
  #moveDestination,
  #moveQuantity,
  #moveSerialScan { min-height: 48px; font-size: 1.05rem; }
  .move-candidate { min-height: 68px; }
  .serial-chip-remove { width: 30px; height: 30px; }
}

@media (forced-colors: active) {
  .move-candidate, .move-source, .serial-chip { border: 1px solid CanvasText; }
}

/* The company on the source summary, so whose stock this is is never
   something the operator was not shown. */
.move-source-company { font-weight: 700; font-size: .86rem; }

/* The three inventory actions sit ABOVE the history sections. Below them, the
   thing an operator came to do was six scrollable sections down. */
.detail-actions { margin: 0 0 4px; }

/* ------------------------------------------------------------------ *
 * UpgradeUI-5 -- fulfillment workflow surfaces.
 *
 * Bounded to the new fulfillment screens, and built on the UpgradeUI-4
 * workflow primitives rather than beside them.
 * ------------------------------------------------------------------ */
.workflow-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}
.workflow-header h4 { margin: 0; font-size: 1.05rem; }
.workflow-header p { margin: 2px 0 0; font-size: .86rem; }
.workflow-header-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.info-banner.subtle { background: var(--surface-soft); border-style: dashed; }

/* The queue rows an operator picks their next job from. Sized for a gloved
   finger, like the move candidates they are modelled on. */
.work-queue { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.work-item {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 60px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  overflow-wrap: anywhere;   /* 0.6.4: a 100-character vendor order # wraps instead of widening the floor queue */
}
.work-item:hover { border-color: var(--primary); }
.work-item:focus-visible { outline: var(--focus); outline-offset: 2px; }
.work-item-main { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.work-item-main strong { font-size: 1rem; }
.work-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  color: var(--muted);
  font-size: .82rem;
}
.work-item-count { font-weight: 700; font-variant-numeric: tabular-nums; }

/* The line an operator is working right now, held apart from the rest. */
.work-line-current {
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  gap: 6px;
}
.work-progress { font-weight: 700; font-variant-numeric: tabular-nums; }
.package-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  gap: 10px;
}
.package-card-header {
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: space-between;
}
.package-card-header strong { font-size: .95rem; }

/* ------------------------------------------------------------------ *
 * UpgradeUI-5 closure -- bounded work queues (U55-002) and touch targets.
 * ------------------------------------------------------------------ */
.queue-search { margin: 0 0 10px; }
.queue-search .field { margin: 0; }
.queue-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}
.queue-showing { color: var(--muted); font-size: .86rem; font-variant-numeric: tabular-nums; }

/* The "you cannot do this step" state. A screen whose only action the account
   cannot perform shows this instead of a list of buttons that all 403. */
.queue-denied {
  list-style: none;
  padding: 14px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}
.queue-denied p { margin: 0; }
.queue-denied .error-next-step { margin-top: 4px; }

/* The order just handed over from packing. */
.work-item-handover { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary) inset; }
.work-item-verb {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* UpgradeUI-7 removed `.receiving-note`: it repeated, 90px lower, what the
   page description above it already said, and on a handheld it sat between
   the operator and the queue. The sentence was merged into that description,
   so the rule it needed has gone with the element. */

/* U55-004: the primary control of a scan workflow is pressed with a gloved
   finger hundreds of times a shift. "Add to the receipt" measured 38px.
   "Load more" is the same class of control -- it is how an operator reaches
   the rest of a 136-order backlog on a handheld. */
.workflow-form .actions .btn,
.workflow-panel > .actions .btn,
.queue-footer .btn { min-height: 44px; }

/* ------------------------------------------------------------------ *
 * UpgradeUI-6 -- people and permission administration.
 * ------------------------------------------------------------------ */

/* The permission editor leads with what the permission DOES; the key stays on
   every row because an administrator configuring fine-grained access needs to
   see exactly what is being granted. */
.permission-key {
  display: inline-block;
  margin-top: 3px;
  font-size: .74rem;
  color: var(--muted);
}
.permission-group label[data-traced="false"] .permission-key { color: var(--text); }
.permission-group label > span { display: grid; gap: 1px; }
.permission-group label small { color: var(--muted); line-height: 1.35; }

/* What a save will actually change, before it is clicked. */
.permission-changes {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  font-size: .86rem;
}
.permission-changes ul { margin: 4px 0 0; padding-left: 18px; }
.permission-changes li { margin: 2px 0; }
.permission-changes code { font-size: .74rem; color: var(--muted); }
.permission-change-add strong { color: var(--primary-dark); }
.permission-change-remove strong { color: var(--danger); }
.permission-change-remove { margin-top: 8px; }

/* A setup password is revealed one account at a time, never on render. */
.setup-password { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.setup-password-value {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  font-size: .82rem;
  letter-spacing: .04em;
}
.setup-password small { flex-basis: 100%; }
.badge.subtle { background: var(--surface-soft); color: var(--muted); }

/* A bulk edit must not bury the list being edited. */
.permission-changes { max-height: 30vh; overflow: auto; }
.permission-untraced { font-style: italic; }
.warehouse-access-list { display: grid; gap: 6px; max-height: 50vh; overflow: auto; }
.warehouse-access-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.warehouse-access-row span { display: grid; gap: 1px; }
.warehouse-access-row small { color: var(--muted); }

/* ------------------------------------------------------------------ *
 * UpgradeUI-7 -- PDA / responsive / consistency polish.
 *
 * THE RESPONSIVE CONTRACT THIS SECTION IMPLEMENTS. One UI, one set of
 * routes, one permission model: a handheld scanner runs the same screens a
 * desktop does. What changes with the viewport is density, never capability.
 *
 *   DESKTOP (>1050px)   several columns, persistent side rail, the
 *                       information density a supervisor wants.
 *   TABLET (561-1050)   fewer columns, dialogs fit the viewport, the primary
 *                       action stays where it was.
 *   PDA (<=560px)       ONE working column. The scan or search target and the
 *                       work itself come first; explanation and optional
 *                       detail move behind a disclosure. No page-level
 *                       sideways scrolling on a floor workflow.
 *   COARSE POINTER      44px minimum on the controls an operator actually
 *                       presses, at any width, because a glove is a glove on
 *                       a 1080p wall panel too.
 *
 * Business data is never hidden because a screen is narrow. Everything below
 * either resizes, reorders, or discloses -- nothing is dropped.
 * ------------------------------------------------------------------ */

/* --- Touch targets (Task 6) ---------------------------------------------
 * Measured before it was changed: `.btn` was 38px, `.btn.small` 38px (31px
 * above the 560px breakpoint), inputs and selects 39-41px, `.sort-button`
 * 30px and a person's name in the People table 20px. Every one of those is
 * something an operator presses on a shift.
 *
 * Bound to `pointer: coarse` on purpose. A desktop with a mouse keeps its
 * density -- an over-mobile pass that inflated every desktop button would be
 * a regression for the supervisor who spends the day in this UI. */
@media (pointer: coarse) {
  .btn, .btn.small { min-height: var(--touch-target); }
  .btn.icon { min-width: var(--touch-target); }
  /* Reviewer C and Reviewer A both caught this independently: the ONE control
     present on every handheld screen was the one that escaped the floor.
     `.btn.nav-toggle { min-height: 42px }` (in the 800px block) out-specifies
     `.btn` at (0,2,0) against (0,1,0), so the rule above never reached it. */
  .btn.nav-toggle { min-height: 44px; }
  /* This milestone's own new disclosure, missed by its own rule. */
  .package-measurements > summary { min-height: 44px; }
  input, select, textarea { min-height: 44px; }
  /* A checkbox stays a checkbox: the 158-row permission editor would become
     unreadable at 44px a row. The LABEL is the target -- it is what the
     browser activates -- and it is already tall enough; the box itself only
     grows enough to aim at. */
  .field.checkbox input, .check-field input { width: 20px; height: 20px; min-height: 20px; }
  .field.checkbox, .check-field { min-height: 44px; }
  .queue-tabs button { min-height: 44px; }
  .sort-button { min-height: 44px; }
  /* The person's name in a table is the way into their record. Underlined
     text is a 20px target; this makes the row cell itself pressable without
     turning it into a button that looks like one. */
  .link-cell { min-height: 44px; display: inline-flex; align-items: center; }
  .link-cell.person-cell { min-height: 44px; }
  .pagination .btn { min-height: 44px; }
  /* Removing a mis-scanned serial IS an operator action, and 32px was this
     milestone's own rule falling short of this milestone's own floor. */
  .serial-chip-remove { width: 44px; height: 44px; }
}

/* --- Filters as a disclosure (Task 7) -----------------------------------
 * WHAT WAS MEASURED. At 375 the filter card owned the whole first screen on
 * every list page: on Receive goods the first inbound row started at 650px
 * of a 667px viewport, so an operator who opened the screen to do work saw
 * no work. Same on Orders, Find inventory, Count items, People, Materials.
 *
 * The filters are not removed and nothing is hidden from the server query --
 * they are one press away, and the summary says how many are applied so a
 * short list is never unexplained. Above 560px the disclosure is invisible
 * and the toolbar renders exactly as it did. */
.filter-disclosure { display: block; }
.filter-disclosure > summary {
  display: none;   /* desktop: there is nothing to disclose */
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin-bottom: 10px;
  padding: 8px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.filter-disclosure > summary::-webkit-details-marker { display: none; }
.filter-disclosure > summary:focus-visible { outline: var(--focus); outline-offset: 2px; }
.filter-disclosure > summary::after {
  content: "▾";
  margin-left: auto;
  font-size: .8rem;
  /* Meaning never rests on the rotation alone: the summary also carries
     aria-expanded through the native <details>, and the count below. */
}
.filter-disclosure:not([open]) > summary::after { content: "▸"; }
.filter-active-count {
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: .76rem;
  font-variant-numeric: tabular-nums;
}
.filter-active-count[hidden] { display: none; }

@media (max-width: 560px) {
  .filter-disclosure > summary { display: flex; }
}

/* --- A workspace is the whole screen (Task 7) ---------------------------
 * The receive, pick, pack and ship workspaces live on the same page as the
 * queue they came from, under that page's own description. On a handheld
 * that description is 150px of prose above the job -- it pushed the scan
 * field to the bottom edge of a 667px screen with the counted lines below
 * the fold. The text belongs to the QUEUE, so it is shown with the queue and
 * stands down while a job is open. Narrow screens only; a desktop has room
 * for both. */
@media (max-width: 560px) {
  #receiving:has(#receiveWorkspace:not([hidden])) > .page-heading p,
  #picking:has(#pickWorkspace:not([hidden])) > .page-heading p,
  #packing:has(#packWorkspace:not([hidden])) > .page-heading p,
  #shipping:has(#shipWorkspace:not([hidden])) > .page-heading p { display: none; }
  /* The job header's secondary actions ("Back to the list") took a line of
     their own above the scan field. They sit beside the job identity. */
  .workflow-header { gap: 8px; }
  .workflow-header-actions { margin-left: auto; }
}

/* Below 800px the side rail becomes a STICKY header 76px tall at z-index 40,
   so anything scrolled to the top of the viewport lands underneath it. The
   pick workspace scrolls its current line into view deliberately (see
   picking.js), and this is what stops that landing behind the logo. */
@media (max-width: 800px) {
  #pickCurrentWhere, .work-line-current { scroll-margin-top: 92px; }
}

/* --- Packing on a handheld (Task 13) ------------------------------------
 * MEASURED AT 375: the "In this box" column and its quantity input were cut
 * off at the right edge of a scrollable wrapper, so the operator could not
 * see what they were typing into without scrolling the table sideways; and
 * six optional measurement fields per box sat ABOVE the line assignment, so
 * with two boxes the operator scrolled past twelve optional inputs to reach
 * the thing that matters.
 *
 * The assignment now leads each box and the measurements are disclosed. The
 * table keeps its markup -- it is still a table, still captioned, still
 * scoped -- it simply stops needing a sideways scroll to be read. */
.package-measurements > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 4px 2px;
  font-size: .86rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
}
.package-measurements > summary:focus-visible { outline: var(--focus); outline-offset: 2px; }
.package-measurements[open] > summary { margin-bottom: 8px; }
.package-measurements > summary::after { content: "▾"; font-size: .75rem; }
.package-measurements:not([open]) > summary::after { content: "▸"; }
.package-lines-empty { margin: 0; color: var(--muted); }

/* The measurements disclosure is the SAME contract as the filter disclosure:
   on a desktop there is nothing to disclose, so the control is not drawn and
   the module keeps the panel open. Reviewer B measured the summary costing
   46px of pure chrome per box on a desktop that has room for the fields. */
.package-measurements > summary { display: none; }
@media (max-width: 560px) {
  .package-measurements > summary { display: flex; }
}

/* Task 10's sticky action, at EVERY width rather than only on a handheld.
   Reviewer B measured `#packProgress` at y=1058 with two boxes on a 900px
   desktop -- 158px below the fold. Moving progress down to sit with the
   action it qualifies only helps if the pair stays on screen, and a desktop
   packing three boxes scrolls 1583px just like a handheld does. */
#packWorkspace .pack-commit {
  position: sticky;
  z-index: 5;
  bottom: 0;
  display: grid;
  gap: 8px;
  justify-items: start;
  margin-top: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
/* Reviewer A, BLOCKER: after "Start another box" the app focuses the new
   box's first quantity input -- and the sticky bar was painted over it.
   Measured: input at y561-605, bar at y553-667, `elementFromPoint` returning
   the progress line. The browser will not self-correct, because the input IS
   inside the viewport; it is merely underneath something. So the packages
   container reserves the bar's height, and every field in it carries a scroll
   margin so any scroll-into-view stops clear of the bar. */
#packWorkspace input,
#packWorkspace select,
#packWorkspace textarea { scroll-margin-bottom: 148px; }

@media (max-width: 560px) {
  /* Task 10 -- one sticky action, and only where it earns its place. Packing
     two boxes is 2000px of scroll at this width, and "Finish packing" was at
     the very bottom under every box. Progress rides with it so "what is not
     in a box yet" is answerable without scrolling back up. Nothing else in
     the app gets a sticky footer. */
  /* Narrow only: the bar spans the panel's padding so it reads as a footer
     rather than as a floating card. The sticky behaviour itself is now
     unconditional -- see the base rule above. */
  #packWorkspace .pack-commit {
    margin: 12px -14px -14px;
    padding: 12px 14px;
  }
  #packWorkspace .pack-commit-actions .btn { flex: 1 1 140px; }
}

/* 0.6.4 -- the Pack workspace (owner-accepted Astra design). >=1151px: Items ~40% left, the package selector and the
   selected package ~60% right. 761-1150px: the selector across the top, two columns below. <=760px: one flow --
   selector (a native select), items, contents -- with the sticky action bar. Tokens only; scoped to #packWorkspace. */
#packWorkspace .pack-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "head" "items" "card";
  overflow-wrap: anywhere;
}
#packWorkspace .pack-head { grid-area: head; }
#packWorkspace .pack-items { grid-area: items; }
#packWorkspace .pack-selected { grid-area: card; }
@media (min-width: 761px) {
  #packWorkspace .pack-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas: "head head" "items card";
    align-items: start;
  }
}
@media (min-width: 1151px) {
  #packWorkspace .pack-grid {
    grid-template-columns: minmax(0, 40fr) minmax(0, 60fr);
    grid-template-areas: "items head" "items card";
    grid-template-rows: auto 1fr;
  }
}
#packWorkspace .pack-grid h5 { margin: 0; font-size: 1rem; }
#packWorkspace .pack-grid p { margin: 0; }
#packWorkspace .pack-label { margin: 0 0 6px; font-weight: 700; }
#packWorkspace .pack-grid .info-banner { margin: 0; }
#packWorkspace .pack-order-progress { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: space-between; }
#packWorkspace .pack-tags { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; white-space: nowrap; }
#packWorkspace .package-card-header > div { min-width: 0; }
#packWorkspace .pack-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
#packWorkspace .pack-chip { flex: 0 0 auto; flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.25; }
#packWorkspace .pack-chip small { font-weight: 500; color: var(--muted); }
#packWorkspace .pack-chip[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
  box-shadow: inset 0 0 0 2px var(--primary);
}
/* Rows: a list, never a nested scroll pane. */
#packWorkspace .pack-rows { list-style: none; margin: 0; padding: 0; display: grid; }
#packWorkspace .pack-row { display: grid; align-items: center; gap: 8px 10px; padding: 10px 0; border-top: 1px solid var(--border); }
#packWorkspace .pack-item { grid-template-columns: minmax(0, 1fr) 3.5rem 5rem auto; }
#packWorkspace .pack-content { grid-template-columns: minmax(0, 1fr) auto auto; }
#packWorkspace .pack-photo { grid-template-columns: minmax(0, 1fr) auto auto; }
#packWorkspace .pack-main { display: grid; gap: 2px; min-width: 0; }
#packWorkspace .pack-left { display: grid; justify-items: center; line-height: 1.1; font-variant-numeric: tabular-nums; }
#packWorkspace .pack-left small { color: var(--muted); font-size: .7rem; }
#packWorkspace .pack-qty { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
#packWorkspace .pack-item input { width: 100%; text-align: center; }
/* A narrow Items column (the 761-1150px two-column layout, or a collapsed-sidebar desktop) stacks each row: the item's name
   on its own line, then left / quantity / Add -- otherwise the name column is squeezed to a few characters wide. */
#packWorkspace .pack-items { container-type: inline-size; }
@media (min-width: 761px) {
  @container (max-width: 460px) {
    #packWorkspace .pack-item { grid-template-columns: 3.5rem minmax(0, 1fr) auto; }
    #packWorkspace .pack-item .pack-main { grid-column: 1 / -1; }
  }
}
#packWorkspace .pack-mobile-left, #packWorkspace .pack-phone { display: none; }
#packWorkspace .pack-over { color: var(--danger); font-weight: 700; }
#packWorkspace .pack-content[data-over] { border-left: 3px solid var(--danger); padding-left: 8px; }
#packWorkspace .pack-empty { padding: 14px 0; list-style: none; }
#packWorkspace .pack-undo { margin-top: 8px; }
#packWorkspace .pack-photo-add { cursor: pointer; justify-self: start; }
#packWorkspace .pack-photo-add[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
#packWorkspace .btn,
#packWorkspace input:not([type="checkbox"]):not([type="file"]),
#packWorkspace select { min-height: 44px; }
#packWorkspace .btn.small { min-width: 44px; padding-inline: 10px; }
#packWorkspace :is(.btn, input, select, textarea, a):focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
#packWorkspace .pack-commit-actions { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
#packWorkspace .pack-commit-actions #packSaveProgress { margin-right: auto; }
@media (max-width: 760px) {
  #packWorkspace .pack-desk { display: none; }
  #packWorkspace .pack-phone { display: grid; }
  #packWorkspace .pack-jumps { display: flex; gap: 8px; flex-wrap: wrap; }
  #packWorkspace .pack-jumps a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius); }
  #packWorkspace .pack-item { grid-template-columns: minmax(0, 1fr) 4.5rem auto; }
  #packWorkspace .pack-item .pack-left { display: none; }
  #packWorkspace .pack-mobile-left { display: block; font-weight: 700; }
  #packWorkspace .pack-item .btn.primary, #packWorkspace .pack-commit .btn.primary { min-height: 48px; }
  #packWorkspace .pack-commit-actions #packSaveProgress { margin-right: 0; }
  #packWorkspace .pack-commit {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  /* While a field inside the workspace has focus the bar sits in the page flow, never over what is being typed. */
  #packWorkspace .pack-commit.in-flow { position: static; }
}

/* --- Warehouse map (Task 1: clipped content) ----------------------------
 * MEASURED, AND NOT WHAT IT LOOKED LIKE. At 375 a location card's right edge
 * sat 47px outside a container whose overflow is `hidden` -- so the card was
 * cut off and could not be scrolled to. The obvious suspect was the depth
 * indent, but the offenders were at depth 0 with no indent at all: the list
 * is a GRID, a grid item's `min-width` defaults to `auto`, and an item whose
 * min-content is wider than the track makes the item -- not the track --
 * wider than its parent. `minmax(0, 1fr)` lets the row shrink, and the card
 * already ellipsizes its text inside a `min-width: 0` span.
 *
 * The indent still scales down, for room to read at that width. */
.location-list, .location-children { grid-template-columns: minmax(0, 1fr); }
/* The node is itself a grid, and its implicit `auto` track is the card's
   MAX-content -- the untruncated name -- so letting the node shrink was not
   enough on its own. */
.location-node { min-width: 0; grid-template-columns: minmax(0, 1fr); }

@media (max-width: 560px) {
  .location-node[data-depth="1"] { margin-left: 12px; }
  .location-node[data-depth="2"] { margin-left: 24px; }
}

/* --- Record grids (Task 31: no catastrophic overflow) -------------------
 * The database-health cells join several <small> facts with no separator.
 * Inline, "…configured" and "OFFSITE_UNCONFIGURED" become one unbreakable
 * 256px word, which pushed the whole System status page 33px wider than the
 * viewport at 480. Each fact is its own line, which is also how it reads. */
.record-grid small { display: block; overflow-wrap: anywhere; }
.record-grid small + small { margin-top: 2px; }

/* --- Order tabs (Task 8) ------------------------------------------------
 * Eight status tabs cannot fit 375px and should not shrink to fit. They
 * scroll, and the strip snaps so a half-tab is never the resting state. */
.queue-tabs { scroll-snap-type: x proximity; scroll-padding-inline: 4px; }
.queue-tabs button { scroll-snap-align: start; }

/* --- Operator tables at a handheld width (Task 8) -----------------------
 * MEASURED by Reviewer A: to read an order's status the operator dragged the
 * 341px window right by 804px, and to reach the button that starts the work,
 * by 1141px -- then dragged back to read the next row's identity. Page-level
 * scroll was zero the whole time, so the milestone's own contract was
 * satisfied while the row was still unusable.
 *
 * No column is hidden: hiding business data because a screen is narrow is the
 * one thing the contract forbids. Instead the two columns that frame the row
 * -- what it IS and what you can DO with it -- hold their place while the
 * middle scrolls under them, so identity and action are never more than a
 * glance apart. */
@media (max-width: 560px) {
  .page .table.selectable-table td:first-child,
  .page .table.selectable-table th:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    max-width: 42vw;
    background: var(--surface);
    box-shadow: 1px 0 0 var(--border);
  }
  .page .table.selectable-table thead th:first-child { z-index: 3; }
  .page .table.selectable-table tbody tr:hover td:first-child,
  .page .table.selectable-table tbody tr.selected td:first-child { background: var(--surface-soft); }
  .page .table.selectable-table td:last-child,
  .page .table.selectable-table th:last-child {
    position: sticky;
    right: 0;
    z-index: 2;
    background: var(--surface);
    box-shadow: -1px 0 0 var(--border);
  }
  .page .table.selectable-table thead th:last-child { z-index: 3; }
  /* A sticky cell cannot be transparent or the scrolling row shows through. */
  .page .table.selectable-table thead th:first-child,
  .page .table.selectable-table thead th:last-child { background: var(--surface-soft); }
}

/* --- The Orders first screen (Task 7) -----------------------------------
 * MEASURED by Reviewer A at 375: 296px of supervisor count tiles -- 44% of
 * the viewport -- pushed the first order 76px below the fold, so the order
 * screen opened on no orders. The counts are kept and stay readable; they
 * stop being a grid and become one scrollable band. */
@media (max-width: 560px) {
  #orderStatusCards {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding-bottom: 4px;
  }
  #orderStatusCards > * {
    flex: 0 0 auto;
    min-width: 8.5rem;
    scroll-snap-align: start;
  }
}

@media (forced-colors: active) {
  .filter-disclosure > summary { border: 1px solid ButtonText; }
  .filter-active-count { border: 1px solid CanvasText; }
  #packWorkspace .pack-commit { border-top: 1px solid CanvasText; }
  /* Reviewer C: which status tab is selected was carried ONLY by an inset
     box-shadow and a background one shade off the page -- forced colours
     strips the first and flattens the second, so every channel measured
     identical and the selection was invisible. Highlight is the system's own
     "this one is chosen". */
  .queue-tabs button[aria-selected="true"] {
    background: Highlight;
    color: HighlightText;
    forced-color-adjust: none;
  }
  /* The sticky operator columns must stay opaque, or the row scrolls through
     them in a forced palette. */
  .page .table.selectable-table td:first-child,
  .page .table.selectable-table td:last-child,
  .page .table.selectable-table th:first-child,
  .page .table.selectable-table th:last-child { background: Canvas; }
}

/* --- Technical pages: containment, not simplification (Task 31) ---------
 * Reviewer C measured 79px of PAGE-level overflow on /workspace at 375. The
 * cause is an inline `display:flex` with no class rule anywhere, so no media
 * query could reach it -- `flex-wrap` is the one property that can be added
 * from outside without touching the inline style. /api-explorer overflowed
 * 14px at 480 on an unbreakable scope name. */
@media (max-width: 900px) {
  .workspace-layout { flex-wrap: wrap; }
  .workspace-layout > * { min-width: 0; flex: 1 1 100%; }
}
#apiKeyScopeChoices { min-width: 0; }
#apiKeyScopeChoices label, #apiKeyScopeChoices span { overflow-wrap: anywhere; }

/* 0.6.4: the notification-recipient component's styles are shared/css/notify-recipients.css. */
/* 0.5.1: Ship-to "Email recipients", one address per line. */
.v-email-recipients { margin-top: 12px; }
.v-email-recipients textarea { min-height: 5.5em; resize: vertical; font-family: inherit; line-height: 1.45; }
.v-email-recipients small { color: var(--muted); }
/* 0.5.9 CSP: a style-src without 'unsafe-inline' refuses every style="" attribute parsed from markup (CSSOM writes
   such as el.style.width stay allowed), so what used to be inline attributes in the shared dialogs, the setup
   page and the vendor portal are these classes. */
.span-all { grid-column: 1 / -1; }
.gap-top { margin-top: 12px; }
.gap-top-s { margin-top: 8px; }
.gap-top-l { margin-top: 16px; }
.totp-key-label { margin-bottom: 6px; }
.totp-app-link { margin: 10px 0 4px; }
#totpDone { margin-top: 12px; }
#secClose { margin-top: 16px; }
.setup-main { width: min(980px, 100%); }
#serialSetupChoice { margin-top: 6px; }
#restorePanel { margin-top: 18px; }
#restorePanel h3 { margin: .2rem 0 .4rem; }

/* 0.6.1 no-flash start-up (shared/js/theme-boot.js; pages opt in with <html data-boot-gate>). Until the page's own
   start-up has applied branding (and, in the portals, the session and display mode), the workspace is hidden
   behind a neutral state -- never the default theme, never the placeholder logo. Inert on every other page. */
html[data-boot="pending"] .app,
html[data-boot="pending"] .auth { visibility: hidden; }
html[data-boot="pending"] body::after {
  content: "Loading…";
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .02em;
}

/* 0.6.4 Ship: the BOL editor (pages/order_documents.js). Commodity rows are cards -- the short fields in a grid, the
   description full width below, the shipment-only HAZMAT section last -- and the form can be hosted in the Ship workspace. */
#bolEditorForm .bol-cards { overflow: visible; contain: none; border: 0; }
#bolEditorForm .bol-cards table, #bolEditorForm .bol-cards tbody { display: block; width: 100%; min-width: 0; }
#bolEditorForm .bol-cards thead { display: none; }
#bolEditorForm .bol-row-card {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 112px), 1fr)); gap: 10px 12px;
  margin: 0 0 12px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  white-space: normal;   /* the table this card came from is nowrap: the HAZMAT text then forced the card wider than its column */
}
#bolEditorForm .bol-row-card > td { display: block; min-width: 0; max-width: none; padding: 0; border: 0; overflow: visible; }
#bolEditorForm .bol-row-card > .bol-row-type { order: -1; grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-weight: 800; }
#bolEditorForm .bol-row-card > .bol-row-c-description { order: 90; grid-column: 1 / -1; }
#bolEditorForm .bol-row-card > .bol-row-hazmat { order: 95; grid-column: 1 / -1; display: grid; gap: 10px; }
#bolEditorForm .bol-row-card > .bol-row-remove { order: 99; grid-column: 1 / -1; display: flex; justify-content: flex-end; }
#bolEditorForm .bol-commodity-description { field-sizing: content; min-height: 5.5em; max-height: 16em; line-height: 1.4; resize: vertical; }
#bolEditorForm .bol-row-hz { display: grid; min-width: 0; overflow-wrap: anywhere; gap: 8px; padding: 12px; border: 1px solid #edd1a5; border-radius: 10px; background: var(--warning-soft); color: var(--text); }
#bolEditorForm .bol-row-hz h4, #bolEditorForm .bol-row-hz p { margin: 0; }
#bolEditorForm .bol-row-hz h4 { font-size: .92rem; }
#bolEditorForm .bol-row-hz [hidden] { display: none; }
#bolEditorForm .bol-row-hz-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); gap: 8px 14px; margin: 0; }
#bolEditorForm .bol-row-hz-facts dt { color: var(--muted); font-size: .72rem; font-weight: 750; }
#bolEditorForm .bol-row-hz-facts dd { margin: 0; overflow-wrap: anywhere; font-weight: 650; }
#bolEditorForm .bol-row-hz-issues { color: var(--danger); font-weight: 750; }
#bolEditorForm .bol-row-hz-na { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
#bolEditorForm .bol-row-hz-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 10px 12px; align-items: end; }
/* The section sits in a commodity row's table cell, and every cell is `white-space: nowrap`: a long label ("Subsidiary
   hazards (comma separated)") ran over the next field. Labels wrap inside their own column; inputs line up at the bottom. */
#bolEditorForm .bol-row-hz, #bolEditorForm .bol-row-hz-form .field { white-space: normal; min-width: 0; }
#bolEditorForm .bol-row-hz-form .field > span { overflow-wrap: anywhere; }
#bolEditorForm .bol-row-hz .form-error { display: block; padding: 4px 8px; font-size: .78rem; }
#bolEditorForm .bol-class-note { display: block; margin-top: 4px; font-size: .78rem; overflow-wrap: anywhere; }
#bolEditorForm .bol-class-note.form-error { padding: 4px 8px; }
#shipMain[data-mode="ground"] [data-ship-class] { display: none; }   /* 0.6.4: freight class is a Freight BOL matter */
#bolEditorForm.bol-hosted { height: auto; max-height: none; }
#bolEditorForm.bol-hosted .dialog-body { overflow: visible; padding: 0 0 18px; }
#bolEditorForm.bol-hosted [data-close-dialog] { display: none; }
#bolEditorForm.bol-hosted .dialog-footer { position: sticky; bottom: 0; z-index: 2; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
#bolEditorForm.bol-hosted > #shipBackToShip { align-self: flex-start; margin: 0 0 12px; }
@media (max-width: 560px) {
  #bolEditorForm .bol-row-card { padding: 10px; }
  #bolEditorForm.bol-hosted .dialog-footer .btn { flex: 1 1 100%; }
}

/* 0.6.4 -- the Ship workspace (Option C; astra_design/ship_workspace). Tokens only, scoped to #shipWorkspace.
   >=1151px two columns; 761-1150px two columns with the fields stacked inside the cards; <=760px one column, section
   links, 48px controls and a sticky bar that moves into the flow while a control in the workspace has focus. */
#shipWorkspace .ship-modebar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
#shipWorkspace .ship-modebar p, #shipWorkspace .ship-card p, #shipWorkspace .ship-card h5, #shipWorkspace .ship-card h6 { margin: 0; }
#shipWorkspace .ship-modes { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
#shipWorkspace .ship-modes .btn[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
#shipWorkspace .ship-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 12px 0; }
#shipWorkspace .ship-metric { display: grid; gap: 2px; align-content: start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); min-width: 0; overflow-wrap: anywhere; }
#shipWorkspace .ship-metric small { color: var(--muted); font-weight: 600; }
#shipWorkspace .ship-metric b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
#shipWorkspace .ship-jumps { display: none; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
#shipWorkspace .ship-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); align-items: start; }
#shipWorkspace .ship-col { display: grid; gap: 14px; min-width: 0; align-content: start; }
#shipWorkspace .ship-card { scroll-margin-top: 84px; min-width: 0; }
#shipWorkspace .ship-card > summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
#shipWorkspace .ship-card > summary h5 { display: inline; }
#shipWorkspace .ship-fields { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
#shipWorkspace .ship-field { min-width: 0; display: grid; gap: 4px; align-content: start; }
#shipWorkspace .ship-note { font-size: .78rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
#shipWorkspace .ship-flag { color: var(--warning); font-weight: 600; }
#shipWorkspace .ship-field input[aria-invalid="true"] { border-color: var(--danger); }
#shipWorkspace .error-text { color: var(--danger); font-weight: 700; }
#shipWorkspace [data-ship-carrier-diff] { color: var(--text); }
#shipWorkspace .ship-bill, #shipWorkspace .ship-doc, #shipWorkspace .ship-pack, #shipWorkspace .ship-measures, #shipWorkspace .ship-details {
  display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-soft); }
#shipWorkspace .ship-doc + .ship-doc, #shipWorkspace .ship-pack + .ship-pack { margin-top: 8px; }
#shipWorkspace .ship-doc > summary { cursor: pointer; font-weight: 700; }
#shipWorkspace .ship-doc .actions, #shipWorkspace .ship-card .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#shipWorkspace .ship-packs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
#shipWorkspace .ship-pack-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; justify-content: space-between; }
#shipWorkspace .ship-pack .btn { justify-self: start; }
#shipWorkspace .ship-route { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
#shipWorkspace .ship-route p { overflow-wrap: anywhere; }
#shipWorkspace .ship-review { display: grid; gap: 6px; margin: 12px 0 0; }
#shipWorkspace .ship-review div { display: grid; grid-template-columns: minmax(0, 11rem) minmax(0, 1fr); gap: 8px; }
#shipWorkspace .ship-review dt { color: var(--muted); font-weight: 600; }
#shipWorkspace .ship-review dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
#shipWorkspace .ship-save-state { margin: 0; font-weight: 600; }
#shipWorkspace .ship-save-state[data-state="dirty"] { color: var(--warning); }
#shipWorkspace .ship-save-state[data-state="saved"] { color: var(--primary-dark); }
#shipWorkspace .ship-save-state[data-state="failed"] { color: var(--danger); }
#shipWorkspace .ship-commit { position: sticky; z-index: 5; bottom: 0; display: grid; gap: 8px; justify-items: start; margin-top: 12px; padding: 12px 0; border-top: 1px solid var(--border); background: var(--surface); }
#shipWorkspace .ship-commit-actions { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }
#shipWorkspace .ship-commit-actions #shipSaveDraft { margin-right: auto; }
#shipWorkspace[data-shipped] .ship-freight-only { display: none; }
#shipWorkspace .ship-grid[data-mode="ground"] .ship-freight, #shipWorkspace .ship-grid[data-mode="freight"] .ship-ground { display: none; }
#shipWorkspace .btn, #shipWorkspace input:not([type="checkbox"]):not([type="file"]), #shipWorkspace select { min-height: 44px; }
#shipWorkspace .btn.small { min-width: 44px; padding-inline: 10px; }
#shipWorkspace :is(.btn, input, select, textarea, a, summary):focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
#shipWorkspace input, #shipWorkspace select { scroll-margin-bottom: 148px; }
@media (min-width: 761px) {
  #shipWorkspace .ship-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 761px) and (max-width: 1150px) {
  #shipWorkspace .ship-fields, #shipWorkspace .ship-route { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  #shipWorkspace .ship-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #shipWorkspace .ship-jumps { display: flex; }
  #shipWorkspace .ship-jumps a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius); }
  #shipWorkspace .ship-fields, #shipWorkspace .ship-route { grid-template-columns: minmax(0, 1fr); }
  #shipWorkspace .ship-modes { display: flex; width: 100%; }
  #shipWorkspace .ship-modes .btn { flex: 1 1 0; }
  #shipWorkspace input:not([type="checkbox"]):not([type="file"]), #shipWorkspace select { min-height: 48px; font-size: 16px; }
  #shipWorkspace .btn { min-height: 48px; }
  #shipWorkspace .btn.small { min-height: 44px; }
  #shipWorkspace .ship-commit { margin: 12px -14px -14px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px)); }
  #shipWorkspace .ship-commit-actions .btn { flex: 1 1 140px; }
  #shipWorkspace .ship-commit-actions #shipSaveDraft { margin-right: 0; }
  #shipWorkspace .ship-commit.in-flow { position: static; }
  #shipWorkspace .ship-review div { grid-template-columns: minmax(0, 1fr); gap: 0; }
}
@media (forced-colors: active) { #shipWorkspace .ship-commit { border-top: 1px solid CanvasText; } }

/* 0.6.6 M2: Export CSV on the Inventory pages -- a toolbar menu of two choices, opening downward. */
.export-menu { position: relative; }
.export-menu > summary { list-style: none; }
.export-menu > summary::-webkit-details-marker { display: none; }
.export-menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; display: grid; gap: 8px;
  width: max-content; max-width: min(320px, calc(100vw - 32px)); padding: 10px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow); }
@media (max-width: 560px) { .export-menu > summary, .export-menu-list .btn { min-height: 44px; } }
