/* PrintWizzard — Component library
 * Phase 2 (v2.45.0). Vanilla CSS layered on tokens.css.
 *
 * Naming: `.pw-{component}--{variant}`. BEM-ish. Component names
 * intentionally collision-free with legacy style.css class names
 * (`.btn`, `.card`, `.pill`) so both layers cohabit during the
 * Phase 3+4 template migration.
 *
 * Loads BEFORE legacy style.css so the legacy `:root` overrides
 * still cascade-win for any template that still uses old class
 * names. Components below reference --pw-* semantic tokens
 * exclusively; light/dark and prefers-reduced-motion parity
 * are automatic via tokens.css.
 *
 * Accessibility baseline:
 *   - Every interactive component honors :focus-visible with the
 *     token-driven focus ring.
 *   - All status colors are WCAG AA against their backgrounds.
 *   - prefers-reduced-motion zeroes out transitions (via tokens).
 *   - Touch targets ≥44 px (admin) / ≥60 px (operator/QA) via
 *     the --pw-touch-target tokens.
 */

/* ════════════════════════════════════════════════════════════════
   Component-layer tokens. Extends tokens.css with per-component
   purpose aliases so component CSS reads cleanly without
   re-deriving values inline.
   ════════════════════════════════════════════════════════════════ */
:root {
  /* Touch targets */
  --pw-touch-sm: 36px;
  --pw-touch-md: 44px;   /* admin minimum */
  --pw-touch-lg: 60px;   /* operator/kiosk minimum */
  --pw-touch-xl: 80px;   /* QA verdict buttons */

  /* Button heights per size */
  --pw-btn-h-sm: var(--pw-touch-sm);
  --pw-btn-h-md: var(--pw-touch-md);
  --pw-btn-h-lg: var(--pw-touch-lg);

  /* Card */
  --pw-card-pad: var(--pw-space-5);
  --pw-card-pad-sm: var(--pw-space-4);

  /* Field */
  --pw-field-h: var(--pw-touch-md);
  --pw-field-pad-x: var(--pw-space-3);
  --pw-field-pad-y: var(--pw-space-2);

  /* Status colours — station online/offline indicators and error surfaces */
  --pw-green:    #1a8a1a;
  --pw-red:      #c0392b;
  --pw-error-bg: #fff0f0;

  /* Neutral / surface palette used by pairing screens */
  --pw-muted:          #888;
  --pw-surface-raised: #f5f5f5;

  /* Nav */
  --pw-nav-h: 56px;
  --pw-kiosk-header-h: 72px;
}

/* ════════════════════════════════════════════════════════════════
   pw-btn — primary action element. Always render as <button> or
   <a class="pw-btn">; never use <div onclick>. Default size is
   md; modifiers pick variant + size + width.
   ════════════════════════════════════════════════════════════════ */
.pw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--pw-space-2);
  min-height: var(--pw-btn-h-md);
  padding: 0 var(--pw-space-4);
  border: 1px solid transparent;
  border-radius: var(--pw-radius-md);
  font-family: var(--pw-font-ui);
  font-size: var(--pw-text-base);
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color var(--pw-duration-fast) var(--pw-easing-out),
    border-color var(--pw-duration-fast) var(--pw-easing-out),
    color var(--pw-duration-fast) var(--pw-easing-out),
    box-shadow var(--pw-duration-fast) var(--pw-easing-out);
  background: var(--pw-surface);
  color: var(--pw-text);
  border-color: var(--pw-border-strong);
}
.pw-btn:hover { background: var(--pw-surface-2); }
.pw-btn:active { background: var(--pw-surface-3); }
.pw-btn:focus-visible { outline: none; box-shadow: var(--pw-focus-ring); }
.pw-btn:disabled,
.pw-btn[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: .55;
  pointer-events: none;
}

/* Variant: primary */
.pw-btn--primary {
  background: var(--pw-primary);
  color: var(--pw-primary-on);
  border-color: var(--pw-primary);
}
.pw-btn--primary:hover { background: var(--pw-primary-hover); border-color: var(--pw-primary-hover); }
.pw-btn--primary:active { background: var(--pw-primary-active); border-color: var(--pw-primary-active); }

/* Variant: secondary (low-emphasis outlined) */
.pw-btn--secondary {
  background: transparent;
  color: var(--pw-primary);
  border-color: var(--pw-primary);
}
.pw-btn--secondary:hover { background: var(--pw-primary-soft); }

/* Variant: ghost (no border) */
.pw-btn--ghost {
  background: transparent;
  color: var(--pw-text);
  border-color: transparent;
}
.pw-btn--ghost:hover { background: var(--pw-surface-2); }

/* Variant: danger */
.pw-btn--danger {
  background: var(--pw-danger);
  color: var(--pw-danger-on);
  border-color: var(--pw-danger);
}
.pw-btn--danger:hover { filter: brightness(1.1); }
.pw-btn--danger:active { filter: brightness(0.92); }

/* Sizes */
.pw-btn--sm { min-height: var(--pw-btn-h-sm); padding: 0 var(--pw-space-3); font-size: var(--pw-text-sm); }
.pw-btn--lg { min-height: var(--pw-btn-h-lg); padding: 0 var(--pw-space-6); font-size: var(--pw-text-md); }
.pw-btn--xl { min-height: var(--pw-touch-xl); padding: 0 var(--pw-space-8); font-size: var(--pw-text-lg); font-weight: 600; }

/* Full-width (mobile-friendly) */
.pw-btn--block { display: flex; width: 100%; }

/* ════════════════════════════════════════════════════════════════
   pw-card — surface container for grouped content. Default is the
   resting surface; --raised adds a subtle shadow.
   ════════════════════════════════════════════════════════════════ */
.pw-card {
  background: var(--pw-surface);
  border: 1px solid var(--pw-border);
  border-radius: var(--pw-radius-lg);
  padding: var(--pw-card-pad);
}
.pw-card--raised { box-shadow: var(--pw-shadow-md); }
.pw-card--sm { padding: var(--pw-card-pad-sm); }
.pw-card--flush { padding: 0; overflow: hidden; }
.pw-card__title {
  font-family: var(--pw-font-display);
  font-style: italic;
  font-weight: 600;
  font-size: var(--pw-text-xl);
  letter-spacing: -.005em;
  color: var(--pw-text);
  margin: 0 0 var(--pw-space-3);
  line-height: var(--pw-line-tight);
}
.pw-card__subtitle {
  font-size: var(--pw-text-sm);
  color: var(--pw-text-muted);
  margin: 0 0 var(--pw-space-4);
}

/* ════════════════════════════════════════════════════════════════
   pw-pill — compact status badge. Variants mirror the system's
   status enums (print_jobs.status + qa_status) so a template can
   write `<span class="pw-pill pw-pill--{{ pj.status }}">` and get
   the right colors automatically. Add new status keys here, not
   inline-styled in templates.
   ════════════════════════════════════════════════════════════════ */
.pw-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--pw-space-1);
  padding: 2px var(--pw-space-2);
  border-radius: var(--pw-radius-pill);
  font-family: var(--pw-font-ui);
  font-size: var(--pw-text-xs);
  font-weight: 600;
  letter-spacing: .02em;
  line-height: 1.4;
  white-space: nowrap;
  background: var(--pw-surface-2);
  color: var(--pw-text-muted);
  border: 1px solid var(--pw-border);
}
.pw-pill--lg { font-size: var(--pw-text-sm); padding: 4px var(--pw-space-3); }

/* Lifecycle states. Background is a low-saturation tint of the
   foreground color so the pill reads against either light or
   dark surfaces. */
.pw-pill--queued     { background: var(--pw-paper-200); color: var(--pw-paper-700); border-color: var(--pw-paper-300); }
.pw-pill--processing { background: var(--pw-blue-100);  color: var(--pw-blue-700);  border-color: var(--pw-blue-500); }
.pw-pill--printing   { background: var(--pw-blue-100);  color: var(--pw-blue-700);  border-color: var(--pw-primary); }
.pw-pill--printed    { background: #E5F0E9;             color: var(--pw-good-500);  border-color: var(--pw-good-500); }
.pw-pill--error      { background: #F8E0DC;             color: var(--pw-bad-500);   border-color: var(--pw-bad-500); }

/* QA states. qa-pass = printed-and-passed; qa-fail = printed-and-
   failed; qa-missing = sheet missing from the printed batch. */
.pw-pill--qa-pass    { background: #E5F0E9; color: var(--pw-good-500); border-color: var(--pw-good-500); }
.pw-pill--qa-fail    { background: #F8E0DC; color: var(--pw-bad-500);  border-color: var(--pw-bad-500); }
.pw-pill--qa-missing { background: #F8EFD5; color: var(--pw-warn-500); border-color: var(--pw-warn-500); }

/* Dark mode tints — semi-transparent overlays of the foreground
   color, automatically adapted. */
@media (prefers-color-scheme: dark) {
  .pw-pill--queued     { background: rgba(255,255,255,.06); color: var(--pw-paper-300); border-color: rgba(255,255,255,.12); }
  .pw-pill--processing { background: rgba(96, 136, 200, .15); color: var(--pw-blue-300); border-color: var(--pw-blue-300); }
  .pw-pill--printing   { background: rgba(96, 136, 200, .15); color: var(--pw-blue-300); border-color: var(--pw-blue-300); }
  .pw-pill--printed,
  .pw-pill--qa-pass    { background: rgba(63, 149, 96, .15); color: var(--pw-good-300); border-color: var(--pw-good-300); }
  .pw-pill--error,
  .pw-pill--qa-fail    { background: rgba(209, 79, 64, .15); color: var(--pw-bad-300);  border-color: var(--pw-bad-300); }
  .pw-pill--qa-missing { background: rgba(212, 168, 51, .15); color: var(--pw-warn-300); border-color: var(--pw-warn-300); }
}

/* ════════════════════════════════════════════════════════════════
   pw-table — data tables. Touch-scrolls horizontally on mobile
   when wider than the viewport; sticky header row keeps the
   labels visible during long scrolls. Use real <table>/<thead>/
   <tbody>/<th> markup; semantic HTML is required for the sticky
   header rules to apply.
   ════════════════════════════════════════════════════════════════ */
.pw-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--pw-radius-lg);
  border: 1px solid var(--pw-border);
}
.pw-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--pw-font-ui);
  font-size: var(--pw-text-base);
  background: var(--pw-surface);
}
.pw-table th,
.pw-table td {
  text-align: left;
  padding: var(--pw-space-3) var(--pw-space-4);
  border-bottom: 1px solid var(--pw-border);
  vertical-align: middle;
}
.pw-table th {
  background: var(--pw-surface-2);
  font-weight: 600;
  font-size: var(--pw-text-sm);
  color: var(--pw-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  position: sticky;
  top: 0;
  z-index: 1;
}
.pw-table tbody tr:last-child td { border-bottom: 0; }
.pw-table tbody tr:hover { background: var(--pw-surface-2); }
.pw-table--compact th,
.pw-table--compact td { padding: var(--pw-space-2) var(--pw-space-3); }
.pw-table--tnum { font-feature-settings: 'tnum'; }

/* ════════════════════════════════════════════════════════════════
   pw-modal — overlay dialog. Uses <dialog> on supporting
   browsers (Chrome 37+, Safari 15.4+); the `.pw-modal` class
   styles both <dialog> and a fallback `<div role="dialog">` for
   the rare iOS that still lags. JS opens via .showModal().
   ════════════════════════════════════════════════════════════════ */
.pw-modal {
  border: 1px solid var(--pw-border);
  border-radius: var(--pw-radius-lg);
  padding: 0;
  background: var(--pw-surface);
  color: var(--pw-text);
  box-shadow: var(--pw-shadow-lg);
  width: min(560px, calc(100vw - var(--pw-space-8)));
  max-height: calc(100vh - var(--pw-space-8));
  overflow: hidden;
}
.pw-modal::backdrop {
  background: rgba(14, 16, 20, 0.55);
  backdrop-filter: blur(2px);
}
.pw-modal__header,
.pw-modal__body,
.pw-modal__footer {
  padding: var(--pw-space-4) var(--pw-space-5);
}
.pw-modal__header {
  border-bottom: 1px solid var(--pw-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--pw-space-3);
}
.pw-modal__title {
  margin: 0;
  font-family: var(--pw-font-display);
  font-style: italic;
  font-weight: 600;
  font-size: var(--pw-text-lg);
  line-height: var(--pw-line-tight);
}
.pw-modal__body {
  max-height: 60vh;
  overflow-y: auto;
}
.pw-modal__footer {
  border-top: 1px solid var(--pw-border);
  display: flex;
  gap: var(--pw-space-2);
  justify-content: flex-end;
  background: var(--pw-surface-2);
}

/* pw-sheet — bottom-anchored variant for mobile. */
@media (max-width: 640px) {
  .pw-modal--sheet {
    margin: auto auto 0 auto;
    width: 100vw;
    max-width: 100vw;
    border-radius: var(--pw-radius-xl) var(--pw-radius-xl) 0 0;
    max-height: 85vh;
  }
}

/* ════════════════════════════════════════════════════════════════
   pw-toast — short-lived feedback. Position is fixed to the
   bottom-center; templates JS opens + auto-dismisses.
   ════════════════════════════════════════════════════════════════ */
.pw-toast {
  position: fixed;
  left: 50%;
  bottom: var(--pw-space-6);
  transform: translateX(-50%);
  background: var(--pw-ink);
  color: var(--pw-paper-50);
  padding: var(--pw-space-3) var(--pw-space-5);
  border-radius: var(--pw-radius-pill);
  box-shadow: var(--pw-shadow-lg);
  font-family: var(--pw-font-ui);
  font-size: var(--pw-text-base);
  z-index: 1000;
  max-width: calc(100vw - var(--pw-space-8));
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--pw-duration-base) var(--pw-easing-out);
}
.pw-toast--visible { opacity: 1; pointer-events: auto; }
.pw-toast--success { background: var(--pw-success); }
.pw-toast--danger  { background: var(--pw-danger); }

/* ════════════════════════════════════════════════════════════════
   pw-field — form input. Wraps <label> + <input>/<select>/
   <textarea> in `.pw-field`. Adds help text + validation states.
   ≥16 px input font-size on touch (prevents iOS zoom).
   ════════════════════════════════════════════════════════════════ */
.pw-field {
  display: flex;
  flex-direction: column;
  gap: var(--pw-space-1);
}
.pw-field__label {
  font-family: var(--pw-font-ui);
  font-size: var(--pw-text-sm);
  font-weight: 500;
  color: var(--pw-text);
}
.pw-field__label--required::after {
  content: " *";
  color: var(--pw-danger);
}
.pw-field__control,
.pw-field input,
.pw-field select,
.pw-field textarea {
  width: 100%;
  min-height: var(--pw-field-h);
  padding: var(--pw-field-pad-y) var(--pw-field-pad-x);
  background: var(--pw-surface);
  color: var(--pw-text);
  border: 1px solid var(--pw-border-strong);
  border-radius: var(--pw-radius-md);
  font-family: var(--pw-font-ui);
  font-size: 16px;  /* iOS zoom prevention; touch override */
  line-height: var(--pw-line-base);
  transition:
    border-color var(--pw-duration-fast) var(--pw-easing-out),
    box-shadow var(--pw-duration-fast) var(--pw-easing-out);
}
@media (min-width: 700px) {
  .pw-field input,
  .pw-field select,
  .pw-field textarea {
    font-size: var(--pw-text-base);
  }
}
.pw-field input:hover,
.pw-field select:hover,
.pw-field textarea:hover { border-color: var(--pw-text-muted); }
.pw-field input:focus,
.pw-field select:focus,
.pw-field textarea:focus,
.pw-field input:focus-visible,
.pw-field select:focus-visible,
.pw-field textarea:focus-visible {
  outline: none;
  border-color: var(--pw-primary);
  box-shadow: var(--pw-focus-ring);
}
.pw-field textarea { min-height: calc(var(--pw-field-h) * 2.5); resize: vertical; }
.pw-field__help {
  font-size: var(--pw-text-xs);
  color: var(--pw-text-faint);
}
.pw-field__error {
  font-size: var(--pw-text-xs);
  color: var(--pw-danger);
  font-weight: 500;
}
.pw-field--invalid input,
.pw-field--invalid select,
.pw-field--invalid textarea { border-color: var(--pw-danger); }
.pw-field--invalid input:focus { box-shadow: 0 0 0 3px rgba(168, 38, 26, 0.35); }

/* ════════════════════════════════════════════════════════════════
   pw-nav — top-of-page navigation. Used by the new shared chrome
   in admin pages once Phase 4 migrates them. Operator + QA have
   their own pw-kiosk-header below.
   ════════════════════════════════════════════════════════════════ */
/* v2.59.80 — Inline mode pills in the top bar (Admin/Station/QA/
   CRM/Portal). Replaces the old separate mode-switcher strip so
   there's only ONE row of chrome. */
.pw-modes {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 32px;
  margin-left: 0.75em;
  padding: 2px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
}
.pw-mode {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.85em;
  height: 28px;
  font-family: var(--pw-font-ui, 'IBM Plex Sans', sans-serif);
  font-size: 12.5px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  border-radius: 6px;
  letter-spacing: 0.01em;
  transition: background 140ms ease, color 140ms ease;
}
.pw-mode:hover { color: rgba(255, 255, 255, 0.85); }
.pw-mode--active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--pw-paper-50);
  font-weight: 600;
}
@media (max-width: 768px) {
  .pw-modes { display: none; }
}

/* v2.59.81 — Daily-driver page links in the top bar. Visually
   DISTINCT from the mode pills (which sit to the left): these are
   newspaper-section-style small-caps text links so the eye reads
   the two nav rows as separate things (universal switcher vs
   page wayfinding), not redundant pills. */
.pw-pages {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 1.5em;
  height: 32px;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  padding-left: 1.5em;
}
.pw-page-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0 0.85em;
  height: 32px;
  font-family: var(--pw-font-mono, 'IBM Plex Mono', monospace);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  white-space: nowrap;
  transition: color 120ms ease;
}
.pw-page-link:hover { color: var(--pw-paper-50, #fafafa); }
.pw-page-link--active {
  color: var(--pw-paper-50, #fafafa);
  font-weight: 600;
}
.pw-page-link--active::after {
  content: '';
  position: absolute;
  left: 0.85em;
  right: 0.85em;
  bottom: 6px;
  height: 1px;
  background: var(--pw-primary, var(--pw-accent));
}
.pw-page-link__chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 17px;
  height: 15px;
  padding: 0 5px;
  border-radius: 8px;
  background: var(--pw-warn, #b85c00);
  color: white;
  font-family: var(--pw-font-mono, monospace);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}
@media (max-width: 1200px) {
  .pw-pages { display: none; }
}

/* v2.59.81 — Subtle dot-grid texture on the shell background.
   Pure CSS radial-gradient at very low opacity gives the dark
   surface depth without competing with content. */
.pw-app-layout {
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: 0 0;
}

/* App-shell top bar. Brand sits in a fixed-width zone matching the
   rail (232px) so they read as one continuous masthead; everything
   right of the brand lives in the content column. Vertical hairline
   between brand and content reinforces the rail seam. */
.pw-nav {
  display: flex;
  align-items: center;
  gap: var(--pw-space-3);
  min-height: var(--pw-nav-h);
  padding: 0;
  background: var(--pw-ink);
  color: var(--pw-paper-50);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .15);
  position: sticky;
  top: 0;
  z-index: 100;
}
.pw-nav .brand {
  display: inline-flex;
  align-items: center;
  height: var(--pw-nav-h);
  padding: 0 1.25em 0 1em;
  box-sizing: border-box;
  font-family: var(--pw-font-display);
  font-style: italic;
  font-weight: 600;
  font-size: 1.15em;
  text-decoration: none;
  color: var(--pw-paper-50);
  letter-spacing: -.005em;
}
.pw-nav .brand:hover { color: var(--pw-paper-50); }
/* Everything right of the brand gets a left padding so it doesn't
   crowd the rail seam. */
.pw-nav > *:not(.brand):not(.pw-nav-hamburger):first-of-type {
  margin-left: 1em;
}
.pw-nav .spacer { flex: 1 1 auto; }
@media (max-width: 768px) {
  .pw-nav .brand {
    width: auto;
    min-width: 0;
    border-right: 0;
    padding: 0 1em;
  }
}
.pw-nav__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--pw-space-2);
  font-family: var(--pw-font-display);
  font-style: italic;
  font-weight: 600;
  font-size: var(--pw-text-lg);
  text-decoration: none;
  color: inherit;
  letter-spacing: -.005em;
}
.pw-nav__link {
  display: inline-flex;
  align-items: center;
  padding: var(--pw-space-2) var(--pw-space-3);
  font-family: var(--pw-font-ui);
  font-size: var(--pw-text-base);
  font-weight: 500;
  color: rgba(255, 255, 255, .75);
  text-decoration: none;
  border-radius: var(--pw-radius-md);
  transition: background-color var(--pw-duration-fast) var(--pw-easing-out),
              color var(--pw-duration-fast) var(--pw-easing-out);
}
.pw-nav__link:hover { background: rgba(255, 255, 255, .08); color: var(--pw-paper-50); }
.pw-nav__link--active {
  background: rgba(255, 255, 255, .12);
  color: var(--pw-paper-50);
}
.pw-nav__link:focus-visible {
  outline: none;
  box-shadow: var(--pw-focus-ring-on-dark);
}
.pw-nav__right {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--pw-space-3);
}

/* ════════════════════════════════════════════════════════════════
   pw-kiosk-header — top bar for the touch-screen surfaces
   (/operator/<printer>, /qa/*). Taller than the admin nav and
   sized for finger taps. Phase 3 templates migrate onto this.
   ════════════════════════════════════════════════════════════════ */
.pw-kiosk-header {
  display: flex;
  align-items: center;
  gap: var(--pw-space-4);
  min-height: var(--pw-kiosk-header-h);
  padding: var(--pw-space-3) var(--pw-space-5);
  background: var(--pw-ink);
  color: var(--pw-paper-50);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.pw-kiosk-header__title {
  font-family: var(--pw-font-display);
  font-style: italic;
  font-weight: 600;
  font-size: var(--pw-text-xl);
  letter-spacing: -.01em;
  margin: 0;
  line-height: var(--pw-line-tight);
}
.pw-kiosk-header__meta {
  font-size: var(--pw-text-sm);
  color: rgba(255, 255, 255, .7);
}
.pw-kiosk-header__right {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--pw-space-3);
}
.pw-kiosk-header .pw-btn {
  min-height: var(--pw-touch-lg);  /* taller taps for kiosk hands */
}

/* ════════════════════════════════════════════════════════════════
   pw-flash — banner-style message at the top of a page or above
   a form. Multi-line OK; tone via --error / --success / --info.
   Phase 3 first-touch (v2.45.1) — added during operator_login
   migration because so many templates use the legacy
   `.flash .flash-error` class.
   ════════════════════════════════════════════════════════════════ */
.pw-flash {
  padding: var(--pw-space-3) var(--pw-space-4);
  border-radius: var(--pw-radius-md);
  border: 1px solid var(--pw-border);
  background: var(--pw-surface-2);
  color: var(--pw-text);
  font-family: var(--pw-font-ui);
  font-size: var(--pw-text-base);
  line-height: var(--pw-line-base);
}
.pw-flash--success {
  background: #E5F0E9;
  color: var(--pw-good-500);
  border-color: var(--pw-good-500);
}
.pw-flash--error {
  background: #F8E0DC;
  color: var(--pw-bad-500);
  border-color: var(--pw-bad-500);
}
.pw-flash--info {
  background: var(--pw-blue-100);
  color: var(--pw-blue-700);
  border-color: var(--pw-blue-500);
}
@media (prefers-color-scheme: dark) {
  .pw-flash--success { background: rgba(63, 149, 96, .15); color: var(--pw-good-300); border-color: var(--pw-good-300); }
  .pw-flash--error   { background: rgba(209, 79, 64, .15); color: var(--pw-bad-300);  border-color: var(--pw-bad-300); }
  .pw-flash--info    { background: rgba(96, 136, 200, .15); color: var(--pw-blue-300); border-color: var(--pw-blue-300); }
}

/* ════════════════════════════════════════════════════════════════
   Utility classes used by the styleguide page + small ones the
   component examples need. Intentionally minimal — utility-class
   bloat is a Phase 5 concern, not now.
   ════════════════════════════════════════════════════════════════ */
.pw-stack { display: flex; flex-direction: column; gap: var(--pw-space-4); }
.pw-row   { display: flex; align-items: center; gap: var(--pw-space-3); flex-wrap: wrap; }
.pw-muted { color: var(--pw-text-muted); }
.pw-mono  { font-family: var(--pw-font-mono); font-size: var(--pw-text-sm); }

/* Page wrappers for the styleguide + future Phase 3+4 pages. */
.pw-page {
  background: var(--pw-bg);
  color: var(--pw-text);
  min-height: 100vh;
  font-family: var(--pw-font-ui);
  font-size: var(--pw-text-base);
  line-height: var(--pw-line-base);
}
.pw-container {
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--pw-space-6) var(--pw-space-5);
}

/* ═══════════════════════════════════════════════════════════════════
   v2.51.0 — Theme toggle
   Three-button form: light / dark / auto. Compact icon-with-label
   chip set that sits in the .pw-nav__right group. Uses semantic
   tokens throughout so the toggle itself adapts to the theme it
   controls (the active button's contrast still reads in both modes).
   =================================================================== */
.pw-theme-toggle {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--pw-border);
  border-radius: var(--pw-radius-pill);
  padding: 2px;
  background: var(--pw-surface-2);
}
.pw-theme-toggle__option {
  appearance: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: var(--pw-text-xs);
  color: var(--pw-text-muted);
  padding: 6px 12px;
  border-radius: var(--pw-radius-pill);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
  transition: background var(--pw-duration-fast) var(--pw-easing-out),
              color var(--pw-duration-fast) var(--pw-easing-out);
}
.pw-theme-toggle__option:hover {
  color: var(--pw-text);
}
.pw-theme-toggle__option:focus-visible {
  outline: none;
  box-shadow: var(--pw-focus-ring);
}
.pw-theme-toggle__option.is-active {
  background: var(--pw-surface);
  color: var(--pw-text);
  font-weight: 500;
  box-shadow: var(--pw-shadow-sm);
}
.pw-theme-toggle__label {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}
/* On phones, drop the text label and just show the icon chip
   so the toggle doesn't crowd a narrow nav. v2.51.46 — Gap H4
   fix: min-height/min-width 44px so the icon-only chips don't
   collapse below Apple HIG tap-target on coarse pointers. */
@media (max-width: 640px) {
  .pw-theme-toggle__label { display: none; }
  .pw-theme-toggle__option {
    padding: 6px 12px;
    min-width: 44px;
    min-height: 44px;
    justify-content: center;
  }
}

/* v2.61.x (D1) — Language toggle (EN / ES / RU). Rides the
   .pw-theme-toggle pill styling; this variant only guarantees the
   ≥44px touch target at EVERY viewport (the theme toggle only grows
   to 44px on phones). Labels are two-letter codes, so the pill stays
   compact even with the 44px minimums. */
.pw-lang-toggle__option {
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════════════
   v2.51.0 — §3 new component classes
   Replaces legacy patterns (.kpi-grid, .actions, .filters, .kv,
   .meta-grid, .store-form, .bar-chart, .qa-agent-banner*,
   .mode-switcher, .attention-banner, .verify-banner, .changelog).
   Editorial primitives (.pw-prose, .pw-heading--display, .pw-byline,
   .pw-rule) feed the §5 polish pass.
   =================================================================== */

/* ─── .pw-stats — KPI grid (replaces .kpi-grid + .kpi*) ────────── */
.pw-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--pw-space-4);
  margin: var(--pw-space-4) 0;
}
.pw-stats__item {
  background: var(--pw-surface);
  border: 1px solid var(--pw-border);
  border-radius: var(--pw-radius-lg);
  padding: var(--pw-space-5);
  display: flex;
  flex-direction: column;
  gap: var(--pw-space-2);
}
.pw-stats__label {
  font-size: var(--pw-text-xs);
  color: var(--pw-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 500;
}
.pw-stats__value {
  font-size: var(--pw-text-2xl);
  font-weight: 600;
  line-height: var(--pw-line-tight);
  font-variant-numeric: tabular-nums;
  color: var(--pw-text);
}
.pw-stats__value--hero {
  font: var(--pw-font-display-italic);
  font-size: 96px;
  line-height: 1;
}
.pw-stats__meta {
  font-size: var(--pw-text-sm);
  color: var(--pw-text-muted);
}

/* ─── .pw-toolbar — action group row (replaces .actions) ────────── */
.pw-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pw-space-3);
  align-items: center;
  margin: var(--pw-space-4) 0;
}
.pw-toolbar__group {
  display: inline-flex;
  gap: var(--pw-space-2);
  align-items: center;
}
.pw-toolbar__spacer {
  flex: 1;
  min-width: var(--pw-space-3);
}

/* ─── .pw-filter-bar — filter row (replaces .filters) ──────────── */
.pw-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pw-space-4);
  align-items: flex-end;
  background: var(--pw-surface);
  border: 1px solid var(--pw-border);
  border-radius: var(--pw-radius-lg);
  padding: var(--pw-space-4) var(--pw-space-5);
  margin: var(--pw-space-4) 0;
}
.pw-filter-bar__field {
  display: flex;
  flex-direction: column;
  gap: var(--pw-space-1);
  min-width: 160px;
}
.pw-filter-bar__field label,
.pw-filter-bar__label {
  font-size: var(--pw-text-xs);
  color: var(--pw-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}
.pw-filter-bar__field input,
.pw-filter-bar__field select {
  padding: var(--pw-space-2) var(--pw-space-3);
  border: 1px solid var(--pw-border);
  border-radius: var(--pw-radius-sm);
  background: var(--pw-surface);
  color: var(--pw-text);
  font-size: var(--pw-text-sm);
  font-family: inherit;
  min-height: var(--pw-touch-md);
}
.pw-filter-bar__field input:focus-visible,
.pw-filter-bar__field select:focus-visible {
  outline: none;
  box-shadow: var(--pw-focus-ring);
  border-color: var(--pw-primary);
}

/* ─── .pw-kv — key/value table (replaces .kv + .meta-grid) ─────── */
.pw-kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--pw-space-2) var(--pw-space-5);
  margin: var(--pw-space-3) 0;
}
.pw-kv__label {
  font-size: var(--pw-text-xs);
  color: var(--pw-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
  align-self: center;
}
.pw-kv__value {
  color: var(--pw-text);
  font-size: var(--pw-text-base);
}

/* ─── .pw-form-grid — 2-col responsive form (replaces .store-form) */
.pw-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--pw-space-4) var(--pw-space-5);
  background: var(--pw-surface);
  border: 1px solid var(--pw-border);
  border-radius: var(--pw-radius-lg);
  padding: var(--pw-space-6) var(--pw-space-6);
  max-width: 960px;
}
.pw-form-grid label.wide,
.pw-form-grid__wide {
  grid-column: 1 / -1;
}

/* ─── .pw-prose — long-form text container ────────────────────── */
.pw-prose {
  max-width: var(--pw-prose-measure);
  line-height: var(--pw-prose-leading);
  font-size: var(--pw-text-base);
  color: var(--pw-text);
}
.pw-prose p {
  margin: 0 0 var(--pw-space-3) 0;
}
.pw-prose--editorial::first-letter {
  font: var(--pw-font-display-italic);
  font-size: var(--pw-dropcap-size);
  float: left;
  line-height: 0.85;
  margin: 0.05em var(--pw-space-3) 0 0;
  color: var(--pw-primary);
}

/* ─── .pw-heading--display — editorial italic title ───────────── */
.pw-heading--display {
  font: var(--pw-font-display-italic);
  font-size: var(--pw-text-2xl);
  color: var(--pw-text);
  margin: 0 0 var(--pw-space-3) 0;
  letter-spacing: -0.005em;
}
.pw-heading--display-xl {
  font: var(--pw-font-display-italic);
  font-size: 64px;
  line-height: 1.05;
  color: var(--pw-text);
  letter-spacing: -0.01em;
}

/* ─── .pw-byline — small-caps magazine metadata strip ─────────── */
.pw-byline {
  font-family: var(--pw-font-ui);
  font-size: var(--pw-byline-size);
  text-transform: uppercase;
  letter-spacing: var(--pw-byline-letter-spacing);
  color: var(--pw-text-muted);
  display: flex;
  gap: var(--pw-space-3);
  flex-wrap: wrap;
  align-items: center;
  border-top: 1px solid var(--pw-border);
  border-bottom: 1px solid var(--pw-border);
  padding: var(--pw-space-2) 0;
  margin: var(--pw-space-3) 0 var(--pw-space-5) 0;
}
.pw-byline > * + *::before {
  content: "·";
  margin-right: var(--pw-space-3);
  color: var(--pw-text-faint);
}

/* ─── .pw-rule — hairline section break ───────────────────────── */
.pw-rule {
  border: 0;
  border-top: var(--pw-rule);
  margin: var(--pw-space-6) 0;
}

/* ─── .pw-bar-chart — theme-aware sparkline (replaces .bar-chart) */
.pw-bar-chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: var(--pw-space-2);
  background: var(--pw-surface);
  border: 1px solid var(--pw-border);
  border-radius: var(--pw-radius-lg);
  padding: var(--pw-space-4);
  align-items: end;
  min-height: 140px;
}
.pw-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--pw-space-1);
}
.pw-bar-fill {
  width: 100%;
  background: var(--pw-primary);
  border-radius: var(--pw-radius-sm) var(--pw-radius-sm) 0 0;
  min-height: 2px;
  transition: height var(--pw-duration-base) var(--pw-easing-out);
}
.pw-bar-label {
  font-size: var(--pw-text-xs);
  color: var(--pw-text-muted);
  font-variant-numeric: tabular-nums;
}

/* ─── .pw-agent-banner — QA active-agent banner ───────────────── */
.pw-agent-banner {
  background: var(--pw-agent-color, var(--pw-primary));
  color: #fff;
  padding: var(--pw-space-4) var(--pw-space-5);
  border-bottom: 1px solid rgba(0, 0, 0, 0.18);
}
.pw-agent-banner__inner {
  display: flex;
  align-items: center;
  gap: var(--pw-space-4);
  max-width: 1280px;
  margin: 0 auto;
}
.pw-agent-banner__label {
  font-size: var(--pw-text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.85;
}
.pw-agent-banner__name {
  display: inline-flex;
  align-items: center;
  gap: var(--pw-space-3);
  color: inherit;
  text-decoration: none;
  font-size: var(--pw-text-md);
  font-weight: 500;
}
.pw-agent-banner__initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 2px solid rgba(255, 255, 255, 0.5);
  font-weight: 700;
  font-size: var(--pw-text-md);
}

/* ─── .pw-mode-switcher — Admin/Station/QA strip ──────────────── */
.pw-mode-switcher {
  display: flex;
  gap: var(--pw-space-1);
  padding: calc(var(--pw-space-2) + env(safe-area-inset-top, 0px))
           var(--pw-space-3) var(--pw-space-2) var(--pw-space-3);
  background: var(--pw-ink);
  border-bottom: 1px solid var(--pw-paper-800);
  font-size: var(--pw-text-sm);
}
.pw-mode-switcher__link {
  padding: var(--pw-space-2) var(--pw-space-3);
  color: var(--pw-paper-50);
  text-decoration: none;
  border-radius: var(--pw-radius-sm);
  font-weight: 500;
  transition: background var(--pw-duration-fast) var(--pw-easing-out);
}
.pw-mode-switcher__link:hover {
  background: var(--pw-paper-800);
}
.pw-mode-switcher__link.is-active {
  background: var(--pw-paper-800);
  font-weight: 600;
}

/* ─── .pw-login-surfaces — sign-in page surface chooser ──────── */
.pw-login-surfaces {
  display: flex;
  flex-wrap: wrap;
  gap: var(--pw-space-2);
  margin: 0 0 var(--pw-space-4);
  padding: 0;
  list-style: none;
  /* style.css has a bare `nav { height: 48px }` rule for the admin top bar.
     Override it here so the surface chooser can grow to contain its wrapped chips. */
  height: auto;
}
.pw-login-surface {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: var(--pw-touch-lg);
  padding: var(--pw-space-2) var(--pw-space-4);
  border: 1px solid var(--pw-border-strong);
  border-radius: var(--pw-radius-md);
  font-family: var(--pw-font-ui);
  font-size: var(--pw-text-base);
  font-weight: 500;
  text-decoration: none;
  color: var(--pw-text);
  background: var(--pw-surface);
  transition: background-color var(--pw-duration-fast) var(--pw-easing-out),
              border-color var(--pw-duration-fast) var(--pw-easing-out);
}
.pw-login-surface:hover {
  background: var(--pw-surface-2);
  border-color: var(--pw-primary);
}
.pw-login-surface:focus-visible {
  outline: none;
  box-shadow: var(--pw-focus-ring);
}
.pw-login-surface--current {
  background: var(--pw-primary);
  color: var(--pw-primary-on);
  border-color: var(--pw-primary);
  cursor: default;
}
.pw-login-surface--current:hover {
  background: var(--pw-primary);
  border-color: var(--pw-primary);
}
.pw-login-surface__hint {
  font-size: var(--pw-text-xs);
  font-weight: 400;
  opacity: 0.75;
}
/* Dark mode: --pw-primary flips to blue-300 (light) with --pw-primary-on = ink-dark.
   At 0.75 opacity the dark ink on medium blue = 3.73:1 → fails AA for 11px text.
   Bump to 0.9 so the effective contrast clears 4.5:1. */
:root[data-theme="dark"] .pw-login-surface--current .pw-login-surface__hint { opacity: 0.9; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .pw-login-surface--current .pw-login-surface__hint { opacity: 0.9; }
}

/* ─── .pw-attention — top-of-page alert banner ────────────────── */
.pw-attention {
  display: flex;
  align-items: center;
  gap: var(--pw-space-3);
  background: var(--pw-warn-300);
  color: var(--pw-ink);
  padding: var(--pw-space-3) var(--pw-space-5);
  border-radius: var(--pw-radius-md);
  margin: var(--pw-space-3) 0;
  border: 1px solid var(--pw-warn-500);
}
.pw-attention--danger {
  /* v2.51.21 — was bad-300 (light red-orange) with ink text — read
     at 4.45:1, just below AA. Bumped to bad-500 with white text
     for ~6:1 in both themes. */
  background: var(--pw-bad-500);
  border-color: var(--pw-bad-500);
  color: #fff;
}
.pw-attention--danger a { color: #fff; }
.pw-attention--info {
  background: var(--pw-primary-soft);
  color: var(--pw-text);
  border-color: var(--pw-primary);
}

/* ─── .pw-verify-banner — pre-deploy gate status ──────────────── */
.pw-verify-banner {
  display: flex;
  align-items: center;
  gap: var(--pw-space-3);
  flex-wrap: wrap;
  padding: var(--pw-space-3) var(--pw-space-4);
  border-radius: var(--pw-radius-md);
  border: 1px solid var(--pw-border);
  margin: var(--pw-space-3) 0;
  font-size: var(--pw-text-sm);
}
.pw-verify-banner--passed {
  background: color-mix(in srgb, var(--pw-success) 12%, var(--pw-surface));
  border-color: var(--pw-success);
  color: var(--pw-success);
}
.pw-verify-banner--failed {
  background: color-mix(in srgb, var(--pw-danger) 12%, var(--pw-surface));
  border-color: var(--pw-danger);
  color: var(--pw-danger);
}
.pw-verify-banner--unknown {
  background: color-mix(in srgb, var(--pw-warning) 12%, var(--pw-surface));
  border-color: var(--pw-warning);
  color: var(--pw-warning);
}
.pw-verify-step {
  display: inline-block;
  padding: 2px var(--pw-space-2);
  border-radius: var(--pw-radius-sm);
  font-size: var(--pw-text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pw-verify-step--pass {
  background: color-mix(in srgb, var(--pw-success) 20%, transparent);
  color: var(--pw-success);
}
.pw-verify-step--fail {
  background: color-mix(in srgb, var(--pw-danger) 20%, transparent);
  color: var(--pw-danger);
}

/* ─── .pw-changelog — release notes list ──────────────────────── */
.pw-changelog {
  display: flex;
  flex-direction: column;
  gap: var(--pw-space-5);
  max-width: 800px;
}
.pw-changelog__entry {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--pw-space-2) var(--pw-space-5);
  align-items: baseline;
  padding-bottom: var(--pw-space-4);
  border-bottom: 1px solid var(--pw-border);
}
.pw-changelog__ver {
  font-family: var(--pw-font-mono);
  font-size: var(--pw-text-sm);
  color: var(--pw-primary);
  font-weight: 500;
  white-space: nowrap;
}
.pw-changelog__date {
  font-size: var(--pw-text-xs);
  color: var(--pw-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.pw-changelog__desc {
  font-size: var(--pw-text-md);
  font-weight: 500;
  color: var(--pw-text);
  grid-column: 2;
}
.pw-changelog__body {
  font-size: var(--pw-text-sm);
  color: var(--pw-text-muted);
  line-height: var(--pw-line-base);
  grid-column: 2;
}

/* ═══════════════════════════════════════════════════════════════════
   v2.51.19 — Editorial page primitives (.pw-page-*)
   ──────────────────────────────────────────────────────────────────
   Reusable building blocks for the remaining legacy admin pages.
   Lets a template wrap its content with a consistent editorial
   headline + section dividers without inlining 300 lines of CSS
   per page. Uses the same tokens (--pw-text, --pw-border, etc.) so
   everything theme-flips cleanly in both light + dark.

   Pattern (any page):
     <div class="pw-page">
       <section class="pw-page-head">
         <div class="pw-page-kicker"><span>Section · subtitle</span></div>
         <h1 class="pw-page-title">Page Name</h1>
         <div class="pw-page-byline">
           <span><strong>N</strong> items</span> ...
         </div>
       </section>
       ... existing content ...
     </div>
   ═════════════════════════════════════════════════════════════════ */

.pw-page {
  margin: -1.5em -2em 0;
  position: relative;
}
.pw-page::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  pointer-events: none; opacity: 0.03; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.6' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.9'/></svg>");
}
:root[data-theme="dark"] .pw-page::before { opacity: 0.05; mix-blend-mode: screen; }
.pw-page > * { position: relative; z-index: 1; }

.pw-page-head {
  padding: 32px 32px 22px;
  border-bottom: 1px solid var(--pw-border);
}
.pw-page-kicker {
  font-family: var(--pw-font-cond, var(--pw-font-ui));
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.36em; text-transform: uppercase;
  color: var(--pw-text-muted);
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 10px;
}
.pw-page-kicker::after {
  content: ""; flex: 1; height: 1px; background: var(--pw-border);
}
/* v2.51.21 — kicker colors use semantic state tokens so they
   auto-flip to the lighter variants in dark mode (good-500 etc.
   stay dark and become low-contrast on the ink background). */
.pw-page-kicker--good   { color: var(--pw-success); }
.pw-page-kicker--warn   { color: var(--pw-warning); }
.pw-page-kicker--danger { color: var(--pw-danger); }

.pw-page-title {
  font-family: var(--pw-font-display);
  font-style: italic; font-weight: 500;
  font-size: clamp(44px, 7vw, 80px);
  line-height: 0.92; letter-spacing: -0.02em;
  color: var(--pw-text);
  margin: 0; display: inline-block; position: relative;
}
.pw-page-title::after {
  content: ""; position: absolute; left: 0.04em; right: 0.04em;
  bottom: 0.06em; height: 5px;
  background: var(--pw-primary); opacity: 0.85;
}
.pw-page-title--good::after   { background: var(--pw-success); }
.pw-page-title--warn::after   { background: var(--pw-warning); }
.pw-page-title--danger::after { background: var(--pw-danger); }

.pw-page-intro {
  font-family: var(--pw-font-display);
  font-style: italic;
  font-size: 16px; line-height: 1.5;
  color: var(--pw-text-muted);
  max-width: 70ch;
  margin: 14px 0 0;
}
.pw-page-intro code, .pw-page-intro strong {
  font-family: var(--pw-font-mono);
  font-size: 13px; font-style: normal;
  background: color-mix(in srgb, var(--pw-text) 6%, transparent);
  padding: 1px 6px; border-radius: 2px;
  color: var(--pw-text); font-weight: 500;
}
.pw-page-intro a { color: var(--pw-primary); }

.pw-page-byline {
  display: flex; gap: 22px; align-items: baseline; flex-wrap: wrap;
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid var(--pw-border);
  font-family: var(--pw-font-cond, var(--pw-font-ui));
  font-size: 12px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--pw-text-muted);
}
.pw-page-byline strong { color: var(--pw-text); font-weight: 700; }
.pw-page-byline a { color: var(--pw-primary); text-decoration: none; }
.pw-page-byline a:hover { text-decoration: underline; }

.pw-page-section-h {
  margin: 32px 32px 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--pw-text);
  font-family: var(--pw-font-cond, var(--pw-font-ui));
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.36em; text-transform: uppercase;
  color: var(--pw-text-muted);
  display: flex; align-items: center; gap: 12px;
}
:root[data-theme="dark"] .pw-page-section-h { border-bottom-color: var(--pw-text); }
.pw-page-section-h .num {
  font-family: var(--pw-font-display);
  font-style: italic; font-size: 22px; font-weight: 500;
  color: var(--pw-text); letter-spacing: 0.02em;
  text-transform: none;
}

.pw-page-toolbar {
  margin: 18px 32px 0;
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center;
}

.pw-page-body {
  margin: 18px 32px 32px;
}

.pw-page-empty {
  margin: 18px 32px 0;
  padding: 28px;
  font-family: var(--pw-font-display);
  font-style: italic; font-size: 18px;
  color: var(--pw-text-muted);
  text-align: center;
  border: 1px dashed var(--pw-border);
}

@media (max-width: 800px) {
  .pw-page-head { padding: 24px 18px 18px; }
  .pw-page-title { font-size: 38px; }
  .pw-page-section-h, .pw-page-toolbar, .pw-page-body, .pw-page-empty {
    margin-left: 18px; margin-right: 18px;
  }
}

@keyframes pwPageRise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.pw-page-head, .pw-page-section-h, .pw-page-toolbar, .pw-page-body {
  /* fill-mode BACKWARDS, never `both`. A filled transform animation makes
     the element a containing block for fixed-position descendants FOREVER,
     even once it settles on `transform: none` (Chrome reports the identity
     matrix). That trapped the crop overlay inside .pw-pjd on 2026-09-12:
     overlay top=104 h=313 instead of covering the viewport, and its ✕ /
     Cancel / submit bar scrolled away with a 12,545px sheet instead of
     staying pinned, so Eric could not close it. `backwards` keeps the
     pre-delay state (what the stagger needs) and drops the post-end fill,
     whose values are identical to the element's own anyway. */
  animation: pwPageRise 380ms cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}
@media (prefers-reduced-motion: reduce) {
  .pw-page-head, .pw-page-section-h, .pw-page-toolbar, .pw-page-body { animation: none; }
}

/* v2.51.40 — Loading indicators for slow image loads.
   `.pw-image-loader` wraps an <img>; the spinner sits absolutely on
   top of the image area and is hidden via a `data-loaded="1"`
   attribute set in JS once the inner image's `load` event fires. */
.pw-image-loader {
  position: relative;
  display: inline-block;
  max-width: 100%;
}
.pw-image-loader::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 56px; height: 56px;
  margin: -28px 0 0 -28px;
  border: 4px solid var(--pw-border);
  border-top-color: var(--pw-primary, #1B3A6F);
  border-radius: 50%;
  animation: pwSpin 900ms linear infinite;
  pointer-events: none;
  z-index: 2;
}
.pw-image-loader[data-loaded="1"]::after {
  display: none;
}
.pw-image-loader[data-loaded="error"]::after {
  display: none;
}
.pw-image-loader__msg {
  display: none;
  position: absolute; inset: 0;
  align-items: center; justify-content: center;
  font-family: var(--pw-font-ui, system-ui, sans-serif);
  color: var(--pw-text-muted);
  background: var(--pw-surface);
  text-align: center; padding: 16px;
  z-index: 1;
}
.pw-image-loader[data-loaded="error"] .pw-image-loader__msg {
  display: flex;
}

/* Standalone spinner (for the lightbox + anywhere else without an
   image to attach to). Same animation; JS controls visibility. */
.pw-spinner {
  display: inline-block;
  width: 56px; height: 56px;
  border: 4px solid rgba(255,255,255,0.25);
  border-top-color: rgba(255,255,255,0.95);
  border-radius: 50%;
  animation: pwSpin 900ms linear infinite;
}
.pw-spinner--dark {
  border: 4px solid var(--pw-border);
  border-top-color: var(--pw-primary, #1B3A6F);
}

@keyframes pwSpin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .pw-image-loader::after, .pw-spinner { animation: none; }
}

/* v2.51.51 — Gap L7 fix. Emoji glyphs (🖨 ✂ 📦 etc.) fell back
   to whatever the local UI font happened to ship, producing
   inconsistent renders across viewports + themes (especially in
   dark mode where some fonts shipped monochrome outlines).
   This selector force-routes any inline-emoji span to the
   system emoji fonts in cascade order. Use `class="emoji"`
   anywhere a glyph is the only/primary content. Inline emoji in
   text runs (not in a span) still inherit and may render
   inconsistently — by design, since wrapping every emoji is
   noisy. */
.emoji, [data-emoji] {
  font-family: "Apple Color Emoji", "Segoe UI Emoji",
               "Noto Color Emoji", "Segoe UI Symbol", sans-serif;
  font-variant-emoji: emoji;
}

/* Lightbox loader — used by lightbox.js. The overlay JS sets
   `data-loading="1"` on the frame while the inner img is still
   loading; we render the spinner centered on the dark stage. */
.pw-lightbox-frame[data-loading="1"]::before {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 72px; height: 72px;
  margin: -36px 0 0 -36px;
  border: 5px solid rgba(255,255,255,0.25);
  border-top-color: rgba(255,255,255,0.95);
  border-radius: 50%;
  animation: pwSpin 900ms linear infinite;
  z-index: 10;
  pointer-events: none;
}

/* ═════ v2.59.28 — A11Y systemic touch/zoom fixes ═════
   F-009 (16px form-control minimum to stop iOS zoom-on-focus)
   F-012 (admin nav link 44px tap target)
   Applied globally; component CSS still wins where it overrides. */

input,
select,
textarea {
  /* iOS Safari zooms when an input < 16px gets focus. min-font sets
     a floor without overriding deliberate per-component sizes that
     are already >= 16px. */
  font-size: max(16px, 1em);
}

/* Override for the always-visible refresh chip in base.html: it's
   read-only display, never typed into, so the iOS rule doesn't
   apply. Keep it compact. */
.refresh-picker select {
  font-size: 13px;
}

/* Admin top nav + mega-menu links: ensure 44px tap height. */
.nav-bar > a,
.nav-bar > details > summary,
.nav-dropdown-menu a {
  min-height: var(--pw-touch-md, 44px);
  display: flex;
  align-items: center;
}

/* ═════ v2.59.46 — Header IA responsive ═════
   On viewports < 1100px (iPad portrait, large phones) the search
   wraps to its own row instead of competing with the dropdowns
   for horizontal space. */
@media (max-width: 1100px) {
  nav {
    flex-wrap: wrap;
    row-gap: 8px;
  }
  .pw-nav-search {
    flex: 1 1 100% !important;
    order: 99;  /* pushed to the end / next row */
  }
}
@media (max-width: 720px) {
  /* On phones, collapse the dropdowns by hiding their content
     until the user expands them via tap. The default <details>
     open/close behavior handles that automatically; we just need
     to make sure each dropdown is its own block so they stack. */
  nav > details.nav-dropdown {
    flex: 1 1 100%;
  }
  nav > a {
    flex: 0 0 auto;
  }
}

/* ═════ v2.59.59 — Mobile hamburger nav ═════
   On narrow viewports collapse every nav child except the brand +
   the hamburger button into a hidden block; reveal as a vertical
   menu when the hamburger toggles `.pw-nav--open` on the nav. */
.pw-nav-hamburger {
  display: none;  /* desktop: hidden */
  background: transparent;
  border: 1px solid var(--pw-border);
  border-radius: 6px;
  width: 44px; height: 44px;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
}
.pw-nav-hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: var(--pw-text);
  margin: 5px auto;
  transition: transform .2s, opacity .2s;
}
.pw-nav--open .pw-nav-hamburger span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.pw-nav--open .pw-nav-hamburger span:nth-child(2) { opacity: 0; }
.pw-nav--open .pw-nav-hamburger span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 900px) {
  .pw-nav-hamburger { display: inline-block; }
  /* Hide every direct child of nav except the brand + hamburger by
     default; reveal when nav is open. */
  .pw-nav > *:not(.brand):not(.pw-nav-hamburger) {
    display: none !important;
  }
  .pw-nav--open {
    flex-direction: column;
    align-items: stretch;
  }
  .pw-nav--open > *:not(.brand):not(.pw-nav-hamburger) {
    display: flex !important;
    width: 100%;
    margin: 2px 0;
  }
  /* Search input takes its own row, full width. */
  .pw-nav--open .pw-nav-search {
    flex: 1 1 100% !important;
    margin: 4px 0;
  }
  /* Dropdowns inside the open nav lay flat; their menu cards stack
     beneath the summary instead of floating. */
  .pw-nav--open details.nav-dropdown {
    margin: 0;
  }
  .pw-nav--open details.nav-dropdown[open] .nav-dropdown-menu {
    position: static !important;
    box-shadow: none;
    border-radius: 0;
    border-top: none;
  }
  /* v2.60.5 — Global search must ALWAYS be reachable on mobile. The
     v2.59.88 nav rebuild rewired the hamburger to open the leftrail
     DRAWER (data-pw-leftrail-toggle) instead of setting .pw-nav--open,
     so the old reveal-on-open never fired and the search was
     permanently hidden on phones (Eric: "no search functions on
     mobile"). Pin it visible as its own full-width row in the masthead,
     overriding the blanket `display:none` above. The double-class
     selector ties the hide rule's specificity and wins by source order. */
  .pw-nav .global-search.pw-nav-search {
    display: block !important;
    flex: 1 1 100% !important;
    order: 99;
    margin: 6px 0 2px;
  }
}

/* ═════ v2.55.31 — Mobile touch-target tuning ═════
   Eric reviews the admin dashboard from his iPhone on the shop
   floor. The editorial layout (per-page CSS in dashboard.html
   etc.) handles its own density at ≤640px; this block makes
   sure the SHARED chrome — attention banners, verify banner,
   stat tiles — also reaches the 44px touch target + readable
   body type on phones. Only ADDS rules; nothing here overrides
   existing desktop behavior since it's gated to ≤640px. */
@media (max-width: 640px) {
  /* Top-of-page alerts — bigger tap area, more breathing room. */
  .pw-attention {
    padding: 14px 16px;
    font-size: 14px;
    line-height: 1.4;
    min-height: 44px;
    display: flex;
    align-items: center;
    border-radius: 4px;
  }
  .pw-verify-banner {
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.4;
  }
  .pw-verify-banner strong { display: block; margin-bottom: 4px; }
  .pw-verify-step {
    display: inline-block;
    margin: 2px 4px 2px 0;
    font-size: 11px;
  }

  /* Stat tiles in the colophon (Cost & usage) — stack 1-up on
     phone instead of cramming 4 per row. */
  .pw-stats {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .pw-stats__item { padding: 12px 14px; }
  .pw-stats__label { font-size: 11px; }
  .pw-stats__value { font-size: 20px; }

  /* All anchor-style links inside .pw-dash get a comfy hit area
     so a thumb doesn't miss between paragraph lines. */
  .pw-dash a { padding: 2px 0; }
}

/* ═════ v2.59.62 — Mobile-first PWA polish: operator + QA + print-jobs + impersonate ═════
   Eric uses the operator station + QA pages from his phone in
   the shop. Janice uses QA from a tablet. These surfaces were
   designed kiosk-first but never tuned for <500px viewports.
   This block ONLY adds rules below 640px; existing desktop
   layouts are untouched.

   Touch-target rules (load-bearing):
     - Operator action buttons (Grab Next, Submit, Pause, Resume): ≥60px h × ≥140px w
     - QA verdict buttons (PASS/FAIL/MISSING/CROP): ≥60px h
     - Bulk select checkbox: ≥44px
     - Form fields: ≥16px font, ≥44px h (covered globally by F-009)

   Aesthetic: operator + QA are FUNCTIONAL kiosk surfaces, not
   editorial magazines. Below 640px we lean into bold, high-
   contrast, minimal-chrome density. Editorial type stays
   readable but type-scale shrinks; numerals and verbs stay
   loud. */
@media (max-width: 640px) {

  /* ─── OPERATOR STATION ────────────────────────────────────── */
  /* Tighten page padding so every inch counts; the station gets
     opened on operators' personal phones, not just tablets. */
  .pw-op-header { padding: 18px 16px 14px; }
  .pw-op-header__top {
    grid-template-columns: 1fr;
    gap: 12px; align-items: flex-start;
  }
  .pw-op-printer { font-size: clamp(44px, 11vw, 64px); }
  .pw-op-category { font-size: 0.16em; padding: 2px 7px; }
  .pw-op-header__controls { flex-wrap: wrap; }

  /* Section headers tighter on mobile so they don't crowd content. */
  .pw-op-section-h { padding-left: 16px; padding-right: 16px; }

  /* Stat strip — 2 per row instead of 4. */
  .pw-op-stats {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding-left: 16px; padding-right: 16px;
  }
  .pw-op-stat__num { font-size: 28px; }
  .pw-op-stat__label { font-size: 10px; }

  /* Master queue strip — 1 card per row, full bleed. */
  .pw-op-master-queues { padding-left: 12px !important; padding-right: 12px !important; }
  .pw-op-mq-strip { gap: 10px !important; }
  .pw-op-mq-card {
    flex: 1 1 100% !important;
    min-width: 0 !important;
    padding: 16px !important;
  }
  /* Grab Next CTA — biggest, loudest thing on the page. */
  .pw-op-mq-card form button[type="submit"] {
    min-height: 72px !important;
    font-size: 20px !important;
    font-weight: 700 !important;
    letter-spacing: 0.02em;
  }
  /* Mode picker (Auto/Manual/Pause/Disabled) — 2x2 grid not 1x4 cram. */
  .pw-op-mq-modes { gap: 6px !important; }
  .pw-op-mq-modes form {
    flex: 1 1 calc(50% - 3px) !important;
    min-width: 0 !important;
  }
  .pw-op-mq-modes button {
    min-height: 52px !important;
    font-size: 14px !important;
  }

  /* Grab toolbar (1/2/3/5/10) — 60px+ kiosk minimum, 140px wide
     so glove-on-phone hits the right number. Wrap to 2 cols. */
  .pw-op-grab { padding: 4px 16px 14px; }
  .pw-op-grab-buttons { gap: 8px; }
  .pw-op-grab-buttons form {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }
  .pw-op-grab-buttons button {
    width: 100%;
    min-width: 140px;
    min-height: 64px;
    font-size: 18px;
    font-weight: 700;
    padding: 10px 14px;
  }

  /* Supplies grid stacks 1-up on phones (large taps for "I just
     opened a box of media" events). */
  .pw-op-supplies {
    grid-template-columns: 1fr !important;
    padding: 0 16px !important;
    gap: 10px;
  }
  .pw-op-supply { min-height: 64px; padding: 12px 14px; }
  .pw-op-supply__title { font-size: 17px; }
  .pw-op-supply__sub { font-size: 12px; }

  /* Jobs table — already has overflow-x:auto; just slim its
     padding so the side-scroll has more horizontal room. */
  .pw-op-jobs-wrap { padding: 12px 8px 18px; }
  .pw-op-jobs td, .pw-op-jobs th { padding: 10px 8px; font-size: 13px; }

  /* Test-pages strip — bigger cards on phone (gloved finger). */
  .pw-op-test-pages { padding: 4px 16px 18px; }
  .pw-op-test-page button { width: 160px; min-height: 60px; }

  /* Recent-activity wire feed — tighter padding, larger names. */
  .pw-op-wire { padding-left: 16px; padding-right: 16px; }
  .pw-op-wire__row { gap: 8px; padding: 10px 0; }

  /* ─── OPERATOR — OTHER PAGES ─────────────────────────────── */
  /* operator_job_detail.html line cards — stack image above text
     instead of side-by-side at 200px wide which steals everything. */
  body.operator-body .pw-card {
    flex-direction: column !important;
    gap: 12px !important;
  }
  body.operator-body .pw-card > div:first-child {
    flex: 0 0 auto !important;
    width: 100% !important;
    max-width: 320px;
    margin: 0 auto;
  }
  body.operator-body .operator-header {
    padding: 12px 14px;
    font-size: 14px;
  }
  body.operator-body section.op-jobs {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  /* Operator pages: every primary action button gets the 60px kiosk
     touch height on phone. */
  body.operator-body .pw-btn--lg,
  body.operator-body .pw-btn--primary,
  body.operator-body .pw-btn--danger {
    min-height: 60px;
    font-size: 16px;
  }

  /* ─── QA BASE ─────────────────────────────────────────────── */
  /* Active-agent banner — keep it bold + tap-friendly on phone. */
  .qa-agent-banner { padding: 10px 14px; }
  .qa-agent-banner-inner {
    flex-wrap: wrap; gap: 10px;
    justify-content: space-between;
  }
  .qa-agent-banner-name {
    font-size: 18px;
    min-height: 44px;
    display: inline-flex; align-items: center;
  }
  .qa-agent-banner-signout { min-height: 44px; padding: 0 12px; }

  /* ─── QA ORDER PAGE — sheet cards + bulk select + sticky bar ── */
  /* Sheet grid — 1 column at <500, 2 columns up to 640. */
  .pw-qa-sheets {
    grid-template-columns: 1fr !important;
    padding: 12px !important;
    gap: 10px !important;
  }
  /* Matrix view (the printer × line grid) — let the matrix cells
     stay readable but shrink padding. */
  .pw-qa-matrix { padding: 12px !important; gap: 10px !important; }

  /* Bulk-select checkbox — 56px circle on phone (44 minimum, but
     QA sheets are dense and gloves get used). */
  .pw-qa-sheet__select {
    width: 56px !important;
    height: 56px !important;
    top: 8px !important;
    right: 8px !important;
    font-size: 26px !important;
    border-width: 3px !important;
  }
  .pw-qa-matrix .pw-qa-sheet__select {
    width: 48px !important;
    height: 48px !important;
    top: 6px !important;
    right: 6px !important;
    font-size: 22px !important;
  }

  /* Sticky bulk action bar — already responsive at 720px but
     buttons are still cramped on <400px. Stack vertically with
     full-width buttons. */
  .pw-qa-bulk {
    grid-template-columns: 1fr 1fr !important;
    padding: 10px 12px !important;
    gap: 8px !important;
  }
  .pw-qa-bulk__num { font-size: 32px; }
  .pw-qa-bulk__btn {
    min-height: 60px !important;
    padding: 0 8px !important;
    font-size: 13px !important;
  }
  .pw-qa-bulk__btn--clear { grid-column: 1 / -1; }

  /* Notes form — stack input + submit; both 44px+ tall. */
  .pw-qa-notes { padding: 18px 14px !important; }
  .pw-qa-notes__form { flex-direction: column; gap: 10px; }
  .pw-qa-notes__form .pw-field { flex: 1 1 100%; }
  .pw-qa-notes__form button[type="submit"] {
    width: 100%;
    min-height: 48px;
  }

  /* QA back-bar + ribbon — tighter padding, ≥44px tap targets. */
  .pw-qa-back, .pw-qa-ribbon { padding: 10px 14px !important; min-height: 44px; }
  .pw-qa-head { padding: 18px 14px 14px !important; }
  .pw-qa-head__title { font-size: clamp(32px, 9vw, 48px) !important; }

  /* ─── QA SHEET DETAIL — full-bleed preview + huge verdicts ──── */
  /* Page chrome: drop padding to 12px so the artwork preview gets
     full bleed. */
  .pw-qad-back, .pw-qad-head, .pw-qad-flashes,
  .pw-qad-stage, .pw-qad-secondary, .pw-qad-panels,
  .pw-qad-picker, .pw-qad-footer {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  .pw-qad-picker { margin-left: 12px !important; margin-right: 12px !important; }
  .pw-qad-head__title { font-size: 32px !important; }

  /* Preview — let the image bleed edge to edge (no inner padding). */
  .pw-qad-preview { padding: 6px !important; }
  .pw-qad-preview__scroll { max-height: 60vh !important; }

  /* Verdict grid — 2x2 with HUGE buttons (≥72px h on phone so
     PASS/FAIL/MISSING is committed without misfires under stress). */
  .pw-qad-verdicts { gap: 10px !important; }
  .pw-qad-verdict {
    min-height: 80px !important;
    font-size: 22px !important;
    padding: 12px !important;
  }
  .pw-qad-verdict__glyph { font-size: 28px !important; }
  .pw-qad-verdict__hint { font-size: 11px !important; }
  .pw-qad-verdict--crop {
    min-height: 68px !important;
    font-size: 18px !important;
  }
  .pw-qad-verdict--label {
    min-height: 60px !important;
    font-size: 16px !important;
  }

  /* Crop overlay — make sure it fills iPhone Safari's actual
     viewport (the address bar eats 100vh in some states; use
     dvh fallback where supported). Keep close button reachable
     with thumb in the top-left corner. */
  .qa-crop-overlay {
    padding: 8px !important;
  }
  .qa-crop-overlay__inner {
    /* Use dynamic viewport units when available so the crop
       UI doesn't fight Safari's collapsing chrome. */
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
  }
  .qa-crop-overlay__close {
    width: 56px !important;
    height: 56px !important;
    top: 12px !important;
    right: 12px !important;
    font-size: 26px !important;
    /* Add a subtle ring so it stands out against busy crop preview. */
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    z-index: 10;
  }
  /* Crop handles — bigger drag tabs for fingertip dragging. */
  .qa-crop-overlay .crop-handle-tab {
    min-width: 44px;
    min-height: 44px;
  }

  /* ─── QA INDEX — landing tiles ───────────────────────────── */
  .pw-qi-head { padding: 18px 14px 14px !important; }
  .pw-qi-head__title { font-size: clamp(36px, 10vw, 56px) !important; }
  .pw-qi-lookup {
    margin: 14px 14px 0 !important;
    padding: 14px !important;
  }
  .pw-qi-lookup input[type="search"],
  .pw-qi-lookup input[type="text"] {
    min-height: 48px;
    font-size: 16px;
  }
  .pw-qi-cards {
    grid-template-columns: 1fr !important;
    padding: 14px !important;
    gap: 12px !important;
  }
  .pw-qi-card { min-height: 80px; padding: 16px !important; }
  .pw-qi-card__title { font-size: 20px !important; }
  .pw-qi-card__sub { font-size: 13px !important; }

  /* ─── PRINT-JOBS GRID — mobile sticky + reachable actions ──── */
  /* Tighter headline so the table gets more vertical space. */
  .pw-pj-head { padding: 18px 14px 14px !important; }
  .pw-pj-head__title { font-size: 38px !important; }
  .pw-pj-head__intro { font-size: 14px; line-height: 1.45; }
  .pw-pj-flashes, .pw-pj-actions, .pw-pj-tabs,
  .pw-pj-filter, .pw-pj-bulk, .pw-pj-empty {
    margin-left: 12px !important;
    margin-right: 12px !important;
  }
  /* Refresh / bulk action buttons — wrap, full-bleed, ≥44px. */
  .pw-pj-actions { gap: 8px !important; }
  .pw-pj-actions button[type="submit"],
  .pw-pj-actions a {
    flex: 1 1 calc(50% - 4px);
    min-height: 48px;
    font-size: 13px;
  }
  /* Tabs as tap-strip — keep horizontal but bigger taps. */
  .pw-pj-tabs { gap: 4px !important; overflow-x: auto; }
  .pw-pj-tabs a {
    min-height: 48px !important;
    padding: 10px 14px !important;
    font-size: 12px !important;
    white-space: nowrap;
  }
  /* Filter form fields — stack to 1-col so the printer + date
     pickers don't squeeze. */
  .pw-pj-filter form {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .pw-pj-filter form > * { width: 100%; }
  .pw-pj-filter select,
  .pw-pj-filter input {
    min-height: 44px;
    font-size: 16px;
  }
  /* Bulk toolbar — stack the bits so the dropdown + submit each
     get full width + ≥48px height. */
  .pw-pj-bulk {
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 10px !important;
    gap: 10px !important;
  }
  .pw-pj-bulk label.checkbox { min-height: 44px; }
  .pw-pj-bulk select {
    min-height: 48px !important;
    font-size: 16px !important;
    width: 100%;
  }
  .pw-pj-bulk button[type="submit"] {
    min-height: 52px !important;
    font-size: 14px !important;
    width: 100%;
  }
  /* Table wrap — give it the entire viewport width minus 4px
     side gutter so the sticky horizontal scroll is reachable
     under the thumb. */
  .pw-pj-table-wrap {
    margin: 12px 4px 18px !important;
    /* Keep header sticky but bound height so the X-scroll handle
       stays just above the on-screen keyboard / nav bar. */
    max-height: calc(100vh - 240px);
  }
  /* Row buttons (re-submit, refresh, send-to-fulfiller, ✂ crop)
     get a comfy ≥44px tap target even though the table itself
     is dense. */
  .pw-pj-table__btn,
  .pw-pj-table a.pw-btn,
  .pw-pj-table button {
    min-height: 44px;
    padding: 8px 12px;
    display: inline-flex;
    align-items: center;
  }
  /* Action cells often stack vertically — give them a touch
     more space so the buttons don't sit on top of each other. */
  .pw-pj-table td { padding: 10px 8px !important; font-size: 13px; }
  /* Make sure the row-checkbox is at least 22×22 (browsers shrink
     it under font-size shrinks). */
  .pw-pj-table input[type="checkbox"] {
    width: 22px !important;
    height: 22px !important;
  }

  /* ─── IMPERSONATE PAGE — tap-grid not table ─────────────── */
  /* Hide the table on mobile and present each station as a big
     tap-card. The form-submit POST routes are unchanged; we just
     restyle the table rows to look like a stacked grid. */
  .pw-page-body table.grid thead { display: none; }
  .pw-page-body table.grid,
  .pw-page-body table.grid tbody,
  .pw-page-body table.grid tr,
  .pw-page-body table.grid td {
    display: block;
    width: 100%;
  }
  .pw-page-body table.grid tr {
    background: var(--pw-surface);
    border: 1px solid var(--pw-border);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  }
  .pw-page-body table.grid td {
    padding: 4px 0;
    border: 0;
  }
  .pw-page-body table.grid td:first-child {
    font-family: var(--pw-font-mono, ui-monospace, monospace);
    font-size: 16px;
    font-weight: 700;
    color: var(--pw-text);
  }
  .pw-page-body table.grid td:nth-child(2) {
    font-size: 18px;
    color: var(--pw-text);
    padding-bottom: 6px;
  }
  .pw-page-body table.grid td:nth-child(3),
  .pw-page-body table.grid td:nth-child(4) {
    font-size: 13px;
    color: var(--pw-text-muted);
  }
  /* The Impersonate button gets full-width + 56px tap height. */
  .pw-page-body table.grid td:last-child {
    padding-top: 10px;
    border-top: 1px dashed var(--pw-border);
    margin-top: 8px;
  }
  .pw-page-body table.grid td:last-child form,
  .pw-page-body table.grid td:last-child button {
    width: 100%;
  }
  .pw-page-body table.grid td:last-child button {
    min-height: 56px;
    font-size: 16px;
    font-weight: 600;
  }
}

/* ═════ v2.59.62 — Narrow-phone breakpoint (<500px) ═════
   For the smallest phones (iPhone SE, narrow Androids) the
   operator screen needs even bolder reflow: Grab Next becomes
   1-up at full bleed; verdict grid stays 2-up because PASS/FAIL
   parity is critical for muscle memory. */
@media (max-width: 499px) {
  /* Operator Grab buttons — 1-up at full bleed. */
  .pw-op-grab-buttons form { flex: 1 1 100%; }
  .pw-op-grab-buttons button {
    min-height: 60px;
    font-size: 17px;
  }
  /* QA sheet cards already 1-up at <640; tighten further. */
  .pw-qa-sheets { padding: 8px !important; }
  /* QA bulk bar — single column on tiny phones except the
     PASS/FAIL/MISSING trio which stays a row of three. */
  .pw-qa-bulk { grid-template-columns: 1fr 1fr 1fr !important; }
  .pw-qa-bulk__count,
  .pw-qa-bulk__hint,
  .pw-qa-bulk__btn--clear { grid-column: 1 / -1 !important; }
  /* Verdict glyph + hint scale down so 2 buttons fit per row
     without overflow. */
  .pw-qad-verdict { font-size: 18px !important; min-height: 72px !important; }
  .pw-qad-verdict__glyph { font-size: 22px !important; }
  /* Print-jobs row buttons stack vertically in the action cell. */
  .pw-pj-table__btn { display: block; width: 100%; margin: 4px 0; }
  /* Master queue mode picker drops to 1-col on tiny phones so
     each Auto/Manual/Pause/Disabled gets full width. */
  .pw-op-mq-modes form { flex: 1 1 100% !important; }
}

/* ═════ v2.59.65 — Customer linkification (Eric: "every customer
   name links back to the CRM"). Subtle but unmistakable: name reads
   as text but the hairline underline signals it's a click target;
   on hover the underline + the text pop in the accent color. Used
   anywhere we display a customer's name with a known customer_id. ═════ */
.pw-customer-link {
  color: var(--pw-text);
  text-decoration: underline;
  text-decoration-color: var(--pw-text-muted, var(--pw-muted, #9aa));
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: text-decoration-color .15s, color .15s;
}
.pw-customer-link:hover,
.pw-customer-link:focus-visible {
  text-decoration-color: var(--pw-primary, var(--pw-accent, #1B3A6F));
  color: var(--pw-primary, var(--pw-accent, #1B3A6F));
  outline: none;
}
.pw-customer-link strong,
.pw-customer-link span { color: inherit; }

/* Search-fallback affordance for rows where we have a name but no
   customer_id linked yet. Small dotted "+ Find in CRM" hint. */
.pw-customer-search {
  margin-left: 6px;
  font-size: 11px;
  color: var(--pw-text-muted, var(--pw-muted, #9aa));
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
  transition: color .15s, border-color .15s;
}
.pw-customer-search:hover,
.pw-customer-search:focus-visible {
  color: var(--pw-primary, var(--pw-accent, #1B3A6F));
  border-bottom-color: var(--pw-primary, var(--pw-accent, #1B3A6F));
  outline: none;
}

/* ═════ Customer card (job_detail.html) — prominent block at the
   top of the order page with name (linked), email, phone, follow-up
   + SR counts, difficulty chip, "Open full profile →" CTA. ═════ */
.pw-cust-card {
  max-width: 1280px;
  margin: 24px auto;
  padding: 24px 32px;
  border: 1px solid var(--pw-border, #D8D4C8);
  border-radius: 4px;
  background: var(--pw-surface, #fff);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px 24px;
  align-items: start;
}
.pw-cust-card__kicker {
  font-family: var(--pw-font-ui, 'IBM Plex Sans', system-ui, sans-serif);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--pw-text-muted, #4A4F5C);
  margin: 0 0 6px;
}
.pw-cust-card__name {
  font-family: 'EB Garamond', Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.04;
  margin: 0 0 12px;
  color: var(--pw-text, #0E1014);
}
.pw-cust-card__name a { color: inherit; }
.pw-cust-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  font-family: var(--pw-font-ui, 'IBM Plex Sans', system-ui, sans-serif);
  font-size: 13px;
  color: var(--pw-text-muted, #4A4F5C);
}
.pw-cust-card__meta a {
  color: var(--pw-text, #0E1014);
  text-decoration: underline;
  text-decoration-color: var(--pw-text-muted, #9aa);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.pw-cust-card__meta a:hover { color: var(--pw-primary, #1B3A6F); text-decoration-color: var(--pw-primary, #1B3A6F); }
.pw-cust-card__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.pw-cust-card__chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: color-mix(in srgb, var(--pw-text, #000) 6%, transparent);
  color: var(--pw-text, #0E1014);
  text-decoration: none;
}
.pw-cust-card__chip:hover { background: color-mix(in srgb, var(--pw-primary, #1B3A6F) 14%, transparent); color: var(--pw-primary, #1B3A6F); }
.pw-cust-card__chip--diff { background: color-mix(in srgb, var(--pw-warning, #8F6A11) 16%, transparent); color: var(--pw-warning, #8F6A11); }
.pw-cust-card__chip--diff.is-high { background: color-mix(in srgb, var(--pw-danger, #A8261A) 18%, transparent); color: var(--pw-danger, #A8261A); }
.pw-cust-card__cta {
  font-family: var(--pw-font-ui, 'IBM Plex Sans', system-ui, sans-serif);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--pw-primary, #1B3A6F);
  white-space: nowrap;
  align-self: end;
}
.pw-cust-card__cta:hover { text-decoration: underline; }
.pw-cust-card--empty {
  grid-template-columns: 1fr;
  background: color-mix(in srgb, var(--pw-text, #000) 3%, transparent);
}
.pw-cust-card--empty .pw-cust-card__name {
  font-size: 18px;
  font-style: normal;
  font-family: var(--pw-font-ui, 'IBM Plex Sans', system-ui, sans-serif);
  font-weight: 500;
  color: var(--pw-text-muted, #4A4F5C);
}
@media (max-width: 640px) {
  .pw-cust-card { grid-template-columns: 1fr; padding: 20px; }
  .pw-cust-card__cta { justify-self: start; }
}

/* ═════ v2.59.71 — Phone mobile sweep (≤640 / ≤499) ════════════════
   Eric audits PrintWizzard from a 375px iPhone. Surfaces shipped
   after the v2.59.61 mobile pass (Vendors, Fulfillers, Service
   Requests, Workflow Board, Companies billing, CRM single-page,
   Inbox/Comms config, Copilot, 3CX call, Customer profile,
   Stations) needed a sweep. All rules below are additive — desktop
   layout untouched. Tokens only, no hardcoded colors.
   ─────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  /* ── #1 Recent-orders / Jobs list table ──
     _jobs_table.html uses <table class="jobs">. style.css scrolls
     `.grid` + `.op-jobs` on mobile but NOT `.jobs` — 11 cols
     overflow at 375px. Add the same scroll affordance. */
  main table.jobs,
  .pw-page-body table.jobs {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  main table.jobs th,
  main table.jobs td { white-space: nowrap; }
  /* Wrap customer cell so long names break instead of stretching
     the table. */
  main table.jobs td:nth-child(5) { white-space: normal; min-width: 120px; }

  /* ── #2 Copilot chat layout ──
     copilot_chat.html has hardcoded `grid-template-columns:240px 1fr`
     inline; can't unscope it from CSS only. The wrapper has no class,
     but the conversations list aside + main are predictable children
     of `.pw-page-body > div[style*="grid-template-columns:240px"]`.
     Easier: select via the .pw-page-body's first div that has the
     copilot conv list inside. We provide a helper class the template
     opts into below (.pw-copilot-grid). */
  .pw-copilot-grid {
    grid-template-columns: 1fr !important;
    gap: var(--pw-space-3) !important;
  }
  .pw-copilot-grid > aside {
    order: 2;   /* push conversation list below the active thread */
    max-height: 40vh;
    overflow-y: auto;
  }
  .pw-copilot-grid > main { order: 1; }

  /* ── #3 Customer profile jumpnav ──
     At ≤900px the rail collapses to static, but that puts 12 anchor
     links above the content. On phones, collapse to a horizontally
     scrolling chip rail pinned to the top so the visitor can still
     skip to any section without scrolling 600px of nav. */
  .crm-jumpnav {
    position: sticky !important;
    top: 0;
    flex-direction: row !important;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none !important;
    padding: 6px 4px !important;
    gap: 4px !important;
    background: var(--pw-bg);
    z-index: 5;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px 8px;
    border-radius: 0;
  }
  .crm-jumpnav a {
    white-space: nowrap;
    border-left: 0 !important;
    border-bottom: 2px solid transparent;
    min-height: 40px;
    padding: 8px 12px !important;
    flex: 0 0 auto;
  }
  .crm-jumpnav a.active {
    border-bottom-color: var(--pw-primary, var(--pw-accent));
    background: color-mix(in srgb, var(--pw-primary, var(--pw-accent)) 10%, transparent) !important;
  }
  .crm-jumpnav .count {
    background: color-mix(in srgb, var(--pw-text) 10%, transparent);
  }

  /* ── #5 Workflow board move buttons ──
     <44px tap target on the per-card move buttons; mobile is exactly
     where Eric uses the board. Bump to 44px + larger font; the card
     stays compact because move buttons wrap. */
  .pw-board-card__move button {
    min-height: 44px !important;
    font-size: 13px !important;
    padding: 8px 12px !important;
    flex: 1 1 auto;
  }

  /* ── #8 SR detail reminder action buttons ──
     "Mark done" / "Cancel" / "Revoke" are 34-36px in the source. */
  .pw-page-body section .pw-btn[style*="min-height:34px"],
  .pw-page-body section .pw-btn[style*="min-height:36px"] {
    min-height: 44px !important;
  }

  /* ── #7 Customer card chips ──
     Chip row wraps OK already; just give each chip a 32px min target
     when it's a real link (chip CTAs vs informational badges). */
  .pw-cust-card__chip[href] {
    min-height: 36px;
    padding: 6px 12px;
    display: inline-flex;
    align-items: center;
  }

  /* ── #6 Wide data tables that use .grid: cell-side padding pinch
        so 6-8 col tables waste less horizontal pixels when scrolled.  */
  main table.grid th,
  main table.grid td { padding: 6px 8px; }

  /* Customer profile <details> sections — tighten padding so content
     gets more room. */
  .crm-sec { padding: 0.8em 0.9em !important; }
  .crm-sec h2 { font-size: 17px !important; }

  /* Customer profile call-form: was a flex row at desktop; force the
     four inputs to stack instead of squeezing to 160px min-widths. */
  details#calls form[action="/admin/cx3/place-call"] > div {
    flex-direction: column;
    align-items: stretch !important;
  }
  details#calls form[action="/admin/cx3/place-call"] > div label {
    flex: 1 1 100% !important;
    min-width: 0 !important;
  }

  /* customer_profile match-flag checkboxes — make tap target the
     entire label, not just the checkbox. */
  .crm-sec form label.checkbox {
    border-radius: 6px;
    padding: 4px 6px;
  }
  .crm-sec form label.checkbox:active {
    background: color-mix(in srgb, var(--pw-text) 6%, transparent);
  }

  /* Header right-side meta on customer_profile — wrap below title
     instead of crowding it. */
  .pw-page-head.crm-head { flex-direction: column; align-items: flex-start; }

  /* Page-head action button rail (vendor_detail, comm_account_detail
     "Save / Back" + similar) — wrap inline-flex buttons full-width
     so each is a comfortable tap. */
  .pw-page-body form > div[style*="display: flex"][style*="gap"] > .pw-btn,
  .pw-page-body form > div[style*="display:flex"][style*="gap"] > .pw-btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  /* Sweep: any inline-text input that forgot the 16px iOS-no-zoom
     floor + 44px tap height. Covers fields where the template
     author dropped pw-input without the inline sizing. */
  .pw-page-body input[type="text"]:not([style*="font-size"]),
  .pw-page-body input[type="email"]:not([style*="font-size"]),
  .pw-page-body input[type="tel"]:not([style*="font-size"]),
  .pw-page-body input[type="search"]:not([style*="font-size"]),
  .pw-page-body input[type="number"]:not([style*="font-size"]),
  .pw-page-body input[type="password"]:not([style*="font-size"]),
  .pw-page-body input[type="date"]:not([style*="font-size"]),
  .pw-page-body input[type="datetime-local"]:not([style*="font-size"]),
  .pw-page-body select:not([style*="font-size"]),
  .pw-page-body textarea:not([style*="font-size"]) {
    font-size: 16px;
    min-height: 44px;
  }
}

@media (max-width: 499px) {
  /* Hide the OD-id "<th>OD #</th>" + Finished column on tiny phones
     to reclaim viewport; the OD link is reachable from the row detail. */
  main table.jobs th:nth-child(4),
  main table.jobs td:nth-child(4),
  main table.jobs th:nth-child(11),
  main table.jobs td:nth-child(11),
  main table.jobs th:nth-child(12),
  main table.jobs td:nth-child(12) {
    display: none;
  }
  /* Even tighter padding on data tables. */
  main table.grid th,
  main table.grid td { padding: 5px 6px; font-size: 13px; }

  /* Customer card name was clamp(28px, 4vw, 40px) — that hits 28px
     at 375vw. Already OK; nothing further. */

  /* Customer profile contact KV grid — single column on tiny phones
     so dt/dd pairs read as labelled rows. */
  .crm-sec .crm-kv[style*="auto-fit"] {
    grid-template-columns: 1fr !important;
  }
}

/* ═════ v2.59.71 — Theme-safe colored callout cells.
   Some templates have hardcoded rgba(255,255,255,.04) for subtle
   inset blocks (assumes dark theme). Use a token-driven class that
   adapts. Templates can opt in by adding .pw-soft-callout. */
.pw-soft-callout {
  background: color-mix(in srgb, var(--pw-text) 4%, transparent);
  border-radius: 6px;
  padding: .6em .8em;
}
.pw-soft-callout--info {
  background: color-mix(in srgb, var(--pw-primary, var(--pw-accent)) 6%, transparent);
}
.pw-soft-callout--success {
  background: color-mix(in srgb, var(--pw-success, #2e8b57) 7%, transparent);
}
.pw-soft-callout--warn {
  background: color-mix(in srgb, var(--pw-warning, #b85c00) 8%, transparent);
}
.pw-soft-callout--danger {
  background: color-mix(in srgb, var(--pw-danger, #d14f40) 8%, transparent);
}
.pw-soft-callout--left-rule { border-left: 3px solid var(--pw-border); padding-left: .8em; }

/* ═════ v2.59.72 — Inbox channel color stripes.
   Used on inbox list rows + thread headers to color-code the channel
   at a glance. Token-driven so light/dark themes stay legible.
   --pw-accent / --pw-warning / --pw-success / --pw-danger already
   exist in the design tokens. */
:root {
  --pw-channel-email: var(--pw-primary, #3b82f6);
  --pw-channel-sms:   var(--pw-success, #22c55e);
  --pw-channel-voice: var(--pw-warning, #f59e0b);
  --pw-channel-other: var(--pw-text-muted, #94a3b8);
}

.pw-inbox-row {
  display: grid;
  grid-template-columns: 4px 24px 1fr auto;
  gap: var(--pw-space-3);
  align-items: center;
  padding: var(--pw-space-3) var(--pw-space-4);
  border-bottom: 1px solid var(--pw-border);
  text-decoration: none;
  color: var(--pw-text);
}
.pw-inbox-row:hover { background: var(--pw-surface-2); }
.pw-inbox-row__stripe {
  width: 4px;
  height: 100%;
  min-height: 32px;
  background: var(--pw-channel-other);
  border-radius: 2px;
}
.pw-inbox-row[data-channel="email"] .pw-inbox-row__stripe { background: var(--pw-channel-email); }
.pw-inbox-row[data-channel="sms"]   .pw-inbox-row__stripe { background: var(--pw-channel-sms); }
.pw-inbox-row[data-channel="voice"] .pw-inbox-row__stripe { background: var(--pw-channel-voice); }
/* v2.59.93 — Unread rows OBVIOUSLY different so marking read shows a
   visible change (Eric: 'mark as read doesn't appear to do anything').
   Accent bar + tint + dot, not just bold. */
.pw-inbox-row--unread {
  font-weight: 600;
  background: color-mix(in srgb, var(--pw-primary, var(--pw-accent)) 7%, transparent);
  box-shadow: inset 3px 0 0 var(--pw-primary, var(--pw-accent));
}
.pw-inbox-row--unread .pw-inbox-row__subject::before {
  content: "\25cf ";
  color: var(--pw-primary, var(--pw-accent));
  font-size: 0.8em;
}
.pw-inbox-row__body { min-width: 0; }
.pw-inbox-row__subject { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pw-inbox-row__preview {
  display: block;
  font-weight: normal;
  color: var(--pw-text-muted);
  font-size: 0.92em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pw-inbox-row__meta {
  text-align: right;
  font-size: 0.85em;
  color: var(--pw-text-muted);
}
.pw-tag-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--pw-primary, var(--pw-accent)) 12%, transparent);
  color: var(--pw-text);
  font-size: 0.78em;
  margin-right: 4px;
  vertical-align: middle;
}
.pw-bulk-bar {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--pw-surface);
  border-top: 1px solid var(--pw-border);
  padding: var(--pw-space-3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--pw-space-2);
  z-index: 10;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
}
@media (max-width: 767px) {
  .pw-inbox-row {
    grid-template-columns: 4px 1fr;
    grid-template-rows: auto auto;
  }
  .pw-inbox-row__channel-icon { display: none; }
  .pw-inbox-row__meta { grid-column: 2; text-align: left; }
  .pw-bulk-bar button { min-height: 44px; }
}

/* ════════════════════════════════════════════════════════════════
   LEFT RAIL + TABS (Issue #51 layout redesign, 2026-06-23)
   Replaces the mega-menu top-bar with a fixed 240px left rail and
   shrinks the top bar to just brand + utility chrome (search, bell,
   theme, user). Tabs replace stacked sections on detail pages
   (jobs, customers, print-jobs, service-requests).
   ════════════════════════════════════════════════════════════════ */

/* App layout shell — sits below the top bar. Rail is fixed so it
   doesn't scroll; <main> gets matching left margin so content
   doesn't slip under the rail. Main also gets a proper content
   gutter so pages don't hug the rail edge. App-shell feel:
   persistent rail + top bar, content column owns its breathing
   room. */
.pw-app-layout {
  display: block;
  min-height: calc(100vh - 56px);
  background: var(--pw-bg);
}
@media (min-width: 769px) {
  .pw-app-layout > main {
    margin-left: 60px;
    padding: 1.5em 1.75em 3em;
    min-height: calc(100vh - 56px);
    box-sizing: border-box;
    max-width: 100%;
    overflow-x: hidden;
  }
  @media (max-width: 1100px) {
    .pw-app-layout > main {
      padding: 1.25em 1.25em 2.5em;
    }
  }
}
@media (max-width: 768px) {
  .pw-app-layout > main {
    padding: 1em 1em 2em;
    min-height: calc(100vh - 56px);
    box-sizing: border-box;
  }
}

/* Fixed rail. Sits below the 56px top bar (top: 56px) and runs to
   the bottom of the viewport. Scrolls internally if its content
   overflows. */
/* v2.59.80 — Narrow icon rail (Intercom/Crisp/Freshdesk pattern).
   Replaces the wide text rail. 60px wide, glyphs only, tooltips on
   hover, active section highlighted by accent. Sub-pages within a
   section live inside that section's hub page (not the rail). */
.pw-leftrail {
  position: fixed;
  top: 56px;
  left: 0;
  bottom: 0;
  width: 60px;
  background: var(--pw-surface);
  border-right: 1px solid var(--pw-border);
  z-index: 90;
  transition: transform 200ms ease;
}
.pw-leftrail__inner {
  /* Rail layout — brand at top, icon group in the middle (scrolls if
     it ever overflows), user avatar pinned at the bottom. No nested
     scrollbars on the page. */
  padding: 8px 0 10px;
  height: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.pw-iconrail__group {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
  width: 100%;
  overflow-y: auto;
  scrollbar-width: none;
}
.pw-iconrail__group::-webkit-scrollbar { width: 0; }
/* Brand glyph — small italic "P" in the display serif so the rail
   carries the PrintWizzard editorial mark. Hairline divider below
   separates brand from nav. */
.pw-iconrail__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  margin-bottom: 4px;
  font-family: var(--pw-font-display, 'EB Garamond', Georgia, serif);
  font-style: italic;
  font-weight: 600;
  font-size: 26px;
  color: var(--pw-paper-50, #fafafa);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--pw-text) 12%, transparent);
  letter-spacing: -.02em;
}
.pw-iconrail__brand:hover { color: var(--pw-primary, var(--pw-accent)); }
/* User-avatar puck pinned at the bottom of the rail. Tap opens the
   already-in-DOM user dropdown in the top bar (no duplicate menu). */
.pw-iconrail__me {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-top: auto;
  border-radius: 50%;
  background: color-mix(in srgb, var(--pw-primary, var(--pw-accent)) 22%, transparent);
  color: var(--pw-primary, var(--pw-accent));
  font-family: var(--pw-font-mono, 'IBM Plex Mono', monospace);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid color-mix(in srgb, var(--pw-primary, var(--pw-accent)) 35%, transparent);
}
.pw-iconrail__me:hover {
  background: color-mix(in srgb, var(--pw-primary, var(--pw-accent)) 32%, transparent);
}
/* Icon rail items — 48px square targets with a glyph, optional dot
   for live counts, and a tooltip that fly-outs on hover. */
.pw-iconrail__item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 0 auto;
  border-radius: 8px;
  color: var(--pw-text-muted);
  text-decoration: none;
  transition: background 140ms ease, color 140ms ease;
  cursor: pointer;
  list-style: none;  /* kill the <summary> disclosure triangle */
}
.pw-iconrail__item::-webkit-details-marker { display: none; }
/* Chevron only renders in the mobile accordion (hidden on desktop
   where the rail is icon+hover-popout). */
.pw-iconrail__chevron { display: none; }
.pw-iconrail__item:hover {
  background: color-mix(in srgb, var(--pw-text) 8%, transparent);
  color: var(--pw-text);
}
.pw-iconrail__item--active {
  background: color-mix(in srgb, var(--pw-primary, var(--pw-accent)) 18%, transparent);
  color: var(--pw-primary, var(--pw-accent));
  box-shadow: inset 3px 0 0 var(--pw-primary, var(--pw-accent));
}
.pw-iconrail__item:focus-visible {
  outline: 2px solid var(--pw-primary, var(--pw-accent));
  outline-offset: 2px;
}
.pw-iconrail__glyph {
  width: 22px;
  height: 22px;
  display: block;
}
/* v2.59.81 — Section flyout. Each rail cell holds the icon + a
   hidden menu listing every page in that section. Hover/focus
   opens it to the right of the icon. */
.pw-iconrail__cell {
  position: relative;
  width: 48px;
  display: flex;
  justify-content: center;
}
.pw-iconrail__cell--active .pw-iconrail__item {
  background: color-mix(in srgb, var(--pw-primary, var(--pw-accent)) 18%, transparent);
  color: var(--pw-primary, var(--pw-accent));
  box-shadow: inset 3px 0 0 var(--pw-primary, var(--pw-accent));
}
.pw-iconrail__flyout {
  /* display:block overrides the native <details> closed-content
     hiding so the desktop hover-popout still renders for collapsed
     sections. Mobile re-uses native open/closed via the max-width
     block below. */
  display: block;
  position: absolute;
  left: calc(100% + 8px);
  top: -8px;
  min-width: 220px;
  background: var(--pw-ink, #161616);
  border: 1px solid color-mix(in srgb, var(--pw-paper-50, #fafafa) 12%, transparent);
  border-radius: 8px;
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-4px);
  transition: opacity 140ms ease, transform 140ms ease, visibility 0s linear 140ms;
  z-index: 220;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
.pw-iconrail__cell:hover .pw-iconrail__flyout,
.pw-iconrail__cell:focus-within .pw-iconrail__flyout {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
  transition: opacity 140ms ease, transform 140ms ease, visibility 0s;
  pointer-events: auto;
}
.pw-iconrail__flyout::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 22px;
  border: 6px solid transparent;
  border-right-color: var(--pw-ink, #161616);
}
.pw-iconrail__flyout-title {
  font-family: var(--pw-font-mono, 'IBM Plex Mono', monospace);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: rgba(255, 255, 255, 0.45);
  padding: 6px 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 4px;
}
.pw-iconrail__flyout-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5em;
  padding: 7px 10px;
  font-family: var(--pw-font-ui, 'IBM Plex Sans', sans-serif);
  font-size: 13.5px;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  border-radius: 5px;
  transition: background 100ms ease, color 100ms ease;
}
.pw-iconrail__flyout-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--pw-paper-50, #fafafa);
}
.pw-iconrail__flyout-item--active {
  background: color-mix(in srgb, var(--pw-primary, var(--pw-accent)) 18%, transparent);
  color: var(--pw-primary, var(--pw-accent));
  font-weight: 600;
}
.pw-iconrail__flyout-chip {
  font-family: var(--pw-font-mono, 'IBM Plex Mono', monospace);
  font-size: 10px;
  font-weight: 700;
  background: var(--pw-warn, #b85c00);
  color: white;
  padding: 2px 6px;
  border-radius: 8px;
}

/* Tooltip — fly-out to the right on hover/focus. Hidden by default,
   appears with a small delay so the rail stays quiet when the
   cursor sweeps across it. */
.pw-iconrail__tip {
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--pw-ink, #161616);
  color: var(--pw-paper-50, #fafafa);
  font-family: var(--pw-font-ui, 'IBM Plex Sans', sans-serif);
  font-size: 13px;
  font-weight: 500;
  padding: 0.45em 0.75em;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease 200ms;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.pw-iconrail__tip::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 4px solid transparent;
  border-right-color: var(--pw-ink, #161616);
}
.pw-iconrail__item:hover .pw-iconrail__tip,
.pw-iconrail__item:focus-visible .pw-iconrail__tip {
  opacity: 1;
}
/* Live count dot — top-right of the glyph, pulses subtle warn tint
   so the user clocks "something needs attention" without reading. */
.pw-iconrail__dot {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--pw-warn, #b85c00);
  color: white;
  font-family: var(--pw-font-mono, monospace);
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--pw-surface);
}
.pw-leftrail__section {
  margin: 0 0 1.75em;
}
.pw-leftrail__section:last-child {
  margin-bottom: 0;
}
.pw-leftrail__title {
  font-family: var(--pw-font-mono, 'IBM Plex Mono', monospace);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--pw-text-muted);
  padding: 0 0 0.5em 0.15em;
  margin: 0 0 0.4em;
  border-bottom: 1px solid color-mix(in srgb, var(--pw-text) 12%, transparent);
  font-weight: 500;
}
.pw-leftrail__item {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.55em 0.7em 0.55em 0.85em;
  color: var(--pw-text);
  text-decoration: none;
  border-radius: 6px;
  font-size: 14.5px;
  font-family: var(--pw-font-ui, 'IBM Plex Sans', sans-serif);
  margin: 1px 0;
  line-height: 1.3;
  position: relative;
  transition: background 140ms ease, color 140ms ease, padding-left 140ms ease;
}
/* Subtle hover — fades in a background + a 2px nudge so it feels
   alive without screaming. */
.pw-leftrail__item:hover {
  background: color-mix(in srgb, var(--pw-text) 7%, transparent);
  padding-left: 1em;
}
/* Active state — accent rail to the left, accent color on the LABEL
   itself, light tint behind. The rail's bar uses an inset
   box-shadow so it sits flush at the edge of the rail (cleaner than
   border-left which adds layout width). */
.pw-leftrail__item--active {
  color: var(--pw-primary, var(--pw-accent));
  background: color-mix(in srgb, var(--pw-primary, var(--pw-accent)) 12%, transparent);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--pw-primary, var(--pw-accent));
  padding-left: 1em;
}
.pw-leftrail__item--active:hover {
  background: color-mix(in srgb, var(--pw-primary, var(--pw-accent)) 16%, transparent);
  padding-left: 1em;
}
/* When focused via keyboard, mirror the hover affordance so tab-nav
   users see where they are. */
.pw-leftrail__item:focus-visible {
  outline: 2px solid var(--pw-primary, var(--pw-accent));
  outline-offset: -2px;
}
/* Item label takes available width; badge pins to the right. */
.pw-leftrail__label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Live count chip. Mono so digits align, small-caps weight so it
   reads as data not decoration. Default state is muted; warning
   tint when the count is non-zero (the chip only renders then).
   Active row gets a brighter chip so contrast doesn't drop. */
.pw-leftrail__badge {
  flex: 0 0 auto;
  font-family: var(--pw-font-mono, 'IBM Plex Mono', monospace);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--pw-warn, #b85c00) 18%, transparent);
  color: var(--pw-warn, #b85c00);
  letter-spacing: 0.02em;
}
.pw-leftrail__badge--active {
  background: color-mix(in srgb, var(--pw-warn, #b85c00) 26%, transparent);
}

/* Mobile drawer — off-canvas by default, slides in when .open is
   toggled. The overlay dims content + catches outside-taps to close. */
.pw-leftrail__drawer-overlay {
  display: none;
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 85;
}
.pw-leftrail__drawer-overlay.pw-leftrail__drawer-overlay--open {
  display: block;
}
@media (max-width: 768px) {
  /* v2.59.85 — Mobile drawer. The desktop icon+flyout popout
     pattern clips off-screen in a narrow drawer (every Settings
     item was truncated). On mobile we widen the drawer and render
     each section's items INLINE as an always-open list under its
     icon+label — no flyouts, nothing to clip, everything tappable
     by scrolling. */
  .pw-leftrail {
    transform: translateX(-100%);
    width: min(86vw, 340px);
    box-shadow: 2px 0 18px rgba(0, 0, 0, 0.4);
  }
  .pw-leftrail.pw-leftrail--open {
    transform: translateX(0);
  }
  .pw-app-layout > main {
    margin-left: 0;
  }
  /* Cells stack full-width, left-aligned. */
  .pw-leftrail__inner {
    align-items: stretch;
    padding: 0.5em 0 2em;
  }
  .pw-iconrail__group {
    align-items: stretch;
    gap: 0;
    padding: 0;
  }
  .pw-iconrail__cell {
    width: 100%;
    display: block;
    border-bottom: 1px solid color-mix(in srgb, var(--pw-text) 8%, transparent);
    padding: 0.25em 0;
  }
  /* Icon becomes a full-width section header row: icon + label +
     chevron. The whole row is the <summary> — tapping toggles the
     section. */
  .pw-iconrail__item {
    width: 100%;
    height: 48px;
    justify-content: flex-start;
    gap: 0.75em;
    padding: 0 1em;
    border-radius: 0;
    box-shadow: none;
    color: var(--pw-text);
  }
  .pw-iconrail__item::after {
    content: attr(aria-label);
    flex: 1 1 auto;
    font-family: var(--pw-font-mono, monospace);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--pw-text-muted);
  }
  /* Chevron shows on mobile + rotates when the section is open. */
  .pw-iconrail__chevron {
    display: block;
    flex: 0 0 auto;
    color: var(--pw-text-muted);
    transition: transform 160ms ease;
  }
  .pw-iconrail__cell[open] .pw-iconrail__chevron {
    transform: rotate(180deg);
  }
  .pw-iconrail__cell[open] .pw-iconrail__item::after {
    color: var(--pw-text);
  }
  /* Flyout is the accordion body: static + full width. Native
     <details> toggles it via [open] (no JS needed). Collapsed by
     default; the active section starts open (server adds `open`). */
  .pw-iconrail__flyout {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
    min-width: 0;
    width: 100%;
    box-shadow: none;
    border: 0;
    border-radius: 0;
    padding: 0 0 0.6em;
    background: color-mix(in srgb, var(--pw-text) 3%, transparent);
    box-sizing: border-box;
  }
  /* Accordion: collapsed by default; only the open section shows its
     items. (Base rule forces display:block for the desktop popout,
     so we re-gate on [open] here.) */
  .pw-iconrail__cell:not([open]) .pw-iconrail__flyout { display: none; }
  .pw-iconrail__cell[open] .pw-iconrail__flyout { display: block; }
  .pw-iconrail__flyout::before { display: none; }
  .pw-iconrail__flyout-title { display: none; }
  .pw-iconrail__flyout-item {
    padding: 0.7em 1em 0.7em 3.4em;
    font-size: 14.5px;
    border-radius: 0;
  }
  .pw-iconrail__tip { display: none; }
}

/* Tabs — replaces the per-detail stacked-section accordion. Strip
   sits flush at the top of the content column with a hairline
   underline; active tab gets a colored bottom border that flows
   into the strip rule. */
.pw-tabs {
  display: flex;
  gap: 1.5em;
  border-bottom: 1px solid var(--pw-border);
  margin-bottom: 1em;
  overflow-x: auto;
  padding-bottom: 0;
  scrollbar-width: thin;
}
.pw-tab {
  padding: 0.5em 0.25em;
  color: var(--pw-text-muted);
  text-decoration: none;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  font-family: var(--pw-font-ui, 'IBM Plex Sans', sans-serif);
  cursor: pointer;
  background: none;
  border-left: 0;
  border-right: 0;
  border-top: 0;
}
.pw-tab:hover {
  color: var(--pw-text);
  background: color-mix(in srgb, var(--pw-text) 4%, transparent);
}
.pw-tab--active {
  color: var(--pw-text);
  font-weight: 600;
  border-bottom-color: var(--pw-primary);
}
.pw-tab-panel[hidden] {
  display: none;
}
.pw-tab-panel {
  padding-top: 0.5em;
}


/* ════════════════════════════════════════════════════════════════════
   v2.59.82 — EDITORIAL-INDUSTRIAL BASELINE
   ════════════════════════════════════════════════════════════════════
   Comprehensive frontend pass. Brand DNA distilled + extended:
   - Dark newsprint surface; paper-50 type with sharp periwinkle accent
   - EB Garamond italic for display; Plex Sans body; Plex Mono labels
   - Hairline rules + dot separators as connective tissue
   - Bloomberg-density data; Linear-restraint chrome; WSJ masthead vibe
   - Single orchestrated page-load stagger (no scattered micro-fx)
   - Sharp edges; no fake shadows; controlled negative space
   Reference: Eric's frontend-design skill invocation 2026-06-23. */

/* ─── 1. Atmospheric depth ─────────────────────────────────────────── */
body { background: var(--pw-bg); }
.pw-app-layout {
  background-image:
    linear-gradient(180deg, rgba(255,255,255,0.012) 0%, transparent 200px),
    radial-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px);
  background-size: auto, 24px 24px;
  background-position: 0 0, 0 0;
  background-repeat: no-repeat, repeat;
}

/* ─── 2. Page-load motion — one orchestrated stagger ─────────────── */
@keyframes pw-rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .pw-app-layout > main > * {
  /* fill-mode BACKWARDS, never `both`. A filled transform animation makes
     the element a containing block for fixed-position descendants FOREVER,
     even once it settles on `transform: none` (Chrome reports the identity
     matrix). That trapped the crop overlay inside .pw-pjd on 2026-09-12:
     overlay top=104 h=313 instead of covering the viewport, and its ✕ /
     Cancel / submit bar scrolled away with a 12,545px sheet instead of
     staying pinned, so Eric could not close it. `backwards` keeps the
     pre-delay state (what the stagger needs) and drops the post-end fill,
     whose values are identical to the element's own anyway. */
    animation: pw-rise 380ms cubic-bezier(0.2, 0.7, 0.2, 1) backwards;
  }
  .pw-app-layout > main > *:nth-child(1) { animation-delay: 0ms; }
  .pw-app-layout > main > *:nth-child(2) { animation-delay: 60ms; }
  .pw-app-layout > main > *:nth-child(3) { animation-delay: 120ms; }
  .pw-app-layout > main > *:nth-child(4) { animation-delay: 180ms; }
  .pw-app-layout > main > *:nth-child(5) { animation-delay: 240ms; }
  .pw-app-layout > main > *:nth-child(6) { animation-delay: 300ms; }
}

/* ─── 3. Universal page primitives ───────────────────────────────── */
.pw-page {
  max-width: 1480px;
  margin: 0 auto;
}
.pw-page-head {
  display: flex;
  flex-direction: column;
  gap: 0.25em;
  padding: 0 0 1.25em;
  margin-bottom: 1.5em;
  border-bottom: 1px solid color-mix(in srgb, var(--pw-text) 12%, transparent);
}
.pw-page-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-family: var(--pw-font-mono, 'IBM Plex Mono', monospace);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--pw-text-muted);
}
.pw-page-kicker > span:not(:last-child)::after { content: ' · '; opacity: 0.45; padding: 0 0.15em; }
.pw-page-title {
  font-family: var(--pw-font-display, 'EB Garamond', Georgia, serif);
  font-style: italic;
  font-weight: 600;
  font-size: clamp(2.4rem, 4.5vw, 3.6rem);
  line-height: 1;
  letter-spacing: -0.015em;
  margin: 0.1em 0 0;
  color: var(--pw-text);
}
.pw-page-lede {
  font-family: var(--pw-font-ui, 'IBM Plex Sans', sans-serif);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--pw-text-muted);
  max-width: 62ch;
  margin: 0.5em 0 0;
}

/* Editorial section head — small mono kicker, italic display title,
   hairline rule under. Use for every named section inside a page. */
.pw-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1em;
  padding: 0 0 0.6em;
  margin: 2em 0 1em;
  border-bottom: 1px solid color-mix(in srgb, var(--pw-text) 10%, transparent);
}
.pw-section-head__title {
  font-family: var(--pw-font-display, 'EB Garamond', Georgia, serif);
  font-style: italic;
  font-weight: 600;
  font-size: 1.5rem;
  line-height: 1.1;
  letter-spacing: -0.005em;
  margin: 0;
}
.pw-section-head__meta {
  font-family: var(--pw-font-mono, 'IBM Plex Mono', monospace);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--pw-text-muted);
}

/* ─── 4. Editorial card primitive ───────────────────────────────── */
.pw-card {
  background: color-mix(in srgb, var(--pw-text) 3%, transparent);
  border: 1px solid color-mix(in srgb, var(--pw-text) 10%, transparent);
  border-radius: 8px;
  padding: 1.5em 1.6em;
  position: relative;
}
.pw-card + .pw-card { margin-top: 1em; }
.pw-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1em;
  margin: -0.25em 0 1em;
  padding-bottom: 0.75em;
  border-bottom: 1px solid color-mix(in srgb, var(--pw-text) 8%, transparent);
}
.pw-card__title {
  font-family: var(--pw-font-display, 'EB Garamond', Georgia, serif);
  font-style: italic;
  font-weight: 600;
  font-size: 1.15rem;
  margin: 0;
}

/* ─── 5. Data table — Bloomberg-density tabular ──────────────────── */
table.pw-table,
.pw-page table:not(.no-pw):not(.crm-kv) {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--pw-font-ui, 'IBM Plex Sans', sans-serif);
  font-size: 13.5px;
  line-height: 1.5;
}
.pw-page table thead th {
  font-family: var(--pw-font-mono, 'IBM Plex Mono', monospace);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--pw-text-muted);
  text-align: left;
  font-weight: 500;
  padding: 0.6em 0.85em;
  border-bottom: 1px solid color-mix(in srgb, var(--pw-text) 16%, transparent);
  background: transparent;
}
.pw-page table tbody td {
  padding: 0.75em 0.85em;
  border-bottom: 1px solid color-mix(in srgb, var(--pw-text) 6%, transparent);
  color: var(--pw-text);
  vertical-align: top;
}
.pw-page table tbody tr:hover td {
  background: color-mix(in srgb, var(--pw-text) 4%, transparent);
}
.pw-page table tbody td:last-child,
.pw-page table thead th:last-child { padding-right: 1.25em; }
.pw-page table tbody td:first-child,
.pw-page table thead th:first-child { padding-left: 1.25em; }

/* Mono-numeric columns — durations, counts, money, IDs */
.pw-num,
.pw-page table td:has(> code),
.pw-mono {
  font-family: var(--pw-font-mono, 'IBM Plex Mono', monospace);
  font-feature-settings: 'tnum' 1, 'zero' 1;
  letter-spacing: -0.01em;
}

/* ─── 6. Editorial buttons ──────────────────────────────────────── */
.pw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  height: 36px;
  padding: 0 1em;
  font-family: var(--pw-font-ui, 'IBM Plex Sans', sans-serif);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.005em;
  color: var(--pw-text);
  background: color-mix(in srgb, var(--pw-text) 6%, transparent);
  border: 1px solid color-mix(in srgb, var(--pw-text) 12%, transparent);
  border-radius: 5px;
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.pw-btn:hover {
  background: color-mix(in srgb, var(--pw-text) 10%, transparent);
  border-color: color-mix(in srgb, var(--pw-text) 20%, transparent);
}
.pw-btn--primary {
  background: var(--pw-primary, var(--pw-accent));
  border-color: var(--pw-primary, var(--pw-accent));
  /* --pw-ink is a raw palette step and never flips with the theme, so
     this painted #0E1014 text onto the light theme's navy --pw-primary:
     1.71:1, measured on every primary button on every admin page.
     --pw-primary-on is the paired foreground and flips with the theme
     (#FFFFFF light, ink-dark dark). Same token .pw-btn--primary already
     uses at line 108; this later block was silently overriding it. */
  color: var(--pw-primary-on, var(--pw-ink, #161616));
  font-weight: 600;
}
.pw-btn--primary:hover {
  filter: brightness(1.08);
}
.pw-btn--sm { height: 28px; padding: 0 0.8em; font-size: 12.5px; }

/* ─── 7. Forms ─────────────────────────────────────────────────── */
.pw-input,
.pw-page input[type="text"]:not(.no-pw),
.pw-page input[type="email"]:not(.no-pw),
.pw-page input[type="number"]:not(.no-pw),
.pw-page input[type="search"]:not(.no-pw),
.pw-page input[type="tel"]:not(.no-pw),
.pw-page input[type="url"]:not(.no-pw),
.pw-page input[type="password"]:not(.no-pw),
.pw-page select:not(.no-pw),
.pw-page textarea:not(.no-pw) {
  font-family: var(--pw-font-ui, 'IBM Plex Sans', sans-serif);
  font-size: 14px;
  background: color-mix(in srgb, var(--pw-text) 4%, transparent);
  color: var(--pw-text);
  border: 1px solid color-mix(in srgb, var(--pw-text) 14%, transparent);
  border-radius: 5px;
  padding: 0.55em 0.75em;
  transition: border-color 120ms ease, background 120ms ease;
}
.pw-input:focus,
.pw-page input:focus:not(.no-pw),
.pw-page select:focus:not(.no-pw),
.pw-page textarea:focus:not(.no-pw) {
  outline: none;
  border-color: var(--pw-primary, var(--pw-accent));
  background: color-mix(in srgb, var(--pw-text) 6%, transparent);
}

/* ─── 8. Tighten the noisy chrome ───────────────────────────────── */
/* Refresh picker — was loud, make it small + utilitarian */
.refresh-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  height: 28px;
  padding: 0 0.6em;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 5px;
  font-family: var(--pw-font-mono, monospace);
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
}
.refresh-picker select {
  background: transparent;
  border: 0;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  padding: 0;
}
.refresh-icon { opacity: 0.7; }

/* Low-stock pill — already prominent enough, tighten */
.low-stock-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  height: 28px;
  padding: 0 0.7em;
  border-radius: 5px;
  font-family: var(--pw-font-mono, monospace);
  font-size: 11px;
  font-weight: 600;
  background: var(--pw-warn, #b85c00);
  color: white;
  text-decoration: none;
  letter-spacing: 0.04em;
}

/* User chip dropdown — slim mono treatment */
.nav-user > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  height: 32px;
  padding: 0 0.8em;
  border-radius: 5px;
  font-family: var(--pw-font-ui, sans-serif);
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  transition: background 120ms ease;
}
.nav-user > summary:hover { background: rgba(255, 255, 255, 0.06); }
.nav-user > summary::-webkit-details-marker { display: none; }
.nav-user > summary .pw-muted { color: rgba(255, 255, 255, 0.45); margin-left: 0.3em; }

/* Pre-deploy gate banner — quiet when failed, not screaming */
.predeploy-banner,
[class*="predeploy"][class*="failed"],
.banner-fail {
  background: color-mix(in srgb, var(--pw-fail, #b8281f) 12%, transparent);
  border-left: 3px solid var(--pw-fail, #b8281f);
  border-radius: 4px;
  padding: 0.7em 1em;
  font-size: 13px;
  color: var(--pw-text);
}

/* Bell dropdown — sharper editorial treatment */
#bell-dropdown > summary {
  list-style: none;
  height: 32px;
  width: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  cursor: pointer;
  transition: background 120ms ease;
}
#bell-dropdown > summary::-webkit-details-marker { display: none; }
#bell-dropdown > summary:hover { background: rgba(255, 255, 255, 0.08); }
#bell-dropdown[open] > summary { background: rgba(255, 255, 255, 0.12); }

/* ─── 9. Selection accent ──────────────────────────────────────── */
::selection {
  background: color-mix(in srgb, var(--pw-primary, var(--pw-accent)) 40%, transparent);
  color: var(--pw-paper-50, #fafafa);
}

/* ─── 10. Scrollbars — slim utilitarian, dark theme ─────────────── */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.18) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.32); }
*::-webkit-scrollbar-track { background: transparent; }

/* ─── 11. Eliminate horizontal-scroll bleed ─────────────────────── */
html, body { overflow-x: hidden; max-width: 100vw; }
.pw-app-layout > main { overflow-x: hidden; }


/* v2.59.83 — Customer profile tabs: let them wrap to multiple rows
   instead of horizontal-scrolling in a cramped column. 13 tabs is
   too many to fit on one row at any realistic viewport. */
.pw-tabs {
  flex-wrap: wrap;
  overflow-x: visible;
}

/* ════════════════════════════════════════════════════════════════════
   v2.59.88 — DESKTOP MEGA-MENU RIBBON (Office-ribbon style)
   ════════════════════════════════════════════════════════════════════
   Second header row on desktop. A row of broad tabs; hover/focus a
   tab → full mega-panel of group-columns drops down. Hidden on
   mobile (the hamburger drawer takes over). */
.pw-ribbon {
  display: block;
  background: var(--pw-ink, #161616);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: var(--pw-nav-h, 56px);
  z-index: 95;
}
.pw-ribbon__inner {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 0 1em 0 calc(232px - 232px + 1.25em);
  max-width: 100%;
}
.pw-ribbon__tab { position: relative; }
.pw-ribbon__tabbtn {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  height: 42px;
  padding: 0 1em;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: rgba(255, 255, 255, 0.72);
  font-family: var(--pw-font-ui, 'IBM Plex Sans', sans-serif);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: color 120ms ease, background 120ms ease;
}
.pw-ribbon__tabbtn:hover {
  color: var(--pw-paper-50, #fafafa);
  background: rgba(255, 255, 255, 0.05);
}
.pw-ribbon__tab--active .pw-ribbon__tabbtn {
  color: var(--pw-paper-50, #fafafa);
  font-weight: 600;
  border-bottom-color: var(--pw-primary, var(--pw-accent));
}
.pw-ribbon__caret {
  opacity: 0.5;
  transition: transform 160ms ease;
}
.pw-ribbon__tab:hover .pw-ribbon__caret,
.pw-ribbon__tab:focus-within .pw-ribbon__caret {
  transform: rotate(180deg);
  opacity: 0.9;
}
/* Mega-panel — drops below the tab on hover/focus. */
.pw-ribbon__panel {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 280px;
  max-width: 90vw;
  background: var(--pw-surface, #1a1d22);
  border: 1px solid color-mix(in srgb, var(--pw-text) 14%, transparent);
  border-top: 2px solid var(--pw-primary, var(--pw-accent));
  border-radius: 0 0 10px 10px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  padding: 1.25em 1.5em;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 150ms ease, transform 150ms ease, visibility 0s linear 150ms;
  z-index: 300;
}
.pw-ribbon__tab:hover .pw-ribbon__panel,
.pw-ribbon__tab:focus-within .pw-ribbon__panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 150ms ease, transform 150ms ease, visibility 0s;
}
.pw-ribbon__cols {
  display: flex;
  gap: 2.5em;
  align-items: flex-start;
}
.pw-ribbon__col { min-width: 170px; }
.pw-ribbon__col-title {
  font-family: var(--pw-font-mono, 'IBM Plex Mono', monospace);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--pw-text-muted);
  padding: 0 0 0.6em;
  margin-bottom: 0.4em;
  border-bottom: 1px solid color-mix(in srgb, var(--pw-text) 10%, transparent);
}
.pw-ribbon__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6em;
  padding: 0.5em 0.6em;
  margin: 1px -0.6em;
  border-radius: 5px;
  color: var(--pw-text);
  text-decoration: none;
  font-family: var(--pw-font-ui, 'IBM Plex Sans', sans-serif);
  font-size: 13.5px;
  transition: background 110ms ease, color 110ms ease;
}
.pw-ribbon__item:hover {
  background: color-mix(in srgb, var(--pw-text) 7%, transparent);
}
.pw-ribbon__item--active {
  background: color-mix(in srgb, var(--pw-primary, var(--pw-accent)) 14%, transparent);
  color: var(--pw-primary, var(--pw-accent));
  font-weight: 600;
}
.pw-ribbon__chip {
  flex: 0 0 auto;
  font-family: var(--pw-font-mono, monospace);
  font-size: 10px;
  font-weight: 700;
  background: var(--pw-warn, #b85c00);
  color: white;
  padding: 2px 6px;
  border-radius: 8px;
}

/* ─── Desktop vs mobile visibility ──────────────────────────────── */
/* Desktop: ribbon shown, icon rail hidden, content full-width
   (no left rail). */
@media (min-width: 769px) {
  .pw-leftrail--mobile-only { display: none; }
  .pw-app-layout > main { margin-left: 0; }
}
/* Mobile: ribbon hidden, hamburger drawer (icon rail) used. */
@media (max-width: 768px) {
  .pw-ribbon { display: none; }
}

/* Group sub-headers inside the mobile drawer accordion. */
.pw-iconrail__grp-title {
  font-family: var(--pw-font-mono, 'IBM Plex Mono', monospace);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--pw-text-muted);
  padding: 0.6em 1em 0.3em 1.6em;
  opacity: 0.7;
}

/* ── SLA chips (v2.60.x, Slice 4) ─────────────────────────────────────
   Compact per-milestone turnaround-status chip. Color comes from the
   --pw-* state tokens (success/warning/danger) — never hardcoded — so
   light/dark themes both read correctly. Chips wrap on narrow screens
   (Eric works from his phone) and never force horizontal overflow. */
.pw-sla-chips {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.pw-sla-chip {
  display: inline-flex; align-items: baseline; flex-wrap: wrap;
  gap: 0 0.4em; max-width: 100%;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid currentColor;
  font-family: var(--pw-font-ui, system-ui, sans-serif);
  font-size: 12px; line-height: 1.35;
  background: color-mix(in srgb, currentColor 10%, var(--pw-surface, #fff));
}
.pw-sla-chip__label { font-weight: 600; letter-spacing: 0.01em; }
.pw-sla-chip__state { font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; font-size: 11px; }
.pw-sla-chip__when  { color: var(--pw-text-muted); font-size: 11px; white-space: nowrap; }
.pw-sla-chip--success { color: var(--pw-success, #1F5B3A); }
.pw-sla-chip--warning { color: var(--pw-warning, #8F6A11); }
.pw-sla-chip--danger  { color: var(--pw-danger,  #A8261A); }
.pw-sla-chip--muted {
  color: var(--pw-text-muted, #4A4F5C);
  border-color: var(--pw-border, #D8D4C8);
  background: transparent;
}
/* Bare inline variant for the dense print-jobs grid cell — no pill
   border, just colored text so the column stays narrow. */
.pw-sla-mini { font-size: 11px; font-weight: 700; white-space: nowrap; }
.pw-sla-mini--success { color: var(--pw-success, #1F5B3A); }
.pw-sla-mini--warning { color: var(--pw-warning, #8F6A11); }
.pw-sla-mini--danger  { color: var(--pw-danger,  #A8261A); }
.pw-sla-mini--muted   { color: var(--pw-text-faint, #9EA1A8); }

/* Numbered procedure — see admin_kiosk.html. Device Owner provisioning has
   a step nothing on the device hints at (tap the welcome screen 6 times),
   so the steps belong on the page, not in a chat log someone has to find
   again six months from now. */
.pw-steps { max-width: 62em; margin: 1em 0; padding-left: 1.4em; }
.pw-steps li { margin-bottom: .55em; line-height: 1.45; }

/* QR plate. A scanner needs genuine white behind the modules — a themed
   surface could resolve to grey or near-black and stop it decoding. This
   is the one place a literal colour is correct, so it lives here as a
   class rather than being hardcoded inline in each template. */
.pw-qr-plate {
    background: #ffffff;
    padding: 8px;
    border-radius: 6px;
    display: inline-block;
    max-width: 100%;
}

/* ── Cropped-reprint badge (v2.63.20) ────────────────────────────────
   Rendered by _crop_badge.html on all four QA surfaces: the tablet
   order grid + sheet detail, and the handheld order list + sheet
   screen. One rule set, because the fact it states is the same fact
   everywhere and QA should recognise it at a glance regardless of which
   device is in their hand.

   Nick cropped one sheet of a two-sheet order; QA saw the crop and had
   no way to know a full sheet had come first. Amber, not red: this is
   context, not a fault — the crop is the CORRECT sheet to judge.

   Tokens only. --pw-warning/-on flip with the theme; the raw
   --pw-warn-* palette steps do not, and this renders on a light tablet
   and a dark handheld in the same shift. */
.pw-crop-badge {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 0.5rem;
  margin: 0.5rem 0 0;
  padding: 0.4rem 0.55rem;
  border-left: 3px solid var(--pw-warning);
  border-radius: 0 4px 4px 0;
  background: color-mix(in srgb, var(--pw-warning) 12%, var(--pw-surface));
  color: var(--pw-text);
  font-size: 0.78rem;
  line-height: 1.35;
  text-align: left;
}

.pw-crop-badge__tag {
  flex: 0 0 auto;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: var(--pw-warning);
  color: var(--pw-warning-on);
  font-family: var(--pw-font-mono, monospace);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.pw-crop-badge__body { flex: 1 1 10rem; min-width: 0; }

.pw-crop-badge__band {
  font-family: var(--pw-font-mono, monospace);
  font-weight: 700;
  white-space: nowrap;
}

/* A plain QA-fail respawn keeps the shape but drops the alarm — it says
   "an earlier print exists", which is worth knowing and nothing more. */
.pw-crop-badge--rerun {
  border-left-color: var(--pw-border-strong);
  background: var(--pw-surface-2);
}

.pw-crop-badge--rerun .pw-crop-badge__tag {
  background: var(--pw-border-strong);
  color: var(--pw-text);
}

/* ═════ v2.63.x — POD partner portal: shipping columns ═════
   Jiffy asked to see, per order: the tracking number, when the UPS label
   was created, when WE physically scanned the box, and which UPS batch it
   went out in. That is four more columns on a table that already had five,
   so the desktop table scrolls sideways inside its own wrapper rather than
   squeezing every column to unreadable — the page body itself must never
   scroll horizontally.

   Every color is a --pw-* token, so both themes are covered by
   construction. --pw-primary is already defined per theme (blue-600 on
   light paper, blue-300 on dark), which is what keeps the tracking link
   legible in both without a single hardcoded hex.
   ════════════════════════════════════════════════════════════════════ */
.pw-ship-note {
  margin: 0 0 var(--pw-space-3);
  max-width: 68ch;
}

.pw-ship-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* The tracking number is the thing partners came for: a real link, in
   full, that survives being copied out. `break-all` because an 18-char
   1Z… number in a narrow column would otherwise force the whole table
   wider than the phone. */
.pw-ship-table .pw-ship-track__link {
  color: var(--pw-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.pw-ship-table .pw-ship-track__link:hover,
.pw-ship-table .pw-ship-track__link:focus-visible {
  text-decoration-thickness: 2px;
}

.pw-ship-batch__pickup {
  display: block;
  font-size: var(--pw-text-xs);
}

@media (max-width: 640px) {
  /* Below 640px the shared `.grid` rules turn every table into stacked
     cards and HIDE the header row. That works for the 5-column tables it
     was written for, where each line is self-evident; with nine columns a
     card of bare timestamps is unreadable, so each cell carries its own
     label. Eric reads this portal from his phone in the shop. */
  .pw-page-body table.grid.pw-ship-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-family: var(--pw-font-ui);
    font-size: var(--pw-text-xs);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--pw-text-muted);
  }
  /* Those same shared rules style cards BY COLUMN POSITION (children 3
     and 4 muted, last child a bordered full-width action footer) because
     the table they were written for ended in a button. Here column 9 is a
     timestamp and column 3 is the store name, so the positional styling
     has to be neutralised or the card reads as though it had an action in
     it. Class-qualified, so these win on specificity. */
  .pw-page-body table.grid.pw-ship-table td {
    font-size: 15px;
    color: var(--pw-text);
    padding: 6px 0;
  }
  .pw-page-body table.grid.pw-ship-table td:first-child { font-size: 16px; }
  .pw-page-body table.grid.pw-ship-table td:last-child {
    border-top: 0;
    margin-top: 0;
    padding-top: 6px;
  }
  /* 16px keeps the link a comfortable tap target and stops iOS zooming. */
  .pw-page-body table.grid.pw-ship-table .pw-ship-track__link {
    font-size: 16px;
  }
}

/* v2.63.50 — lazy tab panels ([data-pw-lazy] in leftrail.js).
   A small themed row, not the 56px lightbox spinner above: this sits
   inline in a panel, on the page surface, in both themes. Tokens only —
   a hardcoded white border vanishes on the light theme. */
.pw-lazy-loading {
  display: flex;
  align-items: center;
  gap: var(--pw-space-3);
  padding: var(--pw-space-4);
  color: var(--pw-text-muted);
  font-size: var(--pw-text-sm);
}
.pw-lazy-loading .pw-spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--pw-border);
  border-top-color: var(--pw-text-muted);
}
