/* ╔════════════════════════════════════════════════════════════════════════════╗
   ║  CPAF v6 - styles.css                                                       ║
   ║  Complete Stylesheet                                                        ║
   ╚════════════════════════════════════════════════════════════════════════════╝ */

/* ========== RESET & BASE ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f8fafc;
  color: #1e293b;
  font-size: 13px;
  line-height: 1.5;
}

/* ========== HEADER ========== */
.header {
  background: linear-gradient(135deg, #1e40af, #7c3aed);
  color: #fff;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.header-brand h1 {
  font-size: 18px;
  font-weight: 300;
}
.header-brand h1 strong {
  font-weight: 700;
  color: #86efac;
}
.header-sub {
  font-size: 10px;
  opacity: 0.85;
}
.header-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.case-select {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 11px;
  cursor: pointer;
}
.case-select option { color: #1e293b; }
.speed-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
}
.speed-control input { width: 60px; }
.time-display {
  background: rgba(0,0,0,0.2);
  padding: 6px 12px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 11px;
}
.time-display strong { color: #86efac; }

/* ========== BUTTONS ========== */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-run {
  background: #10b981;
  color: #fff;
}
.btn-run:hover { background: #059669; }
.btn-run.running { background: #ef4444; }
.btn-reset {
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
}
.btn-reset:hover { background: rgba(255,255,255,0.3); }
.btn-admin {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
}
.btn-admin:hover { background: rgba(255,255,255,0.25); }

/* ========== SUMMARY BAR ========== */
.summary-bar {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 8px 20px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 11px;
}
.summary-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.summary-item.warning .summary-text {
  color: #dc2626;
  font-weight: 600;
}
.summary-item.success .summary-text {
  color: #16a34a;
  font-weight: 600;
}
.btn-primary {
  background: #2563eb;
  color: #fff;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary {
  background: #e2e8f0;
  color: #475569;
}
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger {
  background: #ef4444;
  color: #fff;
}
.btn-danger:hover { background: #dc2626; }
.btn-warning {
  background: #f59e0b;
  color: #fff;
}
.btn-warning:hover { background: #d97706; }
.btn-small {
  padding: 4px 10px;
  font-size: 10px;
}

/* ========== MAIN GRID ========== */
.main-grid {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  gap: 12px;
  padding: 12px;
  min-height: calc(100vh - 70px);
}
@media (max-width: 1200px) {
  .main-grid { grid-template-columns: 1fr; }
}

/* ========== PANELS ========== */
.panel {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.panel-header {
  background: #f8fafc;
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-icon { font-size: 14px; }
.panel-body {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
}

/* ========== DIMENSION CARDS ========== */
.dim-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  border-left: 4px solid var(--c, #64748b);
  transition: all 0.3s;
  cursor: pointer;
}
.dim-card:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
.dim-card.active {
  background: var(--bg, #f1f5f9);
  border-color: var(--c);
  box-shadow: 0 0 12px var(--glow, rgba(0,0,0,0.1));
}
.dim-card[data-dim="D1"] { --c: #059669; --bg: #dcfce7; --glow: rgba(5,150,105,0.3); }
.dim-card[data-dim="D2"] { --c: #d97706; --bg: #fef3c7; --glow: rgba(217,119,6,0.3); }
.dim-card[data-dim="D3"] { --c: #7c3aed; --bg: #ede9fe; --glow: rgba(124,58,237,0.3); }
.dim-card[data-dim="D4"] { --c: #2563eb; --bg: #dbeafe; --glow: rgba(37,99,235,0.3); }
.dim-card[data-dim="D5"] { --c: #0891b2; --bg: #cffafe; --glow: rgba(8,145,178,0.3); }
.dim-card[data-dim="D6"] { --c: #db2777; --bg: #fce7f3; --glow: rgba(219,39,119,0.3); }
.dim-card[data-dim="D7"] { --c: #64748b; --bg: #f1f5f9; --glow: rgba(100,116,139,0.3); }

.dim-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.dim-label {
  font-size: 9px;
  color: #64748b;
  text-transform: uppercase;
  font-weight: 600;
}
.dim-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--c);
}
.dim-value {
  font-size: 20px;
  font-weight: 700;
  color: #1e293b;
  margin: 2px 0;
}
.dim-value.trap { color: #dc2626; }
.dim-value.transition { color: #f59e0b; }
.dim-value.growth { color: #16a34a; }
.dim-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
}
.dim-bar-fill {
  height: 100%;
  background: var(--c);
  border-radius: 3px;
  transition: width 0.5s;
}
.dim-status {
  font-size: 9px;
  color: #64748b;
  margin-top: 4px;
  line-height: 1.4;
}

/* ========== NPF NARRATIVE DISPLAY ========== */
.npf-display {
  background: #faf5ff;
  border: 1px solid #e9d5ff;
  border-radius: 4px;
  padding: 6px;
  margin-top: 6px;
  font-size: 9px;
}
.npf-narrative {
  font-weight: 600;
  color: #7c3aed;
  margin-bottom: 4px;
}
.npf-characters {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.npf-char {
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 8px;
  white-space: nowrap;
}
.npf-char.hero {
  background: #dcfce7;
  color: #166534;
}
.npf-char.villain {
  background: #fee2e2;
  color: #991b1b;
}
.npf-char.victim {
  background: #fef3c7;
  color: #92400e;
}
.npf-coalitions {
  display: flex;
  gap: 4px;
}
.coalition-bar {
  flex: 1;
  height: 14px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.coalition-fill {
  height: 100%;
  transition: width 0.3s;
}
.coalition-fill.welfare {
  background: linear-gradient(90deg, #7c3aed, #a855f7);
}
.coalition-fill.market {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}
.coalition-label {
  position: absolute;
  top: 0;
  font-size: 7px;
  line-height: 14px;
  padding: 0 3px;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
}

/* ========== COUPLINGS ========== */
.coupling-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}
.coupling-title {
  font-size: 10px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 8px;
}
.coupling-network {
  height: 100px;
  background: #fafbfc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  margin-bottom: 8px;
  overflow: hidden;
}
.coupling-network svg {
  width: 100%;
  height: 100%;
}
.coupling-node {
  cursor: pointer;
  transition: all 0.2s;
}
.coupling-node:hover {
  filter: brightness(0.95);
}
.coupling-edge {
  stroke: #e2e8f0;
  stroke-width: 1.5;
  fill: none;
  transition: all 0.3s;
}
.coupling-edge.active {
  stroke: #22c55e;
  stroke-width: 3;
  filter: drop-shadow(0 0 3px rgba(34, 197, 94, 0.5));
}
.coupling-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.coupling-badge {
  font-size: 9px;
  padding: 3px 8px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  transition: all 0.3s;
}
.coupling-badge.active {
  background: #dcfce7;
  border-color: #22c55e;
  color: #166534;
}
.coupling-desc {
  font-size: 7px;
  color: #94a3b8;
}

/* ========== CLD ========== */
.cld-legend {
  display: flex;
  gap: 12px;
  font-size: 9px;
  color: #64748b;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}
.leg-stock {
  width: 16px;
  height: 12px;
  background: #dbeafe;
  border: 2px solid #2563eb;
  border-radius: 2px;
}
.leg-aux {
  width: 12px;
  height: 12px;
  background: #f8fafc;
  border: 2px solid #94a3b8;
  border-radius: 50%;
}
.leg-dim {
  width: 12px;
  height: 12px;
  background: #dcfce7;
  border: 2px solid #16a34a;
  border-radius: 50%;
}
.leg-pol {
  width: 12px;
  height: 12px;
  background: #fef3c7;
  border: 2px solid #d97706;
  border-radius: 50%;
}
.leg-dim {
  width: 12px;
  height: 12px;
  background: #dcfce7;
  border: 2px solid #16a34a;
  border-radius: 50%;
}

.leg-r { color: #16a34a; font-weight: 700; }
.leg-b { color: #dc2626; font-weight: 700; }

.cld-container {
  background: #fafbfc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  height: 400px;
  position: relative;
  overflow: hidden;
}
.cld-container svg {
  width: 100%;
  height: 100%;
}
.tipping-alert {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: #fef3c7;
  border: 2px solid #f59e0b;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 11px;
  font-weight: 600;
  color: #92400e;
  display: none;
  z-index: 10;
  animation: alertPulse 1s infinite;
}
.tipping-alert.visible { display: block; }
@keyframes alertPulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.05); }
}

/* SVG Styles */
.stock-box {
  fill: #dbeafe;
  stroke: #2563eb;
  stroke-width: 2;
  cursor: pointer;
  transition: all 0.3s;
}
.stock-box:hover {
  stroke-width: 3;
  filter: drop-shadow(0 0 6px rgba(37,99,235,0.4));
}
.stock-box.pulse {
  animation: stockPulse 1s infinite;
}
@keyframes stockPulse {
  0%, 100% { stroke-width: 2; }
  50% { stroke-width: 4; filter: drop-shadow(0 0 8px rgba(37,99,235,0.6)); }
}
.stock-lbl {
  font-size: 11px;
  font-weight: 700;
  fill: #1e40af;
  text-anchor: middle;
  pointer-events: none;
}
.aux {
  fill: #f8fafc;
  stroke: #94a3b8;
  stroke-width: 1.5;
  cursor: pointer;
  transition: all 0.3s;
}
.aux:hover {
  stroke-width: 2.5;
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.2));
}
.aux.dim {
  fill: #dcfce7;
  stroke: #16a34a;
}
.aux.pol {
  fill: #fef3c7;
  stroke: #d97706;
}
.aux-lbl {
  font-size: 9px;
  fill: #475569;
  text-anchor: middle;
  pointer-events: none;
}
.flow {
  fill: none;
  stroke: #94a3b8;
  stroke-width: 1.5;
  transition: all 0.3s;
}
.flow.neg {
  stroke: #ef4444;
  stroke-dasharray: 4,2;
}
.flow.active {
  stroke-width: 3;
  filter: drop-shadow(0 0 4px currentColor);
}
.flow.dim-flow { stroke: #16a34a; }
.loop-lbl {
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.loop-lbl:hover { font-size: 11px; }
.loop-lbl.r { fill: #16a34a; }
.loop-lbl.b { fill: #dc2626; }
.loop-lbl.active {
  font-size: 12px;
  filter: drop-shadow(0 0 4px currentColor);
}
.loop-arc {
  fill: none;
  stroke-width: 1.5;
  stroke-dasharray: 4,2;
  opacity: 0.5;
}
.loop-arc.r { stroke: #16a34a; }
.loop-arc.b { stroke: #dc2626; }
.loop-arc.active {
  opacity: 1;
  stroke-width: 2.5;
}

/* ========== SEGMENTS ========== */
.segments-container {
  margin-top: 12px;
}
.chart-title {
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 8px;
}
.seg-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid #f1f5f9;
}
.seg-label {
  width: 100px;
  font-size: 10px;
  color: #475569;
  font-weight: 500;
}
.seg-bar {
  flex: 1;
  height: 18px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.seg-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s;
}
.seg-bar-fill.seg-a { background: linear-gradient(90deg, #ef4444, #dc2626); }
.seg-bar-fill.seg-b { background: linear-gradient(90deg, #f59e0b, #d97706); }
.seg-bar-fill.seg-c { background: linear-gradient(90deg, #22c55e, #16a34a); }
.seg-pct {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 9px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.seg-inc {
  width: 70px;
  text-align: right;
  font-size: 11px;
  font-weight: 600;
  color: #1e293b;
}

/* ========== CHARTS ========== */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}
.charts-grid.four-charts {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.chart-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px;
}
.chart-container {
  height: 100px;
}
.charts-grid.four-charts .chart-container {
  height: 90px;
}
.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ========== 3D ATTRACTOR ========== */
.attractor-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}
.attractor-section .chart-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.attractor-controls {
  display: flex;
  gap: 4px;
}
.attractor-container {
  height: 180px;
  background: #fafbfc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: grab;
  overflow: hidden;
}
.attractor-container:active {
  cursor: grabbing;
}
.attractor-legend {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 6px;
  font-size: 9px;
}
.leg-trap { color: #dc2626; }
.leg-trans { color: #f59e0b; }
.leg-growth { color: #16a34a; }

/* ========== MONTE CARLO & ABM ========== */
.mc-abm-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}
.mc-abm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.mc-box, .abm-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px;
}
.mc-chart, .abm-chart {
  height: 100px;
}
.btn-mc {
  background: #7c3aed;
  color: #fff;
  border: none;
  margin-left: 8px;
}
.btn-mc:hover {
  background: #6d28d9;
}
.mc-stats {
  font-size: 8px;
  color: #64748b;
  text-align: center;
  margin-top: 4px;
  padding: 4px;
  background: #fff;
  border-radius: 3px;
}
.mc-stats strong {
  color: #1e293b;
}

/* ========== POLICIES ========== */
.scenario-buttons {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.btn-scenario {
  padding: 6px 12px;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-scenario:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
.btn-scenario.active {
  background: #dbeafe;
  border-color: #2563eb;
  color: #1e40af;
}

/* Active Shocks Indicator */
.active-shocks-panel {
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.shock-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.shock-icon {
  font-size: 16px;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.shock-label {
  font-size: 11px;
  font-weight: 700;
  color: #dc2626;
  text-transform: uppercase;
}
.shock-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.shock-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255,255,255,0.7);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 11px;
}
.shock-name {
  font-weight: 600;
  color: #b91c1c;
}
.shock-remaining {
  color: #64748b;
  font-size: 10px;
}

/* Decision Insights Panel */
.decision-insights-panel {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #7dd3fc;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.insights-header {
  font-size: 11px;
  font-weight: 700;
  color: #0369a1;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.insights-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.insight-item {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.8);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.insight-icon {
  font-size: 12px;
}
.insight-text {
  color: #0c4a6e;
}
.insight-item.positive .insight-text {
  color: #166534;
}
.insight-item.warning .insight-text {
  color: #b45309;
}
.insight-item.negative .insight-text {
  color: #b91c1c;
}
.synergy-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.synergy-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 4px;
}
.synergy-item.synergy {
  background: #dcfce7;
  color: #166534;
}
.synergy-item.conflict {
  background: #fee2e2;
  color: #991b1b;
}
.synergy-item.risk {
  background: #fef3c7;
  color: #92400e;
}

.policy-group {
  margin-bottom: 14px;
}
.policy-group-title {
  font-size: 10px;
  color: #475569;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 2px solid #e2e8f0;
}
.policy-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px;
  background: #f8fafc;
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
}
.policy-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
.policy-item.active {
  background: #dcfce7;
  border-color: #22c55e;
}
.policy-item.active .check-mark { display: block; }
.policy-item.blocked {
  opacity: 0.5;
  cursor: not-allowed;
  background: #fee2e2;
}
.policy-check {
  width: 18px;
  height: 18px;
  border: 2px solid #cbd5e1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.policy-item.active .policy-check {
  background: #22c55e;
  border-color: #22c55e;
}
.check-mark {
  display: none;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.policy-info { flex: 1; }
.policy-name {
  font-size: 11px;
  font-weight: 600;
  color: #1e293b;
}
.policy-effect {
  font-size: 9px;
  color: #64748b;
  margin-top: 2px;
}
.policy-blocked {
  font-size: 8px;
  color: #92400e;
  margin-top: 2px;
  font-style: italic;
}

/* ========== OUTCOMES ========== */
.outcomes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.outcome-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px;
  text-align: center;
}
.outcome-label {
  font-size: 9px;
  color: #64748b;
  text-transform: uppercase;
  font-weight: 600;
}
.outcome-value {
  font-size: 20px;
  font-weight: 700;
  color: #1e293b;
  margin: 4px 0;
}
.outcome-value.trap { color: #dc2626; }
.outcome-value.transition { color: #f59e0b; }
.outcome-value.growth { color: #16a34a; }
.outcome-sub {
  font-size: 9px;
  color: #94a3b8;
}

/* ========== COMPLEXITY INDICATORS ========== */
.complexity-panel {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 8px;
  margin: 10px 0;
}
.complexity-header {
  font-size: 10px;
  font-weight: 600;
  color: #065f46;
  margin-bottom: 6px;
}
.complexity-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px 12px;
}
.cx-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  flex-wrap: wrap;
  cursor: help;
}
.cx-label {
  color: #475569;
  min-width: 70px;
  font-weight: 500;
}
.cx-bar-track {
  flex: 1;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}
.cx-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}
.cx-bar.r1 { background: #22c55e; }
.cx-bar.r2 { background: #3b82f6; }
.cx-bar.credit { background: #ef4444; }
.cx-bar.comp { background: #f59e0b; }
.cx-val {
  min-width: 32px;
  text-align: right;
  font-weight: 600;
  color: #1e293b;
  font-size: 9px;
}
.cx-interpret {
  width: 100%;
  font-size: 8px;
  color: #64748b;
  font-style: italic;
  margin-top: -1px;
  margin-bottom: 2px;
  padding-left: 74px;
  line-height: 1.3;
}
.cx-help {
  font-size: 10px;
  color: #94a3b8;
  cursor: help;
  margin-left: 4px;
}
.cx-refs-btn {
  font-size: 11px;
  cursor: pointer;
  margin-left: auto;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.cx-refs-btn:hover {
  opacity: 1;
}

/* ========== EVENT LOG ========== */
.log-section { margin-top: 12px; }
.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 4px;
}
.log-filters {
  display: flex;
  gap: 3px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.log-filter {
  padding: 3px 6px;
  font-size: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
}
.log-filter:hover {
  background: #f1f5f9;
}
.log-filter.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.log-container {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px;
  min-height: 260px;
  max-height: 520px;
  overflow-y: auto;
  font-size: 10px;
}
.log-count {
  padding: 2px 6px;
  margin-bottom: 4px;
  font-size: 9px;
  color: #64748b;
  text-align: right;
  border-bottom: 1px solid #e2e8f0;
}
  overflow-y: auto;
  font-family: monospace;
  font-size: 9px;
}
.log-entry {
  padding: 3px 0;
  border-bottom: 1px solid #f1f5f9;
}
.log-entry:last-child { border-bottom: none; }
.log-time { color: #64748b; }
.log-type {
  font-weight: 600;
  margin: 0 4px;
  padding: 1px 4px;
  border-radius: 2px;
}
.log-type.STATE { background: #fef3c7; color: #92400e; }
.log-type.POLICY { background: #dbeafe; color: #1e40af; }
.log-type.SHOCK { background: #fee2e2; color: #991b1b; }
.log-type.COUPLING { background: #ede9fe; color: #5b21b6; }
.log-type.COMPLEXITY { background: #d1fae5; color: #065f46; }
.log-type.NPF { background: #fef3c7; color: #92400e; }
.log-type.MONTE { background: #e0f2fe; color: #0369a1; }
.log-type.SIM { background: #f1f5f9; color: #475569; }
.log-type.START { background: #dcfce7; color: #166534; }
.log-type.SIM { background: #e0f2fe; color: #0369a1; }
.log-type.MONTE { background: #fef9c3; color: #854d0e; }
.log-type.CALIBRATE { background: #f3e8ff; color: #7c3aed; }

/* ========== MODALS ========== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 20px;
}
.modal-overlay.visible { display: flex; }
.detail-modal {
  background: #fff;
  border-radius: 12px;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}
.modal-header {
  background: #f8fafc;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
  flex: 1;
}
.modal-type {
  font-size: 10px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  text-transform: uppercase;
}
.modal-type.dim { background: #dcfce7; color: #166534; }
.modal-type.loop-r { background: #dcfce7; color: #166534; }
.modal-type.loop-b { background: #fee2e2; color: #991b1b; }
.modal-type.stock { background: #dbeafe; color: #1e40af; }
.modal-type.policy { background: #fef3c7; color: #92400e; }
.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: #e2e8f0;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: #cbd5e1; }
.modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(80vh - 70px);
}
.modal-section {
  margin-bottom: 16px;
}
.modal-section:last-child { margin-bottom: 0; }
.modal-section-title {
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 6px;
}
.modal-eq {
  background: #f8fafc;
  padding: 12px;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: #1e40af;
  white-space: pre-wrap;
}
.modal-ref {
  font-size: 10px;
  color: #64748b;
  font-style: italic;
}
.modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.modal-item {
  background: #f8fafc;
  padding: 8px 12px;
  border-radius: 4px;
  text-align: center;
}
.modal-item-label {
  font-size: 9px;
  color: #64748b;
  text-transform: uppercase;
}
.modal-item-value {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
}
.modal-item-value.positive { color: #16a34a; }
.modal-item-value.negative { color: #dc2626; }
.modal-list {
  padding-left: 20px;
  font-size: 12px;
  color: #475569;
}
.modal-list li { margin-bottom: 4px; }

/* ========== ADMIN PANEL ========== */
.admin-modal {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}
.admin-header {
  background: linear-gradient(135deg, #1e40af, #7c3aed);
  color: #fff;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.admin-header h2 {
  font-size: 18px;
  font-weight: 600;
}
.admin-tabs {
  display: flex;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.admin-tab {
  padding: 12px 20px;
  border: none;
  background: none;
  font-size: 12px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
}
.admin-tab:hover {
  color: #1e293b;
  background: #f1f5f9;
}
.admin-tab.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  background: #fff;
}
.admin-content {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(85vh - 130px);
}
.admin-section {
  margin-bottom: 24px;
}
.admin-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.admin-section h3 {
  font-size: 16px;
  color: #1e293b;
}
.admin-section h4 {
  font-size: 14px;
  color: #475569;
  margin-bottom: 8px;
}
.admin-desc {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 12px;
}
.form-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.form-card h4 {
  margin-bottom: 12px;
  color: #1e293b;
}
.form-card h5 {
  font-size: 12px;
  color: #475569;
  margin: 12px 0 8px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-group label {
  font-size: 11px;
  font-weight: 500;
  color: #475569;
}
.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 12px;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #2563eb;
}
.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ========== CALIBRATION GRIDS ========== */
.calibration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.calib-item {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px;
}
.calib-item label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 4px;
}
.calib-item input, .calib-item select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 12px;
}
.calib-item input:focus, .calib-item select:focus {
  outline: none;
  border-color: #2563eb;
}
.calib-help {
  display: block;
  font-size: 9px;
  color: #94a3b8;
  margin-top: 3px;
}

/* Policy Interactions */
.interaction-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}
.interaction-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 11px;
}
.interaction-item.synergy {
  border-left: 3px solid #22c55e;
}
.interaction-item.conflict {
  border-left: 3px solid #ef4444;
}
.interaction-item.redundancy {
  border-left: 3px solid #f59e0b;
}
.interaction-pair {
  flex: 1;
  font-weight: 500;
  color: #1e293b;
}
.interaction-item input {
  width: 60px;
  padding: 4px 6px;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  text-align: center;
}
.interaction-type {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 3px;
  background: #f1f5f9;
  color: #64748b;
}

/* GIS/Spatial Data Grid */
.gis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.gis-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 12px;
}
.gis-card h5 {
  font-size: 11px;
  color: #475569;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e2e8f0;
}

.hidden { display: none !important; }
.empty-state {
  text-align: center;
  color: #94a3b8;
  padding: 20px;
  font-style: italic;
}
.badge {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 600;
}
.badge.custom { background: #dbeafe; color: #1e40af; }
.badge.edited { background: #fef3c7; color: #92400e; }
.badge.active { background: #dcfce7; color: #166534; }

/* Calibration */
.calibration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.calib-item {
  background: #f8fafc;
  padding: 12px;
  border-radius: 6px;
}
.calib-item label {
  font-size: 11px;
  font-weight: 500;
  color: #475569;
  display: block;
  margin-bottom: 4px;
}
.calib-item input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-size: 12px;
}
.calib-help {
  font-size: 9px;
  color: #94a3b8;
  margin-top: 4px;
  display: block;
}
.loops-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.loop-item {
  background: #f8fafc;
  padding: 12px;
  border-radius: 6px;
  border-left: 4px solid #64748b;
}
.loop-item.reinforcing { border-left-color: #16a34a; }
.loop-item.balancing { border-left-color: #dc2626; }
.loop-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.loop-header label {
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.loop-type {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 3px;
  background: #e2e8f0;
}
.loop-strength {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}
.loop-strength input[type="range"] { flex: 1; }
.loop-desc {
  font-size: 10px;
  color: #64748b;
  margin-top: 8px;
}
.param-category {
  margin-bottom: 16px;
}
.param-category h5 {
  font-size: 12px;
  color: #475569;
  text-transform: capitalize;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #e2e8f0;
}
.param-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.param-item {
  background: #f8fafc;
  padding: 8px 10px;
  border-radius: 4px;
}
.param-item label {
  font-size: 10px;
  color: #64748b;
  display: block;
  margin-bottom: 4px;
}
.param-item input {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  font-size: 11px;
}
.param-range {
  font-size: 8px;
  color: #94a3b8;
}

/* Export */
.export-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.report-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.report-options label {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.mc-summary {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  margin-top: 12px;
}
.mc-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  text-align: center;
}
.stat-label {
  font-size: 10px;
  color: #64748b;
  display: block;
}
.stat-value {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
}

/* Case Studies */
.case-list {
  display: grid;
  gap: 12px;
}
.case-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px;
  transition: all 0.2s;
}
.case-item:hover {
  border-color: #cbd5e1;
}
.case-item.active {
  border-color: #22c55e;
  background: #f0fdf4;
}
.case-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.case-name {
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
}
.case-location {
  font-size: 11px;
  color: #64748b;
}
.case-item-details {
  font-size: 11px;
  color: #475569;
}
.detail-row {
  display: flex;
  gap: 16px;
  margin-bottom: 4px;
}
.case-item-segments {
  display: flex;
  gap: 8px;
  margin: 8px 0;
}
.seg {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 3px;
}
.seg.seg-a { background: #fee2e2; color: #991b1b; }
.seg.seg-b { background: #fef3c7; color: #92400e; }
.seg.seg-c { background: #dcfce7; color: #166534; }
.case-item-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

/* Shock */
.shock-list {
  display: grid;
  gap: 8px;
}
.shock-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  padding: 10px 12px;
}
.shock-name {
  font-weight: 600;
  color: #92400e;
}
.shock-remaining {
  font-size: 11px;
  color: #b45309;
}
.template-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}
.template-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s;
}
.template-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
.template-name {
  font-size: 11px;
  font-weight: 600;
  display: block;
}
.template-duration {
  font-size: 9px;
  color: #64748b;
}

/* ========== COMPLEXITY TAB STYLES ========== */
.admin-subsection {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 12px;
  margin: 8px 0;
}
.admin-subsection h5 {
  font-size: 12px;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: #1e293b;
}
.admin-subsection h5 small {
  font-weight: 400;
  color: #64748b;
  font-style: italic;
}
.cal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  gap: 8px;
}
.cal-row label {
  font-size: 11px;
  color: #475569;
  flex: 1;
}
.cal-input {
  width: 80px;
  padding: 3px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 11px;
  text-align: right;
}
.cal-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.2);
}

/* Toggle switch */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  transition: .3s;
  border-radius: 20px;
}
.switch .slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}
.switch input:checked + .slider {
  background-color: #059669;
}
.switch input:checked + .slider:before {
  transform: translateX(16px);
}

/* ===== Umbrella nesting + demonstration notes (CPAF update) ===== */
.policy-note {
  font-size: 11px;
  line-height: 1.55;
  color: #6b6b6b;
  background: rgba(31, 78, 95, 0.05);
  border: 1px solid rgba(31, 78, 95, 0.12);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 0 0 12px;
}
.policy-note b { color: #34474e; font-weight: 600; }
.policy-umbrella {
  border-left: 3px solid #6B3FA0;
  background: rgba(107, 63, 160, 0.045);
}
.policy-umbrella .policy-name { font-weight: 600; }
.policy-umbrella-tag {
  font-weight: 400;
  opacity: 0.6;
  font-size: 0.8em;
  margin-left: 6px;
}
.policy-child { margin-left: 16px; }
.policy-child .policy-name::before {
  content: "\2514\00A0";
  opacity: 0.4;
  font-weight: 400;
}
