/* 
  =========================================
  AAIS Command & Intelligence Simulator CSS
  High-Fidelity dark-mode first design
  =========================================
*/

:root {
  /* Default Dark Theme Variable Palette */
  color-scheme: dark;
  --ink: #e6edf7;
  --ink-pure: #ffffff;
  --muted: #94a3b8;
  --line: #1e293b;
  --panel: rgba(15, 23, 42, 0.7);
  --panel-solid: #0f172a;
  --page: #080c15;
  --nav: #090d16;
  --nav-soft: #1e293b;
  --glass-border: rgba(255, 255, 255, 0.08);
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.5);

  /* Surface elevation steps (clinical dark UI reads better with real depth
     than with glow; each step is a flat, opaque ground you can stack on) */
  --surface-0: #0b1120;
  --surface-1: #111a2e;
  --surface-2: #17233c;
  --surface-3: #1e2c49;
  --hairline: rgba(255, 255, 255, 0.07);
  --hairline-strong: rgba(255, 255, 255, 0.14);

  /* Status Colors — calibrated for legibility on cheap Android screens in
     daylight and for long night shifts, rather than for neon demo impact. */
  --green: #22c55e;
  --green-ink: #4ade80;
  --green-soft: rgba(34, 197, 94, 0.14);
  --amber: #f59e0b;
  --amber-ink: #fbbf24;
  --amber-soft: rgba(245, 158, 11, 0.14);
  --red: #ef4444;
  --red-ink: #f87171;
  --red-soft: rgba(239, 68, 68, 0.14);
  --blue: #3b82f6;
  --blue-ink: #60a5fa;
  --blue-soft: rgba(59, 130, 246, 0.14);
  --violet: #8b5cf6;
  --violet-ink: #a78bfa;
  --violet-soft: rgba(139, 92, 246, 0.14);
  --accent: #38bdf8;
  --accent-ink: #7dd3fc;
  --accent-soft: rgba(56, 189, 248, 0.14);

  /* Accent Glows */
  --glow-green: 0 0 15px rgba(34, 197, 94, 0.3);
  --glow-blue: 0 0 15px rgba(59, 130, 246, 0.3);
  --glow-red: 0 0 15px rgba(239, 68, 68, 0.3);
  --glow-amber: 0 0 15px rgba(245, 158, 11, 0.3);

  /* Typography & Transitions */
  --font-sans: 'Plus Jakarta Sans', ui-sans-serif, system-ui, sans-serif;
  --font-display: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition-fast: 150ms ease;
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Type scale */
  --text-xs: 0.72rem;
  --text-sm: 0.82rem;
  --text-base: 0.94rem;
  --text-lg: 1.08rem;
  --text-xl: 1.3rem;
  --text-2xl: 1.6rem;
  --text-3xl: 2rem;

  /* Spacing scale */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;

  /* Radii + elevation */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-pill: 9999px;
  --elev-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --elev-2: 0 4px 12px rgba(0, 0, 0, 0.35);
  --elev-3: 0 12px 32px rgba(0, 0, 0, 0.45);

  /* Minimum comfortable touch target for gloved hands on a phone */
  --touch: 48px;

  /* Z-index scale */
  --z-sticky: 50;
  --z-overlay: 500;
  --z-toast: 900;
}

/* Light Theme Variable Overrides */
[data-theme="light"] {
  color-scheme: light;
  --ink: #0f172a;
  --ink-pure: #000000;
  --muted: #475569;
  --line: #cbd5e1;
  --panel: rgba(255, 255, 255, 0.85);
  --panel-solid: #ffffff;
  --page: #f1f5f9;
  --nav: #0f172a;
  --nav-soft: #f8fafc;
  --glass-border: rgba(15, 23, 42, 0.08);
  --shadow: 0 20px 40px rgba(15, 23, 42, 0.06);

  --surface-0: #ffffff;
  --surface-1: #f8fafc;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --hairline: rgba(15, 23, 42, 0.1);
  --hairline-strong: rgba(15, 23, 42, 0.2);

  /* Status Colors */
  --green: #16a34a;
  --green-ink: #15803d;
  --green-soft: rgba(22, 163, 74, 0.1);
  --amber: #d97706;
  --amber-ink: #b45309;
  --amber-soft: rgba(217, 119, 6, 0.1);
  --red: #dc2626;
  --red-ink: #b91c1c;
  --red-soft: rgba(220, 38, 38, 0.1);
  --blue: #2563eb;
  --blue-ink: #1d4ed8;
  --blue-soft: rgba(37, 99, 235, 0.1);
  --violet: #7c3aed;
  --violet-ink: #6d28d9;
  --violet-soft: rgba(124, 58, 237, 0.1);
  --accent: #0284c7;
  --accent-ink: #0369a1;
  --accent-soft: rgba(2, 132, 199, 0.1);

  --glow-green: 0 0 10px rgba(22, 163, 74, 0.15);
  --glow-blue: 0 0 10px rgba(37, 99, 235, 0.15);
  --glow-red: 0 0 10px rgba(220, 38, 38, 0.15);
  --glow-amber: 0 0 10px rgba(217, 119, 6, 0.15);

  --elev-1: 0 1px 2px rgba(15, 23, 42, 0.06);
  --elev-2: 0 4px 12px rgba(15, 23, 42, 0.08);
  --elev-3: 0 12px 32px rgba(15, 23, 42, 0.12);
}

/* Global Reset & Base Setup */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--page);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Typography Custom Rules */
h1, h2, h3, h4, h5, h6, .font-display {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Scrollbars styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}

/* Buttons and Inputs */
button {
  font-family: var(--font-sans);
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  outline: none;
}

button:disabled {
  opacity: 0.35;
  cursor: not-allowed !important;
}

.primary-btn {
  background-color: var(--green);
  color: #052e16;
  padding: 10px 20px;
  font-size: 14px;
}
.primary-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--glow-green);
  filter: brightness(1.1);
}

.control-btn {
  background-color: var(--line);
  color: var(--ink);
  border: 1px solid var(--glass-border);
  padding: 8px 16px;
  font-size: 13px;
}
.control-btn:hover:not(:disabled) {
  background-color: var(--nav-soft);
  border-color: var(--muted);
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--muted);
  color: var(--ink);
  padding: 8px 16px;
  font-size: 13px;
}
.ghost-btn:hover:not(:disabled) {
  background-color: rgba(255, 255, 255, 0.05);
  border-color: var(--ink);
}

.mini-ghost-btn {
  font-size: 11px;
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}
.mini-ghost-btn:hover {
  border-color: var(--muted);
  color: var(--ink);
}

.icon-btn {
  width: 38px;
  height: 38px;
  background: var(--line);
  border: 1px solid var(--glass-border);
  border-radius: 50%;
  color: var(--ink);
  font-size: 16px;
}
.icon-btn:hover {
  background: var(--nav-soft);
  transform: scale(1.05);
}

/* ==========================================================================
   1. BRIEFING OVERLAY (PITCH DECK OVERLAY)
   ========================================================================== */
.briefing-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  transition: opacity 500ms ease, visibility 500ms ease;
}

.briefing-overlay.dismissed {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.briefing-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(4, 6, 12, 0.88);
  backdrop-filter: blur(15px);
}

.briefing-content {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 1200px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(9, 13, 26, 0.98) 100%);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8), 0 0 100px rgba(0, 176, 255, 0.05);
  padding: 40px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.briefing-header {
  text-align: center;
  margin-bottom: 40px;
}

.brand-badge {
  display: inline-block;
  background: var(--blue-soft);
  border: 1px solid var(--blue);
  color: var(--blue);
  padding: 4px 12px;
  border-radius: 99px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
  text-shadow: var(--glow-blue);
}

.briefing-header h1 {
  font-size: 38px;
  line-height: 1.1;
  color: var(--ink-pure);
  margin-bottom: 8px;
}

.briefing-header .subtitle {
  font-size: 16px;
  color: var(--muted);
}

.architecture-grid {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 40px;
  align-items: start;
}

.briefing-intro-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 30px;
}

.briefing-intro-card h3 {
  font-size: 22px;
  color: var(--blue);
  margin-bottom: 15px;
}

.briefing-intro-card p {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 15px;
  line-height: 1.6;
}

.briefing-intro-card .subtext {
  font-size: 13px;
  opacity: 0.8;
}

.tech-stack-summary {
  margin-top: 24px;
  margin-bottom: 30px;
  display: grid;
  gap: 10px;
}

.tech-item {
  font-size: 12px;
  font-family: var(--font-mono);
  background: var(--nav);
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--ink);
}

.pulse-glow {
  animation: primaryPulse 2.5s infinite;
  width: 100%;
}

.briefing-flow-diagram {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
}

.briefing-flow-diagram h4 {
  font-size: 14px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.05em;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.flow-steps-grid {
  display: grid;
  gap: 12px;
}

.flow-step {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  align-items: center;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--glass-border);
  padding: 12px 16px;
  border-radius: 10px;
  transition: all var(--transition-fast);
}

.flow-step:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--blue);
  transform: translateX(4px);
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-family: var(--font-display);
}

.step-desc {
  display: flex;
  flex-direction: column;
}

.step-desc strong {
  font-size: 14px;
  color: var(--ink-pure);
}

.step-desc span {
  font-size: 12px;
  color: var(--muted);
}

.flow-step .pill {
  display: inline-block;
  align-self: flex-start;
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 4px;
  margin-right: 6px;
}

.pill.mock {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.pill.prod {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

/* ==========================================================================
   2. MAIN SHELL & BRAND HEADER
   ========================================================================== */
.shell-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
  padding: 12px 24px;
  background-color: var(--nav);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
  font-family: var(--font-display);
  font-weight: 800;
  display: grid;
  place-items: center;
  font-size: 16px;
  letter-spacing: -0.05em;
  text-shadow: var(--glow-blue);
  box-shadow: inset 0 0 10px rgba(0, 176, 255, 0.2);
}

.shell-header h1 {
  font-size: 18px;
  color: var(--ink-pure);
  line-height: 1.2;
}

.shell-header p {
  font-size: 12px;
  color: var(--muted);
}

.nav-tabs {
  display: flex;
  background: var(--line);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
}

.tab-btn {
  padding: 8px 16px;
  font-size: 13px;
  color: var(--muted);
  background: transparent;
  border: none;
  font-weight: 600;
  border-radius: 6px;
}

.tab-btn:hover {
  color: var(--ink);
}

.tab-btn.active {
  background: var(--panel-solid);
  color: var(--ink-pure);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.llm-provider-card {
  min-width: 310px;
  max-width: 430px;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.58);
  padding: 8px 10px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.llm-provider-card.ok {
  border-color: rgba(0, 230, 118, 0.5);
  box-shadow: var(--glow-green);
}

.llm-provider-card.warn {
  border-color: rgba(255, 23, 68, 0.55);
  box-shadow: var(--glow-red);
}

.llm-provider-card.provider-nim.ok,
.llm-provider-card.provider-deepinfra.ok {
  border-color: rgba(0, 176, 255, 0.65);
  box-shadow: var(--glow-blue);
}

.llm-provider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.llm-provider-label {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-pure);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.llm-provider-detail {
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.llm-provider-card.provider-nim .llm-provider-detail,
.llm-provider-card.provider-deepinfra .llm-provider-detail {
  color: var(--blue);
}

.model-status {
  padding: 6px 14px;
  background-color: var(--line);
  border: 1px solid var(--glass-border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  border-radius: 99px;
  font-family: var(--font-mono);
  text-align: center;
  max-width: 250px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.model-status.ok {
  background-color: var(--green-soft);
  color: var(--green);
  border-color: var(--green);
}

.model-status.warn {
  background-color: var(--red-soft);
  color: var(--red);
  border-color: var(--red);
}

/* ==========================================================================
   3. APP SHELL LAYOUT
   ========================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: calc(100vh - 72px);
}

.scenario-rail {
  background-color: var(--nav);
  border-right: 1px solid var(--line);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 72px);
  overflow-y: auto;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-head span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  color: var(--muted);
}

.section-head strong {
  background: var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  color: var(--ink);
}

.scenario-list {
  display: grid;
  gap: 12px;
}

.scenario-card {
  width: 100%;
  padding: 14px;
  background-color: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all var(--transition-fast);
}

.scenario-card:hover {
  background-color: rgba(255, 255, 255, 0.03);
  border-color: var(--muted);
  transform: translateY(-1px);
}

.scenario-card.active {
  background: var(--blue-soft);
  border-color: var(--blue);
  box-shadow: inset 4px 0 0 var(--blue);
}

.scenario-card strong {
  font-size: 13px;
  font-family: var(--font-display);
  color: var(--ink-pure);
}

.scenario-card span {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.scenario-card small {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.scenario-card.active span,
.scenario-card.active small {
  color: var(--ink);
  opacity: 0.9;
}

/* ==========================================================================
   4. WORKSPACE CONTROLS & NARRATION DECK
   ========================================================================== */
.workspace {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(100vh - 72px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.hidden {
  display: none !important;
}

.narration-deck {
  background: var(--panel);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 20px;
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.narration-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  flex-wrap: wrap;
}

.narration-step-indicator {
  display: flex;
  flex-direction: column;
}

#narration-step-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--blue);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-shadow: var(--glow-blue);
}

#narration-step-title {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--ink-pure);
}

.narration-controls {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.autoplay-control {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
}

/* Toggle Switch Styling */
.switch-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}
.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--line);
  transition: .3s;
  border-radius: 24px;
  border: 1px solid var(--glass-border);
}
.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--muted);
  transition: .3s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--green-soft);
  border-color: var(--green);
}
input:checked + .slider:before {
  transform: translateX(20px);
  background-color: var(--green);
  box-shadow: var(--glow-green);
}

.autoplay-speed {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.autoplay-speed input[type="range"] {
  width: 80px;
  height: 4px;
  background: var(--line);
  outline: none;
  border-radius: 2px;
  appearance: none;
}
.autoplay-speed input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--blue);
  cursor: pointer;
}

/* Speed Preset Buttons */
.speed-presets {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.speed-presets .muted {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  margin-right: 2px;
}

.speed-preset-btn {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
  background: var(--line);
  border: 1px solid var(--glass-border);
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.speed-preset-btn:hover {
  color: var(--ink);
  border-color: var(--muted);
  background: var(--nav-soft);
}

/* ⚡ Instant — amber glow */
#speed-instant.active,
#speed-instant:focus {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: var(--amber);
  box-shadow: 0 0 8px rgba(255, 171, 0, 0.3);
}

/* 🚀 Fast — blue glow */
#speed-fast.active,
#speed-fast:focus {
  background: var(--blue-soft);
  border-color: var(--blue);
  color: var(--blue);
  box-shadow: 0 0 8px rgba(0, 176, 255, 0.3);
}

/* 📖 Detailed — green glow */
#speed-detailed.active,
#speed-detailed:focus {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green);
  box-shadow: 0 0 8px rgba(0, 230, 118, 0.3);
}

.narration-body {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 20px;
}

.narrator-bubble,
.narrator-impact-bubble {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 16px;
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--line);
  padding: 16px;
  border-radius: 12px;
}

.narrator-icon,
.impact-icon {
  font-size: 24px;
  width: 44px;
  height: 44px;
  background: var(--line);
  border-radius: 10px;
  display: grid;
  place-items: center;
  border: 1px solid var(--glass-border);
}

.narrator-icon {
  color: var(--blue);
  box-shadow: var(--glow-blue);
  border-color: var(--blue-soft);
}
.impact-icon {
  color: var(--amber);
  box-shadow: var(--glow-amber);
  border-color: var(--amber-soft);
}

.eyebrow-accent {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 4px;
}

.narrator-text,
.narrator-impact {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink);
}

.narrator-text {
  font-family: var(--font-sans);
}

/* Auto advance pulse text styling */
.typewriter-cursor::after {
  content: "▋";
  animation: cursorBlink 1s step-end infinite;
  color: var(--blue);
  margin-left: 2px;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ==========================================================================
   5. DATA FLOW PIPELINE STRIP
   ========================================================================== */
.data-flow-strip {
  background: var(--panel);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 16px 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.flow-nodes {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.flow-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  z-index: 2;
  transition: all var(--transition-normal);
  text-align: center;
  flex-shrink: 0;
  width: 110px;
}

.flow-node .node-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--line);
  border: 2px solid var(--glass-border);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 18px;
  transition: all var(--transition-normal);
}

.flow-node .node-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  transition: all var(--transition-normal);
}

.flow-node .node-status {
  font-family: var(--font-mono);
  font-size: 9px;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--line);
  padding: 2px 6px;
  border-radius: 99px;
  transition: all var(--transition-normal);
}

/* Connective Pipeline flow lines */
.flow-line {
  flex-grow: 1;
  height: 3px;
  background-color: var(--line);
  margin: 0 -15px;
  position: relative;
  z-index: 1;
  overflow: hidden;
}

.flow-pulse {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, var(--blue), transparent);
  transform: translateX(-100%);
}

/* Active Node States */
.flow-node.active .node-icon {
  background: var(--blue-soft);
  border-color: var(--blue);
  color: var(--blue);
  transform: scale(1.1);
  box-shadow: var(--glow-blue);
}
.flow-node.active .node-label {
  color: var(--ink-pure);
}
.flow-node.active .node-status {
  background: var(--blue);
  color: #000;
}
.flow-node.active + .flow-line .flow-pulse {
  animation: pipelineFlow 2s linear infinite;
}

/* Completed Node States */
.flow-node.complete .node-icon {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green);
  box-shadow: var(--glow-green);
}
.flow-node.complete .node-label {
  color: var(--ink);
}
.flow-node.complete .node-status {
  background: var(--green-soft);
  color: var(--green);
}

/* Failed/Alert State */
.flow-node.paused .node-icon {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: var(--amber);
  box-shadow: var(--glow-amber);
  animation: alertPulse 1.5s infinite;
}
.flow-node.paused .node-status {
  background: var(--amber);
  color: #000;
}

@keyframes pipelineFlow {
  from { transform: translateX(-100%); }
  to { transform: translateX(250%); }
}

@keyframes alertPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* ==========================================================================
   6. OPS METRIC STRIP
   ========================================================================== */
.ops-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.metric:hover {
  transform: translateY(-2px);
  border-color: var(--line);
}

.metric span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  display: block;
}

.metric strong {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--ink-pure);
  display: block;
  margin-top: 6px;
}

.metric.live {
  border-color: var(--blue-soft);
}
.metric.live strong {
  color: var(--blue);
  text-shadow: var(--glow-blue);
  animation: metricPulse 2s ease-in-out infinite;
}

@keyframes metricPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

/* ==========================================================================
   7. MAIN PANELS & TACTICAL GIS MAPS
   ========================================================================== */
.main-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 20px;
  align-items: start;
}

.col-visuals,
.col-intelligence {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.panel-header,
.panel-header-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 16px;
}

.panel-title h2 {
  font-size: 16px;
  color: var(--ink-pure);
}

.panel-title span {
  font-size: 12px;
  color: var(--muted);
  display: block;
}

/* Dynamic Map Wrapper */
.map-container-wrapper {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.4);
}

.leaflet-map-element {
  height: 480px;
  width: 100%;
  z-index: 10;
}

/* TACTICAL DARK THEME FOR LEAFLET TILES */
[data-theme="dark"] .leaflet-tile-container {
  filter: invert(100%) hue-rotate(180deg) brightness(85%) contrast(90%);
}

.leaflet-container {
  background: var(--page) !important;
}

/* Custom Tactical Glassmorphic Leaflet Popups */
.leaflet-popup-content-wrapper {
  background: rgba(9, 13, 26, 0.92) !important;
  border: 1px solid var(--glass-border) !important;
  color: var(--ink) !important;
  backdrop-filter: blur(10px);
  border-radius: 8px !important;
  box-shadow: var(--shadow) !important;
}

.leaflet-popup-tip {
  background: rgba(9, 13, 26, 0.92) !important;
  border-left: 1px solid var(--glass-border) !important;
  border-bottom: 1px solid var(--glass-border) !important;
}

.leaflet-popup-content h4 {
  color: var(--ink-pure) !important;
  font-size: 13px !important;
  font-weight: 700 !important;
  margin-bottom: 4px !important;
}

.leaflet-popup-content p {
  font-size: 11px !important;
  color: var(--muted) !important;
  margin: 0 !important;
}

/* Leaflet control button re-theme */
.leaflet-bar a {
  background-color: var(--panel-solid) !important;
  color: var(--ink) !important;
  border-bottom: 1px solid var(--line) !important;
}
.leaflet-bar a:hover {
  background-color: var(--line) !important;
  color: var(--ink-pure) !important;
}

/* Sub-telemetry panels layout (Ambulance Fleet + Hospital Load) */
.grid-sub-telemetry {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Hospital load cards grid */
.hospital-grid {
  display: grid;
  gap: 12px;
  max-height: 250px;
  overflow-y: auto;
}

.hospital-card {
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hospital-card strong {
  font-size: 12.5px;
  color: var(--ink-pure);
}

.hospital-card span {
  font-size: 11px;
  color: var(--muted);
}

.load-track {
  width: 100%;
  height: 6px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 4px;
  margin-bottom: 2px;
}

.load-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  transition: width 1s ease-in-out;
}
.load-fill.low { background-color: var(--green); }
.load-fill.medium { background-color: var(--amber); }
.load-fill.high { background-color: var(--red); }

/* Ambulance fleet cards */
.fleet-list {
  display: grid;
  gap: 12px;
  max-height: 250px;
  overflow-y: auto;
}

.fleet-card {
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--line);
  padding: 10px 14px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: all var(--transition-fast);
}

.fleet-card:hover {
  background: rgba(255, 255, 255, 0.03);
}

.fleet-card.active {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.fleet-card.active.en_route {
  border-color: var(--green);
  background: var(--green-soft);
}

.fleet-card div {
  display: flex;
  flex-direction: column;
}

.fleet-card strong {
  font-size: 12.5px;
  color: var(--ink-pure);
}

.fleet-card span {
  font-size: 11px;
  color: var(--muted);
}

.fleet-card em {
  font-size: 10px;
  font-weight: 700;
  color: var(--blue);
  font-style: normal;
  margin-top: 2px;
}
.fleet-card.en_route em {
  color: var(--green);
}

.status-chip {
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--line);
  color: var(--muted);
}

.status-chip.available {
  background: var(--green-soft);
  color: var(--green);
}
.status-chip.assigned {
  background: var(--amber-soft);
  color: var(--amber);
}
.status-chip.en_route {
  background: var(--green);
  color: #000;
}
.status-chip.at_hospital {
  background: var(--blue-soft);
  color: var(--blue);
}
.status-chip.offline {
  background: var(--line);
  color: var(--muted);
}

/* ==========================================================================
   8. CLINICAL PATIENT FILE & VITALS GAUGES
   ========================================================================== */
.patient-id-card-wrapper {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

.patient-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.patient-header-details h3 {
  font-size: 18px;
  color: var(--ink-pure);
}

.patient-id-badges {
  display: flex;
  gap: 8px;
}

.patient-id-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--nav);
  color: var(--ink);
}

.complaint-box {
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.01);
  border-left: 3px solid var(--blue);
  padding: 8px 12px;
  border-radius: 0 8px 8px 0;
}

.complaint-box h4 {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.complaint-box p {
  font-size: 13.5px;
  color: var(--ink);
}

/* Custom Simulated Medical Gauges for Vitals */
.vitals-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.vital-card {
  background: var(--nav);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.vital-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.vital-value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink-pure);
  margin: 4px 0;
}

/* Vitals gauge bar inside card */
.vital-bar {
  width: 100%;
  height: 4px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}
.vital-bar-fill {
  height: 100%;
  background: var(--green);
  width: 0%;
  transition: width 1.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.vital-card.critical .vital-value {
  color: var(--red);
  text-shadow: var(--glow-red);
}
.vital-card.critical .vital-bar-fill {
  background: var(--red);
}

.vital-card.warning .vital-value {
  color: var(--amber);
  text-shadow: var(--glow-amber);
}
.vital-card.warning .vital-bar-fill {
  background: var(--amber);
}

/* AI Triage response display */
.triage-output-box {
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.triage-output-box h4 {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}

.triage-badge-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.triage-pill {
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--line);
  color: var(--ink);
}

.triage-pill.acuity-red { background-color: var(--red-soft); color: var(--red); border: 1px solid var(--red); }
.triage-pill.acuity-orange { background-color: var(--amber-soft); color: var(--amber); border: 1px solid var(--amber); }
.triage-pill.acuity-yellow { background-color: rgba(234, 179, 8, 0.15); color: #eab308; border: 1px solid rgba(234, 179, 8, 0.3); }
.triage-pill.acuity-green { background-color: var(--green-soft); color: var(--green); border: 1px solid var(--green); }

.triage-pill.capability {
  background-color: var(--blue-soft);
  color: var(--blue);
  border: 1px solid rgba(0, 176, 255, 0.3);
}

.triage-summary-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
}

.triage-rationale-text {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  font-style: italic;
  padding-left: 8px;
  border-left: 2px solid var(--line);
}

.confidence-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--muted);
  background: var(--nav);
  padding: 6px 10px;
  border-radius: 6px;
}

.confidence-indicator strong {
  color: var(--blue);
}

/* ==========================================================================
   9. DETERMINISTIC ROUTING PANEL
   ========================================================================== */
.routing-explainer {
  background: var(--nav);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  transition: max-height var(--transition-normal);
}

.explainer-inner h4 {
  font-size: 13px;
  color: var(--ink-pure);
  margin-bottom: 6px;
}

.weights-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 11px;
}

.weights-table th,
.weights-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}

.weights-table th {
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
}

.weights-table td strong {
  color: var(--ink-pure);
}

/* Score bar rows inside recommendation list */
.ranking-list {
  display: grid;
  gap: 14px;
}

.ranking-card {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all var(--transition-normal);
}

/* First place glow visual */
.ranking-card:first-child:not(.blocked) {
  border-color: var(--green);
  box-shadow: var(--glow-green);
  background: linear-gradient(135deg, var(--green-soft) 0%, rgba(255, 255, 255, 0.01) 100%);
}

.ranking-card.blocked {
  opacity: 0.5;
  border-color: var(--line);
  background: rgba(0, 0, 0, 0.2);
}

.ranking-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.ranking-top strong {
  font-size: 14px;
  color: var(--ink-pure);
  font-family: var(--font-display);
}

.ranking-top span {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.ranking-top .score {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  padding: 4px 10px;
  background: var(--blue-soft);
  color: var(--blue);
  border-radius: 6px;
  border: 1px solid rgba(0, 176, 255, 0.2);
}

.ranking-card:first-child:not(.blocked) .score {
  background: var(--green);
  color: #000;
  border-color: transparent;
  box-shadow: var(--glow-green);
}

.ranking-card.blocked .score {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid var(--red);
}

.score-bars {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.bar-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 9px;
  font-family: var(--font-mono);
  color: var(--muted);
}

.bar-track {
  height: 4px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--blue);
  width: 0%;
  transition: width 1s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.ranking-card:first-child:not(.blocked) .bar-fill {
  background: var(--green);
}

.bar-row span:last-child {
  align-self: flex-end;
}

.ranking-card .muted {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--muted);
}

.blocked-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--red);
  background: var(--red-soft);
  border: 1px solid var(--red);
  padding: 1px 6px;
  border-radius: 4px;
  margin-top: 4px;
}

/* ==========================================================================
   10. PRE-ALERT & EHR HANDOVER SBAR VISUAL DOCUMENTS
   ========================================================================== */
.alert-handover-workspace {
  display: grid;
  gap: 20px;
  margin-top: 12px;
}

.document-display-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.005);
  overflow: hidden;
  transition: all var(--transition-normal);
}

.doc-header {
  background: var(--line);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.doc-badge {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--ink-pure);
}

.doc-status {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--panel-solid);
  color: var(--muted);
}

.doc-content {
  padding: 16px;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.placeholder-text {
  text-align: center;
  font-size: 12px;
  max-width: 80%;
  line-height: 1.5;
}

.document-text {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink);
  white-space: pre-wrap;
  align-self: flex-start;
  text-align: left;
}

/* Pre-alert message layout */
.clinical-alert-box {
  background: rgba(0, 176, 255, 0.015);
  border: 1px dashed var(--blue);
  padding: 14px;
  border-radius: 8px;
  color: var(--ink);
  box-shadow: inset 0 0 10px rgba(0, 176, 255, 0.05);
}

/* SBAR Paper Printout Layout (Official EHR Style) */
.clinical-handover-box {
  background: var(--panel-solid);
  border: 1px solid var(--muted);
  padding: 20px;
  border-radius: 4px;
  color: #1e293b;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  position: relative;
  /* Printout color overrides (forces paper look) */
  background-color: #fafafa !important;
  color: #0f172a !important;
}

/* Dark mode specific style to preserve readability */
.clinical-handover-box h5 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  border-bottom: 1.5px solid #0f172a;
  padding-bottom: 3px;
  margin-top: 10px;
  margin-bottom: 6px;
  color: #0f172a;
  text-transform: uppercase;
}

.clinical-handover-box .sbar-header {
  border-bottom: 2px solid #0f172a;
  padding-bottom: 8px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.clinical-handover-box .sbar-header h4 {
  font-size: 14px;
  color: #0f172a;
}

.clinical-handover-box .sbar-header span {
  font-size: 10px;
  color: #64748b;
}

.clinical-handover-box .sbar-footer {
  border-top: 1px dashed #cbd5e1;
  padding-top: 8px;
  margin-top: 14px;
  font-size: 9px;
  color: #64748b;
  display: flex;
  justify-content: space-between;
}

/* Pre-alert active styles */
.document-display-card.alert-active {
  border-color: var(--blue);
  box-shadow: var(--glow-blue);
}
.document-display-card.alert-active .doc-header {
  background-color: var(--blue-soft);
}
.document-display-card.alert-active #pre-alert-status-badge {
  background-color: var(--blue);
  color: #000;
}

/* Handover active styles */
.document-display-card.handover-active {
  border-color: var(--green);
  box-shadow: var(--glow-green);
}
.document-display-card.handover-active .doc-header {
  background-color: var(--green-soft);
}
.document-display-card.handover-active #handover-status-badge {
  background-color: var(--green);
  color: #052e16;
}

/* ==========================================================================
   11. COMMAND AUDIT LOG TIMELINE
   ========================================================================== */
.timeline-panel {
  grid-column: 1 / -1;
}

.timeline {
  max-height: 200px;
  overflow-y: auto;
  display: grid;
  gap: 8px;
  padding-right: 4px;
}

.event-row {
  display: grid;
  grid-template-columns: 100px 180px 1fr;
  gap: 12px;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  align-items: center;
}

.event-row time {
  font-family: var(--font-mono);
  color: var(--muted);
}

.event-row code {
  font-family: var(--font-mono);
  color: var(--blue);
  font-weight: 600;
}

.event-row span {
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   12. PRODUCTION ROADMAP PANEL
   ========================================================================== */
.roadmap-header {
  text-align: center;
  margin-bottom: 30px;
}

.roadmap-header h2 {
  font-size: 32px;
  color: var(--ink-pure);
  margin-bottom: 8px;
}

.roadmap-header .subtitle {
  font-size: 15px;
  color: var(--muted);
}

.roadmap-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.roadmap-card {
  background: var(--panel);
  border: 1px solid var(--glass-border);
  padding: 30px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  backdrop-filter: blur(12px);
  transition: all var(--transition-fast);
}

.roadmap-card:hover {
  transform: translateY(-2px);
  border-color: var(--blue);
  box-shadow: 0 20px 45px rgba(0, 176, 255, 0.05);
}

.roadmap-card .card-icon {
  font-size: 32px;
  width: 54px;
  height: 54px;
  background: var(--line);
  border-radius: 12px;
  display: grid;
  place-items: center;
  border: 1px solid var(--glass-border);
}

.roadmap-card h3 {
  font-size: 18px;
  color: var(--ink-pure);
}

.roadmap-badge-comparison {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.roadmap-badge-comparison .badge-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 4px;
}

.roadmap-badge-comparison .badge-arrow {
  color: var(--muted);
  font-weight: 700;
}

.roadmap-card p {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.6;
}

/* ==========================================================================
   13. TOAST MESSAGES & UTILITIES
   ========================================================================== */
.toast-stack {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10000;
  display: grid;
  gap: 10px;
  width: min(380px, calc(100vw - 48px));
}

/* Standalone toast (scan / bedboard / specialist / ambulance pages).
   Hidden until JS adds .show, and anchored bottom-centre above the safe-area
   inset so it can never sit on top of a primary action button on a phone.
   NOTE: no `animation` here - an animation with `both` fill would pin
   opacity to its end value and defeat the hidden state. The stacked toasts
   built by app.js re-enable the animation below. */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 12px);
  width: max-content;
  max-width: min(420px, calc(100vw - 32px));
  z-index: var(--z-toast);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast), visibility var(--transition-fast);
  background: var(--surface-2);
  border: 1px solid var(--hairline-strong);
  border-left: 4px solid var(--accent);
  color: var(--ink);
  padding: 12px 16px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--elev-3);
  backdrop-filter: blur(10px);
}

.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

/* Toasts injected into the stack by app.js flow in normal document order and
   animate in; they are always visible while present in the DOM. */
.toast-stack .toast {
  position: static;
  width: auto;
  max-width: none;
  opacity: 1;
  visibility: visible;
  transform: none;
  animation: toastIn 300ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.toast.warn {
  border-left-color: var(--amber);
}

.toast.ok {
  border-left-color: var(--green);
}

.toast.danger {
  border-left-color: var(--red);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes primaryPulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.4); }
  70% { box-shadow: 0 0 0 12px rgba(0, 230, 118, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 230, 118, 0); }
}

/* ==========================================================================
   14. RESPONSIVE BREAKPOINTS
   ========================================================================== */
@media (max-width: 1280px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .scenario-rail {
    max-height: 250px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .scenario-list {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

@media (max-width: 1024px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
  .roadmap-grid {
    grid-template-columns: 1fr;
  }
  .narration-body {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   15. SHARED OPERATIONAL UI KIT
   Used by every non-briefing surface (bedside scanner, nurse bed-board,
   specialist check-in, paramedic CAD, ER inbound monitor). These screens are
   used one-handed on a phone, often at night, sometimes with gloves - so the
   kit favours large targets, flat legible surfaces and unambiguous status
   colour over decoration.
   ========================================================================== */

/* --- Accessibility: the global `button { outline: none }` above removes the
   focus ring, so every interactive element gets a visible one back here. --- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* --- Page shell --- */
.page-shell {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-4) var(--sp-7);
}

.page-shell.narrow {
  max-width: 560px;
}

.page-head {
  margin-bottom: var(--sp-5);
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--ink-pure);
  letter-spacing: -0.02em;
  margin: 0;
}

.page-sub {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: var(--sp-1);
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin: var(--sp-6) 0 var(--sp-3);
}

.section-title h2 {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.section-title .hint {
  font-size: var(--text-xs);
  color: var(--muted);
}

/* --- Navigation chips (previously defined only inside bedboard.html, which
   left every other page rendering them as bare underlined links) --- */
.app-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
}

.nav-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--surface-1);
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 0 var(--sp-3);
  min-height: 38px;
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: color var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast);
}

.nav-chip:hover {
  color: var(--ink);
  background: var(--surface-2);
  border-color: var(--hairline-strong);
}

.nav-chip.active {
  color: var(--ink-pure);
  background: var(--blue);
  border-color: var(--blue-ink);
}

/* On a phone the nav is secondary to the task - let it scroll on one line
   instead of consuming three rows above the content that matters. */
@media (max-width: 640px) {
  .app-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-inline: calc(var(--sp-4) * -1);
    padding-inline: var(--sp-4);
  }
  .app-nav::-webkit-scrollbar {
    display: none;
  }
}

/* --- Surfaces --- */
.surface {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--elev-2);
}

.surface.flush {
  padding: 0;
  overflow: hidden;
}

.surface-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.surface-head h3 {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 42px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--hairline-strong);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  transition: filter var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.btn:hover:not(:disabled) {
  background: var(--surface-3);
  border-color: var(--muted);
}

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

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06121e;
}

.btn--primary:hover:not(:disabled) {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
}

.btn--ok {
  background: var(--green);
  border-color: var(--green);
  color: #052e16;
}

.btn--ok:hover:not(:disabled) {
  background: var(--green-ink);
  border-color: var(--green-ink);
}

.btn--warn {
  background: var(--amber);
  border-color: var(--amber);
  color: #2a1a02;
}

.btn--warn:hover:not(:disabled) {
  background: var(--amber-ink);
  border-color: var(--amber-ink);
}

.btn--danger {
  background: var(--red);
  border-color: var(--red);
  color: #2b0707;
}

.btn--danger:hover:not(:disabled) {
  background: var(--red-ink);
  border-color: var(--red-ink);
}

.btn--info {
  background: var(--blue);
  border-color: var(--blue);
  color: #06101f;
}

.btn--info:hover:not(:disabled) {
  background: var(--blue-ink);
  border-color: var(--blue-ink);
}

.btn--ghost {
  background: transparent;
  border-color: var(--hairline-strong);
  color: var(--muted);
}

.btn--ghost:hover:not(:disabled) {
  color: var(--ink);
  background: var(--surface-1);
}

.btn--quiet {
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  font-size: var(--text-xs);
  font-weight: 600;
  min-height: auto;
  padding: var(--sp-1);
  white-space: nowrap;
  flex: none;
}

.btn--quiet:hover:not(:disabled) {
  color: var(--ink);
  background: none;
}

.btn--lg {
  min-height: var(--touch);
  font-size: var(--text-base);
  padding: 0 var(--sp-5);
}

.btn--block {
  width: 100%;
}

/* Task rows: the large one-tap actions on the bedside and specialist screens.
   Deliberately NOT four saturated fills - colour on this product belongs to
   *state* (what the bed or specialist currently is), so an action only
   carries a colour accent hinting at the state it will produce. Calmer to
   scan at 3am and it keeps the status banner as the loudest thing on screen. */
.task-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  width: 100%;
  min-height: 60px;
  padding: 0 var(--sp-4);
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-left: 4px solid var(--muted);
  border-radius: var(--r-md);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 700;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.task-row:hover:not(:disabled) {
  background: var(--surface-3);
}

.task-row:active:not(:disabled) {
  transform: translateY(1px);
}

.task-row .task-hint {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.task-row.is-current {
  border-color: var(--hairline-strong);
  background: var(--surface-3);
  cursor: default;
}

.task-row.is-current .task-hint::after {
  content: " · current";
}

.task-row.tone-ok { border-left-color: var(--green); }
.task-row.tone-ok .task-label { color: var(--green-ink); }
.task-row.tone-warn { border-left-color: var(--amber); }
.task-row.tone-warn .task-label { color: var(--amber-ink); }
.task-row.tone-danger { border-left-color: var(--red); }
.task-row.tone-danger .task-label { color: var(--red-ink); }
.task-row.tone-info { border-left-color: var(--blue); }
.task-row.tone-info .task-label { color: var(--blue-ink); }
.task-row.tone-idle { border-left-color: var(--muted); }
.task-row.tone-idle .task-label { color: var(--muted); }

.btn-stack {
  display: grid;
  gap: var(--sp-3);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

/* --- Form controls --- */
.field {
  display: block;
  margin-bottom: var(--sp-4);
}

.field-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: var(--sp-2);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 44px;
  background: var(--surface-0);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-sm);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  padding: var(--sp-2) var(--sp-3);
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--muted);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}

.input--mono {
  font-family: var(--font-mono);
}

/* Numeric entry (PINs, vitals) reads better monospaced and spaced out. */
.input--code {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  letter-spacing: 0.3em;
  text-align: center;
  min-height: var(--touch);
}

/* --- Status pills --- */
.state-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  border-radius: var(--r-pill);
  padding: 0.22rem 0.6rem;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-3);
  color: var(--muted);
  white-space: nowrap;
}

.state-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.state-pill.is-ok { background: var(--green-soft); color: var(--green-ink); }
.state-pill.is-warn { background: var(--amber-soft); color: var(--amber-ink); }
.state-pill.is-danger { background: var(--red-soft); color: var(--red-ink); }
.state-pill.is-info { background: var(--blue-soft); color: var(--blue-ink); }
.state-pill.is-idle { background: var(--surface-3); color: var(--muted); }

/* --- Status banner (current state of the thing on screen) --- */
.status-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  font-weight: 700;
  font-size: var(--text-sm);
}

.status-banner .status-banner-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.status-banner .status-banner-value {
  font-size: var(--text-base);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-banner.is-ok { background: var(--green-soft); border-color: var(--green); color: var(--green-ink); }
.status-banner.is-warn { background: var(--amber-soft); border-color: var(--amber); color: var(--amber-ink); }
.status-banner.is-danger { background: var(--red-soft); border-color: var(--red); color: var(--red-ink); }
.status-banner.is-info { background: var(--blue-soft); border-color: var(--blue); color: var(--blue-ink); }
.status-banner.is-idle { background: var(--surface-2); border-color: var(--hairline-strong); color: var(--muted); }

/* --- Stat tiles --- */
.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.stat {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-pill);
  padding: 0.35rem 0.85rem;
  font-size: var(--text-sm);
  color: var(--muted);
}

.stat strong {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--accent-ink);
  font-variant-numeric: tabular-nums;
}

.stat.is-critical strong { color: var(--red-ink); }
.stat.is-warn strong { color: var(--amber-ink); }
.stat.is-ok strong { color: var(--green-ink); }

/* --- Identity / meta rows --- */
.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.meta-name {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--ink-pure);
  letter-spacing: -0.01em;
}

.meta-sub {
  font-size: var(--text-sm);
  color: var(--muted);
}

.code-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--surface-0);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 0.3rem 0.7rem;
  border-radius: var(--r-sm);
  border: 1px solid var(--hairline-strong);
}

/* --- Tag list (equipment, capabilities) --- */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.tag {
  font-size: var(--text-xs);
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  padding: 0.15rem 0.45rem;
  color: var(--muted);
  text-transform: capitalize;
}

/* --- Feedback states: loading / empty / error ---
   Every async list previously rendered a bare "Loading..." paragraph and
   nothing at all on failure, which reads as a broken page on a slow phone
   connection. */
.skeleton {
  background: linear-gradient(90deg, var(--surface-1) 25%, var(--surface-2) 37%, var(--surface-1) 63%);
  background-size: 400% 100%;
  animation: skeletonShimmer 1.4s ease infinite;
  border-radius: var(--r-md);
}

.skeleton-card {
  height: 132px;
}

.skeleton-line {
  height: 12px;
  margin-bottom: var(--sp-2);
}

@keyframes skeletonShimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--sp-6) var(--sp-4);
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--r-lg);
  background: var(--surface-1);
}

.empty-state .empty-icon {
  font-size: 1.8rem;
  margin-bottom: var(--sp-2);
}

.empty-state h4 {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 var(--sp-1);
}

.empty-state p {
  font-size: var(--text-sm);
  color: var(--muted);
  margin: 0 auto;
  max-width: 42ch;
}

.empty-state.is-error {
  border-color: var(--red);
  background: var(--red-soft);
}

.empty-state.is-error h4 {
  color: var(--red-ink);
}

/* --- Connection indicator for the SSE-backed live screens --- */
.live-dot {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.live-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}

.live-dot.is-live {
  color: var(--green-ink);
}

.live-dot.is-live::before {
  background: var(--green);
  box-shadow: 0 0 0 0 var(--green-soft);
  animation: livePulse 2.4s ease-out infinite;
}

.live-dot.is-down {
  color: var(--amber-ink);
}

.live-dot.is-down::before {
  background: var(--amber);
}

@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* --- Card grids shared by the bed board and roster views --- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--sp-3);
}

.card-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

/* --- Bed card. Shared by the nurse bed-board and the simulation studio, so
   it lives here rather than inside one page's <style> block. The left border
   carries the state so a board stays readable across a room. --- */
.bed-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--sp-3);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-left: 5px solid var(--muted);
  border-radius: var(--r-md);
  padding: var(--sp-4);
}

.bed-card.status-available { border-left-color: var(--green); }
.bed-card.status-occupied { border-left-color: var(--red); }
.bed-card.status-cleaning { border-left-color: var(--amber); }
.bed-card.status-reserved { border-left-color: var(--blue); }

/* --- Modal / gate overlay --- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 9, 19, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  z-index: var(--z-overlay);
}

.overlay[hidden] {
  display: none;
}

.overlay-card {
  background: var(--surface-1);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  width: 100%;
  max-width: 360px;
  box-shadow: var(--elev-3);
  text-align: center;
}

.overlay-card h2 {
  font-size: var(--text-lg);
  margin: 0 0 var(--sp-1);
  color: var(--ink-pure);
}

.overlay-card p {
  font-size: var(--text-sm);
  color: var(--muted);
  margin: 0 0 var(--sp-4);
}

.form-error {
  color: var(--red-ink);
  font-size: var(--text-sm);
  font-weight: 600;
  min-height: 1.2rem;
  margin-bottom: var(--sp-2);
}

/* --- Utilities --- */
.tabular { font-variant-numeric: tabular-nums; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .page-shell {
    padding: var(--sp-3) var(--sp-4) var(--sp-7);
  }
  .surface {
    padding: var(--sp-4);
  }
  .page-title {
    font-size: var(--text-xl);
  }
  .card-grid,
  .card-grid.compact {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .shell-header {
    flex-direction: column;
    align-items: stretch;
    height: auto;
    padding: 16px;
  }
  .header-actions {
    justify-content: space-between;
  }
  .ops-strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid-sub-telemetry {
    grid-template-columns: 1fr;
  }
  .event-row {
    grid-template-columns: auto 1fr;
  }
  .event-row code {
    grid-column: 1 / -1;
  }
  .vitals-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
