/* ==================== RESET & BASE ==================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-surface: #252540;
  --bg-hover: #2d2d4a;
  --bg-card: #fffdf5;
  --text: #f0e6d0;
  --text-primary: #f0e6d0;
  --text-secondary: #a89f91;
  --text-muted: #a89f91;
  --text-dark: #2d2d2d;
  --accent: #e8a838;
  --accent-bright: #f5bd54;
  --accent-dim: #b8862a;
  --accent-glow: rgba(232, 168, 56, 0.3);
  --accent-grad: linear-gradient(135deg, #f5bd54 0%, #e8a838 100%);
  --border: #3d3d5c;
  --border-soft: rgba(255, 255, 255, 0.07);
  --danger: #ef4444;
  --danger-glow: rgba(239, 68, 68, 0.4);
  --red: #ef4444;
  --success: #4ade80;
  --warning: #facc15;
  --yellow: #facc15;
  /* Cleaner mono stack — keeps the kitchen-ticket feel, drops dated Courier */
  --font: 'SF Mono', 'JetBrains Mono', 'Menlo', 'Consolas', 'Courier New', monospace;
  --turbo: #00c8ff;
  --turbo-glow: rgba(0, 200, 255, 0.3);
  --turbo-oncard: #0e7490; /* brand cyan darkened for ≥4.5:1 on the light --bg-card */
  --radius-lg: 16px;
  --radius: 11px;
  --radius-sm: 7px;

  /* Spacing scale — use these instead of ad-hoc rem values */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.5);

  /* ==================== TOKEN FOUNDATION (Phase 1) ==================== */
  /* Mantine-style spacing scale, 4px base — not yet wired into existing
     rules; adopt incrementally in later phases. */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;

  /* Type scale — larger sizes use clamp() for fluid sizing between
     phone and desktop viewports. */
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: clamp(1.125rem, 1.05rem + 0.35vw, 1.25rem);
  --fs-xl: clamp(1.375rem, 1.2rem + 0.75vw, 1.75rem);
  --fs-2xl: clamp(1.75rem, 1.4rem + 1.5vw, 2.5rem);

  /* Stacking order */
  --z-header: 100;
  --z-dropdown: 200;
  --z-modal: 300;
  --z-toast: 400;

  /* Icon sizes */
  --icon-sm: 16px;
  --icon-md: 20px;
  --icon-lg: 24px;

  /* Shared focus indicator (WCAG 2.2 2.4.11/2.4.13) */
  --focus-ring: 0 0 0 3px rgba(232, 168, 56, 0.5), 0 0 0 1px var(--accent);

  /* Phase 4 contrast audit: flag colors darkened for use as TEXT/borders on
     the light --bg-card surface (order cards). The base --success/--warning/
     --danger/purple tokens stay as-is for dark-surface use (header, modals,
     alerts bar) where they already clear 4.5:1+. */
  --success-oncard: #15803d;
  --warning-oncard: #92400e;
  --danger-oncard: #b91c1c;
  --purple-oncard: #7c3aed;
}

html {
  font-size: 15px;
}

/* ==================== ACCESSIBILITY (Phase 4: WCAG 2.2 AA) ==================== */

/* Skip link — first focusable element on the page; hidden until focused. */
.skip-link {
  position: absolute;
  top: -999px;
  left: 0;
  /* Intentionally above the --z-toast(400)/--z-modal(300) scale — the skip
     link and the full-page lock-screen gate (below) are top-layer sentinels,
     not part of the header/dropdown/modal/toast stack. */
  z-index: 1000;
  background: var(--accent);
  color: #1a1200;
  font-family: var(--font);
  font-weight: bold;
  font-size: var(--fs-sm);
  padding: var(--space-sm) var(--space-lg);
  border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
  top: 0;
  left: 0;
}

/* Shared focus-visible ring (2.4.11 Focus Not Obscured / 2.4.13 Focus
   Appearance) — every interactive element gets the same, clearly visible
   indicator instead of a per-component one. scroll-margin-top keeps the
   sticky header (and the phone sticky alerts bar) from covering whatever
   just received focus. */
a,
button,
input,
select,
textarea,
[tabindex],
summary,
[role="menuitem"],
[role="button"] {
  scroll-margin-top: calc(var(--header-h, 56px) + var(--space-sm));
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
summary:focus-visible,
[role="menuitem"]:focus-visible,
[role="button"]:focus-visible,
.order-card:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: var(--radius-sm);
}

/* Target size (2.5.8): buttons, chips, and menu items get a 24×24 CSS px
   minimum hit area. Padding is used where a component's content is smaller
   than that so the dense desktop layout doesn't have to change visually. */
button,
.btn,
[role="menuitem"],
.concern-chip,
.shift-day-btn,
.flag-ack-btn,
.alert-ack-confirm,
.alert-ack-btn {
  min-height: 24px;
  min-width: 24px;
}

@media (max-width: 600px), (pointer: coarse) {
  button,
  .btn,
  [role="menuitem"],
  .concern-chip,
  .shift-day-btn {
    min-height: 28px;
    min-width: 28px;
  }
}

/* Reduced motion — disable non-essential animation/transition for users who
   ask for it, without having to touch every keyframe/transition rule. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==================== ICON SYSTEM ==================== */
.icon { display: inline-block; vertical-align: -0.15em; fill: currentColor; flex-shrink: 0; }
.icon--sm { width: var(--icon-sm); height: var(--icon-sm); }
.icon--md { width: var(--icon-md); height: var(--icon-md); }
.icon--lg { width: var(--icon-lg); height: var(--icon-lg); }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(232, 168, 56, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(239, 68, 68, 0.02) 0%, transparent 50%);
}

/* ==================== HEADER ==================== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: var(--bg-secondary);
  border-bottom: 2px solid var(--accent-dim);
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.logo {
  font-size: 1.4rem;
  font-weight: bold;
  color: var(--accent);
  letter-spacing: 1px;
}

.logo-icon {
  margin-right: 0.25rem;
}

.subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Header overflow menu — hidden on desktop/tablet; only surfaces at ≤600px
   where the secondary icon buttons are collapsed into it (see phone block). */
.header-overflow {
  position: relative;
  display: none;
}

.header-overflow-menu {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-xs));
  z-index: var(--z-dropdown);
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xs);
}

.header-overflow-menu[hidden] {
  display: none;
}

.header-overflow-menu button {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--text-primary);
  padding: var(--space-sm);
  min-height: 24px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.header-overflow-menu button:hover,
.header-overflow-menu button:focus-visible {
  background: var(--bg-hover);
}

.burn-setting {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--bg-surface);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
}

.burn-setting input {
  width: 48px;
  padding: 0.2rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.75rem;
  text-align: center;
}

.burn-setting input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
}

.burn-unit {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* ==================== SHIFT WIDGET ==================== */
.shift-widget {
  position: relative;
}

.btn-shift-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.75rem;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-shift-status:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

.btn-shift-status.closed {
  border-color: rgba(239, 68, 68, 0.5);
  color: var(--danger);
}

.shift-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  transition: background 0.3s;
}

.btn-shift-status.closed .shift-status-dot {
  background: var(--danger);
  animation: shift-dot-pulse 2s ease-in-out infinite;
}

@keyframes shift-dot-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

.shift-schedule-preview {
  font-size: 0.65rem;
  color: var(--text-secondary);
  opacity: 0.75;
  font-style: italic;
}

.shift-caret {
  font-size: 0.55rem;
  opacity: 0.5;
  transition: transform 0.15s;
}

.shift-widget.popover-open .shift-caret {
  transform: rotate(180deg);
}

/* --- Popover panel --- */
.shift-popover {
  display: none;
  flex-direction: column;
  gap: 0.6rem;
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: var(--z-dropdown);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  min-width: 270px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  animation: slide-up 0.15s ease;
}

.shift-popover.open {
  display: flex;
}

.shift-popover-title {
  font-size: 0.72rem;
  font-weight: bold;
  color: var(--text-primary);
  letter-spacing: 0.5px;
  margin-bottom: 0.1rem;
}

.shift-popover-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.shift-popover-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.shift-time-group {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.shift-popover input[type="time"] {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.78rem;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
  width: 96px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.shift-popover input[type="time"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
}

.shift-clear-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.6rem;
  padding: 0.2rem 0.3rem;
  border-radius: 3px;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
}

.shift-clear-btn:hover {
  opacity: 1;
  color: var(--danger);
}

#shift-timezone {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.72rem;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}

#shift-timezone:focus {
  outline: none;
  border-color: var(--accent);
}

.shift-popover-divider {
  height: 1px;
  background: var(--border);
  margin: 0.15rem 0;
}

.btn-shift-manual {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.78rem;
  padding: 0.45rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: center;
}

.btn-shift-manual.action-close {
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--danger);
}

.btn-shift-manual.action-close:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--danger);
}

.btn-shift-manual.action-open {
  border-color: rgba(74, 222, 128, 0.35);
  color: var(--success);
}

.btn-shift-manual.action-open:hover {
  background: rgba(74, 222, 128, 0.1);
  border-color: var(--success);
}

/* ==================== BUTTONS ==================== */
.btn {
  font-family: var(--font);
  font-size: 0.8rem;
  padding: 0.5rem 1.05rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  font-weight: bold;
  letter-spacing: 0.3px;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent-grad);
  color: #2a1c00;
  border-color: transparent;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  box-shadow: 0 4px 16px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--accent-dim);
}

.btn-lang {
  background: var(--bg-surface);
  color: var(--text-secondary);
  border-color: var(--border);
  font-size: 0.7rem;
  padding: 0.3rem 0.55rem;
  letter-spacing: 0.08em;
}

.btn-lang:hover {
  background: var(--border);
  color: var(--text-primary);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: transparent;
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.15);
}

.btn-cancel {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-cancel:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.btn-icon-sm {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem;
  border-radius: 4px;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.btn-icon-sm:hover {
  opacity: 1;
}

.btn-turbo {
  /* plain <button> doesn't inherit color, so its currentColor-stroked icon
     rendered black and vanished on the dark station header — inherit instead */
  color: inherit;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.1rem;
  border-radius: 4px;
  line-height: 1;
  opacity: 0.55;
  transition: all 0.2s ease;
}

.btn-turbo:hover {
  opacity: 0.9;
  transform: scale(1.2);
}

.btn-turbo.active {
  color: var(--turbo);
  opacity: 1;
  filter: drop-shadow(0 0 4px var(--turbo-glow));
  animation: turbo-icon-pulse 1s ease-in-out infinite;
}

.btn-blocked {
  color: inherit; /* same fix as .btn-turbo — inherit header text, not black */
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.1rem;
  border-radius: 4px;
  line-height: 1;
  opacity: 0.55;
  transition: all 0.2s ease;
}

.btn-blocked:hover {
  opacity: 0.9;
  transform: scale(1.2);
}

.btn-blocked.active {
  opacity: 1;
  color: var(--danger);
  filter: drop-shadow(0 0 4px var(--danger-glow));
}

@keyframes turbo-icon-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}

/* ==================== BOARD ==================== */
.board {
  display: flex;
  gap: var(--space-5);
  padding: var(--space-5) var(--space-6);
  overflow-x: auto;
  min-height: calc(100vh - 64px);
  align-items: flex-start;
  scroll-behavior: smooth;
}

.board::-webkit-scrollbar {
  height: 8px;
}

.board::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

.board::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.board::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ==================== STATION ==================== */
.station {
  min-width: 280px;
  max-width: 310px;
  flex: 0 0 auto;
  background: var(--bg-surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 90px);
  box-shadow: var(--shadow-md);
}

.station.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

.station.turbo {
  border-color: var(--turbo);
  box-shadow: 0 0 15px var(--turbo-glow), 0 0 30px rgba(0, 200, 255, 0.1);
  animation: turbo-glow 1.5s ease-in-out infinite;
}

.station.turbo .station-header {
  border-bottom-color: var(--turbo);
  background: rgba(0, 200, 255, 0.06);
}

.station.turbo .station-body.drag-over {
  background: rgba(0, 200, 255, 0.05);
}

.station.blocked {
  border-color: var(--danger);
  box-shadow: 0 0 15px var(--danger-glow);
  animation: blocked-pulse 2s ease-in-out infinite;
}

.station.blocked .station-header {
  background: rgba(239, 68, 68, 0.1);
}

@keyframes blocked-pulse {
  0%, 100% {
    box-shadow: 0 0 15px var(--danger-glow);
  }
  50% {
    box-shadow: 0 0 25px var(--danger-glow), 0 0 40px rgba(239, 68, 68, 0.3);
  }
}

@keyframes turbo-glow {
  0%, 100% {
    box-shadow: 0 0 15px var(--turbo-glow), 0 0 30px rgba(0, 200, 255, 0.1);
  }
  50% {
    box-shadow: 0 0 25px var(--turbo-glow), 0 0 50px rgba(0, 200, 255, 0.2);
  }
}

.station-header {
  padding: 0.8rem 1rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.22));
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}

.station-header:active {
  cursor: grabbing;
}

.station-title {
  font-weight: bold;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-primary);
}

.station-title .station-icon {
  font-size: 1.1rem;
}

/* Phase 3: accessible accordion toggle wrapping the station title. On
   desktop/tablet this is reset to look exactly like the previous plain
   title (the caret stays hidden); only on phone does it behave as a real
   accordion button — see the ≤600px block below. */
.station-toggle {
  all: unset;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font: inherit;
  color: inherit;
  cursor: inherit;
}

.station-accordion-caret {
  display: none;
  margin-left: 0.2rem;
  font-size: 0.7rem;
  transition: transform 0.2s ease;
}

.station-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.station-count {
  background: var(--accent);
  color: var(--bg-primary);
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: bold;
}

.station-count.empty {
  background: var(--border);
  color: var(--text-secondary);
}

.station-actions {
  display: flex;
  gap: 0.15rem;
}

/* Station health banner */
.station-health {
  font-size: 0.64rem;
  font-family: var(--font);
  padding: 0.2rem 0.75rem;
  min-height: 22px;
  display: flex;
  align-items: center;
  transition: background 0.3s, color 0.3s;
  border-bottom: 1px solid transparent;
}

.station-health.health-ok {
  background: rgba(74, 222, 128, 0.06);
  color: var(--success);
  border-bottom-color: rgba(74, 222, 128, 0.15);
}

.station-health.health-warn {
  background: rgba(250, 204, 21, 0.08);
  color: var(--warning);
  border-bottom-color: rgba(250, 204, 21, 0.2);
}

.station-health.health-critical {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-bottom-color: rgba(239, 68, 68, 0.25);
  animation: health-critical-pulse 1.5s ease-in-out infinite;
}

@keyframes health-critical-pulse {
  0%, 100% { background: rgba(239, 68, 68, 0.10); }
  50%       { background: rgba(239, 68, 68, 0.20); }
}

/* ==================== STATION THERMOMETER ==================== */
.station-thermo {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.66rem;
  font-family: var(--font);
  padding: 0.25rem 0.75rem;
  min-height: 24px;
  border-bottom: 1px solid transparent;
  transition: background 0.3s, color 0.3s;
  cursor: default;
}
.station-thermo .thermo-icon { font-size: 0.8rem; }
.station-thermo .thermo-temp { font-weight: 700; min-width: 38px; }
.station-thermo .thermo-bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.station-thermo .thermo-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease, background 0.3s;
}
.station-thermo .thermo-dot { font-size: 0.7rem; }

.station-thermo.thermo-cool {
  background: rgba(74, 222, 128, 0.06);
  color: var(--success);
  border-bottom-color: rgba(74, 222, 128, 0.15);
}
.station-thermo.thermo-cool .thermo-fill { background: var(--success); }

.station-thermo.thermo-warm {
  background: rgba(250, 204, 21, 0.08);
  color: var(--warning);
  border-bottom-color: rgba(250, 204, 21, 0.2);
}
.station-thermo.thermo-warm .thermo-fill { background: var(--warning); }

.station-thermo.thermo-hot {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-bottom-color: rgba(239, 68, 68, 0.25);
  animation: health-critical-pulse 1.5s ease-in-out infinite;
}
.station-thermo.thermo-hot .thermo-fill { background: var(--danger); }

.station-thermo.thermo-cool .thermo-dot .icon { color: var(--success); }
.station-thermo.thermo-warm .thermo-dot .icon { color: var(--warning); }
.station-thermo.thermo-hot  .thermo-dot .icon { color: var(--danger); }

/* Turbo countdown on order cards */
.order-time.turbo-time {
  color: var(--turbo);
  font-variant-numeric: tabular-nums;
  font-weight: bold;
}

.order-time.turbo-time.urgent {
  color: var(--danger);
  animation: turbo-urgent-pulse 0.7s ease-in-out infinite;
}

@keyframes turbo-urgent-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

/* Subtle left border on turbo cards */
.order-card.card-turbo {
  border-left-color: var(--turbo);
}

.station-body {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  overflow-y: auto;
  flex: 1;
  min-height: 80px;
}

.station-body.drag-over {
  background: rgba(232, 168, 56, 0.05);
}

.station-empty {
  color: var(--text-secondary);
  font-size: 0.7rem;
  text-align: center;
  padding: 1.5rem 0.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

.station-empty.hidden {
  display: none;
}

/* ==================== ORDER CARD ==================== */
.order-card {
  background: var(--bg-card);
  color: var(--text-dark);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.8rem 0.6rem;
  border-left: 4px solid #999;
  cursor: grab;
  position: relative;
  font-family: var(--font);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.2s;
  box-shadow: var(--shadow-sm);
  user-select: none;
}

.order-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.order-card:active {
  cursor: grabbing;
}

.order-card.dragging {
  opacity: 0.4;
}

.order-card.drag-over-before {
  border-top: 3px solid var(--accent);
}

.order-card.drag-over-after {
  border-bottom: 3px solid var(--accent);
}

.order-card.priority-normal {
  border-left-color: var(--success-oncard);
}

.order-card.priority-alta {
  border-left-color: var(--warning-oncard);
}

.order-card.priority-urgente {
  border-left-color: var(--danger-oncard);
}

.order-card.is-delivered {
  opacity: 0.7;
}

.order-card.is-delivered .order-title {
  text-decoration: line-through;
}

.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}

.order-client {
  font-size: 0.6rem;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.order-priority-badge {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-weight: bold;
}

.order-priority-badge.normal {
  background: rgba(74, 222, 128, 0.15);
  color: #2d8a4e;
}

.order-priority-badge.alta {
  background: rgba(250, 204, 21, 0.2);
  color: #9a7a0a;
}

.order-priority-badge.urgente {
  background: rgba(239, 68, 68, 0.15);
  color: #b91c1c;
  animation: urgent-pulse 2s ease-in-out infinite;
}

@keyframes urgent-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.order-title {
  font-weight: bold;
  font-size: 0.88rem;
  margin: 0.1rem 0 0.3rem;
  line-height: 1.35;
}

.order-desc {
  font-size: 0.7rem;
  color: #777;
  margin-bottom: 0.4rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.order-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.3rem 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.45rem;
  border-top: 1px dashed #e2ddd0;
}

.order-footer-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

/* Accomplishment bar (server-computed % complete) */
.order-progress {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.order-progress-label { font-size: 0.6rem; color: #9aa0ab; font-weight: 700; }
.order-progress-bar {
  flex: 1;
  height: 5px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.1);
  overflow: hidden;
}
.order-progress-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.order-progress-pct {
  font-size: 0.6rem;
  font-weight: 700;
  color: #6b7280;
  min-width: 26px;
  text-align: right;
}
.order-progress.progress-low  .order-progress-fill { background: #fb923c; }
.order-progress.progress-mid  .order-progress-fill { background: #facc15; }
.order-progress.progress-high .order-progress-fill { background: linear-gradient(90deg, #4ade80, #22c55e); }

/* Per-order temperature chip (server-computed thermo) */
.order-thermo-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.08rem 0.35rem;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
  line-height: 1;
}
.order-thermo-chip .icon { width: 0.7em; height: 0.7em; vertical-align: 0; }
.order-thermo-chip.thermo-cool { color: #2d8a4e; background: rgba(74, 222, 128, 0.14); border-color: rgba(74,222,128,.35); }
.order-thermo-chip.thermo-warm { color: #9a7a0a; background: rgba(250, 204, 21, 0.18); border-color: rgba(250,204,21,.4); }
.order-thermo-chip.thermo-hot  { color: #b91c1c; background: rgba(239, 68, 68, 0.16);  border-color: rgba(239,68,68,.4); }
.order-thermo-chip.is-critical {
  color: #fff; background: var(--danger); border-color: transparent;
  animation: health-critical-pulse 1.2s ease-in-out infinite;
}

.order-time {
  font-size: 0.65rem;
  color: #999;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.order-time.burning {
  color: var(--danger-oncard);
  font-weight: bold;
}

.order-time.paused {
  color: #aaa;
  font-style: italic;
}

.order-card.is-paused {
  opacity: 0.8;
}

.order-card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.2rem;
  min-width: 0;
}

.order-card-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.15rem;
  border-radius: 3px;
  opacity: 0.35;
  transition: opacity 0.15s;
  line-height: 1;
}

/* Keep the action-row icons compact so the full set fits inside the card
   (the SVG icons default to --icon-md / 20px, wider than the old emoji). */
.order-card-actions .icon { width: var(--icon-sm); height: var(--icon-sm); vertical-align: 0; }

.order-card:hover .order-card-actions button {
  opacity: 0.6;
}

.order-card-actions button:hover {
  opacity: 1 !important;
  background: rgba(0, 0, 0, 0.05);
}

/* Turbo on the light card: inherited card text is near-black and hard to read.
   Give it a readable teal (brand cyan darkened for contrast on --bg-card). */
.order-card-actions .btn-order-turbo { color: var(--turbo-oncard); opacity: 0.7; }
.order-card-actions .btn-order-turbo.active {
  color: var(--turbo-oncard);
  opacity: 1;
  filter: drop-shadow(0 0 4px var(--turbo-glow));
  animation: turbo-icon-pulse 1s ease-in-out infinite;
}
/* Turbo countdown icon shown in the order time slot — same readable teal. */
.order-time .icon { color: var(--turbo-oncard); }

/* ==================== PHONE CARD ACTION MENU (Phase 3) ==================== */
/* Hidden on desktop/tablet — `.order-card-actions` (above) covers those. On
   phone the action row is swapped for this single menu button + popover
   (see the ≤600px block below), which is the non-drag alternative for
   moving/acting on an order (WCAG 2.5.7 groundwork; full pass in Phase 4). */
.order-card-menu-wrap {
  position: relative;
  display: none;
}

.btn-order-menu {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 3px;
  color: var(--text-dark);
  opacity: 0.7;
}

.btn-order-menu:hover,
.btn-order-menu:focus-visible {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}

.order-card-menu {
  position: absolute;
  right: 0;
  bottom: 100%;
  z-index: var(--z-dropdown);
  margin-bottom: 0.3rem;
  min-width: 210px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xs);
}

.order-card-menu[hidden] {
  display: none;
}

.order-card-menu button {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  font: inherit;
  font-size: 0.8rem;
  color: inherit;
  padding: var(--space-sm);
  min-height: 24px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.order-card-menu button:hover,
.order-card-menu button:focus-visible {
  background: var(--bg-hover);
}

.order-card-menu-hint {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  padding: var(--space-sm);
  margin-top: var(--space-xs);
  border-top: 1px solid var(--border-soft);
}

.metrics-bar-fill.accuracy-low {
  background: var(--warning);
}

.station-metrics-avg.accuracy-returns {
  color: var(--warning);
}

/* Burning animation */
.order-card.burning {
  box-shadow:
    0 0 12px rgba(239, 68, 68, 0.35),
    0 0 25px rgba(239, 68, 68, 0.15);
  animation: burn-glow 1.5s ease-in-out infinite;
}

@keyframes burn-glow {
  0%, 100% {
    box-shadow:
      0 0 12px rgba(239, 68, 68, 0.3),
      0 0 25px rgba(239, 68, 68, 0.1);
  }
  50% {
    box-shadow:
      0 0 18px rgba(239, 68, 68, 0.5),
      0 0 35px rgba(239, 68, 68, 0.2);
  }
}

/* ==================== FLAGS ==================== */
.order-header-left {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
}

.order-flag-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
  opacity: 0.35;
  transition: opacity 0.15s, transform 0.15s;
}

.order-flag-btn:hover {
  opacity: 1 !important;
  transform: scale(1.2);
}

.order-flag-btn.flag-yellow,
.order-flag-btn.flag-red {
  opacity: 1;
}

.order-card.card-flag-red {
  border-left-color: var(--danger);
}

.order-card.card-flag-yellow {
  border-left-color: var(--warning-oncard);
}

.order-card.card-flag-purple {
  border-left-color: var(--purple-oncard);
}

.order-flag-btn.flag-purple {
  opacity: 1;
}

/* Flag countdown badge on card */
.flag-countdown {
  font-size: 0.6rem;
  font-weight: bold;
  color: var(--warning-oncard);
  background: rgba(250, 204, 21, 0.12);
  border: 1px solid rgba(250, 204, 21, 0.3);
  border-radius: 4px;
  padding: 1px 4px;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* Acked badge on card */
.flag-acked-badge {
  font-size: 0.6rem;
  color: var(--success-oncard);
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: 4px;
  padding: 1px 4px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

/* Flag modal */
.flag-options {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.flag-option {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
  width: 100%;
  transition: border-color 0.15s, background 0.15s;
}

.flag-option:hover {
  border-color: var(--text-secondary);
}

.flag-option.active {
  border-color: var(--accent);
  background: rgba(232, 168, 56, 0.07);
}

.flag-option-emoji {
  font-size: 1.15rem;
  line-height: 1;
  flex-shrink: 0;
}

.flag-option-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.flag-option-label {
  font-size: 0.82rem;
  color: var(--text-primary);
  font-weight: bold;
}

.flag-option-desc {
  font-size: 0.63rem;
  color: var(--text-secondary);
}

.flag-extra-fields {
  margin-top: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flag-extra-fields.hidden {
  display: none;
}

.flag-extra-fields label {
  display: block;
  font-size: 0.68rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.2rem;
}

.flag-extra-fields textarea,
.flag-extra-fields input[type="text"] {
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.8rem;
  resize: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.flag-extra-fields textarea:focus,
.flag-extra-fields input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
}

.flag-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.85rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

/* Alerts bar */
.alerts-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: calc(var(--z-header) - 10);
  background: rgba(26, 26, 46, 0.96);
  backdrop-filter: blur(8px);
  border-top: 2px solid var(--warning);
  padding: 0.5rem 1.5rem 0.6rem;
  max-height: 180px;
  overflow-y: auto;
}

.alerts-bar.hidden {
  display: none;
}

.alerts-bar-header {
  font-size: 0.65rem;
  font-weight: bold;
  color: var(--warning);
  letter-spacing: 1.5px;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
}

.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.alert-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.75rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.alert-item:last-child {
  border-bottom: none;
}

.alert-item.alert-overheat .alert-reason {
  color: var(--danger);
  font-weight: 700;
}

.alert-flag-emoji {
  font-size: 1rem;
  flex-shrink: 0;
}

.alert-content {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  flex: 1;
  flex-wrap: wrap;
  min-width: 0;
}

.alert-station {
  font-weight: bold;
  color: var(--text-primary);
  white-space: nowrap;
}

.alert-sep {
  color: var(--text-secondary);
}

.alert-order-title {
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.alert-reason {
  color: var(--text-secondary);
  font-style: italic;
  font-size: 0.7rem;
}

.alert-timeaway {
  color: #a855f7;
  font-size: 0.7rem;
}

.alert-devname {
  color: var(--accent);
  font-size: 0.7rem;
  font-style: italic;
}

.alert-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.alert-countdown {
  font-size: 0.68rem;
  font-weight: bold;
  color: var(--warning);
  font-variant-numeric: tabular-nums;
  min-width: 34px;
  text-align: right;
}

.alert-acked {
  font-size: 0.68rem;
  color: var(--success);
  white-space: nowrap;
}

.alert-ack-area {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.alert-ack-btn {
  background: rgba(250, 204, 21, 0.1);
  border: 1px solid rgba(250, 204, 21, 0.35);
  color: var(--warning);
  border-radius: var(--radius-sm);
  font-size: 0.65rem;
  font-family: var(--font);
  padding: 2px 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.alert-ack-btn:hover {
  background: rgba(250, 204, 21, 0.2);
}

.alert-ack-form {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.alert-ack-input {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.65rem;
  padding: 2px 6px;
  width: 90px;
  outline: none;
}

.alert-ack-input:focus {
  border-color: var(--success);
}

.alert-ack-confirm {
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.35);
  color: var(--success);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.65rem;
  padding: 2px 7px;
  cursor: pointer;
  transition: background 0.15s;
}

.alert-ack-confirm:hover {
  background: rgba(74, 222, 128, 0.2);
}

/* ==================== PURPLE WIDGET ==================== */
.purple-widget {
  position: relative;
}

.btn-purple-status {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
  transition: border-color 0.15s;
  line-height: 1;
}

.btn-purple-status:hover,
.btn-purple-status.has-active {
  border-color: #a855f7;
}

.purple-badge {
  background: #a855f7;
  color: #fff;
  border-radius: 50%;
  min-width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.58rem;
  font-weight: bold;
  font-family: var(--font);
}

.purple-badge.hidden { display: none; }

.purple-popover {
  display: none;
  flex-direction: column;
  gap: 0.55rem;
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: var(--z-dropdown);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  min-width: 260px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  animation: slide-up 0.15s ease;
}

.purple-popover.open { display: flex; }

.purple-popover-title {
  font-size: 0.72rem;
  font-weight: bold;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

.purple-active-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.purple-empty {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-style: italic;
}

.purple-active-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(168, 85, 247, 0.25);
}

.purple-active-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.purple-active-name {
  font-size: 0.78rem;
  color: var(--text-primary);
  font-weight: bold;
}

.purple-active-detail {
  font-size: 0.65rem;
  color: var(--text-secondary);
}

.purple-dismiss-btn {
  background: transparent;
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: 4px;
  color: var(--success);
  font-family: var(--font);
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}

.purple-dismiss-btn:hover {
  background: rgba(74, 222, 128, 0.1);
}

.purple-divider {
  height: 1px;
  background: var(--border);
}

.purple-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.purple-form input[type="text"] {
  width: 100%;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.78rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.purple-form input[type="text"]:focus {
  outline: none;
  border-color: #a855f7;
  box-shadow: 0 0 6px rgba(168, 85, 247, 0.3);
}

.btn-purple-raise {
  width: 100%;
  background: rgba(168, 85, 247, 0.12);
  border: 1px solid rgba(168, 85, 247, 0.4);
  border-radius: var(--radius-sm);
  color: #c084fc;
  font-family: var(--font);
  font-size: 0.78rem;
  padding: 0.4rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-align: center;
}

.btn-purple-raise:hover {
  background: rgba(168, 85, 247, 0.22);
  border-color: #a855f7;
}

.alert-dismiss,
.alert-dismiss-purple {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s;
  font-family: var(--font);
}

.alert-dismiss:hover,
.alert-dismiss-purple:hover {
  color: var(--success);
  border-color: var(--success);
}

/* push board content above fixed alerts bar */
body.has-alerts .board {
  padding-bottom: 110px;
}

/* ==================== MODALS ==================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  justify-content: center;
  align-items: center;
  animation: fade-in 0.15s ease;
}

.modal-overlay.open {
  display: flex;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 480px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slide-up 0.2s ease;
}

.modal-lg {
  max-width: 600px;
}

.modal-sm {
  max-width: 360px;
}

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--border-soft);
}

.modal-header h2 {
  font-size: 1.1rem;
  color: var(--text-primary);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  transition: color 0.15s;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-soft);
}

.config-hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

/* ==================== FORM ==================== */
/* Native <fieldset>/<legend> reset — used to group the concern tags and the
   claim data-availability radios (2.4.6 / 4.1.2: named group, not just a
   visual label floating above a div). */
.concern-fieldset,
.claim-data-fieldset {
  border: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}

#form-order label,
#form-order legend {
  display: block;
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  margin-top: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#form-order label:first-of-type {
  margin-top: 0;
}

#form-order input,
#form-order textarea,
#form-order select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#form-order input:focus,
#form-order textarea:focus,
#form-order select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

#form-order textarea {
  resize: vertical;
  min-height: 60px;
}

#form-order select {
  cursor: pointer;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* ==================== STATION CONFIG ==================== */
.stations-config {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.config-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-surface);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}

.config-item.dragging {
  opacity: 0.4;
}

.config-item.drag-over-top {
  border-top: 2px solid var(--accent);
}

.config-item.drag-over-bottom {
  border-bottom: 2px solid var(--accent);
}

.config-drag-handle {
  cursor: grab;
  color: var(--text-secondary);
  font-size: 1.1rem;
  padding: 0.1rem 0.2rem;
  user-select: none;
  line-height: 1;
}

.config-drag-handle:active {
  cursor: grabbing;
}

.config-icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.2rem;
  border-radius: 4px;
  transition: background 0.15s;
  line-height: 1;
}

.config-icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.config-name-input {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 0.3rem 0.4rem;
  border-radius: 4px;
  transition: border-color 0.15s;
}

.config-name-input:hover {
  border-color: var(--border);
}

.config-name-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-primary);
}

.config-blocked-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 0.25rem;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}

.config-blocked-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

.config-blocked-btn.active {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.2);
}

.config-remove-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 0.25rem;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}

.config-remove-btn:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.config-remove-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.config-remove-btn:disabled:hover {
  color: var(--text-secondary);
  background: transparent;
}

/* ==================== ICON GRID ==================== */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
}

.icon-grid button {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.5rem;
  padding: 0.5rem;
  transition: all 0.15s;
  line-height: 1;
}

.icon-grid button:hover {
  border-color: var(--accent);
  background: var(--bg-secondary);
  transform: scale(1.1);
}

.icon-grid button.selected {
  border-color: var(--accent);
  background: rgba(232, 168, 56, 0.15);
  box-shadow: 0 0 10px var(--accent-glow);
}

/* ==================== BADGE ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  font-size: 0.6rem;
  font-weight: bold;
  border-radius: 9px;
}

/* ==================== SCROLLBAR (modals) ==================== */
.modal-body::-webkit-scrollbar,
.station-body::-webkit-scrollbar,
.flag-glossary-pills::-webkit-scrollbar,
.glossary-list::-webkit-scrollbar,
.metrics-sidebar .metrics-content::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

.modal-body::-webkit-scrollbar-track,
.station-body::-webkit-scrollbar-track,
.flag-glossary-pills::-webkit-scrollbar-track,
.glossary-list::-webkit-scrollbar-track,
.metrics-sidebar .metrics-content::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb,
.station-body::-webkit-scrollbar-thumb,
.flag-glossary-pills::-webkit-scrollbar-thumb,
.glossary-list::-webkit-scrollbar-thumb,
.metrics-sidebar .metrics-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover,
.station-body::-webkit-scrollbar-thumb:hover,
.flag-glossary-pills::-webkit-scrollbar-thumb:hover,
.glossary-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
  color: #fff;
}

/* ==================== METRICS SIDEBAR ==================== */
.metrics-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: var(--z-modal);
  backdrop-filter: blur(2px);
  transition: opacity 0.2s;
}

.metrics-backdrop.hidden {
  opacity: 0;
  pointer-events: none;
}

.metrics-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 100vw;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  z-index: calc(var(--z-modal) + 1);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
}

.metrics-sidebar.open {
  transform: translateX(0);
}

.metrics-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.metrics-sidebar-title {
  font-size: 1rem;
  font-family: var(--font);
  color: var(--text-primary);
  font-weight: bold;
}

.metrics-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.75rem;
  transition: border-color 0.15s, color 0.15s;
}

.metrics-close:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.metrics-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.metrics-body::-webkit-scrollbar {
  width: 6px;
}
.metrics-body::-webkit-scrollbar-track { background: transparent; }
.metrics-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.metrics-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.metrics-section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  font-family: var(--font);
  font-weight: bold;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem;
}

.metrics-empty {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* Tooltip info icon in section titles */
.metric-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 0.5rem;
  color: var(--text-secondary);
  cursor: help;
  vertical-align: middle;
  margin-left: 5px;
  flex-shrink: 0;
}

.metric-card[data-tooltip] {
  cursor: help;
}

/* JS-positioned tooltip popup — appended to body, never clipped */
.metrics-tooltip-popup {
  position: fixed;
  z-index: 9999;
  width: 240px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.65rem;
  font-style: normal;
  font-weight: normal;
  line-height: 1.45;
  padding: 0.5rem 0.7rem;
  white-space: normal;
  pointer-events: none;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.1s;
}

.metrics-tooltip-popup.visible {
  opacity: 1;
}

/* Metric cards grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

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

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.5rem;
  text-align: center;
  transition: border-color 0.15s;
}

.metric-card.metric-danger {
  border-color: rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.06);
}

.metric-card.metric-warn {
  border-color: rgba(250, 204, 21, 0.4);
  background: rgba(250, 204, 21, 0.05);
}

.metric-card.metric-dim {
  opacity: 0.5;
}

.metric-value {
  font-size: 1.35rem;
  font-weight: bold;
  color: var(--accent);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.metric-value.metric-value-sm {
  font-size: 1rem;
}

.metric-value-sep {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0 2px;
}

.metric-label {
  font-size: 0.58rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Recent lists */
.metrics-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.metrics-list-header {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  padding: 0.35rem 0.6rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.metrics-list-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.7rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.metrics-list-row:last-child {
  border-bottom: none;
}

.metrics-list-row-flag {
  gap: 0.35rem;
}

.metrics-list-flag-emoji {
  flex-shrink: 0;
  font-size: 0.75rem;
}

.metrics-list-name {
  color: var(--text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.metrics-list-client {
  color: var(--text-secondary);
  font-size: 0.63rem;
  white-space: nowrap;
}

.metrics-list-meta {
  color: var(--text-secondary);
  font-size: 0.62rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}

.metrics-list-dur {
  color: var(--accent);
  font-size: 0.65rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.metrics-list-dur.metrics-open {
  color: var(--warning);
}

/* Bottleneck / suggestion callout */
.metrics-suggestion {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  background: rgba(250, 204, 21, 0.07);
  border: 1px solid rgba(250, 204, 21, 0.25);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.68rem;
  line-height: 1.4;
  padding: 0.45rem 0.6rem;
}

.metrics-suggestion strong {
  color: var(--warning);
}

.metrics-suggestion.ok {
  background: rgba(74, 222, 128, 0.06);
  border-color: rgba(74, 222, 128, 0.2);
  color: var(--success);
}

/* Combined station table */
.station-metrics-table {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.station-metrics-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.3rem 0.6rem;
  align-items: center;
}

.station-metrics-row.bottleneck-row .metrics-bar-label {
  color: var(--warning);
}

.station-metrics-row.bottleneck-row .metrics-bar-fill {
  background: var(--warning);
}

.station-metrics-avg {
  font-size: 0.65rem;
  color: var(--accent);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  text-align: right;
  min-width: 44px;
}

.station-metrics-avg.no-data {
  color: var(--text-secondary);
  opacity: 0.5;
}

.station-metrics-sub {
  font-size: 0.58rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  grid-column: 1 / -1;
  margin-top: 0.1rem;
}

/* Bar charts */
.metrics-bars {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.metrics-bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.7rem;
}

.metrics-bar-label {
  width: 120px;
  flex-shrink: 0;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metrics-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-surface);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.metrics-bar-fill {
  height: 100%;
  background: var(--danger);
  border-radius: 4px;
  transition: width 0.4s ease;
  min-width: 2px;
}

.metrics-bar-fill.accent {
  background: var(--accent);
}

.metrics-bar-value {
  width: 36px;
  flex-shrink: 0;
  text-align: right;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.turbo-laps-badge {
  color: var(--turbo) !important;
  font-weight: bold;
}

/* ==================== WORK DAYS SELECTOR ==================== */
.shift-days-row {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.shift-days-selector {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.shift-day-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 0.62rem;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.shift-day-btn.active {
  background: rgba(232, 168, 56, 0.18);
  border-color: var(--accent);
  color: var(--accent);
}

.shift-day-btn:hover:not(.active) {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

/* ==================== ORDER PAUSE ==================== */
.btn-order-pause,
.btn-order-resume {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0.15rem 0.2rem;
  border-radius: 3px;
  opacity: 0.5;
  transition: opacity 0.15s, transform 0.15s;
  line-height: 1;
}

.btn-order-pause:hover {
  opacity: 1;
  transform: scale(1.1);
}

.btn-order-resume {
  opacity: 1;
  color: var(--success-oncard);
}

.btn-order-resume:hover {
  transform: scale(1.1);
}

.order-paused-badge {
  font-size: 0.62rem;
  color: var(--purple-oncard);
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.25);
  border-radius: 4px;
  padding: 0.15rem 0.35rem;
  margin-top: 0.25rem;
  word-break: break-word;
}

.metric-card.metric-purple {
  border-color: rgba(168, 85, 247, 0.5);
  background: rgba(168, 85, 247, 0.07);
}

/* ==================== KITCHENFLOW: meta badges, claim, intake ==================== */
.order-meta-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.3rem;
}
.order-menu-badge,
.order-concern-badge,
.order-claimed-badge {
  font-size: 0.6rem;
  border-radius: 4px;
  padding: 0.12rem 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}
.order-claimed-badge {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.1);
}
/* Concern badge palette — one accent per phase/effort tag */
.order-concern-badge.concern-security    { color: #f87171; border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.12); }
.order-concern-badge.concern-bug         { color: #fb923c; border-color: rgba(251,146,60,.4);  background: rgba(251,146,60,.12); }
.order-concern-badge.concern-data        { color: #60a5fa; border-color: rgba(96,165,250,.4);  background: rgba(96,165,250,.12); }
.order-concern-badge.concern-integration { color: #c084fc; border-color: rgba(192,132,252,.4); background: rgba(192,132,252,.12); }
.order-concern-badge.concern-architecture{ color: #5eead4; border-color: rgba(94,234,212,.4);  background: rgba(94,234,212,.12); }
.order-concern-badge.concern-research    { color: #fbbf24; border-color: rgba(251,191,36,.4);  background: rgba(251,191,36,.12); }
.btn-order-claim {
  font-size: 0.62rem !important;
  font-weight: 600;
  padding: 0.18rem 0.45rem !important;
  color: #0c4a6e !important;
  background: #38bdf8 !important;
  border: none !important;
  border-radius: 5px;
  white-space: nowrap;
  width: auto !important;
}
.btn-order-claim:hover { background: #0ea5e9 !important; }

.concern-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.concern-chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  user-select: none;
}
.concern-chip:hover { border-color: var(--accent-dim); color: var(--text-primary); }
.concern-chip input { display: none; }
.concern-chip:has(input:checked) {
  background: var(--accent-grad);
  border-color: transparent;
  color: #2a1c00;
  font-weight: 600;
}

.claim-data-choice {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}
.claim-data-choice label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.claim-data-choice input { width: auto; margin: 0; }

/* ==================== ARTIFACTS ==================== */
.btn-order-artifacts.has-artifacts {
  color: #38bdf8 !important;
  font-weight: 600;
}
.artifacts-order-name {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-secondary);
}
.artifact-add-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin-bottom: 0.6rem;
}
.artifact-add-row input[type="text"],
.artifact-add-row textarea,
.artifact-add-row input[type="file"] {
  flex: 1;
  margin: 0;
}
.artifact-add-row .btn { white-space: nowrap; }
.artifacts-list {
  margin-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 40vh;
  overflow-y: auto;
}
.artifacts-empty {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 0.5rem 0;
}
.artifact-item {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}
.artifact-type-icon { font-size: 1rem; line-height: 1.3; }
.artifact-main { flex: 1; min-width: 0; }
.artifact-body { font-size: 0.85rem; word-break: break-word; }
.artifact-body a { color: #38bdf8; }
.artifact-note-text { white-space: pre-wrap; }
.artifact-meta {
  font-size: 0.68rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}
.btn-artifact-delete {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  opacity: 0.6;
}
.btn-artifact-delete:hover { opacity: 1; }

/* ==================== QUALITY GATES ==================== */
.btn-order-gate {
  font-size: 0.62rem !important;
  font-weight: 600;
  padding: 0.18rem 0.4rem !important;
  white-space: nowrap;
  width: auto !important;
}
.btn-order-gate.gate-ok { color: #4ade80 !important; }
.gate-station-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}
.gate-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.6rem 0;
  max-height: 45vh;
  overflow-y: auto;
}
.gate-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid transparent;
}
.gate-item.is-passed { border-left-color: #4ade80; }
.gate-item.is-override { border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.08); }
.gate-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 400;
}
.gate-check input { width: auto; margin: 0; }
.gate-req { color: #f87171; font-weight: 700; }
.gate-override-tag {
  font-size: 0.68rem;
  color: #f59e0b;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-gate-override,
.btn-gate-clear-override {
  font-size: 0.68rem;
  padding: 0.2rem 0.45rem;
  border: 1px solid rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-gate-override:hover,
.btn-gate-clear-override:hover { background: rgba(245, 158, 11, 0.2); }
#btn-gate-move:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-order-dossier.dossier-ready { color: #4ade80 !important; }

/* ==================== RETURN MODAL ==================== */
.return-intro {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0 0 0.85rem;
  line-height: 1.5;
}

.return-field-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0.75rem 0 0.3rem;
}

.return-target-select,
#return-why-input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.8rem;
  padding: 0.5rem 0.65rem;
  resize: vertical;
  transition: border-color 0.15s;
}

.return-target-select:focus,
#return-why-input:focus {
  outline: none;
  border-color: var(--accent);
}

.return-code-block,
.return-flag-block {
  margin-top: 0.25rem;
}

.return-flag-options {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.return-flag-opt {
  flex: 1 1 auto;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.return-flag-opt:hover {
  border-color: var(--accent);
}

.return-flag-opt.selected {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.return-flag-opt.flag-yellow.selected {
  border-color: var(--warning, #eab308);
  box-shadow: inset 0 0 0 1px var(--warning, #eab308);
  background: rgba(234, 179, 8, 0.12);
}

.return-flag-opt.flag-red.selected {
  border-color: var(--danger);
  box-shadow: inset 0 0 0 1px var(--danger);
  background: rgba(239, 68, 68, 0.12);
}

/* ==================== GLOSSARY ==================== */
.modal-xl {
  max-width: 720px;
}

.glossary-toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

#glossary-search {
  flex: 1 1 160px;
  min-width: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.82rem;
  padding: 0.5rem 0.75rem;
  transition: border-color 0.15s;
}

#glossary-search:focus {
  outline: none;
  border-color: var(--accent);
}

.glossary-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.glossary-empty {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-style: italic;
  padding: 1rem 0;
  text-align: center;
}

.glossary-category {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.glossary-cat-header {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.1rem;
}

.glossary-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: 0.6rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
}

.glossary-row:hover {
  background: var(--bg-surface);
}

.glossary-code-badge {
  font-size: 0.72rem;
  font-weight: bold;
  background: rgba(232, 168, 56, 0.15);
  border: 1px solid rgba(232, 168, 56, 0.35);
  color: var(--accent);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  white-space: nowrap;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 0.1rem;
  min-width: 72px;
  text-align: center;
}

.glossary-code-body {
  flex: 1;
  min-width: 0;
}

.glossary-code-title {
  font-size: 0.82rem;
  font-weight: bold;
  color: var(--text-primary);
  margin-bottom: 0.15rem;
}

.glossary-code-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.glossary-row-actions {
  display: flex;
  gap: 0.2rem;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

/* Visible on mouse hover (desktop) AND on keyboard focus of either action
   button (2.4.7/2.4.13 — a focused control must never be invisible). Touch/
   coarse-pointer devices don't reliably fire :hover, so the actions stay
   shown there unconditionally (matches the phone/tablet "always-on light
   actions" model used elsewhere on cards). */
.glossary-row:hover .glossary-row-actions,
.glossary-row:focus-within .glossary-row-actions {
  opacity: 1;
}

@media (max-width: 1024px), (pointer: coarse) {
  .glossary-row-actions {
    opacity: 1;
  }
}

.btn-glossary-edit,
.btn-glossary-delete {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.2rem 0.3rem;
  border-radius: 3px;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.btn-glossary-edit:hover,
.btn-glossary-delete:hover {
  opacity: 1;
}

#modal-glossary-edit .modal-body label,
#modal-pause .modal-body label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
}

#modal-glossary-edit .modal-body label:first-of-type,
#modal-pause .modal-body label:first-of-type {
  margin-top: 0;
}

#modal-glossary-edit .modal-body input[type="text"],
#modal-glossary-edit .modal-body textarea,
#modal-pause .modal-body input[type="text"],
#modal-pause .modal-body textarea {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.82rem;
  padding: 0.5rem 0.65rem;
  resize: vertical;
  transition: border-color 0.15s;
}

#modal-glossary-edit .modal-body input[type="text"]:focus,
#modal-glossary-edit .modal-body textarea:focus,
#modal-pause .modal-body input[type="text"]:focus,
#modal-pause .modal-body textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* ==================== COOKBOOK ==================== */
.cookbook-toolbar {
  display: flex;
  gap: var(--space-md);
  align-items: center;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.cookbook-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

.cookbook-tab {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: var(--fs-xs);
  padding: var(--space-xs) var(--space-md);
  min-height: 24px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.cookbook-tab:hover {
  border-color: var(--accent);
}

.cookbook-tab[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #0f0f1a;
  font-weight: 600;
}

#cookbook-search {
  flex: 1 1 160px;
  min-width: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: var(--fs-sm);
  padding: var(--space-sm) var(--space-md);
  transition: border-color 0.15s;
}

#cookbook-search:focus {
  outline: none;
  border-color: var(--accent);
}

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

.cookbook-list.hidden,
.cookbook-detail.hidden {
  display: none;
}

.cookbook-empty,
.cookbook-loading {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  font-style: italic;
  padding: var(--space-lg) 0;
  text-align: center;
}

.cookbook-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-sm);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: var(--font);
  color: var(--text-primary);
  transition: background 0.12s, border-color 0.12s;
}

.cookbook-row:hover,
.cookbook-row:focus-visible {
  background: var(--bg-surface);
  border-color: var(--border);
}

.cookbook-row-cat {
  font-size: var(--fs-xs);
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(232, 168, 56, 0.15);
  border: 1px solid rgba(232, 168, 56, 0.35);
  color: var(--accent);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-start;
  min-width: 64px;
  text-align: center;
}

.cookbook-row-body {
  flex: 1;
  min-width: 0;
}

.cookbook-row-title {
  font-size: var(--fs-sm);
  font-weight: bold;
}

.cookbook-row-tags {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

.cookbook-status-badge {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: bold;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  margin-left: 0.4rem;
  vertical-align: middle;
}

.cookbook-status-proposed {
  background: var(--flag-yellow, #f5c542);
  color: #2b2400;
}

.cookbook-status-approved {
  background: var(--flag-green, #3ba55d);
  color: #032b12;
}

.cookbook-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}

.cookbook-detail-back {
  background: transparent;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: var(--fs-sm);
  padding: var(--space-xs) var(--space-sm);
  min-height: 24px;
}

.cookbook-detail-actions {
  display: flex;
  gap: var(--space-sm);
}

.cookbook-detail-title {
  font-size: var(--fs-lg);
  margin: 0 0 var(--space-xs);
}

.cookbook-detail-meta {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

.cookbook-detail-body {
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--text-primary);
}

.cookbook-detail-body h1,
.cookbook-detail-body h2,
.cookbook-detail-body h3,
.cookbook-detail-body h4,
.cookbook-detail-body h5,
.cookbook-detail-body h6 {
  margin: var(--space-lg) 0 var(--space-sm);
}

.cookbook-detail-body p { margin: 0 0 var(--space-md); }
.cookbook-detail-body ul,
.cookbook-detail-body ol { margin: 0 0 var(--space-md); padding-left: var(--space-xl); }
.cookbook-detail-body pre {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  overflow-x: auto;
}
.cookbook-detail-body code {
  background: var(--bg-primary);
  border-radius: 3px;
  padding: 0 0.3em;
  font-family: monospace;
}
.cookbook-detail-body pre code { background: none; padding: 0; }
.cookbook-detail-body a { color: var(--accent); text-decoration: underline; }

#modal-cookbook-edit .modal-body label,
#modal-glossary-edit .modal-body label,
#modal-pause .modal-body label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
}

#modal-cookbook-edit .modal-body label:first-of-type {
  margin-top: 0;
}

#modal-cookbook-edit .modal-body input[type="text"],
#modal-cookbook-edit .modal-body select,
#modal-cookbook-edit .modal-body textarea {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.82rem;
  padding: 0.5rem 0.65rem;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

#modal-cookbook-edit .modal-body input[type="text"]:focus,
#modal-cookbook-edit .modal-body select:focus,
#modal-cookbook-edit .modal-body textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.cookbook-edit-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--fs-sm);
  margin-bottom: var(--space-md);
}

.cookbook-edit-error.hidden { display: none; }

.order-desc-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: var(--fs-sm);
  margin-top: var(--space-xs);
}

.order-desc-error.hidden { display: none; }

#btn-cookbook.hidden,
#btn-metrics.hidden { display: none; }

.cookbook-preview-wrap {
  margin-top: var(--space-md);
}

.cookbook-preview-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.cookbook-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  font-size: var(--fs-sm);
  line-height: 1.6;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg-primary);
}

.cookbook-preview p { margin: 0 0 var(--space-md); }
.cookbook-preview ul,
.cookbook-preview ol { margin: 0 0 var(--space-md); padding-left: var(--space-xl); }
.cookbook-preview pre {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  overflow-x: auto;
}
.cookbook-preview code {
  background: var(--bg-secondary);
  border-radius: 3px;
  padding: 0 0.3em;
  font-family: monospace;
}
.cookbook-preview pre code { background: none; padding: 0; }
.cookbook-preview a { color: var(--accent); text-decoration: underline; }

@media (max-width: 1024px), (pointer: coarse) {
  .cookbook-row { border-color: var(--border); }
}

/* ==================== GLOSSARY FLAG PICKER ==================== */
.flag-glossary-picker {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.flag-glossary-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.flag-glossary-search {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
  color: var(--text);
  margin-bottom: 0.5rem;
  box-sizing: border-box;
}

.flag-glossary-search:focus {
  outline: none;
  border-color: var(--accent);
}

.flag-glossary-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-height: 120px;
  overflow-y: auto;
}

.flag-glossary-pill {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.flag-glossary-pill:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
  color: #fff;
}

.flag-glossary-pill.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #0f0f1a;
}

.flag-glossary-pill .pill-code {
  font-weight: 700;
  font-size: 0.72rem;
  font-family: monospace;
  color: var(--accent);
}

.flag-glossary-pill .pill-title {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.flag-glossary-pill:hover .pill-title {
  color: #fff;
  font-size: 0.75rem;
}

.flag-glossary-pill.selected .pill-code {
  color: #0f0f1a;
  font-weight: 800;
}

.flag-glossary-pill.selected .pill-title {
  color: #2d2d2d;
}

.flag-glossary-team-notify {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
}

.flag-glossary-team-notify.hidden {
  display: none;
}

.flag-glossary-clear {
  margin-top: 0.4rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.15rem 0;
  text-decoration: underline;
}

.flag-glossary-clear:hover {
  color: var(--red);
}

/* ==================== ORDER CARD FLAG CODE BADGE ==================== */
.order-flag-code-badge {
  display: inline-block;
  font-family: monospace;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  margin: 0.2rem 0 0.1rem;
  letter-spacing: 0.03em;
}

.order-flag-code-badge.flag-code-yellow {
  background: rgba(234, 179, 8, 0.18);
  color: #ca8a04;
  border: 1px solid rgba(234, 179, 8, 0.4);
}

.order-flag-code-badge.flag-code-red {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

/* ==================== ALERT BAR GLOSSARY ==================== */
.alert-gloss-code {
  font-family: monospace;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin: 0 0.2rem;
}

.alert-gloss-yellow {
  background: rgba(234, 179, 8, 0.18);
  color: #92400e;
}

.alert-gloss-red {
  background: rgba(239, 68, 68, 0.15);
  color: #991b1b;
}

.alert-team-notify {
  font-size: 0.75rem;
  font-weight: 600;
  color: #f59e0b;
  white-space: nowrap;
}

/* ==================== GLOSSARY TEAM TAG ==================== */
.glossary-team-tag {
  font-size: 0.72rem;
  color: #f59e0b;
  margin-left: 0.5rem;
  font-weight: 500;
}

/* ==================== HIGH CONTRAST MODE ==================== */
/*
 * CB-safe palette used here:
 *   flag-ok    → blue   #2563eb  (safe for all CVD types)
 *   flag-warn  → gold   #d97706  (amber, distinct from blue)
 *   flag-block → orange #ea580c  + dashed border (shape+color)
 *   flag-pause → violet #7c3aed  + dotted border
 *   burning    → orange #f97316  (not red — safe for red-green CVD)
 */

/* HC toggle button */
.btn-hc {
  font-size: 0.85rem;
  padding: 0.35rem 0.55rem;
  line-height: 1;
  transition: all 0.15s;
}

.btn-hc.active {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
}

/* ---- Base overrides ---- */
body.hc-mode {
  --bg-primary:   #000000;
  --bg-secondary: #0d0d0d;
  --bg-surface:   #161616;
  --bg-hover:     #222222;
  --bg-card:      #ffffff;
  --text:         #ffffff;
  --text-primary: #ffffff;
  --text-secondary: #d4d4d4;
  --text-muted:   #aaaaaa;
  --text-dark:    #111111;
  --border:       #555555;
  --accent:       #f5c518;
  --accent-dim:   #c9a010;
  --accent-glow:  rgba(245, 197, 24, 0.4);
  --danger:       #ea580c;
  --danger-glow:  rgba(234, 88, 12, 0.4);
  --red:          #ea580c;
  --success:      #2563eb;
  --warning:      #d97706;
  --yellow:       #d97706;
  --turbo:        #00aaff;
  --turbo-glow:   rgba(0, 170, 255, 0.4);
  /* on-card variants recomputed against hc-mode's white --bg-card, keeping
     the colorblind-safe hue swap (blue = success) while clearing 4.5:1 */
  --success-oncard: #2563eb;
  --warning-oncard: #92400e;
  --danger-oncard:  #9a3412;
  --purple-oncard:  #7c3aed;
  --turbo-oncard:   #155e75;
  background-image: none;

  /* Token foundation (Phase 1): higher-contrast focus ring for HC mode.
     Spacing/type/z-index/icon scales are identical in HC mode, so no
     overrides are needed for those. */
  --focus-ring: 0 0 0 3px rgba(245, 197, 24, 0.6), 0 0 0 2px #ffffff;
}

/* ---- Disable all glows/pulsing animations in HC ---- */
body.hc-mode .order-card.burning,
body.hc-mode .station.blocked,
body.hc-mode .station.turbo,
body.hc-mode .order-card.card-turbo {
  animation: none;
  box-shadow: none;
}

/* ---- Order cards: thicker, patterned left borders ---- */
body.hc-mode .order-card {
  border-left-width: 5px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.4);
}

body.hc-mode .order-card.card-flag-yellow {
  border-left-color: #d97706;
  border-left-style: solid;
  border-left-width: 6px;
}

body.hc-mode .order-card.card-flag-red {
  border-left-color: #c2410c;
  border-left-style: dashed;
  border-left-width: 6px;
}

body.hc-mode .order-card.card-flag-purple {
  border-left-color: #7c3aed;
  border-left-style: dotted;
  border-left-width: 6px;
}

/* Text label badge for flagged cards */
body.hc-mode .order-card.card-flag-yellow::before,
body.hc-mode .order-card.card-flag-red::before,
body.hc-mode .order-card.card-flag-purple::before {
  content: '';
  display: block;
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  float: right;
  margin: -0.2rem -0.3rem 0.2rem 0.4rem;
  line-height: 1.6;
}

body.hc-mode .order-card.card-flag-yellow::before {
  content: '⚠ WARN';
  background: #d97706;
  color: #000;
}

body.hc-mode .order-card.card-flag-red::before {
  content: '✖ BLOCK';
  background: #c2410c;
  color: #fff;
}

body.hc-mode .order-card.card-flag-purple::before {
  content: '⏸ PAUSE';
  background: #7c3aed;
  color: #fff;
}

/* Burning: striped outline instead of red glow */
body.hc-mode .order-card.burning {
  border: 2px dashed #f97316;
  outline: none;
}

body.hc-mode .order-time.burning {
  color: #f97316;
  font-weight: bold;
}

/* ---- Flag buttons: full opacity + bold in HC ---- */
body.hc-mode .order-flag-btn {
  opacity: 1;
  font-size: 0.9rem;
}

/* ---- Flag options in modal ---- */
body.hc-mode .flag-option {
  border-width: 2px;
}

body.hc-mode .flag-option.active {
  border-width: 3px;
  font-weight: bold;
}

/* ---- Station health: bold borders ---- */
body.hc-mode .station-health.health-ok {
  background: rgba(37, 99, 235, 0.15);
  color: #93c5fd;
  border-bottom-color: rgba(37, 99, 235, 0.4);
  font-weight: bold;
}

body.hc-mode .station-health.health-warn {
  background: rgba(217, 119, 6, 0.2);
  color: #fbbf24;
  border-bottom-color: rgba(217, 119, 6, 0.5);
  font-weight: bold;
}

body.hc-mode .station-health.health-critical {
  background: rgba(234, 88, 12, 0.2);
  color: #fb923c;
  border-bottom-color: rgba(234, 88, 12, 0.5);
  font-weight: bold;
  animation: none;
}

/* ---- Alert bar: strong left border per severity ---- */
body.hc-mode .alert-item {
  border-left: 4px solid transparent;
  padding-left: 0.6rem;
}

body.hc-mode .alert-item.alert-yellow {
  border-left-color: #d97706;
  background: rgba(217, 119, 6, 0.1);
}

body.hc-mode .alert-item.alert-red {
  border-left-color: #ea580c;
  background: rgba(234, 88, 12, 0.1);
}

body.hc-mode .alert-item.alert-purple {
  border-left-color: #7c3aed;
  background: rgba(124, 58, 237, 0.1);
}

/* ---- Turbo countdowns ---- */
body.hc-mode .order-time.turbo-time {
  font-weight: bold;
}

body.hc-mode .order-time.turbo-time.urgent {
  text-decoration: underline;
}

/* ---- Priority badges: text instead of color-only ---- */
body.hc-mode .order-card.priority-high .order-priority-badge {
  border: 1px solid #d97706;
}

body.hc-mode .order-card.priority-urgente .order-priority-badge {
  border: 2px solid #ea580c;
  font-weight: bold;
}

/* ---- Borders and UI chrome ---- */
body.hc-mode .station {
  border-width: 2px;
}

body.hc-mode .station.blocked {
  border: 3px dashed #ea580c;
}

body.hc-mode .btn-blocked.active {
  color: #ea580c;
}

body.hc-mode .btn-turbo.active {
  color: #00aaff;
  font-weight: bold;
}

body.hc-mode .btn-order-turbo.active {
  color: #00aaff;
}

/* ==================== RESPONSIVE ====================
   Breakpoints (Phase 3): ≤600px phone, 601–1024px tablet, >1024px desktop.
   Desktop is the default rule set above and is intentionally untouched here.
   See docs/superpowers/specs/2026-07-03-responsive-accessible-frontend-design.md §2. */

/* ---- Tablet (601px–1024px): columns become a horizontally-scrollable,
   snapping row. Drag-and-drop stays enabled (desktop behavior, unchanged JS). */
@media (max-width: 1024px) and (min-width: 601px) {
  .board {
    scroll-snap-type: x mandatory;
  }

  .station {
    scroll-snap-align: start;
    min-width: 260px;
    max-width: 280px;
  }

  .modal {
    width: 92%;
    max-width: 560px;
  }
}

/* ---- Phone (≤600px): stations stack as a collapsible accordion; drag is
   disabled (guarded in app.js); cards expose a per-card action menu instead
   of the desktop action row ("view + light actions" model). */
@media (max-width: 600px) {
  .header {
    padding: 0.5rem 0.75rem;
  }

  .header-left {
    gap: 0.5rem;
  }

  .logo {
    font-size: 1.1rem;
  }

  .subtitle {
    display: none;
  }

  .header-right {
    width: 100%;
    justify-content: flex-end;
  }

  .burn-setting {
    font-size: 0.65rem;
    padding: 0.25rem 0.5rem;
  }

  .burn-setting input {
    width: 36px;
    font-size: 0.65rem;
  }

  .shift-popover {
    right: auto;
    left: 0;
  }

  .btn {
    font-size: 0.7rem;
    padding: 0.35rem 0.65rem;
  }

  /* Compact header: collapse the secondary icon buttons into the overflow
     menu (their handlers still run — the overflow items proxy to them). */
  .header-overflow {
    display: inline-block;
  }

  #btn-cookbook,
  #btn-glossary,
  #btn-metrics,
  #btn-hc,
  #btn-config {
    display: none;
  }

  /* Heat/alerts summary pinned at the top on phone (most important
     at-a-glance info). Relocated in the DOM to sit just above the board,
     it sticks directly under the sticky header (--header-h set in JS). */
  .alerts-bar {
    position: sticky;
    top: var(--header-h, 56px);
    bottom: auto;
    left: auto;
    right: auto;
    z-index: calc(var(--z-header) - 1);
    border-top: none;
    border-bottom: 2px solid var(--warning);
    max-height: 40vh;
  }

  .board {
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem;
    gap: 0.75rem;
    overflow-x: hidden;
    min-height: 0;
  }

  /* Alerts are pinned at the top on phone, so the desktop bottom reserve
     (110px) is no longer needed. */
  body.has-alerts .board {
    padding-bottom: 0.75rem;
  }

  .station {
    min-width: 0;
    max-width: none;
    width: 100%;
    max-height: none;
  }

  /* Accordion: header (+ heat summary right under it) always visible;
     `.station-body` collapses. Open/closed state is tracked in app.js
     (`openStationIds`) so it survives the board's full re-render. */
  .station-header {
    cursor: pointer;
  }

  .station-accordion-caret {
    display: inline-block;
  }

  .station-toggle[aria-expanded="false"] .station-accordion-caret {
    transform: rotate(-90deg);
  }

  .station[data-collapsed="true"] .station-body {
    display: none;
  }

  .station-body {
    max-height: none;
  }

  /* Drag disabled on phone (app.js stops attaching draggable/drop
     listeners at this breakpoint) — the card menu below is the
     accessible alternative for moving/acting on an order. */
  .order-card {
    cursor: default;
  }

  .order-card-actions {
    display: none;
  }

  .order-card-menu-wrap {
    display: block;
  }

  .modal {
    width: 95%;
    max-width: none;
  }
}

/* ── Signed editing (UI identity) ───────────────────────────── */
.sign-banner {
  padding: 10px 24px;
  background: rgba(250, 204, 21, 0.12);
  border-bottom: 1px solid var(--warning);
  color: var(--text-primary);
  font-size: 0.9rem;
  text-align: center;
}
.sign-banner.hidden { display: none; }

#btn-sign { white-space: nowrap; }

.config-security {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.config-security-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 600;
}
.config-security-toggle input { width: 16px; height: 16px; cursor: pointer; }

/* ── Access lock (lock screen + admin panel) ────────────────── */
.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
}
.lock-screen.hidden { display: none; }
.lock-box {
  width: min(92vw, 380px);
  padding: 36px 32px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
.lock-logo { font-size: 2.6rem; }
.lock-title { margin: 10px 0 4px; font-size: 1.5rem; }
.lock-subtitle { margin: 0 0 22px; color: var(--text-secondary); font-size: 0.95rem; }
.lock-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 1.05rem;
  text-align: center;
  letter-spacing: 0.12em;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
}
.lock-submit { width: 100%; margin-top: 14px; }
.lock-error { margin: 14px 0 0; color: var(--danger); font-size: 0.9rem; }
.lock-error.hidden { display: none; }
.lock-admin-link {
  margin-top: 18px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-decoration: underline;
  cursor: pointer;
}
.lock-admin-link:hover { color: var(--accent-bright); }

.config-access {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.config-access.hidden { display: none; }
.access-code-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.access-code-row input {
  flex: 1 1 160px;
  padding: 9px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
}

.config-project {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.config-project.hidden { display: none; }
.config-project label {
  display: block;
  margin-top: 10px;
  margin-bottom: 4px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.config-project input,
.config-project textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  resize: vertical;
}

/* ── Actor name fields auto-filled from the signed-in key identity ───── */
/* When the user is signed in, their key identity attributes every action, so
   the manual "your name" fields are filled automatically and hidden. */
body.identity-known .actor-field { display: none; }
