 /* =========================================
   QRITON PLATFORM - COMPLETE COMPACT CSS
   Neural-Symbolic AI Enterprise System
   ========================================= */

/* ROOT VARIABLES - Dynamic & Responsive */
:root {
  /* Dynamic Spacing */
  --s: clamp(0.25rem, 1vw, 0.5rem);
  --s-xs: calc(var(--s) * 0.5);
  --s-sm: var(--s);
  --s-md: calc(var(--s) * 2);
  --s-lg: calc(var(--s) * 3);
  --s-xl: calc(var(--s) * 4);
  --s-2xl: calc(var(--s) * 6);
  
  /* Fluid Typography */
  --f-xs: clamp(0.625rem, 0.5rem + 0.5vw, 0.75rem);
  --f-sm: clamp(0.75rem, 0.7rem + 0.4vw, 0.875rem);
  --f-base: clamp(0.875rem, 0.8rem + 0.5vw, 1rem);
  --f-lg: clamp(1rem, 0.9rem + 0.6vw, 1.125rem);
  --f-xl: clamp(1.125rem, 1rem + 0.8vw, 1.25rem);
  --f-2xl: clamp(1.25rem, 1.1rem + 1vw, 1.5rem);
  --f-3xl: clamp(1.5rem, 1.3rem + 1.5vw, 2rem);
  --f-4xl: clamp(2rem, 1.5rem + 2.5vw, 3rem);
  --f-5xl: clamp(3rem, 2rem + 3vw, 4.5rem);
  
  /* Core Colors */
  --primary: #004d7d;
  --primary-light: #64c4ff;
  --primary-dark: #00314f;
  --primary-gradient: linear-gradient(135deg, var(--primary), var(--primary-light));
  
  /* Status Colors */
  --success: #059669;
  --warning: #d97706;
  --error: #dc2626;
  --info: #0891b2;
  
  /* Grays */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  
  /* Layout */
  --sidebar-width: min(280px, 30vw);
  --header-height: clamp(56px, 8vh, 72px);
  
  /* System Fonts */
  --font-family: -apple-system, BlinkMacSystemFont, 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  
  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 8px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 24px rgba(0,0,0,0.05), 0 5px 12px rgba(0,0,0,0.08);
  --shadow-xl: 0 20px 40px rgba(0,0,0,0.1);
  
  /* Transitions */
  --t-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Radius */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --r-xl: 12px;
  --r-full: 9999px;
}

/* BASE RESET */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font-family); font-size: var(--f-base); line-height: 1.6; color: var(--gray-900); background: var(--gray-50); -webkit-font-smoothing: antialiased; min-height: 100vh; }

/* LAYOUT COMPONENTS */
.app-container { display: flex; min-height: 100vh;   background: var(--gray-50); }
.sidebar { width: var(--sidebar-width); background: white; border-right: 1px solid var(--gray-200); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; transition: transform var(--t-base); }
.main-wrapper { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.top-header { height: var(--header-height); background: white; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; padding: 0 var(--s-lg); position: sticky; top: 0; z-index: 100; backdrop-filter: blur(8px); }
.header-title { font-size: var(--f-xl); font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: var(--s-md); }
.main-content { flex: 1; padding: var(--s-lg); overflow-y: auto; }


/* NAVIGATION */
.nav-menu { flex: 1; padding: var(--s-md) 0; overflow-y: hidden; }
.nav-section { margin-bottom: var(--s-xl); }
.nav-section-title { font-size: var(--f-xs); font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.05em; padding: 0 var(--s-lg); margin-bottom: var(--s-sm); }
.nav-item { display: flex; align-items: center; gap: var(--s-sm); padding: var(--s-sm) var(--s-lg); color: var(--gray-700); font-size: var(--f-sm); font-weight: 500; text-decoration: none; border: none; background: none; width: 100%; text-align: left; cursor: pointer; transition: all var(--t-fast); position: relative; }
.nav-item::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: transparent; transition: background var(--t-fast); }
.nav-item:hover { background: var(--gray-80); color: var(--primary); }
.nav-item.active { background: var(--primary); color: white; }
.nav-item.active::before { background: var(--primary-light); }
.nav-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }

/* COLLAPSIBLE SIDEBAR */
.sidebar { height: 100vh; overflow-y: hidden; -ms-overflow-style: none; scrollbar-width: none; }
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 998; }
.sidebar::-webkit-scrollbar { display: none; }
.sidebar.collapsed { width: 64px; transition: width var(--t-base); }
.sidebar.collapsed .sidebar-header { padding: var(--s-sm); }
.sidebar.collapsed .company-logo { font-size: 0; padding-left: 10px; margin-bottom: -10px; }
.sidebar.collapsed .company-logo svg, .sidebar.collapsed .nav-icon { width: 20px; height: 20px; margin: 0; color: var(--primary); }
.sidebar.collapsed .platform-tagline, .sidebar.collapsed .nav-item span:not(.nav-icon) { display: none; }
.sidebar.collapsed .nav-section-title { font-size: 0; text-align: center; margin: var(--s-xs) 0; }
.sidebar.collapsed .nav-section-title::before { content: ''; display: none; }
.sidebar.collapsed .nav-item { padding: var(--s-sm); gap: var(--s-xs); justify-content: center; position: relative; }
.sidebar.collapsed .nav-item + .nav-section-title { margin-top: var(--s-md); }
.sidebar .nav-item.active .nav-icon {  color: white;}
.sidebar .nav-item:hover .nav-icon:not(.active) {  color: var(--primary-light); }
.sidebar.collapsed .sidebar-toggle svg .ch1 { transform: translateX(-3px);   }
.sidebar.collapsed .sidebar-toggle svg .ch2 { transform: translateX(0); }
.sidebar.collapsed .sidebar-toggle svg .ch3 { transform: translateX(3px); }
.sidebar.collapsed .nav-item:hover .nav-item-tooltip { opacity: 1; }

/* TOGGLE BUTTON — TRIPLE ANIMATED CHEVRON */
.sidebar-header { display: flex; align-items: center; padding-left: 20px; justify-content: space-between; color: white; padding: var(--s-sm) var(--s-lg); }
.sidebar-toggle {
  width: 25px; height: 25px; background: none; border: none; padding: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  opacity: 0.4; transition: opacity var(--t-fast); z-index: 100; position: absolute; bottom: 20px; left: 15px;
}
.sidebar-toggle:hover { opacity: 0.6; color:var(--primary-light); }
.sidebar-toggle svg { transform: rotate(180deg); width: 35px; height: 35px; stroke: var(--gray-800); transition: transform var(--t-fast); }
.sidebar-toggle svg polyline { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0.6; transition: transform .3s ease, opacity .3s ease; }
.sidebar-toggle:hover svg polyline { opacity: 1; }
.sidebar:not(.collapsed) .sidebar-toggle svg .ch1 { transform: translateX(3px); }
.sidebar:not(.collapsed) .sidebar-toggle svg .ch2 { transform: translateX(0); }
.sidebar:not(.collapsed) .sidebar-toggle svg .ch3 { transform: translateX(-3px); }

/* TOOLTIP */
.nav-item-tooltip {
  position: absolute; left: calc(100% + var(--s-sm)); top: 50%; transform: translateY(-50%);
  background: var(--gray-900); color: white; padding: var(--s-xs) var(--s-sm); border-radius: var(--r-sm);
  font-size: var(--f-sm); white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity var(--t-fast); z-index: 100;
}
.nav-item-tooltip::before {
  content: ''; position: absolute; right: 100%; top: 50%; transform: translateY(-50%);
  border: 4px solid transparent; border-right-color: var(--gray-900);
}

/* LAYOUT FIX */
.app-container.sidebar-collapsed .main-wrapper { margin-left: 0; }

/* MOBILE */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .sidebar-toggle { display: none; }
  .sidebar.collapsed { width: 100%; }
  .sidebar.collapsed .nav-item span:not(.nav-icon) { display: inline; }
  .sidebar.collapsed .nav-section-title { font-size: var(--f-xs); }
  .sidebar.collapsed .nav-section-title::before { display: none; }
}


/* TOOLTIP */
.nav-item-tooltip {
  position: absolute; left: calc(100% + var(--s-sm)); top: 50%; transform: translateY(-50%);
  background: var(--gray-900); color: white; padding: var(--s-xs) var(--s-sm); border-radius: var(--r-sm);
  font-size: var(--f-sm); white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity var(--t-fast); z-index: 100;
}
.nav-item-tooltip::before {
  content: ''; position: absolute; right: 100%; top: 50%; transform: translateY(-50%);
  border: 4px solid transparent; border-right-color: var(--gray-900);
}

/* WRAPPER ADJUSTMENT */
.app-container.sidebar-collapsed .main-wrapper { margin-left: 0; }

/* MOBILE */
@media (max-width: 768px) {
  .sidebar-toggle { display: none; }
  .sidebar.collapsed { width: 100%; }
  .sidebar.collapsed .nav-item span:not(.nav-icon) { display: inline; }
  .sidebar.collapsed .nav-section-title { font-size: var(--f-xs); }
  .sidebar.collapsed .nav-section-title::before { display: none; }
}



/* BUTTONS */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-sm); padding: var(--s-sm) var(--s-md); border: none; border-radius: var(--r-md); font-size: var(--f-sm); font-weight: 500; cursor: pointer; transition: all var(--t-fast); white-space: nowrap; position: relative; overflow: hidden; }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-md); }
.btn-secondary { background: white; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-ghost { background: transparent; color: var(--primary); padding: var(--s-xs);   justify-content: flex-start; }
.btn-ghost:hover { background: var(--gray-50); }
.btn-sm { padding: calc(var(--s-xs) * 1.5) var(--s-sm); font-size: var(--f-xs); }

/* CARDS */
.card { background: white; border: 1px solid var(--gray-200); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); margin-bottom: var(--s-lg); transition: all var(--t-base); }
.card:hover { box-shadow: var(--shadow-md); }
.card-header { padding: var(--s-md) var(--s-lg); border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; gap: var(--s-md); }
.card-title { font-size: var(--f-lg); font-weight: 600; color: var(--gray-900); }
.card-body { padding: var(--s-lg); }

/* ===== THOUGHT NETWORK ANALYSIS STYLES ===== */

/* Complexity Indicator */
.complexity-indicator {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--gray-50);
  border-radius: 8px;
}

.complexity-bar {
  width: 100%;
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.complexity-fill {
  height: 100%;
  background: linear-gradient(90deg, 
    #10b981 0%, 
    #f59e0b 50%, 
    #ef4444 100%);
  transition: width 0.3s ease;
  border-radius: 4px;
}

.complexity-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  color: #8b5cf6;
  font-size: 0.875rem;
  font-weight: 500;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Decomposition View Container */
.decomposition-view {
  margin-top: 2rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, 
    rgba(139, 92, 246, 0.03) 0%, 
    rgba(59, 130, 246, 0.03) 100%);
  border: 2px solid rgba(139, 92, 246, 0.2);
  border-radius: 12px;
}

.decomposition-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(139, 92, 246, 0.1);
}

.decomposition-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  background: linear-gradient(135deg, #8b5cf6, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Thought Network Visualization */
.thought-network {
  background: white;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 1.5rem;
  min-height: 400px;
}

#thought-network-svg {
  width: 100%;
  height: 400px;
}

/* SVG Elements Styling */
.thought-network .node-circle {
  fill: #fff;
  stroke: #8b5cf6;
  stroke-width: 2px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.thought-network .node-circle:hover {
  stroke-width: 3px;
  filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.4));
}

.thought-network .node-circle.premise {
  stroke: #3b82f6;
}

.thought-network .node-circle.evidence {
  stroke: #10b981;
}

.thought-network .node-circle.conclusion {
  stroke: #8b5cf6;
}

.thought-network .node-circle.causal {
  stroke: #f59e0b;
}

.thought-network .node-circle.condition {
  stroke: #06b6d4;
}

.thought-network .synapse-line {
  stroke: #cbd5e1;
  stroke-width: 1.5;
  fill: none;
  stroke-dasharray: 0;
  transition: all 0.3s ease;
}

.thought-network .synapse-line.logical {
  stroke: #3b82f6;
  stroke-width: 2;
}

.thought-network .synapse-line.causal {
  stroke: #8b5cf6;
  stroke-width: 2;
}

.thought-network .synapse-line.evidential {
  stroke: #10b981;
  stroke-width: 2;
}

.thought-network .synapse-line.contradictory {
  stroke: #ef4444;
  stroke-width: 2;
  stroke-dasharray: 5, 5;
}

.thought-network .synapse-line.sequential {
  stroke: #94a3b8;
  stroke-width: 1;
  opacity: 0.5;
}

/* Animated flow effect */
@keyframes flow {
  0% {
    stroke-dashoffset: 24;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

.thought-network .synapse-line.flowing {
  stroke-dasharray: 8, 16;
  animation: flow 2s linear infinite;
}

/* Fragment Cards Grid */
.fragments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.fragment-card {
  background: white;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border-left: 4px solid;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.fragment-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
}

/* Fragment type colors */
.fragment-card[data-type="premise"] {
  border-left-color: #3b82f6;
}

.fragment-card[data-type="evidence"] {
  border-left-color: #10b981;
}

.fragment-card[data-type="conclusion"] {
  border-left-color: #8b5cf6;
}

.fragment-card[data-type="causal"] {
  border-left-color: #f59e0b;
}

.fragment-card[data-type="condition"] {
  border-left-color: #06b6d4;
}

.fragment-card[data-type="contrast"] {
  border-left-color: #ef4444;
}

.fragment-type {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  background: var(--gray-100);
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
  color: #64748b;
}

.fragment-text {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--gray-700);
  margin-bottom: 1rem;
  max-height: 100px;
  overflow-y: auto;
}

.fragment-score {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  background: linear-gradient(135deg, #8b5cf6, #3b82f6);
  color: white;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

/* Synapse Analysis */
.synapse-analysis {
  margin-top: 2rem;
  padding: 1.5rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.synapse-analysis h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--gray-900);
}

.synapse-item {
  display: grid;
  grid-template-columns: 120px 80px 1fr;
  gap: 1rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  background: var(--gray-50);
  border-radius: 6px;
  align-items: center;
  transition: background 0.2s ease;
}

.synapse-item:hover {
  background: var(--gray-100);
}

.synapse-type {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}

.synapse-type.logical {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
}

.synapse-type.causal {
  background: rgba(139, 92, 246, 0.1);
  color: #8b5cf6;
}

.synapse-type.evidential {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
}

.synapse-type.sequential {
  background: rgba(148, 163, 184, 0.1);
  color: #64748b;
}

.synapse-type.contradictory {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.synapse-strength {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
}

.synapse-strength::before {
  content: '';
  display: inline-block;
  width: 24px;
  height: 4px;
  background: linear-gradient(90deg, 
    transparent 0%, 
    currentColor 100%);
  border-radius: 2px;
  opacity: 0.6;
}

.synapse-reason {
  font-size: 0.8125rem;
  color: var(--gray-600);
  font-style: italic;
}

/* Enlightenment Summary */
.enlightenment-summary {
  margin-top: 2rem;
  padding: 1.5rem;
  background: linear-gradient(135deg, 
    rgba(139, 92, 246, 0.05) 0%, 
    rgba(59, 130, 246, 0.05) 100%);
  border-radius: 8px;
  border: 1px solid rgba(139, 92, 246, 0.2);
}

.enlightenment-score {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-bottom: 1rem;
}

.enlightenment-metric {
  flex: 1;
  text-align: center;
}

.enlightenment-metric-label {
  font-size: 0.75rem;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.enlightenment-metric-value {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #8b5cf6, #3b82f6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Loading Animation for Decomposition */
.decomposition-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
}

.thought-loader {
  width: 60px;
  height: 60px;
  position: relative;
}

.thought-loader::before,
.thought-loader::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: #8b5cf6;
  animation: thought-spin 1.5s linear infinite;
}

.thought-loader::after {
  width: 80%;
  height: 80%;
  top: 10%;
  left: 10%;
  border-top-color: #3b82f6;
  animation-duration: 2s;
  animation-direction: reverse;
}

@keyframes thought-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .fragments-grid {
    grid-template-columns: 1fr;
  }
  
  .synapse-item {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  
  .synapse-type,
  .synapse-strength {
    justify-self: start;
  }
  
  .thought-network {
    min-height: 300px;
  }
  
  #thought-network-svg {
    height: 300px;
  }
}

.synapse-link {
  fill: none;
}

.synapse-label {
  pointer-events: none;
}

.thought-node {
  cursor: move;
}

.thought-node:hover circle {
  filter: brightness(1.1);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
}

/* Tooltip for network nodes */
.thought-tooltip {
  position: absolute;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  border-radius: 6px;
  font-size: 0.875rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 1000;
  max-width: 250px;
}

.thought-tooltip.visible {
  opacity: 1;
}

.thought-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
}

/* FORMS */
.form-group { margin-bottom: var(--s-md); }
.form-label { display: block; font-size: var(--f-sm); font-weight: 500; color: var(--gray-700); margin-bottom: var(--s-xs); }
.form-input, .form-select, .form-textarea { width: 100%; padding: var(--s-sm) var(--s-md); border: 1px solid var(--gray-300); border-radius: var(--r-md); font-size: var(--f-sm); font-family: inherit; background: white; transition: all var(--t-fast); }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }
.form-textarea { resize: vertical; min-height: 120px; }
.form-range { width: 100%; }

/* BADGES */
.badge { display: inline-flex; align-items: center; padding: calc(var(--s-xs) * 0.5) var(--s-sm); border-radius: var(--r-full); font-size: var(--f-xs); font-weight: 500; }
.badge-success { background: rgba(5, 150, 105, 0.1); color: var(--success); }
.badge-warning { background: rgba(217, 119, 6, 0.1); color: var(--warning); }
.badge-error { background: rgba(220, 38, 38, 0.1); color: var(--error); }
.badge-info { background: rgba(8, 145, 178, 0.1); color: var(--info); }

/* TABLES */
.data-table { width: 100%; border-collapse: collapse; font-size: var(--f-sm); }
.data-table th { text-align: left; font-size: var(--f-xs); font-weight: 600; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.05em; padding: var(--s-sm) var(--s-md); background: var(--gray-50); border-bottom: 1px solid var(--gray-200); position: sticky; top: 0; z-index: 10; }
.data-table td { padding: var(--s-md); border-bottom: 1px solid var(--gray-100); }
.data-table tbody tr { transition: background var(--t-fast); }
.data-table tbody tr:hover { background: var(--gray-50); }

/* USER INTERFACE */
.user-menu { display: flex; align-items: center; gap: var(--s-sm); padding: var(--s-sm); border-radius: var(--r-md); background: var(--gray-50); }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: var(--f-sm); }
.company-logo { font-size: var(--f-3xl); font-weight: 700; color: var(--primary); margin-bottom: var(--s-sm); display: flex; align-items: center; justify-content: center; gap: var(--s-sm); }
.company-logo svg { width: 40px; height: 40px; }
.platform-tagline { text-align: center; color: var(--gray-600); margin-bottom: var(--s-xl); font-size: var(--f-sm); }

/* LOGIN */
.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%); padding: var(--s-md); }
.login-card { background: white; padding: var(--s-2xl); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 400px; }

/* HALLMETER SPECIFIC */
.hallmeter-container { position: relative; }
.probability-meter { --size: clamp(150px, 20vw, 200px); width: var(--size); height: var(--size); margin: var(--s-xl) auto; position: relative; }
.probability-circle { width: 100%; height: 100%; border-radius: 50%; position: relative; overflow: hidden; cursor: pointer; transition: all var(--t-base); transform-style: preserve-3d; }
.probability-circle:hover { transform: translateY(-4px) rotateX(5deg); box-shadow: 0 20px 40px rgba(0,0,0,0.15); }
.probability-circle::before { content: ''; position: absolute; inset: 10px; border-radius: 50%; background: white; z-index: 1; }
.probability-value { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: var(--f-5xl); font-weight: 700; z-index: 2; display: flex; align-items: baseline; }
.percentage-sign { font-size: 0.3em; margin-left: 0.1em; }

/* Probability States */
.prob-very-low { background: var(--error); color: var(--error); }
.prob-low { background: #f59e0b; color: #f59e0b; }
.prob-medium { background: #eab308; color: #eab308; }
.prob-good { background: #84cc16; color: #84cc16; }
.prob-very-good { background: #22c55e; color: #22c55e; }
.prob-excellent { background: #059669; color: #059669; }
.prob-perfect { background: var(--primary-gradient); color: var(--primary); animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }

/* QUANTUM VISUALIZER */
.quantum-visualizer { background: var(--gray-900); border-radius: var(--r-lg); padding: var(--s-lg); margin: var(--s-md) 0; position: relative; overflow: hidden; }
.quantum-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: var(--s-sm); }
.quantum-node { width: 40px; height: 40px; border-radius: 50%; background: rgba(59, 130, 246, 0.2); border: 2px solid rgba(59, 130, 246, 0.4); position: relative; transition: all var(--t-slow); cursor: pointer; }
.quantum-node.active { background: rgba(59, 130, 246, 0.6); border-color: var(--primary); box-shadow: 0 0 20px rgba(59, 130, 246, 0.8); animation: quantumPulse 1.5s ease-in-out infinite; }
.entanglement-line { position: absolute; height: 2px; background: linear-gradient(90deg, transparent, var(--primary), transparent); transform-origin: left center; animation: entanglementFlow 3s linear infinite; }

/* NEURAL MONITOR */
.neural-monitor { background: var(--gray-900); border-radius: var(--r-lg); padding: var(--s-md); margin: var(--s-md) 0; }
.neural-wave { height: 100px; position: relative; overflow: hidden; }
.wave-path { stroke: var(--primary); stroke-width: 2; fill: none; filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.6)); }

/* STATION CARDS */
.station-card { background: white; border: 1px solid var(--gray-200); border-radius: var(--r-lg); padding: var(--s-lg); margin-bottom: var(--s-md); transition: all var(--t-fast); position: relative; overflow: hidden; }
.station-card::before { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--gray-300); transition: background var(--t-base); }
.station-card.active::before { background: var(--success); }
.station-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.station-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-md); }
.station-name { font-size: var(--f-lg); font-weight: 600; color: var(--gray-900); }
.station-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-md); margin-top: var(--s-md); }
.station-metric { text-align: center; padding: var(--s-sm); background: var(--gray-50); border-radius: var(--r-md); }
.station-metric-value { font-size: var(--f-xl); font-weight: 600; color: var(--primary); }
.station-metric-label { font-size: var(--f-xs); color: var(--gray-600); }

/* AGENT CARDS */
.agent-card { background: white; border: 1px solid var(--gray-200); border-radius: var(--r-lg); padding: var(--s-lg); margin-bottom: var(--s-md); transition: all var(--t-fast); }
.agent-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.agent-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: var(--s-md); }
.agent-icon { width: 48px; height: 48px; border-radius: var(--r-lg); display: flex; align-items: center; justify-content: center; font-size: var(--f-2xl); background: var(--gray-100); margin-bottom: var(--s-sm); }
.agent-type-badge { display: inline-flex; align-items: center; padding: var(--s-xs) var(--s-sm); border-radius: var(--r-full); font-size: var(--f-xs); font-weight: 500; background: var(--primary); color: white; }
.agent-capabilities { display: flex; flex-wrap: wrap; gap: var(--s-sm); margin-top: var(--s-sm); }
.capability-tag { display: inline-flex; align-items: center; padding: var(--s-xs) var(--s-sm); border-radius: var(--r-sm); font-size: var(--f-xs); background: var(--gray-100); color: var(--gray-700); }

/* SCHEDULER CARDS */
.scheduler-card { background: white; border: 1px solid var(--gray-200); border-radius: var(--r-lg); padding: var(--s-lg); margin-bottom: var(--s-md); transition: all var(--t-fast); }
.scheduler-card:hover { box-shadow: var(--shadow-md); }
.scheduler-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s-md); }
.scheduler-name { font-weight: 600; color: var(--gray-900); }
.scheduler-status { display: flex; align-items: center; gap: var(--s-sm); }
.status-indicator { width: 8px; height: 8px; border-radius: 50%; background: var(--gray-400); }
.status-indicator.active { background: var(--success); animation: blink 2s ease-in-out infinite; }
.cron-expression { font-family: var(--font-mono); font-size: var(--f-sm); background: var(--gray-100); padding: var(--s-xs) var(--s-sm); border-radius: var(--r-sm); color: var(--gray-700); }

/* DATA SOURCES */
.datasource-item { display: flex; align-items: center; gap: var(--s-md); padding: var(--s-sm); background: var(--gray-50); border-radius: var(--r-md); margin-bottom: var(--s-sm); }
.datasource-selection-item:hover { background: var(--gray-50); }
.datasource-icon { width: 40px; height: 40px; border-radius: var(--r-lg); display: flex; align-items: center; justify-content: center; font-size: var(--f-xl); }
.datasource-icon.api { background: rgba(59, 130, 246, 0.1); color: var(--primary); }
.datasource-icon.database { background: rgba(168, 85, 247, 0.1); color: #a855f7; }
.datasource-icon.file { background: rgba(34, 197, 94, 0.1); color: var(--success); }
.datasource-icon.webhook { background: rgba(251, 146, 60, 0.1); color: #fb923c; }

/* COMPONENT CHART */
.component-chart { margin: var(--s-lg) 0; }
.component-score-item { background: var(--gray-50); padding: var(--s-sm); border-radius: var(--r-md); transition: all var(--t-fast); }
.component-score-item:hover { background: var(--gray-100); transform: translateX(4px); }

/* DASHBOARD GRID */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: var(--s-lg); margin-bottom: var(--s-xl); }
.transparency-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s-lg); margin-bottom: var(--s-xl); }
.metric-card { background: white; border: 0px solid var(--gray-200); border-radius: var(--r-lg); padding: var(--s-lg); box-shadow: var(--shadow-sm); transition: all var(--t-base); position: relative; overflow: hidden; }
.metric-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--primary-gradient); transform: scaleX(0); transform-origin: left; transition: transform var(--t-base); }
.metric-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.metric-card:hover::before { transform: scaleX(1); }
.metric-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-md); }
.metric-label { font-size: var(--f-sm); color: var(--gray-600); margin-bottom: var(--s-xs); }
.metric-value { font-size: var(--f-3xl); font-weight: 700; line-height: 1; margin-bottom: var(--s-sm); }
.metric-change { font-size: var(--f-xs); display: flex; align-items: center; gap: var(--s-xs); }
.metric-change.positive { color: var(--success); }
.metric-change.negative { color: var(--error); }
.metric-icon { width: 48px; height: 48px; border-radius: var(--r-lg); display: flex; align-items: center; justify-content: center; font-size: var(--f-2xl); flex-shrink: 0; }
.metric-icon.blue { background: rgba(59, 130, 246, 0.1); color: var(--primary); }
.metric-icon.green { background: rgba(5, 150, 105, 0.1); color: var(--success); }
.metric-icon.amber { background: rgba(217, 119, 6, 0.1); color: var(--warning); }

/* TRANSPARENCY METRICS */
.transparency-metric { background: white; border: 1px solid var(--gray-200); border-radius: var(--r-lg); padding: var(--s-lg); }

/* TASK RESULTS */
.task-result-card { background: white; border: 1px solid var(--gray-200); border-radius: var(--r-lg); overflow: hidden; margin-bottom: var(--s-lg); }
.task-result-header { background: var(--gray-50); padding: var(--s-md) var(--s-lg); border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.task-timeline { display: flex; align-items: center; gap: var(--s-md); padding: var(--s-md); background: var(--gray-50); border-bottom: 1px solid var(--gray-200); }
.timeline-step { flex: 1; text-align: center; }
.timeline-dot { width: 24px; height: 24px; border-radius: 50%; background: var(--gray-300); margin: 0 auto var(--s-xs); position: relative; }
.timeline-step.completed .timeline-dot { background: var(--success); }
.timeline-step.active .timeline-dot { background: var(--primary); animation: pulse 2s ease-in-out infinite; }
.timeline-label { font-size: var(--f-xs); color: var(--gray-600); }

/* EXPLANATION CARDS */
.explanation-card { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: var(--r-md); padding: var(--s-md); margin-bottom: var(--s-md); }
.explanation-header { display: flex; align-items: center; gap: var(--s-sm); margin-bottom: var(--s-sm); }
.explanation-type { display: inline-flex; align-items: center; padding: var(--s-xs) var(--s-sm); border-radius: var(--r-sm); font-size: var(--f-xs); font-weight: 500; }
.explanation-type.symbolic { background: rgba(251, 146, 60, 0.1); color: #fb923c; }
.explanation-type.neural { background: rgba(59, 130, 246, 0.1); color: var(--primary); }
.explanation-type.hallmeter { background: rgba(168, 85, 247, 0.1); color: #a855f7; }

/* RULE EVALUATION */
.rule-evaluation { font-family: var(--font-mono); font-size: var(--f-xs); background: white; padding: var(--s-sm); border-radius: var(--r-sm); margin-top: var(--s-sm); }
.rule-line { margin-bottom: var(--s-sm); }
.rule-matched { color: var(--success); }
.rule-not-matched { color: var(--gray-500); }

/* PROCESS FLOW */
.process-flow { display: flex; align-items: center; gap: var(--s-md); padding: var(--s-sm); background: var(--gray-50); border-radius: var(--r-lg); overflow-x: auto; }
.process-step { flex: 1; min-width: 80px; text-align: center;   }
.process-icon { width: 78px; height: 78px; margin: 0 auto var(--s-sm); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: var(--f-3xl); background: white; border: 1px solid var(--gray-300); transition: all var(--t-base); }
.process-step.active .process-icon { color: white;  border:1px solid var(--gray-200);  }
.process-label { font-size: var(--f-xs);   color: var(--gray-700); }
.process-connector { flex: 0 0 40px; height: 2px; background: var(--gray-300); position: relative; }

/* EVOLUTION BADGES */
.evolution-badge { display: inline-flex; padding: var(--s-xs) var(--s-sm); border-radius: var(--r-sm); font-size: var(--f-xs); font-weight: 600; text-transform: capitalize; }
.evolution-badge.observation { background: rgba(251, 191, 36, 0.1); color: #f59e0b; }
.evolution-badge.hypothesis { background: rgba(96, 165, 250, 0.1); color: #3b82f6; }
.evolution-badge.theory { background: rgba(167, 139, 250, 0.1); color: #8b5cf6; }
.evolution-badge.law { background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(59, 130, 246, 0.1)); color: #6366f1; }

/* EVOLUTION TIMELINE */
.evolution-timeline { background: white; border: 1px solid var(--gray-200); border-radius: var(--r-lg); padding: var(--s-lg); }
.evolution-timeline h3 { font-size: var(--f-lg); font-weight: 600; margin-bottom: var(--s-md); }
.timeline-track { position: relative; height: 60px; background: var(--gray-100); border-radius: 30px; overflow: hidden; display: flex; }
.timeline-stage { flex: 1; position: relative; }
.stage-marker { position: absolute; left: 0; top: 0; height: 100%; display: flex; align-items: center; justify-content: center; flex-direction: column; transition: all var(--t-slow); }
.stage-marker.observation { background: #fbbf24; }
.stage-marker.hypothesis { background: #60a5fa; }
.stage-marker.theory { background: #a78bfa; }
.stage-marker.law { background: linear-gradient(135deg, #8b5cf6, #3b82f6); }
.stage-label { font-size: var(--f-xs); font-weight: 600; color: white; text-transform: capitalize; }
.stage-count { font-size: var(--f-xl); font-weight: 700; color: white; }

/* CAUSAL GRAPH */
/* ===== CAUSAL GRAPH ENHANCED VISUALIZATION ===== */

/* Container and Controls */
.causal-controls {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.control-group {
  flex: 1;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.control-group label {
  font-size: 0.75rem;
  color: #6b7280;
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.control-group .form-range {
  width: 100%;
}

.range-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: #3b82f6;
}

/* Graph Container */
.causal-graph-container {
  position: relative;
  background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
  border-radius: 12px;
  height: 600px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  margin-bottom: 1.5rem;
  overflow: hidden;
  border: 1px solid #e5e7eb;
}

#causal-graph-svg {
  width: 100%;
  height: 100%;
  cursor: grab;
}

#causal-graph-svg:active {
  cursor: grabbing;
}

/* Zoom Controls */
.zoom-controls rect {
  transition: all 0.2s;
}

.zoom-controls rect:hover {
  fill: #f3f4f6 !important;
  stroke: #9ca3af !important;
}

/* Graph Legend */
.graph-legend rect {
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

/* Nodes - Enhanced Styling */
.node {
  cursor: pointer;
  transition: all 0.2s;
}

.node-circle {
  stroke: white;
  stroke-width: 3px;
  transition: all 0.2s ease;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.node-circle:hover {
  stroke-width: 4px;
  filter: brightness(1.15) drop-shadow(0 4px 12px rgba(0,0,0,0.15));
  transform: scale(1.05);
}

/* Evolution Stage Node Colors */
.node.observation .node-circle { 
  fill: #10b981; 
}

.node.hypothesis .node-circle { 
  fill: #06b6d4; 
}

.node.theory .node-circle { 
  fill: #3b82f6; 
}

.node.law .node-circle { 
  fill: url(#law-gradient); 
  filter: drop-shadow(0 0 12px rgba(139,92,246,0.5));
  animation: lawPulse 3s ease-in-out infinite;
}

@keyframes lawPulse {
  0%, 100% { 
    filter: drop-shadow(0 0 12px rgba(139,92,246,0.5)); 
  }
  50% { 
    filter: drop-shadow(0 0 20px rgba(139,92,246,0.8)); 
  }
}

/* Node States */
.node.dimmed {
  opacity: 0.2;
  transition: opacity 0.3s;
}

.node.selected .node-circle {
  stroke: #fbbf24;
  stroke-width: 4px;
  filter: drop-shadow(0 0 15px rgba(251,191,36,0.6));
}

.node.pulsing circle {
  animation: nodePulse 2s ease-in-out infinite;
}

@keyframes nodePulse {
  0%, 100% { 
    transform: scale(1); 
    opacity: 1; 
  }
  50% { 
    transform: scale(1.15); 
    opacity: 0.9; 
  }
}

/* Node Labels */
.node-label {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 11px;
  fill: #374151;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(255,255,255,0.8);
  font-weight: 500;
}

.node-icon {
  font-size: 14px;
  fill: white;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  font-weight: bold;
}

/* Edges - Enhanced Styling */
.edge {
  fill: none;
  stroke-opacity: 0.4;
  transition: all 0.2s ease;
  stroke-linecap: round;
}

.edge:hover {
  stroke-opacity: 0.9;
  stroke-width: 4px !important;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.edge.dimmed {
  stroke-opacity: 0.1;
  transition: stroke-opacity 0.3s;
}

.edge.highlighted {
  stroke-opacity: 1 !important;
  stroke-width: 4px !important;
  filter: drop-shadow(0 0 6px currentColor);
}

/* Flowing Animation */
.edge.flowing {
  stroke-dasharray: 8, 4;
  animation: flowAnimation 2s linear infinite;
}

@keyframes flowAnimation {
  from { 
    stroke-dashoffset: 12; 
  }
  to { 
    stroke-dashoffset: 0; 
  }
}

/* Edge Labels */
.edge-label {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 10px;
  fill: #6b7280;
  font-weight: 500;
  background: white;
  padding: 2px 4px;
  border-radius: 3px;
}

/* Arrow Markers */
.arrow-marker {
  fill: #6b7280;
  opacity: 0.8;
}

/* Panels - Floating Cards */
.node-details-panel,
.predictions-panel {
  position: absolute;
  width: 280px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  max-height: 400px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid #e5e7eb;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.node-details-panel { 
  top: 1rem; 
  right: 1rem; 
}

.predictions-panel { 
  bottom: 1rem; 
  right: 1rem; 
}

.panel-header {
  padding: 0.75rem;
  background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h3 {
  font-size: 0.875rem;
  font-weight: 600;
  margin: 0;
}

.panel-header button {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 18px;
  line-height: 1;
}

.panel-header button:hover {
  background: rgba(255,255,255,0.3);
  transform: scale(1.1);
}

.panel-body {
  padding: 0.75rem;
  overflow-y: auto;
  flex: 1;
  background: white;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.detail-item {
  display: flex;
  flex-direction: column;
}

.detail-label {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  margin-bottom: 0.125rem;
  font-weight: 600;
}

.detail-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: #111827;
}

/* Evolution Badges */
.evolution-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.evolution-badge.observation { 
  background: #d1fae5; 
  color: #065f46; 
}

.evolution-badge.hypothesis { 
  background: #cffafe; 
  color: #155e75; 
}

.evolution-badge.theory { 
  background: #dbeafe; 
  color: #1e40af; 
}

.evolution-badge.law { 
  background: linear-gradient(135deg, #ede9fe 0%, #dbeafe 100%);
  color: #5b21b6;
  box-shadow: 0 1px 2px rgba(139,92,246,0.3);
}

/* Stats Grid */
.graph-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: white;
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: all 0.2s;
  border: 1px solid #e5e7eb;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  flex-shrink: 0;
}

.stat-icon svg {
  width: 20px;
  height: 20px;
}

.stat-content {
  flex: 1;
  min-width: 0;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  color: #111827;
  margin-bottom: 0.125rem;
}

.stat-label {
  font-size: 0.75rem;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Graph Tooltip */
.graph-tooltip {
  position: absolute;
  padding: 0.75rem;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(8px);
  color: white;
  font-size: 0.75rem;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 1000;
  max-width: 220px;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
}

.graph-tooltip.visible {
  opacity: 1;
}

.graph-tooltip strong {
  color: #fbbf24;
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.8125rem;
}

.graph-tooltip div {
  margin: 0.25rem 0;
}

/* Evolution Timeline */
.evolution-timeline {
  background: white;
  padding: 1rem;
  border-radius: 8px;
  margin-top: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  border: 1px solid #e5e7eb;
}

.evolution-timeline h3 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #374151;
}

.timeline-track {
  display: flex;
  height: 40px;
  background: #f3f4f6;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
}

.timeline-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.timeline-stage:hover {
  filter: brightness(1.1);
}

.stage-marker {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.stage-marker.observation { 
  background: linear-gradient(135deg, #10b981 0%, #059669 100%); 
}

.stage-marker.hypothesis { 
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%); 
}

.stage-marker.theory { 
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); 
}

.stage-marker.law { 
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); 
}

.stage-label {
  font-size: 0.625rem;
  font-weight: 600;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.stage-count {
  font-size: 0.875rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .causal-graph-container { 
    height: 400px; 
  }
  
  .node-details-panel,
  .predictions-panel { 
    width: calc(100% - 2rem);
    left: 1rem;
    right: 1rem;
    max-height: 300px;
  }
  
  .graph-stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .control-group {
    min-width: 100%;
  }
  
  .graph-legend {
    transform: scale(0.8);
    transform-origin: top right;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .causal-graph-container {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    border-color: #374151;
  }
  
  #causal-graph-svg {
    background: transparent;
  }
  
  .node-label {
    fill: #e5e7eb;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  }
  
  .graph-tooltip {
    background: rgba(31, 41, 55, 0.95);
    border-color: rgba(255,255,255,0.05);
  }
  
  .zoom-controls rect,
  .graph-legend rect {
    fill: #1f2937;
    stroke: #374151;
  }
  
  .zoom-controls text,
  .graph-legend text {
    fill: #e5e7eb;
  }
}
/* Graph Stats */
.graph-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s-md); margin-bottom: var(--s-lg); }
.stat-card { background: white; border: 1px solid var(--gray-200); border-radius: var(--r-lg); padding: var(--s-md); display: flex; align-items: center; gap: var(--s-md); }
.stat-icon { width: 48px; height: 48px; border-radius: var(--r-lg); background: var(--gray-100); display: flex; align-items: center; justify-content: center; color: var(--primary); }
.stat-content { flex: 1; }
.stat-value { font-size: var(--f-2xl); font-weight: 700; color: var(--gray-900); }
.stat-label { font-size: var(--f-sm); color: var(--gray-600); }

/* BIAS AUDIT */
.bias-audit-container { margin-top: var(--s-md); }
.bias-check-item { padding: var(--s-sm); margin-bottom: var(--s-sm); border-radius: var(--r-sm); }
.bias-check-item.detected { background: rgba(217, 119, 6, 0.1); }
.bias-check-item.passed { background: rgba(5, 150, 105, 0.1); }

/* INFO PANELS */
.info-panel { background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: var(--r-md); padding: var(--s-md); margin-bottom: var(--s-md); }
.info-panel-header { display: flex; align-items: center; gap: var(--s-sm); margin-bottom: var(--s-sm); }
.info-icon { width: 20px; height: 20px; color: var(--info); flex-shrink: 0; }
.info-title { font-weight: 600; color: var(--gray-900); font-size: var(--f-sm); }
.info-text { color: var(--gray-600); font-size: var(--f-sm); line-height: 1.6; }

/* CODE BLOCKS */
.code-block { background: var(--gray-900); color: var(--gray-100); padding: var(--s-md); border-radius: var(--r-md); font-family: var(--font-mono); font-size: var(--f-sm); overflow-x: auto; line-height: 1.5; }
.architecture-diagram { background: var(--gray-900); color: var(--gray-100); padding: var(--s-xl); border-radius: var(--r-lg); margin: var(--s-lg) 0; font-family: var(--font-mono); font-size: var(--f-sm); overflow-x: auto; white-space: pre; }

/* DOCUMENTATION */
.doc-section { margin-bottom: var(--s-xl); }
.doc-section h3 { font-size: var(--f-xl); font-weight: 600; margin-bottom: var(--s-md); }
.doc-section h4 { font-size: var(--f-lg); font-weight: 600; margin: var(--s-lg) 0 var(--s-sm); }
.doc-section ul { margin-left: var(--s-lg); margin-top: var(--s-sm); }
.doc-section li { margin-bottom: var(--s-sm); color: var(--gray-600); }

/* MODALS */  
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: var(--s-md); animation: fadeIn var(--t-fast); overflow-y: auto; }
.modal { background: white; border-radius: var(--r-xl); box-shadow: var(--shadow-xl); max-width: min(600px, 90vw); width: 100%; max-height: 90vh; display: flex; flex-direction: column; animation: slideUp var(--t-base); position: relative; }
.modal-header { padding: var(--s-lg); border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; gap: var(--s-md); flex-shrink: 0; }
.modal-title { font-size: var(--f-xl); font-weight: 600; }
.modal-body { padding: var(--s-lg); overflow-y: auto; overflow-x: hidden; flex: 1; min-height: 0; background: var(--gray-50); scrollbar-width: thin; scrollbar-color: var(--gray-400) var(--gray-100); }
.modal-body::-webkit-scrollbar { width: 8px; display: block !important; }
.modal-body::-webkit-scrollbar-track { background: var(--gray-100); border-radius: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: var(--gray-400); border-radius: 4px; }
.modal-body::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }
.modal-body > * { background: white; padding: var(--s-md); border-radius: var(--r-md); margin-bottom: var(--s-md); }
.modal-footer { padding: var(--s-lg); border-top: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: flex-end; gap: var(--s-sm); flex-shrink: 0; }

/* UTILITIES */
.loading-spinner { --spinner-size: 40px; width: var(--spinner-size); height: var(--spinner-size); border: 3px solid var(--gray-200); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
.empty-state { text-align: center; padding: var(--s-2xl); }
.empty-icon { font-size: 4rem; margin-bottom: var(--s-md); opacity: 0.5; }
.empty-title { font-size: var(--f-xl); font-weight: 600; margin-bottom: var(--s-sm); }
.empty-text { color: var(--gray-600); font-size: var(--f-base); }
.typewriter { font-family: var(--font-mono); overflow: hidden; white-space: nowrap; margin: 0 auto; letter-spacing: 0.05em; animation: typing 3.5s steps(40, end); }
.cursor { display: inline-block; width: 2px; height: 1.2em; background: var(--primary); animation: blink-caret 0.75s step-end infinite; }
.graph-tooltip { position: absolute; padding: var(--s-sm); background: rgba(0, 0, 0, 0.9); color: white; font-size: var(--f-xs); border-radius: var(--r-sm); pointer-events: none; z-index: 100; opacity: 0; transition: opacity var(--t-base); }
.graph-tooltip.visible { opacity: 1; }
#confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 9999; }

/* ANIMATIONS */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.9; transform: scale(1.05); } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
@keyframes quantumPulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.2); opacity: 0.8; } }
@keyframes entanglementFlow { 0% { opacity: 0; } 50% { opacity: 1; } 100% { opacity: 0; } }
@keyframes typing { from { width: 0 } to { width: 100% } }
@keyframes blink-caret { from, to { background-color: transparent } 50% { background-color: var(--primary) } }
@keyframes highlightPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0); } 50% { box-shadow: 0 0 20px 10px rgba(168, 85, 247, 0.3); } }
@keyframes pulse-node { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@keyframes flow-edge { 0% { stroke-dashoffset: 10; } 100% { stroke-dashoffset: 0; } }
@keyframes skeleton-loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* NODE & EDGE GRAPH STATES */
.node.pulsing { animation: pulse-node 2s ease-in-out infinite; }
.edge.flowing { stroke-dasharray: 5 5; animation: flow-edge 1s linear infinite; }
.node.dimmed { opacity: 0.3; }
.edge.dimmed { opacity: 0.2; }
.node.selected { filter: brightness(1.3); }
.edge.highlighted { stroke-width: 4px !important; stroke-opacity: 1 !important; }
.highlight-new { animation: highlightPulse 1s ease 3; }

/* RESPONSIVE DESIGN */
@media (max-width: 1024px) {
  :root { --sidebar-width: 240px; --header-height: 60px; }
  .dashboard-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
  .main-content { padding: var(--s-md); }
  .metric-value { font-size: var(--f-2xl); }
}

@media (max-width: 768px) {
  .app-container { flex-direction: column; }
  .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--gray-200); position: relative; max-height: 60vh; }
  .main-wrapper { min-height: auto; }
  .top-header { padding: 0 var(--s-md); position: relative; }
  .dashboard-grid, .transparency-grid { grid-template-columns: 1fr; gap: var(--s-md); }
  .nav-section { margin-bottom: var(--s-lg); }
  .card-header { flex-wrap: wrap; }
  .data-table { font-size: var(--f-xs); }
  .data-table th, .data-table td { padding: var(--s-sm); }
  .station-metrics { grid-template-columns: 1fr; }
  .process-flow { flex-direction: column; }
  .process-connector { width: 2px; height: 40px; }
}

@media (max-width: 640px) {
  :root { --header-height: 56px; --s: 0.25rem; }
  .main-content { padding: var(--s-sm); }
  .card { margin-bottom: var(--s-md); }
  .card-body { padding: var(--s-md); }
  .modal { max-width: 100%; max-height: 100%; border-radius: 0; }
  .btn { padding: var(--s-sm); font-size: var(--f-xs); }
  .metric-card { padding: var(--s-md); }
  .probability-meter { --size: 150px; }
  .data-table { display: block; overflow-x: auto; white-space: nowrap; }
}

@media (max-width: 400px) {
  .header-title { font-size: var(--f-lg); }
  .user-menu { padding: var(--s-xs); }
  .user-menu span { display: none; }
  .nav-item { padding: var(--s-sm); font-size: var(--f-xs); }
}

/* HOVER STATES FOR TOUCH */
@media (hover: hover) {
  .btn:hover::before { transform: translateX(0); }
}

/* PRINT STYLES */
@media print {
  .sidebar, .top-header, .btn, .modal-overlay { display: none !important; }
  .main-wrapper { width: 100%; }
  .main-content { padding: 0; max-width: 100%; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
}

/* HIGH CONTRAST */
@media (prefers-contrast: high) {
  :root { --primary: #0040dd; --gray-200: #ccc; --gray-300: #999; }
  .btn:focus-visible { outline-width: 3px; }
}

/* REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* DARK MODE SUPPORT */
@media (prefers-color-scheme: dark) {
  :root {
    --gray-50: #111827; --gray-100: #1f2937; --gray-200: #374151; --gray-300: #4b5563;
    --gray-400: #6b7280; --gray-500: #9ca3af; --gray-600: #d1d5db; --gray-700: #e5e7eb;
    --gray-800: #f3f4f6; --gray-900: #f9fafb;
  }
}

/* SMOOTH SCROLLBARS */
* { scrollbar-width: thin; scrollbar-color: var(--gray-400) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--gray-400); border-radius: var(--r-sm); }
*::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* FOCUS STYLES */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* HELPER CLASSES */
.text-sm { font-size: var(--f-sm); }
.text-xs { font-size: var(--f-xs); }
.text-lg { font-size: var(--f-lg); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.m-0 { margin: 0; }
.mt-1 { margin-top: var(--s-sm); }
.mt-2 { margin-top: var(--s-md); }
.mb-1 { margin-bottom: var(--s-sm); }
.mb-2 { margin-bottom: var(--s-md); }
.p-1 { padding: var(--s-sm); }
.p-2 { padding: var(--s-md); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--s-sm); }
.gap-2 { gap: var(--s-md); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0; }
 