/* ============================================================
   QRUCIBLE — Unified Design System
   Patentify color scheme + Qrucible structural layout
   Dark engineering UI with rich accent palette
   ============================================================ */

/* ── CSS Custom Properties (Dark Theme Default) ── */
:root {
  /* Backgrounds */
  --bg-primary: #0A0A0A;
  --bg-secondary: #111111;
  --bg-tertiary: #1A1A1A;
  --bg-elevated: #222222;
  --bg-overlay: rgba(10, 10, 10, 0.92);

  /* Text */
  --text-primary: rgba(255,255,255,0.92);
  --text-secondary: rgba(255,255,255,0.6);
  --text-tertiary: rgba(255,255,255,0.3);
  --text-disabled: rgba(255,255,255,0.2);

  /* Accents — Patentify Rich Color Palette */
  --accent-cyan: #06B6D4;
  --accent-cyan-dim: rgba(6, 182, 212, 0.15);
  --accent-cyan-glow: rgba(6, 182, 212, 0.35);
  --accent-purple: #8B5CF6;
  --accent-purple-dim: rgba(139, 92, 246, 0.15);
  --accent-purple-glow: rgba(139, 92, 246, 0.35);
  --accent-green: #22C55E;
  --accent-green-dim: rgba(34, 197, 94, 0.15);
  --accent-green-glow: rgba(34, 197, 94, 0.35);
  --accent-orange: #D4A017;
  --accent-orange-dim: rgba(212, 160, 23, 0.15);
  --accent-orange-glow: rgba(212, 160, 23, 0.35);
  --accent-red: #EF4444;
  --accent-red-dim: rgba(239, 68, 68, 0.15);
  --accent-red-glow: rgba(239, 68, 68, 0.35);
  --accent-blue: #2563EB;
  --accent-blue-dim: rgba(37, 99, 235, 0.15);
  --accent-blue-glow: rgba(37, 99, 235, 0.35);
  --accent-teal: #2E8B7A;
  --accent-teal-dim: rgba(46, 139, 122, 0.15);
  --accent-teal-glow: rgba(46, 139, 122, 0.35);
  --accent-rose: #F43F5E;
  --accent-rose-dim: rgba(244, 63, 94, 0.15);
  --accent-rose-glow: rgba(244, 63, 94, 0.35);

  /* Fonts */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', Courier, monospace;
  --font-display: 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  /* Type Scale */
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 17px;
  --text-xl: 20px;
  --text-2xl: 24px;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Borders */
  --border-subtle: 1px solid rgba(255,255,255,0.06);
  --border-default: 1px solid rgba(255,255,255,0.1);
  --border-strong: 1px solid rgba(255,255,255,0.18);
  --border-accent: 1px solid var(--accent-teal);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.6);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.7);
  --shadow-cyan: 0 0 20px rgba(6, 182, 212, 0.2);
  --shadow-purple: 0 0 20px rgba(139, 92, 246, 0.2);
  --shadow-green: 0 0 20px rgba(34, 197, 94, 0.2);
  --shadow-orange: 0 0 20px rgba(212, 160, 23, 0.2);
  --shadow-teal: 0 0 20px rgba(46, 139, 122, 0.2);
  --shadow-blue: 0 0 20px rgba(37, 99, 235, 0.2);

  /* Gradients */
  --gradient-cyan: linear-gradient(135deg, #06B6D4, #0891B2);
  --gradient-purple: linear-gradient(135deg, #8B5CF6, #7C3AED);
  --gradient-green: linear-gradient(135deg, #22C55E, #16A34A);
  --gradient-orange: linear-gradient(135deg, #D4A017, #B8860B);
  --gradient-teal: linear-gradient(135deg, #2E8B7A, #236B5F);
  --gradient-blue: linear-gradient(135deg, #2563EB, #1D4ED8);
  --gradient-rose: linear-gradient(135deg, #F43F5E, #E11D48);
  --gradient-bg: linear-gradient(180deg, #0A0A0A 0%, #080808 100%);
  --gradient-panel: linear-gradient(180deg, rgba(17,17,17,0.98) 0%, rgba(10,10,10,0.98) 100%);
  --gradient-card: linear-gradient(135deg, rgba(26,26,26,0.8), rgba(17,17,17,0.8));
  --gradient-glow-cyan: radial-gradient(ellipse at center, rgba(6,182,212,0.08) 0%, transparent 70%);
  --gradient-glow-teal: radial-gradient(ellipse at center, rgba(46,139,122,0.08) 0%, transparent 70%);

  /* Transitions */
  --transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --topbar-height: 56px;
  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
  --guide-width: 320px;
  --statusbar-height: 28px;
  --demo-bar-height: 0px;
  --context-banner-height: 48px;

  /* ── Patentify Compatibility Aliases ── */
  --bg: var(--bg-primary);
  --bg-surface: var(--bg-secondary);
  --bg-card: var(--bg-tertiary);
  --bg-hover: var(--bg-elevated);
  --border: var(--border-default);
  --text: var(--text-primary);
  --text-muted: var(--text-tertiary);
  --text-faint: var(--text-disabled);
  --accent: var(--accent-teal);
  --teal: #2E8B7A;
  --blue: var(--accent-blue);
  --amber: var(--accent-orange);
  --green: var(--accent-green);
  --red: var(--accent-red);
  --violet: var(--accent-purple);
  --success: var(--accent-green);
  --warning: var(--accent-orange);
  --danger: var(--accent-red);
  --info: var(--accent-blue);
}

/* ── Light Theme ── */
[data-theme="light"] {
  --bg-primary: #F5F5F5;
  --bg-secondary: #EBEBEB;
  --bg-tertiary: #E0E0E0;
  --bg-elevated: #F5F5F5;
  --bg-overlay: rgba(245, 245, 245, 0.92);

  --text-primary: rgba(0,0,0,0.87);
  --text-secondary: rgba(0,0,0,0.6);
  --text-tertiary: rgba(0,0,0,0.35);
  --text-disabled: rgba(0,0,0,0.2);

  --accent-cyan: #0891B2;
  --accent-purple: #7C3AED;
  --accent-green: #16A34A;
  --accent-orange: #B8860B;
  --accent-red: #DC2626;
  --accent-blue: #1D4ED8;
  --accent-teal: #236B5F;
  --accent-rose: #E11D48;

  --accent-cyan-dim: rgba(8, 145, 178, 0.1);
  --accent-purple-dim: rgba(124, 58, 237, 0.1);
  --accent-green-dim: rgba(22, 163, 74, 0.1);
  --accent-orange-dim: rgba(184, 134, 11, 0.1);
  --accent-red-dim: rgba(220, 38, 38, 0.1);
  --accent-blue-dim: rgba(29, 78, 216, 0.1);
  --accent-teal-dim: rgba(35, 107, 95, 0.1);
  --accent-rose-dim: rgba(225, 29, 72, 0.1);

  --accent-cyan-glow: rgba(8, 145, 178, 0.25);
  --accent-purple-glow: rgba(124, 58, 237, 0.25);
  --accent-green-glow: rgba(22, 163, 74, 0.25);
  --accent-orange-glow: rgba(184, 134, 11, 0.25);
  --accent-red-glow: rgba(220, 38, 38, 0.25);
  --accent-blue-glow: rgba(29, 78, 216, 0.25);
  --accent-teal-glow: rgba(35, 107, 95, 0.25);
  --accent-rose-glow: rgba(225, 29, 72, 0.25);

  --border-subtle: 1px solid rgba(0,0,0,0.06);
  --border-default: 1px solid rgba(0,0,0,0.1);
  --border-strong: 1px solid rgba(0,0,0,0.16);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.15);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.18);
  --shadow-cyan: 0 0 20px rgba(8,145,178,0.15);
  --shadow-purple: 0 0 20px rgba(124,58,237,0.15);
  --shadow-green: 0 0 20px rgba(22,163,74,0.15);
  --shadow-orange: 0 0 20px rgba(184,134,11,0.15);
  --shadow-teal: 0 0 20px rgba(35,107,95,0.15);
  --shadow-blue: 0 0 20px rgba(29,78,216,0.15);

  --gradient-bg: linear-gradient(180deg, #F5F5F5 0%, #EBEBEB 100%);
  --gradient-panel: linear-gradient(180deg, rgba(235,235,235,0.98) 0%, rgba(245,245,245,0.98) 100%);
  --gradient-card: linear-gradient(135deg, rgba(224,224,224,0.9), rgba(235,235,235,0.9));
  --gradient-cyan: linear-gradient(135deg, #0891B2, #06748E);
  --gradient-purple: linear-gradient(135deg, #7C3AED, #6D28D9);
  --gradient-green: linear-gradient(135deg, #16A34A, #15803D);
  --gradient-orange: linear-gradient(135deg, #B8860B, #996F0A);
  --gradient-teal: linear-gradient(135deg, #236B5F, #1A5248);
  --gradient-blue: linear-gradient(135deg, #1D4ED8, #1E40AF);
  --gradient-glow-cyan: radial-gradient(ellipse at center, rgba(8,145,178,0.06) 0%, transparent 70%);
  --gradient-glow-teal: radial-gradient(ellipse at center, rgba(35,107,95,0.06) 0%, transparent 70%);
}

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

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  position: relative;
}

/* ── Noise/Grain Texture Overlay ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.4;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

[data-theme="light"] body::before {
  opacity: 0.15;
}

/* ── App Shell Layout ── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   DEMO TOGGLE BAR
   ============================================================ */
.demo-bar {
  display: none;
  height: 0;
}

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

.demo-bar-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.demo-bar-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
  transition: all var(--transition-base);
}

.demo-bar-indicator.off {
  background: rgba(255,255,255,0.4);
  box-shadow: none;
}

.demo-toggle {
  position: relative;
  width: 44px;
  height: 22px;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(0,0,0,0.3);
  border-radius: var(--radius-full);
  border: 1px solid rgba(255,255,255,0.2);
  cursor: pointer;
  transition: all var(--transition-base);
  outline: none;
}

.demo-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  transition: transform var(--transition-base);
  box-shadow: var(--shadow-sm);
}

.demo-toggle:checked {
  background: rgba(255,255,255,0.25);
  border-color: rgba(255,255,255,0.4);
}

.demo-toggle:checked::after {
  transform: translateX(22px);
}

.demo-bar-status {
  font-size: 10px;
  opacity: 0.8;
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  background: var(--bg-secondary);
  border-bottom: var(--border-default);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
  z-index: 100;
  flex-shrink: 0;
}

.topbar.glass {
  background: rgba(17, 17, 17, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

[data-theme="light"] .topbar.glass {
  background: rgba(235, 235, 235, 0.7);
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  flex-shrink: 0;
}

.topbar-logo-img {
  height: 24px;
  width: auto;
  transition: filter 0.3s ease, opacity 0.3s ease;
}

.topbar-logo:hover .topbar-logo-img {
  filter: drop-shadow(0 0 8px rgba(6, 182, 212, 0.5));
}

.topbar-logo svg { width: 28px; height: 28px; }

.topbar-logo-text {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.topbar-logo-text span {
  background: var(--gradient-teal);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar-divider {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.12);
}

[data-theme="light"] .topbar-divider {
  background: rgba(0,0,0,0.12);
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.breadcrumb-item { color: var(--text-tertiary); white-space: nowrap; }
.breadcrumb-item.active { color: var(--text-primary); }
.breadcrumb-sep { color: var(--text-disabled); font-size: 10px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.segment-badge {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  background: var(--accent-teal-dim);
  border: 1px solid var(--accent-teal);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--accent-teal);
  font-weight: 500;
}

.segment-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent-teal);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}

.demo-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
  transition: all var(--transition-base);
}

.demo-status-dot.inactive {
  background: var(--text-disabled);
  box-shadow: none;
}

.icon-btn.demo-active {
  color: var(--accent-green);
  background: rgba(76, 175, 80, 0.12);
  border-color: rgba(76, 175, 80, 0.3);
  position: relative;
}

.icon-btn.demo-active::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
  animation: pulse-dot 2s infinite;
}

.icon-btn.demo-active:hover {
  background: rgba(76, 175, 80, 0.2);
  border-color: rgba(76, 175, 80, 0.5);
}

/* ============================================================
   VIEW TOGGLE (RAG / IP)
   ============================================================ */
.view-toggle {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.view-toggle-segment {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-tertiary);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  line-height: 1;
}

.view-toggle-segment:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
}

.view-toggle-segment.active {
  background: var(--accent-teal);
  color: #fff;
  box-shadow: 0 1px 3px rgba(6, 182, 212, 0.3);
}

.view-toggle-segment.active:hover {
  background: var(--accent-teal);
  color: #fff;
}

.view-toggle-segment svg {
  flex-shrink: 0;
}

[data-theme="light"] .view-toggle {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .view-toggle-segment:hover {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .view-toggle-segment.active {
  background: var(--accent-teal);
  color: #fff;
}

/* Hidden utility */
.hidden { display: none !important; }

/* Responsive: compact toggle on small screens */
@media (max-width: 768px) {
  .view-toggle-segment {
    padding: 4px 8px;
    font-size: 10px;
  }
  .view-toggle-segment svg {
    display: none;
  }
}

.icon-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 14px;
}

.icon-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: rgba(255,255,255,0.15);
}

[data-theme="light"] .icon-btn:hover {
  border-color: rgba(0,0,0,0.15);
}

.user-menu-btn {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 4px 10px 4px 4px;
  background: var(--bg-tertiary);
  border: var(--border-subtle);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.user-menu-btn:hover { border-color: rgba(255,255,255,0.15); color: var(--text-primary); }
[data-theme="light"] .user-menu-btn:hover { border-color: rgba(0,0,0,0.15); }

.user-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--gradient-purple);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: white;
}

/* ============================================================
   MIDDLE ROW (Sidebar + Main + Guide)
   ============================================================ */
.content-row {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: var(--border-default);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition-slow), min-width var(--transition-slow);
  z-index: 50;
  flex-shrink: 0;
}

.sidebar.glass {
  background: rgba(17, 17, 17, 0.6);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

[data-theme="light"] .sidebar.glass {
  background: rgba(235, 235, 235, 0.6);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
  min-width: var(--sidebar-collapsed);
}

.sidebar-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}

.sidebar-section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-disabled);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-section-label { opacity: 0; }

.sidebar-toggle {
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--text-tertiary);
  cursor: pointer; border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.sidebar-toggle:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-2) 0;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.nav-group { padding: var(--space-2) 0; }

.nav-group-label {
  padding: var(--space-2) var(--space-4) var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-disabled);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .nav-group-label { opacity: 0; height: 0; padding: 0; overflow: hidden; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 7px var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  border-left: 2px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
}

[data-theme="light"] .nav-item:hover {
  background: rgba(0,0,0,0.04);
}

.nav-item.active {
  color: var(--accent-teal);
  background: var(--accent-teal-dim);
  border-left-color: var(--accent-teal);
}

.nav-item-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}

.nav-item-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item-text { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.nav-badge {
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-mono);
  border-radius: var(--radius-full);
  background: var(--accent-teal-dim);
  color: var(--accent-teal);
  flex-shrink: 0;
}

.sidebar.collapsed .nav-item-text,
.sidebar.collapsed .nav-badge { opacity: 0; width: 0; overflow: hidden; }

.sidebar.collapsed .nav-item { justify-content: center; padding: 7px; border-left: none; }
.sidebar.collapsed .nav-item.active { border-radius: var(--radius-sm); }

/* Sidebar tooltip on collapse */
.sidebar.collapsed .nav-item[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  white-space: nowrap;
  border: var(--border-default);
  box-shadow: var(--shadow-md);
  z-index: 200;
}

.sidebar-footer {
  padding: var(--space-3);
  border-top: var(--border-subtle);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-primary);
  position: relative;
}

.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-track { background: transparent; }
.main-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
.main-content::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

.page-container {
  padding: var(--space-6);
  max-width: 1400px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
}

.page-title {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

/* ============================================================
   GUIDE PANEL
   ============================================================ */
.guide-panel {
  width: var(--guide-width);
  min-width: var(--guide-width);
  background: var(--bg-secondary);
  border-left: var(--border-default);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition-slow), min-width var(--transition-slow), opacity var(--transition-slow);
  flex-shrink: 0;
}

.guide-panel.collapsed {
  width: 0;
  min-width: 0;
  opacity: 0;
  pointer-events: none;
}

.guide-header {
  padding: var(--space-3) var(--space-4);
  border-bottom: var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.guide-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  display: flex; align-items: center; gap: var(--space-2);
}

.guide-title::before {
  content: '?';
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent-purple-dim);
  border: 1px solid var(--accent-purple);
  color: var(--accent-purple);
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.guide-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
}

.guide-body::-webkit-scrollbar { width: 3px; }
.guide-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

.guide-section { margin-bottom: var(--space-5); }

.guide-section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-disabled);
  margin-bottom: var(--space-2);
}

.guide-tip {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.5;
}

.guide-tip-icon { flex-shrink: 0; margin-top: 1px; }

/* ============================================================
   STATUS BAR
   ============================================================ */
.statusbar {
  height: var(--statusbar-height);
  min-height: var(--statusbar-height);
  background: var(--bg-secondary);
  border-top: var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-5);
  flex-shrink: 0;
}

.status-item {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text-tertiary);
}

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
}

.status-dot.connected { background: var(--accent-green); box-shadow: 0 0 6px var(--accent-green); }
.status-dot.disconnected { background: var(--accent-red); }
.status-dot.warning { background: var(--accent-orange); }

.status-spacer { flex: 1; }

.status-version {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--text-disabled);
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-secondary);
  border: var(--border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover { border-color: rgba(255,255,255,0.15); }
[data-theme="light"] .card:hover { border-color: rgba(0,0,0,0.15); }

.card-header {
  padding: var(--space-4);
  border-bottom: var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.card-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}

.card-body { padding: var(--space-4); }

.card-accent-cyan { border-color: rgba(6, 182, 212, 0.3); }
.card-accent-purple { border-color: rgba(139, 92, 246, 0.3); }
.card-accent-green { border-color: rgba(34, 197, 94, 0.3); }
.card-accent-orange { border-color: rgba(212, 160, 23, 0.3); }
.card-accent-teal { border-color: rgba(46, 139, 122, 0.3); }
.card-accent-blue { border-color: rgba(37, 99, 235, 0.3); }
.card-accent-rose { border-color: rgba(244, 63, 94, 0.3); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-cyan { background: var(--accent-cyan-dim); color: var(--accent-cyan); border: 1px solid rgba(6,182,212,0.3); }
.badge-purple { background: var(--accent-purple-dim); color: var(--accent-purple); border: 1px solid rgba(139,92,246,0.3); }
.badge-green { background: var(--accent-green-dim); color: var(--accent-green); border: 1px solid rgba(34,197,94,0.3); }
.badge-orange { background: var(--accent-orange-dim); color: var(--accent-orange); border: 1px solid rgba(212,160,23,0.3); }
.badge-red { background: var(--accent-red-dim); color: var(--accent-red); border: 1px solid rgba(239,68,68,0.3); }
.badge-blue { background: var(--accent-blue-dim); color: var(--accent-blue); border: 1px solid rgba(37,99,235,0.3); }
.badge-teal { background: var(--accent-teal-dim); color: var(--accent-teal); border: 1px solid rgba(46,139,122,0.3); }
.badge-rose { background: var(--accent-rose-dim); color: var(--accent-rose); border: 1px solid rgba(244,63,94,0.3); }
.badge-neutral { background: var(--bg-tertiary); color: var(--text-secondary); border: var(--border-subtle); }
.badge-amber { background: var(--accent-orange-dim); color: var(--accent-orange); border: 1px solid rgba(212,160,23,0.3); }
.badge-violet { background: var(--accent-purple-dim); color: var(--accent-purple); border: 1px solid rgba(139,92,246,0.3); }
.badge-muted { background: var(--bg-tertiary); color: var(--text-tertiary); border: var(--border-subtle); }
.badge-running { background: var(--accent-blue-dim); color: var(--accent-blue); border: 1px solid rgba(37,99,235,0.3); }

.confidence-high { background: var(--accent-green-dim); color: var(--accent-green); border: 1px solid rgba(34,197,94,0.4); font-family: var(--font-mono); }
.confidence-medium { background: var(--accent-orange-dim); color: var(--accent-orange); border: 1px solid rgba(212,160,23,0.4); font-family: var(--font-mono); }
.confidence-low { background: var(--accent-red-dim); color: var(--accent-red); border: 1px solid rgba(239,68,68,0.4); font-family: var(--font-mono); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: var(--font-sans);
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

.btn-primary {
  background: var(--gradient-green);
  color: #fff;
  box-shadow: 0 1px 6px rgba(34,197,94,0.3);
}
.btn-primary:hover { box-shadow: 0 2px 12px rgba(34,197,94,0.5); transform: translateY(-1px); }

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: var(--border-default);
}
.btn-secondary:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: rgba(255,255,255,0.2); }
[data-theme="light"] .btn-secondary:hover { border-color: rgba(0,0,0,0.2); }

.btn-ghost {
  background: transparent;
  color: var(--text-tertiary);
}
.btn-ghost:hover { background: var(--bg-tertiary); color: var(--text-primary); }

.btn-danger {
  background: var(--accent-red-dim);
  color: var(--accent-red);
  border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }

.btn-sm { padding: 4px var(--space-3); font-size: var(--text-xs); }
.btn-lg { padding: var(--space-3) var(--space-6); font-size: var(--text-base); font-weight: 600; }

/* ============================================================
   INPUTS
   ============================================================ */
.input, .select, .textarea {
  width: 100%;
  background: var(--bg-tertiary);
  border: var(--border-default);
  border-radius: var(--radius-md);
  padding: 8px var(--space-3);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--text-primary);
  transition: all var(--transition-fast);
  outline: none;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 3px var(--accent-teal-dim);
}

.input::placeholder { color: var(--text-disabled); }
.textarea { resize: vertical; min-height: 80px; }
.select { cursor: pointer; }
.input-mono { font-family: var(--font-mono); font-size: var(--text-xs); }

/* ============================================================
   TABLES
   ============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-tertiary);
  border-bottom: var(--border-default);
  background: var(--bg-secondary);
  position: sticky; top: 0; z-index: 1;
}

.data-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tr:hover td { background: rgba(255,255,255,0.02); color: var(--text-primary); }
[data-theme="light"] .data-table tr:hover td { background: rgba(0,0,0,0.02); }
.data-table .mono { font-family: var(--font-mono); font-size: var(--text-xs); }

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-tertiary);
  padding: 3px;
  border-radius: var(--radius-md);
  width: fit-content;
}

.tab {
  padding: 5px 16px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-tertiary);
  background: transparent;
  border: none;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.tab:hover { color: var(--text-secondary); background: rgba(255,255,255,0.04); }
[data-theme="light"] .tab:hover { background: rgba(0,0,0,0.04); }
.tab.active { background: var(--bg-secondary); color: var(--text-primary); box-shadow: var(--shadow-sm); }

.tabs-underline {
  display: flex;
  gap: var(--space-1);
  border-bottom: var(--border-default);
  background: none;
  padding: 0;
  border-radius: 0;
}

.tabs-underline .tab {
  padding: var(--space-3) var(--space-4);
  border-radius: 0;
  border-bottom: 2px solid transparent;
  background: none;
}

.tabs-underline .tab:hover { color: var(--text-primary); background: rgba(255,255,255,0.02); }
.tabs-underline .tab.active {
  color: var(--accent-teal);
  border-bottom-color: var(--accent-teal);
  background: none;
  box-shadow: none;
}

/* ============================================================
   GRID LAYOUTS
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }

/* ============================================================
   KPI CARD
   ============================================================ */
.kpi-card {
  background: var(--bg-secondary);
  border: var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.kpi-card:hover { border-color: rgba(255,255,255,0.15); box-shadow: var(--shadow-md); }
[data-theme="light"] .kpi-card:hover { border-color: rgba(0,0,0,0.15); }

.kpi-label { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-tertiary); }
.kpi-value { font-size: var(--text-2xl); font-weight: 700; font-family: var(--font-mono); color: var(--text-primary); line-height: 1; }
.kpi-delta { font-size: var(--text-xs); font-family: var(--font-mono); }
.kpi-delta.positive { color: var(--accent-green); }
.kpi-delta.negative { color: var(--accent-red); }

/* ============================================================
   PROGRESS / LOADING
   ============================================================ */
.progress-bar { height: 3px; background: var(--bg-tertiary); border-radius: var(--radius-full); overflow: hidden; }
.progress-fill { height: 100%; background: var(--gradient-teal); border-radius: var(--radius-full); transition: width var(--transition-slow); }

.skeleton {
  background: linear-gradient(90deg, var(--bg-tertiary) 0%, rgba(255,255,255,0.06) 50%, var(--bg-tertiary) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ============================================================
   CODE / MONO
   ============================================================ */
.code-block {
  background: var(--bg-tertiary);
  border: var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  overflow-x: auto;
  line-height: 1.7;
  white-space: pre;
}

.code-inline {
  background: var(--bg-tertiary);
  border: var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--accent-cyan);
}

/* ============================================================
   DIVIDER / TOOLTIPS / SCROLLBAR
   ============================================================ */
.divider { height: 1px; background: var(--bg-tertiary); border: none; margin: var(--space-4) 0; }

[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%; transform: translateX(-50%);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  white-space: nowrap;
  border: var(--border-default);
  box-shadow: var(--shadow-md);
  z-index: 200;
  pointer-events: none;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.08); }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.15); }

/* ============================================================
   GLASSMORPHISM UTILITIES
   ============================================================ */
.glass {
  background: rgba(17, 17, 17, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .glass {
  background: rgba(235, 235, 235, 0.6);
  border-color: rgba(0, 0, 0, 0.08);
}

.glass-strong {
  background: rgba(17, 17, 17, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

[data-theme="light"] .glass-strong {
  background: rgba(235, 235, 235, 0.85);
  border-color: rgba(0, 0, 0, 0.12);
}

/* ============================================================
   MICRO-ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 8px var(--accent-teal-glow); }
  50% { box-shadow: 0 0 24px var(--accent-teal-glow); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slide-in-right { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slide-in-left { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes scale-in { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes glow-pulse { 0%, 100% { box-shadow: 0 0 8px var(--accent-teal-glow); } 50% { box-shadow: 0 0 24px var(--accent-teal-glow); } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.animate-fadeIn { animation: fadeIn var(--transition-slow) both; }
.animate-slideInLeft { animation: slideInLeft var(--transition-slow) both; }
.animate-slideInRight { animation: slideInRight var(--transition-slow) both; }
.animate-scaleIn { animation: scaleIn var(--transition-base) both; }
.animate-pulseGlow { animation: pulseGlow 2s ease-in-out infinite; }
.animate-shimmer {
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.04) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

.animate-fade-in { animation: fade-in var(--transition-slow) both; }
.animate-slide-in-right { animation: slide-in-right var(--transition-slow) both; }
.animate-scale-in { animation: scale-in var(--transition-base) both; }

.stagger-children > * { opacity: 0; animation: fadeIn var(--transition-slow) both; }
.stagger-children > *:nth-child(1) { animation-delay: 50ms; }
.stagger-children > *:nth-child(2) { animation-delay: 100ms; }
.stagger-children > *:nth-child(3) { animation-delay: 150ms; }
.stagger-children > *:nth-child(4) { animation-delay: 200ms; }
.stagger-children > *:nth-child(5) { animation-delay: 250ms; }
.stagger-children > *:nth-child(6) { animation-delay: 300ms; }
.stagger-children > *:nth-child(7) { animation-delay: 350ms; }
.stagger-children > *:nth-child(8) { animation-delay: 400ms; }

.stagger-1 { animation-delay: 50ms; }
.stagger-2 { animation-delay: 100ms; }
.stagger-3 { animation-delay: 150ms; }
.stagger-4 { animation-delay: 200ms; }
.stagger-5 { animation-delay: 250ms; }

.hover-lift { transition: transform var(--transition-base), box-shadow var(--transition-base); }
.hover-lift:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.hover-glow { transition: box-shadow var(--transition-base); }
.hover-glow:hover { box-shadow: 0 0 20px var(--accent-teal-glow); }

/* Scroll-driven animation */
[data-animate] { opacity: 0; transform: translateY(16px); transition: opacity 0.6s ease, transform 0.6s ease; }
[data-animate].visible { opacity: 1; transform: translateY(0); }
[data-animate="slideLeft"] { transform: translateX(-20px); }
[data-animate="slideLeft"].visible { transform: translateX(0); }
[data-animate="slideRight"] { transform: translateX(20px); }
[data-animate="slideRight"].visible { transform: translateX(0); }
[data-animate="scaleIn"] { transform: scale(0.95); }
[data-animate="scaleIn"].visible { transform: scale(1); }

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.flex-1 { flex: 1; }
.min-w-0 { min-width: 0; }
.overflow-hidden { overflow: hidden; }
.text-mono { font-family: var(--font-mono); }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-cyan { color: var(--accent-cyan); }
.text-purple { color: var(--accent-purple); }
.text-green { color: var(--accent-green); }
.text-orange { color: var(--accent-orange); }
.text-red { color: var(--accent-red); }
.text-teal { color: var(--accent-teal); }
.text-blue { color: var(--accent-blue); }
.text-rose { color: var(--accent-rose); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.w-full { width: 100%; }
.p-4 { padding: var(--space-4); }
.hidden { display: none !important; }

/* ============================================================
   TAXONOMY TREE
   ============================================================ */
.taxonomy-tree { padding: var(--space-2) 0; }
.tree-node { font-size: var(--text-sm); user-select: none; }
.tree-node-header { display: flex; align-items: center; gap: var(--space-2); padding: 5px var(--space-3); border-radius: var(--radius-sm); cursor: pointer; transition: background var(--transition-fast); }
.tree-node-header:hover { background: rgba(255,255,255,0.04); }
.tree-node-header.active { background: var(--accent-teal-dim); }
.tree-node-header.active .tree-node-label { color: var(--accent-teal); }
.tree-toggle { width: 14px; height: 14px; display: flex; align-items: center; justify-content: center; color: var(--text-tertiary); font-size: 10px; transition: transform var(--transition-fast); flex-shrink: 0; }
.tree-toggle.open { transform: rotate(90deg); }
.tree-node-icon { font-size: 14px; flex-shrink: 0; }
.tree-node-label { color: var(--text-secondary); font-weight: 500; flex: 1; }
.tree-node-count { font-family: var(--font-mono); font-size: 10px; color: var(--text-disabled); flex-shrink: 0; }
.tree-children { padding-left: var(--space-4); border-left: 1px solid rgba(255,255,255,0.06); margin-left: 18px; overflow: hidden; max-height: 0; transition: max-height var(--transition-slow); }
.tree-children.open { max-height: 2000px; }

/* ============================================================
   SEGMENT STATUS CARDS
   ============================================================ */
.segment-card { background: var(--bg-secondary); border: var(--border-default); border-radius: var(--radius-lg); padding: var(--space-4); cursor: pointer; transition: all var(--transition-fast); position: relative; overflow: hidden; }
.segment-card::before { content: ''; position: absolute; top: 0; left: 0; width: 3px; height: 100%; background: var(--gradient-teal); border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.segment-card:hover { border-color: rgba(46,139,122,0.3); box-shadow: var(--shadow-teal); transform: translateY(-2px); }
.segment-card.active { border-color: var(--accent-teal); background: rgba(46,139,122,0.05); }

/* ============================================================
   ADVISORY BANNER
   ============================================================ */
.advisory-banner { background: rgba(212,160,23,0.08); border: 1px solid rgba(212,160,23,0.3); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); display: flex; gap: var(--space-3); align-items: flex-start; font-size: var(--text-xs); color: var(--text-secondary); line-height: 1.5; }
.advisory-icon { color: var(--accent-orange); font-size: 14px; flex-shrink: 0; margin-top: 1px; }

/* ============================================================
   LIFECYCLE & PIPELINE
   ============================================================ */
.lifecycle-canvas-wrapper { background: var(--bg-secondary); border: var(--border-default); border-radius: var(--radius-lg); overflow: hidden; position: relative; }
.lifecycle-controls { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--bg-tertiary); border-top: var(--border-subtle); }
.playback-btn { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; background: var(--bg-elevated); border: var(--border-default); border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; font-size: 12px; transition: all var(--transition-fast); }
.playback-btn:hover { background: var(--bg-primary); color: var(--text-primary); border-color: rgba(255,255,255,0.2); }
.playback-btn.active { background: var(--accent-teal-dim); color: var(--accent-teal); border-color: var(--accent-teal); }
.speed-control { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-xs); color: var(--text-tertiary); font-family: var(--font-mono); }

input[type="range"] { -webkit-appearance: none; height: 4px; background: var(--bg-elevated); border-radius: var(--radius-full); outline: none; cursor: pointer; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; background: var(--accent-teal); border-radius: 50%; cursor: pointer; box-shadow: 0 0 6px var(--accent-teal-glow); }

.d3-node { cursor: pointer; transition: all 0.2s; }
.d3-node:hover .node-bg { filter: brightness(1.3); }
.d3-edge { stroke: rgba(255,255,255,0.1); fill: none; stroke-width: 1.5; }

.pipeline-step { background: var(--bg-secondary); border: var(--border-default); border-radius: var(--radius-lg); transition: all var(--transition-base); }
.pipeline-step.active { border-color: var(--accent-teal); box-shadow: var(--shadow-teal); }
.pipeline-step.complete { border-color: rgba(34,197,94,0.3); }

.minimap { position: absolute; bottom: 12px; right: 12px; width: 140px; height: 90px; background: var(--bg-overlay); border: var(--border-default); border-radius: var(--radius-md); overflow: hidden; }

.detail-panel { position: absolute; top: 0; right: 0; width: 300px; height: 100%; background: var(--bg-secondary); border-left: var(--border-default); transform: translateX(100%); transition: transform var(--transition-slow); overflow-y: auto; z-index: 10; }
.detail-panel.open { transform: translateX(0); }
.detail-panel-header { padding: var(--space-4); border-bottom: var(--border-subtle); display: flex; align-items: center; justify-content: space-between; }

/* ============================================================
   CHAT INTERFACE (Query page inline)
   ============================================================ */
.chat-container { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-height) - var(--context-banner-height) - var(--statusbar-height) - 120px); min-height: 400px; }
.chat-messages { flex: 1; overflow-y: auto; padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-4); }
.chat-message { display: flex; gap: var(--space-3); animation: fade-in 0.3s both; }
.chat-message.user { flex-direction: row-reverse; }
.message-avatar { width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; }
.message-avatar.ai { background: var(--accent-purple-dim); border: 1px solid rgba(139,92,246,0.3); color: var(--accent-purple); }
.message-avatar.user { background: var(--accent-teal-dim); border: 1px solid rgba(46,139,122,0.3); color: var(--accent-teal); }
.message-body { max-width: 80%; }
.message-content { padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg); font-size: var(--text-sm); line-height: 1.6; color: var(--text-primary); }
.chat-message.ai .message-content { background: var(--bg-secondary); border: var(--border-default); }
.chat-message.user .message-content { background: var(--accent-teal-dim); border: 1px solid rgba(46,139,122,0.25); text-align: right; }
.message-meta { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-1); font-size: var(--text-xs); color: var(--text-disabled); }
.chat-message.user .message-meta { justify-content: flex-end; }

.tool-card { background: var(--bg-tertiary); border: var(--border-subtle); border-radius: var(--radius-md); margin-top: var(--space-2); overflow: hidden; transition: border-color var(--transition-fast); }
.tool-card:hover { border-color: rgba(46,139,122,0.3); }
.tool-card-header { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); cursor: pointer; font-size: var(--text-xs); font-family: var(--font-mono); color: var(--accent-teal); }
.tool-card-icon { font-size: 12px; }
.tool-card-body { padding: var(--space-3); border-top: var(--border-subtle); font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-secondary); display: none; }
.tool-card.expanded .tool-card-body { display: block; }
.tool-latency { font-family: var(--font-mono); font-size: 10px; color: var(--text-disabled); margin-left: auto; }

.rag-citation { background: rgba(139,92,246,0.06); border: 1px solid rgba(139,92,246,0.2); border-radius: var(--radius-md); margin-top: var(--space-2); overflow: hidden; }
.rag-citation-header { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); cursor: pointer; font-size: var(--text-xs); color: var(--accent-purple); }
.rag-citation-body { padding: var(--space-3); border-top: 1px solid rgba(139,92,246,0.15); font-size: var(--text-xs); color: var(--text-secondary); display: none; line-height: 1.6; }
.rag-citation.expanded .rag-citation-body { display: block; }

.chat-input-area { padding: var(--space-3) var(--space-4); background: var(--bg-secondary); border-top: var(--border-default); display: flex; gap: var(--space-2); align-items: flex-end; }
.chat-input-wrapper { flex: 1; position: relative; }
.chat-input { width: 100%; background: var(--bg-tertiary); border: var(--border-default); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); font-size: var(--text-sm); font-family: var(--font-sans); color: var(--text-primary); resize: none; outline: none; transition: border-color var(--transition-fast); min-height: 44px; max-height: 120px; overflow-y: auto; }
.chat-input:focus { border-color: var(--accent-teal); }

.session-sidebar { width: 220px; min-width: 220px; border-right: var(--border-default); display: flex; flex-direction: column; background: var(--bg-secondary); }
.session-item { padding: var(--space-3) var(--space-4); border-bottom: var(--border-subtle); cursor: pointer; transition: background var(--transition-fast); font-size: var(--text-xs); }
.session-item:hover { background: rgba(255,255,255,0.03); }
.session-item.active { background: var(--accent-teal-dim); }

/* ============================================================
   RADAR / HEATMAP
   ============================================================ */
.radar-container { display: flex; align-items: center; justify-content: center; }
.heatmap-grid { display: grid; gap: 2px; }
.heatmap-cell { border-radius: 3px; display: flex; align-items: center; justify-content: center; font-size: 10px; font-family: var(--font-mono); cursor: pointer; transition: all var(--transition-fast); }
.heatmap-cell:hover { transform: scale(1.1); z-index: 5; box-shadow: var(--shadow-md); }

/* ============================================================
   FOOTER
   ============================================================ */
footer { border-top: var(--border-subtle); padding: var(--space-3) var(--space-6); background: var(--bg-secondary); display: flex; align-items: center; justify-content: space-between; font-size: var(--text-xs); color: var(--text-disabled); flex-shrink: 0; }
footer a { color: var(--accent-teal); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ============================================================
   WHITESPACES MODULE
   ============================================================ */
.ws-explorer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--space-4); }
.ws-card { background: var(--bg-secondary); border: var(--border-default); border-radius: var(--radius-lg); padding: var(--space-4); transition: all var(--transition-fast); position: relative; overflow: hidden; }
.ws-card:hover { border-color: rgba(6,182,212,0.3); box-shadow: var(--shadow-cyan); transform: translateY(-2px); }
.ws-card-score { position: absolute; top: var(--space-3); right: var(--space-3); width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: var(--text-sm); font-weight: 700; }
.ws-d3-container { width: 100%; min-height: 400px; background: var(--bg-secondary); border: var(--border-default); border-radius: var(--radius-lg); overflow: hidden; position: relative; }
.ws-tabs { display: flex; gap: 2px; background: var(--bg-tertiary); padding: 3px; border-radius: var(--radius-md); }
.ws-tab { padding: 7px var(--space-4); font-size: var(--text-sm); font-weight: 500; color: var(--text-tertiary); background: transparent; border: none; border-radius: calc(var(--radius-md) - 2px); cursor: pointer; transition: all 0.25s cubic-bezier(0.4,0,0.2,1); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; position: relative; }
.ws-tab:hover { color: var(--text-secondary); background: rgba(255,255,255,0.04); }
.ws-tab.active { font-weight: 600; }

/* ── Colorful Tab Accents ── */
.ws-tab[data-color="cyan"].active    { background: var(--accent-cyan-dim);   color: var(--accent-cyan);   box-shadow: inset 0 -2px 0 var(--accent-cyan); }
.ws-tab[data-color="teal"].active    { background: var(--accent-teal-dim);   color: var(--accent-teal);   box-shadow: inset 0 -2px 0 var(--accent-teal); }
.ws-tab[data-color="purple"].active  { background: var(--accent-purple-dim); color: var(--accent-purple); box-shadow: inset 0 -2px 0 var(--accent-purple); }
.ws-tab[data-color="green"].active   { background: var(--accent-green-dim);  color: var(--accent-green);  box-shadow: inset 0 -2px 0 var(--accent-green); }
.ws-tab[data-color="orange"].active  { background: var(--accent-orange-dim); color: var(--accent-orange); box-shadow: inset 0 -2px 0 var(--accent-orange); }
.ws-tab[data-color="blue"].active    { background: var(--accent-blue-dim);   color: var(--accent-blue);   box-shadow: inset 0 -2px 0 var(--accent-blue); }
.ws-tab[data-color="red"].active     { background: var(--accent-red-dim);    color: var(--accent-red);    box-shadow: inset 0 -2px 0 var(--accent-red); }
.ws-tab[data-color="rose"].active    { background: var(--accent-rose-dim);   color: var(--accent-rose);   box-shadow: inset 0 -2px 0 var(--accent-rose); }

/* Hover states for colored tabs */
.ws-tab[data-color="cyan"]:hover:not(.active)    { color: var(--accent-cyan);   background: rgba(6,182,212,0.06); }
.ws-tab[data-color="teal"]:hover:not(.active)    { color: var(--accent-teal);   background: rgba(46,139,122,0.06); }
.ws-tab[data-color="purple"]:hover:not(.active)  { color: var(--accent-purple); background: rgba(139,92,246,0.06); }
.ws-tab[data-color="green"]:hover:not(.active)   { color: var(--accent-green);  background: rgba(34,197,94,0.06); }
.ws-tab[data-color="orange"]:hover:not(.active)  { color: var(--accent-orange); background: rgba(212,160,23,0.06); }
.ws-tab[data-color="blue"]:hover:not(.active)    { color: var(--accent-blue);   background: rgba(37,99,235,0.06); }
.ws-tab[data-color="red"]:hover:not(.active)     { color: var(--accent-red);    background: rgba(239,68,68,0.06); }
.ws-tab[data-color="rose"]:hover:not(.active)    { color: var(--accent-rose);   background: rgba(244,63,94,0.06); }

/* Fallback for tabs without data-color */
.ws-tab.active:not([data-color]) { background: var(--accent-cyan-dim); color: var(--accent-cyan); box-shadow: inset 0 -2px 0 var(--accent-cyan); }

/* ============================================================
   PATENT LAB MODULE
   ============================================================ */
.pl-pipeline-table { width: 100%; border-collapse: collapse; }
.pl-pipeline-table th { text-align: left; padding: var(--space-2) var(--space-3); font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-tertiary); border-bottom: var(--border-default); background: var(--bg-secondary); position: sticky; top: 0; z-index: 1; }
.pl-pipeline-table td { padding: var(--space-2) var(--space-3); border-bottom: var(--border-subtle); color: var(--text-secondary); font-size: var(--text-sm); }
.pl-pipeline-table tr:hover td { background: rgba(212,160,23,0.04); }
.pl-sunburst-container { width: 100%; min-height: 500px; display: flex; align-items: center; justify-content: center; background: var(--bg-secondary); border: var(--border-default); border-radius: var(--radius-lg); position: relative; }
.pl-workflow-editor { display: grid; grid-template-columns: 240px 1fr; gap: var(--space-4); min-height: 400px; }
.pl-workflow-sidebar { background: var(--bg-secondary); border: var(--border-default); border-radius: var(--radius-lg); padding: var(--space-3); overflow-y: auto; }
.pl-workflow-canvas { background: var(--bg-secondary); border: var(--border-default); border-radius: var(--radius-lg); position: relative; overflow: hidden; }

/* ============================================================
   CIIS MODULE
   ============================================================ */
.ciis-rankings-table { width: 100%; border-collapse: collapse; }
.ciis-rankings-table th { text-align: left; padding: var(--space-2) var(--space-3); font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-tertiary); border-bottom: var(--border-default); background: var(--bg-secondary); position: sticky; top: 0; }
.ciis-rankings-table td { padding: var(--space-2) var(--space-3); border-bottom: var(--border-subtle); color: var(--text-secondary); font-size: var(--text-sm); }
.ciis-rankings-table tr:hover td { background: rgba(34,197,94,0.04); }
.ciis-score-bar { height: 6px; background: var(--bg-tertiary); border-radius: var(--radius-full); overflow: hidden; }
.ciis-score-bar-fill { height: 100%; border-radius: var(--radius-full); transition: width var(--transition-slow); }
.ciis-scoring-editor { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.ciis-factor-card { background: var(--bg-secondary); border: var(--border-default); border-radius: var(--radius-lg); padding: var(--space-4); }
.ciis-factor-card:hover { border-color: rgba(34,197,94,0.3); }

/* ============================================================
   STRATEGY MODULE
   ============================================================ */
.strat-d3-container { width: 100%; min-height: 500px; background: var(--bg-secondary); border: var(--border-default); border-radius: var(--radius-lg); position: relative; overflow: hidden; }
.strat-layer-selector { display: flex; gap: var(--space-2); margin-bottom: var(--space-4); }
.strat-layer-btn { padding: 6px var(--space-4); font-size: var(--text-sm); font-weight: 500; color: var(--text-tertiary); background: var(--bg-tertiary); border: var(--border-default); border-radius: var(--radius-md); cursor: pointer; transition: all var(--transition-fast); }
.strat-layer-btn.active { background: var(--accent-blue-dim); color: var(--accent-blue); border-color: var(--accent-blue); }
.strat-layer-btn:hover:not(.active) { background: var(--bg-elevated); color: var(--text-primary); }

/* ============================================================
   COMMAND CENTER MODULE
   ============================================================ */
.cmd-workflow-editor { display: grid; grid-template-columns: 280px 1fr; gap: var(--space-4); min-height: 500px; }
.cmd-workflow-list { background: var(--bg-secondary); border: var(--border-default); border-radius: var(--radius-lg); overflow-y: auto; }
.cmd-workflow-item { padding: var(--space-3) var(--space-4); border-bottom: var(--border-subtle); cursor: pointer; transition: all var(--transition-fast); }
.cmd-workflow-item:hover { background: rgba(139,92,246,0.04); }
.cmd-workflow-item.active { background: var(--accent-purple-dim); border-left: 2px solid var(--accent-purple); }
.cmd-activity-log { background: var(--bg-secondary); border: var(--border-default); border-radius: var(--radius-lg); max-height: 400px; overflow-y: auto; }
.cmd-activity-entry { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-3); border-bottom: var(--border-subtle); font-size: var(--text-xs); }
.cmd-activity-entry:hover { background: rgba(255,255,255,0.02); }

/* ============================================================
   BUSINESS PLAN IFRAME WRAPPER
   ============================================================ */
.bp-iframe-wrapper { width: 100%; height: 100%; background: var(--bg-primary); border: none; position: relative; }
.bp-iframe-wrapper iframe { width: 100%; height: 100%; border: none; }

/* ============================================================
   CHAT WIDGET (Floating)
   ============================================================ */
.chat-fab { position: fixed; bottom: 24px; right: 24px; z-index: 9999; width: 56px; height: 56px; border-radius: 50%; background: var(--gradient-teal); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 20px var(--accent-teal-glow); transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.chat-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(46,139,122,0.5); }
.chat-fab:active { transform: scale(0.96); }
.chat-fab svg { width: 24px; height: 24px; stroke: white; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.chat-widget-panel { position: fixed; bottom: 92px; right: 24px; z-index: 9998; width: 420px; max-height: 600px; background: var(--bg-secondary); border: var(--border-default); border-radius: var(--radius-xl); display: flex; flex-direction: column; box-shadow: var(--shadow-xl); opacity: 0; transform: translateY(16px) scale(0.96); pointer-events: none; transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1); }
.chat-widget-panel.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: all; }
.chat-widget-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4) var(--space-5); border-bottom: var(--border-subtle); border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
.chat-widget-messages { flex: 1; overflow-y: auto; padding: var(--space-4) var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); max-height: 400px; min-height: 200px; }
.chat-widget-input-area { padding: var(--space-3) var(--space-4); border-top: var(--border-subtle); display: flex; gap: var(--space-2); align-items: flex-end; border-radius: 0 0 var(--radius-xl) var(--radius-xl); }
.chat-widget-msg { max-width: 85%; padding: var(--space-2) var(--space-3); border-radius: var(--radius-lg); font-size: var(--text-sm); line-height: 1.55; color: var(--text-primary); word-wrap: break-word; }
.chat-widget-msg.user { align-self: flex-end; background: var(--accent-teal-dim); border: 1px solid rgba(46,139,122,0.2); border-bottom-right-radius: var(--radius-sm); }
.chat-widget-msg.assistant { align-self: flex-start; background: var(--bg-tertiary); border: var(--border-subtle); border-bottom-left-radius: var(--radius-sm); }
.chat-widget-msg.system { align-self: center; background: transparent; color: var(--text-tertiary); font-size: var(--text-xs); padding: var(--space-1) var(--space-3); }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container { position: fixed; top: var(--space-4); right: var(--space-4); z-index: 10000; display: flex; flex-direction: column; gap: var(--space-2); }
.toast { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: 500; animation: slideInRight var(--transition-slow) both; max-width: 360px; }
.toast-info { background: var(--accent-blue-dim); color: var(--accent-blue); border: 1px solid rgba(37,99,235,0.3); }
.toast-success { background: var(--accent-green-dim); color: var(--accent-green); border: 1px solid rgba(34,197,94,0.3); }
.toast-warning { background: var(--accent-orange-dim); color: var(--accent-orange); border: 1px solid rgba(212,160,23,0.3); }
.toast-error { background: var(--accent-red-dim); color: var(--accent-red); border: 1px solid rgba(239,68,68,0.3); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
  .guide-panel { width: 0; min-width: 0; opacity: 0; pointer-events: none; }
}

@media (max-width: 900px) {
  .sidebar { width: var(--sidebar-collapsed); min-width: var(--sidebar-collapsed); }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .ws-explorer-grid { grid-template-columns: 1fr; }
  .ciis-scoring-editor { grid-template-columns: 1fr; }
  .cmd-workflow-editor { grid-template-columns: 1fr; }
  .pl-workflow-editor { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .page-container { padding: var(--space-4); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .chat-widget-panel { right: 8px; left: 8px; bottom: 80px; width: auto; }
  .chat-fab { right: 16px; bottom: 16px; }
}

/* ============================================================
   CPC NAVIGATION SIDEBAR — .cpc-nav-* namespace
   Multi-Segment Build
   ============================================================ */
.cpc-sidebar { width: 240px; min-width: 240px; border-right: var(--border-default); background: var(--bg-secondary); display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0; }
.cpc-sidebar-header { padding: 12px 16px; border-bottom: var(--border-default); display: flex; align-items: center; justify-content: space-between; }
.cpc-sidebar-header span { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.cpc-tree { flex: 1; overflow-y: auto; padding: 8px 0; }
.cpc-tree::-webkit-scrollbar { width: 3px; }
.cpc-tree::-webkit-scrollbar-thumb { background: var(--text-disabled); border-radius: 2px; }
.cpc-nav-section { padding: 4px 16px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-disabled); margin-top: 12px; }
.cpc-nav-section:first-child { margin-top: 0; }
.cpc-nav-class { padding: 6px 16px 6px 24px; font-size: 12px; color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; gap: 6px; transition: background var(--transition-fast); }
.cpc-nav-class:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.cpc-nav-class.expanded .cpc-nav-arrow { transform: rotate(90deg); }
.cpc-nav-arrow { font-size: 10px; transition: transform 0.15s; color: var(--text-disabled); flex-shrink: 0; }
.cpc-nav-subclass { padding: 4px 16px 4px 40px; font-size: 11px; color: var(--text-tertiary); }
.cpc-nav-segment-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600; cursor: pointer; margin: 2px 0 2px 48px; transition: all 0.15s; }
.cpc-nav-segment-badge.active { background: var(--accent-purple); color: #fff; }
.cpc-nav-segment-badge:not(.active) { background: var(--bg-tertiary); color: var(--text-secondary); border: var(--border-subtle); }
.cpc-nav-segment-badge:hover { background: var(--accent-purple-dim); color: var(--text-primary); }
.session-list-collapsible { border-top: var(--border-default); }
.session-list-header { padding: 8px 16px; font-size: 11px; font-weight: 600; color: var(--text-disabled); text-transform: uppercase; letter-spacing: 0.06em; cursor: pointer; display: flex; align-items: center; justify-content: space-between; }
.session-list-header:hover { color: var(--text-secondary); }

/* ============================================================
   VIEW MODE TOGGLE — .view-mode-toggle
   ============================================================ */
.view-mode-toggle { display: flex; border-radius: var(--radius-sm); overflow: hidden; border: var(--border-default); }
.view-mode-toggle button { padding: 3px 8px; font-size: 10px; background: transparent; border: none; color: var(--text-tertiary); cursor: pointer; font-family: var(--font-sans); transition: all var(--transition-fast); }
.view-mode-toggle button.active { background: var(--accent-purple); color: #fff; }
.view-mode-toggle button:not(.active):hover { background: var(--bg-tertiary); color: var(--text-secondary); }

/* ============================================================
   PROBLEM/SOLUTION FILTER BAR — .problem-filter-* namespace
   ============================================================ */
.problem-filter-bar { height: 48px; border-bottom: var(--border-default); display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--bg-secondary); flex-shrink: 0; }
.problem-filter-dropdown { background: var(--bg-tertiary); border: var(--border-default); border-radius: var(--radius-md); padding: 6px 10px; font-size: 11px; color: var(--text-primary); min-width: 180px; cursor: pointer; font-family: var(--font-sans); outline: none; transition: border-color var(--transition-fast); -webkit-appearance: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; padding-right: 24px; }
.problem-filter-dropdown:focus { border-color: var(--accent-purple); }
.problem-filter-dropdown option { background: var(--bg-secondary); color: var(--text-primary); }
.problem-filter-pills { display: flex; align-items: center; gap: 6px; flex: 1; overflow-x: auto; }
.problem-filter-pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 12px; font-size: 10px; font-weight: 600; background: var(--accent-purple-dim); color: var(--accent-purple); white-space: nowrap; animation: fade-in 0.2s both; }
.problem-filter-pill-close { cursor: pointer; opacity: 0.6; font-size: 11px; line-height: 1; }
.problem-filter-pill-close:hover { opacity: 1; }
.problem-filter-clear { background: transparent; border: var(--border-subtle); border-radius: var(--radius-sm); padding: 3px 8px; font-size: 10px; color: var(--text-tertiary); cursor: pointer; font-family: var(--font-sans); transition: all var(--transition-fast); }
.problem-filter-clear:hover { color: var(--text-secondary); border-color: var(--text-tertiary); }

/* ============================================================
   RAG SOLUTION PANEL — .rag-viz-* namespace
   ============================================================ */
.rag-viz-panel { height: 35%; border-top: var(--border-default); background: var(--bg-secondary); display: flex; flex-direction: column; flex-shrink: 0; min-height: 180px; }
.rag-viz-header { padding: 8px 16px; border-bottom: var(--border-default); display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-disabled); }
.rag-viz-count { font-family: var(--font-mono); font-size: 10px; color: var(--text-tertiary); font-weight: 400; }
.rag-viz-strip { flex: 1; display: flex; gap: 12px; overflow-x: auto; padding: 12px 16px; scroll-behavior: smooth; }
.rag-viz-strip::-webkit-scrollbar { height: 4px; }
.rag-viz-strip::-webkit-scrollbar-thumb { background: var(--text-disabled); border-radius: 2px; }

.rag-viz-card { width: 220px; min-width: 220px; border: var(--border-default); border-radius: var(--radius-md); padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--bg-primary); transition: all 0.3s; animation: ragCardIn 0.4s ease-out forwards; opacity: 0; }
.rag-viz-card.accepted { border-left: 3px solid var(--accent-green); }
.rag-viz-card.rejected { opacity: 0.45; }
.rag-viz-card.rejected .rag-viz-source { text-decoration: line-through; }

@keyframes ragCardIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes ragPulseGreen { 0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4); } 70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); } }
.rag-viz-card.accepted.pulse { animation: ragCardIn 0.4s ease-out forwards, ragPulseGreen 0.6s ease-out 0.4s; }

.rag-viz-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.rag-viz-source { font-family: var(--font-mono); font-size: 10px; padding: 2px 6px; border-radius: 4px; background: var(--accent-purple-dim); color: var(--accent-purple); display: inline-block; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rag-viz-score { font-family: var(--font-mono); font-size: 11px; font-weight: 600; flex-shrink: 0; }
.rag-viz-score.high { color: var(--accent-green); }
.rag-viz-score.medium { color: var(--accent-orange); }
.rag-viz-score.low { color: var(--accent-red); }
.rag-viz-problem { font-size: 11px; font-style: italic; border-left: 2px solid var(--accent-purple); padding-left: 8px; color: var(--text-secondary); line-height: 1.4; }
.rag-viz-solution { font-size: 11px; color: var(--text-tertiary); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.45; }
.rag-viz-card-bottom { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.rag-viz-verdict { font-size: 12px; }
.rag-viz-tokens { font-size: 10px; color: var(--text-disabled); font-family: var(--font-mono); }

/* ============================================================
   FLOW MONITOR — .flow-* namespace
   ============================================================ */
.flow-layout { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-height) - var(--context-banner-height) - var(--statusbar-height) - var(--demo-bar-height)); overflow: hidden; }
.flow-topbar { height: 48px; display: flex; align-items: center; gap: 16px; padding: 0 20px; border-bottom: var(--border-default); background: var(--bg-secondary); flex-shrink: 0; }
.flow-topbar-brand { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--accent-cyan); letter-spacing: 0.8px; }
.flow-topbar-sep { width: 1px; height: 18px; background: var(--text-disabled); }
.flow-topbar-status { font-family: var(--font-mono); font-size: 10px; color: var(--text-tertiary); display: flex; align-items: center; gap: 6px; }
.flow-dot { width: 6px; height: 6px; border-radius: 50%; }
.flow-dot-idle { background: var(--text-disabled); }
.flow-dot-live { background: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); animation: pulse-dot 1.5s infinite; }
.flow-dot-done { background: var(--accent-green); }
.flow-topbar-spacer { flex: 1; }
.flow-speed-control { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 10px; color: var(--text-tertiary); }
.flow-speed-control select { background: var(--bg-tertiary); border: var(--border-default); color: var(--text-secondary); font-family: var(--font-mono); font-size: 10px; padding: 3px 6px; border-radius: var(--radius-sm); cursor: pointer; outline: none; }
.flow-speed-control select:focus { border-color: var(--accent-cyan); }
.flow-segment-select { background: var(--bg-tertiary); border: var(--border-default); color: var(--text-primary); font-family: var(--font-mono); font-size: 11px; padding: 4px 10px; border-radius: var(--radius-md); cursor: pointer; outline: none; min-width: 180px; }
.flow-segment-select:focus { border-color: var(--accent-cyan); }
.flow-btn { font-family: var(--font-mono); font-size: 10px; padding: 5px 14px; border: var(--border-default); background: var(--bg-tertiary); color: var(--text-secondary); border-radius: var(--radius-sm); cursor: pointer; letter-spacing: 0.3px; transition: all var(--transition-fast); }
.flow-btn:hover { border-color: var(--text-tertiary); color: var(--text-primary); }
.flow-btn-go { background: var(--accent-cyan); border-color: var(--accent-cyan); color: var(--bg-primary); font-weight: 600; }
.flow-btn-go:hover { filter: brightness(1.15); }
.flow-btn-go:disabled { opacity: 0.5; cursor: default; filter: none; }

.flow-main { display: grid; grid-template-columns: repeat(5, 1fr); grid-template-rows: 1fr 1fr; gap: 1px; background: var(--text-disabled); flex: 1; overflow: hidden; }
.flow-bucket { background: var(--bg-primary); display: flex; flex-direction: column; overflow: hidden; position: relative; }
.flow-bucket.wide { grid-column: span 2; }
.flow-bucket.active { box-shadow: inset 0 1px 0 0 var(--accent-cyan-dim); }
.flow-bucket-header { padding: 10px 14px 8px; border-bottom: var(--border-subtle); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; position: relative; }
.flow-bucket-header-left { display: flex; align-items: center; gap: 8px; }
.flow-bucket-icon { width: 24px; height: 24px; border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; }
.flow-bucket-name { font-weight: 600; font-size: 12px; letter-spacing: -0.2px; color: var(--text-primary); }
.flow-bucket-phase { font-family: var(--font-mono); font-size: 9px; color: var(--text-disabled); letter-spacing: 0.5px; }
.flow-bucket-counter { font-family: var(--font-mono); font-size: 10px; padding: 2px 7px; border-radius: 3px; background: var(--bg-tertiary); color: var(--text-tertiary); min-width: 20px; text-align: center; }
.flow-bucket-progress { position: absolute; bottom: 0; left: 0; height: 2px; background: var(--accent-cyan); transition: width 0.4s ease; width: 0; }
.flow-bucket-body { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.flow-bucket-body::-webkit-scrollbar { width: 3px; }
.flow-bucket-body::-webkit-scrollbar-thumb { background: var(--text-disabled); border-radius: 2px; }
.flow-bucket-empty { flex: 1; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 10px; color: var(--text-disabled); opacity: 0.5; }

.flow-card { background: var(--bg-secondary); border: var(--border-subtle); border-radius: 5px; padding: 8px 10px; font-size: 11px; line-height: 1.5; animation: flowCardIn 0.35s cubic-bezier(0.16,1,0.3,1); position: relative; flex-shrink: 0; }
@keyframes flowCardIn { from { opacity: 0; transform: translateY(-8px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
.flow-card-tag { font-family: var(--font-mono); font-size: 9px; display: inline-flex; padding: 1px 5px; border-radius: 3px; margin-bottom: 4px; font-weight: 500; letter-spacing: 0.3px; }
.flow-card-text { color: var(--text-secondary); font-size: 10.5px; line-height: 1.55; word-break: break-word; }
.flow-card-text .hl { color: var(--accent-cyan); font-weight: 500; }
.flow-card-text .val { color: var(--accent-green); font-weight: 600; font-family: var(--font-mono); font-size: 10px; }
.flow-card-text .warn { color: var(--accent-orange); }
.flow-card-text .err { color: var(--accent-red); text-decoration: line-through; opacity: 0.5; }
.flow-card-meta { font-family: var(--font-mono); font-size: 9px; color: var(--text-disabled); margin-top: 4px; display: flex; justify-content: space-between; }
.flow-card-score { font-family: var(--font-mono); font-size: 10px; font-weight: 600; position: absolute; top: 8px; right: 10px; }
.flow-card-gov { border-left: 3px solid var(--accent-orange); }
.flow-card-chunk { border-left: 3px solid var(--accent-purple); }
.flow-card-embed { border-left: 3px solid var(--accent-blue); }
.flow-card-ranked { border-left: 3px solid var(--accent-green); }
.flow-card-rejected { border-left: 3px solid var(--accent-red); opacity: 0.45; }
.flow-card-context { border-left: 3px solid var(--accent-cyan); }
.flow-card-tool { border-left: 3px solid var(--accent-cyan); }
.flow-card-output { border-left: 3px solid var(--accent-green); }
.flow-card-bus { border-left: 3px solid var(--accent-green); }
.flow-card.rejected { opacity: 0.45; }
.flow-bucket-duration { font-family: var(--font-mono); font-size: 9px; color: var(--text-disabled); }
.flow-topbar { justify-content: space-between; }

.flow-token-meter { padding: 6px 10px; background: var(--bg-tertiary); border-radius: var(--radius-sm); margin-bottom: 6px; flex-shrink: 0; }
.flow-token-meter-label { font-family: var(--font-mono); font-size: 10px; color: var(--text-tertiary); display: flex; justify-content: space-between; }
.flow-token-meter-label .num { color: var(--text-primary); font-weight: 600; }
.flow-token-meter-bar { height: 5px; background: var(--bg-elevated); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.flow-token-meter-fill { height: 100%; background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue)); border-radius: 3px; width: 0; transition: width 0.6s ease; }
.flow-token-meter-fill.hot { background: linear-gradient(90deg, var(--accent-orange), var(--accent-red)); }

.flow-bus-item { display: flex; align-items: baseline; gap: 8px; padding: 5px 0; border-bottom: var(--border-subtle); animation: flowCardIn 0.3s ease; }
.flow-bus-key { font-family: var(--font-mono); font-size: 9.5px; color: var(--text-tertiary); min-width: 0; flex-shrink: 0; }
.flow-bus-val { font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--accent-green); }

.flow-event-count { font-family: var(--font-mono); font-size: 10px; color: var(--text-disabled); }

/* Timing bar */
.flow-timing-bar { height: 32px; display: flex; align-items: center; gap: 10px; padding: 0 20px; background: var(--bg-secondary); border-bottom: var(--border-default); flex-shrink: 0; }
.flow-timing-elapsed, .flow-timing-total { font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--text-secondary); min-width: 42px; }
.flow-timing-track { flex: 1; height: 4px; background: var(--bg-elevated); border-radius: 2px; overflow: hidden; }
.flow-timing-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple)); border-radius: 2px; transition: width 0.3s ease; }

/* Bucket grid — 5 col × 2 row with Tool Execution spanning 2 cols */
.flow-bucket-grid { display: grid; grid-template-columns: repeat(5, 1fr); grid-template-rows: 1fr 1fr; gap: 1px; background: var(--text-disabled); flex: 1; overflow: hidden; }

/* ============================================================
   GUIDE PANEL SEGMENT SUPPORT — additional guide styles
   ============================================================ */
.guide-segment-card { background: var(--bg-tertiary); border-radius: var(--radius-md); padding: 12px; font-size: 12px; }
.guide-segment-id { font-family: var(--font-mono); color: var(--accent-cyan); margin-bottom: 4px; }
.guide-segment-desc { color: var(--text-secondary); line-height: 1.5; }
.guide-segment-badges { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; }
.guide-tool-list { display: flex; flex-direction: column; gap: 4px; }
.guide-tool-item { font-family: var(--font-mono); font-size: 11px; color: var(--text-secondary); padding: 4px 8px; background: var(--bg-tertiary); border-radius: var(--radius-sm); }
.guide-compliance-item { font-size: 11px; color: var(--text-secondary); padding: 2px 0; }
.guide-ref-item { font-size: 11px; color: var(--accent-purple); padding: 2px 0; }

/* ── Context Banner ─────────────────────────────────────────── */
.context-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--context-banner-height);
  padding: 0 16px;
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  overflow-x: auto;
  scrollbar-width: none;
}
.context-banner::-webkit-scrollbar { display: none; }

.cb-zone { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.cb-zone-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim, var(--text-tertiary)); }

.cb-dropdown {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 12px;
  padding: 4px 24px 4px 8px;
  appearance: none;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.cb-dropdown:hover { border-color: var(--accent-cyan); }
.cb-dropdown:focus { border-color: var(--accent-cyan); box-shadow: 0 0 0 2px rgba(0,210,211,0.15); }

/* Segment pills */
.cb-pills { display: flex; gap: 4px; }
.cb-pill {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.cb-pill:hover { background: rgba(255,255,255,0.1); }
.cb-pill.active {
  background: var(--accent-cyan);
  color: #000;
  border-color: var(--accent-cyan);
}
.cb-pill.placeholder { opacity: 0.5; font-style: italic; }
.cb-pill.placeholder.active { background: rgba(0,210,211,0.3); color: var(--text-primary); }

/* Optional zones dimming */
.cb-zone.dimmed { opacity: 0.3; pointer-events: none; }
.cb-zone.dimmed .cb-dropdown { cursor: not-allowed; }

.cb-divider {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.1);
  flex-shrink: 0;
}
