/* AMHASS Modelling Dashboard v0.1 — Style */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-h: #94a3b8;     /* Healthy gray */
  --c-u: #f59e0b;     /* Undiagnosed orange */
  --c-d: #fde047;     /* Diagnosed yellow */
  --c-t: #60a5fa;     /* Treated blue */
  --c-c: #10b981;     /* Controlled green */
  --c-e: #dc2626;     /* Event red */
  --c-m: #1f2937;     /* Deceased dark */
  --c-provisional: #fb923c;
  --c-calwarn-bg: #fef3c7;
  --c-calwarn-border: #fde68a;
  --c-calwarn-text: #92400e;
  --c-bg: #f8fafc;
  --c-card: #ffffff;
  --c-border: #e2e8f0;
  --c-text: #1e293b;
  --c-text-muted: #64748b;
  --c-accent: #2563eb;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 14px;
  line-height: 1.45;
}

/* ═══ Header ═══ */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: white;
  border-bottom: 1px solid var(--c-border);
  position: sticky; top: 0; z-index: 100;
}
.brand { font-size: 16px; }
.brand .version {
  display: inline-block; background: #e0e7ff; color: #3730a3;
  padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  margin-left: 6px;
}
.cal-banner-float {
  position: fixed;
  right: 16px; bottom: 16px;
  z-index: 50;
  max-width: 360px;
  background: var(--c-calwarn-bg);
  border: 1px solid var(--c-calwarn-border);
  color: var(--c-calwarn-text);
  padding: 8px 32px 8px 12px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 11px;
  line-height: 1.4;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}
.cal-banner-close {
  position: absolute;
  top: 4px; right: 6px;
  background: transparent; border: none;
  color: var(--c-calwarn-text);
  cursor: pointer; font-size: 16px;
  line-height: 1; padding: 2px 4px;
  font-weight: 700;
}
.cal-banner-close:hover { opacity: 0.7; }
.cal-banner-float.hidden { display: none; }

.banner-warning {
  background: var(--c-calwarn-bg);
  border: 1px solid var(--c-calwarn-border);
  color: var(--c-calwarn-text);
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 12px;
  text-align: center;
}
.header-controls {
  display: flex; gap: 12px; align-items: center;
}
.header-controls label { font-size: 13px; }
.header-controls select {
  padding: 4px 8px; border: 1px solid var(--c-border); border-radius: 4px;
  background: white; font-size: 13px;
}
.lang-toggle {
  padding: 4px 10px; border: 1px solid var(--c-border); border-radius: 4px;
  background: white; font-size: 13px; cursor: pointer;
  font-weight: 600; line-height: 1.4;
  transition: background 0.15s;
}
.lang-toggle:hover { background: #f1f5f9; border-color: var(--c-accent); }

/* ═══ Year scrubber ═══ */
.year-scrubber-container {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 20px;
  background: white;
  border-bottom: 1px solid var(--c-border);
}
.year-scrubber-container label { font-weight: 600; font-size: 13px; min-width: 110px; }
.year-scrubber-container input { flex: 1; }
.year-readout {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-weight: 600; min-width: 70px; text-align: right;
}

/* ═══ Three-pane layout ═══ */
.three-pane {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 12px;
  padding: 12px;
  min-height: calc(100vh - 100px);
}

.pane {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 16px;
  overflow-y: auto;
}
.pane h2 { font-size: 16px; margin-bottom: 8px; color: var(--c-text); }
.pane h3 { font-size: 13px; margin: 12px 0 6px; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.hint { font-size: 12px; color: var(--c-text-muted); margin-bottom: 12px; }

/* ═══ Scenario builder (left) ═══ */
.preset-list {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px;
}
.preset-btn {
  text-align: left; padding: 10px 12px;
  background: white; border: 1px solid var(--c-border); border-radius: 6px;
  cursor: pointer; font-size: 13px; font-family: inherit;
  transition: all 0.15s;
}
.preset-btn:hover { background: #f1f5f9; }
.preset-btn.active {
  background: #e0e7ff; border-color: var(--c-accent); font-weight: 600;
}
.preset-btn-label { display: block; font-weight: 600; }
.preset-btn-desc { display: block; font-size: 11px; color: var(--c-text-muted); margin-top: 2px; }

.scenario-detail { margin-top: 12px; }
.scen-name {
  display: inline-block;
  background: var(--c-accent); color: white;
  padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  margin-left: 6px; vertical-align: middle;
}
.scen-name.custom {
  background: var(--c-provisional);
}

.lever-controls {
  display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px;
}
.lever-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: center;
  gap: 8px;
}
.lever-label {
  font-size: 12px; font-weight: 600; color: var(--c-text);
}
.lever-label .pillar-num {
  display: inline-block; background: #ede9fe; color: #6d28d9;
  padding: 1px 6px; border-radius: 3px;
  font-size: 10px; font-weight: 700; margin-right: 4px;
}
.seg-control {
  display: flex; gap: 0;
  background: #f1f5f9; border: 1px solid var(--c-border);
  border-radius: 6px; overflow: hidden;
}
.seg-control button {
  flex: 1; padding: 6px 4px;
  background: transparent; border: 0; cursor: pointer;
  font-size: 11px; font-family: inherit;
  color: var(--c-text-muted); font-weight: 600;
  transition: all 0.1s;
  border-right: 1px solid var(--c-border);
}
.seg-control button:last-child { border-right: 0; }
.seg-control button:hover { background: #e2e8f0; }
.seg-control button.active {
  background: var(--c-accent); color: white;
}
.range-control {
  background: #f8fafc;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 6px 8px;
}
.range-control input[type="range"] {
  width: 100%;
  accent-color: var(--c-accent);
}
.range-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--c-text-muted);
}
.range-meta .active {
  color: var(--c-accent);
  font-weight: 700;
}
.reset-btn {
  width: 100%; padding: 8px;
  background: white; border: 1px solid var(--c-border); border-radius: 6px;
  cursor: pointer; font-size: 12px; font-family: inherit;
  color: var(--c-text-muted);
  margin-top: 8px;
}
.reset-btn:hover { background: #f1f5f9; color: var(--c-text); }

.action-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 4px; margin-top: 8px;
}
.action-row .reset-btn { padding: 6px; font-size: 11px; }

.compare-select {
  width: 100%; padding: 6px 8px;
  border: 1px solid var(--c-border); border-radius: 6px;
  background: white; font-size: 12px; font-family: inherit;
  margin-bottom: 4px;
}

.counterfactual {
  background: linear-gradient(135deg, #fef9c3, #fef08a);
  border-left: 4px solid #ca8a04;
  padding: 10px 14px;
  margin-bottom: 12px;
  border-radius: 4px;
  font-size: 12px;
  color: #713f12;
}
.counterfactual strong { color: #854d0e; }

.toast {
  position: fixed;
  bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--c-text); color: white;
  padding: 10px 18px; border-radius: 6px;
  font-size: 13px; font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1000;
  animation: toast-in 0.2s ease-out;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ═══ Cascade output (middle) ═══ */
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.section-title-row h2 {
  margin-bottom: 0;
}
.inline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--c-text-muted);
  white-space: nowrap;
}
.inline-toggle input {
  accent-color: var(--c-accent);
}
.metric-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.conversion-row {
  margin-top: -6px;
}
.conversion-row .metric-card {
  background: #fff7ed;
  border-color: #fed7aa;
}
.metric-card {
  padding: 10px;
  background: #f8fafc;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  text-align: center;
}
.metric-card.highlight {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border-color: var(--c-c);
}
.metric-label { font-size: 11px; color: var(--c-text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.metric-value { font-size: 20px; font-weight: 700; margin-top: 4px; }
.metric-delta { font-size: 11px; color: var(--c-text-muted); margin-top: 2px; }
.metric-delta.positive { color: var(--c-c); font-weight: 600; }
.metric-delta.negative { color: var(--c-e); font-weight: 600; }

.chart-container {
  margin-bottom: 16px;
  height: 280px;
}

.cascade-table-container { margin-top: 16px; }
.cascade-table {
  width: 100%; font-size: 12px; border-collapse: collapse;
}
.cascade-table th, .cascade-table td {
  padding: 6px 8px; border-bottom: 1px solid var(--c-border);
}
.cascade-table th {
  background: #f1f5f9; text-align: left;
  font-weight: 600; color: var(--c-text-muted);
}
.cascade-table td:nth-child(3),
.cascade-table td:nth-child(4),
.cascade-table td:nth-child(5) {
  text-align: right; font-family: ui-monospace, monospace;
}
.state-pill {
  display: inline-block; width: 12px; height: 12px;
  border-radius: 3px; margin-right: 6px; vertical-align: middle;
}

.geo-baseline-info {
  font-size: 11px; color: var(--c-text-muted);
  margin-left: 8px; font-style: italic;
}

.sankey-container { margin-top: 16px; }
.sankey-container svg { background: #fafbfc; border-radius: 6px; }
.sankey-node rect { stroke: white; stroke-width: 1; }
.sankey-node text { font-size: 11px; fill: var(--c-text); }
.sankey-link { fill: none; stroke-opacity: 0.4; }
.sankey-link:hover { stroke-opacity: 0.7; }

/* Outcomes panel (M7) */
.outcomes-section { margin-top: 16px; }
.hint.inline {
  display: inline; color: var(--c-text-muted); font-size: 11px; font-weight: 400;
  text-transform: none; letter-spacing: 0;
}
.outcome-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.outcome-card {
  padding: 10px;
  background: linear-gradient(135deg, #fafbfc, #f1f5f9);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  text-align: center;
}
.outcome-card.icer-card {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-color: var(--c-calwarn-text);
}
.outcome-card .metric-value { font-size: 17px; }
.outcome-card .metric-delta { font-size: 10px; }
.outcome-card .ci-band {
  display: block; font-size: 9px; color: var(--c-text-muted);
  margin-top: 2px; font-family: ui-monospace, monospace;
}

.ceac-container {
  margin-top: 12px;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid var(--c-border);
  border-radius: 6px;
}
.ceac-container h3 { margin: 0 0 6px; }
.ceac-container canvas { max-height: 160px; }

/* ═══ Calibration panel (right) ═══ */
.cal-panel {
  padding: 12px;
  background: var(--c-calwarn-bg);
  border: 1px solid var(--c-calwarn-border);
  border-radius: 6px;
  margin-bottom: 12px;
}
.cal-status-badge {
  display: inline-block;
  background: var(--c-calwarn-text); color: white;
  padding: 4px 10px; border-radius: 4px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.cal-status-badge.cal-done {
  background: #047857;
}
.cal-note { font-size: 11px; color: var(--c-calwarn-text); line-height: 1.5; margin-bottom: 8px; }
.cal-table {
  width: 100%; font-size: 11px; background: white; border-radius: 4px;
  border-collapse: collapse;
}
.cal-table th, .cal-table td {
  padding: 4px 6px; border-bottom: 1px solid var(--c-border);
}
.cal-table th {
  font-weight: 600; color: var(--c-text-muted); text-align: left;
}

.provisional-list {
  list-style: none; font-size: 12px;
}
.provisional-list li {
  padding: 8px 10px;
  background: white;
  border-left: 3px solid var(--c-provisional);
  margin-bottom: 4px;
  border-radius: 0 4px 4px 0;
}
.prov-path {
  font-family: ui-monospace, monospace; font-weight: 600;
  display: block;
}
.prov-value {
  display: inline-block; background: var(--c-provisional); color: white;
  padding: 1px 6px; border-radius: 3px; font-size: 10px;
  font-family: ui-monospace, monospace; margin-top: 2px;
}
.prov-note {
  display: block; color: var(--c-text-muted); font-size: 11px; margin-top: 4px;
}

.todo-list {
  list-style: none; font-size: 12px;
}
.todo-list li {
  padding: 4px 0; color: var(--c-text-muted);
}
.todo-list li::before { content: "☐ "; color: var(--c-text-muted); }

/* ═══ Footer ═══ */
.botbar {
  display: flex; justify-content: space-between;
  padding: 10px 20px;
  background: white;
  border-top: 1px solid var(--c-border);
  font-size: 11px; color: var(--c-text-muted);
}
.botbar a { color: var(--c-accent); text-decoration: none; }
.botbar a:hover { text-decoration: underline; }

/* ═══ Tab bar (Outcomes / Mechanism) ═══ */
.tab-bar {
  display: flex; gap: 4px;
  border-bottom: 2px solid var(--c-border);
  margin-bottom: 16px;
}
.tab-btn {
  padding: 10px 16px;
  background: transparent; border: 0;
  font-size: 13px; font-weight: 600; cursor: pointer;
  color: var(--c-text-muted); font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}
.tab-btn:hover { color: var(--c-text); }
.tab-btn.active {
  color: var(--c-accent);
  border-bottom-color: var(--c-accent);
}

/* ═══ Province comparison tab ═══ */
.prov-controls {
  display: flex; align-items: center; gap: 8px;
  margin: 12px 0;
  font-size: 13px;
}
.prov-summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px; margin: 12px 0;
}
.prov-summary-card {
  padding: 10px;
  background: linear-gradient(135deg, #f8fafc, #e0f2fe);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  text-align: center;
}
.prov-summary-card .metric-value { font-size: 14px; font-weight: 700; }
.prov-summary-card .metric-label { font-size: 10px; }

.prov-table {
  width: 100%; min-width: 1120px; font-size: 11px; border-collapse: collapse;
  margin-top: 12px;
}
.prov-table thead th {
  background: #f1f5f9;
  padding: 8px 6px;
  border-bottom: 2px solid var(--c-border);
  text-align: left;
  font-weight: 600;
  position: sticky; top: 0;
}
.prov-table th.sortable { cursor: pointer; user-select: none; }
.prov-table th.sortable:hover { background: #e2e8f0; }
.prov-table th.sortable::after { content: " ↕"; font-size: 8px; color: var(--c-text-muted); }
.prov-table th.sort-asc::after { content: " ▲"; color: var(--c-accent); }
.prov-table th.sort-desc::after { content: " ▼"; color: var(--c-accent); }
.prov-table tbody td {
  padding: 5px 6px;
  border-bottom: 1px solid var(--c-border);
}
.prov-table tbody tr:hover { background: #f1f5f9; cursor: pointer; }
.prov-table tbody tr.selected { background: #dbeafe; }
.prov-table td.numeric {
  text-align: right;
  font-family: ui-monospace, monospace;
}
.prov-table .ctrl-bar {
  display: inline-block; height: 6px; border-radius: 2px;
  background: linear-gradient(to right, #fee2e2, #16a34a);
  vertical-align: middle; margin-right: 4px;
}
.prov-table .delta-positive { color: #047857; font-weight: 600; }
.prov-table .delta-negative { color: #b91c1c; font-weight: 600; }

/* ═══ Kab/Kota tab ═══ */
.comparison-table-scroll {
  overflow-x: auto;
  border: 1px solid var(--c-border);
  border-radius: 4px;
  margin-top: 8px;
}
.kab-table-scroll {
  max-height: 540px;
  overflow-y: auto;
}
#kab-comparison-table {
  margin-top: 0;
}
#kab-comparison-table thead th {
  background: #f1f5f9;
  z-index: 2;
}
#kab-count-hint {
  font-size: 11px;
  color: var(--c-text-muted);
  margin-left: 8px;
}

/* ═══ Mechanism tab ═══ */
.cascade-diagram {
  background: #f8fafc;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 12px;
  margin: 12px 0;
}
.cascade-diagram h3 { margin-bottom: 8px; }
.ascii-cascade {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.5;
  color: var(--c-text);
  margin: 0;
  white-space: pre;
  overflow-x: auto;
}
.ascii-cascade sub {
  font-size: 9px;
  color: var(--c-accent);
}

.mechanism-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 16px 0;
}
.mech-card {
  background: white;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 14px;
  border-left: 4px solid var(--c-accent);
}
.mech-card.p1-card { border-left-color: #3b82f6; }
.mech-card.p3-card { border-left-color: #0d9488; }
.mech-card.p4-card { border-left-color: #10b981; }
.mech-card.p5-card { border-left-color: #ec4899; }

.mech-card h4 {
  font-size: 14px; margin-bottom: 4px;
  text-transform: none; letter-spacing: 0;
  color: var(--c-text);
}
.mech-card .target-badge {
  display: inline-block;
  background: #fef3c7; color: #92400e;
  padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.3px;
  margin-bottom: 8px;
}
.mech-card .formula {
  background: #f1f5f9;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  padding: 8px 10px;
  border-radius: 4px;
  margin: 6px 0;
  white-space: pre-wrap;
  line-height: 1.5;
  color: var(--c-text);
}
.mech-card .live-values {
  margin-top: 8px;
  font-size: 11px;
  color: var(--c-text-muted);
}
.mech-card .live-values strong {
  color: var(--c-text);
  font-family: ui-monospace, monospace;
}
.mech-card .affects-list {
  margin-top: 6px;
  font-size: 10px;
  color: var(--c-text-muted);
}
.mech-card .affects-list strong { color: var(--c-text); }

/* Stakeholder narrative cards */
.stakeholder-card {
  background: white;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 16px;
  border-top: 4px solid var(--c-accent);
  font-size: 13px; line-height: 1.6;
}
.stakeholder-card.p1-card { border-top-color: #3b82f6; }
.stakeholder-card.p3-card { border-top-color: #0d9488; }
.stakeholder-card.p4-card { border-top-color: #10b981; }
.stakeholder-card.p5-card { border-top-color: #ec4899; }

.stakeholder-card h4 {
  font-size: 15px; margin-bottom: 4px;
  text-transform: none; letter-spacing: 0;
  color: var(--c-text);
}
.stakeholder-card .question {
  font-style: italic; color: var(--c-text-muted);
  margin-bottom: 10px; font-size: 12px;
}
.stakeholder-card .field-label {
  display: block;
  margin-bottom: 3px;
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.stakeholder-card .mech-flow {
  background: #f8fafc;
  border-left: 3px solid var(--c-accent);
  padding: 8px 12px; margin: 10px 0;
  font-size: 12px;
  border-radius: 4px;
}
.stakeholder-card .mech-flow strong { color: var(--c-text); }
.stakeholder-card .example {
  background: #ecfdf5;
  border: 1px solid #86efac;
  padding: 8px 12px; margin: 10px 0;
  border-radius: 4px;
  font-size: 12px;
}
.stakeholder-card .risk {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  padding: 8px 12px; margin: 10px 0;
  border-radius: 4px;
  font-size: 12px;
}
.stakeholder-card .example .field-label { color: #047857; }
.stakeholder-card .risk .field-label { color: #b91c1c; }

/* Rationale + inputs cards */
.rationale-card {
  background: white;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 14px 16px;
  border-left: 4px solid var(--c-accent);
  font-size: 12px; line-height: 1.55;
}
.rationale-card.p1-card { border-left-color: #3b82f6; }
.rationale-card.p3-card { border-left-color: #0d9488; }
.rationale-card.p4-card { border-left-color: #10b981; }
.rationale-card.p5-card { border-left-color: #ec4899; }
.rationale-card h4 {
  font-size: 14px; margin-bottom: 8px;
  text-transform: none; letter-spacing: 0;
  color: var(--c-text);
}
.rationale-card .rat-section {
  margin: 8px 0;
}
.rationale-card .rat-label {
  display: block;
  font-size: 10px; font-weight: 700;
  color: var(--c-text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 3px;
}
.rationale-card .rat-evidence {
  background: #fef3c7;
  padding: 6px 10px; border-radius: 4px;
  font-size: 12px;
  border-left: 3px solid #d97706;
}
.rationale-card .rat-evidence strong { color: #78350f; }
.rationale-card .rat-target {
  background: #ecfdf5;
  padding: 6px 10px; border-radius: 4px;
  font-size: 12px;
  border-left: 3px solid #059669;
}
.rationale-card .input-count {
  display: inline-block;
  background: var(--c-accent); color: white;
  padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
  margin-left: 4px;
}
.rationale-card details {
  margin-top: 6px;
}
.rationale-card details summary {
  cursor: pointer;
  font-size: 11px; color: var(--c-accent);
  list-style: none;
}
.rationale-card details summary::-webkit-details-marker { display: none; }
.rationale-card details summary::before { content: "▸ "; }
.rationale-card details[open] summary::before { content: "▾ "; }
.rationale-card .input-table {
  width: 100%; font-size: 10px;
  margin-top: 6px; border-collapse: collapse;
}
.rationale-card .input-table td {
  padding: 3px 6px; border-bottom: 1px solid var(--c-border);
}
.rationale-card .input-table td:first-child {
  font-family: ui-monospace, monospace;
  color: var(--c-accent); font-weight: 700;
  width: 100px;
}
.rationale-card .input-table td:nth-child(2) {
  font-family: ui-monospace, monospace;
  color: var(--c-text);
  text-align: right;
  width: 70px;
}
.rationale-card .input-table tr.lever-row td {
  background: #fef3c7;
  font-weight: 700;
}

/* Interaction story */
.interaction-story {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 16px 20px;
  margin: 20px 0;
}
.interaction-story h4 {
  color: #78350f;
  font-size: 14px; margin-bottom: 10px;
  text-transform: none; letter-spacing: 0;
}
.interaction-story p {
  color: #713f12;
  font-size: 12px; line-height: 1.7;
  margin-bottom: 8px;
}
.interaction-story strong { color: #451a03; }
.interaction-story .synergy-num {
  display: inline-block;
  background: #fbbf24; color: #451a03;
  padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
  font-family: ui-monospace, monospace;
}

/* Notation glossary */
.notation-section {
  background: #f8fafc;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 12px 14px;
  margin: 12px 0;
}
.notation-section summary {
  cursor: pointer; font-size: 13px;
  color: var(--c-text);
  list-style: none;
}
.notation-section summary::-webkit-details-marker { display: none; }
.notation-section summary::before { content: "▸ "; color: var(--c-accent); }
.notation-section[open] summary::before { content: "▾ "; }
.notation-table {
  width: 100%; font-size: 11px;
  margin-top: 10px; border-collapse: collapse;
}
.notation-table th, .notation-table td {
  padding: 4px 8px; border-bottom: 1px solid var(--c-border);
  text-align: left;
}
.notation-table th { font-weight: 600; color: var(--c-text-muted); background: white; }
.notation-table td:first-child {
  font-family: ui-monospace, monospace;
  font-weight: 700;
  color: var(--c-accent);
  width: 110px;
}
.notation-table td:last-child {
  font-size: 10px; color: var(--c-text-muted); width: 90px;
}

/* Pairwise feedback matrix */
.feedback-matrix {
  width: 100%; font-size: 11px;
  margin: 10px 0 16px; border-collapse: collapse;
  background: white;
  border: 1px solid var(--c-border);
}
.feedback-matrix th, .feedback-matrix td {
  padding: 8px 10px; border: 1px solid var(--c-border);
  vertical-align: top;
}
.feedback-matrix th {
  background: #f1f5f9; font-weight: 600;
  text-align: center; font-size: 11px;
}
.feedback-matrix td.row-header {
  background: #f1f5f9; font-weight: 600;
  text-align: center;
}
.feedback-matrix td.diag {
  background: #f8fafc; color: var(--c-text-muted);
  text-align: center; font-style: italic;
}
.badge-A, .badge-B, .badge-C {
  display: inline-block;
  padding: 1px 6px; border-radius: 3px;
  font-size: 9px; font-weight: 700;
  margin-right: 4px;
}
.badge-A { background: #dbeafe; color: #1e40af; }
.badge-B { background: #fef3c7; color: #92400e; }
.badge-C { background: #fce7f3; color: #9f1239; }

/* Recommendations */
.recommendations-section {
  background: #f8fafc;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 12px 14px;
  margin: 16px 0;
}
.recommendations-section summary {
  cursor: pointer; font-size: 13px; color: var(--c-text);
  list-style: none;
}
.recommendations-section summary::-webkit-details-marker { display: none; }
.recommendations-section summary::before { content: "▸ "; color: var(--c-accent); }
.recommendations-section[open] summary::before { content: "▾ "; }
.recommendations-section h4 {
  font-size: 12px; margin: 12px 0 6px; color: var(--c-text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.recommendations-section ul {
  margin-left: 16px; font-size: 12px; line-height: 1.7;
}
.recommendations-section .rec-priority {
  display: inline-block;
  padding: 1px 6px; border-radius: 3px;
  font-size: 9px; font-weight: 700;
  margin-right: 4px;
}
.rec-high { background: #fee2e2; color: #991b1b; }
.rec-med  { background: #fef3c7; color: #92400e; }
.rec-low  { background: #d1fae5; color: #065f46; }

.composition-info {
  background: #fafbfc;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  padding: 14px;
  margin-top: 16px;
}
.comp-order {
  margin-left: 20px; font-size: 12px; line-height: 1.7;
  color: var(--c-text-muted);
}
.comp-order li strong { color: var(--c-accent); }

/* ═══ Calling cards ═══ */
.calling-cards-container { margin-bottom: 16px; }
.calling-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);   /* 8 cards di 2 rows */
  gap: 6px;
}
.pane-right .calling-cards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.calling-card {
  padding: 8px;
  background: white;
  border: 1px solid var(--c-border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  text-align: center;
  transition: all 0.15s;
  position: relative;
}
.calling-card:hover {
  border-color: var(--c-accent);
  box-shadow: 0 2px 8px rgba(37,99,235,0.15);
  transform: translateY(-1px);
}
.calling-card.active {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  border-color: var(--c-accent);
}
.calling-card .cc-label { font-weight: 700; color: var(--c-text); display: block; }
.calling-card .cc-ctrl { font-size: 14px; font-weight: 700; color: var(--c-c); margin-top: 4px; }
.calling-card .cc-events { font-size: 10px; color: var(--c-text-muted); }
.calling-card .cc-icer { font-size: 10px; color: var(--c-accent); margin-top: 2px; font-weight: 600; }

/* ═══ Outcome drawer ═══ */
.outcome-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 380px; max-width: 90%;
  background: white;
  box-shadow: -4px 0 20px rgba(0,0,0,0.20);
  z-index: 1500;
  display: flex; flex-direction: column;
  animation: drawer-slide 0.25s ease-out;
}
@keyframes drawer-slide {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.drawer-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px; border-bottom: 1px solid var(--c-border);
}
.drawer-header h3 { font-size: 16px; margin: 0; color: var(--c-text); text-transform: none; letter-spacing: 0; }
.drawer-close {
  width: 32px; height: 32px;
  background: transparent; border: 0;
  font-size: 24px; cursor: pointer;
  color: var(--c-text-muted); line-height: 1;
}
.drawer-close:hover { color: var(--c-text); }
.drawer-body {
  padding: 16px; overflow-y: auto; flex: 1;
  font-size: 13px; line-height: 1.6;
}
.drawer-body h4 {
  font-size: 12px; color: var(--c-text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin: 16px 0 6px;
}
.drawer-body table {
  width: 100%; font-size: 11px; border-collapse: collapse; margin-top: 4px;
}
.drawer-body table th, .drawer-body table td {
  padding: 4px 6px; border-bottom: 1px solid var(--c-border);
}
.drawer-body table td:not(:first-child) { text-align: right; font-family: ui-monospace, monospace; }
.drawer-body .formula {
  background: #f1f5f9; padding: 8px 10px;
  border-radius: 4px;
  font-family: ui-monospace, monospace; font-size: 11px;
  margin: 6px 0;
}
.drawer-body .spec-ref {
  display: inline-block;
  background: #e0e7ff; color: #3730a3;
  padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 600;
}

/* Outcome cards click-cue */
.outcome-card { cursor: pointer; }
.outcome-card:hover { background: #f1f5f9; }

/* ═══ Modal overlay (intro) ═══ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}
.modal-card {
  background: white; border-radius: 12px;
  max-width: 540px; width: 90%;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.30);
  position: relative;
}
.modal-card h2 { font-size: 22px; margin-bottom: 12px; color: var(--c-text); }
.modal-card h3 { font-size: 13px; margin: 16px 0 8px;
                 color: var(--c-text-muted); text-transform: uppercase; }
.intro-lead { font-size: 14px; line-height: 1.6; margin-bottom: 16px; color: var(--c-text); }
.intro-quick-tour ol { margin-left: 20px; font-size: 13px; line-height: 1.7; }
.intro-warn {
  background: var(--c-calwarn-bg);
  border-left: 4px solid var(--c-calwarn-text);
  padding: 10px 12px; border-radius: 4px;
  font-size: 12px; color: var(--c-calwarn-text);
  margin-top: 16px;
}
.modal-action {
  width: 100%; padding: 12px;
  background: var(--c-accent); color: white;
  border: 0; border-radius: 6px;
  cursor: pointer; font-size: 14px; font-weight: 600;
  margin-top: 18px; font-family: inherit;
}
.modal-action:hover { background: #1d4ed8; }
.modal-close {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px;
  background: transparent; border: 0;
  font-size: 24px; cursor: pointer;
  color: var(--c-text-muted);
  line-height: 1;
}
.modal-close:hover { color: var(--c-text); }

/* ═══ Equity quintile table ═══ */
.equity-table {
  width: 100%; font-size: 11px; border-collapse: collapse;
  margin-bottom: 12px;
}
.equity-table th, .equity-table td {
  padding: 4px 6px; border-bottom: 1px solid var(--c-border);
}
.equity-table th { background: #f1f5f9; text-align: left; }
.equity-table td:not(:first-child) {
  text-align: right; font-family: ui-monospace, monospace;
}
.equity-table .quintile-bar {
  display: inline-block; height: 8px; border-radius: 2px;
  background: linear-gradient(to right, #fee2e2, #16a34a);
  vertical-align: middle; margin-right: 4px;
}

/* ═══ Responsive: tablet/mobile ═══ */
@media (max-width: 1024px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 8px; padding: 8px 12px;
  }
  .banner-warning { font-size: 11px; padding: 4px 8px; }
  .header-controls { flex-wrap: wrap; gap: 8px; }
  .three-pane {
    grid-template-columns: 1fr;
    padding: 8px;
  }
  .pane { padding: 12px; }
  .metric-row { grid-template-columns: repeat(2, 1fr); }
  .outcome-row { grid-template-columns: repeat(2, 1fr); }
  .calling-cards { grid-template-columns: repeat(3, 1fr); }
  .modal-card { padding: 20px; max-width: 95%; }
}

@media (max-width: 640px) {
  body {
    font-size: 13px;
    overflow-x: hidden;
    background: white;
  }
  .topbar {
    position: sticky;
    top: 0;
    padding: 8px 10px;
    gap: 6px;
  }
  .brand {
    font-size: 15px;
    line-height: 1.35;
  }
  .brand .version {
    margin-left: 0;
    margin-top: 4px;
  }
  .banner-warning {
    display: none;
  }
  .header-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
  }
  .header-controls label {
    display: grid;
    gap: 3px;
    font-size: 11px;
    color: var(--c-text-muted);
  }
  .header-controls select,
  .lang-toggle {
    width: 100%;
    min-height: 38px;
    font-size: 12px;
  }
  .year-scrubber-container {
    position: sticky;
    top: 88px;
    z-index: 80;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 10px;
    padding: 8px 10px;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.08);
  }
  .year-scrubber-container label {
    min-width: 0;
    font-size: 12px;
  }
  .year-scrubber-container input {
    grid-column: 1 / -1;
    min-height: 32px;
  }
  .year-readout {
    min-width: 52px;
  }
  .three-pane {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    min-height: auto;
  }
  .pane {
    position: relative;
    padding: 14px 12px 18px;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    overflow: visible;
  }
  .pane + .pane {
    margin-top: 10px;
  }
  .pane-left { order: 1; }
  .pane-mid { order: 2; }
  .pane-right { order: 3; }
  .pane::before {
    display: block;
    margin: -2px 0 10px;
    padding: 7px 9px;
    border-radius: 6px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.2px;
  }
  .pane-left::before { content: "1. Atur skenario"; }
  .pane-mid::before { content: "2. Lihat hasil"; }
  .pane-right::before { content: "3. Ringkasan & kualitas data"; }
  .pane h2 {
    font-size: 16px;
    line-height: 1.25;
    margin-bottom: 6px;
  }
  .pane h3 {
    font-size: 12px;
    margin-top: 14px;
  }
  .hint {
    font-size: 11px;
    margin-bottom: 10px;
    line-height: 1.35;
  }
  .preset-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin-bottom: 12px;
  }
  .preset-btn {
    min-height: 42px;
    padding: 9px 10px;
    font-size: 12px;
  }
  .lever-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }
  .lever-label {
    font-size: 12px;
  }
  .seg-control {
    width: 100%;
  }
  .seg-control button {
    min-height: 40px;
    font-size: 11px;
    padding: 8px 3px;
  }
  .range-control {
    padding: 8px;
  }
  .range-control input[type="range"] {
    min-height: 34px;
  }
  .range-meta {
    font-size: 10px;
    gap: 4px;
  }
  .action-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .reset-btn,
  .action-row .reset-btn,
  .compare-select {
    min-height: 40px;
    font-size: 12px;
  }
  .tab-bar {
    position: sticky;
    top: 154px;
    z-index: 70;
    background: white;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    margin-left: -12px;
    margin-right: -12px;
    padding: 0 12px;
  }
  .tab-btn {
    flex: 0 0 auto;
    min-height: 42px;
    padding: 10px 12px;
    font-size: 12px;
  }
  .section-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
  .inline-toggle {
    white-space: normal;
  }
  .metric-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .outcome-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .metric-card,
  .outcome-card {
    padding: 8px 6px;
  }
  .metric-label {
    font-size: 9px;
    letter-spacing: 0;
  }
  .metric-value {
    font-size: 17px;
  }
  .metric-delta,
  .outcome-card .metric-delta {
    font-size: 9px;
  }
  .chart-container {
    height: 220px;
    overflow: hidden;
    margin-left: -2px;
    margin-right: -2px;
  }
  .ceac-container canvas {
    max-height: 150px;
  }
  .sankey-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sankey-container svg {
    min-width: 560px;
  }
  .cascade-table-container,
  .comparison-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .cascade-table {
    min-width: 560px;
    font-size: 11px;
  }
  .prov-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .prov-controls select,
  .prov-controls input,
  .prov-controls button {
    width: 100% !important;
    min-height: 40px;
  }
  .prov-summary-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .mechanism-grid {
    grid-template-columns: 1fr;
  }
  .ascii-cascade {
    font-size: 10px;
  }
  .calling-cards,
  .pane-right .calling-cards {
    grid-template-columns: 1fr;
  }
  .calling-card {
    min-height: 46px;
    padding: 8px;
    text-align: left;
  }
  .cal-banner-float {
    left: 8px;
    right: 8px;
    bottom: 8px;
    max-width: none;
    font-size: 10px;
  }
  .botbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 10px;
  }
  .modal-card {
    padding: 18px;
    max-width: 94%;
    max-height: 90vh;
    overflow-y: auto;
  }
  .modal-card h2 { font-size: 18px; }
}

@media (max-width: 420px) {
  .preset-list,
  .outcome-row,
  .prov-summary-row,
  .calling-cards,
  .pane-right .calling-cards {
    grid-template-columns: 1fr;
  }
  .metric-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .header-controls {
    grid-template-columns: 1fr;
  }
  .metric-value {
    font-size: 16px;
  }
}
