/* ============================================================
   EXPERT PORTAL — DESIGN SYSTEM
   Premium dark enterprise aesthetic · Dialectica-aligned
   ============================================================ */

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

:root {
  /* Palette */
  --bg-primary:    #0a0e17;
  --bg-secondary:  #111827;
  --bg-tertiary:   #1a2234;
  --bg-card:       #141c2b;
  --bg-card-hover: #1a2438;
  --bg-surface:    #0f1623;

  --border-primary:   rgba(255,255,255,0.06);
  --border-secondary: rgba(255,255,255,0.10);
  --border-accent:    rgba(59,130,246,0.25);

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary:  #64748b;
  --text-muted:     #475569;

  --accent:         #3b82f6;
  --accent-hover:   #2563eb;
  --accent-subtle:  rgba(59,130,246,0.10);
  --accent-glow:    rgba(59,130,246,0.06);

  --success:        #10b981;
  --success-bg:     rgba(16,185,129,0.08);
  --success-border: rgba(16,185,129,0.20);

  --warning:        #f59e0b;
  --warning-bg:     rgba(245,158,11,0.08);
  --warning-border: rgba(245,158,11,0.20);

  --danger:         #ef4444;
  --danger-bg:      rgba(239,68,68,0.08);

  --ops-accent:     #8b5cf6;
  --ops-accent-bg:  rgba(139,92,246,0.08);
  --ops-border:     rgba(139,92,246,0.20);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 40px rgba(59,130,246,0.06);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --max-width: 1200px;
  --header-height: 64px;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* --- Layout --- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-xl);
}

.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-content {
  flex: 1;
  padding-top: var(--space-3xl);
  padding-bottom: var(--space-4xl);
}

/* --- Navigation --- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10,14,23,0.85);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--border-primary);
  height: var(--header-height);
  display: flex;
  align-items: center;
}

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

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 600;
  font-size: 0.9375rem;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.nav-brand .brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  list-style: none;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

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

.nav-link.active {
  color: var(--text-primary);
  background: rgba(255,255,255,0.08);
}

.nav-demo-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-subtle);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-full);
  margin-left: var(--space-sm);
}

/* Mobile nav */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: var(--space-sm);
}

@media (max-width: 768px) {
  .nav-links {
    display: none;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    padding: var(--space-md);
    gap: var(--space-xs);
  }
  .nav-links.open { display: flex; }
  .nav-toggle { display: block; }
  .nav-link { padding: 10px 14px; width: 100%; }
}

/* --- Typography --- */
.label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
}

.label-accent {
  color: var(--accent);
}

h1, .h1 {
  font-size: 2.75rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

h2, .h2 {
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

h3, .h3 {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

h4, .h4 {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text-primary);
}

.subtitle {
  font-size: 1.0625rem;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 640px;
}

.body-sm {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.body-xs {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  line-height: 1.55;
}

/* --- Hero --- */
.hero {
  padding: var(--space-4xl) 0;
  text-align: center;
  position: relative;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 500px;
  background: radial-gradient(ellipse at center, rgba(59,130,246,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.hero h1 {
  max-width: 780px;
  margin: 0 auto var(--space-lg);
}

.hero .subtitle {
  margin: 0 auto var(--space-2xl);
  max-width: 580px;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
  max-width: 900px;
  margin: var(--space-3xl) auto 0;
}

@media (max-width: 768px) {
  .hero { padding: var(--space-2xl) 0; }
  h1, .h1 { font-size: 2rem; }
  .hero-metrics { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .hero-metrics { grid-template-columns: 1fr; }
}

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  transition: all var(--transition-base);
}

.card:hover {
  border-color: var(--border-secondary);
}

.card-sm {
  padding: var(--space-lg);
}

.card-interactive:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-secondary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.card-highlight {
  border-color: var(--border-accent);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(59,130,246,0.03) 100%);
}

.card-ops {
  border-color: var(--ops-border);
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--ops-accent-bg) 100%);
}

/* --- Metric Card --- */
.metric-card {
  text-align: center;
  padding: var(--space-lg) var(--space-md);
}

.metric-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: var(--space-xs);
}

.metric-label {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  line-height: 1.45;
}

/* --- Sections --- */
.section {
  padding: var(--space-4xl) 0;
}

.section + .section {
  border-top: 1px solid var(--border-primary);
}

.section-header {
  margin-bottom: var(--space-2xl);
}

.section-header .label {
  margin-bottom: var(--space-sm);
}

.section-header h2 {
  margin-bottom: var(--space-sm);
}

/* --- Grid Layouts --- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-lg);
}

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

.grid-2-1 {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: var(--space-2xl);
}

.grid-1-2 {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: var(--space-2xl);
}

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4, .grid-2-1, .grid-1-2 {
    grid-template-columns: 1fr;
  }
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-default {
  color: var(--text-secondary);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-secondary);
}

.badge-accent {
  color: var(--accent);
  background: var(--accent-subtle);
  border: 1px solid var(--border-accent);
}

.badge-success {
  color: var(--success);
  background: var(--success-bg);
  border: 1px solid var(--success-border);
}

.badge-warning {
  color: var(--warning);
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
}

.badge-danger {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid rgba(239,68,68,0.20);
}

.badge-ops {
  color: var(--ops-accent);
  background: var(--ops-accent-bg);
  border: 1px solid var(--ops-border);
}

.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  border: 1px solid var(--border-secondary);
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.15);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8125rem;
}

.btn-full { width: 100%; }

/* --- Pillar Items --- */
.pillar-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.pillar-item {
  display: flex;
  gap: var(--space-lg);
  align-items: flex-start;
  padding: var(--space-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  transition: all var(--transition-base);
}

.pillar-item:hover {
  border-color: var(--border-secondary);
  background: var(--bg-card-hover);
}

.pillar-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: 1.125rem;
}

.pillar-content h4 {
  margin-bottom: var(--space-xs);
}

/* --- Pipeline / Steps --- */
.pipeline {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  padding: var(--space-sm) 0;
}

.pipeline-step {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-tertiary);
  white-space: nowrap;
  position: relative;
}

.pipeline-step.active {
  color: var(--accent);
}

.pipeline-step.completed {
  color: var(--success);
}

.pipeline-arrow {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin: 0 var(--space-xs);
}

.pipeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* --- Table-like rows --- */
.data-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-primary);
  transition: background var(--transition-fast);
}

.data-row:last-child { border-bottom: none; }
.data-row:hover { background: rgba(255,255,255,0.02); }

.data-row-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.data-row-value {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* --- Form Elements --- */
.form-group {
  margin-bottom: var(--space-lg);
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-sm);
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-input::placeholder {
  color: var(--text-muted);
}

textarea.form-input {
  resize: vertical;
  min-height: 100px;
}

/* --- Decision Blocks --- */
.decision-block {
  padding: var(--space-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.decision-block p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  font-style: italic;
}

/* --- Audit / Activity --- */
.audit-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--border-primary);
  font-size: 0.8125rem;
}

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

.audit-time {
  flex-shrink: 0;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  min-width: 140px;
}

.audit-event {
  color: var(--text-secondary);
}

.audit-event code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 2px 6px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

/* --- Demo Note --- */
.demo-note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: rgba(59,130,246,0.04);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.demo-note-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.8125rem;
}

/* --- Comparison --- */
.comparison-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.comparison-before {
  padding: var(--space-lg);
  background: var(--danger-bg);
  border: 1px solid rgba(239,68,68,0.15);
  border-radius: var(--radius-lg);
}

.comparison-after {
  padding: var(--space-lg);
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: var(--radius-lg);
}

.comparison-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-sm);
}

.comparison-before .comparison-label { color: var(--danger); }
.comparison-after .comparison-label { color: var(--success); }

.comparison-text {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

@media (max-width: 600px) {
  .comparison-row { grid-template-columns: 1fr; }
}

/* --- Ops-specific --- */
.ops-header {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(139,92,246,0.05) 100%);
  border: 1px solid var(--ops-border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  margin-bottom: var(--space-2xl);
}

/* --- Status indicators --- */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot-success { background: var(--success); }
.status-dot-warning { background: var(--warning); }
.status-dot-danger { background: var(--danger); }
.status-dot-neutral { background: var(--text-muted); }

/* --- Footer --- */
.footer {
  border-top: 1px solid var(--border-primary);
  padding: var(--space-2xl) 0;
  text-align: center;
}

.footer p {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* --- Utility --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }
.gap-2xl { gap: var(--space-2xl); }
.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mt-2xl { margin-top: var(--space-2xl); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.w-full { width: 100%; }
.max-w-narrow { max-width: 640px; }
.max-w-medium { max-width: 800px; }
.mx-auto { margin-left: auto; margin-right: auto; }

.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;
}

/* --- Animations --- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeInUp 0.5s var(--transition-base) both;
}

.animate-delay-1 { animation-delay: 100ms; }
.animate-delay-2 { animation-delay: 200ms; }
.animate-delay-3 { animation-delay: 300ms; }
.animate-delay-4 { animation-delay: 400ms; }

/* --- Separator --- */
.sep {
  height: 1px;
  background: var(--border-primary);
  margin: var(--space-2xl) 0;
}

/* --- Inline list --- */
.inline-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-full);
}

/* --- Progress bar --- */
.progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width var(--transition-slow);
}

/* --- Confidence bar --- */
.confidence-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.confidence-bar .progress-bar { flex: 1; }
.confidence-bar .confidence-value {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: right;
}
