/*
 * Orion Central — operator UI stylesheet.
 *
 * Design tokens are declared once at :root so every component pulls from the
 * same palette. Change a value here and the whole UI follows. Kept narrow
 * and orthogonal (background / surface / text / accent) so future themes
 * (light mode, high-contrast) just override these tokens.
 *
 * Animations are sub-200ms by design — fast enough to feel snappy, slow
 * enough to register. All entrance animations check `prefers-reduced-motion`
 * and fall back to no-motion.
 */

:root {
  /* Surfaces */
  --bg: #0a0a0d;
  --bg-elevated: #15161a;
  --bg-elevated-2: #1c1d22;
  --surface: #1a1b20;
  --surface-hover: #232429;

  /* Text */
  --text: #e8e8ec;
  --text-dim: #9092a0;
  --text-faint: #5a5d68;

  /* Borders */
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --border-accent: rgba(255, 122, 26, 0.4);

  /* Brand — derived from the sortation rig photo (orange diverter rings) */
  --accent: #ff7a1a;
  --accent-hover: #ff8c3d;
  --accent-active: #e66a0f;
  --accent-glow: rgba(255, 122, 26, 0.4);
  --accent-faint: rgba(255, 122, 26, 0.08);

  /* Semantic — match the green machine livery in the photo */
  --ok: #3ddc97;
  --ok-faint: rgba(61, 220, 151, 0.12);
  --warn: #ffd23f;
  --warn-faint: rgba(255, 210, 63, 0.12);
  --err: #ff4d6d;
  --err-faint: rgba(255, 77, 109, 0.12);
  --info: #6cb6ff;

  /* Type */
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SF Mono, Consolas, monospace;

  /* Radii + motion */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 22px;
  --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: 180ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 320ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Shadows */
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.2);
  --shadow-button: 0 4px 14px var(--accent-glow);
}

/* ---- Reset + base -------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  /* Subtle radial accent in the top-right — gives the dark page some life
     without being an overt gradient. */
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 800px 600px at 90% -10%, rgba(255, 122, 26, 0.06), transparent 60%),
    radial-gradient(ellipse 600px 500px at 10% 110%, rgba(108, 182, 255, 0.04), transparent 60%);
  z-index: 0;
}

a { color: var(--accent); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; margin: 0; color: var(--text); }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

code, .mono { font-family: var(--font-mono); font-size: 0.92em; }

/* ---- Top header (when present on a page) --------------------------- */

.page-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  background: rgba(10, 10, 13, 0.7);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid var(--border);
  /* Allow the bar to wrap to a second row when there isn't enough
     horizontal space — prevents the nav from overlapping the user
     panel on mid-width screens. */
  flex-wrap: wrap;
  row-gap: 8px;
}

.page-header .header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1 1 auto;
  min-width: 0;          /* lets children shrink past their content size */
  flex-wrap: wrap;
  row-gap: 6px;
}
.page-header .header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;        /* user panel never shrinks; nav wraps instead */
}

/* White-piped Orion wordmark (same asset as the login screen).
   120px tall — 50% larger than the old 80px so it reads from across
   the warehouse floor. Negative top/bottom margins keep the flex
   line at the same ~80px height the banner was sized around, so the
   bar's overall height does NOT grow; the wordmark just visually
   overflows by ~10px above and below (drop-shadow softens this).
   The -8px right margin pulls "Warehouse Control System" in tighter
   to the wordmark; the previous 14px gap had the title sitting too
   far out. */
.header-logo {
  height: 120px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
  margin: -20px -8px -20px 0;
  filter: drop-shadow(0 0 18px rgba(255, 122, 26, 0.32));
}
/* Casio-80s title vibe: Orbitron is the closest accessible Google Font
   to Casio digital displays — geometric, tech, retro-future.
   Tightened from 1.25rem to 1.05rem (and tracking 0.06em -> 0.04em)
   so the title doesn't elbow the nav off the top bar at typical
   laptop widths. Still feels chunky next to the Inter nav links. */
.header-title {
  font-family: "Orbitron", "Inter", system-ui, sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text);
  text-shadow: 0 0 10px rgba(255, 122, 26, 0.18);
}
/* Hide the title text below 1100px so the nav has room. The logo +
   the page header on each route are enough branding when space is
   tight. */
@media (max-width: 1100px) {
  .header-title { display: none; }
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  row-gap: 4px;
}
.header-nav a {
  display: inline-block;
  padding: 5px 10px;
  border-radius: var(--r-md);
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color var(--t-fast), background var(--t-fast);
}
.header-nav a:hover { color: var(--text); background: var(--surface-hover); }
.header-nav a.active { color: var(--text); background: var(--accent-faint); }

.header-user {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 0.85rem;
  /* Long emails would push the badge + logout off-screen. Cap and
     ellipsis on the email span; full address shows in `title` tooltip. */
  max-width: 240px;
}
.header-user > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
/* Drop the email entirely below ~860px — the role badge alone is enough
   identity-disambiguation when space is at a premium. */
@media (max-width: 860px) {
  .header-user > span:first-child { display: none; }
}
.header-user .badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--accent-faint); color: var(--accent); border: 1px solid var(--border-accent);
}

/* ---- Main content shell ------------------------------------------- */

.main { padding: 24px; max-width: 1600px; margin: 0 auto; position: relative; z-index: 1; }

/* ---- Buttons ------------------------------------------------------ */

.btn, button.primary, button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: #1a0a00;
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-base);
  box-shadow: 0 0 0 0 var(--accent-glow);
}
.btn:hover, button.primary:hover, button[type="submit"]:hover {
  background: var(--accent-hover);
  box-shadow: var(--shadow-button);
  transform: translateY(-1px);
}
.btn:active, button.primary:active, button[type="submit"]:active {
  background: var(--accent-active);
  transform: translateY(0);
}
.btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn.ghost:hover {
  background: var(--surface-hover);
  box-shadow: none;
}

/* ---- Form inputs -------------------------------------------------- */

label { display: block; font-size: 0.82rem; font-weight: 500; color: var(--text-dim); margin: 14px 0 6px 0; letter-spacing: 0.02em; text-transform: uppercase; }

/* Cover every text-ish form control + select + textarea with one
   shared rule. Earlier the rule only listed text/email/password/
   search, which left number/date/tel/url plus selects and textareas
   to fall back to the browser default — white-on-white on the
   dark theme. The maintenance module surfaced this hard because
   its forms use selects + textareas heavily. */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  outline: none;
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="time"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-faint);
  background: var(--bg-elevated-2);
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
/* Native date pickers in WebKit/Blink drop a white calendar icon on
   a white background; force a light glyph so it stays readable. */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(0.85);
  cursor: pointer;
}
/* Select dropdown chevron — Firefox styles via appearance; WebKit
   needs an explicit background-image. Keep it subtle. */
select {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
                    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
select option { background: var(--bg-elevated); color: var(--text); }

/* ---- Cards -------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}
.card.large { padding: 32px; }

.error {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--err-faint);
  color: var(--err);
  border: 1px solid rgba(255, 77, 109, 0.3);
  border-radius: var(--r-sm);
  font-size: 0.9rem;
}
.hint { margin-top: 12px; color: var(--text-dim); font-size: 0.85rem; }

/* ---- Auth split-screen layout ------------------------------------- */

.auth-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.auth-hero {
  position: relative;
  background-image: url("/static/sorter_hero.jpg");
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

.auth-hero::after {
  /* Gradient overlay so the brand text is readable over any photo. */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(10, 10, 13, 0.85) 0%, rgba(10, 10, 13, 0.45) 60%, rgba(10, 10, 13, 0.6) 100%);
}

.auth-hero-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  padding: 48px;
  color: var(--text);
}

.auth-hero-content .brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.auth-hero-content .brand img { height: 144px; filter: drop-shadow(0 0 28px rgba(255, 122, 26, 0.4)); }
.auth-hero-content .brand-text { display: flex; flex-direction: column; gap: 2px; }
.auth-hero-content .brand-name { font-size: 1.15rem; }
.auth-hero-content .brand-strapline { font-size: 0.95rem; font-weight: 400; font-style: italic; color: var(--text-dim); letter-spacing: 0.01em; }

.auth-hero-content .tagline { max-width: 520px; }
.auth-hero-content .tagline h1 {
  font-size: 2.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 16px;
}
.auth-hero-content .tagline p { color: var(--text-dim); font-size: 1.05rem; line-height: 1.55; max-width: 460px; }

.auth-hero-content .meta { color: var(--text); font-family: var(--font-mono); font-size: 0.85rem; letter-spacing: 0.04em; opacity: 0.92; }
.auth-hero-content .meta .live-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); margin-right: 8px; vertical-align: middle;
  box-shadow: 0 0 12px var(--ok);
  animation: pulseDot 2s ease-in-out infinite;
}

.auth-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  background: var(--bg);
}
.auth-form-wrap > .card {
  width: 100%;
  max-width: 420px;
  animation: fadeInUp 480ms cubic-bezier(0.16, 1, 0.3, 1);
}
.auth-form-wrap.wide > .card { max-width: 540px; }

.auth-form-wrap h2 { margin-bottom: 4px; font-size: 1.5rem; }
.auth-form-wrap .sub { color: var(--text-dim); font-size: 0.92rem; margin-bottom: 18px; }

/* When the auth layout is shown, hide the page-header (login pages don't need it). */
.auth-layout ~ .page-header, body.auth-page .page-header { display: none; }

/* Mobile — stack hero above form. */
@media (max-width: 880px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-hero { min-height: 240px; }
  .auth-hero-content { padding: 32px; }
  .auth-hero-content .tagline h1 { font-size: 1.8rem; }
}

/* ---- Tables (parcel feed etc.) ----------------------------------- */

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-card); }
.table-toolbar { display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.table-toolbar .grow { flex: 1; }

/* Live indicator — green pulsing dot + uppercase mono label. Used on
   the parcel feed, stats page, audit page, anywhere we want a "this
   is updating in real time" affordance. Originally scoped to
   `.table-toolbar` but lifted to global so any element with the class
   gets the dot — the stats page's window-selector wasn't getting it. */
.live-indicator {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.82rem; color: var(--text-dim);
  font-family: var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase;
}
.live-indicator::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--ok); box-shadow: 0 0 10px var(--ok);
  animation: pulseDot 2s ease-in-out infinite;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.data thead th {
  position: sticky; top: 0;
  background: var(--bg-elevated);
  color: var(--text-dim);
  text-align: left;
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
table.data tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
table.data tbody tr {
  transition: background var(--t-fast);
}
table.data tbody tr:hover { background: var(--surface-hover); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data .col-mono { font-family: var(--font-mono); color: var(--text-dim); font-size: 0.85rem; }
table.data .col-strong { font-weight: 600; color: var(--text); }

/* Status pills */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.03em; border: 1px solid transparent; }
.pill.ok   { background: var(--ok-faint);   color: var(--ok);   border-color: rgba(61, 220, 151, 0.3); }
.pill.warn { background: var(--warn-faint); color: var(--warn); border-color: rgba(255, 210, 63, 0.3); }
.pill.err  { background: var(--err-faint);  color: var(--err);  border-color: rgba(255, 77, 109, 0.3); }
.pill.dim  { background: rgba(255, 255, 255, 0.04); color: var(--text-dim); border-color: var(--border); }

/* Search input lives inside the table toolbar — make it look like a proper search box */
.table-toolbar input[type="search"] {
  width: 360px;
  max-width: 100%;
  padding: 8px 12px;
  font-size: 0.9rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.table-toolbar input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-faint);
}

/* Live indicator — colour reflects polling state */
.live-indicator[data-state="paused"]::before { background: var(--text-dim); box-shadow: none; animation: none; }
.live-indicator[data-state="paused"] { color: var(--text-dim); }
.live-indicator[data-state="error"]::before { background: var(--err); box-shadow: 0 0 10px var(--err); animation: pulseDot 1s ease-in-out infinite; }
.live-indicator[data-state="error"] { color: var(--err); }
.live-indicator[data-state="search"]::before { background: var(--accent); box-shadow: 0 0 10px var(--accent-glow); animation: none; }
.live-indicator[data-state="search"] { color: var(--accent); }

/* Parcel rows + click-to-expand */
table.data tbody tr.parcel-row { cursor: pointer; }
table.data tbody tr.parcel-row.expanded { background: var(--surface-hover); }
table.data tbody tr.parcel-row.expanded td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

/* New rows fade in from the top */
@keyframes parcelEnter {
  from { background: var(--accent-faint); opacity: 0.7; }
  to   { background: transparent; opacity: 1; }
}
table.data tbody tr.parcel-row.entering { animation: parcelEnter 1500ms ease-out; }
@media (prefers-reduced-motion: reduce) {
  table.data tbody tr.parcel-row.entering { animation: none; }
}

/* Detail row — tabs + content */
table.data tbody tr.detail-row { background: var(--bg-elevated); }
table.data tbody tr.detail-row td { padding: 0; border-bottom: 1px solid var(--border); }
.detail-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated-2);
  padding: 0 16px;
}
.detail-tabs .tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  padding: 12px 16px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.detail-tabs .tab:hover { color: var(--text); }
.detail-tabs .tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.detail-pane { display: none; padding: 20px 24px; }
.detail-pane.active { display: block; animation: fadeInUp 240ms cubic-bezier(0.16, 1, 0.3, 1); }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 24px;
}
.detail-field { display: flex; flex-direction: column; gap: 2px; }
.detail-field label { display: block; font-size: 0.7rem; font-weight: 500; color: var(--text-faint); margin: 0; letter-spacing: 0.06em; text-transform: uppercase; }
.detail-field span { font-size: 0.95rem; }
.detail-field span.small { font-size: 0.82rem; }
.detail-field .dim-W { color: #6cb6ff; font-weight: 600; }
.detail-field .dim-L { color: var(--ok);   font-weight: 600; }
.detail-field .dim-H { color: var(--err);  font-weight: 600; }

.detail-actions { margin-top: 18px; display: flex; gap: 10px; }

/* Image grid + tiles. Keyence delivers wide panoramic images
   (~3:1 aspect — typical sorter side-camera). The tile is sized
   to show the whole frame letterboxed, not cropped, so operators
   can see what's actually on the parcel without clicking through
   to the lightbox. Click for full-resolution lightbox view. */
.image-grid { display: flex; flex-wrap: wrap; gap: 10px; min-height: 60px; }
.image-tile {
  background: #0a0a0d; border: 1px solid var(--border-strong); padding: 0;
  border-radius: var(--r-sm); cursor: pointer;
  transition: transform var(--t-fast), border-color var(--t-fast);
  overflow: hidden;
}
.image-tile:hover { transform: translateY(-1px); border-color: var(--accent); }
.image-tile img {
  display: block; width: 100%; max-width: 480px;
  height: 160px; object-fit: contain;
  background: #0a0a0d;
  border-radius: var(--r-sm);
}
.image-tile-placeholder {
  padding: 32px 20px; color: var(--text-dim); font-size: 0.92rem;
  background: var(--bg-elevated-2); border: 1px dashed var(--border-strong);
  border-radius: var(--r-sm); text-align: center; flex: 1; min-width: 280px;
}
.image-tile-placeholder .small { font-size: 0.78rem; }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.92);
  display: flex; align-items: center; justify-content: center;
  cursor: zoom-out;
  animation: fadeInUp 180ms ease-out;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 92vw; max-height: 92vh; object-fit: contain; pointer-events: none; }

/* Print — when Print report (PDF) is clicked, hide everything except the
   marked detail row. */
@media print {
  body.printing-parcel > *:not(main) { display: none !important; }
  body.printing-parcel .page-header { display: none !important; }
  body.printing-parcel .table-wrap > .table-toolbar,
  body.printing-parcel table.data thead,
  body.printing-parcel table.data tbody tr:not(.detail-row.printing) {
    display: none !important;
  }
  body.printing-parcel .detail-tabs { display: none !important; }
  /* Print BOTH panes — images (top) + details (below). The Images
     pane is normally hidden by the inactive-tab visibility rule;
     force it visible for print so operators get a complete report. */
  body.printing-parcel .detail-pane { display: block !important; }
  body.printing-parcel .detail-pane[data-pane="images"] { margin-bottom: 16px; }
  body.printing-parcel .image-grid { display: flex !important; flex-wrap: wrap !important; gap: 8px; }
  body.printing-parcel .image-tile {
    border: 1px solid #aaa !important; background: white !important;
    page-break-inside: avoid;
  }
  body.printing-parcel .image-tile img {
    width: auto !important; max-width: 100% !important;
    max-height: 280px !important; height: auto !important;
    object-fit: contain !important; background: white !important;
  }
  body.printing-parcel .detail-actions { display: none !important; }
  body.printing-parcel { background: white !important; color: #111 !important; }
  body.printing-parcel * { color: #111 !important; }
  body.printing-parcel .detail-field label { color: #555 !important; }
  body.printing-parcel .detail-field .dim-W { color: #0a5a9e !important; }
  body.printing-parcel .detail-field .dim-L { color: #0a7d0a !important; }
  body.printing-parcel .detail-field .dim-H { color: #c00 !important; }
}

/* ---- Empty state -------------------------------------------------- */

.empty {
  padding: 64px 32px;
  text-align: center;
  color: var(--text-dim);
}
.empty code { color: var(--accent); }

/* ---- Recovery codes / secret box ---------------------------------- */

.secret-box {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.92rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 12px 14px;
  border-radius: var(--r-sm);
  word-break: break-all;
  user-select: all;
  color: var(--text);
}
.recovery-codes {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 14px;
  white-space: pre;
  user-select: all;
  line-height: 1.7;
  letter-spacing: 0.04em;
  color: var(--accent);
}

/* ---- Animations --------------------------------------------------- */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0ms !important;
  }
}

/* ---- Stats page ---------------------------------------------------- */

.stats-page { display: flex; flex-direction: column; gap: 18px; }

/* Window selector */
.window-selector {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 4px;
}
.window-btn {
  appearance: none;
  background: none;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast);
}
.window-btn:hover { color: var(--text); background: var(--surface-hover); }
.window-btn.active {
  color: var(--accent);
  background: var(--accent-faint);
  border-color: var(--border-accent);
}
.window-divider {
  width: 1px; height: 18px; background: var(--border-strong); margin: 0 8px;
}

.window-selector-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

.custom-range {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 0.85rem;
  animation: fadeInUp 240ms cubic-bezier(0.16, 1, 0.3, 1);
}
.custom-range[hidden] { display: none; }
.custom-range label { display: inline-flex; align-items: center; gap: 6px; margin: 0; text-transform: none; letter-spacing: 0; color: var(--text-dim); font-weight: 500; font-size: 0.8rem; }
.custom-range input[type="datetime-local"] {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 6px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  color-scheme: dark;  /* makes the calendar picker chrome match the dark theme */
}
.custom-range input[type="datetime-local"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-faint); }
.custom-range .btn { padding: 6px 12px; font-size: 0.85rem; }

/* Scope selector — pill buttons for site-wide vs per-sorter */
.scope-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.scope-btn {
  appearance: none;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--t-fast);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.scope-btn:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-hover); }
.scope-btn.active {
  color: var(--accent);
  background: var(--accent-faint);
  border-color: var(--border-accent);
  box-shadow: 0 0 0 1px var(--border-accent);
}
.scope-btn .scope-icon { font-size: 0.85rem; opacity: 0.7; }
.scope-btn .scope-name { font-weight: 600; }
.scope-btn .scope-key { font-size: 0.72rem; color: var(--text-faint); margin-left: 2px; }
.scope-btn.active .scope-key { color: var(--accent); opacity: 0.7; }

/* KPI strip */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}
/* Accent card — used for the headline metric (Total in window) */
.kpi-card-accent { background: linear-gradient(135deg, var(--surface) 0%, rgba(255, 122, 26, 0.08) 100%); }
.kpi-card-accent::before { width: 4px; opacity: 1; }
.kpi-card-accent .kpi-value { color: var(--accent); }
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--t-fast), transform var(--t-fast);
}
.kpi-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent);
  opacity: 0.6;
}
.kpi-label {
  font-size: 0.7rem;
  color: var(--text-faint);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.kpi-value {
  font-size: 1.9rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1;
}
.kpi-value.ok { color: var(--ok); }
.kpi-value.warn { color: var(--warn); }
.kpi-value.err { color: var(--err); }
.kpi-unit { font-size: 0.95rem; font-weight: 500; color: var(--text-dim); margin-left: 2px; }
.kpi-sub { font-size: 0.75rem; }

/* Generic panel */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.panel-title { font-size: 0.95rem; font-weight: 600; letter-spacing: -0.005em; color: var(--text); }
.panel-body { padding: 18px 20px; }

.chart-wrap { height: 280px; position: relative; }

.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 980px) { .grid-2col { grid-template-columns: 1fr; } }

/* Quality breakdown — donut + custom legend */
.quality-doughnut-wrap {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  align-items: center;
}
@media (max-width: 720px) {
  .quality-doughnut-wrap { grid-template-columns: 1fr; }
}
.quality-chart-box {
  position: relative;
  width: 200px;
  height: 200px;
}
.quality-chart-box canvas { width: 100% !important; height: 100% !important; }
.quality-chart-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
}
.quality-center-value {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--ok);
  letter-spacing: -0.01em;
  line-height: 1;
}
.quality-center-label {
  font-size: 0.7rem;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 4px;
}
.quality-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.quality-legend-row {
  display: grid;
  grid-template-columns: 14px 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.quality-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(255,255,255,0.04);
}
.quality-legend-name { font-size: 0.92rem; color: var(--text); }
.quality-legend-pct { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.quality-legend-count { font-size: 0.82rem; }

/* Old quality bars — kept for any legacy markup; the donut is the
   default but these rules don't hurt anything if a partial cache
   serves an old template. */
.quality-bars { display: flex; flex-direction: column; gap: 12px; }
.quality-row {
  display: grid;
  grid-template-columns: 130px 1fr 70px 70px;
  align-items: center;
  gap: 12px;
  font-size: 0.92rem;
}
.quality-label { color: var(--text-dim); }
.quality-bar {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.quality-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width var(--t-slow);
}
.quality-bar-ok   { background: linear-gradient(90deg, var(--ok), #56e6aa); box-shadow: 0 0 12px rgba(61,220,151,0.4); }
.quality-bar-warn { background: linear-gradient(90deg, var(--warn), #ffe17a); box-shadow: 0 0 12px rgba(255,210,63,0.4); }
.quality-bar-err  { background: linear-gradient(90deg, var(--err), #ff7a92); box-shadow: 0 0 12px rgba(255,77,109,0.4); }
.quality-bar-dim  { background: var(--text-faint); }
.quality-pct { color: var(--text); font-weight: 600; text-align: right; }
.quality-count { color: var(--text-dim); text-align: right; font-size: 0.85rem; }

/* Top chutes */
.top-chutes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.chute-row {
  display: grid;
  /* Auto-width on the label column so "Sorter1 #13" doesn't wrap; bar
     stretches with the row; count fixed-width on the right. */
  grid-template-columns: minmax(110px, max-content) 1fr 60px;
  align-items: center;
  gap: 12px;
}
.chute-num {
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
/* Small sorter chip in front of the chute number on the site-wide view. */
.chute-sorter {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.chute-hash { color: var(--accent); }
.chute-bar { height: 6px; background: var(--bg-elevated); border-radius: 999px; overflow: hidden; }
.chute-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #ffaf6e);
  box-shadow: 0 0 10px var(--accent-glow);
  transition: width var(--t-slow);
}
.chute-count { text-align: right; color: var(--text); font-weight: 600; }

/* Per-sorter cards */
.sorter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.sorter-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color var(--t-fast), transform var(--t-fast);
}
.sorter-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.sorter-card-head { display: flex; align-items: flex-start; gap: 10px; }
.stack-tight { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.sorter-name { font-size: 1rem; font-weight: 600; color: var(--text); }

.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
  margin-top: 4px;
}
.status-dot.online {
  background: var(--ok);
  box-shadow: 0 0 12px var(--ok);
  animation: pulseDot 2s ease-in-out infinite;
}
.status-dot.offline { background: var(--text-faint); }

.sorter-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.stat-block { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label { font-size: 0.65rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value { font-size: 1.05rem; font-weight: 600; color: var(--text); }
.stat-value.ok   { color: var(--ok); }
.stat-value.warn { color: var(--warn); }
.stat-value.err  { color: var(--err); }

.sorter-quality { display: flex; flex-wrap: wrap; gap: 6px; }
.pill.small { padding: 1px 8px; font-size: 0.7rem; }

.sorter-spark { height: 40px; }
.sparkline { width: 100%; height: 40px; display: block; }
.sparkline path { stroke-width: 1.4; stroke-linejoin: round; stroke-linecap: round; }

/* KPI delta — small chip below value. Good = green, bad = red, neutral = grey.
   Inverted-semantic metrics (e.g. no-read rate) flip green/red so "down is
   good" reads correctly. */
.kpi-sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.kpi-delta.good    { background: var(--ok-faint);   color: var(--ok); }
.kpi-delta.bad     { background: var(--err-faint);  color: var(--err); }
.kpi-delta.neutral { background: rgba(255,255,255,0.04); color: var(--text-faint); }

/* Clickable KPI card (no-read drilldown) — subtle cursor + hover hint */
.kpi-card-clickable { cursor: pointer; }
.kpi-card-clickable:hover { border-color: var(--border-strong); }
.kpi-card-clickable:focus-visible {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-faint);
}

/* Throughput heatmap (last 7 days × 30-min cells by default).
   --heatmap-cols set by stats.js based on bucket size; defaults to 48
   so the rule is correct even if JS hasn't run yet. */
.heatmap {
  display: grid;
  grid-template-columns: 90px repeat(var(--heatmap-cols, 48), 1fr);
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  align-items: center;
}
.heatmap-corner { /* empty top-left */ }
.heatmap-col-label {
  color: var(--text-faint);
  text-align: center;
  font-size: 0.65rem;
  padding-bottom: 2px;
}
.heatmap-row-label {
  color: var(--text-dim);
  text-align: right;
  padding-right: 8px;
  font-size: 0.7rem;
}
.heatmap-cell {
  display: block;
  height: 16px;
  border-radius: 2px;
  background: var(--bg-elevated);
  cursor: pointer;
  transition: transform var(--t-fast);
}
.heatmap-cell:hover {
  transform: scale(1.6);
  z-index: 2;
  position: relative;
  box-shadow: 0 0 0 1px var(--border-strong);
}

/* Click-drilldown popover */
.heatmap-popover {
  position: absolute;
  z-index: 50;
  min-width: 240px;
  max-width: 300px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 12.5px;
}
.heatmap-popover .hp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.heatmap-popover .hp-when {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text);
}
.heatmap-popover .hp-close {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
}
.heatmap-popover .hp-close:hover { color: var(--text); background: var(--surface-hover); }
.heatmap-popover .hp-scope {
  color: var(--text-dim);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.heatmap-popover .hp-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0;
}
.heatmap-popover .hp-grid dt {
  color: var(--text-dim);
  font-size: 11.5px;
}
.heatmap-popover .hp-grid dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}
/* 5 levels of orange — l0 = no data, l4 = peak. Mixed with the brand
   accent so the heatmap visually ties to the rest of the page. */
.heatmap-l0 { background: var(--bg-elevated); }
.heatmap-l1 { background: rgba(255, 122, 26, 0.18); }
.heatmap-l2 { background: rgba(255, 122, 26, 0.38); }
.heatmap-l3 { background: rgba(255, 122, 26, 0.62); }
.heatmap-l4 { background: rgba(255, 122, 26, 0.92); box-shadow: 0 0 8px var(--accent-glow); }

.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--text-dim);
}
.heatmap-legend .heatmap-cell {
  width: 14px;
  height: 14px;
}
.heatmap-legend .small { font-size: 0.7rem; }

/* Modal — used by the no-read drilldown */
.modal {
  position: fixed; inset: 0; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  animation: fadeInUp 200ms ease-out;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
}
.modal-panel {
  position: relative;
  z-index: 1;
  width: min(800px, 92vw);
  max-height: 88vh;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.1rem; }
.modal-sub { padding: 8px 20px; font-size: 0.85rem; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-close {
  appearance: none;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.6rem;
  line-height: 1;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: color var(--t-fast), background var(--t-fast);
}
.modal-close:hover { color: var(--text); background: var(--surface-hover); }

/* No-read row inside the drilldown modal */
.noread-list { display: flex; flex-direction: column; gap: 10px; }
.noread-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px;
  transition: border-color var(--t-fast);
}
.noread-row:hover { border-color: var(--border-strong); }
.noread-thumb {
  width: 96px; height: 72px; object-fit: cover;
  border-radius: var(--r-sm);
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
}
.noread-thumb-empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
  font-size: 0.78rem;
  font-family: var(--font-mono);
}
.noread-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.noread-meta-top { display: flex; gap: 12px; align-items: baseline; }
.noread-meta-mid { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; font-size: 0.88rem; }
.noread-meta-bot { font-size: 0.78rem; }

/* CSV download button — anchor styled like a window-btn */
a#csv-export-btn {
  text-decoration: none;
}
a#csv-export-btn:hover {
  color: var(--accent);
  background: var(--accent-faint);
}

/* ---- Reports page ------------------------------------------------- */

.reports-page { display: flex; flex-direction: column; gap: 18px; }

/* Period selector — tight enough to fit on one line at typical viewport
   widths. Kept wrap-friendly via flex-wrap so it still degrades gracefully
   on narrow screens. */
.period-selector-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.period-selector {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 3px;
  flex-wrap: wrap;
  max-width: 100%;
}
.period-btn {
  appearance: none;
  background: none;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 5px 9px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.3;
}
.period-btn:hover { color: var(--text); background: var(--surface-hover); }
.period-btn.active {
  color: var(--accent);
  background: var(--accent-faint);
  border-color: var(--border-accent);
}

/* KPI strip — bigger variant for reports headline */
.kpi-strip-large .kpi-card { padding: 22px 24px; }
.kpi-strip-large .kpi-value { font-size: 2.4rem; }
.kpi-strip-large .kpi-card-accent .kpi-value { font-size: 2.6rem; }

/* Insights panel */
.insights-panel { border-color: var(--border-accent); }
.insights-panel .panel-header {
  background: linear-gradient(90deg, var(--bg-elevated) 0%, var(--accent-faint) 100%);
}
.insights-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.insight {
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 0.95rem;
  border-left: 3px solid var(--text-faint);
  background: var(--bg-elevated);
  transition: transform var(--t-fast);
}
.insight:hover { transform: translateX(2px); }
.insight-good    { border-left-color: var(--ok);     background: linear-gradient(90deg, var(--ok-faint), transparent 70%); }
.insight-bad     { border-left-color: var(--err);    background: linear-gradient(90deg, var(--err-faint), transparent 70%); }
.insight-neutral { border-left-color: var(--text-faint); }
.insight-fact    { border-left-color: var(--info);   background: linear-gradient(90deg, rgba(108,182,255,0.10), transparent 70%); }

/* Best-day / best-hour callout strip */
.callout-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 880px) {
  .callout-strip { grid-template-columns: 1fr; }
}
.callout {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  position: relative;
  overflow: hidden;
}
.callout::before {
  content: "";
  position: absolute;
  inset: auto auto -40% -20%;
  width: 200px; height: 200px;
  background: radial-gradient(circle, var(--accent-faint), transparent 70%);
  pointer-events: none;
}
.callout-label {
  font-size: 0.7rem; color: var(--text-faint);
  font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
  position: relative; z-index: 1;
}
.callout-value { font-size: 1.5rem; font-weight: 600; color: var(--text); position: relative; z-index: 1; }
.callout-sub   { font-size: 0.85rem; color: var(--text-dim); position: relative; z-index: 1; }

/* Daily chart — slightly taller than other panels but not so tall it
   dominates. 240px keeps a 30-day bar series readable without stretching
   each bar across half the page. */
.chart-wrap-tall { height: 240px; }

/* Sorter leaderboard */
.leaderboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
@media (max-width: 1100px) {
  .leaderboard-grid { grid-template-columns: 1fr; }
}
.leaderboard-cat {
  font-size: 0.85rem;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lb-row {
  display: grid;
  grid-template-columns: 36px 1fr 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color var(--t-fast), transform var(--t-fast);
}
.lb-row:hover { border-color: var(--border-strong); transform: translateX(2px); }
.lb-rank-1 { border-color: rgba(255,210,63,0.4); background: linear-gradient(90deg, rgba(255,210,63,0.10), var(--bg-elevated) 60%); }
.lb-rank-2 { border-color: rgba(192,192,192,0.3); background: linear-gradient(90deg, rgba(192,192,192,0.06), var(--bg-elevated) 60%); }
.lb-rank-3 { border-color: rgba(205,127,50,0.3);  background: linear-gradient(90deg, rgba(205,127,50,0.08), var(--bg-elevated) 60%); }
.lb-medal { font-size: 1.4rem; line-height: 1; text-align: center; }
.lb-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.lb-name { font-size: 0.92rem; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-key  { font-size: 0.72rem; }
.lb-bar  { height: 6px; background: var(--bg-elevated-2); border-radius: 999px; overflow: hidden; }
.lb-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #ffaf6e);
  box-shadow: 0 0 8px var(--accent-glow);
  transition: width var(--t-slow);
}
.lb-rank-1 .lb-bar-fill { background: linear-gradient(90deg, #ffd23f, #ffe57a); box-shadow: 0 0 8px rgba(255,210,63,0.5); }
.lb-value { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.lb-sub   { display: block; font-size: 0.7rem; }
/* 0-value rows (idle sorters in the volume board) — dimmed so they read
   as "present but inactive" without dropping off the leaderboard entirely. */
.lb-row-empty { opacity: 0.55; }
.lb-row-empty .lb-bar-fill { background: var(--text-faint); box-shadow: none; }

/* Shift breakdown */
.shift-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 980px) {
  .shift-grid { grid-template-columns: 1fr; }
}
.shift-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.shift-card-head { display: flex; align-items: center; gap: 10px; }
.shift-icon { font-size: 1.4rem; line-height: 1; }
.shift-label { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.shift-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

/* Year heatmap (GitHub-style 53-week × 7-day grid) */
.year-heatmap {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 8px;
}
.yh-month-row {
  display: grid;
  grid-template-columns: 32px repeat(53, 1fr);
  margin-bottom: 4px;
  font-size: 0.7rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
  height: 14px;
  position: relative;
}
.yh-month-label { grid-row: 1; padding-left: 2px; }
.yh-grid {
  display: grid;
  grid-template-columns: 32px repeat(53, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: 2px;
  min-width: 720px; /* keep heatmap legible on narrow screens — scrolls if needed */
}
.yh-dow-label { color: var(--text-faint); padding-right: 6px; align-self: center; grid-column: 1; }
.yh-cell {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 11px;
  border-radius: 2px;
  background: var(--bg-elevated);
  transition: transform var(--t-fast);
}
.yh-cell:hover:not(.yh-empty) { transform: scale(1.6); z-index: 2; position: relative; }
.yh-empty { visibility: hidden; }

/* Parcel search & export panel */
.parcel-filter-grid {
  display: grid;
  grid-template-columns: 160px 1fr 140px auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 14px;
}
@media (max-width: 880px) {
  .parcel-filter-grid {
    grid-template-columns: 1fr 1fr;
  }
  .parcel-filter-actions { grid-column: 1 / -1; }
}
.parcel-filter { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.parcel-filter label {
  margin: 0;
  font-size: 0.7rem;
  color: var(--text-faint);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.filter-input,
.parcel-filter input[type="text"],
.parcel-filter input[type="search"],
.parcel-filter select {
  width: 100%;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}
.parcel-filter select { appearance: none; cursor: pointer; padding-right: 30px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' stroke='%239092a0' stroke-width='1.6' fill='none'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.parcel-filter input:focus,
.parcel-filter select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-faint);
}
.parcel-filter-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.parcel-filter-actions .btn { padding: 8px 14px; font-size: 0.85rem; white-space: nowrap; }

.parcel-search-meta {
  padding: 10px 14px;
  background: var(--bg-elevated);
  border-radius: var(--r-sm);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.parcel-search-meta.err { color: var(--err); background: var(--err-faint); }
.match-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-faint);
  color: var(--accent);
  border: 1px solid var(--border-accent);
  font-weight: 600;
  letter-spacing: 0.02em;
  font-family: var(--font-mono);
}

.parcel-preview-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  animation: fadeInUp 240ms cubic-bezier(0.16, 1, 0.3, 1);
}
.parcel-preview-header {
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.parcel-preview-table-wrap { max-height: 520px; overflow-y: auto; }
.parcel-preview-table { font-size: 0.85rem; }
.parcel-preview-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}
/* Expand-on-click rows: thumbnail + click-to-expand UX. */
.parcel-row { cursor: pointer; transition: background 80ms ease; }
.parcel-row:hover { background: var(--surface-hover, rgba(0, 0, 0, 0.04)); }
.parcel-row.expanded { background: var(--surface-hover, rgba(0, 0, 0, 0.05)); }
.parcel-thumb {
  width: 44px; height: 44px; object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  display: block;
}
.parcel-thumb-placeholder {
  display: inline-block; width: 44px; text-align: center;
  color: var(--ink-muted, #aaa); font-size: 12px;
}
.parcel-row-expand > td {
  background: var(--surface-hover, rgba(0, 0, 0, 0.03));
  padding: 12px 14px;
}
.parcel-expand-grid {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 16px;
}
@media (max-width: 720px) {
  .parcel-expand-grid { grid-template-columns: 1fr; }
}
.parcel-expand-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 4px 0; border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.06));
}
.parcel-expand-row:last-child { border-bottom: 0; }
.parcel-img-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}
.parcel-img-tile img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 4px; display: block;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
}
.parcel-img-tile:hover img { border-color: var(--accent, #4a90e2); }

/* ---- OOG panel on Reports ------------------------------------------ */
.oog-panel { border-left: 4px solid #f59e0b; }
.oog-grid {
  display: grid;
  grid-template-columns: 160px 1fr 240px;
  gap: 18px;
  align-items: start;
}
@media (max-width: 900px) {
  .oog-grid { grid-template-columns: 1fr; }
}
.oog-kpi-cell {
  background: rgba(254, 243, 199, 0.4);
  border-radius: 8px;
  padding: 14px 16px;
  text-align: center;
}
.oog-kpi-value { font-size: 32px; font-weight: 700; color: #92400e; }
.oog-kpi-label { font-size: 12px; margin-top: 2px; }
.oog-reasons-list { display: flex; flex-direction: column; gap: 4px; }
.oog-reason-row {
  display: grid;
  grid-template-columns: 200px 1fr 60px;
  gap: 10px;
  align-items: center;
  padding: 4px 6px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
  color: inherit;
}
.oog-reason-row:hover { background: var(--surface-hover, rgba(0, 0, 0, 0.04)); }
.oog-reason-label { font-family: var(--font-mono, monospace); font-size: 11px; }
.oog-reason-bar-wrap {
  background: var(--surface-hover, rgba(0, 0, 0, 0.06));
  height: 8px; border-radius: 4px; overflow: hidden;
}
.oog-reason-bar { display: block; height: 100%; background: #f59e0b; border-radius: 4px; }
.oog-reason-count { text-align: right; }
.oog-sorter-row {
  display: flex; justify-content: space-between;
  padding: 3px 4px; font-size: 12px;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.06));
}
.oog-sorter-row:last-child { border-bottom: 0; }

/* ---- SCADA page ----------------------------------------------------- */

.scada-page { display: flex; flex-direction: column; gap: 12px; }

.scada-stage {
  position: relative;
  width: 100%;
  height: 70vh;
  min-height: 480px;
  background: #0a0a0d;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.scada-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* HUD pinned top-left of the canvas */
.scada-hud {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
  background: rgba(15, 16, 20, 0.7);
  backdrop-filter: blur(10px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 0.85rem;
  pointer-events: none;
}
.scada-hud-row {
  display: flex;
  gap: 12px;
  align-items: baseline;
}
.scada-hud-row > span:first-child { min-width: 90px; }

/* Centered overlay shown for loading / empty / error states */
.scada-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 13, 0.7);
  backdrop-filter: blur(6px);
  z-index: 2;
  animation: fadeInUp 240ms ease-out;
}
.scada-overlay-card {
  max-width: 480px;
  padding: 26px 32px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  text-align: center;
  box-shadow: var(--shadow-card);
}
.scada-overlay-icon { font-size: 2.5rem; margin-bottom: 8px; }
.scada-overlay-title { margin: 6px 0 8px 0; font-size: 1.15rem; }
.scada-overlay-text { margin: 0; color: var(--text-dim); font-size: 0.92rem; line-height: 1.55; }
.scada-overlay-empty .scada-overlay-card  { border-color: rgba(108, 182, 255, 0.3); }
.scada-overlay-error .scada-overlay-card  { border-color: rgba(255, 77, 109, 0.3); }
.scada-overlay-error .scada-overlay-title { color: var(--err); }

.scada-tagged-table { font-size: 0.9rem; }

/* ---- Admin pages (audit + user management) ---------------------------- */

.header-admin-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: var(--r-md);
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--t-fast), background var(--t-fast);
}
.header-admin-link:hover { color: var(--text); background: var(--surface-hover); }
.header-admin-link.active { color: var(--text); background: var(--accent-faint); }

.audit-page, .users-page, .backups-page { display: flex; flex-direction: column; gap: 16px; }

/* Backup drills — output excerpt cell renders as a small monospace block */
.backups-table .backup-excerpt {
  margin: 0;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow: hidden;
  color: var(--text-dim);
  font-size: 0.78rem;
  line-height: 1.4;
}

.audit-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr 120px auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 14px;
}
@media (max-width: 880px) {
  .audit-toolbar { grid-template-columns: 1fr 1fr; }
  .audit-toolbar .parcel-filter-actions { grid-column: 1 / -1; }
}

.audit-table-wrap { max-height: 70vh; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--r-sm); }
.audit-table { width: 100%; }
.audit-table thead th { position: sticky; top: 0; z-index: 1; }
.audit-action {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}
.audit-detail {
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 580px;
  color: var(--text);
  font-size: 0.92rem;
}
.audit-detail .ok-text  { color: var(--ok); }
.audit-detail .err-text { color: var(--err); }
.audit-detail .muted    { color: var(--text-dim); }
.audit-detail .small    { font-size: 0.82rem; }

/* User management table */
.users-table { width: 100%; }
.users-table .pill { white-space: nowrap; }
.users-table .role-pill-admin    { background: var(--accent-faint); color: var(--accent); border: 1px solid var(--border-accent); }
.users-table .role-pill-engineer { background: var(--ok-faint);     color: var(--ok); }
.users-table .role-pill-operator { background: var(--warn-faint);   color: var(--warn); }
.users-table .role-pill-viewer   { background: rgba(255,255,255,0.04); color: var(--text-dim); }
.users-table .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.users-table .row-actions .btn { padding: 4px 10px; font-size: 0.78rem; }
.users-table tr.deactivated { opacity: 0.55; }

.add-user-form {
  display: grid;
  grid-template-columns: 1fr 1fr 140px auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 18px;
}
@media (max-width: 880px) {
  .add-user-form { grid-template-columns: 1fr 1fr; }
  .add-user-form > .btn { grid-column: 1 / -1; }
}

.password-banner {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--ok-faint);
  border: 1px solid rgba(61, 220, 151, 0.3);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.password-banner .pwd-value {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ok);
  background: var(--bg);
  padding: 6px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  user-select: all;
}
.password-banner-warn {
  background: var(--warn-faint);
  border-color: rgba(255, 210, 63, 0.3);
}
.password-banner-warn .pwd-value { color: var(--warn); }

/* Edge-agent status pill — used on /routing96 to show whether the
   docker agent for the active sorter is heartbeating central. Three
   states (online / offline / unknown) with a left-side dot. */
.agent-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
}
.agent-status .agent-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}
.agent-status-online {
  color: var(--ok);
  border-color: rgba(61, 220, 151, 0.3);
  background: var(--ok-faint);
}
.agent-status-online .agent-status-dot {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  animation: pulseDot 2s ease-in-out infinite;
}
.agent-status-offline {
  color: var(--err);
  border-color: rgba(255, 77, 109, 0.3);
  background: var(--err-faint);
}
.agent-status-offline .agent-status-dot {
  background: var(--err);
  box-shadow: 0 0 8px var(--err);
}
.agent-status-unknown {
  color: var(--text-faint);
}

/* ---- Depot Routing page ------------------------------------------------ */

.routing-page { display: flex; flex-direction: column; gap: 16px; }

/* Tab bar */
.routing-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 4px;
  width: max-content;
}
.routing-tab {
  appearance: none;
  background: none;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast);
}
.routing-tab:hover { color: var(--text); background: var(--surface-hover); }
.routing-tab.active {
  color: var(--accent);
  background: var(--accent-faint);
  border-color: var(--border-accent);
}
.routing-pane { display: none; }
.routing-pane.active { display: block; animation: fadeInUp 240ms cubic-bezier(0.16, 1, 0.3, 1); }

/* Assign toolbar */
.assign-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.assign-toolbar input[type="search"] {
  flex: 1;
  min-width: 240px;
  max-width: 480px;
}
.assign-toolbar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-dim);
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}
.assign-toolbar-toggle input { margin: 0; cursor: pointer; }
.assign-toolbar-spacer { flex: 1; }
#assign-pending {
  font-size: 0.78rem;
  transition: color var(--t-base);
}
#assign-pending.saved { color: var(--ok); }

/* Chute card grid — bigger cards now we're showing a multi-route spec */
.assign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding: 4px;
}
.chute-card {
  appearance: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
  text-align: left;
  font-family: inherit;
  color: var(--text);
}
.chute-card:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
  transform: translateY(-1px);
}
.chute-card-empty {
  border-style: dashed;
  opacity: 0.7;
}
.chute-card-empty:hover { opacity: 1; }
.chute-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.chute-card-num {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}
.chute-card-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  padding: 2px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-faint);
  border: 1px solid var(--border-accent);
  border-radius: 999px;
}
.chute-card-count-empty {
  color: var(--text-faint);
  background: transparent;
  border-color: var(--border);
}
.chute-card-spec {
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: break-word;
  /* Cap at ~3 lines so a chute with 200 routes doesn't stretch the card. */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Chute editor modal — spec input + live status + conflicts list */
.chute-spec-help {
  margin-top: 6px;
  margin-bottom: 12px;
}
.chute-spec-status {
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-radius: var(--r-sm);
  font-size: 0.88rem;
  margin-bottom: 12px;
}
.chute-spec-status .err-text { color: var(--err); }
.chute-spec-status .ok-text  { color: var(--ok); }
.chute-spec-conflicts {
  padding: 10px 14px;
  background: var(--err-faint);
  border: 1px solid rgba(255, 77, 109, 0.3);
  border-radius: var(--r-sm);
  margin-bottom: 12px;
}
.chute-spec-conflicts strong { display: block; color: var(--err); margin-bottom: 6px; }
.conflict-list { list-style: none; margin: 0 0 6px 0; padding: 0; }
.conflict-list li { font-size: 0.88rem; padding: 2px 0; }
.conflict-list .err-text { color: var(--err); }
#chute-spec-input { font-family: var(--font-mono); }

/* Assign modal — route picker */
.route-pick-list {
  margin: 14px 0;
  max-height: 380px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.route-pick-row {
  display: grid;
  grid-template-columns: 50px auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.route-pick-row:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}
.route-pick-num {
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-faint);
  border-radius: var(--r-sm);
  padding: 2px 8px;
  text-align: center;
}
.route-pick-name { font-size: 0.95rem; }
.route-pick-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#assign-route-filter { margin-top: 8px; }
.modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* Routes catalogue */
.route-toolbar {
  display: grid;
  grid-template-columns: 100px 1fr 2fr auto;
  gap: 10px;
  margin-bottom: 18px;
  align-items: center;
}
@media (max-width: 880px) {
  .route-toolbar { grid-template-columns: 1fr 1fr; }
  .route-toolbar > .btn { grid-column: 1 / -1; }
}
.routes-table .pill { white-space: nowrap; }

/* Chute monitor severity colours on the bar lists */
.chute-bar-fill-overloaded { background: linear-gradient(90deg, var(--err), #ff7a92); box-shadow: 0 0 10px rgba(255,77,109,0.4); }
.chute-bar-fill-heavy      { background: linear-gradient(90deg, var(--warn), #ffe17a); box-shadow: 0 0 8px rgba(255,210,63,0.3); }
.chute-bar-fill-balanced   { background: linear-gradient(90deg, var(--ok), #56e6aa); box-shadow: 0 0 8px rgba(61,220,151,0.3); }
.chute-bar-fill-light      { background: linear-gradient(90deg, var(--info), #9ed1ff); }
.chute-bar-fill-idle       { background: var(--text-faint); }
.chute-row-route { display: block; grid-column: 1 / -1; padding-left: 64px; padding-top: 2px; }

/* ---- Print stylesheet for Reports ----
   Triggered by body.printing-report (set by reports.js when "Print / PDF"
   is clicked). Hides nav chrome, makes the layout single-column, forces
   a white background so the PDF is readable. */
@media print {
  body.printing-report > *:not(main) { display: none !important; }
  body.printing-report .page-header { display: none !important; }
  body.printing-report .period-selector-wrap,
  body.printing-report .scope-selector { display: none !important; }
  body.printing-report .grid-2col,
  body.printing-report .leaderboard-grid,
  body.printing-report .shift-grid,
  body.printing-report .callout-strip,
  body.printing-report .kpi-strip { display: block !important; }
  body.printing-report .grid-2col > .panel,
  body.printing-report .leaderboard-grid > .leaderboard-col,
  body.printing-report .shift-grid > .shift-card,
  body.printing-report .callout-strip > .callout,
  body.printing-report .kpi-strip > .kpi-card {
    page-break-inside: avoid;
    margin-bottom: 12px;
  }
  body.printing-report {
    background: white !important;
    color: #111 !important;
  }
  body.printing-report .panel,
  body.printing-report .kpi-card,
  body.printing-report .callout,
  body.printing-report .lb-row,
  body.printing-report .shift-card,
  body.printing-report .insight {
    background: white !important;
    color: #111 !important;
    border-color: #ddd !important;
    box-shadow: none !important;
  }
  body.printing-report .panel-header { background: #f5f5f5 !important; color: #111 !important; }
  body.printing-report * { color: #111 !important; }
  body.printing-report .muted, body.printing-report .small { color: #555 !important; }
  body.printing-report .kpi-value.ok   { color: #1a7d4a !important; }
  body.printing-report .kpi-value.warn { color: #a17c00 !important; }
  body.printing-report .kpi-value.err  { color: #b00020 !important; }
  body.printing-report canvas { max-width: 100% !important; height: auto !important; }
  body.printing-report .yh-cell { border: 1px solid #ccc; }
  body.printing-report .heatmap-l0 { background: #fafafa !important; }
  body.printing-report .heatmap-l1 { background: #ffe0c2 !important; }
  body.printing-report .heatmap-l2 { background: #ffb066 !important; }
  body.printing-report .heatmap-l3 { background: #ff8a1f !important; }
  body.printing-report .heatmap-l4 { background: #cc5a00 !important; }
}

/* Search-state live indicator class re-used; nothing extra needed */

/* ---- Utilities ---------------------------------------------------- */

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--text-dim); }
.mt-3 { margin-top: 24px; }
.mt-2 { margin-top: 16px; }
.mt-1 { margin-top: 8px; }
.fade-in { animation: fadeInUp 480ms cubic-bezier(0.16, 1, 0.3, 1); }


/* ---- Engineering page (ePlan viewer) ----------------------------- */
/*
 * Sidebar + iframe split. Sidebar takes a fixed width; iframe fills
 * everything else and stretches vertically to the available space.
 * On narrow screens the sidebar collapses above the viewer.
 */
.page-engineering .main {
  /* Make the engineering shell fill the viewport beneath the header. */
  padding: 0;
  height: calc(100vh - 64px);   /* roughly header height; will adjust if header wraps */
  min-height: 600px;
}
.engineering-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  height: 100%;
  background: var(--bg);
}
.eng-sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
  min-height: 0;
}
.eng-sidebar-head {
  padding: 14px 16px 8px;
  border-bottom: 1px solid var(--border);
}
.eng-sidebar-head h2 {
  margin: 0;
  font-family: "Orbitron", "Inter", system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
}
.eng-sidebar-sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-dim);
}
.eng-search {
  margin: 10px 12px 6px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 120ms ease;
}
.eng-search:focus { border-color: var(--accent); }
.eng-list {
  list-style: none;
  margin: 0;
  padding: 0 4px 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.eng-list li { margin: 0; }

/* ---- Tree-style outline (mirrors PDF.js's bookmarks panel) ----- */
.eng-tree, .eng-tree-children {
  list-style: none;
  margin: 0;
  padding: 0;
}
.eng-tree-node { margin: 0; }

/* Each row is indented in proportion to its tree depth — 12px per
   level, capped via padding so deep trees don't push everything off
   the right edge. */
.eng-tree-row {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 4px calc(8px + var(--depth, 0) * 12px);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--text-dim);
  text-align: left;
  font: inherit;
  font-size: 12px;
  line-height: 1.3;
  cursor: pointer;
  transition: background 90ms ease, color 90ms ease, border-color 90ms ease;
}
.eng-tree-row:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.eng-tree-row.active {
  background: var(--accent-faint);
  color: var(--text);
  border-color: var(--border-accent);
}

.eng-tree-caret {
  width: 10px;
  flex-shrink: 0;
  color: var(--text-faint);
  font-size: 9px;
  transition: color 80ms ease;
}
.eng-tree-row:hover .eng-tree-caret { color: var(--accent); }
.eng-tree-caret.ow-hidden { visibility: hidden; }

.eng-tree-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.eng-tree-page {
  flex-shrink: 0;
  font-size: 10.5px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  margin-left: 4px;
}

/* Collapsed state: hide children. Caret still shows ▶ (set in JS). */
.eng-tree-node.eng-tree-collapsed > .eng-tree-children {
  display: none;
}

.eng-tree-empty {
  padding: 12px;
  color: var(--text-dim);
  font-size: 12px;
  font-style: italic;
}

/* In search mode the rows are flat (no tree depth indent). */
.eng-tree-search .eng-tree-row {
  padding-left: 8px;
}
.eng-empty {
  padding: 14px 16px;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.5;
}
.eng-empty code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 4px;
  border-radius: 4px;
}
.eng-viewer {
  position: relative;
  background: var(--bg);
  min-height: 0;
}
.eng-viewer iframe,
.eng-viewer object,
.eng-viewer embed {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg);
}
.eng-viewer-empty {
  padding: 40px;
  color: var(--text-dim);
  font-size: 14px;
  text-align: center;
}

@media (max-width: 900px) {
  .engineering-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 280px 1fr;
  }
  .eng-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}


/* ---- Orion chat widget (Stage 5 of the AI rollout) ---------------- */
/*
 * Class prefix `ow-` (orion-widget) so we never collide with existing
 * page styles. Pulls colours from the design tokens at :root so it
 * matches future theme work for free.
 */

/*
 * Launcher — chat-bubble-shaped pill in the bottom-right corner.
 * Speech-bubble corner radius (bottom-right corner pulled in to a
 * smaller radius) so the silhouette reads as "this is a chat thing"
 * before the user even reads the label. Two-line text composition
 * — "Ask Orion / AI assistant" — invites action; the gold star icon
 * is the brand mark (Orion = the constellation).
 */
.ow-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px 12px 14px;
  /* Chat-bubble corner — bottom-right tucks in tighter. */
  border-radius: 18px 18px 4px 18px;
  border: 1px solid var(--border-strong);
  background:
    radial-gradient(120% 140% at 0% 0%, var(--accent-faint) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-elevated), var(--bg-elevated-2));
  color: var(--text);
  font-family: var(--font-ui);
  cursor: pointer;
  /*
   * Layered glow:
   *   1. depth shadow keeps it grounded against the page
   *   2. inner-edge highlight (1px) for crisp boundary
   *   3. gold halo matching the star colour — close-in, ~32px
   *   4. orange accent aura — wide, ~64px, ties it to brand
   * The keyframes below breathe the gold + orange layers in sync
   * with the star's own pulse so the whole pill feels alive
   * rather than just the icon.
   */
  box-shadow:
    0 10px 28px rgba(0, 0, 0, 0.45),
    0 0 0 1px var(--border),
    0 0 32px rgba(255, 200, 87, 0.28),
    0 0 64px var(--accent-glow);
  animation: ow-launcher-glow 3s ease-in-out infinite;
  transition:
    transform 160ms cubic-bezier(0.16, 1, 0.3, 1),
    border-color 160ms ease;
}
@keyframes ow-launcher-glow {
  0%, 100% {
    box-shadow:
      0 10px 28px rgba(0, 0, 0, 0.45),
      0 0 0 1px var(--border),
      0 0 32px rgba(255, 200, 87, 0.28),
      0 0 64px rgba(255, 122, 26, 0.35);
  }
  50% {
    box-shadow:
      0 12px 32px rgba(0, 0, 0, 0.50),
      0 0 0 1px var(--border-strong),
      0 0 44px rgba(255, 200, 87, 0.50),
      0 0 88px rgba(255, 122, 26, 0.55);
  }
}
.ow-launcher:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  /* Hover trumps the breathing: hold a brighter steady glow so the
     user gets clear feedback that their cursor is in the right place. */
  animation: none;
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.55),
    0 0 0 1px var(--accent),
    0 0 56px rgba(255, 200, 87, 0.55),
    0 0 110px rgba(255, 122, 26, 0.65);
}
.ow-launcher:active {
  transform: translateY(0);
  animation: none;
}
.ow-launcher:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.ow-launcher-star {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  /* Gold-amber, leaning warm to match the orange accent without
     being identical to it — matches the dot on the "i" in the Orion
     wordmark (a star inside concentric rings). 32px gives both rings
     and the star body enough room to read at a glance. */
  color: #ffc857;
  filter: drop-shadow(0 0 6px rgba(255, 200, 87, 0.55));
  animation: ow-star-pulse 3s ease-in-out infinite;
}
.ow-launcher-star svg {
  width: 100%;
  height: 100%;
  display: block;
}
@keyframes ow-star-pulse {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 0 6px rgba(255, 200, 87, 0.55));
  }
  50% {
    transform: scale(1.08);
    filter: drop-shadow(0 0 12px rgba(255, 200, 87, 0.85));
  }
}

.ow-launcher-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  line-height: 1.15;
  text-align: left;
}
.ow-launcher-title {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.005em;
}
.ow-launcher-sub {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/*
 * Panel header — small star reuses the same icon, gives the open
 * panel the same brand mark as the closed launcher.
 */
.ow-panel-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.ow-panel-star {
  display: inline-grid;
  place-items: center;
  /* 22px so the concentric rings remain legible — at the 18px we
     used before, the outer ring crowded the title text. */
  width: 22px;
  height: 22px;
  color: #ffc857;
  filter: drop-shadow(0 0 4px rgba(255, 200, 87, 0.4));
}
.ow-panel-star svg { width: 100%; height: 100%; display: block; }
.ow-panel-status {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ok);
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--ok-faint);
  margin-left: 4px;
}

.ow-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9001;
  width: 420px;
  max-width: calc(100vw - 40px);
  height: min(640px, calc(100vh - 80px));
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-ui);
  color: var(--text);
}
.ow-panel.ow-open {
  display: flex;
  animation: ow-slide-in 200ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes ow-slide-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .ow-panel.ow-open { animation: none; }
}

.ow-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated-2);
  /* Header sticks to the panel width — never overflows. */
  min-width: 0;
}
.ow-panel-head .ow-panel-title {
  /* Title group can shrink ("ONLINE" pill collapses if needed)
     so the action group has room. */
  min-width: 0;
  overflow: hidden;
}
.ow-panel-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
}
.ow-panel-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  /* Critical: don't let the actions row push past the panel's
     right edge. min-width:0 lets children shrink; flex-shrink
     ensures the close button below stays pinned even if the
     voice picker has to give up space. */
  min-width: 0;
  flex: 0 1 auto;
}
.ow-close,
.ow-clear,
.ow-speaker {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  flex-shrink: 0;        /* never collapse — these are the always-visible controls */
}
/* The close ✕ in particular MUST always be reachable. Bump
   contrast slightly so it reads as an interactive control. */
.ow-close {
  color: var(--text);
  font-weight: 600;
}
.ow-clear { font-size: 15px; }
.ow-speaker { font-size: 14px; }
.ow-speaker.ow-active { color: var(--accent); }

/* Voice picker — small dropdown in the panel header. Width-capped so
   long voice names don't push the close button off-screen. The
   leading 🎙 in the option text makes the picker more discoverable
   in the corner. */
.ow-voice-picker {
  /* Voice name can be long ("Microsoft Sonia Online (Natural)…"),
     but we'd rather it ellipsis than shove the close button off
     the right edge. flex-shrink lets it give back space; min-width
     keeps it tappable. */
  flex: 0 1 140px;
  min-width: 60px;
  max-width: 160px;
  padding: 3px 8px 3px 22px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background:
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="%23ffc857"><path d="M8 1a3 3 0 0 0-3 3v4a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3zm5 7a5 5 0 0 1-10 0H1.5a6.5 6.5 0 0 0 5.75 6.46V15h1.5v-.54A6.5 6.5 0 0 0 14.5 8H13z"/></svg>') no-repeat 5px 50% / 12px,
    var(--bg-elevated-2);
  color: var(--text);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-overflow: ellipsis;
  margin-right: 4px;
  appearance: none;
  -webkit-appearance: none;
}
.ow-voice-picker:hover { border-color: var(--accent); }
.ow-voice-picker:focus { outline: 1px solid var(--accent); }
@media (max-width: 600px) {
  .ow-voice-picker { max-width: 120px; }
}
.ow-close:hover,
.ow-clear:hover,
.ow-speaker:hover { color: var(--text); background: var(--surface-hover); }

.ow-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ow-msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ow-msg.ow-user { align-items: flex-end; }
.ow-msg.ow-assistant { align-items: flex-start; }
.ow-msg.ow-error .ow-msg-bubble {
  background: var(--err-faint);
  color: var(--err);
  border-color: rgba(255, 77, 109, 0.3);
}

.ow-msg-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: normal;
}
.ow-user .ow-msg-bubble {
  background: var(--accent);
  color: #1a0e00;
  border-color: transparent;
  border-radius: 12px 12px 2px 12px;
}
.ow-assistant .ow-msg-bubble {
  border-radius: 12px 12px 12px 2px;
}
.ow-msg-bubble code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(255,255,255,0.06);
  padding: 1px 4px;
  border-radius: 4px;
}

.ow-typing {
  display: inline-flex;
  gap: 4px;
  padding: 10px 14px;
}
.ow-typing-dot {
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--text-dim);
  animation: ow-blink 1s infinite;
}
.ow-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ow-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes ow-blink {
  0%, 60%, 100% { opacity: 0.3; }
  30% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .ow-typing-dot { animation: none; opacity: 0.6; }
}

.ow-tool-calls {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
}
.ow-tool-chip {
  display: flex;
  flex-wrap: wrap;          /* description + Open pill wrap to a 2nd line if needed */
  gap: 4px 6px;             /* row-gap 4, col-gap 6 — tighter when stacked */
  align-items: center;
  padding: 4px 10px;
  border-radius: 12px;       /* less pill-y when content stacks */
  background: var(--accent-faint);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 12px;
  max-width: 100%;          /* fill the message bubble width before wrapping */
}
.ow-tool-chip.ow-error { background: var(--err-faint); }
.ow-tool-name { color: var(--accent); font-weight: 600; }
.ow-tool-sep { color: var(--text-faint); }
.ow-tool-result {
  color: var(--text-dim);
  /* Wrap onto multiple lines instead of ellipsing — the chip
     itself wraps so the Open pill drops onto the next row when
     the description is long. */
  white-space: normal;
  overflow-wrap: anywhere;
  flex: 1 1 auto;
  min-width: 0;
}
.ow-tool-open {
  flex-shrink: 0;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #1a0e00;
  background: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  transition: background 120ms ease;
}
.ow-tool-open:hover { background: var(--accent-hover); }

.ow-composer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated-2);
}
.ow-input {
  flex: 1;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 120ms ease;
}
.ow-input:focus { border-color: var(--accent); }
.ow-input:disabled { opacity: 0.6; cursor: not-allowed; }

.ow-mic, .ow-attach {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  font-size: 14px;
  transition: background 120ms ease, border-color 120ms ease;
}
.ow-mic:hover, .ow-attach:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}
.ow-mic.ow-active {
  background: var(--accent);
  color: #1a0e00;
  border-color: var(--accent);
  animation: ow-pulse 1s infinite;
}
@keyframes ow-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50%      { box-shadow: 0 0 0 6px transparent; }
}
.ow-file { display: none; }

.ow-send {
  background: var(--accent);
  color: #1a0e00;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background 120ms ease;
}
.ow-send:hover:not(:disabled) { background: var(--accent-hover); }
.ow-send:disabled { background: var(--text-faint); cursor: not-allowed; opacity: 0.7; }

@media (max-width: 600px) {
  .ow-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: auto;
    max-width: 100vw;
    height: 100vh;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
  /* On phones the launcher collapses to a circular FAB — text would
     crowd the corner. Star icon alone is enough recognition once the
     user knows what it is. */
  .ow-launcher {
    padding: 14px;
    border-radius: 999px;
    bottom: 18px;
    right: 18px;
  }
  .ow-launcher-text { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  /* Keep the look — strong layered glow — but stop it breathing. */
  .ow-launcher-star,
  .ow-launcher { animation: none; }
}

/* Print: hide the whole assistant. Operator reports are paper-bound,
   the chat surface has no place there. */
@media print {
  .ow-launcher, .ow-panel { display: none !important; }
}

/* ----- Maintenance deep-dive (search, calendar, photos, etc.) -------- */

/* Global maintenance search */
.maint-search-wrap { position: relative; }
.maint-search-input {
  width: 320px;
  max-width: 60vw;
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.18));
  border-radius: 6px;
  background: var(--surface, #fff);
}
.maint-search-results {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  width: 420px;
  max-width: 90vw;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.18));
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
  z-index: 50;
}
.search-hit {
  display: grid;
  grid-template-columns: 70px 1fr;
  grid-template-rows: auto auto;
  gap: 2px 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.06));
  text-decoration: none;
  color: inherit;
}
.search-hit:hover { background: var(--surface-hover, rgba(0, 0, 0, 0.03)); }
.search-hit:last-child { border-bottom: 0; }
.search-hit-kind {
  grid-row: 1 / 3;
  align-self: center;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 10px;
  text-align: center;
}
.search-hit-kind.kind-asset    { background: #e0e7ff; color: #3730a3; }
.search-hit-kind.kind-machine  { background: #fef3c7; color: #92400e; }
.search-hit-kind.kind-workorder{ background: #ddd6fe; color: #5b21b6; }
.search-hit-title { font-size: 14px; font-weight: 500; }
.search-hit-sub { font-size: 12px; }

/* ---- Calendar (month-at-a-time) ----------------------------------
   Replaced the original 12-month horizontal strip — it overflowed
   the page (~2400px wide) and the dot-only events made the operator
   click every day to find out what was due. New shape: one month
   filling the panel, with two visible event titles per day plus a
   "+N more" pill, and prev/next month nav in the panel header. */
.cal-panel { overflow: visible; }
.cal-header { flex-wrap: wrap; gap: 12px; }
.cal-legend { gap: 12px; }
.cal-month-big {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
}
.cal-dow-big {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim, #888);
  text-align: left;
  padding: 4px 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cal-day-big {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-height: 88px;
  padding: 6px 8px;
  /* Default cell = bright surface so future-date numbers are
     legible against it without any contrast tricks. Past cells
     dim themselves below. */
  background: var(--bg-elevated-2, #1c1d22);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  text-align: left;
  font: inherit;
  /* Force --text rather than `inherit` — buttons in some browsers
     fall back to ButtonText (system gray) which is what was making
     future-day numbers look dim against the dark surface. */
  color: var(--text);
  cursor: default;
  transition: border-color var(--t-fast, 120ms),
              background var(--t-fast, 120ms);
}
.cal-day-big.cal-day-empty { visibility: hidden; }
/* Past = dim (sunk into the panel), future = full brightness. The
   user explicitly asked to invert from the prior treatment — past
   should fade into the background, the days ahead should be the
   ones jumping out. */
.cal-day-big.cal-day-past {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.04);
}
.cal-day-big.cal-day-past .cal-day-big-num { color: var(--text-faint); }
.cal-day-big.cal-day-past .cal-day-big-event { opacity: 0.6; }
/* Today = accent ring + slight glow so it pops without redrawing
   the cell's surface. */
.cal-day-big.cal-day-today {
  border-color: var(--accent, #ff7a1a);
  box-shadow: 0 0 0 2px var(--accent, #ff7a1a),
              0 0 12px rgba(255, 122, 26, 0.35);
}
.cal-day-big.cal-day-today .cal-day-big-num {
  color: var(--accent, #ff7a1a);
  font-weight: 700;
}
.cal-day-big.cal-day-has-events { cursor: pointer; }
.cal-day-big.cal-day-has-events:hover {
  border-color: var(--accent, #ff7a1a);
}
.cal-day-big-num {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.cal-day-big-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.cal-day-big-event {
  display: block;
  font-size: 11px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #1a1a1a;
  border-left: 3px solid transparent;
}
.cal-evt-wo       { background: #c7d2fe; border-left-color: #4338ca; }
.cal-evt-pm       { background: #a7f3d0; border-left-color: #047857; }
.cal-evt-urgent   { background: #fde68a; border-left-color: #b45309; }
.cal-evt-overdue  { background: #fecaca; border-left-color: #b91c1c; }
.cal-day-big-more { font-size: 10px; padding: 0 4px; }

/* Day-detail panel — renders inline below the calendar grid when an
   operator clicks a day. Replaces the old position:fixed drawer
   that floated outside the page footprint. */
.cal-day-inline {
  margin-top: 14px;
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  padding-top: 12px;
}
.cal-day-inline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.cal-day-inline-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cal-day-event {
  display: grid;
  grid-template-columns: 40px 1fr auto auto;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
  background: var(--bg-elevated, transparent);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.06));
}
.cal-day-event:hover {
  border-color: var(--accent, #4a90e2);
  background: var(--bg-elevated-2, var(--bg-elevated, #1c1d22));
}
.cal-day-event-kind {
  grid-row: 1 / 3;
  align-self: center;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  padding: 4px;
  border-radius: 6px;
}
.cal-day-event-kind.kind-wo { background: #c7d2fe; color: #3730a3; }
.cal-day-event-kind.kind-pm { background: #a7f3d0; color: #065f46; }
.cal-day-event-title {
  grid-column: 2;
  font-size: 14px;
  font-weight: 600;
}
.cal-day-event-meta {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
}
.cal-day-event-arrow {
  grid-row: 1 / 3;
  font-size: 22px;
  font-weight: 300;
  padding-right: 4px;
}

/* Legend dots — kept as small swatches for the panel-header legend. */
.cal-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}
.cal-dot-overdue { background: #ef4444; }
.cal-dot-urgent  { background: #f59e0b; }
.cal-dot-wo      { background: #4338ca; }
.cal-dot-pm      { background: #047857; }

/* Tighter day cells on phones — keep all 7 columns visible by
   trading vertical room for horizontal compactness. */
@media (max-width: 720px) {
  .cal-day-big { min-height: 60px; padding: 4px 5px; }
  .cal-day-big-event { font-size: 10px; padding: 0 4px; }
  .cal-dow-big { font-size: 10px; padding: 2px 4px; }
}

/* Asset hero — QR right next to photo */
.asset-hero-photos {
  display: flex;
  gap: 10px;
  flex: 0 0 auto;
}
.asset-hero-qr {
  flex: 0 0 auto;
  width: 110px;
  height: 110px;
  border-radius: 6px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.18));
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: inherit;
  transition: border-color 80ms ease;
  padding: 6px;
}
.asset-hero-qr:hover { border-color: var(--accent, #4a90e2); }
.asset-hero-qr img {
  max-width: 100%;
  max-height: 80px;
  display: block;
}
.asset-qr-placeholder {
  font-weight: 700;
  font-size: 28px;
  color: var(--ink-muted, #888);
}
.asset-qr-caption {
  margin-top: 4px;
  font-size: 10px;
  text-align: center;
}
@media (max-width: 480px) {
  .asset-hero-photos {
    flex: 0 0 100%;
    flex-direction: column;
  }
  .asset-hero-photo, .asset-hero-qr { width: 100%; }
  .asset-hero-photo { height: 200px; }
  .asset-hero-qr { width: 140px; height: 140px; align-self: center; }
}

/* Photo gallery on WO detail */
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.photo-tile {
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface, #fff);
}
.photo-tile img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
}
.photo-meta {
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.photo-cat {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 6px;
}
.photo-cat-before   { background: #fef3c7; color: #92400e; }
.photo-cat-after    { background: #d1fae5; color: #065f46; }
.photo-cat-progress { background: #e0e7ff; color: #3730a3; }

/* Activity feed */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-left: 2px solid var(--border, rgba(0, 0, 0, 0.08));
  padding-left: 12px;
  margin-bottom: 8px;
}
.activity-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 6px;
  padding: 4px 0;
  font-size: 12px;
  align-items: baseline;
}
.activity-icon { font-size: 14px; }
.activity-text code {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  background: var(--surface-hover, rgba(0, 0, 0, 0.05));
  padding: 1px 4px;
  border-radius: 3px;
}

/* Checklist */
.checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.06));
  font-size: 13px;
  cursor: pointer;
}
.checklist-item:last-child { border-bottom: 0; }
.checklist-item.checked .checklist-text {
  text-decoration: line-through;
  color: var(--ink-muted, #888);
}

/* Asset reliability stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}
.stat-cell {
  background: var(--surface-hover, rgba(0, 0, 0, 0.03));
  border-radius: 6px;
  padding: 10px 12px;
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-muted, #888);
}
.stat-value {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  margin-top: 2px;
}
.stat-sub {
  font-size: 11px;
  margin-top: 2px;
}

/* Failure-mode horizontal bars */
.failure-row {
  display: grid;
  grid-template-columns: 140px 1fr 40px;
  gap: 8px;
  align-items: center;
  margin: 4px 0;
  font-size: 12px;
}
.failure-code {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
}
.failure-bar-wrap {
  background: var(--surface-hover, rgba(0, 0, 0, 0.05));
  border-radius: 8px;
  height: 10px;
  overflow: hidden;
}
.failure-bar {
  height: 100%;
  background: #4a90e2;
  border-radius: 8px;
  transition: width 200ms ease;
}
.failure-count { text-align: right; }

/* ---- Orion Admin god view (admin.orionwcs.com) -------------------- */

.orion-cust-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}
.orion-cust-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  border-radius: 8px;
  background: var(--surface, #fff);
  color: inherit;
  text-decoration: none;
  transition: border-color 80ms ease, transform 80ms ease;
}
.orion-cust-card:hover {
  border-color: var(--accent, #4a90e2);
  transform: translateY(-1px);
}
.orion-cust-card-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.orion-cust-name { font-weight: 600; font-size: 16px; }
.orion-cust-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 8px;
}
.orion-cust-stat {
  display: flex;
  flex-direction: column;
  padding: 6px 8px;
  background: var(--surface-hover, rgba(0, 0, 0, 0.03));
  border-radius: 4px;
}
.orion-cust-stat-value { font-size: 18px; font-weight: 700; }
.orion-cust-stat-label { font-size: 10px; }
.orion-cust-features {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.orion-feat-chip {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  background: #e0e7ff;
  color: #3730a3;
  border-radius: 8px;
}

.orion-feature-list { display: flex; flex-direction: column; gap: 8px; }
.orion-feature-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  border-radius: 6px;
  background: var(--surface, #fff);
}
.orion-feature-meta { flex: 1 1 auto; min-width: 0; }
.orion-feature-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.orion-feature-desc { font-size: 12px; line-height: 1.4; }
.orion-feature-state { margin-top: 4px; font-size: 11px; }
.orion-feature-toggle {
  flex: 0 0 auto;
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.orion-feature-toggle input { opacity: 0; width: 0; height: 0; }
.orion-feature-toggle span {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: #cbd5e1;
  border-radius: 12px;
  transition: background 120ms ease;
}
.orion-feature-toggle span::before {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 120ms ease;
}
.orion-feature-toggle input:checked + span { background: var(--accent, #4a90e2); }
.orion-feature-toggle input:checked + span::before { transform: translateX(20px); }
.orion-feature-toggle input:disabled + span { opacity: 0.5; cursor: not-allowed; }

/* ---- Orion-staff impersonation banner ----------------------------
   Sits above the page header on every customer-subdomain page when an
   active "act as" session is in flight. Yellow background = "this is
   not your real session". Sticky so scrolling doesn't lose it. */
.orion-imp-banner {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: #fbbf24;
  color: #422006;
  border-bottom: 2px solid #d97706;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
.orion-imp-banner .mono { color: #1a1a1a; }
.orion-imp-banner strong { font-weight: 700; }
.orion-imp-banner .btn {
  background: #422006;
  color: #fbbf24;
  border-color: #422006;
}
.orion-imp-banner .btn:hover {
  background: #2a1404;
  color: #fff;
}

/* ---- Sites grid (maintenance home) -------------------------------
   Richer tile than the generic .maint-tile — has a hero photo at
   the top, the site name + address below, and counts at the foot.
   Tiles stay roughly square so a row of varying-length names lines
   up. Inherits the card surface so text styles match the rest of
   the app (no white-on-white footguns). */
.maint-sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.maint-site-tile {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: transform var(--t-fast), border-color var(--t-fast),
              box-shadow var(--t-fast);
}
.maint-site-tile:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-card);
}
.maint-site-tile-photo {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
  background: var(--bg-elevated);
}
.maint-site-tile-photo.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--text-faint);
}
.maint-site-tile-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.maint-site-tile-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}
.maint-site-tile-addr { line-height: 1.35; }
.maint-site-tile-counts { margin-top: 2px; }

/* Platform-wide KPI strip on the orion dashboard. */
.orion-kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}
.orion-kpi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--surface-hover, rgba(0, 0, 0, 0.03));
  border-radius: 6px;
}
.orion-kpi-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
}
.orion-kpi-label { line-height: 1.2; }

/* Fleet insights table (admin.orionwcs.com/admin/fleet). */
.orion-fleet-table-wrap { overflow-x: auto; }
.orion-fleet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.orion-fleet-table th,
.orion-fleet-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  vertical-align: top;
  text-align: left;
}
.orion-fleet-table th {
  font-weight: 600;
  color: var(--muted, #64748b);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.orion-fleet-table th.num,
.orion-fleet-table td.num { text-align: right; white-space: nowrap; }
.orion-fleet-table tbody tr:hover {
  background: var(--surface-hover, rgba(0, 0, 0, 0.03));
}
.orion-fleet-sites-strong {
  font-weight: 700;
  color: var(--accent, #4a90e2);
}
.orion-fc-cell { max-width: 320px; }
.orion-fc-chip {
  display: inline-block;
  padding: 1px 8px;
  margin: 1px 2px;
  background: #fef3c7;
  color: #92400e;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* Raise-issue form polish — matches the rest of the platform's
   panel styling rather than relying on browser defaults. */
.raise-issue-panel { border-left: 4px solid #f59e0b; }
.raise-issue-context {
  padding: 8px 12px;
  background: var(--surface-hover, rgba(0, 0, 0, 0.03));
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: 13px;
}
.raise-issue-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.raise-issue-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.raise-issue-input,
.raise-issue-textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.18));
  border-radius: 6px;
  background: var(--surface, #fff);
  color: var(--ink, #222);
  box-sizing: border-box;
  transition: border-color 80ms ease, box-shadow 80ms ease;
}
.raise-issue-input:focus,
.raise-issue-textarea:focus {
  outline: none;
  border-color: var(--accent, #4a90e2);
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.15);
}
.raise-issue-textarea {
  resize: vertical;
  min-height: 80px;
}

/* Priority pills — colored, click-to-select. Replaces the native
   <select> which felt out of place against the rest of the UI. */
.priority-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.priority-pill {
  appearance: none;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.18));
  background: var(--surface, #fff);
  color: var(--ink, #222);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 14px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 80ms ease;
}
.priority-pill:hover { background: var(--surface-hover, rgba(0, 0, 0, 0.04)); }
.priority-pill.active { box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.18); }
/* Active colour scheme matches the wo-priority-pill palette so the
   form, kanban, and lists tell the same colour story. */
.priority-pill[data-priority="low"].active {
  background: #f3f4f6; color: #4b5563; border-color: #4b5563;
}
.priority-pill[data-priority="medium"].active {
  background: #e0e7ff; color: #3730a3; border-color: #3730a3;
}
.priority-pill[data-priority="high"].active {
  background: #fef3c7; color: #92400e; border-color: #92400e;
}
.priority-pill[data-priority="urgent"].active {
  background: #fee2e2; color: #991b1b; border-color: #991b1b;
}

/* Due-by row: native datetime input + small quick-set chips. */
.raise-issue-due-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.raise-issue-due-input {
  width: auto;
  min-width: 220px;
  flex: 0 0 auto;
}
.due-quicks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.due-quick {
  appearance: none;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.18));
  background: var(--surface, #fff);
  color: var(--ink-muted, #555);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 80ms ease;
}
.due-quick:hover {
  background: var(--accent, #4a90e2);
  color: #fff;
  border-color: var(--accent, #4a90e2);
}
.due-quick-clear { color: var(--ink-muted, #888); font-style: italic; }
.due-quick-clear:hover {
  background: var(--surface-hover, rgba(0, 0, 0, 0.06));
  color: var(--ink, #222);
  border-color: var(--border, rgba(0, 0, 0, 0.18));
}

.raise-issue-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border, rgba(0, 0, 0, 0.06));
}

/* Asset photo dropzone — clickable when admin/engineer */
.asset-hero-photo {
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.asset-hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.asset-photo-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  text-align: center;
  padding: 3px 0;
  opacity: 0;
  transition: opacity 80ms ease;
}
.asset-hero-photo:hover .asset-photo-overlay { opacity: 1; }

/* Compatible-spares row on asset page */
.asset-part-row {
  display: grid;
  grid-template-columns: 100px 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.06));
  font-size: 13px;
}
.asset-part-row:last-child { border-bottom: 0; }
.asset-part-row.low { background: rgba(254, 226, 226, 0.3); }
.asset-part-name { font-weight: 500; }

/* Parts inventory */
.row-low-stock {
  background: rgba(254, 226, 226, 0.4);
}
.part-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  display: block;
}
.part-thumb-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 4px;
  background: var(--surface-hover, rgba(0, 0, 0, 0.04));
  border: 1px dashed var(--border, rgba(0, 0, 0, 0.18));
  color: var(--ink-muted, #888);
  font-size: 18px;
}

/* Tight click-to-expand row */
.part-row {
  cursor: pointer;
  transition: background 80ms ease;
}
.part-row:hover { background: var(--surface-hover, rgba(0, 0, 0, 0.04)); }
.part-row.expanded { background: var(--surface-hover, rgba(0, 0, 0, 0.06)); }
.part-row-name { font-weight: 500; }
.part-row-icon {
  margin-left: 6px;
  font-size: 12px;
  opacity: 0.7;
}
.part-row-chevron {
  text-align: right;
  font-size: 18px;
  transition: transform 120ms ease;
}
.part-row.expanded .part-row-chevron {
  transform: rotate(90deg);
  display: inline-block;
}

/* Inline editor expansion */
.part-row-expand > td {
  background: var(--surface-hover, rgba(0, 0, 0, 0.03));
  padding: 14px 16px;
}
.part-editor {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 18px;
  align-items: start;
}
@media (max-width: 720px) {
  .part-editor { grid-template-columns: 1fr; }
}
.part-editor-photo-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.part-editor-photo-wrap {
  position: relative;
  display: block;
  cursor: pointer;
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface, #fff);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
}
.part-edit-photo {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}
.part-edit-photo.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted, #aaa);
  font-size: 32px;
  gap: 6px;
}
.part-edit-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 4px;
  text-align: center;
  font-size: 11px;
  color: #fff;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 80ms ease;
}
.part-editor-photo-wrap:hover .part-edit-overlay { opacity: 1; }
.part-edit-photo.placeholder + .part-edit-overlay {
  opacity: 1;
  background: rgba(0, 0, 0, 0.35);
}
.part-editor-datasheet {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
}

.part-editor-fields { min-width: 0; }
.part-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.part-editor-grid label,
.part-editor-fields label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
}
.part-editor-grid input,
.part-editor-fields textarea,
.part-editor-fields input,
.part-editor-fields select {
  font-size: 13px;
  padding: 5px 8px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.18));
  border-radius: 4px;
  background: var(--surface, #fff);
  font-family: inherit;
}
.part-editor-grid input:disabled,
.part-editor-fields textarea:disabled,
.part-editor-fields input:disabled {
  background: var(--surface-hover, rgba(0, 0, 0, 0.04));
  color: var(--ink-muted, #888);
  cursor: not-allowed;
}
.part-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border, rgba(0, 0, 0, 0.06));
  font-size: 12px;
}
.part-editor-divider {
  color: var(--ink-muted, #aaa);
  margin: 0 4px;
}
.part-status.err { color: #f87171; }

/* Stock-adjust panel — visually distinct from the field editor so
   it's obvious that "Save details" doesn't touch stock and "Apply
   stock change" is a separate action. */
.part-stock-block {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--bg-elevated-2, #1c1d22);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.12));
  border-radius: 6px;
}
.part-stock-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.part-stock-quick {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.part-stock-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.part-stock-row .part-restock-delta { flex: 1 1 220px; min-width: 180px; }
.part-stock-row .part-restock-reason { flex: 0 1 240px; min-width: 200px; }
.part-stock-current { font-size: 14px; font-weight: 600; color: var(--text); }

/* Delete part — pushed to its own row, ghost-styled, tinted red on
   hover so accidental clicks are unlikely. */
.part-danger-row {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--border, rgba(255, 255, 255, 0.08));
  text-align: right;
}
.part-danger-row .part-delete:hover {
  border-color: #b91c1c;
  color: #fca5a5;
}
.badge-warn {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  background: #fee2e2;
  color: #991b1b;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 6px;
}

/* Asset criticality colour borders on tiles */
.maint-tile[data-criticality="critical"] { border-left: 4px solid #ef4444; }
.maint-tile[data-criticality="high"]     { border-left: 4px solid #f59e0b; }
.maint-tile[data-criticality="medium"]   { border-left: 4px solid #4a90e2; }
.maint-tile[data-criticality="low"]      { border-left: 4px solid #94a3b8; }

/* Print stylesheet — clean WO printout for paper sites */
@media print {
  .page-header, .ow-launcher, .ow-panel,
  .wo-actions, #btn-print-wo,
  #comment-form, .activity-feed,
  #photo-input, .panel-header .btn,
  .maint-search-wrap {
    display: none !important;
  }
  .panel {
    border: 1px solid #ccc !important;
    page-break-inside: avoid;
  }
  body { background: #fff !important; color: #000 !important; }
}

/* ----- Maintenance / CMMS module (Phases A + B + C) ---------------- */
/* KPI variants for the planner dashboard */
.kpi-card.kpi-warn-active { border-left: 4px solid #f59e0b; }
.kpi-card.kpi-critical-active { border-left: 4px solid #ef4444; }
.kpi-card.kpi-warn { border-left: 4px solid #f59e0b; }

/* Planner three-column responsive grid for Today / Upcoming / Recent */
.planner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

/* Work-order row — used in lists, kanban cards, asset history */
.wo-row {
  display: block;
  padding: 10px 12px;
  margin-bottom: 6px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  border-radius: 6px;
  background: var(--surface, #fff);
  color: inherit;
  text-decoration: none;
  transition: border-color 80ms ease, background 80ms ease;
}
.wo-row:hover {
  border-color: var(--accent, #4a90e2);
  background: var(--surface-hover, rgba(0, 0, 0, 0.03));
}
/* Priority left-border tint — urgent jumps out, low fades into the
   list. Matches the colour palette of the priority pills. */
.wo-row[data-priority="urgent"] { border-left: 4px solid #ef4444; }
.wo-row[data-priority="high"]   { border-left: 4px solid #f59e0b; }
.wo-row[data-priority="medium"] { border-left: 4px solid transparent; }
.wo-row[data-priority="low"]    { border-left: 4px solid transparent; opacity: 0.85; }
.wo-row-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.wo-row-title {
  font-size: 14px;
  font-weight: 500;
}
.wo-row-sub {
  margin-top: 2px;
}
.wo-number {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-muted, #666);
}
.wo-overdue {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #b91c1c;
  background: #fee2e2;
  padding: 1px 6px;
  border-radius: 8px;
}

/* Status / priority pills — Fiix-style colour coding */
.wo-status-pill, .wo-priority-pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1px 8px;
  border-radius: 10px;
}
.wo-status-open       { background: #e0e7ff; color: #3730a3; }
.wo-status-assigned   { background: #fef3c7; color: #92400e; }
.wo-status-in_progress{ background: #ddd6fe; color: #5b21b6; }
.wo-status-completed  { background: #dcfce7; color: #166534; }
.wo-status-cancelled  { background: #f3f4f6; color: #4b5563; }
.wo-status-scheduled  { background: #ecfeff; color: #155e75; }

.wo-priority-low      { background: #f3f4f6; color: #4b5563; }
.wo-priority-medium   { background: #e0e7ff; color: #3730a3; }
.wo-priority-high     { background: #fef3c7; color: #92400e; }
.wo-priority-urgent   { background: #fee2e2; color: #991b1b; }

/* Kanban */
.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 12px;
  overflow-x: auto;
}
.kanban-col {
  background: var(--surface-hover, rgba(0, 0, 0, 0.03));
  border-radius: 8px;
  padding: 10px;
  min-height: 240px;
}
.kanban-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  padding: 0 4px;
}
.kanban-col-count {
  font-size: 11px;
  color: var(--ink-muted, #888);
  background: var(--surface, #fff);
  border-radius: 10px;
  padding: 1px 8px;
}
.kanban-col-body .wo-row {
  margin-bottom: 8px;
}
/* Drag-and-drop reclassify (kanban only). The card lifts and fades
   while held; the destination column highlights a dashed border so
   the operator knows it's accepting the drop. Illegal targets get
   no feedback (the JS doesn't preventDefault), so the browser shows
   the "no drop" cursor naturally. */
.kanban-col-body .wo-row[draggable="true"] { cursor: grab; }
.kanban-col-body .wo-row.dragging {
  opacity: 0.45;
  cursor: grabbing;
  transform: scale(0.98);
}
.kanban-col.drop-target {
  outline: 2px dashed var(--accent, #4a90e2);
  outline-offset: -4px;
  background: var(--accent-faint, rgba(74, 144, 226, 0.08));
}
@media (max-width: 768px) {
  .kanban {
    grid-template-columns: 1fr;
  }
}

/* Asset hero — actions column added in Phase B */
.asset-hero-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-self: flex-start;
}

/* Asset doc rows */
.asset-doc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.06));
  font-size: 13px;
}
.asset-doc-row:last-child { border-bottom: 0; }
.asset-doc-title { flex: 1 1 auto; }

/* PM rows */
.pm-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.06));
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.pm-row:last-child { border-bottom: 0; }
.pm-row-summary { flex: 1 1 auto; min-width: 0; }
.pm-row-name { font-weight: 500; }
.pm-edit-btn { flex: 0 0 auto; }
.pm-edit-form {
  background: var(--bg-elevated-2, #1c1d22);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.12));
  border-radius: 6px;
  padding: 10px 12px;
}

/* Work-order detail page */
.wo-detail .wo-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.wo-detail .wo-number-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.wo-detail h1 { margin: 0 0 4px; }
.wo-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Comment thread */
.comments-list { display: flex; flex-direction: column; gap: 12px; }
.comment {
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--surface-hover, rgba(0, 0, 0, 0.03));
}
.comment-meta { margin-bottom: 4px; }
.comment-body { font-size: 13px; line-height: 1.5; }

/* ----- Maintenance / CMMS module (Phase A) -------------------------- */
.maint-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  border-radius: 8px;
  background: var(--surface, #fff);
  color: inherit;
  text-decoration: none;
  position: relative;
  transition: border-color 80ms ease, background 80ms ease;
}
.maint-tile:hover {
  border-color: var(--accent, #4a90e2);
  background: var(--surface-hover, rgba(0, 0, 0, 0.03));
}
.maint-tile-title {
  font-weight: 600;
  font-size: 15px;
}
.maint-tile-sub {
  font-size: 12px;
}
.maint-tile-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
  background: #fef3c7;
  color: #92400e;
}

/* Asset detail hero — mobile-first; the QR-scan landing page must be
   readable on a 4-inch phone in poor warehouse lighting. */
.asset-hero {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.asset-hero-photo {
  flex: 0 0 160px;
  width: 160px;
  height: 160px;
  border-radius: 8px;
  background: var(--surface-hover, rgba(0, 0, 0, 0.05));
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.asset-photo-placeholder {
  font-size: 48px;
  opacity: 0.35;
}
.asset-hero-meta {
  flex: 1 1 240px;
  min-width: 0;
}
.asset-hero-meta h1 {
  margin: 0;
  word-break: break-word;
}
.asset-meta-row {
  margin-top: 4px;
  font-size: 13px;
}
.asset-dl {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 16px;
  margin: 0;
}
.asset-dl dt {
  color: var(--ink-muted, #888);
  font-size: 12px;
  align-self: center;
}
.asset-dl dd {
  margin: 0;
  font-size: 13px;
  word-break: break-word;
}
@media (max-width: 480px) {
  .asset-hero-photo {
    flex: 0 0 100%;
    width: 100%;
    height: 200px;
  }
  .asset-dl {
    grid-template-columns: 110px 1fr;
  }
}

/* ----- /admin/kb (Stage 4 admin page) ------------------------------- */
.kb-tier {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.kb-tier-generic        { background: #e6f0ff; color: #1e40af; }
.kb-tier-shared_curated { background: #ecfdf5; color: #047857; }
.kb-tier-customer_private { background: #fef3c7; color: #92400e; }
.kb-admin-page textarea {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.18));
  border-radius: 4px;
  resize: vertical;
}
.kb-admin-page input[type="text"],
.kb-admin-page select {
  width: 100%;
}

/* ----- Source pills (Stage 3 RAG attribution) -----------------------
   Sit between the assistant bubble and the feedback row. Distinct
   from the tool-call chips: those describe what the assistant DID;
   sources describe what it KNEW going in. */
.ow-sources {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding-left: 4px;
  font-size: 12px;
}
.ow-sources-label {
  color: var(--ink-muted, #888);
  font-size: 12px;
}
.ow-source-pill {
  background: var(--surface-hover, rgba(0, 0, 0, 0.04));
  color: var(--ink, #222);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.12));
  border-radius: 12px;
  padding: 2px 10px;
  font-size: 11px;
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----- Feedback row (Stage 2c) ----------------------------------------
   Sits under each assistant bubble. Subtle by default — operators
   shouldn't feel pressured to rate every reply — but readable on
   hover so the path to "👎 + comment" is one-click obvious when the
   answer was wrong. */
.ow-feedback {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding-left: 4px;
  font-size: 12px;
  color: var(--ink-muted, #888);
  min-height: 22px;
}
.ow-feedback-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0.55;
  transition: opacity 80ms ease, border-color 80ms ease, background 80ms ease;
}
.ow-feedback-btn:hover {
  opacity: 1;
  background: var(--surface-hover, rgba(0, 0, 0, 0.04));
  border-color: var(--border, rgba(0, 0, 0, 0.12));
}
.ow-feedback-btn:focus-visible {
  outline: 2px solid var(--accent, #4a90e2);
  outline-offset: 1px;
  opacity: 1;
}
.ow-feedback-comment {
  flex: 1 1 auto;
  min-width: 120px;
  padding: 4px 8px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.18));
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  background: var(--surface, #fff);
  color: var(--ink, #222);
}
.ow-feedback-comment-send,
.ow-feedback-comment-skip {
  border: 1px solid var(--border, rgba(0, 0, 0, 0.18));
  background: var(--surface, #fff);
  color: var(--ink, #222);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
}
.ow-feedback-comment-send {
  background: var(--accent, #4a90e2);
  color: #fff;
  border-color: var(--accent, #4a90e2);
}
.ow-feedback-status {
  font-size: 12px;
  color: var(--ink-muted, #888);
  font-style: italic;
}
/* "this fixed it" reads more like a positive action than a binary
   thumb — give it a distinct, slightly emphasised look so operators
   notice it as the data-flywheel button. */
.ow-feedback-fixed {
  font-size: 11px;
  padding: 3px 8px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.18));
  background: var(--surface, #fff);
  color: var(--ink, #222);
  border-radius: 12px;
  margin-left: 8px;
  opacity: 0.7;
}
.ow-feedback-fixed:hover {
  background: #ecfdf5;
  color: #047857;
  border-color: #047857;
  opacity: 1;
}
