/* ============================================================
   Satisfactory Train Throughput & Logistics Calculator
   Design System — Elevated Sci-Fi / Industrial Theme
   ============================================================ */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&family=Outfit:wght@400;500;600;700;800;900&display=swap');

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Core Palette — FICSIT Industrial Deep Theme */
  --bg-deep: #080A10;
  --bg-base: #0E1219;
  --bg-surface: #151B28;
  --bg-elevated: #1E2636;
  --bg-card: rgba(18, 22, 32, 0.75);
  --bg-input: rgba(8, 10, 16, 0.9);

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-focus: #FF8C1A;
  --border-glow: rgba(255, 140, 26, 0.4);
  --border-glow-cyan: rgba(50, 215, 255, 0.4);

  /* FICSIT Accent Colors */
  --ficsit-orange: #FF8C1A;
  --ficsit-amber: #FFB84D;
  --blueprint-blue: #3b82f6;
  --cyber-cyan: #32D7FF;
  --success: #7CFF8A;
  --success-bg: rgba(124, 255, 138, 0.12);
  --warning: #FFD44D;
  --warning-bg: rgba(255, 212, 77, 0.12);
  --danger: #FF6262;
  --danger-bg: rgba(255, 98, 98, 0.12);
  --info: #32D7FF;

  /* Industrial Glow & Metal Tokens */
  --glow-orange: rgba(255, 140, 26, 0.15);
  --glow-cyan: rgba(50, 215, 255, 0.15);
  --glow-green: rgba(124, 255, 138, 0.15);
  --glow-red: rgba(255, 98, 98, 0.15);
  --glow-amber: rgba(255, 212, 77, 0.15);
  --metal-highlight: rgba(255, 255, 255, 0.06);
  --metal-shadow: rgba(0, 0, 0, 0.4);

  /* Text */
  --text-primary: #F3F4F6;
  --text-secondary: #9CA3AF;
  --text-tertiary: #6B7280;
  --text-accent: #FFB84D;
  --text-mono: #32D7FF;

  /* Typography */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-display: 'Outfit', sans-serif;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-float: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 4px 12px -2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.5);
  --shadow-inset: inset 0 2px 8px rgba(0, 0, 0, 0.6);
  --shadow-glow-orange: 0 0 15px rgba(255, 140, 26, 0.3);
  --shadow-glow-cyan: 0 0 15px rgba(50, 215, 255, 0.3);

  /* Transitions */
  --transition-all: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-glow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 16px;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ============================================================
   SEAMLESS PAGE TRANSITIONS (Optimized)
   ============================================================ */
/* We animate the containers, keeping the FICSIT background visible */
.app-container, .guide-container {
  transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1), transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

body.page-enter .app-container,
body.page-enter .guide-container {
  opacity: 0;
  transform: translateY(15px);
}

body.page-enter-active .app-container,
body.page-enter-active .guide-container {
  opacity: 1;
  transform: translateY(0);
}

body.page-exit .app-container,
body.page-exit .guide-container {
  opacity: 0;
  transform: translateY(-15px);
  pointer-events: none;
}

/* FICSIT Industrial Blueprint Grid Background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 0% 0%, rgba(50, 215, 255, 0.04) 0%, transparent 40%),
    radial-gradient(ellipse at 100% 100%, rgba(255, 140, 26, 0.03) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(15, 23, 42, 0.8) 0%, var(--bg-deep) 100%),
    repeating-linear-gradient(0deg,
      transparent,
      transparent 50px,
      rgba(50, 215, 255, 0.035) 50px,
      rgba(50, 215, 255, 0.035) 51px),
    repeating-linear-gradient(90deg,
      transparent,
      transparent 50px,
      rgba(50, 215, 255, 0.035) 50px,
      rgba(50, 215, 255, 0.035) 51px);
  pointer-events: none;
  z-index: 0;
}

/* Slow FICSIT Scanline Sweep */
body::after {
  content: '';
  position: fixed;
  left: 0;
  right: 0;
  height: 200px;
  background: linear-gradient(180deg,
      transparent 0%,
      rgba(50, 215, 255, 0.025) 40%,
      rgba(50, 215, 255, 0.04) 50%,
      rgba(50, 215, 255, 0.025) 60%,
      transparent 100%);
  animation: ficsit-scanline 25s linear infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes ficsit-scanline {
  0% {
    top: -200px;
  }

  100% {
    top: calc(100vh + 200px);
  }
}

/* ---------- Layout ---------- */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1600px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-xl);
}

/* ---------- Grid Layout ---------- */
.app-grid {
  display: grid;
  grid-template-columns: minmax(320px, 380px) 1fr;
  gap: var(--space-xl);
  align-items: start;
}

.sidebar {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: var(--space-lg);
}

.app-main-content {
  min-width: 0;
}

/* ---------- Example Scenario Banner ---------- */
.example-scenario-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-left: 3px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: var(--space-lg);
  animation: slide-down 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.banner-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.banner-icon {
  font-size: 1rem;
  opacity: 0.7;
}

.banner-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.banner-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.banner-close {
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
  transition: var(--transition-all);
  line-height: 1;
}

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

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

/* ---------- Header — FICSIT Command Center ---------- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xl);
  padding: var(--space-md) var(--space-xl);
  background: linear-gradient(180deg, rgba(21, 27, 40, 0.9) 0%, rgba(14, 18, 25, 0.85) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 140, 26, 0.1);
  border-top: 1px solid rgba(255, 140, 26, 0.2);
  border-radius: var(--radius-lg);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 var(--metal-highlight),
    inset 0 -1px 0 var(--metal-shadow),
    0 0 30px rgba(255, 140, 26, 0.04);
  position: relative;
  overflow: visible;
  z-index: 50;
}

/* Decorative top accent line */
.app-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 5%, var(--ficsit-orange) 50%, transparent 95%);
  opacity: 0.6;
}

/* Bottom subtle line */
.app-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(50, 215, 255, 0.15), transparent);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.header-center {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
  background: rgba(10, 14, 23, 0.6);
  padding: 8px 20px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.4), 0 4px 15px rgba(0, 0, 0, 0.2);
}

.header-divider {
  width: 1px;
  height: 40px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  margin: 0 4px;
}

.header-control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.header-control-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-left: 6px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.header-toggle {
  background: rgba(0, 0, 0, 0.4);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.6);
  display: flex;
  gap: 4px;
}

.header-toggle .transport-btn,
.header-toggle .tier-btn {
  flex-direction: row;
  padding: 6px 16px;
  gap: 8px;
  border-radius: 8px;
  height: auto;
  opacity: 0.6;
  filter: grayscale(80%);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
}

.header-toggle .transport-btn:hover,
.header-toggle .tier-btn:hover {
  opacity: 0.9;
  filter: grayscale(30%);
  background: rgba(255, 255, 255, 0.05);
}

/* Premium Active States */
.header-toggle .transport-btn[data-mode="solid"].active {
  opacity: 1;
  filter: grayscale(0%);
  background: linear-gradient(180deg, rgba(255, 140, 26, 0.2) 0%, rgba(255, 140, 26, 0.05) 100%);
  border: 1px solid rgba(255, 140, 26, 0.5);
  box-shadow: 0 4px 15px rgba(255, 140, 26, 0.2), inset 0 1px 1px rgba(255, 140, 26, 0.4);
  color: var(--ficsit-orange);
}

.header-toggle .transport-btn[data-mode="fluid"].active {
  opacity: 1;
  filter: grayscale(0%);
  background: linear-gradient(180deg, rgba(50, 215, 255, 0.2) 0%, rgba(50, 215, 255, 0.05) 100%);
  border: 1px solid rgba(50, 215, 255, 0.5);
  box-shadow: 0 4px 15px rgba(50, 215, 255, 0.2), inset 0 1px 1px rgba(50, 215, 255, 0.4);
  color: var(--cyber-cyan);
}

/* Mk.4 : Ficsit Industrial Orange */
.header-toggle .tier-btn[data-tier="mk4"] {
  border-left: 2px solid rgba(255, 140, 26, 0.3);
}

.header-toggle .tier-btn[data-tier="mk4"].active {
  opacity: 1;
  filter: grayscale(0%);
  background: linear-gradient(180deg, rgba(255, 140, 26, 0.2) 0%, rgba(255, 140, 26, 0.05) 100%);
  border: 1px solid rgba(255, 140, 26, 0.4);
  border-left: 3px solid #ff8c1a;
  box-shadow: 0 4px 15px rgba(255, 140, 26, 0.2), inset 0 1px 2px rgba(255, 140, 26, 0.4);
  color: #ffd1a3;
  text-shadow: 0 0 8px rgba(255, 140, 26, 0.6);
}

/* Mk.5 : Alclad High-Speed Ruby */
.header-toggle .tier-btn[data-tier="mk5"] {
  border-left: 2px solid rgba(239, 68, 68, 0.3);
}

.header-toggle .tier-btn[data-tier="mk5"].active {
  opacity: 1;
  filter: grayscale(0%);
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.2) 0%, rgba(239, 68, 68, 0.05) 100%);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-left: 3px solid #ef4444;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.2), inset 0 1px 2px rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  text-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
}

/* Mk.6 : Quantum SAM Purple */
.header-toggle .tier-btn[data-tier="mk6"] {
  border-left: 2px solid rgba(217, 70, 239, 0.3);
}

.header-toggle .tier-btn[data-tier="mk6"].active {
  opacity: 1;
  filter: grayscale(0%);
  background: linear-gradient(180deg, rgba(217, 70, 239, 0.2) 0%, rgba(217, 70, 239, 0.05) 100%);
  border: 1px solid rgba(217, 70, 239, 0.4);
  border-left: 3px solid #d946ef;
  box-shadow: 0 4px 15px rgba(217, 70, 239, 0.2), inset 0 1px 2px rgba(217, 70, 239, 0.4);
  color: #f0abfc;
  text-shadow: 0 0 8px rgba(217, 70, 239, 0.6);
}

/* Mk.2 Fluid : Cyber Cyan */
.header-toggle .tier-btn[data-tier="mk2"] {
  border-left: 2px solid rgba(6, 182, 212, 0.3);
}

.header-toggle .tier-btn[data-tier="mk2"].active {
  opacity: 1;
  filter: grayscale(0%);
  background: linear-gradient(180deg, rgba(6, 182, 212, 0.2) 0%, rgba(6, 182, 212, 0.05) 100%);
  border: 1px solid rgba(6, 182, 212, 0.4);
  border-left: 3px solid #06b6d4;
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.2), inset 0 1px 2px rgba(6, 182, 212, 0.4);
  color: #a5f3fc;
  text-shadow: 0 0 8px rgba(6, 182, 212, 0.6);
}

.header-toggle .transport-icon {
  font-size: 1.15rem;
  margin-bottom: 0;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.header-toggle .transport-name,
.header-toggle .tier-name {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.header-toggle .tier-speed {
  font-size: 0.7rem;
  opacity: 0.8;
  font-family: var(--font-mono);
}

.logo-icon {
  font-size: 2.2rem;
  background: linear-gradient(135deg, rgba(255, 140, 26, 0.15), rgba(50, 215, 255, 0.05));
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 140, 26, 0.25);
  box-shadow: inset 0 0 15px rgba(255, 140, 26, 0.1), 0 4px 12px rgba(0, 0, 0, 0.2);
  animation: none;
  filter: none;
}

.app-title {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
  background: linear-gradient(to right, #ffffff, #c0c8d8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

.app-subtitle {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ficsit-orange);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 10px;
}

.header-right-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Global Apply Button */
.global-apply-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: var(--transition-all);
}

.global-apply-btn.applied {
  background: rgba(124, 255, 138, 0.08);
  border: 1px solid rgba(124, 255, 138, 0.2);
  color: var(--success);
}

.global-apply-btn.pending {
  background: rgba(255, 212, 77, 0.15);
  border: 1px solid rgba(255, 212, 77, 0.4);
  color: var(--ficsit-amber);
  box-shadow: 0 0 15px rgba(255, 212, 77, 0.2);
  animation: pulse-border 2s infinite;
}

.global-apply-btn:hover {
  filter: brightness(1.2);
}

@keyframes pulse-border {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 212, 77, 0.2);
    border-color: rgba(255, 212, 77, 0.4);
    color: var(--ficsit-amber);
  }

  48% {
    box-shadow: 0 0 15px 2px rgba(255, 212, 77, 0.5), inset 0 0 8px rgba(255, 212, 77, 0.2);
    border-color: rgba(255, 212, 77, 1);
    color: #fff;
    text-shadow: 0 0 8px rgba(255, 212, 77, 0.8);
  }

  50% {
    box-shadow: 0 0 5px 0 rgba(255, 212, 77, 0.2);
    border-color: rgba(255, 212, 77, 0.5);
    color: var(--ficsit-amber);
    text-shadow: none;
  }

  52% {
    box-shadow: 0 0 20px 4px rgba(255, 212, 77, 0.7), inset 0 0 12px rgba(255, 212, 77, 0.4);
    border-color: rgba(255, 212, 77, 1);
    color: #fff;
    text-shadow: 0 0 12px rgba(255, 212, 77, 1);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(255, 212, 77, 0);
    border-color: rgba(255, 212, 77, 0.4);
    color: var(--ficsit-amber);
  }
}

.guide-nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: rgba(255, 140, 26, 0.08);
  border: 1px solid rgba(255, 140, 26, 0.2);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ficsit-orange);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  text-decoration: none;
  transition: var(--transition-all);
  cursor: pointer;
  animation: guide-glow-pulse 3s ease-in-out infinite;
}

.guide-nav-btn:hover {
  background: rgba(255, 140, 26, 0.15);
  border-color: rgba(255, 140, 26, 0.4);
  box-shadow: 0 0 15px rgba(255, 140, 26, 0.2), var(--shadow-glow-orange);
  color: var(--ficsit-amber);
  animation: none;
}

@keyframes guide-glow-pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(255, 140, 26, 0);
    border-color: rgba(255, 140, 26, 0.2);
  }

  50% {
    box-shadow: 0 0 12px 2px rgba(255, 140, 26, 0.25), inset 0 0 4px rgba(255, 140, 26, 0.1);
    border-color: rgba(255, 140, 26, 0.5);
  }
}

/* ---------- Examples Dropdown ---------- */
.example-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.example-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0;
  background: linear-gradient(180deg, #182232 0%, #111827 100%);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 8px;
  min-width: 280px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 var(--metal-highlight);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Bridge the gap so hover doesn't break */
.example-dropdown::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  height: 15px;
}

.example-dropdown-wrapper:hover .example-dropdown,
.example-dropdown-wrapper:focus-within .example-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.example-dropdown-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: var(--transition-all);
}

.example-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
}

.example-item-icon {
  font-size: 1.2rem;
  margin-top: 2px;
}

.example-item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.example-item-title {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.example-item-desc {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--text-tertiary);
  line-height: 1.3;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--success), 0 0 20px rgba(124, 255, 138, 0.3);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(124, 255, 138, 0.7);
  }

  70% {
    opacity: 0.5;
    box-shadow: 0 0 0 8px rgba(124, 255, 138, 0);
  }

  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(124, 255, 138, 0);
  }
}

/* ---------- Autosave Notice ---------- */
.autosave-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-tertiary);
}

.autosave-dot {
  width: 6px;
  height: 6px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--success);
  animation: pulse 3s infinite;
}

.autosave-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  opacity: 0.8;
}

.autosave-tooltip-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.autosave-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  font-size: 0.6rem;
  font-weight: 700;
  cursor: help;
  transition: all 0.2s;
}

.autosave-help:hover {
  background: rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.autosave-tooltip {
  position: absolute;
  top: 100%;
  right: 0;
  transform: translateY(8px);
  width: 240px;
  background: linear-gradient(180deg, #182232 0%, #111827 100%);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-secondary);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  text-align: right;
  pointer-events: none;
}

.autosave-tooltip::after {
  content: '';
  position: absolute;
  bottom: 100%;
  right: 5px;
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent var(--border-default) transparent;
}

.autosave-tooltip-wrapper:hover .autosave-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(4px);
}

/* ---------- Section Panels — Industrial Metal Panels ---------- */
.panel-card {
  background: linear-gradient(180deg, #182232 0%, #111827 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-top: 1px solid var(--metal-highlight);
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-xl) var(--space-lg) var(--space-xl);
  margin-bottom: var(--space-lg);
  box-shadow:
    inset 0 1px 0 var(--metal-highlight),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3),
    0 4px 20px rgba(0, 0, 0, 0.35);
  transition: var(--transition-glow);
  overflow: visible;
  position: relative;
}

.panel-card:hover {
  border-color: rgba(255, 140, 26, 0.15);
  box-shadow:
    inset 0 1px 0 var(--metal-highlight),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3),
    0 8px 32px rgba(0, 0, 0, 0.4),
    0 0 20px var(--glow-orange);
}

.sub-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) 0;
  margin-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: border-color 0.2s ease;
}

.sub-header:hover {
  border-bottom-color: rgba(255, 140, 26, 0.3);
}

.sub-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
  min-width: 0;
}

.sub-header-icon {
  font-size: 1.15rem;
  opacity: 0.9;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
  flex-shrink: 0;
}

.sub-header-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  line-height: 1.3;
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.sub-header-chevron {
  display: inline-block;
  font-size: 0.6rem;
  color: var(--text-tertiary);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  margin-top: 2px;
}

.divider {
  height: 1px;
  background: linear-gradient(90deg, var(--border-subtle), rgba(255, 140, 26, 0.06), var(--border-subtle));
  margin: var(--space-lg) 0;
}

/* ============================================================
   QUICK STATS DASHBOARD
   ============================================================ */

.quick-stats-section {
  background: linear-gradient(180deg, #182232 0%, rgba(14, 18, 25, 0.6) 100%) !important;
  border: 1px solid rgba(255, 140, 26, 0.08);
  border-top: 1px solid rgba(255, 140, 26, 0.12);
  box-shadow:
    inset 0 1px 0 var(--metal-highlight),
    0 8px 32px rgba(0, 0, 0, 0.25),
    0 0 40px rgba(255, 140, 26, 0.03);
  overflow: hidden;
}

/* ── System Status Banner ── */
.system-status-banner {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  transition: var(--transition-all);
}

.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse-glow 2s infinite;
}

.status-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.status-headline {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.5px;
}

.status-detail {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ── Belt Tier Toggle ── */
.belt-tier-selector {
  margin-bottom: var(--space-xs);
}

.tier-toggle {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
  overflow: hidden;
}

.tier-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 4px;
  border: 1px solid transparent;
  border-radius: calc(var(--radius-md) - 2px);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-all);
  font-family: var(--font-mono);
  gap: 2px;
}

.tier-btn:hover {
  background: rgba(6, 182, 212, 0.06);
  color: var(--text-primary);
}

.tier-btn.active {
  background: rgba(6, 182, 212, 0.12);
  border-color: var(--cyber-cyan);
  color: var(--cyber-cyan);
  box-shadow: var(--shadow-glow-cyan), inset 0 0 12px rgba(6, 182, 212, 0.08);
}

.tier-name {
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

.tier-speed {
  font-size: 0.65rem;
  opacity: 0.7;
  letter-spacing: 0.3px;
}

.tier-btn.active .tier-speed {
  opacity: 1;
}

/* Status banner color variants */
.status-idle {
  background: rgba(100, 116, 139, 0.08);
  border: 1px solid rgba(100, 116, 139, 0.15);
}

.status-idle .status-indicator {
  background: #64748b;
  box-shadow: 0 0 8px rgba(100, 116, 139, 0.4);
}

.status-idle .status-headline {
  color: #94a3b8;
}

.status-pass {
  background: rgba(124, 255, 138, 0.05);
  border: 1px solid rgba(124, 255, 138, 0.15);
}

.status-pass .status-indicator {
  background: #7CFF8A;
  box-shadow: 0 0 12px rgba(124, 255, 138, 0.5);
}

.status-pass .status-headline {
  color: #7CFF8A;
}

.status-warn {
  background: rgba(255, 212, 77, 0.05);
  border: 1px solid rgba(255, 212, 77, 0.15);
}

.status-warn .status-indicator {
  background: #FFD44D;
  box-shadow: 0 0 12px rgba(255, 212, 77, 0.5);
}

.status-warn .status-headline {
  color: #FFD44D;
}

.status-fail {
  background: rgba(255, 98, 98, 0.05);
  border: 1px solid rgba(255, 98, 98, 0.15);
}

.status-fail .status-indicator {
  background: #FF6262;
  box-shadow: 0 0 12px rgba(255, 98, 98, 0.5);
}

.status-fail .status-headline {
  color: #FF6262;
}

@keyframes pulse-glow {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
}

.stat-card {
  position: relative;
  padding: var(--space-lg);
  background: linear-gradient(180deg, rgba(24, 34, 50, 0.8) 0%, rgba(14, 18, 25, 0.7) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-top: 1px solid var(--metal-highlight);
  border-radius: var(--radius-lg);
  transition: var(--transition-glow);
  overflow: visible;
  --stat-highlight: var(--border-subtle);
  box-shadow:
    inset 0 2px 0 var(--stat-highlight),
    inset 0 1px 0 var(--metal-highlight),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2),
    0 4px 16px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}


.stat-card:hover {
  z-index: 50;
  border-color: rgba(255, 140, 26, 0.15);
  background: linear-gradient(180deg, rgba(24, 34, 50, 0.9) 0%, rgba(17, 24, 39, 0.85) 100%);
  transform: translateY(-3px) scale(1.01);
  box-shadow:
    inset 0 2px 0 var(--stat-highlight),
    inset 0 1px 0 var(--metal-highlight),
    0 12px 32px rgba(0, 0, 0, 0.35),
    0 0 30px var(--glow-orange);
}

.stat-label {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: var(--space-xs);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: clamp(1.2rem, 1.5vw, 1.5rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--space-xs);
  color: var(--text-primary);
  transition: color 0.3s ease;
  word-break: break-word;
  letter-spacing: 0.5px;
}

#stat-val-ideal-rtd {
  font-size: clamp(1rem, 1.2vw, 1.25rem);
  white-space: nowrap;
  letter-spacing: -0.5px;
}

.stat-detail {
  font-size: 0.72rem;
  color: var(--text-tertiary);
  line-height: 1.4;
  font-family: var(--font-body);
}

/* ── Stat Card Color Variants (dynamic) — with Ambient Glow ── */
.stat-idle .stat-value {
  color: var(--text-tertiary);
}



.stat-safe .stat-value {
  color: #7CFF8A;
}

.stat-safe {
  --stat-highlight: #7CFF8A;
  border-color: rgba(124, 255, 138, 0.12);
}

.stat-safe:hover {
  box-shadow:
    inset 0 2px 0 var(--stat-highlight),
    inset 0 1px 0 var(--metal-highlight),
    0 12px 32px rgba(0, 0, 0, 0.35),
    0 0 30px var(--glow-green);
}

.stat-info .stat-value {
  color: #32D7FF;
}

.stat-info {
  --stat-highlight: #32D7FF;
  border-color: rgba(50, 215, 255, 0.12);
}

.stat-info:hover {
  box-shadow:
    inset 0 2px 0 var(--stat-highlight),
    inset 0 1px 0 var(--metal-highlight),
    0 12px 32px rgba(0, 0, 0, 0.35),
    0 0 30px var(--glow-cyan);
}

.stat-warning .stat-value {
  color: #FFD44D;
}

.stat-warning {
  --stat-highlight: #FFD44D;
  border-color: rgba(255, 212, 77, 0.12);
}

.stat-warning:hover {
  box-shadow:
    inset 0 2px 0 var(--stat-highlight),
    inset 0 1px 0 var(--metal-highlight),
    0 12px 32px rgba(0, 0, 0, 0.35),
    0 0 30px var(--glow-amber);
}

.stat-danger .stat-value {
  color: #FF6262;
}

.stat-danger {
  --stat-highlight: #FF6262;
  border-color: rgba(255, 98, 98, 0.12);
}

.stat-danger:hover {
  box-shadow:
    inset 0 2px 0 var(--stat-highlight),
    inset 0 1px 0 var(--metal-highlight),
    0 12px 32px rgba(0, 0, 0, 0.35),
    0 0 30px var(--glow-red);
}




.section-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--ficsit-amber), var(--ficsit-orange));
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--bg-deep);
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.section-header {
  margin-bottom: var(--space-lg);
  display: flex;
  align-items: center;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: 0.5px;
}

.section-desc {
  font-size: 0.95rem;
  color: var(--text-tertiary);
  margin-bottom: var(--space-lg);
  line-height: 1.6;
}

/* ---------- Input Rows ---------- */
.input-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.input-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: var(--space-sm);
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: var(--transition-all);
  overflow: hidden;
  flex-wrap: nowrap;
}

.input-row:hover {
  border-color: var(--border-default);
  background: var(--bg-elevated);
}

.input-row .row-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 52px;
  text-transform: uppercase;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Tactical Inset Inputs */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: var(--transition-all);
  flex: 1;
}

.input-wrapper:focus-within {
  border-color: var(--ficsit-orange);
  box-shadow:
    0 0 0 1px var(--ficsit-orange),
    0 0 12px rgba(255, 140, 26, 0.25),
    0 0 24px rgba(255, 140, 26, 0.08);
  transition: box-shadow 0.3s ease;
}

.input-row input[type="number"] {
  flex: 1 1 0;
  min-width: 60px;
  padding: 8px 8px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  outline: none;
  -moz-appearance: textfield;
}

.setting-input {
  flex: 1;
  width: 100%;
  padding: 8px 12px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  outline: none;
  -moz-appearance: textfield;
}

.input-row input[type="number"]::-webkit-outer-spin-button,
.input-row input[type="number"]::-webkit-inner-spin-button,
.setting-input::-webkit-outer-spin-button,
.setting-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input-with-actions {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  width: 100%;
}

.input-with-actions input[type="number"] {
  padding-right: 28px !important;
}

.btn-fill-max {
  position: absolute;
  right: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--ficsit-amber);
  font-size: 0.8rem;
  padding: 2px;
  opacity: 0.6;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 2;
}

.btn-fill-max:hover {
  opacity: 1;
  transform: scale(1.1);
}

.input-suffix,
.input-row .unit-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-tertiary);
  padding-right: 4px;
  pointer-events: none;
  user-select: none;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Drag Handle */
.drag-handle {
  cursor: grab;
  color: var(--text-tertiary);
  font-size: 0.85rem;
  padding: 0 2px;
  user-select: none;
  opacity: 0.35;
  transition: opacity 0.2s, color 0.2s, transform 0.2s;
  flex-shrink: 0;
  line-height: 1;
}

.drag-handle:hover {
  opacity: 1;
  color: var(--ficsit-amber);
  transform: scale(1.15);
}

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

/* Dragging state — the row being held */
.input-row.dragging {
  opacity: 0.4;
  transform: scale(0.97);
  background: rgba(255, 140, 26, 0.06);
  border-color: rgba(255, 140, 26, 0.25);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(255, 140, 26, 0.1);
  transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

/* Drop target glow — row being hovered over during drag */
.input-row.drag-over-top {
  border-top: 2px solid var(--ficsit-orange) !important;
  margin-top: -1px;
  transition: border-color 0.1s ease;
}

.input-row.drag-over-bottom {
  border-bottom: 2px solid var(--ficsit-orange) !important;
  margin-bottom: -1px;
  transition: border-color 0.1s ease;
}

/* Smooth settle animation after drop */
@keyframes drop-settle {
  0% {
    transform: scale(1.03);
    box-shadow: 0 0 16px rgba(255, 140, 26, 0.3);
    background: rgba(255, 140, 26, 0.08);
  }

  100% {
    transform: scale(1);
    box-shadow: none;
    background: var(--bg-base);
  }
}

.input-row.just-dropped {
  animation: drop-settle 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.btn-duplicate-row,
.btn-remove-row {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  transition: var(--transition-all);
  font-size: 0.85rem;
  flex-shrink: 0;
  padding: 0;
}

.btn-remove-row:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.btn-confirm-row {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: transparent;
  border: 1px solid rgba(124, 255, 138, 0.15);
  border-radius: var(--radius-sm);
  color: rgba(124, 255, 138, 0.5);
  cursor: pointer;
  transition: var(--transition-all);
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
  padding: 0;
}

.btn-confirm-row:hover {
  background: rgba(124, 255, 138, 0.1);
  color: #7CFF8A;
  border-color: #7CFF8A;
  box-shadow: 0 0 12px rgba(124, 255, 138, 0.25);
}

.btn-confirm-row:active {
  transform: scale(0.9);
}

.btn-confirm-row.confirmed {
  color: #7CFF8A;
  border-color: #7CFF8A;
  background: rgba(124, 255, 138, 0.15);
  box-shadow: 0 0 8px rgba(124, 255, 138, 0.3);
}

/* Confirm button for Train Settings (Integrated into input-wrapper) */
.setting-confirm-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: auto;
  align-self: stretch;
  /* Take full height of the input-wrapper */
  background: transparent;
  border: none;
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  /* Separator line */
  color: rgba(124, 255, 138, 0.4);
  cursor: pointer;
  transition: var(--transition-all);
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
  margin: 0;
  border-radius: 0;
  /* Let the wrapper handle border radius */
}

.setting-confirm-btn:hover {
  background: rgba(124, 255, 138, 0.1);
  color: #7CFF8A;
  border-left-color: rgba(124, 255, 138, 0.3);
}

.setting-confirm-btn:active {
  background: rgba(124, 255, 138, 0.2);
}

.setting-confirm-btn.confirmed {
  color: #7CFF8A;
  background: rgba(124, 255, 138, 0.15);
  box-shadow: inset 0 0 8px rgba(124, 255, 138, 0.3);
}

/* Pending indicator — input changed but not confirmed */
.input-row.pending {
  border-color: rgba(255, 212, 77, 0.3);
  box-shadow: 0 0 6px rgba(255, 212, 77, 0.1);
}

.input-row.pending .btn-confirm-row {
  color: #FFD44D;
  border-color: rgba(255, 212, 77, 0.4);
  animation: pulse-confirm 1.5s ease-in-out infinite;
}

.setting-card .input-wrapper.pending {
  border-color: rgba(255, 212, 77, 0.4);
  box-shadow: 0 0 6px rgba(255, 212, 77, 0.15);
}

.setting-card .input-wrapper.pending .setting-confirm-btn {
  color: #FFD44D;
  border-left-color: rgba(255, 212, 77, 0.4);
  background: rgba(255, 212, 77, 0.05);
  animation: pulse-confirm-bg 1.5s ease-in-out infinite;
}

@keyframes pulse-confirm {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

@keyframes pulse-confirm-bg {

  0%,
  100% {
    background: rgba(255, 212, 77, 0.05);
  }

  50% {
    background: rgba(255, 212, 77, 0.15);
  }
}

/* ---------- Clear Section Button ---------- */
.btn-clear-section {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: rgba(255, 98, 98, 0.06);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 98, 98, 0.15);
  border-radius: var(--radius-sm);
  color: rgba(255, 98, 98, 0.7);
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.25s ease;
  flex-shrink: 0;
  white-space: nowrap;
}

.btn-clear-section:hover {
  background: rgba(255, 98, 98, 0.12);
  border-color: rgba(255, 98, 98, 0.4);
  color: #FF6262;
  box-shadow: 0 0 14px rgba(255, 98, 98, 0.15),
    inset 0 0 8px rgba(255, 98, 98, 0.05);
  transform: translateY(-1px);
}

.btn-clear-section:active {
  transform: translateY(0) scale(0.97);
  box-shadow: none;
}

/* ---------- Action Stack & Quick Fill ---------- */
.action-stack {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 8px;
  margin-top: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.btn-add-row {
  flex: 1;
  padding: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed rgba(255, 140, 26, 0.15);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-glow);
}

.btn-add-row:hover {
  background: rgba(255, 140, 26, 0.05);
  border-color: var(--ficsit-orange);
  border-style: solid;
  color: var(--ficsit-orange);
  box-shadow: 0 0 15px rgba(255, 140, 26, 0.15);
  transform: translateY(-1px);
}

/* Quick Fill Strip */
/* Quick Fill Popover */
.quick-fill-dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.quick-fill-toggle {
  padding: 0 12px;
  height: 100%;
  min-height: 40px;
  font-size: 1.1rem;
  border-radius: var(--radius-md);
}

.quick-fill-popover {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(24, 34, 50, 0.95) 100%);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-md);
  z-index: 20;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
}

.quick-fill-dropdown-wrapper:hover .quick-fill-popover,
.quick-fill-dropdown-wrapper:focus-within .quick-fill-popover {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.quick-fill-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qf-field {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.qf-label {
  font-family: var(--font-display);
  font-size: 0.55rem;
  font-weight: 600;
  color: var(--ficsit-amber);
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.7;
  padding-left: 2px;
}

.qf-input {
  width: 64px;
  padding: 5px 8px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: calc(var(--radius-sm) - 1px);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  -moz-appearance: textfield;
}

.qf-input::-webkit-outer-spin-button,
.qf-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.qf-input-sm {
  width: 42px;
  text-align: center;
}

.qf-input::placeholder {
  color: var(--text-tertiary);
  opacity: 0.4;
  font-weight: 400;
}

.qf-input:focus {
  border-color: rgba(255, 140, 26, 0.5);
  box-shadow: 0 0 8px rgba(255, 140, 26, 0.15);
  background: rgba(0, 0, 0, 0.4);
}

.qf-times {
  color: var(--text-tertiary);
  font-size: 0.85rem;
  font-family: var(--font-mono);
  font-weight: 300;
  opacity: 0.4;
  user-select: none;
  padding: 0 2px;
  margin-top: 8px;
}

.qf-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  margin-top: 8px;
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.15), rgba(217, 119, 6, 0.1));
  border: 1px solid rgba(249, 115, 22, 0.3);
  border-radius: calc(var(--radius-sm));
  color: var(--ficsit-amber);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.65rem;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
  height: 27px;
  /* Explicit height to match inputs */
}

.qf-btn:hover {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.25), rgba(217, 119, 6, 0.2));
  border-color: var(--ficsit-orange);
  color: #fff;
  box-shadow: 0 0 20px rgba(249, 115, 22, 0.2),
    0 4px 12px rgba(249, 115, 22, 0.15);
  transform: translateY(-1px);
}

.qf-btn:active {
  transform: translateY(0) scale(0.97);
  box-shadow: none;
}

.qf-btn-icon {
  font-size: 0.8rem;
}

/* ---------- Summary Bars ---------- */
.summary-bar {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
  margin-top: var(--space-lg);
  padding: var(--space-md) var(--space-xl);
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
  box-shadow: var(--shadow-sm);
}

.summary-item {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
}

.summary-label {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.summary-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--ficsit-amber);
}

.summary-unit {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.summary-divider {
  width: 1px;
  height: 24px;
  background: var(--border-subtle);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 12px 24px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-all);
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--ficsit-orange), #d97706);
  color: #fff;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #fb923c, var(--ficsit-orange));
  box-shadow: var(--shadow-glow-orange);
  transform: translateY(-2px);
}

.btn-primary:active {
  transform: translateY(0);
}

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

.btn-secondary:hover {
  border-color: var(--cyber-cyan);
  color: var(--text-mono);
  background: rgba(6, 182, 212, 0.05);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow-cyan);
}

.btn-ghost {
  background: rgba(249, 115, 22, 0.05);
  border-color: rgba(249, 115, 22, 0.2);
  color: var(--ficsit-amber);
}

.btn-ghost:hover {
  background: rgba(249, 115, 22, 0.1);
  border-color: var(--ficsit-orange);
  transform: translateY(-1px);
}

.btn-danger {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-bg);
  box-shadow: var(--shadow-glow-danger);
}

/* ---------- Train Settings Grid ---------- */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-md);
}

.setting-card {
  padding: 20px;
  background: linear-gradient(180deg, rgba(21, 27, 40, 0.8) 0%, rgba(14, 18, 25, 0.7) 100%);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-top: 1px solid var(--metal-highlight);
  border-radius: var(--radius-lg);
  transition: var(--transition-glow);
  display: flex;
  flex-direction: column;
  height: 100%;
  box-shadow:
    inset 0 1px 0 var(--metal-highlight),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2),
    0 4px 12px rgba(0, 0, 0, 0.2);
}

.setting-card:hover {
  z-index: 50;
  border-color: rgba(50, 215, 255, 0.2);
  background: linear-gradient(180deg, rgba(24, 34, 50, 0.85) 0%, rgba(17, 24, 39, 0.8) 100%);
  box-shadow:
    inset 0 1px 0 var(--metal-highlight),
    0 8px 24px rgba(0, 0, 0, 0.3),
    0 0 20px var(--glow-cyan);
  transform: translateY(-2px);
}

.setting-card .input-wrapper {
  flex: none;
  background: rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.1);
}

.setting-card:hover .input-wrapper {
  border-color: rgba(255, 255, 255, 0.2);
}

.setting-label {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  min-height: 42px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  text-transform: uppercase;
  letter-spacing: 1px;
  line-height: 1.4;
}

.setting-label .help-tooltip {
  flex-shrink: 0;
  margin-left: auto;
  margin-top: -2px;
}

.setting-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-top: var(--space-sm);
  font-style: italic;
  line-height: 1.4;
}

.setting-desc {
  margin-top: 16px;
  padding: 14px 16px;
  background: rgba(6, 182, 212, 0.04);
  border-left: 2px solid rgba(6, 182, 212, 0.4);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  transition: var(--transition-all);
  flex-grow: 1;
}

.setting-desc::before {
  content: '✦';
  color: var(--cyber-cyan);
  font-size: 0.85rem;
  margin-top: 2px;
  opacity: 0.8;
}

.setting-card:hover .setting-desc {
  background: rgba(6, 182, 212, 0.06);
  border-left-color: var(--cyber-cyan);
  color: var(--text-primary);
}

/* ---------- Output Section ---------- */
.output-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.output-panel {
  background: linear-gradient(180deg, rgba(21, 27, 40, 0.7) 0%, rgba(14, 18, 25, 0.6) 100%);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-top: 1px solid var(--metal-highlight);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition-glow);
  box-shadow:
    inset 0 1px 0 var(--metal-highlight),
    0 2px 8px rgba(0, 0, 0, 0.2);
}

.output-panel:hover {
  border-color: rgba(255, 140, 26, 0.12);
  box-shadow:
    inset 0 1px 0 var(--metal-highlight),
    0 4px 16px rgba(0, 0, 0, 0.3),
    0 0 15px rgba(255, 140, 26, 0.06);
}

.output-panel-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  user-select: none;
  transition: var(--transition-all);
}

.output-panel-header:hover {
  background: rgba(255, 255, 255, 0.04);
}

.output-panel-icon {
  font-size: 1.2rem;
}

.output-panel-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.5px;
  flex: 1;
}

.output-panel-chevron {
  color: var(--text-tertiary);
  transition: transform 0.3s ease;
  font-size: 0.8rem;
}

.output-panel.collapsed .output-panel-chevron {
  transform: rotate(-90deg);
}

.output-panel-body {
  padding: var(--space-md);
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.4s ease, opacity 0.3s ease;
}

.output-panel.collapsed .output-panel-body {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}

/* ---------- Architecture Output ---------- */
.arch-step {
  padding: var(--space-lg);
  background: linear-gradient(180deg, rgba(21, 27, 40, 0.6) 0%, rgba(14, 18, 25, 0.5) 100%);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-left: 3px solid rgba(255, 140, 26, 0.2);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin-bottom: var(--space-md);
  box-shadow:
    inset 0 1px 0 var(--metal-highlight),
    0 2px 8px rgba(0, 0, 0, 0.15);
  transition: var(--transition-glow);
}

.arch-step:hover {
  border-left-color: var(--ficsit-orange);
  box-shadow:
    inset 0 1px 0 var(--metal-highlight),
    0 4px 12px rgba(0, 0, 0, 0.2),
    0 0 12px rgba(255, 140, 26, 0.06);
  transform: translateX(3px);
}

.arch-step:last-child {
  margin-bottom: 0;
}

.arch-step-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-accent);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.arch-step-content {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.arch-step-content ul {
  padding: 0;
  list-style: none;
}

.arch-step-content li {
  padding: 4px 0 4px 20px;
  position: relative;
}

.arch-step-content li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: var(--ficsit-orange);
  font-weight: 700;
  font-size: 1.2em;
  line-height: 1;
  top: 6px;
}

/* Flow value highlights */
.flow-value {
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
  border: 1px solid transparent;
}

.flow-safe {
  color: #7CFF8A;
  background: rgba(124, 255, 138, 0.08);
  border-color: rgba(124, 255, 138, 0.2);
}

.flow-warning {
  color: #FFD44D;
  background: rgba(255, 212, 77, 0.08);
  border-color: rgba(255, 212, 77, 0.2);
}

.flow-danger {
  color: #FF6262;
  background: rgba(255, 98, 98, 0.08);
  border-color: rgba(255, 98, 98, 0.2);
}

.flow-info {
  color: #32D7FF;
  background: rgba(50, 215, 255, 0.08);
  border-color: rgba(50, 215, 255, 0.2);
}

.flow-neutral {
  color: var(--text-mono);
  background: rgba(50, 215, 255, 0.08);
  border-color: rgba(50, 215, 255, 0.2);
}

/* ---------- RtD Zone Bar ---------- */
.rtd-zone-bar {
  position: relative;
  height: 44px;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: var(--space-lg) 0;
  display: flex;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-subtle);
}

.rtd-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 var(--space-sm);
  transition: flex var(--duration-normal) ease;
}

.rtd-zone.danger {
  background: linear-gradient(135deg, #7f1d1d, #ef4444);
}

.rtd-zone.tight {
  background: linear-gradient(135deg, #92400e, #f59e0b);
}

.rtd-zone.optimal {
  background: linear-gradient(135deg, #064e3b, #10b981);
}

.rtd-zone.safe {
  background: linear-gradient(135deg, #134e4a, #14b8a6);
}

.rtd-zone.overflow {
  background: linear-gradient(135deg, #4c1d95, #8b5cf6);
}

.rtd-zone-labels {
  position: relative;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-tertiary);
  margin-top: var(--space-xs);
  overflow: visible;
}

/* Fix overlapping RtD zone labels - app.js renders these with inline absolute positioning */
.rtd-zone-labels>div {
  pointer-events: none;
}

.rtd-zone-labels>div>div {
  font-size: 0.65rem !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border-subtle);
}

.rtd-zone-labels>div>div span:first-child {
  font-size: 0.7rem !important;
}

.rtd-marker {
  position: absolute;
  top: -6px;
  bottom: -6px;
  width: 3px;
  background: #38bdf8;
  border-radius: 2px;
  z-index: 10;
  box-shadow: 0 0 10px #38bdf8;
  transition: left var(--duration-normal) ease;
}

.rtd-marker::after {
  content: attr(data-label);
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: #0f172a;
  background: #38bdf8;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* ---------- Utilization Bars ---------- */
.utilization-row {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.utilization-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 100px;
}

.utilization-bar-track {
  flex: 1;
  height: 24px;
  background: rgba(2, 6, 23, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-inset);
}

.utilization-bar-fill {
  height: 100%;
  border-radius: var(--radius-sm);
  transition: width 0.6s ease, background 0.3s;
  position: relative;
}

.utilization-bar-fill.safe {
  background: linear-gradient(90deg, #059669, #34d399);
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.3);
}

.utilization-bar-fill.warning {
  background: linear-gradient(90deg, #d97706, #fbbf24);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.3);
}

.utilization-bar-fill.danger {
  background: linear-gradient(90deg, #b91c1c, #f87171);
  box-shadow: 0 0 10px rgba(248, 113, 113, 0.3);
}

.utilization-value {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 60px;
  text-align: right;
}

/* Threshold line at 80% */
.utilization-bar-track .threshold-line {
  position: absolute;
  left: 80%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.5);
  z-index: 2;
  border-right: 1px dashed rgba(255, 255, 255, 0.3);
}

/* ---------- Status Badges ---------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  border: 1px solid transparent;
}

.status-safe {
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.status-warning {
  background: rgba(245, 158, 11, 0.1);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

.status-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.status-info {
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  border-color: rgba(59, 130, 246, 0.3);
}

/* ---------- Callout Boxes ---------- */
.callout {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  font-size: 0.95rem;
  line-height: 1.6;
  background: var(--bg-surface);
  border-left: 4px solid transparent;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-all);
}

.callout:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.callout-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: var(--space-xs);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.callout-info {
  border-left-color: var(--info);
  color: #e0f2fe;
}

.callout-warning {
  border-left-color: var(--warning);
  color: #fef3c7;
}

.callout-danger {
  border-left-color: var(--danger);
  color: #fee2e2;
}

.callout-success {
  border-left-color: var(--success);
  color: #d1fae5;
}

.callout-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: var(--space-xs);
  color: #fff;
  letter-spacing: 0.5px;
}

/* ---------- Data Tables ---------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: var(--space-sm);
  display: block;
  overflow-x: auto;
}

.data-table thead th {
  padding: var(--space-sm) var(--space-md);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}

.data-table tbody td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  color: var(--text-primary);
  transition: var(--transition-all);
}

.data-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

/* ---------- SVG Diagram Container — Engineering Blueprint ---------- */
.diagram-container {
  position: relative;
  background:
    radial-gradient(circle at center, rgba(50, 215, 255, 0.02) 0%, transparent 70%),
    var(--bg-deep);
  border: 1px solid rgba(50, 215, 255, 0.12);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 450px;
  cursor: grab;
  box-shadow:
    var(--shadow-inset),
    0 0 20px rgba(50, 215, 255, 0.03);
  background-image:
    linear-gradient(rgba(50, 215, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(50, 215, 255, 0.03) 1px, transparent 1px),
    radial-gradient(circle at center, rgba(50, 215, 255, 0.02) 0%, transparent 70%);
  background-size: 30px 30px, 30px 30px, 100% 100%;
}

.diagram-container:active {
  cursor: grabbing;
}

.diagram-container svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

.diagram-controls {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  z-index: 10;
}

.diagram-controls button {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(250, 149, 73, 0.3);
  /* Subtle Ficsit Orange */
  border-radius: 8px;
  color: var(--ficsit-orange);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(250, 149, 73, 0.1);
}

.diagram-controls button:hover {
  color: var(--bg-main);
  background: var(--ficsit-orange);
  border-color: var(--ficsit-orange);
  box-shadow: 0 0 15px rgba(250, 149, 73, 0.4);
  transform: translateY(-2px);
}

.diagram-controls button:active {
  transform: translateY(0);
}

.diagram-tabs {
  display: flex;
  gap: 0;
  margin-bottom: var(--space-md);
  background: rgba(15, 23, 42, 0.5);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.diagram-tab {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  border: none;
  border-right: 1px solid var(--border-subtle);
  color: var(--text-tertiary);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-all);
  text-align: center;
}

.diagram-tab:last-child {
  border-right: none;
}

.btn-remove-row:hover {
  color: var(--danger);
  background: rgba(255, 100, 100, 0.1);
}

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

.diagram-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.diagram-tab.active {
  background: rgba(50, 215, 255, 0.08);
  color: var(--cyber-cyan);
  border-bottom: 2px solid var(--cyber-cyan);
  box-shadow: 0 0 8px rgba(50, 215, 255, 0.1);
}

/* ---------- Export Section ---------- */
.export-actions {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

/* ---------- Placeholder / Empty States ---------- */
.empty-state {
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  color: var(--text-tertiary);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-sm);
  opacity: 0.4;
}

.empty-state-text {
  font-family: var(--font-display);
  font-size: 1rem;
}

/* ---------- Tooltip ---------- */
.tooltip-trigger {
  position: relative;
  cursor: help;
  border-bottom: 1px dashed var(--text-tertiary);
  transition: color 0.2s;
}

.tooltip-trigger:hover {
  color: var(--cyber-cyan);
  border-color: var(--cyber-cyan);
}

.tooltip-trigger::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  color: #fff;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-all);
  z-index: var(--z-dropdown);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(4px);
}

.tooltip-trigger:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Nav Quick Links ---------- */
.nav-links {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  justify-content: center;
  margin-top: var(--space-xl);
  margin-bottom: var(--space-xl);
}

.nav-link {
  padding: 6px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition-all);
  cursor: pointer;
}

.nav-link:hover {
  border-color: var(--cyber-cyan);
  color: var(--cyber-cyan);
  background: rgba(6, 182, 212, 0.05);
  box-shadow: var(--shadow-glow-cyan);
}

/* ---------- Formula Display ---------- */
.formula-block {
  display: block;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-mono);
  margin: var(--space-sm) 0;
  overflow-x: auto;
  box-shadow: var(--shadow-inset);
}

/* ---------- Animated flow dashes for SVG ---------- */
@keyframes dash-flow {
  to {
    stroke-dashoffset: -20;
  }
}

.svg-flow-line {
  stroke-dasharray: 8, 6;
  animation: dash-flow 0.6s linear infinite;
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .app-grid {
    grid-template-columns: minmax(280px, 340px) 1fr;
    gap: var(--space-lg);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1024px) {
  .app-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }
}

@media (max-width: 768px) {
  .app-container {
    padding: var(--space-md);
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .panel-card {
    padding: var(--space-md);
  }

  .summary-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .summary-divider {
    width: 100%;
    height: 1px;
  }

  .input-row {
    flex-wrap: wrap;
  }

  .utilization-row {
    flex-wrap: wrap;
  }

  .utilization-label {
    min-width: 100%;
    margin-bottom: var(--space-xs);
  }

  .export-actions {
    flex-direction: column;
  }

  .diagram-container {
    min-height: 300px;
  }

  .nav-links {
    display: none;
  }
}

@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  body {
    background: #020617 !important;
    color: #f1f5f9 !important;
    font-size: 11pt;
  }

  body::before {
    display: none;
  }

  .app-container {
    max-width: 100%;
    padding: 0;
  }

  .panel-card {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 12pt;
    box-shadow: none;
  }

  .btn,
  .btn-remove-row,
  .nav-links,
  .diagram-controls,
  #section-export {
    display: none !important;
  }

  .output-panel.collapsed .output-panel-body {
    max-height: none;
    padding: 16pt;
    opacity: 1;
  }

  .diagram-container {
    min-height: 300px;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .app-header {
    padding: 16pt 0;
    background: none;
    backdrop-filter: none;
    border: none;
  }

  a {
    color: inherit !important;
    text-decoration: none !important;
  }
}


/* ---------- Diagram SVG Hover Effects ---------- */
.svg-node {
  transition: opacity 0.3s ease, filter 0.3s ease;
  cursor: pointer;
}

.node-rect {
  transition: stroke-width 0.3s ease, filter 0.3s ease;
}

.diagram-is-hovered .svg-node {
  opacity: 0.3;
  filter: grayscale(50%);
}

.diagram-is-hovered .svg-node.hover-active {
  opacity: 1;
  filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.4));
}

.diagram-is-hovered .svg-node.hover-active .node-rect {
  stroke-width: 2.5;
}

.diagram-is-hovered .svg-node.hover-input {
  opacity: 1;
  filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.5));
}

.diagram-is-hovered .svg-node.hover-output {
  opacity: 1;
  filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.5));
}

/* ---------- Floating Diagram Controls ---------- */
.btn-diagram-control {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-diagram-control:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: var(--cyber-cyan);
  color: var(--cyber-cyan);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}

.btn-diagram-control:active {
  transform: translateY(1px);
  box-shadow: 0 2px 8px rgba(6, 182, 212, 0.2);
}

/* ---------- Blueprint Dropdown Logic ---------- */
#panel-blueprint.collapsed .blueprint-body {
  display: none;
}

#panel-blueprint.collapsed .blueprint-chevron {
  transform: rotate(-90deg);
}

#panel-blueprint .section-header:hover .section-title {
  color: var(--ficsit-orange);
}

#panel-blueprint .section-header:hover .blueprint-chevron {
  color: var(--ficsit-orange) !important;
}

/* ============================================================
   HELP TOOLTIPS — (?) hover popups
   ============================================================ */

.help-tooltip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--text-tertiary);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  cursor: help;
  position: relative;
  vertical-align: middle;
  margin-left: 6px;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  font-family: var(--font-ui);
  letter-spacing: 0;
  text-transform: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.help-tooltip:hover {
  color: #fff;
  border-color: var(--cyber-cyan);
  background: rgba(6, 182, 212, 0.2);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.4), inset 0 0 8px rgba(6, 182, 212, 0.5);
  transform: scale(1.1);
}

.help-tooltip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  width: max-content;
  max-width: 320px;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #f1f5f9;
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0.2px;
  text-transform: none;
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6), 0 0 16px rgba(6, 182, 212, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 9999;
  white-space: normal;
  text-align: left;
}

.help-tooltip::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%) translateY(5px);
  border: 6px solid transparent;
  border-top-color: rgba(6, 182, 212, 0.4);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 10000;
}

.help-tooltip:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.help-tooltip:hover::before {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Prevent tooltips on the far left from bleeding into the sidebar */
.stats-grid .stat-card:nth-child(4n+1) .help-tooltip::after,
.train-settings-bridge .setting-card:nth-child(4n+1) .help-tooltip::after {
  left: -20px;
  right: auto;
  transform: translateY(10px);
}

.stats-grid .stat-card:nth-child(4n+1) .help-tooltip:hover::after,
.train-settings-bridge .setting-card:nth-child(4n+1) .help-tooltip:hover::after {
  transform: translateY(0);
}

/* Prevent tooltips on the far right from bleeding off the screen */
.stats-grid .stat-card:nth-child(4n) .help-tooltip::after,
.train-settings-bridge .setting-card:nth-child(4n) .help-tooltip::after {
  left: auto;
  right: -20px;
  transform: translateY(10px);
}

.stats-grid .stat-card:nth-child(4n) .help-tooltip:hover::after,
.train-settings-bridge .setting-card:nth-child(4n) .help-tooltip:hover::after {
  transform: translateY(0);
}


/* ============================================================
   TRANSPORT MODE TOGGLE — Solid / Fluid
   ============================================================ */

.transport-mode-selector {
  margin-bottom: var(--space-xs);
}

.transport-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: var(--bg-deep);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
  overflow: hidden;
}

.transport-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  border: 1px solid transparent;
  border-radius: calc(var(--radius-md) - 2px);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-all);
  font-family: var(--font-ui);
  gap: 2px;
}

.transport-btn:hover {
  background: rgba(249, 115, 22, 0.06);
  color: var(--text-primary);
}

.transport-btn.active {
  background: rgba(249, 115, 22, 0.12);
  border-color: var(--ficsit-orange);
  color: var(--ficsit-orange);
  box-shadow: var(--shadow-glow-orange), inset 0 0 12px rgba(249, 115, 22, 0.08);
}

.transport-icon {
  font-size: 1.2rem;
  margin-bottom: 2px;
}

.transport-name {
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.5px;
}

.transport-desc {
  font-size: 0.6rem;
  opacity: 0.7;
  letter-spacing: 0.3px;
}

.transport-btn.active .transport-desc {
  opacity: 1;
}

/* Fluid mode active — change cyan accent */
.transport-btn[data-mode="fluid"].active {
  background: rgba(6, 182, 212, 0.12);
  border-color: var(--cyber-cyan);
  color: var(--cyber-cyan);
  box-shadow: var(--shadow-glow-cyan), inset 0 0 12px rgba(6, 182, 212, 0.08);
}


/* ============================================================
   TRAIN SETTINGS BRIDGE — Centered between sidebar and output
   ============================================================ */

.train-settings-bridge {
  background: linear-gradient(180deg, var(--bg-surface) 0%, rgba(15, 23, 42, 0.5) 100%);
  border: 1px solid rgba(249, 115, 22, 0.1);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-sm), 0 0 20px rgba(249, 115, 22, 0.03);
  position: relative;
  overflow: visible;
}

.train-settings-bridge::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--ficsit-orange), transparent);
  opacity: 0.4;
}

.train-settings-bridge .settings-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
}

@media (max-width: 1100px) {
  .train-settings-bridge .settings-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .train-settings-bridge .settings-grid {
    grid-template-columns: 1fr;
  }
}


/* ============================================================
   FLUID MODE STYLES
   ============================================================ */

body.fluid-mode .tier-btn.active {
  background: rgba(6, 182, 212, 0.12);
  border-color: var(--cyber-cyan);
  color: var(--cyber-cyan);
  box-shadow: var(--shadow-glow-cyan), inset 0 0 12px rgba(6, 182, 212, 0.08);
}

body.fluid-mode .ficsit-orange {
  color: var(--cyber-cyan);
}


/* ============================================================
   RTD HELP (?) — SUBTLE BLINK ANIMATION
   ============================================================ */

@keyframes rtd-help-blink {

  0%,
  100% {
    opacity: 0.5;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  }

  50% {
    opacity: 1;
    box-shadow: 0 0 10px rgba(250, 149, 73, 0.5), inset 0 0 6px rgba(250, 149, 73, 0.3);
    border-color: var(--ficsit-orange);
    color: var(--ficsit-orange);
  }
}

.rtd-help-trigger {
  animation: rtd-help-blink 2.5s ease-in-out infinite;
  cursor: pointer !important;
}

.rtd-help-trigger:hover {
  animation: none;
  color: #fff;
  border-color: var(--ficsit-orange);
  background: rgba(250, 149, 73, 0.25);
  box-shadow: 0 0 16px rgba(250, 149, 73, 0.5), inset 0 0 10px rgba(250, 149, 73, 0.4);
  transform: scale(1.15);
}

/* Suppress the default ::after tooltip for this specific trigger */
.rtd-help-trigger::after,
.rtd-help-trigger::before {
  display: none !important;
}


/* ============================================================
   RTD HELP MODAL — Choo-to-Choo Timeline Overlay
   ============================================================ */

.rtd-help-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 6, 23, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.35s;
}

.rtd-help-overlay.active {
  opacity: 1;
  visibility: visible;
}

.rtd-help-modal {
  position: relative;
  width: min(92vw, 740px);
  max-height: 88vh;
  overflow-y: auto;
  background: linear-gradient(170deg, rgba(15, 23, 42, 0.97) 0%, rgba(30, 41, 59, 0.95) 100%);
  border: 1px solid rgba(250, 149, 73, 0.25);
  border-radius: 18px;
  padding: 0;
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.7),
    0 0 40px rgba(250, 149, 73, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transform: scale(0.92) translateY(20px);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.rtd-help-overlay.active .rtd-help-modal {
  transform: scale(1) translateY(0);
}

/* Scrollbar styling */
.rtd-help-modal::-webkit-scrollbar {
  width: 6px;
}

.rtd-help-modal::-webkit-scrollbar-track {
  background: transparent;
}

.rtd-help-modal::-webkit-scrollbar-thumb {
  background: rgba(250, 149, 73, 0.3);
  border-radius: 3px;
}

.rtd-help-close {
  position: sticky;
  top: 0;
  float: right;
  z-index: 10;
  width: 40px;
  height: 40px;
  margin: 12px 12px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 1.4rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.rtd-help-close:hover {
  color: #fff;
  border-color: var(--danger);
  background: rgba(239, 68, 68, 0.2);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.4);
  transform: rotate(90deg);
}

.rtd-help-content {
  padding: 28px 32px 32px;
}

/* ── Modal Header ── */
.rtd-help-content .rtd-modal-header {
  text-align: center;
  margin-bottom: 24px;
}

.rtd-help-content .rtd-modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  margin: 0 0 6px;
  letter-spacing: 0.5px;
}

.rtd-help-content .rtd-modal-header p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin: 0;
  line-height: 1.5;
}

/* ── Timeline Steps ── */
.rtd-timeline {
  position: relative;
  padding: 0;
  margin: 0 0 24px;
  list-style: none;
}

.rtd-timeline::before {
  content: '';
  position: absolute;
  left: 22px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg,
      #10b981 0%,
      #06b6d4 25%,
      #f97316 50%,
      #06b6d4 75%,
      #ef4444 100%);
  border-radius: 2px;
  opacity: 0.6;
}

.rtd-timeline-step {
  position: relative;
  padding: 14px 14px 14px 56px;
  margin-bottom: 4px;
  border-radius: 10px;
  transition: background 0.2s ease;
}

.rtd-timeline-step:hover {
  background: rgba(255, 255, 255, 0.03);
}

.rtd-timeline-step .step-icon {
  position: absolute;
  left: 6px;
  top: 14px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: var(--bg-surface);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  z-index: 1;
}

.rtd-timeline-step .step-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.92rem;
  color: #fff;
  margin-bottom: 4px;
}

.rtd-timeline-step .step-desc {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.rtd-timeline-step .step-desc strong {
  color: var(--ficsit-orange);
}

.rtd-timeline-step.step-warning {
  background: rgba(250, 149, 73, 0.06);
  border: 1px solid rgba(250, 149, 73, 0.15);
}

.rtd-timeline-step.step-warning .step-icon {
  border-color: var(--ficsit-orange);
  box-shadow: 0 0 10px rgba(250, 149, 73, 0.3);
}

.rtd-timeline-step.step-start .step-icon {
  border-color: #10b981;
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.rtd-timeline-step.step-end .step-icon {
  border-color: #ef4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

/* ── Result Box ── */
.rtd-result-box {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(6, 182, 212, 0.08) 100%);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 12px;
  padding: 18px 22px;
  margin-top: 8px;
  text-align: center;
}

.rtd-result-box .result-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: #10b981;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.rtd-result-box .result-example {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--cyber-cyan);
  padding: 10px 16px;
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.2);
  border-radius: 8px;
  display: inline-block;
  margin-bottom: 10px;
}

.rtd-result-box .result-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Logic Explanation ── */
.rtd-logic-box {
  background: rgba(59, 130, 246, 0.06);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 10px;
  padding: 16px 20px;
  margin-top: 16px;
}

.rtd-logic-box .logic-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.88rem;
  color: #60a5fa;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.rtd-logic-box .logic-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.rtd-logic-box .logic-text strong {
  color: #93c5fd;
}

@media (max-width: 600px) {
  .rtd-help-content {
    padding: 20px 18px 24px;
  }

  .rtd-help-modal {
    width: 96vw;
    max-height: 92vh;
    border-radius: 14px;
  }

  .rtd-help-content .rtd-modal-header h3 {
    font-size: 1.1rem;
  }
}

/* ============================================================
   NEW EFFECTS & ANIMATIONS
   ============================================================ */

/* ---------- Train Flow Animation ---------- */
.train-flow-bar {
  height: 2px;
  width: 100%;
  margin-top: 4px;
  margin-bottom: 4px;
  position: relative;
  overflow: hidden;
  border-radius: 1px;
  background: rgba(50, 215, 255, 0.05);
  /* Cyan subtle track */
}

.flow-packets {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg,
      var(--cyber-cyan) 0px,
      var(--cyber-cyan) 4px,
      transparent 4px,
      transparent 24px);
  opacity: 0.7;
  box-shadow: 0 0 8px var(--glow-cyan);
  animation: flow-move 12s linear infinite;
}

@keyframes flow-move {
  0% {
    transform: translateX(-24px);
  }

  100% {
    transform: translateX(0);
  }
}

/* ---------- Terminal Recalculating Flash ---------- */
.recalculating-flash {
  filter: brightness(1.5) hue-rotate(15deg);
  box-shadow: 0 0 20px rgba(50, 215, 255, 0.5);
  transition: all 0.1s;
}

/* ---------- Premium Help Tooltips ---------- */
.help-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(50, 215, 255, 0.08);
  margin-left: 8px;
  cursor: help;
  vertical-align: middle;
  border: 1px solid rgba(50, 215, 255, 0.2);
  box-shadow: 0 0 6px rgba(50, 215, 255, 0.05);
  color: var(--cyber-cyan, #32D7FF);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.help-tooltip:hover {
  background: rgba(50, 215, 255, 0.2);
  border-color: var(--cyber-cyan, #32D7FF);
  box-shadow: 0 0 12px rgba(50, 215, 255, 0.4);
  transform: scale(1.15);
  color: #fff;
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
}

/* Custom Tooltip Popup (reads data-tip or title) */
.help-tooltip::after {
  content: attr(data-tip) "" attr(title);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%) translateY(5px);
  background: rgba(14, 18, 25, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(50, 215, 255, 0.25);
  padding: 10px 14px;
  border-radius: 6px;
  color: #E5E7EB;
  font-size: 12px;
  font-family: var(--font-ui, sans-serif);
  font-weight: 400;
  line-height: 1.5;
  white-space: normal;
  width: max-content;
  max-width: 280px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  z-index: 1000;
}

/* Tooltip Arrow */
.help-tooltip:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Output Panel Subtitle */
.output-panel-subtitle {
  font-size: 0.75em;
  color: var(--text-tertiary);
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  margin-left: 8px;
}

/* ============================================================
   RESPONSIVE DESIGN (MOBILE & TABLET)
   ============================================================ */

/* ---------- Tablet / Small Laptops (max-width: 1100px) ---------- */
@media (max-width: 1100px) {
  .app-container {
    padding: var(--space-md);
  }

  /* Reduce grid columns to fit comfortably */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .settings-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================================
/* ============================================================
/* ============================================================
   FICSIT OS ERROR TERMINAL (Mobile Blocker)
   ============================================================ */
.mobile-blocker {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100dvh;
  z-index: 9999;
  background: #0a0e14;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  font-family: var(--font-mono);
}

.terminal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.terminal-scanlines {
  position: absolute;
  inset: -100%;
  background: repeating-linear-gradient(0deg,
      rgba(0, 0, 0, 0.15) 0px,
      rgba(0, 0, 0, 0.15) 2px,
      transparent 2px,
      transparent 4px);
  animation: scanline-crawl 10s linear infinite;
  opacity: 0.6;
}

@keyframes scanline-crawl {
  0% {
    transform: translateY(0);
  }

  100% {
    transform: translateY(50%);
  }
}

.terminal-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 120vw;
  height: 120vh;
  background: radial-gradient(circle, rgba(249, 115, 22, 0.08) 0%, transparent 60%);
}

.terminal-hazard-stripe {
  height: 24px;
  width: 100%;
  background: repeating-linear-gradient(45deg,
      #0a0e14 0px,
      #0a0e14 20px,
      #f59e0b 20px,
      #f59e0b 40px);
  z-index: 2;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.terminal-hazard-stripe.bottom {
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.5);
}

.terminal-container {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  max-width: 500px;
  margin: 0 auto;
  width: 100%;
}

.terminal-hud {
  width: 100%;
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
  font-size: 0.75rem;
  color: var(--ficsit-orange);
  letter-spacing: 2px;
  text-shadow: 0 0 8px rgba(249, 115, 22, 0.4);
}

.hud-indicator.blinking {
  animation: blink-crit 1s step-end infinite;
  color: #ef4444;
  text-shadow: 0 0 12px rgba(239, 68, 68, 0.8);
}

@keyframes blink-crit {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

.terminal-main-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(249, 115, 22, 0.3);
  box-shadow: 0 0 30px rgba(249, 115, 22, 0.1),
    inset 0 0 20px rgba(0, 0, 0, 0.8);
  padding: 32px 24px;
  border-radius: 4px;
  position: relative;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  width: 100%;
}

.terminal-main-box::before,
.terminal-main-box::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  border: 2px solid var(--ficsit-orange);
}

.terminal-main-box::before {
  top: -1px;
  left: -1px;
  border-right: none;
  border-bottom: none;
}

.terminal-main-box::after {
  bottom: -1px;
  right: -1px;
  border-left: none;
  border-top: none;
}

.terminal-icon-system {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.terminal-icon-hex {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2;
}

.hex-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  animation: spin-slow 15s linear infinite;
}

@keyframes spin-slow {
  100% {
    transform: rotate(360deg);
  }
}

.terminal-icon-symbol {
  font-size: 2.5rem;
  filter: drop-shadow(0 0 8px rgba(249, 115, 22, 0.8));
  animation: glitch-anim 3s infinite;
}

.terminal-icon-glow {
  position: absolute;
  inset: -20px;
  background: var(--ficsit-orange);
  filter: blur(30px);
  opacity: 0.3;
  border-radius: 50%;
  animation: pulse-glow 2s infinite alternate;
}

.terminal-title {
  font-family: var(--font-display);
  color: #fff;
  text-align: center;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 2px;
  margin: 0 0 16px 0;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5), 0 0 20px var(--ficsit-orange);
}

.terminal-divider {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}

.terminal-divider span {
  display: block;
  height: 2px;
  background: var(--ficsit-orange);
  opacity: 0.8;
}

.terminal-divider span:nth-child(1) {
  width: 40px;
}

.terminal-divider span:nth-child(2) {
  width: 12px;
}

.terminal-divider span:nth-child(3) {
  width: 4px;
}

.terminal-readout {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.85rem;
  line-height: 1.6;
  text-align: left;
}

.terminal-readout p {
  margin-bottom: 16px;
}

.readout-highlight {
  color: #ef4444;
  font-weight: 700;
  letter-spacing: 1px;
}

.terminal-fine-print {
  color: var(--text-tertiary);
  font-size: 0.75rem;
  font-style: italic;
  margin-top: 24px;
  border-left: 2px solid rgba(255, 255, 255, 0.1);
  padding-left: 12px;
}

.terminal-action-box {
  margin-top: 32px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 16px;
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: center;
}

.action-spinner {
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(56, 189, 248, 0.1), transparent);
  animation: scan-line 2s ease-in-out infinite;
}

@keyframes scan-line {
  100% {
    left: 200%;
  }
}

.action-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #38bdf8;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 1px;
}

.action-icon {
  font-size: 1.5rem;
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.6));
}

.action-text {
  text-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
  animation: text-pulse 1.5s ease-in-out infinite alternate;
}

@keyframes text-pulse {
  from {
    opacity: 0.6;
  }

  to {
    opacity: 1;
  }
}

/* ---------- Mobile Devices (max-width: 768px) ---------- */
@media (max-width: 768px) {

  /* Enable Mobile Blocker */
  .mobile-blocker {
    display: flex;
  }

  .app-container {
    display: none !important;
  }

  /* Layout Flow */
  .app-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    top: 0;
  }

  /* Header adjustments */
  .app-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--space-lg);
    padding: var(--space-lg) var(--space-md);
  }

  .header-left {
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
  }

  .header-text {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .logo-icon {
    margin: 0;
  }

  .app-title {
    font-size: 1.5rem;
    text-align: center;
  }

  .train-flow-bar {
    width: 100%;
    max-width: 200px;
    margin: 12px auto;
  }

  /* Panel padding adjustments to maximize horizontal space */
  .app-container {
    padding: 8px;
  }

  .panel-card {
    padding: 12px;
  }

  .output-panel-body {
    padding: 12px 8px;
  }

  .callout {
    padding: 12px;
    border-left-width: 2px;
    font-size: 0.85rem;
  }

  .arch-step {
    padding: 12px;
    border-left-width: 2px;
  }

  .arch-step-content {
    font-size: 0.85rem;
  }

  .data-table th,
  .data-table td {
    padding: 10px 12px;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  /* Grids collapse to single column */
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  /* Summary bars wrap */
  .summary-bar {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  .summary-item {
    flex: 1 1 auto;
    justify-content: center;
    padding: var(--space-xs);
  }

  .summary-divider {
    display: none;
  }

  /* Diagram container must not overflow */
  .diagram-container {
    height: 350px;
    width: 100%;
    overflow: hidden;
  }

  /* Adjust tooltips for mobile screens */
  .help-tooltip::after {
    max-width: 240px;
    font-size: 11px;
  }

  /* Output Panel Subtitles wrap nicely */
  .output-panel-subtitle {
    display: block;
    margin-left: 0;
    margin-top: 4px;
    line-height: 1.4;
  }
}

/* ---------- Very Small Devices (max-width: 480px) ---------- */
@media (max-width: 480px) {
  .tier-toggle {
    grid-template-columns: 1fr;
  }

  .diagram-tabs {
    flex-direction: column;
    gap: var(--space-xs);
  }

  .diagram-tab {
    width: 100%;
    border-radius: var(--radius-sm) !important;
  }
}


/* ============================================================
   COMPREHENSIVE GUIDE PAGE STYLES
   ============================================================ */

/* ---------- Guide Container ---------- */
.guide-container {
  position: relative;
  z-index: 1;
  max-width: 1500px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-xl);
}

/* ---------- Guide Header ---------- */
.guide-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xl);
  padding: var(--space-md) var(--space-xl);
  background: linear-gradient(180deg, rgba(21, 27, 40, 0.95) 0%, rgba(14, 18, 25, 0.9) 100%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 140, 26, 0.12);
  border-top: 1px solid rgba(255, 140, 26, 0.25);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35), inset 0 1px 0 var(--metal-highlight), 0 0 30px rgba(255, 140, 26, 0.04);
  position: relative;
  overflow: hidden;
}

.guide-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 5%, var(--ficsit-orange) 30%, var(--cyber-cyan) 70%, transparent 95%);
  opacity: 0.7;
}

.guide-back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  transition: var(--transition-all);
}

.guide-back-btn:hover {
  background: rgba(255, 140, 26, 0.1);
  border-color: rgba(255, 140, 26, 0.3);
  color: var(--ficsit-orange);
  box-shadow: 0 0 15px rgba(255, 140, 26, 0.15);
}

.guide-back-arrow {
  font-size: 1.1rem;
}

.guide-header-center {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.guide-header-icon {
  font-size: 2rem;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

.guide-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(to right, #ffffff, #c0c8d8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 0;
}

.guide-subtitle {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--ficsit-orange);
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin: 2px 0 0;
}

.guide-header-version {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-tertiary);
  background: rgba(0, 0, 0, 0.3);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* ---------- Guide Layout (TOC + Content) ---------- */
.guide-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: var(--space-xl);
  align-items: start;
}

/* ---------- Sticky Table of Contents ---------- */
.guide-toc {
  position: sticky;
  top: var(--space-lg);
  background: linear-gradient(180deg, #182232 0%, #111827 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-top: 1px solid var(--metal-highlight);
  border-radius: var(--radius-lg);
  padding: var(--space-lg) var(--space-md);
  box-shadow: inset 0 1px 0 var(--metal-highlight), 0 4px 20px rgba(0, 0, 0, 0.35);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.guide-toc::-webkit-scrollbar {
  width: 4px;
}

.guide-toc::-webkit-scrollbar-thumb {
  background: rgba(255, 140, 26, 0.3);
  border-radius: 10px;
}

.toc-title {
  font-family: var(--font-display);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-subtle);
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-list li {
  margin-bottom: 2px;
}

.toc-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  transition: var(--transition-all);
  border-left: 2px solid transparent;
}

.toc-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
  border-left-color: rgba(255, 140, 26, 0.3);
}

.toc-link.active {
  color: var(--ficsit-orange);
  background: rgba(255, 140, 26, 0.08);
  border-left-color: var(--ficsit-orange);
  font-weight: 600;
}

.toc-icon {
  font-size: 0.95rem;
  opacity: 0.8;
  flex-shrink: 0;
}

/* ---------- Guide Content Area ---------- */
.guide-content {
  min-width: 0;
}

/* ---------- Guide Sections ---------- */
.guide-section {
  background: linear-gradient(180deg, #182232 0%, #111827 100%);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-top: 1px solid var(--metal-highlight);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-lg);
  box-shadow: inset 0 1px 0 var(--metal-highlight), 0 4px 20px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  transition: var(--transition-glow);
}

.guide-section:hover {
  border-color: rgba(255, 140, 26, 0.12);
}

.guide-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-lg) var(--space-xl);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease;
}

.guide-section-header:hover {
  background: rgba(255, 140, 26, 0.03);
}

.guide-section-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.section-accent {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  letter-spacing: 1px;
}

.overview-accent {
  background: rgba(50, 215, 255, 0.12);
  color: var(--cyber-cyan);
  border: 1px solid rgba(50, 215, 255, 0.2);
}

.glossary-accent {
  background: rgba(99, 102, 241, 0.12);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.formulas-accent {
  background: rgba(255, 140, 26, 0.12);
  color: var(--ficsit-orange);
  border: 1px solid rgba(255, 140, 26, 0.2);
}

.source-accent {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.fractional-accent {
  background: rgba(245, 158, 11, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.dest-accent {
  background: rgba(139, 92, 246, 0.12);
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.rtd-accent {
  background: rgba(236, 72, 153, 0.12);
  color: #f472b6;
  border: 1px solid rgba(236, 72, 153, 0.2);
}

.fluid-accent {
  background: rgba(6, 182, 212, 0.12);
  color: #22d3ee;
  border: 1px solid rgba(6, 182, 212, 0.2);
}

.dashboard-accent {
  background: rgba(124, 255, 138, 0.12);
  color: var(--success);
  border: 1px solid rgba(124, 255, 138, 0.2);
}

.fixes-accent {
  background: rgba(255, 98, 98, 0.12);
  color: var(--danger);
  border: 1px solid rgba(255, 98, 98, 0.2);
}

.guide-chevron {
  font-size: 0.7rem;
  color: var(--text-tertiary);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.guide-section-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease;
  padding: 0 var(--space-xl);
}

.guide-section-body.open {
  max-height: 100000px;
  padding: 0 var(--space-xl) var(--space-xl);
  overflow: visible;
}

.guide-intro {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
}

.guide-h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: var(--space-xl) 0 var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--border-subtle);
  letter-spacing: 0.3px;
}

.guide-list {
  padding-left: var(--space-lg);
  margin-bottom: var(--space-md);
  line-height: 1.8;
  color: var(--text-secondary);
}

.guide-list li {
  margin-bottom: var(--space-xs);
}

/* ---------- Guide Callout Boxes ---------- */
.guide-callout {
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  border-left: 4px solid;
  line-height: 1.7;
}

.guide-callout p {
  margin: 0 0 8px;
  color: var(--text-secondary);
}

.guide-callout p:last-child {
  margin-bottom: 0;
}

.guide-callout-title {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: var(--space-sm);
  letter-spacing: 0.3px;
}

.callout-cyan {
  background: rgba(50, 215, 255, 0.05);
  border-color: var(--cyber-cyan);
}

.callout-cyan .guide-callout-title {
  color: var(--cyber-cyan);
}

.callout-orange {
  background: rgba(255, 140, 26, 0.05);
  border-color: var(--ficsit-orange);
}

.callout-orange .guide-callout-title {
  color: var(--ficsit-orange);
}

.callout-green {
  background: rgba(16, 185, 129, 0.05);
  border-color: #10b981;
}

.callout-green .guide-callout-title {
  color: #10b981;
}

/* ---------- Info Card Grid ---------- */
.guide-card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.guide-info-card {
  padding: var(--space-lg);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: var(--transition-all);
}

.guide-info-card:hover {
  border-color: rgba(50, 215, 255, 0.2);
  background: rgba(50, 215, 255, 0.03);
  box-shadow: 0 0 20px rgba(50, 215, 255, 0.05);
}

.info-card-icon {
  font-size: 1.6rem;
  margin-bottom: var(--space-sm);
}

.info-card-title {
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-sm);
  font-size: 0.95rem;
}

.guide-info-card p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.6;
  margin: 0;
}

/* ---------- Flow Diagram ---------- */
.guide-flow-diagram {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin: var(--space-lg) 0;
  overflow-x: auto;
  padding-bottom: var(--space-sm);
}

.flow-step {
  flex: 1;
  min-width: 160px;
  padding: var(--space-md) var(--space-lg);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: var(--transition-all);
}

.flow-step.highlight {
  background: rgba(255, 140, 26, 0.06);
  border-color: rgba(255, 140, 26, 0.2);
}

.flow-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--cyber-cyan);
  background: rgba(50, 215, 255, 0.1);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin-bottom: 4px;
}

.flow-label {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.flow-desc {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  line-height: 1.4;
}

.flow-arrow {
  display: flex;
  align-items: center;
  padding: 0 8px;
  color: var(--text-tertiary);
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* ---------- Glossary Grid ---------- */
.glossary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-sm);
}

.glossary-item {
  padding: var(--space-md) var(--space-lg);
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: var(--transition-all);
}

.glossary-item:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(99, 102, 241, 0.15);
}

.glossary-term {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.95rem;
  margin-bottom: var(--space-xs);
  display: flex;
  align-items: center;
  gap: 8px;
}

.glossary-def {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.7;
}

/* ---------- Formula Cards ---------- */
.formula-card {
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  overflow: hidden;
  transition: var(--transition-all);
}

.formula-card:hover {
  border-color: rgba(255, 140, 26, 0.15);
}

.formula-card.featured {
  border-color: rgba(255, 140, 26, 0.2);
  box-shadow: 0 0 20px rgba(255, 140, 26, 0.05);
}

.formula-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-subtle);
}

.formula-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--ficsit-orange);
  background: rgba(255, 140, 26, 0.1);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 140, 26, 0.2);
  letter-spacing: 0.5px;
}

.formula-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.formula-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 1px;
  background: rgba(255, 140, 26, 0.15);
  color: var(--ficsit-orange);
  border: 1px solid rgba(255, 140, 26, 0.3);
  margin-left: auto;
}

.formula-block {
  padding: var(--space-md) var(--space-lg);
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid var(--border-subtle);
}

.formula-block code {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--cyber-cyan);
  line-height: 1.8;
}

.formula-block.compact {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(50, 215, 255, 0.08);
  margin: var(--space-sm) 0;
  border-bottom: none;
}

.formula-block.compact code {
  font-size: 0.82rem;
}

.formula-note {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: 4px;
  font-style: italic;
}

.formula-explain {
  padding: var(--space-md) var(--space-lg);
}

.formula-explain p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.7;
  margin: 0 0 var(--space-sm);
}

.formula-explain p:last-child {
  margin-bottom: 0;
}

.formula-explain ol {
  padding-left: var(--space-lg);
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.7;
  margin: var(--space-sm) 0;
}

.formula-inline {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--cyber-cyan);
  background: rgba(50, 215, 255, 0.08);
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid rgba(50, 215, 255, 0.12);
}

/* ---------- Algorithm Steps ---------- */
.algorithm-step {
  margin-bottom: var(--space-md);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.01);
}

.algo-step-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: rgba(16, 185, 129, 0.04);
  border-bottom: 1px solid var(--border-subtle);
}

.algo-step-num {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: #34d399;
  background: rgba(16, 185, 129, 0.15);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(16, 185, 129, 0.3);
  flex-shrink: 0;
}

.algo-step-title {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.92rem;
}

.algo-step-body {
  padding: var(--space-md) var(--space-lg);
}

.algo-step-body p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.7;
  margin: 0 0 var(--space-sm);
}

.algo-step-body p:last-child {
  margin-bottom: 0;
}

.algo-step-body ol {
  padding-left: var(--space-lg);
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.8;
}

/* ---------- Strategy Cards ---------- */
.strategy-card {
  margin-bottom: var(--space-md);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.01);
  transition: var(--transition-all);
}

.strategy-card:hover {
  border-color: rgba(245, 158, 11, 0.15);
}

.strategy-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: rgba(245, 158, 11, 0.03);
  border-bottom: 1px solid var(--border-subtle);
}

.strategy-num {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.15);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(245, 158, 11, 0.3);
  flex-shrink: 0;
}

.strategy-name {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.92rem;
}

.strategy-tag {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-left: auto;
}

.strategy-tag.simple {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.strategy-tag.advanced {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.strategy-tag.fallback {
  background: rgba(255, 98, 98, 0.15);
  color: var(--danger);
  border: 1px solid rgba(255, 98, 98, 0.3);
}

.strategy-body {
  padding: var(--space-md) var(--space-lg);
}

.strategy-body p {
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.7;
  margin: 0 0 var(--space-sm);
}

.strategy-body p:last-child {
  margin-bottom: 0;
}

.strategy-body ol {
  padding-left: var(--space-lg);
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.8;
}

/* ---------- Zone Grid ---------- */
.zone-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.zone-card {
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  border: 1px solid;
  transition: var(--transition-all);
}

.zone-card:hover {
  transform: translateY(-2px);
}

.zone-name {
  font-weight: 800;
  font-family: var(--font-display);
  font-size: 0.95rem;
  margin-bottom: var(--space-xs);
  letter-spacing: 0.5px;
}

.zone-condition {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  margin-bottom: var(--space-sm);
  opacity: 0.8;
}

.zone-desc {
  font-size: 0.82rem;
  line-height: 1.6;
}

.zone-danger {
  background: rgba(255, 98, 98, 0.06);
  border-color: rgba(255, 98, 98, 0.2);
}

.zone-danger .zone-name {
  color: #FF6262;
}

.zone-danger .zone-condition {
  color: #fca5a5;
}

.zone-danger .zone-desc {
  color: var(--text-secondary);
}

.zone-tight {
  background: rgba(255, 212, 77, 0.06);
  border-color: rgba(255, 212, 77, 0.2);
}

.zone-tight .zone-name {
  color: #FFD44D;
}

.zone-tight .zone-condition {
  color: #fde68a;
}

.zone-tight .zone-desc {
  color: var(--text-secondary);
}

.zone-optimal {
  background: rgba(124, 255, 138, 0.06);
  border-color: rgba(124, 255, 138, 0.2);
}

.zone-optimal .zone-name {
  color: #7CFF8A;
}

.zone-optimal .zone-condition {
  color: #86efac;
}

.zone-optimal .zone-desc {
  color: var(--text-secondary);
}

.zone-safe {
  background: rgba(50, 215, 255, 0.06);
  border-color: rgba(50, 215, 255, 0.2);
}

.zone-safe .zone-name {
  color: #32D7FF;
}

.zone-safe .zone-condition {
  color: #67e8f9;
}

.zone-safe .zone-desc {
  color: var(--text-secondary);
}

.zone-overflow {
  background: rgba(139, 92, 246, 0.06);
  border-color: rgba(139, 92, 246, 0.2);
}

.zone-overflow .zone-name {
  color: #a78bfa;
}

.zone-overflow .zone-condition {
  color: #c4b5fd;
}

.zone-overflow .zone-desc {
  color: var(--text-secondary);
}

/* ---------- Comparison Table ---------- */
.comparison-table {
  overflow-x: auto;
  margin-bottom: var(--space-lg);
}

.comparison-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.comparison-table th {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-weight: 700;
  text-align: left;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 2px solid var(--border-default);
  font-family: var(--font-display);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.comparison-table td {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  line-height: 1.5;
}

.comparison-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ---------- Stats Explain Grid ---------- */
.stats-explain-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.stat-explain-card {
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition-all);
}

.stat-explain-card:hover {
  border-color: rgba(124, 255, 138, 0.15);
}

.stat-explain-header {
  padding: var(--space-sm) var(--space-md);
  background: rgba(124, 255, 138, 0.04);
  border-bottom: 1px solid var(--border-subtle);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-primary);
}

.stat-explain-body {
  padding: var(--space-md);
}

.stat-explain-body p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.6;
  margin: var(--space-xs) 0 0;
}

/* ---------- Guide Detail Block ---------- */
.guide-detail-block {
  padding: var(--space-md) var(--space-lg);
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
}

.guide-detail-block h4 {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.92rem;
  margin-bottom: var(--space-xs);
}

.guide-detail-block p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.7;
  margin: 0 0 var(--space-xs);
}

.guide-detail-block p:last-child {
  margin-bottom: 0;
}

/* ---------- Fix Cards ---------- */
.fix-card {
  margin-bottom: var(--space-lg);
  border: 1px solid rgba(255, 98, 98, 0.15);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.01);
}

.fix-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: rgba(255, 98, 98, 0.04);
  border-bottom: 1px solid rgba(255, 98, 98, 0.1);
}

.fix-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--danger);
  background: rgba(255, 98, 98, 0.12);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(255, 98, 98, 0.25);
  letter-spacing: 0.5px;
}

.fix-title {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.fix-body {
  padding: var(--space-lg);
}

.fix-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.fix-wrong,
.fix-right {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid;
}

.fix-wrong {
  background: rgba(255, 98, 98, 0.04);
  border-color: rgba(255, 98, 98, 0.15);
}

.fix-right {
  background: rgba(16, 185, 129, 0.04);
  border-color: rgba(16, 185, 129, 0.15);
}

.fix-label {
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: var(--space-sm);
}

.fix-wrong .fix-label {
  color: var(--danger);
}

.fix-right .fix-label {
  color: #10b981;
}

.fix-wrong p,
.fix-right p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 0 0 var(--space-xs);
}

.fix-wrong p:last-child,
.fix-right p:last-child {
  margin-bottom: 0;
}

/* ---------- Guide Footer ---------- */
.guide-footer {
  text-align: center;
  padding: var(--space-xl) 0 var(--space-lg);
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--space-xl);
}

.guide-footer p {
  color: var(--text-tertiary);
  font-size: 0.85rem;
  margin: 0 0 var(--space-xs);
}

.guide-footer-sub {
  font-size: 0.75rem !important;
  font-style: italic;
}

/* ---------- Guide Responsive ---------- */
@media (max-width: 1100px) {
  .guide-layout {
    grid-template-columns: 220px 1fr;
    gap: var(--space-md);
  }
}

@media (max-width: 900px) {
  .guide-layout {
    grid-template-columns: 1fr;
  }

  .guide-toc {
    position: static;
    max-height: none;
    margin-bottom: var(--space-lg);
  }

  .toc-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
  }

  .toc-list li {
    margin-bottom: 0;
  }

  .toc-link {
    padding: 6px 10px;
    font-size: 0.75rem;
    border-left: none;
    border-bottom: 2px solid transparent;
  }

  .toc-link.active {
    border-left: none;
    border-bottom-color: var(--ficsit-orange);
  }

  .guide-header {
    flex-direction: column;
    gap: var(--space-md);
    text-align: center;
  }

  .guide-card-grid,
  .stats-explain-grid,
  .fix-comparison {
    grid-template-columns: 1fr;
  }

  .guide-flow-diagram {
    flex-direction: column;
  }

  .flow-arrow {
    transform: rotate(90deg);
    justify-content: center;
    padding: 4px 0;
  }

  .zone-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .guide-container {
    padding: var(--space-md);
  }

  .guide-section-header {
    padding: var(--space-md);
  }

  .guide-section-body {
    padding: 0 var(--space-md);
  }

  .guide-section-body.open {
    padding: 0 var(--space-md) var(--space-md);
  }

  .guide-section-title {
    font-size: 1rem;
  }
}