:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --border: #e0e4e2;
  /* Form-field outline: 3:1 against --surface and --bg (WCAG 1.4.11), unlike
     --border, which is a soft card divider and nearly invisible as a field edge. */
  --field-border: #848c88;
  --text: #1b2420;
  --text-muted: #5a655f;
  --primary: #2f7a4f;
  --primary-dark: #22603c;
  --primary-tint: #e6f2ea;
  /* Text/icons drawn ON --primary (buttons, avatar, badges). White on the
     default green; themes whose --primary is light (dark mode, LSU orange,
     sci-fi cyan) override these so the label never washes out. */
  --on-primary: #ffffff;
  --on-primary-strong: #ffffff; /* on --primary-dark (hover states) */
  --primary-text: var(--primary-dark); /* accent-colored text on --surface / --primary-tint */
  --danger: #c0392b;
  --danger-tint: #fbe9e7;
  --success: #2e9e5b;
  --warning: #e0a52c;
  --radius: 10px;
  --radius-sm: 6px; /* controls, chips, inputs; panels use --radius */
  /* Type scale: --fs-xs is the floor for anything a person must read (labels, badges, captions). */
  --fs-xs: clamp(0.75rem, calc(0.75rem + (100vw - 1100px) * 0.0036), 1.125rem);
  --fs-sm: clamp(0.8125rem, calc(0.8125rem + (100vw - 1100px) * 0.0039), 1.2rem); /* dense data, tables */
  --fs-md: clamp(0.875rem, calc(0.875rem + (100vw - 1100px) * 0.0042), 1.3rem); /* body */
  --fs-lg: clamp(1rem, calc(1rem + (100vw - 1100px) * 0.0048), 1.5rem);
  --fs-xl: clamp(1.25rem, calc(1.25rem + (100vw - 1100px) * 0.006), 1.9rem);
  --fs-2xl: clamp(1.5rem, calc(1.5rem + (100vw - 1100px) * 0.0072), 2.3rem);
  --fs-title: clamp(1.375rem, calc(1.375rem + (100vw - 1100px) * 0.0075), 2.4rem); /* page header title */
  --ctl-h: clamp(36px, calc(36px + (100vw - 1100px) * 0.011), 52px); /* header control height */
  --shadow: 0 1px 3px rgba(20, 30, 25, 0.08), 0 1px 2px rgba(20, 30, 25, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181a;
    --surface: #1c2124;
    --border: #2c3336;
    --field-border: #67706e;
    --text: #eaf0ec;
    --text-muted: #98a29c;
    --primary: #4caf7d;
    --primary-dark: #3d8f65;
    --primary-tint: #1c2b23;
    --on-primary: #0b1a12;
    --on-primary-strong: #0b1a12;
    --primary-text: var(--primary);
    --danger: #e57368;
    --danger-tint: #2c1e1c;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

/* Fluid sizing: clamp(min, preferred, max) lets spacing and headline type
   scale smoothly with the viewport instead of jumping at breakpoints. The
   max of each is the original desktop value, so wide screens look exactly
   as before; only narrower screens tighten up. */
:root {
  --gutter: clamp(12px, 2.4vw, 24px); /* page edges, topbar, card grids */
  --pad-modal: clamp(14px, 3vw, 22px); /* modal / form horizontal inset */
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* Signed-in background theme */
body.themed-bg {
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(244, 246, 245, 0.92), rgba(244, 246, 245, 0.92)), url('/branding/hero-bg.webp');
  background-size: cover;
  background-position: center center;
  background-attachment: fixed;
  background-repeat: no-repeat;
}
@media (prefers-color-scheme: dark) {
  body.themed-bg {
    background-image: linear-gradient(rgba(20, 24, 26, 0.92), rgba(20, 24, 26, 0.92)), url('/branding/hero-bg.webp');
  }
}
:root[data-theme='dark'] body.themed-bg {
  background-image: linear-gradient(rgba(20, 24, 26, 0.92), rgba(20, 24, 26, 0.92)), url('/branding/hero-bg.webp');
}
:root[data-theme='light'] body.themed-bg {
  background-image:
    linear-gradient(rgba(244, 246, 245, 0.92), rgba(244, 246, 245, 0.92)), url('/branding/hero-bg.webp');
}

/* LSU-themed background (Steve) -- 4-stop purple/orange/gold/cream palette.
   The old version washed the ENTIRE page in a near-opaque dark purple and
   only patched --text for the gold cards floating on top of it -- anything
   NOT on a card (ghost buttons, plain <p> empty-states, .history-row) sat
   directly on that dark purple with near-black --text and effectively
   vanished. Fixed at the root instead of per-component: --bg is now the
   pale cream stop (safe default contrast for dark text everywhere, same
   role --bg already plays in every other theme), and purple/orange are a
   low-opacity decorative wash rather than the dominant background color. */
body.themed-bg.lsu-theme {
  --bg: #fdf6d8;
  --surface: #fbe27e;
  --border: #c9a227;
  --field-border: #9b791f;
  --primary: #f4871b;
  --primary-dark: #7a3d03;
  --primary-text: #7a3d03;
  --on-primary: #241608;
  --on-primary-strong: #ffffff;
  --danger: #c0392b;
  --danger-tint: #fbe9e7;
  --primary-tint: #fde3c4;
  --text: #241608;
  --text-muted: #5c4114;
  background-color: #fdf6d8;
  background-image:
    linear-gradient(160deg, rgba(70, 29, 124, 0.16) 0%, rgba(38, 16, 68, 0.08) 55%, rgba(20, 8, 35, 0.04) 100%),
    repeating-linear-gradient(
      135deg,
      rgba(244, 135, 27, 0.07) 0px,
      rgba(244, 135, 27, 0.07) 3px,
      transparent 3px,
      transparent 42px
    );
  background-size:
    cover,
    60px 60px;
  background-position:
    center center,
    0 0;
  background-attachment: fixed, fixed;
  background-repeat: no-repeat, repeat;
}
body.lsu-theme .widget-sub,
body.lsu-theme .stat-label,
body.lsu-theme .widget-label {
  font-size: var(--fs-sm);
}
:root[data-theme='dark'] body.themed-bg.lsu-theme,
:root[data-theme='light'] body.themed-bg.lsu-theme {
  background-image:
    linear-gradient(160deg, rgba(70, 29, 124, 0.16) 0%, rgba(38, 16, 68, 0.08) 55%, rgba(20, 8, 35, 0.04) 100%),
    repeating-linear-gradient(
      135deg,
      rgba(244, 135, 27, 0.07) 0px,
      rgba(244, 135, 27, 0.07) 3px,
      transparent 3px,
      transparent 42px
    );
}
body.lsu-theme .brand-mark {
  background: #fbe27e;
  border-color: #c9a227;
}

/* Sci-fi themed background (Marc) -- the actual photo Marc picked ("a
   purple and blue background with lines of light" by Anton Filatov, free
   to use under the Unsplash License: https://unsplash.com/photos/O_5SJuSOxZA),
   self-hosted at public/branding/marc-hyperspace-bg.webp (the original JPEG
   re-encoded as WebP, 428 KB -> 210 KB, same size and framing). The
   photo itself is dark, so it's anchored to the top of the viewport where
   it's fully visible, then faded into the pale --bg (the same safe-contrast
   base every component in this file already assumes) via a radial mask --
   the fade is a compositing layer in front of the image, not an edit to
   the image file, which is untouched. */
body.themed-bg.scifi-theme {
  --bg: #eef3fa;
  --surface: #ffffff;
  --border: #c7d6ea;
  --field-border: #7a89a0;
  --primary: #0ea5c4;
  --primary-dark: #0a6a80;
  --primary-text: #0a6a80;
  --on-primary: #04222b;
  --on-primary-strong: #ffffff;
  --danger: #c0392b;
  --danger-tint: #fbe9e7;
  --primary-tint: #dff6fb;
  --text: #131a24;
  --text-muted: #52627a;
  background-color: #05060c;
  background-image:
    radial-gradient(
      circle at 50% -20px,
      transparent 0px,
      transparent 45px,
      rgba(238, 243, 250, 0.9) 120px,
      #eef3fa 210px
    ),
    url('/branding/marc-hyperspace-bg.webp');
  background-size: cover, cover;
  background-position:
    center top,
    center top;
  background-attachment: fixed, fixed;
  background-repeat: no-repeat, no-repeat;
  /* General safety net for any text that isn't inside a card (unknown/
     future pages included) -- inherits down by default. A soft white
     glow reads as a legibility aid over the photo and is imperceptible
     on white cards, so it's safe to apply everywhere rather than only to
     the specific bare-on-page classes patched below. */
  text-shadow:
    0 0 8px rgba(255, 255, 255, 0.7),
    0 0 3px rgba(255, 255, 255, 0.8);
}
:root[data-theme='dark'] body.themed-bg.scifi-theme,
:root[data-theme='light'] body.themed-bg.scifi-theme {
  background-image:
    radial-gradient(
      circle at 50% -20px,
      transparent 0px,
      transparent 45px,
      rgba(238, 243, 250, 0.9) 120px,
      #eef3fa 210px
    ),
    url('/branding/marc-hyperspace-bg.webp');
}
body.scifi-theme .brand-mark {
  background: #ffffff;
  border-color: #0ea5c4;
}
/* The photo is busy and dark near the top of the page -- controls and
   empty-state text that float directly on the body background (no card
   behind them) get their own translucent chip so they stay readable
   however close to the photo they land, rather than retuning the fade
   distance per page. */
body.scifi-theme .ghost-btn {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(3px);
}
body.scifi-theme .ghost-btn:hover {
  background: rgba(255, 255, 255, 0.95);
}
body.scifi-theme .month-calendar-day,
body.scifi-theme .history-row {
  background: rgba(255, 255, 255, 0.86);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(3px);
}
body.scifi-theme .widget-loading,
body.scifi-theme .empty-state {
  background: rgba(255, 255, 255, 0.86);
  border-radius: var(--radius);
  backdrop-filter: blur(3px);
  padding: 14px 18px;
}

/* Self-service custom background (Profile > Background, any user) -- the
   uploaded file is unknown ahead of time, so common.js sets --custom-bg-url
   inline per-user rather than this being a per-user class like lsu-theme/
   scifi-theme above. --surface stays fully opaque white (not touched by
   the wash below), so every .card/.widget/.topbar -- i.e. virtually all
   real text on every page -- already sits on a solid background with zero
   photo behind it. No text-shadow here: a white glow on top of an already-
   opaque white surface added no legibility and just blurred every heading
   site-wide. Only the genuinely bare-on-photo elements (chips below) need
   their own treatment. */
body.themed-bg.custom-bg-theme {
  --bg: #eef3fa;
  --surface: #ffffff;
  --border: #c7d6ea;
  --field-border: #7b889b;
  --text: #131a24;
  --text-muted: #2f3b4d;
  --primary: #2f7a4f;
  --primary-dark: #22603c;
  --primary-text: #22603c;
  --primary-tint: #e6f2ea;
  --on-primary: #ffffff;
  --on-primary-strong: #ffffff;
  --danger: #c0392b;
  --danger-tint: #fbe9e7;
  background-color: #05060c;
  /* Flat 70% wash of the page color over the photo, uniform across the page
     (not fading out after a few hundred pixels). Text that isn't inside a
     card sits directly on this, so it has to hold up even over a pure-black
     photo -- at 70% --text stays around 7:1 and the darker --text-muted
     around 4.5:1. The photo still reads through at 30%. */
  background-image: linear-gradient(rgba(238, 243, 250, 0.7), rgba(238, 243, 250, 0.7)), var(--custom-bg-url, none);
  background-size: cover, cover;
  background-position:
    center center,
    center center;
  background-attachment: fixed, fixed;
  background-repeat: no-repeat, no-repeat;
}
:root[data-theme='dark'] body.themed-bg.custom-bg-theme,
:root[data-theme='light'] body.themed-bg.custom-bg-theme {
  background-image: linear-gradient(rgba(238, 243, 250, 0.7), rgba(238, 243, 250, 0.7)), var(--custom-bg-url, none);
}
/* Exec dashboards (Steve/Marc/lab/sales/etc.) have their own --exec-*
   token set, entirely separate from --bg/--surface/--text above -- the
   topbar, nav, and every .exec-card already paint an opaque
   var(--exec-surface) background regardless of this theme, so the photo
   only ever shows through the grid gutters between cards, never behind
   any actual text. Nothing extra needed here. */
body.custom-bg-theme .ghost-btn {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(3px);
}
body.custom-bg-theme .ghost-btn:hover {
  background: rgba(255, 255, 255, 0.95);
}
body.custom-bg-theme .month-calendar-day,
body.custom-bg-theme .history-row {
  background: rgba(255, 255, 255, 0.86);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(3px);
}
body.custom-bg-theme .widget-loading,
body.custom-bg-theme .empty-state {
  background: rgba(255, 255, 255, 0.86);
  border-radius: var(--radius);
  backdrop-filter: blur(3px);
  padding: 14px 18px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: clamp(10px, 1.6vw, 20px);
  flex-wrap: wrap;
  padding: clamp(10px, 1.4vw, 16px) var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* Loud on purpose -- real actions taken while impersonating are real
   actions on that person's account, so this must never be mistakable for
   a normal session. Sits above everything, including the sticky topbar. */
#impersonationBanner {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #7a1f9e;
  color: #fff;
  padding: 8px 20px;
  font-size: var(--fs-sm);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
#impersonationBanner strong {
  font-weight: 700;
}
#impersonationBanner button {
  background: #fff;
  color: #7a1f9e;
  border: none;
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: var(--fs-xs);
  font-weight: 700;
  cursor: pointer;
}
body.has-impersonation-banner .topbar {
  top: 34px;
}

/* Persistent clock in/out bar for the four hourly employees -- sits below
   the impersonation banner (if both happen to be showing) and above the
   topbar, same sticky-stacking approach. */
#clockBar {
  position: sticky;
  top: 0;
  z-index: 19;
  background: #1f7a4d;
  color: #fff;
  padding: 8px 20px;
  font-size: var(--fs-sm);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
#clockBar strong {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
#clockBar button {
  background: #fff;
  color: #1f7a4d;
  border: none;
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: var(--fs-xs);
  font-weight: 700;
  cursor: pointer;
}
/* Both banners call document.body.prepend() -- whichever runs second (the
   clock bar; see common.js) ends up as the visually topmost element, so the
   impersonation banner is the one that needs pushing down when both show. */
body.has-clock-bar #impersonationBanner {
  top: 34px;
}
body.has-clock-bar .topbar {
  top: 34px;
}
body.has-clock-bar.has-impersonation-banner .topbar {
  top: 68px;
}

/* Every control living in the topbar's right-hand cluster -- Add X,
   Log Out, the nav icon badges, the avatar -- shares this one 36px
   height so the row reads as one coordinated group instead of a jumble
   of differently-sized buttons and icons. Vertical padding is zeroed out
   and swapped for flex centering so the explicit height isn't fighting
   the buttons' own padding; horizontal padding is untouched. */
.topbar .primary-btn,
.topbar .ghost-btn {
  height: var(--ctl-h);
  padding-top: 0;
  padding-bottom: 0;
  display: inline-flex;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: auto;
}
.brand-mark {
  width: clamp(40px, calc(40px + (100vw - 1100px) * 0.02), 66px);
  height: clamp(40px, calc(40px + (100vw - 1100px) * 0.02), 66px);
  border-radius: var(--radius);
  background: #fff;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
  object-fit: contain;
  padding: 3px;
  box-sizing: border-box;
  border: 1px solid var(--border);
}
.brand h1 {
  font-size: var(--fs-title);
  line-height: 1.15;
  margin: 0;
}
.subtitle {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin: 2px 0 0;
}

/* ---------- Main navigation: vertical icon rail + click-open submenu ---------- */

:root {
  --side-nav-w: 64px;
  --side-nav-panel-w: 248px;
}

/* The rail is deliberately dark in every theme (light, dark, LSU, sci-fi) so
   it reads as one fixed piece of chrome; its own tokens live here rather
   than in :root so page themes can't recolor it by accident. */
.main-nav {
  --nav-bg: #161f1b;
  --nav-panel-bg: #1f2b26;
  --nav-text: #b9c4bd;
  --nav-text-strong: #ffffff;
  --nav-hover: rgba(255, 255, 255, 0.08);
  --nav-active-bg: rgba(255, 255, 255, 0.12);
  --nav-divider: rgba(255, 255, 255, 0.1);
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--side-nav-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 0;
  background: var(--nav-bg);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  z-index: 25;
}
.main-nav::-webkit-scrollbar {
  display: none;
}
.main-nav:empty {
  display: none;
}
body.has-side-nav {
  padding-left: var(--side-nav-w);
}

.main-nav-item {
  width: 100%;
  display: flex;
  justify-content: center;
}
.main-nav-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--nav-text);
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}
.main-nav-link svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.main-nav-link:hover,
.main-nav-item.is-open > .main-nav-link {
  background: var(--nav-hover);
  color: var(--nav-text-strong);
}
.main-nav-link.is-active {
  background: var(--nav-active-bg);
  color: var(--nav-text-strong);
}
/* Accent bar on the rail's left edge marks the section you're in. */
.main-nav-link.is-active::before {
  content: '';
  position: absolute;
  left: calc((var(--side-nav-w) - 44px) / -2);
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}
.main-nav-link:focus-visible,
.main-nav-panel-close:focus-visible,
.main-nav-dropdown-link:focus-visible,
.side-nav-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Submenu: a full-height vertical panel opening beside the rail, over the
   page (fixed, so it never shifts the content underneath). */
.main-nav-dropdown {
  display: none;
  position: fixed;
  top: 0;
  bottom: 0;
  left: var(--side-nav-w);
  width: var(--side-nav-panel-w);
  max-width: calc(100vw - var(--side-nav-w));
  flex-direction: column;
  background: var(--nav-panel-bg);
  border-right: 1px solid var(--nav-divider);
  box-shadow: 10px 0 28px rgba(0, 0, 0, 0.28);
  overflow-y: auto;
  animation: main-nav-panel-in 0.16s ease-out;
}
.main-nav-item.is-open .main-nav-dropdown {
  display: flex;
}
@keyframes main-nav-panel-in {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .main-nav-dropdown {
    animation: none;
  }
}
.main-nav-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 12px 14px 20px;
  border-bottom: 1px solid var(--nav-divider);
  color: var(--nav-text-strong);
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.main-nav-panel-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--nav-text);
  font-size: var(--fs-xl);
  line-height: 1;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}
.main-nav-panel-close:hover {
  background: var(--nav-hover);
  color: var(--nav-text-strong);
}
.nav-sub-count {
  flex-shrink: 0;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #d32f2f;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 20px;
  text-align: center;
}
.main-nav-dropdown-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--nav-divider);
  color: var(--nav-text);
  font-size: var(--fs-md);
  font-weight: 500;
  text-decoration: none;
}
.main-nav-dropdown-link:hover {
  background: var(--nav-hover);
  color: var(--nav-text-strong);
}
.main-nav-dropdown-link.is-active {
  background: var(--nav-active-bg);
  color: var(--nav-text-strong);
  font-weight: 600;
}
.main-nav-dropdown-link.is-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
}

/* Phone-only hamburger in the topbar that slides the rail in. */
.side-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.side-nav-toggle svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}
@media (max-width: 720px) {
  body.has-side-nav {
    padding-left: 0;
  }
  .side-nav-toggle {
    display: inline-flex;
  }
  .main-nav {
    left: calc(-1 * var(--side-nav-w) - 24px);
    transition: left 0.2s ease;
  }
  body.side-nav-open .main-nav {
    left: 0;
    box-shadow: 6px 0 24px rgba(0, 0, 0, 0.35);
  }
}

@media print {
  .main-nav,
  .side-nav-toggle {
    display: none !important;
  }
  body.has-side-nav {
    padding-left: 0;
  }
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
}
.current-user {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
/* Phones: the icon row, avatar, "Signed in as…" text and Log Out button must be
   able to wrap inside the header instead of pushing the page ~30px wider than
   the screen (every non-dashboard page scrolled sideways before this). */
@media (max-width: 600px) {
  /* Tap targets: small in-table/in-list controls get at least ~36px of touch height. */
  .month-calendar-add {
    min-height: 32px;
    min-width: 40px;
  }
  .lot-trace-link {
    display: inline-block;
    padding-block: 8px;
  }
  input[type='checkbox'],
  input[type='radio'] {
    width: 24px;
    height: 24px;
  }
  /* The wrapped header is 150-350px tall on a phone; stuck to the top it would cover
     up to half the screen while scrolling, so it scrolls away with the page instead. */
  .topbar {
    position: static;
  }
  .topbar .user-menu {
    flex-wrap: wrap;
    max-width: 100%;
    min-width: 0;
  }
  .topbar .current-user {
    flex: 1 1 110px;
    min-width: 0;
  }
  /* A header with several action buttons (Stock) lays them out two to a row, evenly, instead of a ragged stack */
  .topbar.has-action-grid > .ghost-btn:not(.hidden),
  .topbar.has-action-grid > .primary-btn:not(.hidden) {
    flex: 1 1 calc(50% - 12px);
    justify-content: center;
    min-width: 0;
  }
}
/* Nav notification icons (Messages, Tasks) — app-style icon with a small
   red count badge in the corner, like Mail/Slack, instead of a text pill. */
.nav-badges {
  display: flex;
  align-items: center;
  gap: 2px;
}
.nav-icon-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--ctl-h);
  height: var(--ctl-h);
  border-radius: 50%;
  color: var(--text);
  font-size: var(--fs-lg);
  text-decoration: none;
  transition: background 0.15s;
}
.nav-icon-badge:hover {
  background: var(--bg);
}
/* The same red in every theme, because the white number has to stay readable on it. */
.nav-icon-badge .badge-count,
.main-nav-link .badge-count {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #d32f2f;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--surface);
}
.main-nav-link .badge-count {
  top: 0;
  right: 0;
  box-shadow: 0 0 0 2px var(--nav-bg);
}
.month-label {
  font-weight: 600;
  min-width: 150px;
  text-align: center;
}

/* "What's new" Marketing feed widget, injected into every page's topbar
   (public/common.js injectMarketingFeedWidget) -- same icon-badge shell as
   .nav-icon-badge above, with a click-toggled dropdown panel reusing
   .main-nav-dropdown's look, right-aligned since it lives on the topbar's
   right side rather than under the left nav. */
.marketing-feed-widget {
  position: relative;
}
.marketing-feed-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 30;
}
.marketing-feed-widget.is-open .marketing-feed-dropdown {
  display: block;
}
.marketing-feed-item {
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
}
.marketing-feed-item:hover {
  background: var(--bg);
}
.marketing-feed-item img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.marketing-feed-item-title {
  font-size: var(--fs-sm);
  font-weight: 600;
}
.marketing-feed-item-sub {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: capitalize;
}

/* Custom Tank picker (Start New Tank modal) -- a native <select> popup
   isn't reliably scrollable on every device once options exceed the
   available drop-down space (reported: no way to scroll to the 75-gallon
   tanks). This is a real DOM list with its own scroll container instead,
   same overlay idiom as .marketing-feed-dropdown above. */
.tank-picker {
  position: relative;
}
.tank-picker-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.tank-picker-trigger:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.tank-picker-caret {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  margin-left: 8px;
}
.tank-picker-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 40;
}
.tank-picker-list[hidden] {
  display: none;
}
.tank-picker-group-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding: 6px 8px 2px;
}
.tank-picker-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  cursor: pointer;
}
.tank-picker-option:hover,
.tank-picker-option:focus-visible {
  background: var(--bg);
}
.tank-picker-option.is-selected {
  background: var(--primary);
  color: var(--on-primary);
}
.tank-picker-empty {
  padding: 8px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* Profile photo / avatar (nav thumbnail, message rows, member chips, profile page) */
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-initials {
  background: var(--primary);
  color: var(--on-primary);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.avatar.is-small {
  width: 22px;
  height: 22px;
  font-size: 10px;
}
.avatar.avatar-large {
  width: 96px;
  height: 96px;
  font-size: 28px;
}
/* Matches .nav-icon-badge's 36px exactly -- the nav avatar sits directly
   beside the Messages/Tasks icons and was noticeably smaller than both,
   the main thing that made the topbar's right-hand cluster look uneven. */
.avatar.is-nav {
  width: var(--ctl-h);
  height: var(--ctl-h);
  font-size: var(--fs-md);
}
.profile-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--ctl-h);
  height: var(--ctl-h);
  border-radius: 50%;
  line-height: 0;
  transition: background 0.15s;
}
.profile-link:hover {
  background: var(--bg);
}
.profile-photo-panel {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px;
}
.profile-photo-panel {
  flex-wrap: wrap;
}
.profile-photo-panel form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.profile-photo-panel form {
  min-width: 0;
  max-width: 100%;
}
.profile-photo-panel input[type='file'] {
  max-width: 100%;
}
.background-preview-thumb {
  width: 140px;
  height: 88px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg) center / cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  text-align: center;
  padding: 6px;
  flex-shrink: 0;
}
.background-preview-thumb.has-image {
  background-image: var(--thumb-url);
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* Shared feedback for every button variant: a real transition instead of
   an instant color snap, a pressed-down :active state for tactile
   feedback, a visible keyboard focus ring (buttons got none before --
   inputs were the only focusable elements with one), and a disabled
   state that actually looks disabled instead of being indistinguishable
   from enabled. */
.icon-btn,
.ghost-btn,
.primary-btn,
.danger-btn {
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    transform 0.08s ease;
}
.icon-btn:active,
.ghost-btn:active,
.primary-btn:active,
.danger-btn:active {
  transform: scale(0.96);
}
.icon-btn:focus-visible,
.ghost-btn:focus-visible,
.primary-btn:focus-visible,
.danger-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
/* Every other clickable thing (seg/filter/link buttons, custom controls, links) gets the same visible keyboard
   focus ring. :where() keeps this at zero specificity, so any component's own focus style still wins. */
:where(button, [role='button'], a[href], summary):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.icon-btn:disabled,
.ghost-btn:disabled,
.primary-btn:disabled,
.danger-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Applied by withLoadingState() in common.js during an in-flight submit --
   a spinner replaces the button's own text (kept in the DOM for width
   stability, just visually hidden) so the button reads as busy rather than
   just looking disabled. */
.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.is-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: is-loading-spin 0.6s linear infinite;
}
.ghost-btn.is-loading::after {
  border-color: rgba(20, 30, 25, 0.25);
  border-top-color: var(--text);
}
@keyframes is-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Same treatment for hoverable rows/cards elsewhere in the app -- these
   already had a hover color, just no transition, so it used to snap. */
table.runs-table tbody tr,
.task-card,
.checklist-att-add,
.sop-card,
.month-calendar-add,
.channel-list-item,
.user-click-item,
.main-nav-dropdown-link {
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  font-size: var(--fs-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover {
  background: var(--bg);
}
a.icon-btn,
a.ghost-btn,
a.primary-btn {
  text-decoration: none;
}

.ghost-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.55em 1.1em;
  font-size: var(--fs-sm);
}
.ghost-btn:hover {
  background: var(--bg);
}
.ghost-btn.small {
  padding: 0.42em 0.85em;
  font-size: var(--fs-xs);
}
.ghost-btn.is-active {
  background: var(--primary-tint);
  border-color: var(--primary);
  color: var(--primary-text);
}

.primary-btn {
  border: none;
  background: var(--primary);
  color: var(--on-primary);
  border-radius: var(--radius-sm);
  padding: 0.7em 1.25em;
  font-size: var(--fs-sm);
  font-weight: 600;
}
.primary-btn:hover {
  background: var(--primary-dark);
  color: var(--on-primary-strong);
}
.primary-btn.small {
  padding: 0.42em 0.85em;
  font-size: var(--fs-xs);
}

.danger-btn {
  border: 1px solid var(--danger);
  background: var(--danger-tint);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 0.7em 1.25em;
  font-size: var(--fs-sm);
  font-weight: 600;
}
.danger-btn:hover {
  background: var(--danger);
  color: #fff;
}

.weeks-container {
  padding: var(--gutter);
  display: flex;
  flex-direction: column;
  gap: var(--gutter);
  /* Fills the window (tables use the space instead of leaving dead margins and scrolling);
     form/text pages opt back into a readable width with .is-readable. */
  max-width: none;
  margin: 0 auto;
}

.week-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.week-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--primary-tint);
}
.week-header h2 {
  font-size: var(--fs-md);
  margin: 0;
}
.week-header .week-range {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.week-header .week-count {
  margin-left: auto;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.table-wrap {
  overflow-x: auto;
}
.table-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* A form doubling as its own panel (no modal-header above it to create
   breathing room) needs a top inset to match the 22px the global `form`
   rule already gives its other three sides -- otherwise the first field
   row sits flush against the panel's top border. */
form.table-panel {
  padding-top: 22px;
}

/* Interaction-timeline / action-item cards: same panel look as
   .table-panel, but with real padding on every side so the type/date
   header, body text, and action button don't hug the card edges. */
.interaction-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

table.runs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  min-width: 900px;
}

table.runs-table.is-compact {
  min-width: 0;
  font-size: var(--fs-xs);
}

.sm-line-ship-cell {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Nested SMART-goals block under a review row (hr-detail.js) */
.goals-wrap {
  padding: 10px 0 14px 20px;
  border-left: 2px solid var(--border);
  margin-left: 4px;
}

.sort-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.sort-btn:hover {
  color: var(--text);
}
.sort-btn.is-active {
  color: var(--primary-text);
}
.sort-btn .sort-arrow {
  font-size: var(--fs-xs);
}
/* Arrows drawn by CSS (not text) so a stacked table's card labels, taken from the header text, stay clean.
   The primary sort is the brand colour; a "then by" column is muted with a smaller arrow. */
.sort-btn.is-asc::after,
.sort-btn.is-desc::after {
  font-size: var(--fs-xs);
  line-height: 1;
}
.sort-btn.is-asc::after {
  content: '\25B2';
}
.sort-btn.is-desc::after {
  content: '\25BC';
}
.sort-btn.is-then {
  color: var(--text);
}
.sort-btn.is-then::after {
  font-size: 0.6em;
  opacity: 0.7;
}
/* Touch screens: the header text alone is ~18px tall, so give each sort button the 44px tap area the app uses. */
@media (pointer: coarse) {
  .sort-btn {
    min-height: 44px;
    min-width: 44px;
  }
}
/* Phones: a stacked table's sort buttons sit in one wrapping row above the cards; the 44px button is the tap area,
   so the cell itself needs no padding of its own. */
@media (max-width: 760px) {
  .is-stacked.has-head-buttons thead th:has(> .sort-btn) {
    padding: 0 8px;
  }
}
.sort-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

table.runs-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.runs-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  white-space: nowrap;
}

table.runs-table tbody tr:hover {
  background: var(--bg);
  cursor: pointer;
}
table.runs-table tbody tr:last-child td {
  border-bottom: none;
}
table.runs-table tr.is-total td {
  border-top: 2px solid var(--border);
  background: var(--bg);
}
table.runs-table tr.stock-group-header td {
  background: var(--bg);
  border-top: 2px solid var(--border);
}
table.runs-table tr.stock-variant-row td {
  color: var(--text-muted);
  font-size: var(--fs-xs);
}
table.runs-table tr.stock-variant-row td:first-child {
  padding-left: 24px;
}
.stock-variant-indent {
  color: var(--text-muted);
  margin-right: 2px;
}
/* Negative on-hand can't physically exist -- flags the row (and its group
   header, if the drift shows up in the cumulative total) so it reads as a
   problem to reconcile, not a number to trust. */
table.runs-table tr.is-negative-stock td {
  background: var(--danger-tint);
}
.negative-value {
  color: var(--danger);
  font-weight: 600;
}
table.runs-table tr.is-clickable {
  cursor: pointer;
}
table.runs-table tr.is-clickable:hover td {
  background: var(--primary-tint);
}
.stock-group-toggle {
  width: 22px;
  height: 22px;
  padding: 0;
  margin-right: 4px;
  font-size: var(--fs-xs);
  line-height: 1;
  vertical-align: middle;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
}
.status-planned {
  background: #eceff1;
  color: #546e7a;
}
.status-fermenting {
  background: #fff3cd;
  color: #7a5f12;
}
.status-harvested {
  background: #dcefff;
  color: #1b5faa;
}
.status-freezedrying {
  background: #e3dcff;
  color: #5b3fb0;
}
.status-freezedrycomplete {
  background: #d6f0e6;
  color: #1c6b4a;
}
.status-packaging {
  background: #fff0d6;
  color: #9a6a10;
}
.status-labtesting {
  background: #ffe3d6;
  color: #a04517;
}
.status-resultsin {
  background: #d9f0ff;
  color: #1a6fa3;
}
.status-shipped {
  background: var(--primary-tint);
  color: var(--primary-text);
}
.status-down {
  background: #fbdcdc;
  color: var(--danger);
}
.status-active {
  background: #d6f0e6;
  color: #1c6b4a;
}
.status-invited {
  background: #dcefff;
  color: #1b5faa;
}
.status-suspended {
  background: #fff3cd;
  color: #8a6d1a;
}
.status-deleted {
  background: #fbdcdc;
  color: var(--danger);
}

/* Workload Planner: one color per product, assigned dynamically (see
   workload-planner.js) so the same 12-swatch palette covers whatever mix
   of products is actually scheduled that week. */
.product-color-1 {
  background: #dbeafe;
  color: #1e40af;
}
.product-color-2 {
  background: #dcfce7;
  color: #166534;
}
.product-color-3 {
  background: #fef3c7;
  color: #92400e;
}
.product-color-4 {
  background: #ede9fe;
  color: #5b21b6;
}
.product-color-5 {
  background: #ffe4d5;
  color: #9a3412;
}
.product-color-6 {
  background: #cffafe;
  color: #155e75;
}
.product-color-7 {
  background: #fce7f3;
  color: #9d174d;
}
.product-color-8 {
  background: #ecfccb;
  color: #4d7c0f;
}
.product-color-9 {
  background: #e0e7ff;
  color: #3730a3;
}
.product-color-10 {
  background: #fee2e2;
  color: #991b1b;
}
.product-color-11 {
  background: #ccfbf1;
  color: #115e59;
}
.product-color-12 {
  background: #f5e9da;
  color: #78502f;
}

.planner-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}
.planner-chip {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--fs-sm);
  cursor: grab;
}
.planner-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.planner-day {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.planner-day.is-today {
  border-color: var(--primary);
}
.planner-day-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-align: center;
}
.planner-zone {
  min-height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.planner-zone-start.is-drop-target {
  background: rgba(47, 122, 79, 0.12);
  outline: 1px dashed var(--primary);
}
.planner-zone-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.planner-pill {
  font-size: var(--fs-xs);
  padding: 3px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  cursor: grab;
}
.planner-pill.is-unset {
  border-style: dashed;
}
.planner-pill.is-readonly {
  cursor: default;
  border-style: dotted;
}
.planner-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.planner-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
}
.planner-legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}
.exec-empty {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-style: italic;
}

.planner-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) {
  .planner-columns {
    grid-template-columns: 1fr;
  }
}

/* ---------- Production Plan: Gantt preview (gantt-widget.js) ---------- */
/* Every tank shows by default. --gantt-height is set only when someone drags the chart to a height of their own. */
.gantt-scroll {
  overflow: auto;
  height: var(--gantt-height, auto);
  border-radius: var(--radius-sm);
}
.gantt-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg);
}
.gantt-scroll::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.gantt-scroll::-webkit-scrollbar-track {
  background: var(--bg);
  border-radius: var(--radius-sm);
}
.gantt-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius-sm);
}
.gantt-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}
.gantt-grid {
  display: grid;
  position: relative;
  min-width: 100%;
  width: max-content;
}
.gantt-corner {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 4;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.gantt-day-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 6px 4px;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-left: 1px solid var(--border);
  white-space: nowrap;
}
.gantt-day-header.is-today {
  color: var(--primary);
}
.gantt-tank-label {
  position: sticky;
  left: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.gantt-cell {
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}
/* Grid placement comes from data (cssVars in gantt-widget.js); the stylesheet
   owns the rules. Shared by the light pages and the exec dashboards. */
.gantt-grid {
  grid-template-columns: 56px repeat(var(--half-days, 14), minmax(32px, 1fr));
  grid-template-rows: auto repeat(var(--tanks, 1), minmax(20px, 1fr));
  min-height: 100%;
}
.gantt-grid:not(.is-sized) {
  grid-template-rows: auto repeat(var(--tanks, 1), 28px);
}
.gantt-height-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.gantt-height-handle {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  cursor: ns-resize;
  touch-action: none;
  border-radius: var(--radius-sm);
}
.gantt-height-handle::before {
  content: '';
  width: 56px;
  height: 4px;
  border-radius: 2px;
  background: var(--exec-border, var(--border));
  transition: background-color 120ms ease-out;
}
.gantt-height-handle:hover::before,
.gantt-height-handle.is-active::before {
  background: var(--exec-accent, var(--primary));
}
.gantt-height-handle:focus-visible {
  outline: 2px solid var(--exec-accent, var(--primary));
}
@media (pointer: coarse) {
  .gantt-height-handle {
    height: 44px;
  }
}
.gantt-day-header {
  grid-row: 1;
  grid-column: var(--col) / span 2;
}
.gantt-tank-label {
  grid-row: var(--row);
  grid-column: 1;
}
.gantt-cell {
  grid-row: var(--row);
  grid-column: var(--col) / span 2;
}
.gantt-bar {
  grid-row: var(--row);
  grid-column: var(--col-start) / var(--col-end);
}
.gantt-cell.is-today {
  background: rgba(47, 122, 79, 0.06);
}
.gantt-bar {
  display: block;
  align-self: stretch;
  margin: 1px 2px;
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.3;
  overflow: hidden;
  z-index: 1;
  cursor: pointer;
  text-decoration: none;
}
.gantt-bar:hover {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}
.gantt-bar.is-inert {
  cursor: default;
}
.gantt-bar.is-inert:hover {
  outline: none;
}

.plan-entry-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.plan-entry-row:last-child {
  border-bottom: none;
}
.plan-entry-row label {
  flex: 1 1 130px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.plan-entry-row select {
  width: 100%;
}

@media (prefers-color-scheme: dark) {
  .status-planned {
    background: #2a2f31;
    color: #b7c0ba;
  }
  .status-fermenting {
    background: #3a331a;
    color: #e0c268;
  }
  .status-harvested {
    background: #1a2c3d;
    color: #7db3e8;
  }
  .status-freezedrying {
    background: #2b2440;
    color: #b39ff0;
  }
  .status-freezedrycomplete {
    background: #17332a;
    color: #6fd3a5;
  }
  .status-packaging {
    background: #3a2e12;
    color: #e0ab5a;
  }
  .status-labtesting {
    background: #3a2618;
    color: #ef9c6d;
  }
  .status-resultsin {
    background: #17303d;
    color: #77c4ee;
  }
  .status-shipped {
    background: var(--primary-tint);
    color: #7fe0ac;
  }
  .status-down {
    background: #3a1c1c;
    color: #ef8f8f;
  }
  .status-active {
    background: #17332a;
    color: #6fd3a5;
  }
  .status-invited {
    background: #17303d;
    color: #77c4ee;
  }
  .status-suspended {
    background: #3a331a;
    color: #e0c268;
  }
  .status-deleted {
    background: #3a1c1c;
    color: #ef8f8f;
  }

  #lr_flag.is-yellow {
    background: #3a331a;
    color: #e0c268;
    border-color: #e0c268;
  }
  #lr_flag.is-red {
    background: #3a1c1c;
    color: #ef8f8f;
    border-color: #ef8f8f;
  }
  #lr_flag option[value='yellow'] {
    color: #e0c268;
  }
  #lr_flag option[value='red'] {
    color: #ef8f8f;
  }

  .product-color-1 {
    background: #1a2c3d;
    color: #7db3e8;
  }
  .product-color-2 {
    background: #17332a;
    color: #6fd3a5;
  }
  .product-color-3 {
    background: #3a331a;
    color: #e0c268;
  }
  .product-color-4 {
    background: #2b2440;
    color: #b39ff0;
  }
  .product-color-5 {
    background: #3a2618;
    color: #ef9c6d;
  }
  .product-color-6 {
    background: #17303d;
    color: #77c4ee;
  }
  .product-color-7 {
    background: #3a1830;
    color: #e88fc0;
  }
  .product-color-8 {
    background: #2a3a12;
    color: #b8db6a;
  }
  .product-color-9 {
    background: #20244a;
    color: #a3aef0;
  }
  .product-color-10 {
    background: #3a1c1c;
    color: #ef8f8f;
  }
  .product-color-11 {
    background: #123330;
    color: #5fd6c4;
  }
  .product-color-12 {
    background: #332619;
    color: #d1a978;
  }
}

.empty-state {
  max-width: 1400px;
  margin: 40px auto;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.hidden {
  display: none !important;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  /* Figure-ground: dim the page enough that the dialog is clearly the one thing in focus. */
  background: rgba(10, 15, 12, 0.6);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(12px, 5vw, 40px) clamp(8px, 2vw, 16px);
  overflow-y: auto;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 900px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.modal.modal-wide {
  max-width: 1180px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px var(--pad-modal);
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  margin: 0;
  font-size: var(--fs-lg);
}

form {
  padding: 6px var(--pad-modal) var(--pad-modal);
}

fieldset {
  min-width: 0; /* a fieldset otherwise refuses to shrink below its widest child and pushes the page sideways */
  border: none;
  border-top: 1px solid var(--border);
  padding: 16px 0;
  margin: 0;
}
fieldset:first-of-type {
  border-top: none;
}

legend {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  padding: 0;
  margin-bottom: 10px;
}

.grid {
  display: grid;
  gap: 14px;
}
.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}
.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}
.grid-day {
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.span-2 {
  grid-column: span 2;
}
.span-3 {
  grid-column: span 3;
}

@media (max-width: 720px) {
  .grid-2,
  .grid-3,
  .grid-day {
    grid-template-columns: 1fr;
  }
  .span-2,
  .span-3 {
    grid-column: span 1;
  }
}

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
}

/* Browsers give <select> and <input type="date"> their own intrinsic
   sizing (native arrow / calendar-icon chrome) that doesn't obey padding
   the same way plain text inputs do, and with no line-height set at all
   the "normal" default varies by element and font -- that combination is
   exactly what was making fields sit at different heights, with text
   riding high or low, when several field types shared a grid row. Fixing
   it needs three things: a shared line-height, a fixed height on every
   single-line field, and dropping <select>'s native chrome in favor of a
   hand-drawn arrow that respects the same box. */
input,
textarea,
select {
  font-family: inherit;
  font-size: var(--fs-sm);
  line-height: 1.3;
  padding: 0.6em 0.8em;
  border: 1px solid var(--field-border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}
input:not([type='checkbox']):not([type='radio']):not([type='range']),
select {
  height: 2.75em;
}
select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%236b756f' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 11px 7px;
}
@media (prefers-color-scheme: dark) {
  /* The chevron is a data-URI SVG -- it can't read --text-muted, so its
     stroke color needs its own dark-mode swap to stay visible. */
  select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%2398a29c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1.5 6 6.5 11 1.5'/%3E%3C/svg%3E");
  }
}
input:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

.day-col {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.day-col h4 {
  margin: 0 0 2px;
  font-size: var(--fs-xs);
  color: var(--text);
}

.ingredient-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.ingredient-row {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 8px;
  align-items: center;
}
.ingredient-row input {
  width: 100%;
}
.remove-ingredient {
  border: none;
  background: var(--danger-tint);
  color: var(--danger);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  font-size: var(--fs-md);
}

textarea {
  width: 100%;
  resize: vertical;
}

.modal-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.spacer {
  flex: 1;
}

.detail-row td {
  background: var(--bg);
  white-space: normal;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 12px;
  padding: 14px 4px;
}
.detail-item .k {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.detail-item .v {
  font-size: var(--fs-sm);
}
.detail-actions {
  display: flex;
  gap: 8px;
  padding: 6px 4px 12px;
}

/* Dashboard widgets */

.widget-grid {
  padding: var(--gutter);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 340px));
  gap: clamp(12px, 1.5vw, 18px);
  max-width: 1400px;
  margin: 0 auto;
}

.widget-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  text-decoration: none;
  color: var(--text);
  transition:
    box-shadow 0.15s,
    transform 0.15s;
}
.widget-card:hover {
  box-shadow: 0 4px 14px rgba(20, 30, 25, 0.12);
  transform: translateY(-1px);
}

.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.widget-header h2 {
  font-size: var(--fs-md);
  margin: 0;
}
.widget-arrow {
  color: var(--primary);
  font-size: var(--fs-lg);
}

.widget-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.widget-loading {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin: 0;
}

.widget-section + .widget-section {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.widget-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.widget-line {
  font-size: var(--fs-md);
  margin-bottom: 6px;
}
.widget-sub {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* Standalone search panel (not a <form>, so it doesn't get the global form inset) */
.lookup-panel {
  padding: 16px var(--pad-modal);
}
.lookup-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inventory-widget-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: var(--fs-sm);
}
.inventory-widget-item .widget-sub {
  white-space: nowrap;
}

.progress-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 4px;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  /* --pct is a data value (0-100), not a layout style; JS sets only this
     custom property, CSS owns the actual width rule. */
  width: calc(var(--pct, 0) * 1%);
}

/* Production schedule — tank activity-ring board */

.schedule-slider-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.schedule-slider-step {
  /* 44px is Apple's minimum recommended touch target -- these are the
     prev/next/today controls production staff will be tapping on iPads. */
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.schedule-slider-step:active {
  background: var(--primary-tint);
}
.schedule-slider-track-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.schedule-slider-date {
  font-size: var(--fs-md);
  font-weight: 700;
  text-align: center;
}
.schedule-slider-date .relative {
  font-weight: 500;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}
.schedule-slider-input {
  width: 100%;
  height: 32px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  touch-action: pan-y;
}
.schedule-slider-input::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
}
.schedule-slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  margin-top: -11px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.schedule-slider-input::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--border);
}
.schedule-slider-input::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.schedule-slider-today-btn {
  flex-shrink: 0;
}

.tank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
  gap: 16px;
}
@media (max-width: 720px) {
  /* Cards were sitting flush against the grid edge and each other at phone
     widths -- give the ring room to breathe instead of hugging its neighbors. */
  .tank-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr));
    gap: 22px 14px;
  }
  .tank-ring-card {
    padding: 18px 8px;
  }
}
.tank-ring-card {
  /* No box — the ring itself is the card. Just a plain flex layout on the
     page background, per design direction. */
  background: none;
  border: none;
  padding: 14px 12px;
  cursor: pointer;
  transition: transform 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: 240px;
  gap: 4px;
}
.tank-ring-card:hover {
  transform: scale(1.035);
}
.tank-ring-card.is-down .tank-ring-letter {
  color: var(--danger);
}
/* Dim the ring graphic only -- not the tank letter, "Empty" label or product text. */
.tank-ring-card.is-empty .tank-ring-wrap svg {
  opacity: 0.55;
}
.tank-ring-letter {
  font-size: var(--fs-xl);
  font-weight: 800;
  color: var(--primary-text);
  margin-bottom: 10px;
}
.tank-ring-wrap {
  position: relative;
  width: 168px;
  height: 168px;
  margin: 0 auto;
  border-radius: 50%;
  /* A round backdrop, not a box -- just enough to keep the ring from
     dissolving into the busy background photo behind it. */
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 1px 6px rgba(20, 30, 25, 0.08);
}
.tank-ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.tank-ring-track {
  fill: none;
  stroke: var(--border);
}
.tank-ring-arc {
  fill: none;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}
.tank-ring-arc.is-green {
  stroke: var(--success);
}
.tank-ring-arc.is-yellow {
  stroke: var(--warning);
}
.tank-ring-arc.is-red {
  stroke: var(--danger);
}
.tank-ring-arc.is-none {
  stroke: var(--border);
}
.tank-ring-arc.is-progress {
  stroke: var(--primary);
}

.tank-ring-center-select {
  position: absolute;
  inset: 44px;
  /* The site-wide `select { height: 36px }` rule would otherwise fight
     this element's inset-driven sizing (an explicit height, combined
     with both top and bottom set via inset, over-constrains the box and
     the explicit height wins) -- auto hands sizing back to inset alone. */
  height: auto;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-align: center;
  text-align-last: center;
  cursor: pointer;
  padding: 0 2px;
  /* Drop the native dropdown arrow -- it's rendered as a status label
     first, a control second, and the arrow's reserved space is exactly
     what was truncating longer labels like "Freeze Drying". */
  -webkit-appearance: none;
  appearance: none;
}
.tank-ring-center-select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.tank-ring-center-static {
  position: absolute;
  inset: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
  color: var(--text);
  pointer-events: none;
}

.tank-ring-product {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 14px;
  min-height: 16px;
}

/* "Next up"/"should be started" plan reference on a Tank Status card (see
   nextDraftPlanForTank in schedule.js) -- its own status-badge tone
   (status-fermenting's amber) means "start now", status-planned's neutral
   tone means "not yet, just penciled in". */
.tank-ring-card.has-harvest-change {
  border-radius: var(--radius);
  box-shadow: 0 0 0 2px var(--danger);
}
.tank-harvest-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--danger-tint);
  color: var(--danger);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.tank-harvest-strip button {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--danger);
  border-radius: 999px;
  background: var(--surface);
  color: var(--danger);
  font: inherit;
  cursor: pointer;
}
.tank-harvest-tag {
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--danger-tint);
  color: var(--danger);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-align: center;
}
.tank-harvest-note {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--danger-tint);
  color: var(--danger);
  font-size: var(--fs-sm);
}
.tank-next-plan {
  display: block;
  margin-top: 10px;
  cursor: pointer;
  white-space: normal;
  line-height: 1.3;
}
.tank-next-plan:hover {
  filter: brightness(0.95);
}

/* Freeze Dryer board cards -- a plain status card, unlike the tank ring
   visualization (no temp/pH readings apply to a dryer slot). */
.dryer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: transform 0.15s ease;
  text-align: center;
}
.dryer-card:hover {
  transform: scale(1.03);
}
.dryer-card.is-empty .dryer-letter {
  color: var(--text-muted);
}
.dryer-card.is-down .dryer-letter {
  color: var(--danger);
}
.dryer-letter {
  font-size: var(--fs-xl);
  font-weight: 800;
  color: var(--primary-text);
  margin-bottom: 8px;
}
.dryer-product {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 8px;
  min-height: 16px;
}

/* Side notes under each card explaining what each ring means, in the same
   color the ring itself is drawn in — dot + label + current value. */
.tank-ring-legend-notes {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-start;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 168px;
}
.legend-note {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  width: 100%;
}
.legend-label {
  color: var(--text-muted);
  flex: 1;
  text-align: left;
}
.legend-value {
  color: var(--text);
  font-weight: 700;
}

.tank-flags {
  display: flex;
  gap: 12px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.flag-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}
.flag-dot.green {
  background: var(--success);
}
.flag-dot.yellow {
  background: var(--warning);
}
.flag-dot.red {
  background: var(--danger);
}
.flag-dot.none {
  background: var(--border);
}
.flag-dot.progress {
  background: var(--primary);
}

.reading-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs);
}
.reading-row:last-child {
  border-bottom: none;
}

/* Kanban page */

.kanban-container {
  padding: 24px;
  max-width: none;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Overdue tasks banner -- shown above the calendar regardless of which
   week/month it's currently scrolled to, since an overdue task could be
   from well outside that range. */
.overdue-banner {
  background: var(--danger-tint);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.overdue-banner strong {
  color: var(--danger);
  font-size: var(--fs-sm);
}
.overdue-banner-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.overdue-banner-item {
  background: var(--surface);
  border: 1px solid var(--danger);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: var(--fs-xs);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}
.overdue-banner-item:hover {
  background: var(--danger-tint);
}
.overdue-banner-date {
  color: var(--text-muted);
  margin-left: 4px;
}

.section-title {
  font-size: var(--fs-md);
  font-weight: 700;
  margin: 0 0 12px;
}

/* Collapsed-by-default page sections (e.g. Stock page) -- a native
   <details>/<summary> so no JS is needed to track open/closed state. */
.collapsible-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.collapsible-header {
  list-style: none;
  cursor: pointer;
  padding: 14px 18px;
  font-size: var(--fs-md);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
.collapsible-header::-webkit-details-marker {
  display: none;
}
.collapsible-header::before {
  content: '\25B8';
  color: var(--text-muted);
  transition: transform 0.15s ease;
  font-size: var(--fs-xs);
}
details[open] > .collapsible-header::before {
  transform: rotate(90deg);
}
.collapsible-body {
  padding: 0 clamp(12px, 2vw, 18px) clamp(12px, 2vw, 18px);
}
.badge-count {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--on-primary, #fff);
  background: var(--primary);
  border-radius: 999px;
  padding: 1px 8px;
}

/* A long table (e.g. the full Stock list) scrolls inside a bounded height
   instead of pushing the page itself into an endless scroll. */
.scroll-table-wrap {
  max-height: 480px;
  overflow-y: auto;
}
.scroll-table-wrap thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.tank-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: var(--fs-xs);
}
.tank-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.tank-letter {
  font-weight: 700;
  font-size: var(--fs-md);
  color: var(--primary-text);
}
.tank-history-link {
  font-size: var(--fs-xs);
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
}
.tank-history-link:hover {
  text-decoration: underline;
}
.tank-product-input {
  width: 100%;
  font-size: var(--fs-xs);
  padding: 5px 7px;
  margin-bottom: 4px;
}
.tank-wo {
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
}
/* Safety net: a modal's content is only padded today via <form> or an
   explicit .modal-body wrapper (see rules above) -- any other bare child
   dropped straight under .modal (a list, an empty-state <p>, etc.) got zero
   padding and rode the modal's edges. Pads every direct child except the
   header and the two already-padded cases, so this never double-pads and
   covers new bare modal content automatically. .modal-footer is included
   here on purpose: it only gets padding for free when it's inside a <form>
   (padded above) -- a footer sitting as a bare sibling of .modal-body (no
   form) is exactly this selector's ":not(form)" case and got zero
   horizontal padding, so its buttons rode the modal's edge. Selecting only
   ".modal > *" (direct children) keeps this from ever double-padding a
   form-wrapped footer, which lives one level deeper. */
.modal > *:not(.modal-header):not(form):not(.modal-body):not(.user-click-list) {
  padding-left: var(--pad-modal);
  padding-right: var(--pad-modal);
}
.modal > *:not(.modal-header):not(form):not(.modal-body):not(.user-click-list):last-child {
  padding-bottom: var(--pad-modal);
}
.history-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
}
.history-row .k {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Task calendar */

.task-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
}
@media (max-width: 1300px) {
  .task-calendar {
    grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
  }
}

.task-day-column {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 140px;
}
.task-day-column.is-today {
  border-color: var(--primary);
}
/* A real <button>, not a <div> -- clicking the day header jumps into Day
   view for that date, and it needs to be keyboard-reachable like any
   other control that triggers navigation. */
.task-day-header {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding: 4px 4px 10px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  transition: color 0.15s ease;
}
.task-day-header:hover,
.task-day-header:focus-visible {
  color: var(--primary);
}
.task-day-header:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.task-day-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-card {
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease;
}
.task-card:hover {
  border-color: var(--primary);
}
.task-card.is-complete {
  opacity: 0.6;
}
.task-card.is-complete .tank-card-header span:first-child {
  text-decoration: line-through;
}
.task-card.is-started {
  border-color: var(--primary);
  background: var(--primary-tint);
}
/* Overdue wins visually over the started/complete tint -- a task that's
   both started and overdue still needs to read as urgent first. */
.task-card.is-overdue .tank-card-header span:first-child {
  color: var(--danger);
  font-weight: 700;
}
.task-card .tank-card-header span:first-child {
  font-size: var(--fs-sm);
}

.checklist-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding-left: 26px;
}
.checklist-att {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.checklist-att img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.checklist-att .remove-checklist-att {
  position: absolute;
  top: 1px;
  right: 1px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 999px;
  width: 16px;
  height: 16px;
  font-size: var(--fs-xs);
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.checklist-att-add {
  width: 44px;
  height: 44px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-lg);
  color: var(--text-muted);
  cursor: pointer;
}
.checklist-att-add:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.checklist-att-add input[type='file'] {
  display: none;
}

/* SOP / How-To */

.sop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: 14px;
}
.sop-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  cursor: pointer;
}
.sop-card:hover {
  border-color: var(--primary);
}
.sop-card h3 {
  margin: 0 0 6px;
  font-size: var(--fs-md);
}
.sop-card p {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

.sop-steps-list {
  margin: 0;
  display: flex;
  flex-direction: column;
}
.sop-view-step {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.sop-view-step:last-child {
  border-bottom: none;
}
.sop-view-step-text {
  font-size: var(--fs-sm);
}

.sop-step-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 10px;
}
.sop-step-media {
  margin-top: 8px;
  padding-left: 2px;
}
.sop-step-media-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.sop-step-media-grid:empty {
  margin-bottom: 0;
}
.sop-step-media-input {
  display: none;
}

.sop-attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(160px, 100%), 1fr));
  gap: 10px;
  margin-top: 10px;
}
.sop-attachment {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
  position: relative;
}
.sop-attachment img,
.sop-attachment video {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
}
.sop-attachment .doc-link {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  font-size: var(--fs-xs);
  color: var(--primary);
  text-decoration: none;
  padding: 8px;
  text-align: center;
  word-break: break-word;
}
.sop-attachment .attachment-name {
  font-size: var(--fs-xs);
  padding: 6px 8px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sop-attachment .remove-attachment {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 999px;
  width: 22px;
  height: 22px;
  font-size: var(--fs-sm);
  cursor: pointer;
}

/* Action items logged from an interaction (partner-detail.js) — same
   list-of-rows-in-a-panel pattern as the Orders table, but simple flex rows
   since there's no tabular data to align into columns. */
.action-item-list {
  display: flex;
  flex-direction: column;
}
.action-item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.action-item-row:last-child {
  border-bottom: none;
}
.action-item-desc {
  flex: 1;
  min-width: 160px;
  font-size: var(--fs-sm);
}
.action-item-row.is-complete .action-item-desc {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Inline form feedback (e.g. password change) -- shown/hidden via the
   `hidden` utility, never inline styles, per the class-swap rule. */
.form-error {
  color: var(--danger);
  font-size: var(--fs-sm);
  margin: 10px 0 0;
}
.form-success {
  color: var(--primary-text);
  font-size: var(--fs-sm);
  margin: 10px 0 0;
}

/* ---------- Utility classes ---------- */
/* Small, reusable primitives so JS templates never need inline `style="…"`. */

.m-0 {
  margin: 0;
}
.mt-xs {
  margin-top: 4px;
}
.mt-sm {
  margin-top: 6px;
}
.mt-md {
  margin-top: 8px;
}
.mb-sm {
  margin-bottom: 8px;
}
.mb-md {
  margin-bottom: 14px;
}
.ml-sm {
  margin-left: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* flex-wrap so a non-shrinking .row-actions button group (Print BOL, Print
   Labels, Cancel, Finalize Shipment...) that doesn't fit next to its
   sibling text drops to its own line below, instead of the text getting
   squeezed into a single narrow column with every word wrapping. */
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.row-between-start {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
/* No flex-shrink: 0 (used to force this to its full button-row width even
   when that's wider than its own container) -- letting it shrink is what
   lets its own flex-wrap actually kick in and stack the buttons instead of
   overflowing sideways once .row-between above has already given it a full
   line to itself. */
.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.block {
  display: block;
}

.link {
  color: var(--primary);
  text-decoration: none;
}
.link:hover {
  text-decoration: underline;
}
.text-muted {
  color: var(--text-muted);
}
.text-danger {
  color: var(--danger);
}
.text-sm {
  font-size: var(--fs-xs);
}
.text-strike {
  text-decoration: line-through;
  color: var(--text-muted);
}

.input-sm {
  font-size: var(--fs-xs);
  padding: 6px 8px;
}
.input-flex {
  flex: 1;
}
.input-w-full {
  width: 100%;
}
.input-w-xs {
  width: 80px;
}
.input-w-num {
  width: 100px;
  max-width: 100%;
}
.input-w-90 {
  width: 90px;
}
.input-w-120 {
  width: 120px;
}
.input-w-140 {
  width: 140px;
}
.mw-140 {
  max-width: 140px;
}
.mw-160,
.modal .mw-160 {
  max-width: min(160px, 100%);
}
.mt-14 {
  margin-top: 14px;
}
.link-inline-sm {
  display: inline-block;
  margin-top: 4px;
  font-size: var(--fs-xs);
}
.label-block {
  display: block;
  margin-bottom: 8px;
}
.cfu-input-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cfu-input-group input {
  width: 80px;
  min-width: 0;
}
.cfu-input-x {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  white-space: nowrap;
}

/* Sample Status dropdown -- colored to match the chosen result, same
   red/yellow/green tokens as the status badges elsewhere (Flag column,
   Stock Quality badges). The select itself is recolored via class swap
   (see applyFlagStyle() in lab.js, never element.style); option colors
   below tint the closed list too, best-effort since browsers vary in how
   much of an <option>'s own styling they honor. */
/* Fixed green: a quality result reads the same in every theme, whatever the accent colour. */
#lr_flag.is-green {
  background: #d6f0e6;
  color: #1c6b4a;
  border-color: #1c6b4a;
}
#lr_flag.is-yellow {
  background: #fff3cd;
  color: #8a6d1a;
  border-color: #8a6d1a;
}
#lr_flag.is-red {
  background: #fbdcdc;
  color: var(--danger);
  border-color: var(--danger);
}
#lr_flag option[value='green'] {
  color: #1c6b4a;
}
@media (prefers-color-scheme: dark) {
  #lr_flag.is-green {
    background: #17332a;
    color: #6fd3a5;
    border-color: #6fd3a5;
  }
  #lr_flag option[value='green'] {
    color: #6fd3a5;
  }
}
#lr_flag option[value='yellow'] {
  color: #8a6d1a;
}
#lr_flag option[value='red'] {
  color: var(--danger);
}
.btn-sm {
  padding: 6px 12px;
  font-size: var(--fs-xs);
}
.grid.is-tight {
  gap: 8px;
}

.modal.modal-sm {
  max-width: 500px;
}
.modal.modal-md {
  max-width: 560px;
}
.modal.modal-lg {
  max-width: 640px;
}
.modal-body {
  padding: 6px var(--pad-modal) var(--pad-modal);
}
.modal-body.is-loose {
  padding: 16px var(--pad-modal) var(--pad-modal);
}

.attachment-icon-link,
.attachment-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.attachment-icon-link {
  font-size: var(--fs-lg);
  text-decoration: none;
}
.attachment-icon {
  font-size: var(--fs-lg);
  background: var(--bg);
}

.mini-table {
  width: 100%;
  font-size: var(--fs-xs);
  border-collapse: collapse;
  margin-top: 4px;
}
.mini-table th,
.mini-table td {
  text-align: left;
  padding: 4px;
}

.mini-table-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

.compact-list {
  margin: 6px 0 0;
  padding-left: 18px;
}

.completed-banner {
  background: var(--primary-tint);
  color: var(--primary-text);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: var(--fs-sm);
  margin-bottom: 12px;
  font-weight: 600;
}

.checklist-item-box {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
}
.checkbox-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.request-supplies-form {
  display: none;
  margin-top: 8px;
  padding: 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}
.request-supplies-form.is-active {
  display: block;
}

.po-tracking-row {
  display: none;
  gap: 8px;
  align-items: center;
}
.po-tracking-row.is-active {
  display: flex;
}

.po-detail-box {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.detail-grid.is-compact {
  padding: 0 0 10px;
}
.detail-grid.is-flush {
  padding: 0;
}

.ingredient-row.is-compact {
  grid-template-columns: 1fr auto;
}
.history-row.is-single-col {
  grid-template-columns: 1fr;
}

/* Generic interactive states, per the design system's "State States" rule. */
.is-loading {
  opacity: 0.6;
}
.has-error .widget-loading {
  color: var(--danger);
}

.fieldset-hint {
  margin: -4px 0 10px;
}
.sop-notes {
  margin-top: 14px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.mt-lg {
  margin-top: 24px;
}
.mt-10 {
  margin-top: 10px;
}
.approve-summary {
  padding: 0 22px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.viewing-user-label {
  gap: 3px;
  font-size: var(--fs-xs);
}
.sop-preview {
  margin-top: 10px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.items-end {
  align-items: flex-end;
}
.span-wide {
  grid-column: span 2;
}
@media (max-width: 720px) {
  .span-wide {
    grid-column: span 1;
  }
}

button.widget-card {
  font: inherit;
  text-align: left;
  width: 100%;
  cursor: pointer;
}

/* Attendance widget + PTO calendar */

.attendance-roster {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.attendance-roster-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-sm);
}
.attendance-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-right: 6px;
  background: var(--primary);
}
.attendance-status-dot.is-off {
  background: var(--text-muted);
}
.attendance-status-dot.is-pto {
  background: #b5501f;
}
@media (prefers-color-scheme: dark) {
  .attendance-status-dot.is-pto {
    background: #ef9c6d;
  }
}

.attendance-tools {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 16px;
  background: var(--bg);
}

.month-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.month-calendar-weekday {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  text-align: center;
  padding-bottom: 4px;
}
.month-calendar-day {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  min-height: 74px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.month-calendar-day.is-today {
  border-color: var(--primary);
}
.month-calendar-day.is-other-month {
  background: var(--bg);
}
.month-calendar-day.is-other-month .month-calendar-date {
  color: var(--text-muted);
}
.month-calendar-date {
  font-size: var(--fs-xs);
  font-weight: 600;
}
.month-calendar-chips {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.attendance-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: var(--fs-xs);
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
}
.attendance-chip.is-pto {
  background: var(--danger-tint);
  border-color: var(--danger);
  color: var(--danger);
}
.attendance-chip .remove-attendance-chip {
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
  font-size: var(--fs-xs);
  line-height: 1;
  padding: 0;
}
.month-calendar-add {
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  padding: 2px 0;
  cursor: pointer;
}
.month-calendar-add:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Task calendar's Month view -- reuses .month-calendar-grid/-day/-date
   above (same component the attendance calendar uses), just with its own
   chip style since a task chip needs the same complete/started/overdue
   language as .task-card without the room a full card gets. */
.month-calendar-day.is-clickable {
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.month-calendar-day.is-clickable:hover {
  border-color: var(--primary);
}
.task-month-chip {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: var(--fs-xs);
  text-align: left;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease;
}
.task-month-chip:hover,
.task-month-chip:focus-visible {
  border-color: var(--primary);
}
.task-month-chip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.task-month-chip.is-complete {
  text-decoration: line-through;
  opacity: 0.6;
}
.task-month-chip.is-started {
  border-color: var(--primary);
  background: var(--primary-tint);
}
.task-month-chip.is-overdue {
  color: var(--danger);
  font-weight: 700;
  border-color: var(--danger);
}
.month-calendar-more {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: var(--fs-xs);
  text-align: left;
  color: var(--text-muted);
  border: none;
  background: none;
  padding: 1px 5px;
  cursor: pointer;
}
.month-calendar-more:hover {
  color: var(--primary);
}
@media (max-width: 720px) {
  .month-calendar-grid {
    grid-template-columns: repeat(7, minmax(36px, 1fr));
  }
  .month-calendar-day {
    min-height: 50px;
    padding: 3px;
  }
}

/* ---------- Performance charts ---------- */

.viz-root {
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
}
@media (prefers-color-scheme: dark) {
  .viz-root {
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
  }
}
:root[data-theme='dark'] .viz-root {
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.tank-filter-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
}
.tank-filter-label select {
  padding: 6px 10px;
  font-size: var(--fs-xs);
}
.filter-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: var(--fs-xs);
  cursor: pointer;
}
.filter-btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.stat-tile-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.stat-tile .stat-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.stat-tile .stat-value {
  font-size: clamp(20px, 1.6vw + 14px, 26px);
  font-weight: 600;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

/* ---------- Business Performance: gauge dashboard ---------- */

.perf-charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr));
  gap: 18px;
  margin-bottom: 18px;
}
.perf-gauge-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}
@media (max-width: 900px) {
  .perf-gauge-row {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 560px) {
  .perf-gauge-row {
    grid-template-columns: 1fr;
  }
}

.perf-panel-header {
  margin-bottom: 4px;
}
.perf-panel-title {
  font-size: var(--fs-sm);
  font-weight: 700;
  margin: 0 0 4px;
}
.perf-panel-sub {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin: 0 0 10px;
}

.perf-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  font-weight: 700;
}
.perf-trend.is-up {
  color: var(--primary-text);
}
.perf-trend.is-down {
  color: var(--danger);
}
.perf-trend.is-flat {
  color: var(--text-muted);
}
.perf-trend-label {
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 2px;
}

.perf-gauge-card {
  text-align: center;
}
.perf-gauge-title {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 8px;
}
.gauge-wrap {
  position: relative;
  width: 100%;
  max-width: 200px;
  margin: 0 auto;
}
.gauge-svg {
  width: 100%;
  display: block;
}
.gauge-track {
  fill: none;
  stroke: var(--border);
}
.gauge-arc {
  fill: none;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}
.gauge-arc.is-green {
  stroke: var(--success);
}
.gauge-arc.is-yellow {
  stroke: var(--warning);
}
.gauge-arc.is-red {
  stroke: var(--danger);
}
.gauge-arc.is-neutral {
  stroke: var(--primary);
}
.gauge-arc.is-none {
  stroke: var(--border);
}
.gauge-minmax {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  padding: 0 6px;
  margin-top: -18px;
}
.gauge-value {
  font-size: clamp(19px, 1.4vw + 13px, 24px);
  font-weight: 800;
  color: var(--text);
  margin-top: 4px;
}
.gauge-value .unit {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.chart-legend {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.chart-legend-swatch {
  width: 14px;
  height: 2px;
  border-radius: 2px;
  display: inline-block;
}
.chart-legend-swatch.is-bar {
  height: 8px;
}

.chart-svg-wrap {
  position: relative;
}
.chart-svg-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}
.chart-crosshair {
  stroke: var(--border);
  stroke-width: 1;
  opacity: 0;
}
.chart-crosshair.is-visible {
  opacity: 1;
}
.chart-gridline {
  stroke: var(--border);
  stroke-width: 1;
}
.chart-axis-label {
  fill: var(--text-muted);
  font-size: 10px;
}
.chart-marker-ring {
  fill: var(--surface);
}
.chart-reference-line {
  stroke: var(--text-muted);
  stroke-width: 1.5;
  stroke-dasharray: 4 3;
}
.chart-reference-label {
  fill: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
}

.sparkline {
  width: 100%;
  height: 48px;
  display: block;
  margin: 6px 0 4px;
}
.sparkline-area {
  fill: var(--primary);
  opacity: 0.12;
  stroke: none;
}
.sparkline-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sparkline-dot {
  fill: var(--primary);
}

.chart-line {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chart-line.chart-series-primary {
  stroke: var(--primary);
}
.chart-line.chart-series-1 {
  stroke: var(--series-1);
}
.chart-line.chart-series-2 {
  stroke: var(--series-2);
}
.chart-line.chart-series-3 {
  stroke: var(--series-3);
}
.chart-line.chart-series-outside {
  stroke: var(--text-muted);
  stroke-dasharray: 5 3;
}

.chart-marker.chart-series-primary {
  fill: var(--primary);
}
.chart-marker.chart-series-1 {
  fill: var(--series-1);
}
.chart-marker.chart-series-2 {
  fill: var(--series-2);
}
.chart-marker.chart-series-3 {
  fill: var(--series-3);
}
.chart-marker.chart-series-outside {
  fill: var(--text-muted);
}

.chart-bar {
  fill: var(--primary);
  opacity: 0.55;
  transition: opacity 0.15s;
}
.chart-bar:hover {
  opacity: 0.8;
}

.chart-legend-toggle {
  gap: 18px;
  flex-wrap: wrap;
}
.chart-legend-toggle-item {
  cursor: pointer;
  user-select: none;
}
.chart-legend-toggle-item input[type='checkbox'] {
  margin: 0;
  accent-color: var(--primary);
}

.chart-legend-swatch.chart-series-primary,
.tt-key.chart-series-primary {
  background: var(--primary);
}
.chart-legend-swatch.chart-series-1,
.tt-key.chart-series-1 {
  background: var(--series-1);
}
.chart-legend-swatch.chart-series-2,
.tt-key.chart-series-2 {
  background: var(--series-2);
}
.chart-legend-swatch.chart-series-3,
.tt-key.chart-series-3 {
  background: var(--series-3);
}
.chart-legend-swatch.chart-series-outside,
.tt-key.chart-series-outside {
  background: var(--text-muted);
}

.chart-tooltip {
  position: absolute;
  left: var(--tt-left, 0);
  top: var(--tt-top, 0);
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 11px;
  box-shadow: var(--shadow);
  display: none;
  white-space: nowrap;
  z-index: 5;
}
.chart-tooltip.is-visible {
  display: block;
}
.chart-tooltip .tt-date {
  color: var(--text-muted);
  margin-bottom: 3px;
}
.chart-tooltip .tt-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.chart-tooltip .tt-key {
  width: 10px;
  height: 2px;
  border-radius: 2px;
  display: inline-block;
}
.chart-tooltip .tt-value {
  font-weight: 700;
  margin-left: auto;
}

.chart-empty {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 50px 0;
}

/* ---------- Printable QR labels ---------- */

.label-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(180px, 100%), 1fr));
  gap: 14px;
}
.label-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  text-align: center;
}
.label-card img {
  display: block;
  margin: 0 auto 8px;
}
.label-card.is-asset {
  text-align: left;
}
.label-card.is-clickable {
  cursor: pointer;
}
.label-card img.label-card-thumb {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
}
.label-title {
  font-weight: 700;
  font-size: 14px;
}
.label-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

@media print {
  .no-print {
    display: none !important;
  }
  .label-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.25in;
  }
  .label-card {
    box-shadow: none;
    border: 1px solid #000;
    break-inside: avoid;
  }
  body,
  body.themed-bg {
    background: #fff !important;
    background-image: none !important;
  }
}

/* ---------- SO shipping label + customer copy ---------- */

.ship-label {
  background: var(--surface);
  border: 2px solid var(--text);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 4in;
  margin-bottom: 24px;
}
.ship-label-from {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.ship-label-to-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.ship-label-to {
  font-size: 18px;
  font-weight: 700;
  margin: 2px 0 14px;
  white-space: pre-line;
}
.ship-label-meta {
  font-size: 12px;
  margin-bottom: 12px;
}
.ship-label img {
  display: block;
  margin: 0 auto;
}

.customer-copy {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  max-width: 800px;
}
.customer-copy h2 {
  margin: 0 0 4px;
}
.customer-copy table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: var(--fs-sm);
}
.customer-copy th,
.customer-copy td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

@media print {
  .ship-label {
    border-color: #000;
    break-inside: avoid;
  }
  .ship-label-to {
    color: #000;
  }
  .customer-copy {
    box-shadow: none;
    border: none;
    break-before: page;
  }
}

/* ---------- BOL / Packing Slip ---------- */

.bol-doc {
  font-size: 13px;
}
.bol-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
.bol-header-meta {
  text-align: right;
  font-size: 13px;
  line-height: 1.6;
}
.bol-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.bol-party-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.bol-party-body {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}
.bol-fields {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 12px;
}
.bol-fields td {
  border: 1px solid var(--border);
  padding: 6px 8px;
}
.bol-fields td:nth-child(odd) {
  font-weight: 700;
  width: 22%;
  color: var(--text-muted);
}
.bol-commodities {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 13px;
}
.bol-commodities th,
.bol-commodities td {
  border: 1px solid var(--border);
  padding: 8px;
  text-align: left;
}
.bol-commodities tfoot td {
  font-weight: 700;
}
.bol-hm-note {
  font-size: 11px;
  color: var(--text-muted);
  margin: -8px 0 16px;
}
.bol-certification {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 20px 0;
}
.bol-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-top: 32px;
}
.bol-sig-line {
  border-bottom: 1px solid var(--text);
  height: 32px;
}
.bol-sig-date {
  height: 24px;
  max-width: 140px;
}
.bol-sig-label {
  font-size: 10px;
  color: var(--text-muted);
  margin: 4px 0 16px;
}
.packing-slip-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.packing-slip-header img {
  height: 48px;
  width: auto;
}

@media print {
  .bol-doc {
    color: #000;
  }
  .bol-fields td,
  .bol-commodities th,
  .bol-commodities td {
    border-color: #000;
  }
  .bol-sig-line {
    border-color: #000;
  }
}

/* ---------- Work Order ticket ---------- */

.wo-ticket {
  background: var(--surface);
  border: 2px solid var(--text);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 500px;
  text-align: center;
}
.wo-ticket img {
  display: block;
  margin: 0 auto 12px;
}
.wo-ticket-number {
  font-size: 22px;
  font-weight: 700;
}
.wo-ticket-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0 20px;
}
.wo-ticket table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 16px;
  font-size: 13px;
  text-align: left;
}
.wo-ticket th,
.wo-ticket td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.wo-ticket-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-align: left;
  margin: 4px 0 8px;
}

@media print {
  .wo-ticket {
    border-color: #000;
    break-inside: avoid;
  }
}

/* ---------- Scan page ---------- */

.scan-container {
  padding: 24px;
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.scan-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.scan-form input {
  font-size: var(--fs-lg);
  padding: 12px 14px;
}

.camera-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.camera-wrap video {
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #000;
}

.scan-result-wrap {
  min-height: 4px;
}
.scan-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
}
.scan-result.has-error {
  border-color: var(--danger);
}
.scan-result-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  margin-bottom: 4px;
}
.scan-result-sub {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-bottom: 14px;
}

.scan-pick-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  margin-top: 10px;
}
.scan-pick-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-md);
  cursor: pointer;
  text-align: left;
}
.scan-pick-row:hover,
.scan-pick-row:focus-visible {
  border-color: var(--primary);
  background: var(--primary-tint);
}

.row-actions.is-centered {
  justify-content: center;
}

.count-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 10px 0;
}
.count-step-btn {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-2xl);
  line-height: 1;
  cursor: pointer;
}
.count-step-btn:active {
  background: var(--primary-tint);
}
.count-input {
  width: 100px;
  text-align: center;
  font-size: var(--fs-2xl);
  font-weight: 700;
  padding: 10px 6px;
}

.mini-table.chart-table td {
  font-variant-numeric: tabular-nums;
}

/* ---------- Messages ---------- */

.messages-layout {
  display: flex;
  height: calc(100vh - 106px);
  max-width: 1400px;
  margin: 0 auto;
}
.messages-sidebar {
  width: 300px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.messages-sidebar-header {
  padding: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}
.channel-list {
  flex: 1;
  overflow-y: auto;
}
.channel-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.channel-list-item:hover {
  background: var(--bg);
}
.channel-list-item.is-active {
  background: var(--primary-tint, var(--bg));
}
.channel-list-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.channel-list-item-name {
  font-size: var(--fs-md);
}
.channel-list-item-preview {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}
.channel-unread-badge {
  background: var(--primary);
  color: var(--on-primary);
  font-size: var(--fs-xs);
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 7px;
  flex-shrink: 0;
}

.messages-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.messages-pane .empty-state {
  margin-top: 80px;
}
#activeChannel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

/* Below 768px the fixed 300px sidebar alone would consume most of a phone
   screen -- stack the channel list above the conversation instead, capping
   the list's height so the open conversation still gets real room. */
@media (max-width: 768px) {
  .messages-layout {
    flex-direction: column;
    height: calc(100vh - 106px);
  }
  .messages-sidebar {
    width: 100%;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .messages-pane {
    min-height: 0;
  }
}
.messages-pane-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.member-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.member-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 4px 2px 10px;
  font-size: var(--fs-xs);
}
.member-chip-remove {
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: var(--fs-md);
  line-height: 1;
  padding: 2px 6px;
}
.member-chip-remove:hover {
  color: var(--text);
}

.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.message-row.is-mine {
  justify-content: flex-end;
}
.message-bubble {
  max-width: 60%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
}
.message-row.is-mine .message-bubble {
  background: var(--primary-tint, var(--bg));
}
.message-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-bottom: 2px;
}
.message-body {
  font-size: var(--fs-md);
  white-space: pre-wrap;
  word-break: break-word;
}

.composer {
  display: flex;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}
.composer textarea {
  flex: 1;
  resize: none;
  font-family: inherit;
  font-size: var(--fs-md);
  padding: 10px 12px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
}

.user-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 260px;
  overflow-y: auto;
}
.user-click-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px;
}
.user-click-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  background: none;
  border-radius: var(--radius);
  font-size: var(--fs-md);
  color: var(--text);
  cursor: pointer;
}
.user-click-item:hover {
  background: var(--bg);
}
.user-click-item.partner-picker-create {
  color: var(--primary);
  font-weight: 600;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 12px;
}

#notifyToggleBtn.is-active {
  color: var(--primary);
  border-color: var(--primary);
}

/* ---------- Touch-target sizing for touch-primary devices (iPads) ----------
   Keyed on input method (pointer: coarse), not screen width -- an iPad in
   landscape is plenty wide enough to hit a desktop breakpoint but is still
   touch-primary, and a narrow desktop browser window with a mouse doesn't
   need bigger targets just because it's narrow. Apple's Human Interface
   Guidelines recommend a 44x44pt minimum tap target; 16px is the input
   font-size iOS Safari requires to not auto-zoom the page on focus. */
@media (pointer: coarse) {
  .icon-btn {
    width: 44px;
    height: 44px;
    font-size: var(--fs-lg);
  }
  .remove-ingredient {
    width: 44px;
    height: 44px;
    font-size: var(--fs-lg);
  }

  .ghost-btn,
  .primary-btn,
  .danger-btn {
    padding: 12px 18px;
    font-size: var(--fs-md);
    min-height: 44px;
  }
  .ghost-btn.small,
  .btn-sm {
    padding: 10px 14px;
    font-size: var(--fs-sm);
    min-height: 40px;
  }

  input,
  textarea,
  select {
    font-size: var(--fs-lg);
    padding: 11px 12px;
    min-height: 44px;
  }
  /* Same specificity as the desktop height:36px rule (both are
     element + 2 :not() pseudo-classes) -- source order then decides,
     and this comes later, so touch gets a true fixed 44px instead of
     silently staying pinned at the desktop height. */
  input:not([type='checkbox']):not([type='radio']):not([type='range']),
  select {
    height: 44px;
  }
  textarea {
    min-height: 88px;
  }
  input[type='checkbox'],
  input[type='radio'] {
    width: 22px;
    height: 22px;
    min-height: 0;
  }
  input[type='date'],
  input[type='datetime-local'],
  input[type='time'] {
    min-height: 44px;
  }

  /* Table rows are tap targets on several pages (row click opens detail) --
     give them breathing room instead of the dense desktop padding. */
  table.runs-table th,
  table.runs-table td {
    padding: 12px 10px;
  }

  /* The schedule ring's center select is deliberately compact (it's a
     status label first, control second) and already sized/tested for
     touch -- don't let the blanket input rule above stretch it. */
  .tank-ring-center-select {
    height: auto;
    min-height: 0;
    padding: 0 2px;
    font-size: var(--fs-xs);
  }

  /* iPhones zoom the whole page into any field whose text is under 16px
     and leave it zoomed after. These page rules set smaller text than the
     touch rule above and win on specificity, so each gets the 16px floor
     back here (the body prefix outranks the page rule, including the ones in
     exec-dashboard.css / hr-org.css / workspace.css,
     which load after this file). The tank-ring picker is left alone: its
     text has to fit inside the ring. */
  body .exec-subtask-add input[type='text'],
  body .sched-toggle input[type='date'],
  body .rtp-row-inputs input,
  body .rtp-row-inputs select,
  body .wp-field select,
  body .tank-product-input,
  body .tank-filter-label select,
  body .composer textarea,
  body .th-filter .th-filter-input,
  body .stock-batch-table.is-stacked .th-filter .th-filter-input,
  body .sr-search input,
  body .input-sm {
    /* max(): on large touch screens the fluid token is already above 16px */
    font-size: max(16px, var(--fs-md));
  }

  .nav-icon-badge {
    width: 44px;
    height: 44px;
    font-size: var(--fs-xl);
  }

  /* Same touch-target bump as .nav-icon-badge above, so the avatar stays
     the same size as the icons beside it on a touch device instead of
     the desktop 36px/44px pairing splitting back apart. */
  .avatar.is-nav,
  .profile-link {
    width: 44px;
    height: 44px;
    font-size: 16px;
  }
}

/* ---------- "Get Support" floating chat widget ---------- */
#supportFabBtn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  font-size: var(--fs-xl);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  z-index: 30;
  transition: transform 0.15s ease;
}
#supportFabBtn:hover {
  transform: scale(1.06);
}
/* Room under every page for the floating help button, so it never sits on top of the last buttons (a form's
   Next / Save) once the page is scrolled to the bottom: 52px button + 20px gap + breathing room. */
body:has(#supportFabBtn) main {
  padding-bottom: 88px;
}

#supportPanel {
  position: fixed;
  bottom: 82px;
  right: 20px;
  width: 320px;
  max-width: calc(100vw - 40px);
  max-height: 60vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 30;
}
#supportPanel.hidden {
  display: none;
}
.support-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--primary);
  color: var(--on-primary);
}
.support-header strong {
  font-size: var(--fs-md);
}
.support-header .icon-btn {
  color: var(--on-primary);
}
.support-log {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 160px;
}
.support-msg {
  font-size: var(--fs-sm);
  line-height: 1.4;
  padding: 8px 10px;
  border-radius: var(--radius);
  max-width: 85%;
  white-space: pre-wrap;
}
.support-msg-assistant {
  background: var(--bg);
  border: 1px solid var(--border);
  align-self: flex-start;
}
.support-msg-user {
  background: var(--primary);
  color: var(--on-primary);
  align-self: flex-end;
}
.support-typing {
  opacity: 0.6;
  font-style: italic;
}
.support-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
}
.support-form input {
  flex: 1;
  min-width: 0;
}

/* Media never outgrows its container (width:100% + a cap is the same idea
   as .modal's width:100% / max-width pairing). */
img,
video {
  max-width: 100%;
}

/* An inline field warning dropped into a grid spans the whole row instead of
   squeezing into one cell. */
.form-error.is-full-row {
  grid-column: 1 / -1;
  margin: 6px 0 0;
}

/* ---------- Parts & Supplies photos ---------- */
.part-thumb {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: zoom-in;
}
.part-thumb:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.part-thumb-empty {
  display: inline-block;
  width: 44px;
  text-align: center;
  color: var(--text-muted);
}
/* Enlarged copy shown while a thumbnail is hovered/focused. Fixed to the
   viewport (not the thumbnail) so the table's scrolling wrapper can't clip it. */
.part-image-preview {
  display: none;
  position: fixed;
  top: 96px;
  right: var(--gutter);
  width: min(340px, 42vw);
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.3);
  pointer-events: none;
  z-index: 60;
}
.part-image-preview.is-visible {
  display: block;
}
.part-image-preview img {
  display: block;
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
}
.part-photo-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.part-photo-preview {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.part-photo-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

/* Elements a restricted (employee-tier) user never sees: lab results and
   manager-only actions. The server withholds the data too. */
body.is-restricted .lab-only,
body.is-restricted .manager-only {
  display: none !important;
}
/* The actual CFU number/result (as opposed to .lab-only's broader "not for
   floor staff" scope, which also covers things like the Quality badges
   that ARE meant to stay visible to every manager/exec) -- hidden for
   anyone outside LAB_RESULT_ENTRY_USERS specifically, employee tier or
   not. The server withholds the underlying field regardless; this just
   avoids an empty-looking column for them. */
body.lab-restricted .cfu-only {
  display: none !important;
}

/* ---------- 4x4 product labels (shipping + reprint) ---------- */

.copies-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  white-space: nowrap;
}
.copies-field input {
  width: 64px;
  flex: none;
}
#woSearchResults {
  max-height: 40vh;
  overflow-y: auto;
}

.label-sheet-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 16px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--primary-tint);
}

.label-sheet {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.ship-tag {
  box-sizing: border-box;
  width: 4in;
  height: 4in;
  padding: 0.2in;
  display: flex;
  flex-direction: column;
  gap: 0.12in;
  background: #fff;
  color: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.ship-tag-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.15in;
}
.ship-tag-top img {
  width: 1.6in;
  height: 1.6in;
  display: block;
}
.ship-tag-wo {
  text-align: right;
}
.ship-tag-wo span {
  display: block;
  font-size: 12pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ship-tag-wo strong {
  display: block;
  font-size: 30pt;
  line-height: 1.05;
  overflow-wrap: anywhere;
}
.ship-tag-fields {
  margin: 0;
  display: grid;
  gap: 0.08in;
}
.ship-tag-fields > div {
  display: grid;
  grid-template-columns: 1.15in 1fr;
  align-items: baseline;
  gap: 0.08in;
  border-top: 1px solid #000;
  padding-top: 0.05in;
}
.ship-tag-fields dt {
  font-size: 9pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.ship-tag-fields dd {
  margin: 0;
  font-size: 13pt;
  font-weight: 700;
  overflow-wrap: anywhere;
}

@page tag {
  size: 4in 4in;
  margin: 0;
}

@media print {
  #clockBar,
  .clock-bar,
  .toast,
  .update-banner {
    display: none !important;
  }
  .label-page {
    padding: 0 !important;
    margin: 0 !important;
    max-width: none !important;
  }
  .label-sheet {
    page: tag;
    display: block;
  }
  .ship-tag {
    border: none;
    border-radius: 0;
    break-after: page;
    break-inside: avoid;
  }
  .ship-tag:last-child {
    break-after: auto;
  }
}

/* ---------- HR (confidential personal information) ---------- */

.hr-page {
  max-width: 1100px;
  gap: calc(var(--gutter) * 1.25);
}
.hr-page .widget-section + .widget-section {
  border-top: 0;
  padding-top: 0;
}
.hr-page .widget-label {
  margin: 0 0 10px;
}
.hr-page .stat-tile-row {
  margin-bottom: 14px;
}
.hr-page .runs-table th,
.hr-page .runs-table td {
  padding: 10px 14px;
}
.hr-card {
  padding: 18px var(--pad-modal);
}
.hr-card form {
  padding: 0;
}
.hr-card .detail-grid.is-flush {
  gap: 16px 20px;
}
.hr-back {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
  text-decoration: none;
}
.hr-back:hover,
.hr-back:focus-visible {
  border-color: var(--primary);
  color: var(--primary-text);
}
.hr-confidential {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px var(--pad-modal);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
}
.hr-confidential svg {
  flex: none;
  margin-top: 1px;
  color: var(--primary-text);
}
.hr-confidential p {
  margin: 0;
  line-height: 1.45;
}

@media print {
  .hr-confidential {
    border-color: #000;
  }
}

/* ---------- Reports page ---------- */

.reports-page {
  display: flex;
  flex-direction: column;
  gap: calc(var(--gutter) * 1.25);
  max-width: none;
  margin: 0 auto;
}
.report-card {
  padding: 20px var(--pad-modal);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.report-card-title {
  margin: 0;
  font-size: var(--fs-lg);
}
.report-subtitle {
  margin: 8px 0 0;
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.report-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: 14px 16px;
  align-items: end;
}
.report-controls label {
  min-width: 0;
}
.report-extra-filters {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.report-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.report-result {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.report-result-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 0 2px;
}
.report-count {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
}
.report-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.reports-page .runs-table th,
.reports-page .runs-table td {
  padding: 10px 14px;
}
.reports-page .runs-table .is-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.report-card.is-loading {
  opacity: 0.7;
  pointer-events: none;
}
.report-card.has-error .report-actions .widget-sub {
  color: var(--danger, #b3261e);
}

.count-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 16px;
}
.count-step {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px var(--pad-modal);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.count-step-title {
  font-weight: 700;
  font-size: var(--fs-md);
}
.count-step-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}
.count-step-body label {
  align-self: stretch;
}
.count-message {
  margin: 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: var(--fs-sm);
}
.report-card.has-error .count-message {
  border-color: var(--danger, #b3261e);
  color: var(--danger, #b3261e);
}
.count-message.is-success {
  border-color: var(--primary);
  color: var(--primary-text);
}
.count-preview {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.count-preview-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-weight: 600;
}
.count-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 600;
  border: 1px solid var(--border);
}
.count-status.is-change {
  border-color: var(--primary);
  color: var(--primary-text);
  background: var(--primary-tint);
}
.count-status.is-same,
.count-status.is-skip {
  color: var(--text-muted);
}
.count-status.is-invalid {
  border-color: var(--danger, #b3261e);
  color: var(--danger, #b3261e);
}
.count-detail-row td {
  background: var(--bg);
}
.count-detail-list {
  margin: 0;
  padding: 4px 0 4px 18px;
  columns: 2;
  font-size: var(--fs-sm);
}

/* The report table shows about 10 rows; the rest scroll inside it (header stays put). */
#reportTableWrap {
  max-height: 450px;
  overflow-y: auto;
}
#reportTableWrap table.runs-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}

@media print {
  .report-card,
  .report-pager,
  .topbar .user-menu {
    display: none !important;
  }
  #reportTableWrap {
    max-height: none;
    overflow: visible;
  }
}

/* ---------- Blend Recipes (Sales Order product picker) ---------- */

.blend-info {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--primary-tint);
}
.blend-info .mini-table th {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: var(--fs-xs);
  letter-spacing: 0.03em;
}
.blend-warning {
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--danger-tint);
  color: var(--danger);
  font-size: var(--fs-xs);
  font-weight: 600;
}

/* ---------- Blend Recipes: per-product CFU split ---------- */

.blend-line-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 10px;
}
/* Product select and its Lbs input used to sit in a plain 3-column grid
   alongside the "X% of batch" annotation -- .grid-3 stacks to one column
   per row below 720px, which put that annotation on its own orphaned row
   under the Lbs field instead of reading as part of it. Grouping Lbs +
   annotation into one flex item keeps them together (and on their own
   line under Product) at any width, so nothing reads as a field knocked
   out of place. */
.blend-line-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.blend-line-row .blend-line-product {
  flex: 1 1 220px;
  min-width: 160px;
}
.blend-line-lbs-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 200px;
}
.blend-line-lbs-wrap .blend-line-ratio {
  white-space: nowrap;
}
.blend-cfu-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.blend-cfu-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.blend-cfu-prefix {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.blend-cfu-row .cfu-label {
  width: 110px;
  flex: none;
}
.blend-cfu-row .cfu-percent {
  width: 70px;
  flex: none;
}
.remove-cfu-split {
  border: none;
  background: var(--danger-tint);
  color: var(--danger);
  border-radius: var(--radius-sm);
  width: 24px;
  height: 24px;
  cursor: pointer;
  line-height: 1;
}
.blend-cfu-total {
  font-weight: 600;
}
.blend-cfu-total.is-off {
  color: var(--danger);
}

/* ---------- Inventory Count (iPad-oriented floor count) ---------- */

.count-product-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 60vh;
  overflow-y: auto;
}
.count-product-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.count-product-card:hover {
  border-color: var(--primary);
  background: var(--primary-tint);
}
/* The "Count by WO# (all products)" entry sits above the product cards. */
.count-by-wo-card {
  width: 100%;
  border-color: var(--primary);
  background: var(--primary-tint);
}
.input-w-sm {
  width: 150px;
}
/* Save / Cancel that appears beside a field once its value has been changed. */
.edit-actions {
  display: inline-flex;
  gap: 6px;
  margin-left: 8px;
  vertical-align: middle;
}
.edit-actions .small {
  min-height: 30px;
}
/* Buttons stacked under a value in a table cell (Shipping: Lot # / Tracking). */
.cell-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
.cell-center {
  display: flex;
  justify-content: center;
}
table.runs-table td.cell-middle {
  vertical-align: middle;
}
/* Custom blend plan: picks on the left, running pounds tally on the right. */
.blend-custom-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 18px;
  align-items: start;
}
.blend-tally {
  position: sticky;
  top: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.blend-tally-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
}
.blend-tally-name {
  font-weight: 600;
}
.blend-tally-note {
  grid-column: 1 / -1;
  font-size: var(--fs-xs);
}
.blend-tally-row.is-ok .blend-tally-note {
  color: var(--primary-text);
}
.blend-tally-row.is-over .blend-tally-note,
.blend-tally-row.is-under .blend-tally-note {
  color: var(--danger);
}
.blend-tally-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 10px;
  font-size: var(--fs-md);
}
.blend-tally-total strong {
  font-size: var(--fs-xl);
}
@media (max-width: 760px) {
  .blend-custom-layout {
    grid-template-columns: 1fr;
  }
  .blend-tally {
    position: static;
    order: -1;
  }
}
/* Data-heavy pages (Shipping) use the whole window instead of a centered 1400px column. */
.weeks-container.is-readable,
.kanban-container.is-readable {
  max-width: clamp(1400px, 88vw, 2200px);
}
.ship-date-input {
  width: 150px;
}
/* Schedule page settings bar (overtime capacity + effective start date). */
.schedule-settings {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 24px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.schedule-settings label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.schedule-settings .widget-sub {
  flex: 1 1 260px;
}
.lifecycle-check {
  padding: 12px 16px;
  border: 1px solid var(--danger);
  background: var(--danger-tint);
  border-radius: var(--radius);
}
.lifecycle-check-list {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: var(--fs-sm);
  max-height: 260px;
  overflow-y: auto;
}
.lifecycle-check-list .lifecycle-group {
  list-style: none;
  margin: 8px 0 2px -18px;
}
.claim-row {
  cursor: pointer;
}
.claim-row:hover {
  border-color: var(--primary);
}
.claim-row:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
/* Lot# Trace: feeder WO#s nest under the one they made. */
.trace-feeder-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.trace-feeder-detail {
  margin: 6px 0 0 14px;
  padding-left: 12px;
  border-left: 2px solid var(--border);
}

.count-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.count-row {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--surface);
}
.count-row.is-confirmed {
  border-color: var(--primary);
  background: var(--primary-tint);
}
.count-row.is-negative-stock {
  border-color: var(--danger);
  background: var(--danger-tint);
}
.count-row-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}
.count-row-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  flex: none;
}
.count-row-check input {
  width: 20px;
  height: 20px;
}
.count-row-id {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 160px;
  min-width: 140px;
}
.count-row-lbs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.count-row-lbs input {
  width: 90px;
}
.count-row-location {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.count-row-location select {
  min-width: 100px;
}
.count-confirm-btn {
  flex: none;
  margin-left: auto;
}
.count-row-msg {
  margin: 6px 0 0;
}

@media (max-width: 720px) {
  .count-row-main {
    gap: 10px;
  }
  .count-row-id {
    flex-basis: 100%;
  }
  .count-confirm-btn {
    margin-left: 0;
  }
}
.blend-info .blend-cfu-subrow td {
  padding-top: 2px;
  padding-bottom: 2px;
  border-top: none;
}

/* ---------- Sample Pickups: bigger type, roomier header, for a page read
   at arm's length off a lab bench rather than a desk. ---------- */
.pickup-page .runs-table th {
  padding: 16px 14px;
  font-size: var(--fs-sm);
}
.pickup-page .runs-table td {
  padding: 16px 14px;
  font-size: var(--fs-md);
}
.pickup-page .runs-table th input[type='checkbox'],
.pickup-page .runs-table td input[type='checkbox'] {
  width: 20px;
  height: 20px;
}

/* ---------- Live dashboard status pill (startLiveRefresh in common.js) ---------- */
.live-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: var(--fs-xs);
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
}
.live-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex: none;
}
.live-status.is-synced::before {
  background: var(--success);
}
.live-status.is-loading::before {
  background: var(--warning);
}
.live-status.has-error {
  color: var(--danger);
  border-color: var(--danger);
}
.live-status.has-error::before {
  background: var(--danger);
}
.live-status:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: no-preference) {
  .live-status.is-loading::before {
    animation: live-status-pulse 1s ease-in-out infinite;
  }
}
@keyframes live-status-pulse {
  50% {
    opacity: 0.35;
  }
}
@media print {
  .live-status {
    display: none;
  }
}

/* Screen-reader-only label (visible to assistive tech, not on screen) */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Cross-links into detail pages the employee tier can't open (sales order
   detail, partner records): shown as plain text for them instead of a link
   that would 403. body.is-restricted is set by common.js. */
body.is-restricted .restricted-inert {
  pointer-events: none;
  color: inherit;
  text-decoration: none;
}

/* What's New (marketing feed) popover pieces -- see injectMarketingFeedWidget */
.marketing-feed-empty {
  padding: 8px;
}
.marketing-feed-heading {
  padding: 0 8px;
}
.marketing-feed-all {
  display: block;
  padding: 8px;
  text-align: center;
}

/* ---------- My Approvals (approvals.html) ---------- */
.approvals-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.approvals-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.approvals-stat-value {
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}
.approvals-stat-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 4px;
}
.approvals-stat.has-error {
  border-color: var(--danger);
  background: var(--danger-tint);
}
.approvals-stat.has-error .approvals-stat-value {
  color: var(--danger);
}
.approvals-chip-count {
  display: inline-block;
  min-width: 18px;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-align: center;
}
.ghost-btn.is-active .approvals-chip-count {
  background: var(--surface);
  color: var(--primary-text);
}
table.runs-table.approvals-table tbody tr:hover {
  cursor: default;
}
.approvals-check-col {
  width: 36px;
  text-align: center;
}
.approvals-type {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.approvals-title {
  font-weight: 600;
  color: var(--text);
}
.approvals-actions {
  justify-content: flex-end;
  flex-wrap: nowrap;
}
.approvals-row.is-sla-overdue td:first-child {
  box-shadow: inset 3px 0 0 var(--danger);
}
.approvals-row.is-sla-warn td:first-child {
  box-shadow: inset 3px 0 0 var(--warning);
}
.approvals-row {
  transition:
    opacity 0.2s ease,
    background-color 0.3s ease;
}
.approvals-row.is-saving {
  opacity: 0.55;
  pointer-events: none;
}
.approvals-row.is-synced {
  background: var(--primary-tint);
}
.approvals-row.has-error {
  background: var(--danger-tint);
}
@media (max-width: 720px) {
  .approvals-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}
@media print {
  .approvals-actions,
  .approvals-check-col,
  .approvals-filters,
  [data-action='bulk-approve'] {
    display: none !important;
  }
}

/* ---------- Permissions matrix (admin-permissions.html) ---------- */
.perm-toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.perm-toolbar-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.perm-matrix-wrap {
  overflow: auto;
  max-height: 70vh;
}
table.runs-table.perm-matrix {
  min-width: 0;
}
table.runs-table.perm-matrix tbody tr:hover {
  cursor: default;
}
.perm-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
}
.perm-matrix .perm-name-col {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 240px;
  max-width: 320px;
  background: var(--surface);
  text-align: left;
  white-space: normal;
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  border-right: 1px solid var(--border);
}
.perm-matrix thead .perm-name-col {
  z-index: 3;
}
.perm-matrix .perm-user-col {
  text-align: center;
  min-width: 76px;
  white-space: normal;
}
.perm-matrix .perm-category-row th {
  position: sticky;
  left: 0;
  background: var(--bg);
  color: var(--primary-text);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 12px;
}
.perm-cell {
  text-align: center;
  transition: background-color 0.3s ease;
}
.perm-cell input[type='checkbox'] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}
.perm-cell input[type='checkbox']:disabled {
  cursor: not-allowed;
}
.perm-cell:focus-within {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.perm-cell.is-saving {
  opacity: 0.5;
}
.perm-cell.is-synced {
  background: var(--primary-tint);
}
.perm-cell.has-error {
  background: var(--danger-tint);
}
.perm-matrix tr.is-locked .perm-name-col {
  color: var(--text-muted);
}

/* ---------- Supply Planning (planning.html) ---------- */
.plan-ctp-row {
  display: grid;
  grid-template-columns: minmax(200px, 2fr) minmax(120px, 1fr) auto;
  gap: 12px;
  align-items: end;
}
@media (max-width: 640px) {
  .plan-ctp-row {
    grid-template-columns: 1fr;
  }
}
.plan-ctp-result {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--primary-tint);
  color: var(--text);
}
.plan-ctp-result.has-error {
  background: var(--danger-tint);
  color: var(--danger);
}
.plan-ctp-date {
  font-size: var(--fs-lg);
  margin-bottom: 6px;
}
.plan-ctp-lines {
  margin: 0 0 6px;
  padding-left: 18px;
}
.plan-action.is-expedite {
  border-left: 3px solid var(--danger);
}
.plan-action.is-schedule_runs {
  border-left: 3px solid var(--warning);
}
table.runs-table.plan-table {
  min-width: 720px;
}
table.runs-table.plan-table tbody tr:hover,
table.runs-table.plan-grid tbody tr:hover {
  cursor: default;
}
.plan-table .is-num,
.plan-grid .is-num,
.plan-events .is-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.plan-table tr.is-at-risk td:first-child,
.plan-grid tr.is-at-risk th:first-child {
  box-shadow: inset 3px 0 0 var(--danger);
}
.plan-grid-wrap {
  overflow: auto;
}
table.runs-table.plan-grid {
  min-width: 1100px;
}
.plan-grid .plan-grid-product {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  min-width: 200px;
  text-align: left;
  white-space: normal;
  text-transform: none;
  letter-spacing: 0;
  font-size: var(--fs-sm);
  color: var(--text);
  border-right: 1px solid var(--border);
}
.plan-grid thead .plan-grid-product {
  z-index: 2;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  text-transform: uppercase;
}
.plan-expand {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.plan-expand:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.plan-cell.is-short {
  background: var(--danger-tint);
  color: var(--danger);
  font-weight: 700;
}
.plan-cell.is-low {
  color: var(--warning);
  font-weight: 600;
}
.plan-grid-detail > td {
  background: var(--bg);
  padding: 8px 12px 14px;
}
table.runs-table.plan-events {
  min-width: 0;
  background: var(--surface);
}
.plan-setting-input {
  width: 110px;
  text-align: right;
}
.plan-table tr.is-saving {
  opacity: 0.55;
}
.plan-table tr.is-synced td {
  background: var(--primary-tint);
}
.plan-table tr.has-error td {
  background: var(--danger-tint);
}
@media print {
  .plan-ctp-row button,
  [data-action='request-material'],
  [data-action='save-setting'] {
    display: none !important;
  }
  .plan-grid-wrap {
    overflow: visible;
  }
}

/* Capable-to-promise hint under the Sales Order Promise Date */
.ctp-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-weight: 400;
}
.ctp-hint.is-loading {
  opacity: 0.7;
}
.ctp-hint.is-late {
  color: var(--danger);
}

/* ---------- Alerts (alerts.html) + real-time toasts ---------- */
.alert-row.is-critical {
  border-left: 3px solid var(--danger);
}
.alert-row.is-warning {
  border-left: 3px solid var(--warning);
}
.alert-row.is-unread .alert-title {
  font-weight: 700;
}
.alert-row.is-saving {
  opacity: 0.55;
}
.alert-title {
  margin-top: 6px;
  color: var(--text);
}
.alerts-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.alerts-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}
table.runs-table.alerts-prefs {
  min-width: 560px;
}
table.runs-table.alerts-prefs tbody tr:hover {
  cursor: default;
}
.alerts-prefs tr.is-saving {
  opacity: 0.55;
}
.alerts-prefs tr.is-synced td {
  background: var(--primary-tint);
}
.alerts-prefs tr.has-error td {
  background: var(--danger-tint);
}

.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 12px 12px 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
}
.toast.is-critical {
  border-left-color: var(--danger);
}
.toast.is-leaving {
  opacity: 0;
  transform: translateY(8px);
}
@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
}
.toast-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: inherit;
  text-decoration: none;
  font-size: var(--fs-sm);
}
.toast-body span {
  color: var(--text-muted);
}
.toast-body:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.toast-close {
  flex: none;
}
@media print {
  .toast-stack {
    display: none !important;
  }
}

/* Labor page */
.labor-period-label {
  font-weight: 600;
  padding: 0 6px;
}
.labor-import {
  padding: 16px 18px;
}
.labor-note {
  margin-top: 14px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.labor-map-row {
  align-items: center;
  margin-top: 6px;
}
.labor-total {
  align-self: end;
  padding-bottom: 8px;
}
table.labor-table tbody tr:hover {
  cursor: default;
}
table.labor-table tr.has-clash td {
  background: var(--danger-tint);
}
@media (max-width: 720px) {
  #tempForm .grid-3 {
    grid-template-columns: 1fr;
  }
}
.widget-sub.has-error {
  color: var(--danger);
}

/* Partner contact people */
.contact-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 14px;
}
.contact-row {
  padding: 0 0 14px;
  border-bottom: 1px solid var(--border);
}
.contact-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.contact-row .grid {
  row-gap: 12px;
}
.contact-row .contact-remove {
  margin-top: 12px;
}
.contact-card {
  padding-right: 12px;
}
.contact-card + .contact-card {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* Panels whose content sits directly in the box (no table / form padding of its own) */
.table-panel.is-padded {
  padding: 14px 18px;
}

/* Shipping location picker in the partner form */
.ship-loc-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.ship-loc-bar label {
  min-width: 220px;
  flex: 1 1 220px;
  max-width: 360px;
}
input[readonly] {
  background: var(--bg);
  color: var(--text-muted);
}

/* Open Pick Tickets */
.pick-ticket-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.pt-edit-product {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.pt-edit-product:last-child {
  border-bottom: none;
}
.pt-edit-row {
  display: grid;
  grid-template-columns: 1fr 110px auto;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

/* Duplicate WO# resolution: pick which record to delete */
.dup-pick-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 10px;
  margin-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}
.dup-pick-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
}
.mini-table-wrap.is-delete-pick {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
  border-radius: var(--radius);
  background: var(--danger-tint);
}
.dup-pick-label {
  flex-direction: row;
}
.dup-pick-label input[type='radio'] {
  width: auto;
  margin: 0;
}

/* User Audit page */
.audit-filters {
  padding: 16px 18px;
}
.audit-filter-grid {
  margin: 12px 0;
}
table.audit-table tbody tr[data-action='open-user'] {
  cursor: pointer;
}
.audit-flag {
  white-space: normal;
}
.audit-ua {
  max-width: 360px;
  overflow-wrap: anywhere;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
table.audit-matrix td.has-count {
  background: var(--primary-tint);
  font-weight: 600;
  text-align: center;
}
table.audit-matrix th {
  text-transform: capitalize;
}
.audit-exports,
.audit-notes {
  padding: 16px 18px;
}
.audit-notes-list {
  margin: 0;
  padding-left: 18px;
  font-size: var(--fs-sm);
  line-height: 1.6;
}

/* ---------- Header account menu (avatar opens: signed-in name, My profile, Log Out) ---------- */
.account-menu {
  position: relative;
}
button.profile-link {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.account-menu-panel {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 40;
  min-width: 230px;
  max-width: min(320px, 90vw);
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}
.account-menu.is-open .account-menu-panel {
  display: flex;
}
.account-menu-panel .current-user {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  padding: 2px 2px 8px;
  border-bottom: 1px solid var(--border);
  white-space: normal;
  flex: 0 0 auto;
}
.account-menu-panel .ghost-btn {
  width: 100%;
  justify-content: center;
  text-align: center;
  text-decoration: none;
}
body.exec-dashboard .account-menu-panel {
  background: var(--exec-surface-2);
  color: var(--exec-text);
  border-color: var(--exec-border);
}
body.exec-dashboard .account-menu-panel .current-user {
  color: var(--exec-text-muted);
  border-bottom-color: var(--exec-border);
}
@media print {
  .account-menu-panel {
    display: none !important;
  }
}

/* ---------- Active holds: one collapsible group per reason ---------- */
.hold-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  margin-bottom: 8px;
}
.hold-group-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
.hold-group-summary::-webkit-details-marker {
  display: none;
}
.hold-group-summary::before {
  content: '\25B8';
  margin-right: 8px;
  color: var(--text-muted);
  transition: transform 0.15s;
}
.hold-group[open] > .hold-group-summary::before {
  transform: rotate(90deg);
}
.hold-group-title {
  flex: 1 1 auto;
}
.hold-group-list {
  max-height: 340px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}
.hold-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
}
.hold-row:last-child {
  border-bottom: 0;
}
.hold-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.hold-row-main .widget-sub {
  overflow-wrap: anywhere;
}

/* ---------- Phones: nothing may push the page wider than the screen ---------- */
.weeks-container > *,
.kanban-container > * {
  min-width: 0;
}
.table-wrap {
  max-width: 100%;
}
@media (max-width: 600px) {
  .ship-tag {
    width: 100%;
    max-width: 4in;
    height: auto;
    aspect-ratio: 1 / 1;
  }
  .label-sheet {
    display: block;
  }
  .label-sheet .ship-tag {
    margin-bottom: 12px;
  }
}

/* Label lookup row (WO# search + copies + print format) wraps instead of running off a phone */
.lookup-row {
  flex-wrap: wrap;
}
.copies-field,
.copies-field select,
.copies-field input {
  min-width: 0;
  max-width: 100%;
}

/* ---------- Touch targets: nothing clickable under ~32px (40px on touch screens) ---------- */
.live-status {
  min-height: 32px;
}
.ghost-btn.small,
.primary-btn.small,
.danger-btn.small,
.danger-btn.btn-sm {
  min-height: 32px;
}
.icon-btn.stock-group-toggle,
.exec-legend-toggle {
  min-width: 32px;
  min-height: 32px;
}
.plan-expand {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
}
.exec-card-link {
  display: inline-block;
  padding-block: 8px;
}
.exec-radial-legend-row {
  min-height: 28px;
}
input[type='checkbox'],
input[type='radio'] {
  min-width: 18px;
  min-height: 18px;
}
/* Touch screens: every button is at least 44 x 44 px (Apple HIG / WCAG 2.5.5). The .small variants are
   included on purpose -- their 32px desktop minimum above would otherwise win on a tablet. Links styled as
   buttons are flex boxes here so their label stays centred in the taller box. */
@media (pointer: coarse) {
  .ghost-btn,
  .primary-btn,
  .danger-btn,
  .ghost-btn.small,
  .ghost-btn.btn-sm,
  .primary-btn.small,
  .danger-btn.small,
  .danger-btn.btn-sm,
  .seg-btn,
  .filter-btn,
  .live-status,
  .nav-icon-badge,
  .plan-expand,
  .icon-btn,
  .bulk-clear,
  .task-day-header,
  .maint-tabs button,
  .exec-todo-toggle button {
    min-height: 44px;
  }
  .ghost-btn.small,
  .primary-btn.small,
  .bulk-clear {
    min-width: 44px;
  }
  .icon-btn.stock-group-toggle,
  .exec-legend-toggle,
  .icon-btn {
    min-width: 44px;
  }
  a.ghost-btn,
  a.primary-btn,
  a.danger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  input[type='checkbox'],
  input[type='radio'] {
    width: 24px;
    height: 24px;
  }
  select,
  input:not([type='checkbox']):not([type='radio']):not([type='hidden']) {
    min-height: 40px;
  }
}
/* A scroll container must also be the containing block for absolutely-positioned content
   inside it (e.g. the visually-hidden "Actions" header text), or that content escapes the
   clip and widens the whole page on a phone. */
.table-wrap {
  position: relative;
}

/* Empty states: a short message + one action, sized to the space they replace */
.empty-state {
  padding: 20px 16px;
}
.empty-state.is-compact {
  margin: 12px auto;
  padding: 12px 16px;
  flex-direction: row;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}
.empty-state p {
  margin: 0;
}

/* Phones: one step up from the desktop base so text is comfortable at arm's length. */
@media (max-width: 600px) {
  :root {
    --fs-xs: 0.8125rem;
    --fs-sm: 0.875rem;
    --fs-md: 0.9375rem;
    --fs-lg: 1.0625rem;
    --fs-xl: 1.3rem;
    --fs-2xl: 1.55rem;
    --fs-title: 1.4rem;
  }
}

/* ---------- Accent themes (Profile > Appearance). Forest is the default green: no attribute set. ---------- */
:root[data-accent='ocean'] {
  --primary: #2f66c9;
  --primary-dark: #1f4fa8;
  --primary-tint: #e6eefc;
  --primary-text: #1f4fa8;
  --on-primary: #ffffff;
  --on-primary-strong: #ffffff;
}
:root[data-accent='plum'] {
  --primary: #7d52c4;
  --primary-dark: #6a3fb0;
  --primary-tint: #f0e9fb;
  --primary-text: #6a3fb0;
  --on-primary: #ffffff;
  --on-primary-strong: #ffffff;
}
:root[data-accent='ember'] {
  --primary: #c85a2a;
  --primary-dark: #b1491d;
  --primary-tint: #fcebe2;
  --primary-text: #9a3f19;
  --on-primary: #ffffff;
  --on-primary-strong: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root[data-accent='ocean'] {
    --primary: #6d9bec;
    --primary-dark: #4f7fd0;
    --primary-tint: #1a2438;
    --primary-text: #6d9bec;
    --on-primary: #0b1218;
    --on-primary-strong: #0b1218;
  }
  :root[data-accent='plum'] {
    --primary: #ad8ce6;
    --primary-dark: #8f6bd1;
    --primary-tint: #261c36;
    --primary-text: #ad8ce6;
    --on-primary: #0b1218;
    --on-primary-strong: #0b1218;
  }
  :root[data-accent='ember'] {
    --primary: #ec9a6c;
    --primary-dark: #d77a48;
    --primary-tint: #33201a;
    --primary-text: #ec9a6c;
    --on-primary: #0b1218;
    --on-primary-strong: #0b1218;
  }
}

/* Accent on top of a background theme (an uploaded photo background, or the LSU / sci-fi themes): those pin their own light palette on <body>,
   so the chosen accent has to be re-applied there. Backgrounds themselves are untouched. */
:root[data-accent='ocean'] body.themed-bg {
  --primary: #2f66c9;
  --primary-dark: #1f4fa8;
  --primary-tint: #e6eefc;
  --primary-text: #1f4fa8;
  --on-primary: #ffffff;
  --on-primary-strong: #ffffff;
}
:root[data-accent='plum'] body.themed-bg {
  --primary: #7d52c4;
  --primary-dark: #6a3fb0;
  --primary-tint: #f0e9fb;
  --primary-text: #6a3fb0;
  --on-primary: #ffffff;
  --on-primary-strong: #ffffff;
}
:root[data-accent='ember'] body.themed-bg {
  --primary: #c85a2a;
  --primary-dark: #b1491d;
  --primary-tint: #fcebe2;
  --primary-text: #9a3f19;
  --on-primary: #ffffff;
  --on-primary-strong: #ffffff;
}

/* ---------- Shared "workspace" look on every page (matches Tasks / Calendar / Team) ---------- */
:root {
  --radius-lg: calc(var(--radius) * 1.6);
}
.table-panel,
.week-section,
.stat-tile,
.chart-card,
.widget-card,
.modal {
  border-radius: var(--radius-lg);
}
.table-wrap.table-panel {
  overflow: hidden auto;
}

/* Filter buttons read as one segmented pill control, like the Tasks filters */
.filter-row:not(:has(input, select, textarea)) {
  width: fit-content;
  max-width: 100%;
  padding: 4px;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.filter-row:not(:has(input, select, textarea)) .filter-btn {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
  padding: 0.45em 1.1em;
  font-size: var(--fs-sm);
}
.filter-row:not(:has(input, select, textarea)) .filter-btn:hover {
  color: var(--text);
}
.filter-row:not(:has(input, select, textarea)) .filter-btn.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}

/* Search boxes are pills everywhere */
input[type='search'],
input[placeholder^='Search' i],
input[placeholder^='Filter by' i] {
  border-radius: 999px;
  padding-inline: 1.1em;
}

/* Small ghost buttons that toggle a view (Open / All, Pending / All, kind filters...) group into the same segmented pill */
.row-actions:has(> .ghost-btn.small.is-active) {
  width: fit-content;
  max-width: 100%;
  padding: 4px;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.row-actions:has(> .ghost-btn.small.is-active) > .ghost-btn.small {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.45em 1.1em;
  font-size: var(--fs-sm);
}
.row-actions:has(> .ghost-btn.small.is-active) > .ghost-btn.small:hover {
  color: var(--text);
}
.row-actions:has(> .ghost-btn.small.is-active) > .ghost-btn.small.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}

.detail-item .v {
  overflow-wrap: anywhere;
  min-width: 0;
}
.detail-item {
  min-width: 0;
}
.contact-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.contact-link {
  color: var(--primary-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}
/* Inline edit rows (e.g. ship date + Save/Cancel in a narrow order card): wrap as a group, buttons never squash or stack their text */
.detail-item .v .row {
  flex-wrap: wrap;
}
.detail-item .v .row > button,
.edit-actions > button {
  flex: none;
  white-space: nowrap;
}
.detail-item .v .row > input[type='date'] {
  flex: 0 1 auto;
  min-width: 0;
}
/* Order forms: fields and tables never push past the modal margin */
.modal .grid > label,
.modal .grid > * {
  min-width: 0;
}
.modal input,
.modal select,
.modal textarea {
  max-width: 100%;
  box-sizing: border-box;
}
.modal .mini-table-wrap {
  overflow-x: auto;
  max-width: 100%;
}

/* Wide data tables on a phone: each row becomes a stacked card (labels come from the column headers, set by common.js)
   so every button and field is on screen instead of sitting off to the right of a sideways-scrolling table */
@media (max-width: 760px) {
  .table-wrap:has(> .is-stacked) {
    overflow-x: hidden;
  }
  table.runs-table.is-stacked {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    table-layout: auto;
  }
  .is-stacked td {
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .is-stacked td :not(button):not(svg):not(select):not(input) {
    white-space: normal;
    text-overflow: clip;
    overflow: visible;
    max-width: 100%;
  }
  .is-stacked,
  .is-stacked tbody,
  .is-stacked tr,
  .is-stacked td {
    display: block;
    width: 100%;
    box-sizing: border-box;
  }
  .is-stacked thead {
    display: none;
  }
  .is-stacked tbody tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    margin-bottom: 12px;
    padding: 8px 12px;
  }
  .is-stacked td {
    border: 0;
    padding: 6px 0;
  }
  .is-stacked td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: var(--fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 2px;
  }
  .is-stacked td.ship-actions-cell {
    border-top: 1px solid var(--border);
    margin-top: 6px;
    padding-top: 10px;
  }
  .is-stacked .ship-actions {
    min-width: 0;
    max-width: none;
  }
  .is-stacked .ship-actions > button {
    flex: 1 1 calc(50% - 6px);
    min-height: 40px;
  }
  .is-stacked.has-head-buttons thead {
    display: block;
  }
  .is-stacked.has-head-buttons thead tr {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 0 8px;
  }
  .is-stacked.has-head-buttons thead th {
    display: none;
    width: auto;
  }
  .is-stacked.has-head-buttons thead th:has(button) {
    display: block;
  }
  .is-stacked tbody td[colspan] {
    width: 100%;
  }
}

/* Always fit the screen: nothing is allowed to be wider than the space it is in (phones, laptops, wide monitors) */
.grid > *,
.row-actions > *,
form > label,
.modal > * {
  min-width: 0;
}
input,
select,
textarea {
  max-width: 100%;
  box-sizing: border-box;
}
input[type='file'] {
  width: 100%;
  max-width: 100%;
}
img,
svg,
video,
canvas {
  max-width: 100%;
}

/* Stacked cards: text always wraps (beats any table-cell no-wrap rule) */
@media (max-width: 760px) {
  table.runs-table.is-stacked td,
  table.runs-table.is-stacked td > * {
    white-space: normal;
  }
  table.runs-table.is-stacked td button {
    white-space: nowrap;
  }
}

/* Shown on any copy that is not the live system */
.env-badge {
  position: fixed;
  left: 8px;
  bottom: 8px;
  z-index: 9000;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--danger, #b3261e);
  color: #fff;
  font-size: var(--fs-xs, 0.75rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  pointer-events: none;
  opacity: 0.9;
}
/* Client demo sandbox: calmer than the red test badge, still impossible to miss. */
.env-badge.is-sandbox {
  background: var(--primary, #1d5fa8);
  color: var(--on-primary, #fff);
}
@media print {
  .env-badge {
    display: none;
  }
}

/* ---------- System Health (admin-health.html) ---------- */
.health-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}
.health-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--success);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.health-tile.has-error {
  border-left-color: var(--danger);
  background: var(--danger-tint);
}
.health-tile-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.health-tile-value {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text);
}
.health-route-grid {
  gap: 12px;
  align-items: start;
}
.health-route-grid > .is-wide {
  grid-column: 1 / -1;
}
@media (max-width: 900px) {
  .health-route-grid {
    grid-template-columns: 1fr;
  }
}

/* Idle sign-out warning (common.js showIdleWarning) -- sits above every other dialog */
#idleWarnModal {
  z-index: 400;
}
.idle-warn-text {
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--text);
}
#idleWarnModal .modal-footer {
  justify-content: flex-end;
}

/* ---------- Offline queue (common.js apiFetchQueued) ---------- */
.queue-row.is-saving {
  box-shadow: inset 4px 0 0 var(--warning);
}
.queue-row.is-synced {
  box-shadow: inset 4px 0 0 var(--success);
  background: var(--primary-tint);
  transition: background 0.4s;
}
.queue-row.has-clash {
  box-shadow: inset 4px 0 0 var(--danger);
  background: var(--danger-tint);
}
.offline-queue-pill {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--text);
  color: var(--surface);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow);
}

/* ---------- iPhone "Add to Home Screen" hint ---------- */
.ios-install-hint {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: var(--fs-sm);
}
.ios-install-hint span {
  flex: 1;
}
.health-panel {
  padding: 14px 16px;
}
.health-panel .runs-table {
  margin-top: 4px;
}

/* Links inside muted helper text inherit its (contrast-checked) color and stay underlined, instead of the browser's
   default blue, which fell below 4.5:1 on the photo-scrim page backgrounds. */
.widget-sub a:not([class]) {
  color: inherit;
  text-decoration: underline;
  font-weight: 600;
}

/* ---------- Ship against (shipping-new step 1) and the PO-page return banner ---------- */
.ship-against-panel {
  margin-top: 12px;
}
fieldset.inline-radios {
  border: 0;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: center;
}
/* Reads like the other field labels (not the uppercase section legend). */
fieldset.inline-radios legend {
  width: 100%;
  padding: 0;
  margin-bottom: 4px;
  font-size: inherit;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text-muted);
}
.shipment-return-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: var(--primary-tint);
  color: var(--primary-text);
  border: 1px solid var(--border);
  position: sticky;
  top: 8px;
  z-index: 50;
  box-shadow: var(--shadow);
}
.shipment-return-banner span {
  flex: 1 1 320px;
  font-size: var(--fs-sm);
}

/* Draft PO: vendor-on-file line, and the dialogs opened from the draft sit above it */
.dpo-vendor-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 8px 0 4px;
}
.dpo-vendor-info:empty {
  display: none;
}
#newItemModal,
#vendorModal {
  z-index: 150;
}
.dpo-results .dpo-new-item {
  width: auto;
  justify-self: start;
  align-self: flex-start;
  margin-top: 6px;
}

/* ---------- Item photos window (item-photos.js) ---------- */
.item-photos-body {
  padding: 12px var(--pad-modal) 0;
}
.item-photos-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.item-photo {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.item-photo.is-primary {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.item-photo-link {
  display: block;
  aspect-ratio: 1 / 1;
  border-radius: calc(var(--radius) - 2px);
  overflow: hidden;
  background: var(--bg);
}
.item-photo-link img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.item-photo-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 1.4em;
  font-size: var(--fs-xs);
}
.item-photo-primary {
  font-weight: 700;
  padding: 0.1em 0.6em;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
}
.item-photo-label {
  color: var(--text-muted);
  overflow-wrap: anywhere;
}
.item-photo-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.item-photos-grid .empty-state {
  grid-column: 1 / -1;
}

/* ---------- Vendor page: items we buy there (partner-detail.js) ---------- */
.vendor-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}
.vendor-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.vendor-item-thumb {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: calc(var(--radius) - 2px);
  object-fit: contain;
  background: var(--bg);
}
.vendor-item-thumb.is-empty {
  display: block;
}
.vendor-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Sign-in page: choosing a two-step method (login.html #mfaChooseForm). The login card keeps its own light palette. */
.login-form .mfa-choice {
  border: 0;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.login-form .mfa-choice-option {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #dce3de;
  border-radius: 8px;
  background: #f7f9f7;
  font-size: 13px;
  cursor: pointer;
}
.login-form .mfa-choice-option:has(input:checked) {
  border-color: #2f7a4f;
  background: #eaf4ee;
}
.login-form .mfa-choice-option input {
  padding: 0;
  margin: 0;
  width: 16px;
  height: 16px;
  accent-color: #2f7a4f;
}
.login-form .mfa-setup-totp {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-form .mfa-setup-totp .login-newpw-note {
  margin: 0;
}
.login-form .mfa-note {
  color: #7a5200;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* WO# with its 4x6 label button */
.wo-with-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.wo-label-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-text);
}
.wo-label-btn:hover,
.wo-label-btn:focus-visible {
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
}
@media print {
  .wo-label-btn {
    display: none;
  }
}
/* The hidden frame printLabelPdf prints through (here too: not every page loads workspace.css) */
.print-frame {
  position: fixed;
  width: 0;
  height: 0;
  border: 0;
  right: 0;
  bottom: 0;
}
@media (pointer: coarse) {
  .wo-label-btn {
    width: 40px;
    height: 40px;
  }
}
.copies-field .bucket-lbs-input {
  width: 8rem;
}
/* A stacked card never shows a label over an empty cell */
@media (max-width: 760px) {
  .is-stacked td:empty {
    display: none;
  }
}
/* Compact stacked cards: fields two to a row; the first cell (the record's id), the last two (notes, actions) span the card */
@media (max-width: 760px) {
  table.is-card-grid.is-stacked tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 14px;
  }
  table.is-card-grid.is-stacked tbody td:first-child,
  table.is-card-grid.is-stacked tbody td:nth-last-child(2),
  table.is-card-grid.is-stacked tbody td:last-child {
    grid-column: 1 / -1;
  }
  table.is-card-grid.is-stacked tbody td:first-child {
    font-size: var(--fs-md, 1.05rem);
    font-weight: 700;
  }
  table.is-card-grid.is-stacked tbody td {
    min-width: 0;
  }
}

/* Sales order product lines */
.so-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.so-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.so-item-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.4fr) minmax(90px, 0.8fr) minmax(90px, 0.8fr) minmax(90px, 0.8fr) auto;
  gap: 8px 12px;
  align-items: end;
}
.so-item-grid label {
  min-width: 0;
}
.so-item-total {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-bottom: 8px;
  font-variant-numeric: tabular-nums;
}
.so-item-remove {
  align-self: end;
  margin-bottom: 4px;
}
/* the assign dialog's minimum-CFU line, and confirm messages that list WO#s one per line */
.assign-cfu {
  margin: 4px 0 8px;
  font-size: var(--fs-sm);
  color: var(--text);
}
#confirmModalMessage {
  white-space: pre-line;
}
.cfu-unverified {
  color: color-mix(in srgb, var(--warning) 65%, var(--text));
  font-weight: 600;
}
.so-item-cfu {
  display: block;
  max-width: 280px;
  margin-top: 8px;
}
.so-item-cfu select {
  width: 100%;
}
@media (max-width: 640px) {
  .so-item-cfu {
    max-width: none;
  }
}
.so-item-shipped {
  margin: 6px 0 0;
}
.so-item .blend-info {
  margin-top: 8px;
}
.so-items-foot {
  margin-top: 10px;
  gap: 10px;
  flex-wrap: wrap;
}
.so-items-total {
  margin: 0;
  font-weight: 600;
}
@media (max-width: 640px) {
  .so-item-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .so-item-product-field {
    grid-column: 1 / -1;
  }
  .so-item-total {
    padding-bottom: 0;
  }
  .so-item-remove {
    grid-column: 2;
    justify-self: end;
  }
}

/* New Shipment: the picked sales order's lines and what is left on each */
.so-lines-panel {
  max-width: 560px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--primary) 5%, var(--surface));
}
.so-lines-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.so-lines-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.so-lines-list li.is-done {
  color: var(--text-muted);
}
.so-lines-name {
  min-width: 0;
  overflow-wrap: anywhere;
}
.blend-line-block.is-ingredient {
  border-left: 3px solid color-mix(in srgb, var(--primary) 50%, var(--border));
}
.blend-line-ingredient {
  flex: 1 1 220px;
  min-width: 0;
}
.blend-kind-chip {
  flex: none;
}

/* Sales order board card: each line's shipped progress under the overall bar */
.so-card-lines {
  list-style: none;
  margin: 8px 0 0;
  padding: 6px 0 0;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.so-card-line-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: var(--fs-xs, 0.75rem);
  color: var(--text-muted);
}
.so-card-line-name {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
}
.so-card-line-qty {
  flex: none;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
/* The card's move menu keeps its small look but gets a finger-sized tap area */
@media (pointer: coarse) {
  .task-menu-btn {
    position: relative;
  }
  .task-menu-btn::after {
    content: '';
    position: absolute;
    inset: -8px;
  }
}
.meter.is-thin {
  height: 3px;
  margin-top: 3px;
}
/* Order view: one card per product line, its held WO#s inside it */
.so-lines {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.so-line {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.so-line p {
  margin: 0;
}
.so-line-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.so-line-name {
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}
.so-line-total {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  flex: none;
}
.so-line-terms,
.so-line-status {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.so-line-status strong {
  color: var(--text);
  font-weight: 600;
}
.so-line-meter {
  margin: 2px 0;
}
.so-line-assign {
  align-self: flex-start;
  margin-top: 4px;
}
.so-line-done {
  font-size: var(--fs-sm);
  color: var(--primary-text);
  font-weight: 600;
}
.held-list {
  list-style: none;
  margin: 2px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px dashed var(--border);
}
.held-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 2px 0;
  border-bottom: 1px dashed var(--border);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
/* Assign inventory dialog */
.assign-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  gap: 10px 16px;
  align-items: end;
}
/* Segmented choice: radios that read as one pill control, same look as the filter pills */
fieldset.seg-control {
  border: 0;
  padding: 0;
  margin: 0;
}
fieldset.seg-control legend {
  padding: 0;
  margin-bottom: 6px;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text-muted);
}
.seg-pills {
  display: flex;
  padding: 4px;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.seg-pills label {
  flex: 1 1 0;
  position: relative;
  margin: 0;
}
.seg-pills input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.seg-pills span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  white-space: nowrap;
  transition-property: background-color, color;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}
.seg-pills label:hover span {
  color: var(--text);
}
.seg-pills input:checked + span {
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}
.seg-pills input:focus-visible + span {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
@media (pointer: coarse) {
  .seg-pills span {
    min-height: 40px;
  }
}
.assign-table .is-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.assign-table .assign-take {
  text-align: right;
}
.assign-picked {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.assign-plan {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.assign-part {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.assign-take {
  width: 90px;
}
@media (max-width: 640px) {
  .assign-controls {
    grid-template-columns: minmax(0, 1fr);
  }
}
.so-item-product-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.so-item-new-blend {
  align-self: flex-start;
  font-size: var(--fs-xs, 0.75rem);
}
.so-item-supply {
  margin: 6px 0 0;
  font-size: var(--fs-sm, 0.875rem);
}
.so-item-supply.is-ok {
  color: var(--success-text, var(--primary-text));
}
.so-item-supply.is-late {
  color: var(--warning-text, var(--text));
}
.customer-status {
  align-self: end;
  margin: 0 0 10px;
}
.ship-to-picker {
  margin-bottom: 12px;
}
.widget-sub.ship-to-hint {
  margin-bottom: 12px;
}
.ship-to-picker select {
  width: 100%;
  padding-right: 34px;
  text-overflow: ellipsis;
}
.ship-to-picker + .widget-sub {
  margin-bottom: 14px;
}
.ship-to-picker .widget-sub {
  margin: 6px 0 0;
}
.ship-to-new {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  padding: 14px 0 0;
}
.ship-to-new label {
  flex: 1 1 240px;
}
@media (max-width: 1024px) {
  .ship-to-picker select,
  .ship-to-new input,
  .ship-to-new .ghost-btn {
    min-height: 44px;
  }
  .ship-to-picker .link-btn,
  .ship-to-actions .ghost-btn {
    min-height: 44px;
  }
}
.ship-to-status {
  margin: 10px 0 0;
  font-size: 0.9rem;
}
.ship-to-status.is-synced {
  color: var(--primary-text);
  font-weight: 600;
}
.ship-to-status.has-error {
  color: var(--danger);
  font-weight: 600;
}
.customer-status.is-new {
  color: var(--primary-text);
  font-weight: 600;
}
.link-btn {
  background: none;
  border: 0;
  padding: 2px 0;
  color: var(--primary-text);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
}
.link-btn:hover,
.link-btn:focus-visible {
  text-decoration-thickness: 2px;
}
.assign-search {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 260px;
}

/* Wizard footers on phones: wrap the buttons instead of pushing Next off-screen, and leave room under them for the Support button. */
@media (max-width: 600px) {
  .wizard-footer {
    flex-wrap: wrap;
    padding-bottom: 72px;
  }
  .wizard-footer .spacer {
    flex-basis: 100%;
    height: 0;
  }
}
/* Text-style buttons get a finger-sized tap area on touch screens. */
@media (pointer: coarse) {
  .link-btn {
    min-height: 44px;
    padding: 10px 0;
  }
}
.assign-source {
  margin-bottom: 16px;
}
.held-more summary {
  padding: 8px 0;
  font-size: var(--fs-sm);
  color: var(--primary-text);
  cursor: pointer;
}
.held-more summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.held-more .held-list {
  border-top: 0;
}

/* New Shipment: WO#s held for the order, grouped by order line, a ship amount per WO# */
.held-ship {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 12px;
  align-items: start;
}
.held-ship-group {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.held-ship-name {
  margin: 0 0 4px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.held-ship-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.held-ship-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px dashed var(--border);
}
.held-ship-wo {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}
.held-ship-held {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.held-ship-input {
  margin: 0;
  flex: none;
}
.held-ship-input input {
  width: 104px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.held-ship-total {
  margin: 10px 0 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
/* Blend Recipes opened from a sales order, when the browser won't close the tab after saving */
.handoff-note {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  color: var(--text);
  font-weight: 600;
}
/* Sales order customer step: matching Partners customers as a tappable list under the name */
.customer-field {
  position: relative;
  min-width: 0;
}
.suggest-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.suggest-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.suggest-item:hover,
.suggest-item:focus-visible {
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  outline: none;
}
.suggest-item:focus-visible {
  box-shadow: inset 0 0 0 2px var(--primary);
}
.suggest-sub {
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
/* Sales order Review step: one section per step, each with Edit */
.review-sections {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.review-section {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.review-section p {
  margin: 0 0 4px;
  overflow-wrap: anywhere;
}
.review-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}
.review-head h3 {
  margin: 0;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
}
.review-muted {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.review-flag {
  color: var(--primary-text);
  font-weight: 600;
  font-size: var(--fs-sm);
}
.review-note {
  padding: 8px 10px;
  border-left: 3px solid var(--border);
  background: var(--bg);
  white-space: pre-wrap;
}
.review-lines {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
.review-lines li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px dashed var(--border);
}
.review-line-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.review-line-total,
.review-total span:last-child {
  flex: none;
  font-variant-numeric: tabular-nums;
}
.review-total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
/* Sales order saved screen */
#wizardDoneTitle {
  font-size: var(--fs-xl);
  margin-bottom: 6px;
}
.done-summary {
  margin: 0 0 4px;
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
#wizardDoneTitle:focus {
  outline: none;
}
#wizardDoneTitle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}
.done-actions {
  margin-top: 12px;
  align-items: center;
}
.done-actions > * {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
@media (max-width: 600px) {
  .done-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
/* Sales order view: status chips on one row, then only the fields that are filled in */
.so-view-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 12px;
}
.so-view-note {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-left: 3px solid var(--border);
  background: var(--bg);
  font-size: var(--fs-sm);
  white-space: pre-wrap;
}
@media (pointer: coarse) {
  .so-view-customer {
    display: inline-block;
    padding: 10px 0;
  }
}
/* Stacked (phone) tables: a cell with nothing in it is left out of the card */
@media (max-width: 760px) {
  table.is-stacked td.is-empty-cell {
    display: none;
  }
}

/* Assign dialog: a long WO# list scrolls inside the dialog so Cancel / Hold stay in view */
.assign-plan .table-wrap {
  max-height: min(46vh, 420px);
  overflow-y: auto;
}
.assign-plan .assign-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}
#assignModal .modal {
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
}
#assignModal .modal-body {
  overflow-y: auto;
  min-height: 0;
}
/* sticks to the very bottom edge (over the body's own bottom padding) so nothing scrolls through underneath it */
#assignModal .modal-footer {
  position: sticky;
  bottom: calc(-1 * var(--pad-modal));
  z-index: 2;
  background: var(--surface);
  margin-bottom: calc(-1 * var(--pad-modal));
  padding-bottom: var(--pad-modal);
}

/* ---- Tips review 2026-10-23 (UI pass; side-by-side preview in preview/ux-compare.html) ---- */

/* Switch: a checkbox with role="switch" for settings that save the moment they're clicked (My Alerts, the
   Permissions matrix). Forms with a Save button keep plain checkboxes. */
input[type='checkbox'].switch-input {
  appearance: none;
  position: relative;
  width: 36px;
  height: 20px;
  min-width: 36px;
  margin: 0;
  border-radius: 999px;
  /* --text-muted, not --border: the Off track needs 3:1 against the page to read as a control. */
  background: var(--text-muted);
  cursor: pointer;
  vertical-align: middle;
  transition: background-color 160ms ease;
  flex: none;
}
input[type='checkbox'].switch-input::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform 160ms ease;
}
input[type='checkbox'].switch-input:checked {
  background: var(--primary);
}
input[type='checkbox'].switch-input:checked::before {
  transform: translateX(16px);
}
input[type='checkbox'].switch-input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
input[type='checkbox'].switch-input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
@media (pointer: coarse) {
  input[type='checkbox'].switch-input {
    width: 44px;
    height: 26px;
    min-width: 44px;
  }
  input[type='checkbox'].switch-input::before {
    width: 22px;
    height: 22px;
  }
  input[type='checkbox'].switch-input:checked::before {
    transform: translateX(18px);
  }
}

/* Bulk actions bar: appears once a row is ticked and sticks to the bottom of the screen while the list scrolls. */
.bulk-bar {
  position: sticky;
  bottom: 16px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--text);
  color: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  transform: translateY(12px);
  opacity: 0;
  visibility: hidden;
  transition:
    transform 180ms ease,
    opacity 180ms ease,
    visibility 180ms;
}
.bulk-bar.is-active {
  transform: none;
  opacity: 1;
  visibility: visible;
}
/* Count and buttons sit on the left: the floating help button covers the bottom-right corner. */
.bulk-count {
  font-weight: 600;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.bulk-clear {
  background: none;
  border: none;
  padding: 4px 2px;
  color: var(--surface);
  font: inherit;
  font-size: var(--fs-sm);
  text-decoration: underline;
  cursor: pointer;
}
.bulk-clear:focus-visible {
  outline: 2px solid var(--surface);
  outline-offset: 2px;
}
table.runs-table tbody tr.is-selected td {
  background: var(--primary-tint);
}

/* Data tables: a capped-height wrap so the header row can stay visible while the rows scroll. */
.table-wrap.is-scroll-y {
  max-height: calc(100vh - 160px);
  overflow: auto;
}
table.runs-table.has-sticky-head thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--border);
}
table.runs-table th.is-num,
table.runs-table td.is-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  input[type='checkbox'].switch-input,
  input[type='checkbox'].switch-input::before,
  .bulk-bar {
    transition: none;
  }
}
@media print {
  .bulk-bar {
    display: none;
  }
  .table-wrap.is-scroll-y {
    max-height: none;
    overflow: visible;
  }
}

/* Profile > Passkeys (profile.js) */
/* Last section on the page: room so the floating help button never covers Add a passkey. */
.passkey-section {
  margin-bottom: 72px;
}
.passkey-panel {
  display: grid;
  gap: 10px;
}
.passkey-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.passkey-list:empty {
  display: none;
}
.passkey-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

/* Opt-in: a .table-wrap.stack-narrow turns its table into cards whenever the space it sits in is too narrow for its
   columns (phones, iPad portrait) -- decided by the wrapper's width, not the screen's. common.js marks the table
   .is-stacked and labels each cell from its column header. The first cell heads the card; the rest flow two or three
   to a line. */
.table-wrap.stack-narrow {
  container: stacknarrow / inline-size;
}
@container stacknarrow (max-width: 899px) {
  .stack-narrow > table.is-stacked,
  .stack-narrow > table.is-stacked tbody {
    display: block;
    width: 100%;
    min-width: 0;
  }
  .stack-narrow > table.is-stacked thead {
    display: none;
  }
  .stack-narrow > table.is-stacked tbody tr {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0 14px;
    margin-bottom: 10px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
  }
  .stack-narrow > table.is-stacked td {
    display: block;
    padding: 6px 0;
    border: 0;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .stack-narrow > table.is-stacked td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: var(--fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
  }
  .stack-narrow > table.is-stacked td:first-child,
  .stack-narrow > table.is-stacked td[colspan] {
    grid-column: 1 / -1;
  }
  .stack-narrow > table.is-stacked td:first-child:not([colspan]) {
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2px;
    font-weight: 700;
  }
  .stack-narrow > table.is-stacked td:first-child::before {
    display: none;
  }
}

/* ---------- Full-size photo (openPhotoViewer in item-photos.js) ---------- */
.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 56px;
  align-items: center;
  background: rgba(8, 12, 10, 0.88);
}
.photo-viewer.hidden {
  display: none;
}
.photo-viewer-figure {
  grid-column: 2;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.photo-viewer-figure img {
  max-width: 100%;
  max-height: calc(100dvh - 96px);
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: #fff;
}
.photo-viewer-caption {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 16px;
  color: #fff;
  font-size: var(--fs-sm);
  text-wrap: pretty;
  text-align: center;
}
.photo-viewer-caption a {
  color: #fff;
}
.photo-viewer-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 150ms ease-out;
}
.photo-viewer-btn:hover {
  background: rgba(255, 255, 255, 0.28);
}
.photo-viewer-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.photo-viewer-btn.is-close {
  position: absolute;
  top: 12px;
  right: 12px;
}
.photo-viewer-btn.is-prev {
  grid-column: 1;
  grid-row: 1;
  justify-self: center;
}
.photo-viewer-btn.is-next {
  grid-column: 3;
  grid-row: 1;
  justify-self: center;
}
.photo-viewer:not(.has-many) .is-prev,
.photo-viewer:not(.has-many) .is-next {
  visibility: hidden;
}
.part-thumb {
  cursor: zoom-in;
}
@media (max-width: 640px) {
  .photo-viewer {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    padding: 56px 8px 12px;
    row-gap: 8px;
  }
  .photo-viewer-figure {
    grid-column: 1 / -1;
    grid-row: 1;
  }
  .photo-viewer-figure img {
    max-height: calc(100dvh - 190px);
  }
  .photo-viewer-btn.is-prev,
  .photo-viewer-btn.is-next {
    grid-row: 2;
  }
  .photo-viewer-btn.is-next {
    grid-column: 2;
  }
}

/* ---------- Inventory Count: finishing a count ---------- */
.count-row.is-not-found {
  border-color: var(--danger);
  background: var(--danger-tint);
}
.count-complete-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-top: 16px;
  padding: 12px 76px 12px 14px; /* clears the floating help button */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 -4px 14px rgba(20, 30, 25, 0.1);
}
@media (max-width: 720px) {
  .count-complete-bar {
    bottom: 84px; /* above the help button, so the bar can use the full width */
    padding-right: 14px;
  }
}
.count-complete-bar strong {
  font-variant-numeric: tabular-nums;
}
.count-review-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 12px;
  margin: 0;
}
.count-review-totals dt {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.count-review-totals dd {
  margin: 2px 0 0;
  font-size: var(--fs-lg);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.count-review-note {
  margin: 12px 0 0;
  padding: 8px 10px;
  border-left: 3px solid var(--warning);
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  text-wrap: pretty;
}
.count-review-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}
.count-review-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.count-review-list li > span:first-child {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 8px;
  min-width: 0;
}
.count-review-change {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  font-variant-numeric: tabular-nums;
}
.count-review-change .is-down {
  color: var(--danger);
}
.count-review-change .is-up {
  color: var(--primary-text);
}

/* ---------- PTO Calendar: requesting days ---------- */
.month-calendar-day.is-pickable {
  cursor: pointer;
  user-select: none;
  transition:
    background-color 120ms ease-out,
    border-color 120ms ease-out;
}
.month-calendar-day.is-pickable:hover {
  border-color: var(--primary);
}
.month-calendar-day.is-pickable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.month-calendar-day.is-in-range {
  background: var(--primary-tint);
  border-color: var(--primary);
}
.month-calendar-day.is-holiday {
  background: var(--bg);
}
.month-calendar-day.is-holiday.is-in-range {
  background: var(--primary-tint);
}
.month-calendar-holiday {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 400;
  color: var(--text-muted);
}
.attendance-chip.is-pending {
  background: var(--primary-tint);
  border-style: dashed;
  border-color: var(--primary);
  color: var(--primary-text);
}
.pto-request-summary {
  margin: 12px 0 0;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  text-wrap: pretty;
}
.month-calendar-holiday::after {
  content: 'Holiday';
}
@media (max-width: 640px) {
  .month-calendar-holiday::after {
    content: 'Hol.';
  }
}

.tank-parent-reason {
  display: block;
  font-weight: 400;
  text-wrap: pretty;
}

/* ---------- Sales order type (first step of the order form) ---------- */
.so-type-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  border: 0;
  padding: 0;
  margin: 0;
}
.so-type-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition:
    border-color 120ms ease-out,
    background-color 120ms ease-out;
}
.so-type-card:hover {
  border-color: var(--primary);
}
.so-type-card:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-tint);
}
.so-type-card input {
  grid-row: span 2;
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
}
.so-type-name {
  font-weight: 700;
  color: var(--text);
}
.so-type-text {
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--text-muted);
  text-wrap: pretty;
}
/* The product line changes with the type: a sample takes grams or lbs, a no-charge order has no price. */
.so-item-unit-field {
  display: none;
}
.is-sample .so-item-unit-field {
  display: block;
}
.is-sample .so-item-cfu,
.is-sample .so-item-new-blend,
.is-no-charge .so-item-ppl-field,
.is-no-charge .so-item-total {
  display: none;
}

/* ---------- New Shipment: FedEx packaging and sample lines ---------- */
.fx-pack {
  flex: 1 1 100%;
  min-width: 0;
}
.fx-dims {
  display: inline-flex;
  flex: 0 1 300px;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.fedex-parcel .fx-dims input {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
}
.fx-dims.hidden {
  display: none;
}
.sample-ship-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 8px 0;
}
.sample-ship-row .held-ship-name {
  flex: 0 1 280px;
  margin: 0;
}
.sample-ship-row .held-ship-input {
  flex: 0 1 120px;
  width: auto;
  margin: 0;
}
.sample-ship-unit {
  flex: 0 0 auto;
  margin: 0;
}
.sample-ship-unit select {
  min-width: 90px;
}

/* ---------- Tank Gantt vs Tank Status ---------- */
/* Something needs a person: a soft halo and a light that runs round the edge. On the Gantt, a bar whose tank differs
   from the plan (red when a harvest is overdue) or whose WO needs reprinting (amber); in Tank Status, a tank whose
   printed WO is out of date, until the updated WO is printed. */
@property --gantt-glow-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}
.gantt-bar.has-issue {
  --gantt-glow: var(--exec-warning, var(--warning));
  /* Same layer as other bars, so the sticky tank letters still cover it when the grid scrolls. The halo is still (a
     moving filter repaints every frame on dashboards left open all day); the light round the edge does the moving. */
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--gantt-glow) 80%, transparent));
}
.gantt-bar.has-issue[data-issue='overdue'] {
  --gantt-glow: var(--exec-danger, var(--danger));
}
.tank-ring-card.has-wo-reprint {
  --gantt-glow: var(--warning);
  position: relative;
  border-radius: var(--radius);
  box-shadow: 0 0 10px 1px color-mix(in srgb, var(--gantt-glow) 55%, transparent);
}
/* Both: keep the red "harvest moved" ring inside the amber halo. */
.tank-ring-card.has-harvest-change.has-wo-reprint {
  box-shadow:
    0 0 0 2px var(--danger),
    0 0 12px 2px color-mix(in srgb, var(--gantt-glow) 55%, transparent);
}
.gantt-bar.has-issue::after,
.tank-ring-card.has-wo-reprint::after {
  content: '';
  position: absolute;
  inset: 0;
  padding: 2px;
  border-radius: inherit;
  background:
    conic-gradient(
      from var(--gantt-glow-angle),
      transparent 0 62%,
      color-mix(in srgb, var(--gantt-glow) 40%, #fff) 78%,
      #fff 82%,
      color-mix(in srgb, var(--gantt-glow) 40%, #fff) 86%,
      transparent 100%
    ),
    var(--gantt-glow);
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box exclude,
    linear-gradient(#000 0 0);
  pointer-events: none;
  animation: gantt-glow-run 3.2s linear infinite;
}
@keyframes gantt-glow-run {
  to {
    --gantt-glow-angle: 360deg;
  }
}
@media (prefers-reduced-motion: reduce) {
  .gantt-bar.has-issue::after,
  .tank-ring-card.has-wo-reprint::after {
    animation: none;
  }
}
.gantt-bar[data-id]:focus-visible {
  outline: 2px solid var(--exec-accent, var(--primary));
  outline-offset: 1px;
}
@media print {
  .gantt-bar.has-issue {
    filter: none;
  }
  .tank-ring-card.has-wo-reprint {
    box-shadow: none;
  }
}

/* Planned vs now: what a glowing bar opens */
.gantt-issue-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-weight: 700;
  text-wrap: balance;
}
.gantt-issue-dot {
  --gantt-glow: var(--exec-warning, var(--warning));
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--gantt-glow);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--gantt-glow) 22%, transparent);
}
.gantt-issue-status[data-issue='overdue'] .gantt-issue-dot {
  --gantt-glow: var(--exec-danger, var(--danger));
}
.gantt-issue-status[data-issue='none'] .gantt-issue-dot {
  --gantt-glow: var(--exec-accent, var(--primary));
}
.gantt-issue-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.gantt-issue-table th,
.gantt-issue-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--exec-border, var(--border));
  text-align: left;
  vertical-align: top;
  text-wrap: pretty;
}
.gantt-issue-table tbody tr:last-child > * {
  border-bottom: 0;
}
.gantt-issue-table thead th {
  color: var(--exec-text-muted, var(--text-muted));
  font-size: var(--fs-xs);
  font-weight: 600;
}
.gantt-issue-table tbody th {
  width: 26%;
  color: var(--exec-text-muted, var(--text-muted));
  font-weight: 600;
}
.gantt-issue-table td.is-off {
  font-weight: 700;
  color: color-mix(in srgb, var(--exec-warning, var(--warning)) 60%, var(--exec-text, var(--text)));
}
.gantt-issue-status[data-issue='overdue'] + .gantt-issue-table td.is-off {
  color: color-mix(in srgb, var(--exec-danger, var(--danger)) 78%, var(--exec-text, var(--text)));
}
.gantt-issue-wo {
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 4px solid var(--exec-warning, var(--warning));
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--exec-warning, var(--warning)) 12%, transparent);
  font-size: var(--fs-sm);
}
.gantt-issue-wo-title,
.gantt-issue-move-title {
  margin: 0 0 4px;
  font-weight: 700;
}
.gantt-issue-wo ul {
  margin: 0 0 6px;
  padding-left: 18px;
}
.gantt-issue-move {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--exec-border, var(--border));
}
.gantt-issue-move-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 12px;
}
.gantt-issue-move-row label {
  flex: 1 1 180px;
  margin: 0;
}
.gantt-issue-move-row input {
  width: 100%;
}
.gantt-issue-move input.has-error,
body.exec-dashboard .modal .gantt-issue-move input.has-error {
  border-color: var(--exec-danger, var(--danger));
}
body.exec-dashboard .gantt-issue-move input[type='date'] {
  color-scheme: dark;
}
body.exec-dashboard .modal p.form-error[data-gantt-issue-error] {
  color: var(--exec-danger, var(--danger));
}
.gantt-issue-move.is-saving {
  opacity: 0.6;
  pointer-events: none;
}
.gantt-issue-done {
  margin: 10px 0 0;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--exec-accent, var(--primary)) 14%, transparent);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-wrap: pretty;
}
.gantt-issue .modal-footer {
  flex-wrap: wrap;
  gap: 8px;
}
@media (max-width: 420px) {
  .gantt-issue-table th,
  .gantt-issue-table td {
    padding: 8px 6px;
  }
  .gantt-issue .modal-footer > * {
    flex: 1 1 100%;
    text-align: center;
  }
  .gantt-issue .modal-footer .spacer {
    display: none;
  }
}
.tank-wo-tag {
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--danger-tint);
  color: var(--danger);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-align: center;
}
.tank-wo-note {
  margin: 0 0 12px;
  padding: 8px 12px;
  border-left: 4px solid var(--danger);
  border-radius: var(--radius-sm);
  background: var(--danger-tint);
  color: var(--text);
  font-size: var(--fs-sm);
  text-wrap: pretty;
}
.tank-harvest-move {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px 12px;
}
.tank-harvest-move label {
  margin: 0;
}
.tank-harvest-move p {
  flex-basis: 100%;
}

/* ---------- Tank Gantt: start, harvest and continuation marks ---------- */
.gantt-grid .gantt-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.gantt-bar-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gantt-ico {
  flex: none;
  width: 13px;
  height: 13px;
}
.gantt-ico.is-start circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
}
.gantt-ico.is-start path,
.gantt-ico.is-finish .flag {
  fill: currentColor;
}
.gantt-ico.is-finish .pole {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
}
.gantt-origin,
.gantt-ahead {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 1px;
  padding: 0 6px 0 3px;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 14%, transparent);
  font-size: var(--fs-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}
.gantt-ahead {
  padding: 0 3px 0 6px;
}
.gantt-chev {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* A bar that carries on past the edge of the days shown has a square edge with a soft shade on that side. */
.gantt-grid .gantt-bar.is-cut-start {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  margin-left: 0;
  box-shadow: inset 10px 0 8px -8px rgba(0, 0, 0, 0.28);
}
.gantt-grid .gantt-bar.is-cut-end {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  margin-right: 0;
  box-shadow: inset -10px 0 8px -8px rgba(0, 0, 0, 0.28);
}
.gantt-grid .gantt-bar.is-cut-start.is-cut-end {
  box-shadow:
    inset 10px 0 8px -8px rgba(0, 0, 0, 0.28),
    inset -10px 0 8px -8px rgba(0, 0, 0, 0.28);
}
/* On a short bar the marks matter more than the name: the name goes first, then the chevrons. */
.gantt-grid .gantt-bar {
  container-type: inline-size;
}
@container (max-width: 96px) {
  .gantt-bar-label {
    display: none;
  }
}
@container (max-width: 64px) {
  .gantt-chev {
    display: none;
  }
  .gantt-origin,
  .gantt-ahead {
    padding: 0 4px;
  }
}
.gantt-key {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  flex-basis: 100%;
  margin-top: 4px;
  opacity: 0.85;
}
.gantt-key .planner-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Add / Modify User: a copied setup is shown, not edited */
#userForm fieldset.is-copied {
  opacity: 0.7;
}

/* ---------- Equipment maps (equipment-map.js): panoramic / 360 photo with pinned components ----------
   Colours fall back from the dashboard tokens (--exec-*) to the app's, so the same viewer sits on the dark
   Maintenance dashboard and the light Maintenance page. */
.emap {
  --emap-accent: var(--exec-warn, #f2a93b);
  --emap-repair: var(--exec-danger, var(--danger));
  position: relative;
  display: grid;
  gap: 8px;
}
.emap-viewport {
  position: relative;
  height: clamp(300px, 58vh, 620px);
  overflow: hidden;
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px) 0 0 / 24px 24px,
    #0c1015;
  cursor: grab;
  touch-action: none;
  user-select: none;
  outline-offset: 2px;
}
.emap.is-dragging .emap-viewport {
  cursor: grabbing;
}
.emap.is-placing .emap-viewport {
  cursor: crosshair;
  box-shadow: inset 0 0 0 2px var(--emap-accent);
}
.emap-track {
  position: absolute;
  inset: 0 auto auto 0;
  display: flex;
  transform: translate3d(var(--emap-x, 0), var(--emap-y, 0), 0);
  will-change: transform;
}
.emap-pano {
  position: relative;
  flex: none;
  width: var(--emap-w, 100%);
  height: var(--emap-h, 100%);
}
.emap-pano img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  -webkit-user-drag: none;
}
/* A pin: a quiet ring until you come near it, then it lights up and names itself. */
.emap-pin {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  z-index: 1;
}
.emap-pin-dot {
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: color-mix(in srgb, var(--emap-accent) 70%, transparent);
  box-shadow:
    0 0 0 3px rgba(0, 0, 0, 0.35),
    0 2px 8px rgba(0, 0, 0, 0.5);
  transition-property: transform, background-color, box-shadow;
  transition-duration: 160ms;
  transition-timing-function: ease-out;
}
.emap-pin:hover .emap-pin-dot,
.emap-pin:focus-visible .emap-pin-dot,
.emap-pin.is-lit .emap-pin-dot {
  transform: scale(1.35);
  background: var(--emap-accent);
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--emap-accent) 35%, transparent),
    0 0 0 9px color-mix(in srgb, var(--emap-accent) 14%, transparent),
    0 2px 10px rgba(0, 0, 0, 0.55);
}
.emap-pin:focus-visible {
  outline: none;
}
.emap-pin.has-repair .emap-pin-dot {
  background: var(--emap-repair);
}
.emap-pin.has-repair::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 2px solid var(--emap-repair);
  animation: emap-ping 1.8s ease-out infinite;
}
@keyframes emap-ping {
  from {
    transform: scale(0.7);
    opacity: 0.9;
  }
  to {
    transform: scale(1.9);
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .emap-pin.has-repair::after {
    animation: none;
    opacity: 0.6;
  }
}
.emap-pin-label {
  position: absolute;
  left: 50%;
  top: calc(100% + 2px);
  transform: translateX(-50%);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(10, 14, 20, 0.82);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition-property: opacity;
  transition-duration: 150ms;
}
.emap.show-labels .emap-pin-label,
.emap-pin.is-lit .emap-pin-label {
  opacity: 1;
}
.emap-tip {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(var(--tip-x, 0), var(--tip-y, 0));
  z-index: 3;
  width: max-content;
  max-width: min(280px, calc(100% - 16px));
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(14, 18, 24, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  color: #f1f4f8;
  pointer-events: none;
  font-size: var(--fs-sm);
}
.emap-tip-head {
  display: flex;
  gap: 10px;
  align-items: center;
}
.emap-tip-head img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  outline: 1px solid rgba(255, 255, 255, 0.12);
  outline-offset: -1px;
}
.emap-tip-head strong {
  display: block;
  text-wrap: balance;
}
.emap-tip-sub {
  display: block;
  color: #aeb8c6;
  font-size: var(--fs-xs);
}
.emap-tip-repair {
  margin: 8px 0 0;
  display: flex;
  gap: 6px;
  align-items: center;
}
.emap-tip-hint {
  margin: 6px 0 0;
  color: #aeb8c6;
  font-size: var(--fs-xs);
}
.emap-placing {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--emap-accent);
  color: #1b1405;
  font-weight: 700;
  font-size: var(--fs-sm);
  pointer-events: none;
  z-index: 2;
}
.emap-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.emap-ctl {
  min-width: 36px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--exec-border, var(--border));
  background: var(--exec-surface-2, var(--surface));
  color: var(--exec-text, var(--text));
  font-size: var(--fs-md);
  font-weight: 700;
  cursor: pointer;
  transition-property: border-color, transform;
  transition-duration: 120ms;
}
.emap-ctl.is-text {
  font-size: var(--fs-sm);
}
.emap-ctl:hover {
  border-color: var(--emap-accent);
}
.emap-ctl:active {
  transform: scale(0.96);
}
.emap-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 6px;
  font-size: var(--fs-sm);
  color: var(--exec-text-muted, var(--text-muted));
}
.emap-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
}
.emap-pill.is-ok {
  color: #16794a;
  background: #dff5e9;
}
.emap-pill.is-warn {
  color: #8a5a00;
  background: #fdf0d5;
}
.emap-pill.is-bad {
  color: #a8232f;
  background: #fde4e6;
}
.emap-pill.is-neutral {
  color: var(--text-muted);
  background: var(--bg);
}
body.exec-dashboard .emap-pill.is-ok,
.emap-tip .emap-pill.is-ok {
  color: #5fe3b4;
  background: rgba(95, 227, 180, 0.14);
}
body.exec-dashboard .emap-pill.is-warn,
.emap-tip .emap-pill.is-warn {
  color: #f6c065;
  background: rgba(246, 192, 101, 0.14);
}
body.exec-dashboard .emap-pill.is-bad,
.emap-tip .emap-pill.is-bad {
  color: #ff8a95;
  background: rgba(255, 93, 108, 0.16);
}
body.exec-dashboard .emap-pill.is-neutral {
  color: var(--exec-text-muted);
  background: var(--exec-surface-2);
}

/* Component card */
.emap-modal-body {
  padding: 4px var(--pad-modal) 8px;
}
.emap-card-top {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
@media (max-width: 520px) {
  .emap-card-top {
    grid-template-columns: 1fr;
  }
  .emap-card-photo {
    max-width: 180px;
  }
}
.emap-card-photo {
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border-radius: var(--radius);
  border: 1px solid var(--exec-border, var(--border));
  background: var(--exec-surface-2, var(--bg));
  overflow: hidden;
  cursor: zoom-in;
  color: var(--exec-text-muted, var(--text-muted));
  font-size: var(--fs-sm);
}
.emap-card-photo.is-empty {
  cursor: default;
}
.emap-card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  outline: 1px solid rgba(0, 0, 0, 0.1);
  outline-offset: -1px;
}
.emap-card-facts dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  margin: 6px 0 10px;
  font-size: var(--fs-sm);
}
.emap-card-facts dt {
  color: var(--exec-text-muted, var(--text-muted));
}
.emap-card-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.emap-card-part {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--exec-surface-2, var(--bg));
}
.emap-card-part-name {
  font-weight: 700;
  flex-basis: 100%;
}
.emap-card-details {
  margin: 14px 0 0;
  white-space: pre-wrap;
  font-size: var(--fs-sm);
  line-height: 1.55;
  text-wrap: pretty;
}
.emap-card-h {
  margin: 16px 0 6px;
  font-size: var(--fs-sm);
}
.emap-card-repairs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  font-size: var(--fs-sm);
}
.emap-card-repairs li {
  display: flex;
  gap: 8px;
  align-items: center;
}
.emap-modal-actions {
  flex-wrap: wrap;
  gap: 8px;
}
.emap-replace {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--exec-border, var(--border));
}
.emap-replace.is-on {
  border-style: solid;
  border-color: var(--warning);
}
.emap-replace-qty {
  display: none;
  align-items: center;
  gap: 6px;
}
.emap-replace-qty input {
  width: 80px;
}
.emap-replace.is-on .emap-replace-qty {
  display: inline-flex;
}
.emap-replace p {
  flex-basis: 100%;
  margin: 0;
}
.emap-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}
.emap-list button {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  column-gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 40px;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition-property: background-color;
  transition-duration: 120ms;
}
.emap-list button:hover,
.emap-list button:focus-visible {
  background: var(--primary-tint);
}
.emap-list-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--warning);
  grid-row: span 2;
}
.emap-list-dot.has-repair {
  background: var(--danger);
}
.emap-list-name {
  font-weight: 600;
  font-size: var(--fs-sm);
}
.emap-list-sub {
  grid-column: 2;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}
.emap-list-empty {
  margin: 8px 4px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* ---------- Repairs (maintenance-repairs.js) ---------- */
.repair-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.repair-row {
  position: relative;
  display: grid;
  grid-template-columns: 4px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 10px 12px 10px 0;
  border: 1px solid var(--exec-border, var(--border));
  border-radius: var(--radius);
  background: var(--exec-surface, var(--surface));
  color: var(--exec-text, var(--text));
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition-property: border-color, transform;
  transition-duration: 140ms;
}
.repair-row:hover,
.repair-row:focus-visible {
  border-color: var(--exec-warn, var(--primary));
}
.repair-row:active {
  transform: scale(0.995);
}
.repair-row-priority {
  align-self: stretch;
  background: var(--exec-border, var(--border));
}
.repair-row.is-urgent .repair-row-priority {
  background: var(--exec-danger, var(--danger));
}
.repair-row.is-high .repair-row-priority {
  background: var(--exec-warn, var(--warning));
}
.repair-row-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.repair-row-title {
  font-weight: 700;
  text-wrap: pretty;
}
.repair-row-meta {
  color: var(--exec-text-muted, var(--text-muted));
  font-size: var(--fs-xs);
}
.repair-row-meta.is-order {
  color: var(--exec-accent-2, var(--primary-text));
}
.repair-row-side {
  display: grid;
  gap: 4px;
  justify-items: end;
}
.repair-row-pri {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--exec-warn, #8a5a00);
}
.repair-row.is-urgent .repair-row-pri,
.repair-row-pri.is-urgent {
  color: var(--exec-danger, var(--danger));
}
.repair-list.is-compact .repair-row {
  padding-top: 8px;
  padding-bottom: 8px;
}
.repair-head {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}
.repair-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 14px;
  margin: 0 0 10px;
  font-size: var(--fs-sm);
}
.repair-facts dt {
  color: var(--exec-text-muted, var(--text-muted));
}
.repair-facts dd {
  margin: 0;
}
.repair-desc {
  margin: 0 0 10px;
  white-space: pre-wrap;
  text-wrap: pretty;
}
.repair-photo {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  margin-bottom: 10px;
}
.repair-photo img {
  max-width: 100%;
  max-height: 220px;
  border-radius: var(--radius);
  outline: 1px solid rgba(0, 0, 0, 0.1);
  outline-offset: -1px;
}
.repair-timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 14px;
  border-left: 2px solid var(--exec-border, var(--border));
  display: grid;
  gap: 8px;
  font-size: var(--fs-sm);
}
.repair-timeline li {
  display: grid;
  gap: 1px;
}
.repair-timeline-what {
  font-weight: 600;
}
.repair-timeline-note {
  white-space: pre-wrap;
}
#repairForm {
  padding: 0 var(--pad-modal);
}
#repairResolutionWrap.is-required::after {
  content: 'Needed to mark it fixed';
  display: block;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* ---------- Maintenance page ---------- */
.maint-page {
  display: grid;
  gap: 16px;
}
.maint-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}
.maint-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: none;
  color: var(--text-muted);
  font-size: var(--fs-md);
  font-weight: 600;
  cursor: pointer;
}
.maint-tabs button.is-active {
  color: var(--text);
  border-bottom-color: var(--primary);
}
.maint-tab-count {
  min-width: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: var(--fs-xs);
  line-height: 20px;
  text-align: center;
}
.maint-map-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.maint-map-chooser {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.maint-map-chip {
  display: grid;
  gap: 1px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition-property: border-color, box-shadow;
  transition-duration: 140ms;
}
.maint-map-chip.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.maint-map-chip-name {
  font-weight: 700;
}
.maint-map-chip-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.maint-map-chip-meta strong {
  color: var(--danger);
}
.maint-map-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.maint-map-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 14px;
  align-items: start;
}
@media (max-width: 900px) {
  .maint-map-stage {
    grid-template-columns: 1fr;
  }
}
.maint-map-side {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  max-height: clamp(300px, 58vh, 620px);
  overflow: auto;
}
.maint-empty {
  max-width: 560px;
  margin: 24px auto;
  padding: 28px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.maint-empty h2 {
  margin: 0 0 8px;
  text-wrap: balance;
}
.maint-empty p {
  color: var(--text-muted);
  text-wrap: pretty;
}
.maint-empty-line {
  color: var(--text-muted);
  margin: 12px 0;
}
.maint-repair-bar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}
.maint-seg {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius);
  background: var(--border);
  gap: 2px;
}
.maint-seg button {
  padding: 6px 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  cursor: pointer;
}
.maint-seg button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* Checkbox and quantity sit beside their words, not under them (labels stack by default). */
.emap-replace label,
.emap-toggle {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.emap-replace input[type='checkbox'],
.emap-toggle input[type='checkbox'] {
  width: auto;
  margin: 0;
}
.emap-replace .check-inline {
  display: inline-flex;
  font-size: var(--fs-sm);
  color: var(--exec-text, var(--text));
}
.emap-card-photo img {
  font-size: var(--fs-xs);
  color: transparent;
}

.emap-broken {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  padding: 16px;
  text-align: center;
  color: #aeb8c6;
  font-size: var(--fs-sm);
}
.emap.is-broken .emap-pano {
  visibility: hidden;
}

/* ---------- Type-to-narrow suggestions (common.js typeaheadForDatalists) ----------
   One floating list under whichever field is being typed in; replaces the browser's datalist dropdown, which iPhone
   and iPad Safari don't show reliably. */
.typeahead-list {
  position: fixed;
  left: var(--ta-x, 0);
  top: var(--ta-y, 0);
  width: var(--ta-w, 280px);
  min-width: min(240px, calc(100vw - 16px));
  max-height: var(--ta-max, min(320px, 45vh));
  overflow-y: auto;
  touch-action: pan-y;
  overscroll-behavior: contain;
  margin: 0;
  padding: 4px;
  list-style: none;
  z-index: 2000;
  border: 1px solid var(--exec-border, var(--border));
  border-radius: var(--radius);
  background: var(--exec-surface, var(--surface));
  color: var(--exec-text, var(--text));
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.18),
    0 2px 6px rgba(0, 0, 0, 0.08);
  -webkit-overflow-scrolling: touch;
}
.typeahead-list.is-up {
  transform: translateY(-100%);
}
.typeahead-list.hidden {
  display: none;
}
.typeahead-list li[role='option'] {
  display: grid;
  gap: 1px;
  min-height: 44px;
  align-content: center;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--fs-sm);
}
.typeahead-list li[role='option']:hover,
.typeahead-list li[role='option'].is-active {
  background: var(--exec-surface-2, var(--primary-tint));
}
.typeahead-value {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.typeahead-label {
  color: var(--exec-text-muted, var(--text-muted));
  font-size: var(--fs-xs);
}
.typeahead-more {
  padding: 8px 10px;
  color: var(--exec-text-muted, var(--text-muted));
  font-size: var(--fs-xs);
}

/* ---------- Shipping preferences (lib/ship-prefs.js) ---------- */
/* New Shipment: what the customer asked for, and a warning when this shipment differs. */
.ship-pref-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  background: var(--primary-tint);
  font-size: var(--fs-sm);
}
.ship-pref-banner.hidden {
  display: none;
}
.ship-pref-banner-label {
  color: var(--text-muted);
}
.ship-pref-conflict {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--warning);
  border-left-width: 4px;
  background: color-mix(in srgb, var(--warning) 12%, var(--surface));
}
.ship-pref-conflict.hidden {
  display: none;
}
.ship-pref-conflict-title {
  margin: 0;
  font-weight: 700;
  color: var(--text);
}
.ship-pref-conflict ul {
  margin: 0;
  padding-left: 18px;
  font-size: var(--fs-sm);
  color: var(--text);
}
.ship-pref-conflict label {
  color: var(--text);
}
/* A shipment that went out differently from the order (order detail, Shipping Charges). */
.ship-pref-note {
  margin: 8px 0 0;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warning) 14%, var(--surface));
  font-size: var(--fs-xs);
  color: var(--text);
  text-wrap: pretty;
}
.ship-charge-count:not(:empty) {
  display: inline-block;
  min-width: 20px;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: var(--fs-xs);
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.ship-charge-partial {
  display: inline-block;
  padding: 0 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--warning) 22%, var(--surface));
  color: var(--text);
  font-weight: 700;
}

/* Shipping Charges: one card per shipment up to tablet width (two side by side on an iPad), a table on wider screens.
   Phones already stack it (common.js marks it .is-stacked); this carries the cards up to 1100px. */
@media (max-width: 1100px) {
  .table-wrap:has(> .ship-charge-table) {
    overflow-x: hidden;
    background: transparent;
    border: 0;
    padding: 0;
  }
  table.runs-table.ship-charge-table.is-stacked {
    display: block;
    min-width: 0;
    width: 100%;
  }
  .ship-charge-table.is-stacked thead {
    display: none;
  }
  .ship-charge-table.is-stacked tbody {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
    gap: 12px;
  }
  .ship-charge-table.is-stacked tbody tr {
    display: block;
    margin: 0;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
  }
  table.runs-table.ship-charge-table.is-stacked td {
    display: block;
    width: 100%;
    padding: 6px 0;
    border: 0;
    text-align: left;
    white-space: normal;
  }
  .ship-charge-table.is-stacked td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-size: var(--fs-xs);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
  }
}

/* Shipping Charges on wider screens: a table whose notes and reasons wrap, so the last column (Open order) stays in view. */
table.runs-table.ship-charge-table {
  min-width: 0;
  width: 100%;
}
table.runs-table.ship-charge-table th,
table.runs-table.ship-charge-table td {
  white-space: normal;
  vertical-align: top;
}
table.runs-table.ship-charge-table td .ghost-btn,
table.runs-table.ship-charge-table td .status-badge {
  white-space: nowrap;
}

/* ---------- Stock Detail: live WO# filter, CFU levels, totals ---------- */
.inv-filters {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}
.inv-filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px 12px;
  align-items: end;
}
.inv-field {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.inv-field.is-search {
  grid-column: span 2;
}
.inv-field-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-muted);
}
.inv-field input,
.inv-field select {
  width: 100%;
  min-height: 40px;
}
.cfu-levels {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.cfu-level {
  display: grid;
  grid-template-columns: auto auto;
  column-gap: 8px;
  align-items: baseline;
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-variant-numeric: tabular-nums;
  transition-property: background-color, border-color, box-shadow;
  transition-duration: 150ms;
}
.cfu-level:hover {
  border-color: var(--primary);
}
.cfu-level:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.cfu-level.is-active {
  background: var(--primary-tint);
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.cfu-level-name {
  font-weight: 700;
  color: var(--primary-text);
}
.cfu-level.is-below {
  border-left: 3px solid var(--warning);
}
.cfu-level.is-untested .cfu-level-name {
  color: var(--text-muted);
}
.cfu-level-lbs {
  font-size: var(--fs-sm);
}
.cfu-level-count {
  grid-column: 1 / -1;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.inv-clear {
  justify-self: start;
}
.table-wrap.is-refreshing {
  opacity: 0.55;
  transition: opacity 150ms;
}
.inv-total-bar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 24px;
  margin-top: 10px;
  padding: 12px 16px;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-variant-numeric: tabular-nums;
}
.inv-total-head {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.inv-total-title {
  font-weight: 700;
  font-size: var(--fs-md);
}
.inv-total-scope {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  overflow-wrap: anywhere;
}
.inv-total-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin: 0;
}
.inv-stat {
  display: grid;
  gap: 1px;
}
.inv-stat dt {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.inv-stat dd {
  margin: 0;
  font-weight: 700;
  font-size: var(--fs-md);
}
.inv-stat.is-available dd {
  color: var(--primary-text);
}
.inv-stat.is-held dd {
  color: var(--danger);
}
@media (max-width: 600px) {
  .inv-field.is-search {
    grid-column: 1 / -1;
  }
  .inv-filter-row {
    grid-template-columns: 1fr 1fr;
  }
  .inv-total-bar {
    gap: 6px;
    padding: 8px 64px 8px 12px; /* clear of the floating help button */
  }
  .inv-total-stats {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(5.5rem, 1fr));
    gap: 4px 10px;
  }
  .inv-stat dd {
    font-size: var(--fs-sm);
  }
  /* Phone: the CFU levels scroll sideways in one row instead of stacking five rows deep. */
  .cfu-levels {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding: 2px 2px 6px;
  }
  .cfu-level {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }
}

/* Stock Detail WO# table as a table (laptop and up): actions sit in one row and a hold note wraps, so each WO# is one
   short line instead of buttons stacked three deep. On an iPad it is cards (below): nine columns don't fit. */
@media (min-width: 1025px) {
  table.stock-batch-table td:last-child .row-actions {
    flex-wrap: nowrap;
  }
  table.stock-batch-table td:nth-child(6) {
    white-space: normal;
    min-width: 12rem;
  }
  table.stock-batch-table td:nth-child(6) .status-badge {
    display: inline-block;
    white-space: normal;
    max-width: 100%;
  }
  table.stock-batch-table td:nth-last-child(2) {
    min-width: 10rem;
    max-width: 18rem;
  }
}

/* ---------- Lab: contamination hold + WO# review (lab.html) ---------- */
.lab-check {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}
.lab-check input {
  width: auto;
  margin: 0;
}
/* The flex box lives on a div inside the cell: flex on the <td> itself takes it out of the table and its
   borders no longer line up with the rest of the row. */
.lab-row-actions {
  display: flex;
  /* Side by side: Override + Contamination stacking made those rows taller than the rest. */
  flex-wrap: nowrap;
  gap: 6px;
  justify-content: flex-end;
}
table.runs-table td.lab-notes-cell {
  white-space: normal;
}
/* At most two lines (the smaller size fits more per line), so a long note or several organisms never make the row taller.
   The width sits on this div (a <td> ignores max-width); a tap or Enter opens the full text. */
.lab-notes {
  width: 34ch;
  max-width: 100%;
  cursor: pointer;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: var(--fs-sm);
  line-height: 1.3;
}
.lab-notes.is-dense {
  font-size: var(--fs-xs);
  line-height: 1.25;
}
.lab-notes.is-expanded {
  -webkit-line-clamp: unset;
  line-clamp: none;
}
.lab-notes:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
/* Phone cards grow anyway: show the whole note across the card. */
@media (max-width: 760px) {
  table.runs-table.is-stacked .lab-notes {
    display: block;
    width: auto;
    -webkit-line-clamp: unset;
    line-clamp: none;
  }
}
/* Contamination modal: one chip per organism, each removable; Add box below. */
.contam-chips {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.contam-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 2px 2px 12px;
  border-radius: 999px;
  border: 1px solid var(--danger);
  color: var(--danger);
  background: var(--surface);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.contam-chip-remove {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 999px;
}
.contam-chip-remove:hover,
.contam-chip-remove:focus-visible {
  background: var(--surface-2, rgba(0, 0, 0, 0.06));
}
.contam-add {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.contam-add input {
  flex: 1;
  min-width: 0;
}
.lab-notes-contam {
  font-weight: 600;
  color: var(--danger);
}
.wo-review-body {
  display: grid;
  gap: 16px;
}
.wo-review-body.is-loading {
  opacity: 0.7;
}
.wo-review-chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.wo-review-clear {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--primary-tint);
  color: var(--primary-text);
  font-weight: 600;
}
.wo-review-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--surface);
}
.wo-review-section h3 {
  margin: 0 0 10px;
  font-size: var(--fs-lg);
}
.wo-review-section h4 {
  margin: 12px 0 6px;
  font-size: var(--fs-md);
  color: var(--text-muted);
}
.wo-issue-list,
.wo-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.wo-issue {
  display: grid;
  grid-template-columns: minmax(9rem, max-content) 1fr;
  gap: 10px;
  align-items: start;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.wo-issue > .status-badge {
  justify-self: start;
}
.wo-issue:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}
.wo-run-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 8px 16px;
  margin: 0;
}
.wo-run-facts dt {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.wo-run-facts dd {
  margin: 2px 0 0;
  font-weight: 600;
}
.wo-readings td.is-caution {
  background: #fff3cd;
  color: #7a5f12;
  font-weight: 600;
}
.wo-readings td.is-alert {
  background: var(--danger-tint);
  color: var(--danger);
  font-weight: 700;
}
.wo-timeline li {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 10px;
}
.wo-timeline-when {
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
@media (max-width: 600px) {
  .wo-issue,
  .wo-timeline li {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* ---------- Product Names (product-names.html) ---------- */
.pn-lock-note {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  text-wrap: pretty;
}
.pn-done {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary-tint);
  color: var(--primary-text);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.pn-groups {
  display: grid;
  gap: 12px;
}
.pn-group {
  border: 1px solid var(--border);
  border-left: 4px solid var(--warning);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: var(--surface);
}
.pn-group-title {
  margin: 0;
  font-size: var(--fs-md);
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.pn-group-why {
  margin: 4px 0 0;
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.pn-choices {
  border-top: none;
  padding: 10px 0 0;
  display: grid;
  gap: 6px;
}
.pn-choices-legend {
  margin-bottom: 4px;
}
.pn-choice {
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition-property: border-color, background-color;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}
.pn-choice:hover {
  border-color: var(--primary);
}
.pn-choice:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-tint);
}
.pn-choice input {
  margin-top: 2px;
  flex: none;
}
.pn-choice-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.pn-choice-name {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text);
  overflow-wrap: anywhere;
}
.pn-choice-use {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.pn-group-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.pn-empty {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.pn-all-head {
  flex-wrap: wrap;
  gap: 8px;
}
.pn-search {
  min-width: min(260px, 100%);
}
.pn-table .pn-name {
  white-space: normal;
  min-width: 10em;
  text-align: left;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.pn-table .pn-use {
  white-space: normal;
  min-width: 14em;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.pn-table .pn-actions {
  text-align: right;
  white-space: nowrap;
}
.pn-pager {
  display: flex;
  gap: 8px;
}
.pn-history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.pn-history li {
  display: grid;
  gap: 2px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.pn-history li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.pn-history-what {
  font-size: var(--fs-sm);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.pn-modal {
  max-width: 720px;
}
.pn-rename {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.pn-rename label {
  flex: 1 1 260px;
}
.pn-preview-sum {
  margin: 0 0 10px;
  font-size: var(--fs-sm);
  text-wrap: pretty;
}
.pn-preview-wrap {
  max-height: 46vh;
  overflow: auto;
}
.pn-preview-wrap .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
#pnPreview.is-loading {
  opacity: 0.6;
}
@media (max-width: 600px) {
  .pn-group {
    padding: 12px;
  }
  .pn-group-actions > button {
    flex: 1 1 auto;
  }
  /* phone: each name is a small block - name + Rename on top, where it's used underneath */
  .pn-table thead {
    display: none;
  }
  .pn-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 10px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
  }
  .pn-table tbody td {
    border: none;
    padding: 0;
  }
  .pn-table .pn-name,
  .pn-table .pn-use {
    min-width: 0;
  }
  .pn-table .pn-use {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-top: 2px;
  }
  .pn-table tbody tr:last-child,
  .pn-preview-table tbody tr:last-child {
    border-bottom: none;
  }
  /* phone: preview rows stack - where + count, then old name → new name */
  .pn-preview-table thead {
    display: none;
  }
  .pn-preview-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 10px;
    row-gap: 2px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
  }
  .pn-preview-table tbody td {
    border: none;
    padding: 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .pn-preview-table .pn-prev-where {
    font-weight: 600;
  }
  .pn-preview-table .num {
    grid-column: 2;
    grid-row: 1;
    padding-right: 6px;
    color: var(--text-muted);
  }
  .pn-preview-table .pn-prev-from,
  .pn-preview-table .pn-prev-to {
    grid-column: 1 / -1;
  }
  .pn-preview-table .pn-prev-from {
    color: var(--text-muted);
    text-decoration: line-through;
  }
  .pn-preview-table .pn-prev-to::before {
    content: '→ ';
    color: var(--text-muted);
  }
}

/* ---------- Blend recipes: lbs or % entry, amount calculator, new ingredient ---------- */
.blend-mode-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 16px;
  margin-bottom: 12px;
}
.blend-mode-bar .seg-control {
  flex: 0 1 300px;
}
.blend-batch-size {
  flex: 0 1 180px;
}
.blend-amount-unit {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  min-width: 1.6em;
}
.blend-line-lbs-wrap .blend-line-ratio {
  font-variant-numeric: tabular-nums;
}
#blendBatchSummary.is-off {
  color: var(--danger);
  font-weight: 600;
}
.blend-calc-input {
  max-width: 220px;
}
.blend-calc {
  margin-top: 10px;
}
.blend-calc:empty {
  display: none;
}
.blend-calc-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.blend-calc-table .blend-calc-name {
  white-space: normal;
  overflow-wrap: anywhere;
}
.new-ing-modal {
  max-width: 560px;
}

/* ---------- Stock Detail: WO# and Variant filters in the table header ---------- */
.th-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  font-weight: inherit;
}
.th-filter-name {
  white-space: nowrap;
}
.stock-batch-table thead th {
  vertical-align: bottom;
}
.stock-batch-table th.th-filter-cell {
  min-width: 9rem;
}
.th-filter .th-filter-input {
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 5px 8px;
  font-size: var(--fs-sm);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--field-border);
  border-radius: var(--radius);
}
.th-filter .th-filter-input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.variant-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}
.variant-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--primary-tint);
  color: var(--text);
  font-size: var(--fs-xs);
  line-height: 1.6;
  white-space: nowrap;
}
/* Phones: the header row is hidden for the stacked cards, so the two filters sit side by side above them. */
@media (max-width: 760px) {
  .stock-batch-table.is-stacked thead {
    display: block;
  }
  .stock-batch-table.is-stacked thead tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 10px;
    padding: 0 0 10px;
    border: 0;
  }
  .stock-batch-table.is-stacked thead th {
    display: none;
  }
  .stock-batch-table.is-stacked thead th.th-filter-cell {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
  }
  .stock-batch-table.is-stacked .th-filter .th-filter-input {
    min-height: 40px;
    font-size: var(--fs-md);
  }
}

/* Phones and iPads show the WO#s as cards: the Sort by / Then by dropdowns do the sorting there, so only the two
   filter headers stay above the cards. */
@media (max-width: 1024px) {
  table.stock-batch-table.is-stacked thead th[data-sort-th]:not(.th-filter-cell) {
    display: none;
  }
}

/* Stock Detail: arrived from the Stock board's On hold card */
.held-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 10px;
  padding: 10px 14px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: var(--danger-tint);
  color: var(--text);
  font-size: var(--fs-sm);
}

/* Stock Detail WO# table on an iPad: cards three fields across, like the phone's two, with the WO# and Variant filters
   side by side above them (the table would be twice the screen's width). */
@media (min-width: 761px) and (max-width: 1024px) {
  table.stock-batch-table.is-stacked,
  table.stock-batch-table.is-stacked tbody,
  table.stock-batch-table.is-stacked thead {
    display: block;
    width: 100%;
    min-width: 0;
  }
  table.stock-batch-table.is-stacked thead tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 12px;
    padding: 0 0 12px;
    border: 0;
  }
  table.stock-batch-table.is-stacked thead th {
    display: none;
  }
  table.stock-batch-table.is-stacked thead th.th-filter-cell {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
  }
  table.stock-batch-table.is-stacked tbody tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    margin-bottom: 12px;
    padding: 10px 14px;
  }
  table.stock-batch-table.is-stacked tbody td {
    display: block;
    min-width: 0;
    max-width: none;
    border: 0;
    padding: 6px 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  table.stock-batch-table.is-stacked tbody td:first-child {
    font-size: var(--fs-md);
    font-weight: 700;
  }
  table.stock-batch-table.is-stacked tbody td:nth-last-child(2),
  table.stock-batch-table.is-stacked tbody td:last-child {
    grid-column: 1 / -1;
  }
  table.stock-batch-table.is-stacked tbody td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: var(--fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 2px;
  }
  table.stock-batch-table.is-stacked tbody td:last-child .row-actions {
    flex-wrap: wrap;
  }
  table.stock-batch-table.is-stacked tbody td .status-badge {
    display: inline-block;
    max-width: 100%;
    white-space: normal;
  }
}

/* Order type: the rare replacement kinds sit behind one disclosure (fewer choices up front). */
.so-type-more {
  grid-column: 1 / -1;
}
.so-type-more > summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--primary-text);
  font-weight: 600;
  cursor: pointer;
}
.so-type-more-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
