/* PharmID Payout Model — Stripe-inspired design system */

/* ---------------- Reset / base ---------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-feature-settings: 'cv11', 'ss03';
  color: var(--ink-900);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 14.5px;
  line-height: 1.5;
}

/* ---------------- Tokens ---------------- */
:root {
  /* Stripe-inspired palette */
  --bg:           #f6f9fc;
  --bg-sub:       #eef2f7;
  --surface:      #ffffff;
  /* Darkened toward black for legibility (was #1a1f36 … #adbdcc). */
  --ink-900:      #0a0e1a;
  --ink-700:      #232838;
  --ink-500:      #3c4763;
  --ink-400:      #566579;
  --ink-300:      #7787a0;
  --ink-200:      #9caec0;
  --border:       #e3e8ee;
  --border-soft:  #ebeef3;
  --border-strong:#c1c9d2;

  --accent:       #635bff;  /* Stripe purple */
  --accent-soft:  #f0eeff;
  --accent-hover: #5048e5;
  --accent-ink:   #4f46e5;

  --pos:          #1b8c5a;
  --pos-soft:     #defff0;
  --neg:          #cd3500;
  --neg-soft:     #ffe7df;
  --warn:         #b25e09;
  --warn-soft:    #fff4e0;
  --info:         #0073b0;
  --info-soft:    #e0f3ff;

  /* Pastel data viz */
  --c1: #c1d8ff; /* blue   */
  --c2: #ffc7ee; /* pink   */
  --c3: #aff4c6; /* green  */
  --c4: #ffe5a3; /* yellow */
  --c5: #d4b9ff; /* purple */
  --c6: #ffd1b3; /* orange */
  --c7: #b5e9e3; /* teal   */
  --c8: #f0c4d4; /* rose   */
  --c1-ink: #2563eb;
  --c2-ink: #d6478e;
  --c3-ink: #0a8c4e;
  --c4-ink: #b25e09;
  --c5-ink: #7d3cd6;
  --c6-ink: #c2410c;
  --c7-ink: #0e7b6e;
  --c8-ink: #b8336a;

  /* Layout */
  --radius:    10px;
  --radius-sm: 6px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(50,50,93,.04), 0 1px 1px rgba(0,0,0,.02);
  --shadow:    0 2px 5px -1px rgba(50,50,93,.08), 0 1px 3px -1px rgba(0,0,0,.04);
  --shadow-lg: 0 12px 28px -8px rgba(50,50,93,.12), 0 4px 8px -2px rgba(0,0,0,.04);

  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

/* ---------------- Type ---------------- */
h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--ink-900); letter-spacing: -0.011em; }
h1 { font-size: 28px; letter-spacing: -0.022em; }
h2 { font-size: 20px; letter-spacing: -0.014em; }
h3 { font-size: 15px; }
p, label, span, div { color: inherit; }

.num { font-family: var(--mono); font-feature-settings: 'tnum', 'zero'; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.muted { color: var(--ink-400); }
.dim { color: var(--ink-500); }
.faint { color: var(--ink-300); }
.eyebrow { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-400); }

/* ---------------- Layout primitives ---------------- */
.stack > * + * { margin-top: var(--gap, 12px); }
.row { display: flex; align-items: center; gap: var(--gap, 12px); }
.row.between { justify-content: space-between; }
.row.tight { gap: 6px; }
.col { display: flex; flex-direction: column; gap: var(--gap, 12px); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card .card-head {
  padding: 16px 20px 0;
}
.card .card-body {
  padding: 16px 20px;
}
.card .card-body + .card-body { padding-top: 0; }
.card hr { border: none; border-top: 1px solid var(--border-soft); margin: 0; }

/* ---------------- Top chrome ---------------- */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  /* Brand bar is NOT sticky — it scrolls away so the pinned stack stays compact. */
}
/* Single sticky anchor for the exit slider + comparison cards. Self-sizing, so there are
   no hardcoded per-layer top offsets to keep in sync (the old source of clipping). */
.sticky-stack {
  position: sticky; top: 0; z-index: 40;
  box-shadow: 0 8px 20px -18px rgba(10,14,26,.4);
}
.app-header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 15px; color: var(--ink-900);
  letter-spacing: -0.01em;
  white-space: nowrap;
  flex-shrink: 0;
}
.brand-glyph {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #7a73ff 0%, #635bff 50%, #4f46e5 100%);
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 13px;
  box-shadow: 0 2px 6px rgba(99,91,255,.35);
}
.scenario-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-700);
}
.scenario-pill .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
}

/* ---------------- Summary bar ---------------- */
.summary-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  /* Sticky handled by the .sticky-stack wrapper; this is a plain block within it. */
}
.summary-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 5px 28px 5px;
  display: grid;
  grid-template-columns: minmax(320px, 1.4fr) repeat(4, minmax(110px, 1fr));
  gap: 24px;
  align-items: center;
}
.metric-block {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 110px;
}
.metric-block .label {
  font-size: 11px; color: var(--ink-400); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.metric-block .value {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink-900);
  font-variant-numeric: tabular-nums;
}
.metric-block .sub {
  font-size: 11px; color: var(--ink-400);
}

/* Exit slider */
.exit-slider {
  display: flex; flex-direction: column; gap: 4px;
}
.exit-slider-row { display: flex; align-items: baseline; gap: 10px; }
.exit-value-display {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 22px; font-weight: 700; color: var(--ink-900);
  letter-spacing: 0; line-height: 1.02;
}
.exit-value-display .unit { font-size: 12px; color: var(--ink-400); margin-left: 4px; font-weight: 500; }
.exit-slider-track {
  position: relative;
  height: 20px;
  display: flex; align-items: center;
}
input[type="range"].range {
  -webkit-appearance: none; appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) var(--pct, 50%), var(--border) var(--pct, 50%), var(--border) 100%);
  outline: none;
  margin: 0;
}
input[type="range"].range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--accent);
  box-shadow: 0 2px 4px rgba(99,91,255,.3);
  cursor: pointer;
  transition: transform .12s;
}
input[type="range"].range::-webkit-slider-thumb:hover { transform: scale(1.12); }
input[type="range"].range::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: white; border: 2px solid var(--accent);
  box-shadow: 0 2px 4px rgba(99,91,255,.3);
  cursor: pointer;
}

/* Reconciliation badge */
.recon-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500;
  background: var(--pos-soft); color: var(--pos);
  white-space: nowrap;
}
.recon-badge.warn { background: var(--warn-soft); color: var(--warn); }
.recon-badge.err { background: var(--neg-soft); color: var(--neg); }
.recon-badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ---------------- Scenario rail ---------------- */
.scenario-rail {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 8px 28px 10px;
  /* Sticky handled by the .sticky-stack wrapper. */
}
.scenario-rail-head {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 6px;
}
.scenario-rail-head h2 {
  font-size: 13px; font-weight: 600; color: var(--ink-700);
  letter-spacing: 0.01em;
}
.scenario-rail-head .count {
  font-size: 12px; color: var(--ink-400);
  background: var(--surface); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 999px;
  font-family: var(--mono);
}

.scenario-cols {
  max-width: 1400px; margin: 0 auto;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(230px, 1fr);
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.scenario-cols::-webkit-scrollbar { height: 6px; }
.scenario-cols::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.scenario-col {
  /* Soft wash of the scenario color (var(--swatch) = color.hex, set inline) so the card
     reads as the same hue as its chart bar. Fallback to white where color-mix is unsupported. */
  background: var(--surface);
  background: color-mix(in srgb, var(--swatch, var(--surface)) 32%, var(--surface));
  border: 4px solid var(--swatch, var(--border));
  border-radius: 8px;
  padding: 7px 9px;
  display: flex; flex-direction: column;
  gap: 5px;
  position: relative;
  transition: box-shadow .15s, transform .15s;
  min-width: 0;
  cursor: pointer;
}
.scenario-col:hover { transform: translateY(-1px); }
.scenario-col.active {
  box-shadow: 0 0 0 2px var(--accent), 0 6px 18px -8px rgba(99,91,255,.25);
}
/* Selected card — a crisp dark ring (distinct from the colored border) that mirrors
   the black outline drawn on this scenario's bars in the hero chart. */
.scenario-col.selected {
  box-shadow: inset 0 0 0 3px var(--ink-900), 0 8px 22px -10px rgba(0,0,0,.35);
}
.scenario-col.selected.active {
  box-shadow: inset 0 0 0 3px var(--ink-900), 0 8px 22px -10px rgba(0,0,0,.35);
}
/* interactive controls inside the card shouldn't show the card's pointer */
.scenario-col .name, .scenario-col input, .scenario-col textarea { cursor: text; }
.scenario-col button, .scenario-col .qs-check { cursor: pointer; }
.scenario-col .col-head {
  display: flex; align-items: flex-start; gap: 8px;
}
.scenario-col .col-head .swatch {
  width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; margin-top: 4px;
}
.scenario-col .col-head .name {
  font-size: 12.8px; font-weight: 700; color: #000;
  flex: 1; min-width: 0;
  background: transparent; border: none;
  outline: none;
  font-family: inherit;
  width: 100%;
  border-radius: 4px;
  padding: 2px 4px; margin: -2px -4px;
  /* textarea that wraps to as many lines as the title needs (auto-grown in JS) */
  resize: none; overflow: hidden;
  white-space: normal; word-break: break-word;
  line-height: 1.25;
  display: block;
}
.scenario-col .col-head .name:hover { background: var(--bg); }
.scenario-col .col-head .name:focus { background: var(--bg); }
.scenario-col .col-head .menu-btn {
  background: transparent; border: none; cursor: pointer;
  color: var(--ink-400);
  padding: 2px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity .15s;
}
.scenario-col:hover .col-head .menu-btn,
.scenario-col.active .col-head .menu-btn { opacity: 1; }
.scenario-col .col-head .menu-btn:hover { background: var(--bg); color: var(--ink-700); }

.scenario-col .details-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-600);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 10.5px;
  font-weight: 650;
  line-height: 1.2;
}
.scenario-col .details-mini:hover {
  background: var(--bg);
  color: var(--accent-ink);
  border-color: var(--border-strong);
}

.scenario-col .col-kpi {
  display: flex; flex-direction: column; gap: 2px;
  padding: 3px 0;
  border-bottom: 1px solid var(--border-soft);
}
.scenario-col .col-kpi .pps {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 17px; font-weight: 700; color: #000;
  letter-spacing: 0;
}
.scenario-col .col-kpi .label {
  font-size: 10px; color: var(--ink-500); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.scenario-col .col-kpi .sub { font-size: 9.5px; color: var(--ink-500); font-family: var(--mono); }

/* (i) info button on each card — like the menu button but always visible */
/* The (i) is the invitation to read what a scenario MEANS — make it stand out and
   gently pulse so the eye is drawn to click it (not a wallflower grey glyph). */
.scenario-col .col-head .info-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0;
  background: var(--accent-soft); border: 1px solid transparent; cursor: pointer;
  color: var(--accent); border-radius: 50%;
  flex-shrink: 0;
  transition: color .15s, background .15s, transform .15s, box-shadow .15s;
  animation: info-pulse 2.6s ease-in-out infinite;
}
.scenario-col .col-head .info-btn:hover {
  background: var(--accent); color: #fff;
  transform: scale(1.1); animation: none;
  box-shadow: 0 4px 12px -2px rgba(99, 91, 255, .45);
}
@keyframes info-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(99, 91, 255, 0); }
  50%      { box-shadow: 0 0 0 4px rgba(99, 91, 255, .16); }
}
/* Respect users who don't want motion — keep the standout color, drop the pulse. */
@media (prefers-reduced-motion: reduce) {
  .scenario-col .col-head .info-btn { animation: none; }
}
/* Fixed-position (coords set inline from the button's rect) so it never gets clipped by the
   scenario-rail's horizontal overflow. A transparent backdrop catches the click-away. */
.card-info-backdrop { position: fixed; inset: 0; z-index: 129; }
.card-info-pop {
  position: fixed;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 130;
  padding: 12px 14px;
}
.card-info-pop .cip-headline {
  font-size: 13px; font-weight: 700; color: var(--ink-900); line-height: 1.35;
  margin-bottom: 7px;
}
.card-info-pop .cip-body {
  font-size: 12px; font-weight: 500; line-height: 1.5; color: var(--ink-600);
  margin-bottom: 5px;
}
.card-info-pop .cip-foot {
  font-size: 11px; font-weight: 600; color: var(--accent-ink);
  margin-top: 6px;
}

/* Crossover readout (Hjalti = James @ $X) — the equality-valuation answer on the card */
.scenario-col .crossover-line {
  font-size: 10.5px; color: var(--ink-700); font-weight: 600;
  padding: 3px 6px; border-radius: 6px;
  background: var(--accent-soft);
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
}
.scenario-col .crossover-line .cx-icon { color: var(--accent-ink); font-weight: 700; }
.scenario-col .crossover-line b { color: #000; font-family: var(--mono); }

/* Quick-select preset checkboxes sit below the compact cards. */
.quick-select-strip {
  max-width: 1400px;
  margin: 6px auto 0;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 8px;
  align-items: center;
}
.quick-select-strip .qs-strip-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 2px;
}
.quick-select-strip .qs-strip-head span:first-child {
  font-size: 10px;
  color: var(--ink-500);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.quick-select-strip .qs-strip-head span:last-child {
  font-size: 10px;
  color: var(--ink-300);
  line-height: 1.25;
}
.quick-select-strip .qs-global-checks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.quick-select-strip .qs-check {
  display: flex; align-items: flex-start; gap: 7px;
  padding: 5px 7px; border-radius: 6px;
  border: 1px solid var(--border-strong); background: var(--surface);
  transition: border-color .12s, background .12s;
  user-select: none;
}
.quick-select-strip .qs-check:hover { border-color: var(--accent); background: var(--bg); }
.quick-select-strip .qs-check input[type="checkbox"] {
  width: 13px; height: 13px; margin: 1px 0 0; flex-shrink: 0;
  accent-color: var(--accent); pointer-events: none;
}
.quick-select-strip .qs-check-label {
  font-size: 11px; font-weight: 650; color: var(--ink-700); line-height: 1.2;
  min-width: 0;
}
.quick-select-strip .qs-check:has(input:checked) {
  border-color: var(--accent); background: var(--accent-soft);
}
.quick-select-strip .qs-check:has(input:checked) .qs-check-label { color: var(--accent-ink); }

/* $0 placeholder bars in the hero chart (GroupedBars) */
.bar-zero { fill: none; stroke-width: 1.3px; stroke-dasharray: 2 2; opacity: 0.65; }
.bar-zero-label { fill: var(--ink-400); font-family: var(--mono); font-size: 10.5px; }

.scenario-col .lever-summary {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11.5px;
}
.scenario-col .lever-summary .line {
  display: flex; justify-content: space-between; gap: 8px;
  color: var(--ink-500);
  min-height: 18px;
  align-items: center;
}
.scenario-col .lever-summary .line .label {
  color: var(--ink-400); flex-shrink: 0;
  white-space: nowrap;
}
.scenario-col .lever-summary .line .val {
  color: var(--ink-700); text-align: right;
  font-family: var(--mono); font-size: 11px;
  font-variant-numeric: tabular-nums;
  min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.scenario-col .lever-summary .line .val.tx { font-family: inherit; }
.scenario-col .lever-summary .line.diff .val {
  color: var(--accent-ink); font-weight: 600;
}

.add-scenario {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: transparent;
  border: 1.5px dashed var(--border-strong);
  border-radius: 8px;
  cursor: pointer;
  padding: 8px;
  gap: 4px;
  color: var(--ink-500);
  transition: all .15s;
  min-width: 150px;
}
.add-scenario:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent-soft);
}
.add-scenario .plus {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid currentColor;
}
.add-scenario .label { font-size: 11px; font-weight: 600; }

/* ---------------- Comparison chart ---------------- */
.comparison-block {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

/* ---------------- Drawer ---------------- */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(26,31,54,0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 100;
  animation: backdrop-in .2s ease;
}
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(640px, 100vw);
  background: var(--bg);
  z-index: 101;
  display: flex; flex-direction: column;
  box-shadow: -12px 0 32px -8px rgba(50,50,93,0.16);
  transform: translateX(0);
  transition: transform .25s cubic-bezier(.4,.2,.2,1);
}
.drawer.entering { transform: translateX(100%); }
.drawer-head {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 22px;
  display: flex; align-items: center; gap: 14px;
  flex-shrink: 0;
}
.drawer-head .swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.drawer-head input.title {
  flex: 1;
  font-size: 18px; font-weight: 600; color: var(--ink-900);
  background: transparent; border: none; outline: none;
  font-family: inherit;
  border-radius: 6px;
  padding: 4px 6px;
  margin: -4px -6px;
  min-width: 0;
}
.drawer-head input.title:hover { background: var(--bg); }
.drawer-head input.title:focus { background: var(--bg); box-shadow: 0 0 0 2px var(--accent-soft); }
.drawer-head .close {
  background: var(--bg); border: 1px solid var(--border);
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-500);
}
.drawer-head .close:hover { color: var(--ink-900); background: var(--border-soft); }
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 22px;
}
.drawer-body .lever-section {
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 22px 0;
}
.drawer-body .lever-section .lever-meta { padding-right: 0; }
.drawer-foot {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 22px;
  display: flex; justify-content: space-between; align-items: center;
  flex-shrink: 0;
}

.color-picker {
  display: flex; gap: 6px;
}
.color-picker .chip {
  width: 22px; height: 22px; border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform .12s;
}
.color-picker .chip:hover { transform: scale(1.1); }
.color-picker .chip.active { border-color: var(--ink-900); transform: scale(1.1); }

/* ---------------- Holder comparison table ---------------- */
.holder-compare-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.holder-compare-head { padding: 16px 20px 14px; border-bottom: 1px solid var(--border-soft); }
.holder-compare-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 13px;
}
.holder-compare-table th {
  text-align: left;
  font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-400);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0;
}
.holder-compare-table th.scenario-col-h {
  border-left: 1px solid var(--border-soft);
}
.holder-compare-table th.scenario-col-h .swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
  margin-right: 6px; vertical-align: -1px;
}
.holder-compare-table th.scenario-col-h .name { color: var(--ink-700); font-weight: 600; text-transform: none; letter-spacing: 0; font-size: 12px; }
.holder-compare-table th.scenario-col-h .sub { color: var(--ink-400); font-size: 10.5px; font-family: var(--mono); margin-top: 1px; }
.holder-compare-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.holder-compare-table td.scenario-cell { border-left: 1px solid var(--border-soft); position: relative; }
.holder-compare-table td.scenario-cell .amt {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 13px; font-weight: 500;
  display: block;
}
.holder-compare-table td.scenario-cell .delta {
  font-size: 11px; font-family: var(--mono);
  margin-top: 1px;
}
.holder-compare-table td.scenario-cell .bar {
  position: absolute; left: 0; bottom: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0.7;
}
.holder-compare-table td.best { background: var(--pos-soft); }
.holder-compare-table td.best .amt { color: var(--pos); font-weight: 600; }
.holder-compare-table td.worst { background: var(--neg-soft); }
.holder-compare-table td.worst .amt { color: var(--neg); }
.holder-compare-table tr:hover td { background: var(--bg); }
.holder-compare-table tr:hover td.best { background: var(--pos-soft); }
.holder-compare-table tr:hover td.worst { background: var(--neg-soft); }
.holder-compare-table tr.group td {
  background: var(--bg); padding: 8px 12px 4px;
  font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-400);
}

/* ---------------- Tabs ---------------- */
.tab-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tab-bar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  gap: 4px;
}
.tab {
  background: transparent;
  border: none;
  padding: 14px 14px 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-400);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-family: inherit;
  display: flex; align-items: center; gap: 8px;
  transition: color .15s;
}
.tab:hover { color: var(--ink-700); }
.tab.active {
  color: var(--accent-ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.tab .badge {
  background: var(--bg);
  color: var(--ink-500);
  padding: 1px 7px; border-radius: 999px;
  font-size: 11px;
}

/* ---------------- Main content ---------------- */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px;
  width: 100%;
  flex: 1;
}

/* ---------------- Lever sections ---------------- */
.lever-section {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 32px;
  padding: 28px 0;
  border-bottom: 1px solid var(--border-soft);
}
.lever-section:last-child { border-bottom: none; }
.lever-section .lever-meta { padding-right: 8px; }
.lever-section .lever-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--accent-ink);
  margin-bottom: 8px;
}
.lever-section .lever-title {
  font-size: 17px; font-weight: 600; color: var(--ink-900);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}
.lever-section .lever-desc {
  font-size: 13px; color: var(--ink-500); line-height: 1.55;
}
.lever-section.disabled {
  opacity: 0.5;
  pointer-events: none;
}
.lever-section .disabled-banner {
  margin-top: 10px;
  padding: 8px 10px;
  background: var(--warn-soft); color: var(--warn);
  border-radius: 8px; font-size: 12px;
}

/* ---------------- Form controls ---------------- */
.field-label {
  font-size: 12px; font-weight: 500; color: var(--ink-500);
  margin-bottom: 6px; display: block;
}
.input, .select {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13.5px;
  color: var(--ink-900);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,91,255,.12);
}
.input.text { font-family: inherit; font-variant-numeric: normal; }
.select { padding-right: 28px; appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%23525f7f' d='M6 8L0 0h12z'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; background-size: 9px; }

.input-group {
  display: flex; align-items: stretch; gap: 0;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); overflow: hidden;
}
.input-group .prefix {
  padding: 0 10px; display: flex; align-items: center;
  background: var(--bg); color: var(--ink-400);
  font-family: var(--mono); font-size: 13px;
  border-right: 1px solid var(--border);
}
.input-group input {
  border: none; padding: 9px 11px; flex: 1; min-width: 0;
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 13.5px; outline: none; background: transparent; color: var(--ink-900);
}
.input-group:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,91,255,.12);
}

/* Toggle */
.toggle {
  position: relative; display: inline-block;
  width: 38px; height: 22px;
}
.toggle input { display: none; }
.toggle .slider {
  position: absolute; inset: 0;
  background: var(--border-strong);
  border-radius: 999px;
  transition: background .15s;
  cursor: pointer;
}
.toggle .slider::after {
  content: '';
  position: absolute; left: 2px; top: 2px;
  width: 18px; height: 18px;
  background: white; border-radius: 50%;
  transition: transform .18s cubic-bezier(.4,.2,.2,1);
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider::after { transform: translateX(16px); }

/* Segmented */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.segmented button {
  background: transparent; border: none;
  padding: 6px 12px; border-radius: 6px;
  font-size: 12.5px; font-weight: 500; color: var(--ink-500);
  cursor: pointer; font-family: inherit;
  transition: all .12s;
  white-space: nowrap;
}
.segmented button:hover { color: var(--ink-900); }
.segmented button.active {
  background: var(--surface);
  color: var(--ink-900);
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}

/* Radio cards */
.radio-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.radio-card {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  background: var(--surface);
  transition: all .12s;
  position: relative;
}
.radio-card:hover { border-color: var(--border-strong); }
.radio-card.active {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(99,91,255,.04) 0%, transparent 100%);
  box-shadow: 0 0 0 1px var(--accent);
}
.radio-card .title {
  font-size: 13.5px; font-weight: 600; color: var(--ink-900);
  margin-bottom: 4px;
}
.radio-card .desc {
  font-size: 12px; color: var(--ink-500); line-height: 1.5;
}
.radio-card .check {
  position: absolute; top: 12px; right: 12px;
  width: 16px; height: 16px; border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
}
.radio-card.active .check {
  border-color: var(--accent); background: var(--accent);
  box-shadow: inset 0 0 0 3px white;
}

/* Buttons */
.btn {
  border: 1px solid var(--border); background: var(--surface);
  padding: 7px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--ink-700);
  cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .12s;
}
.btn:hover { background: var(--bg); border-color: var(--border-strong); }
.btn.primary {
  background: var(--accent); color: white; border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(99,91,255,.25);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--bg); }
.btn.small { padding: 4px 9px; font-size: 12px; }

/* Pills/Badges */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500;
  background: var(--bg); color: var(--ink-500);
  border: 1px solid var(--border-soft);
}
.pill.ok    { background: var(--pos-soft); color: var(--pos); border-color: transparent; }
.pill.warn  { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.err   { background: var(--neg-soft); color: var(--neg); border-color: transparent; }
.pill.info  { background: var(--info-soft); color: var(--info); border-color: transparent; }
.pill.accent{ background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }

/* Tables */
.tbl-wrap { overflow-x: auto; }
.tbl {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 13px;
  min-width: 600px;
}
.tbl th {
  text-align: left;
  font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-400);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  user-select: none;
}
.tbl th:first-child { border-top-left-radius: 8px; }
.tbl th:last-child  { border-top-right-radius: 8px; }
.tbl th.sortable:hover { color: var(--ink-700); }
.tbl th .sort-arrow { font-size: 10px; opacity: .6; margin-left: 2px; }
.tbl td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.expanded { background: var(--bg); }
.tbl tr.expand-row td { background: var(--bg); padding: 4px 12px 14px 36px; }
.tbl td.right, .tbl th.right { text-align: right; }
.tbl td.num, .tbl th.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.tbl tr.click-row { cursor: pointer; }
.tbl tr.click-row:hover { background: var(--bg); }

/* Bar in cell */
.bar-cell {
  position: relative; height: 22px;
  display: flex; align-items: center;
}
.bar-cell .bar {
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  height: 14px; border-radius: 3px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
}
.bar-cell .basis-mark {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 2px; height: 18px; background: var(--ink-300);
}

/* ---------------- Footer ---------------- */
.app-footer {
  text-align: center; padding: 24px;
  font-size: 12px; color: var(--ink-400);
}

/* ---------------- Hero chart wrapper ---------------- */
.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.hero-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.hero-title { font-size: 16px; font-weight: 600; color: var(--ink-900); }
.hero-sub { font-size: 12.5px; color: var(--ink-500); margin-top: 2px; }
/* Scenario color legend — swatch hexes match the bar fills and the tinted cards. */
.hero-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 8px; }
.hero-legend-item {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--ink-700);
}
.hero-legend-swatch {
  width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.hero-canvas { position: relative; }

/* SVG chart styles */
.chart-axis-line { stroke: var(--border); stroke-width: 1; }
.chart-axis-text { fill: var(--ink-400); font-size: 11px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.chart-grid-line { stroke: var(--border-soft); stroke-width: 1; stroke-dasharray: 2 3; }
.chart-label { fill: var(--ink-700); font-size: 11.5px; font-family: 'Manrope', sans-serif; }

/* Animated transitions */
.fade-enter { animation: fade-in .25s ease; }
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------- Scenario picker ---------------- */
.scenario-menu {
  position: absolute; top: calc(100% + 6px); left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  min-width: 360px;
  padding: 6px;
}
.scenario-menu-item {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.scenario-menu-item:hover { background: var(--bg); }
.scenario-menu-item .name { font-size: 13.5px; font-weight: 600; color: var(--ink-900); }
.scenario-menu-item .desc { font-size: 12px; color: var(--ink-500); margin-top: 2px; line-height: 1.45; }

/* ---------------- Responsive ---------------- */
.summary-bar-inner .metric-row { display: contents; }

@media (max-width: 1100px) {
  .summary-bar-inner {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .summary-bar-inner > .exit-slider { grid-column: 1; }
  .summary-bar-inner .metric-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
  }
  .app-header-inner { padding: 12px 20px; gap: 12px; }
  .scenario-pill { font-size: 12px; }
  .btn .label-md { display: none; }
}
@media (max-width: 900px) {
  .app-header-inner { padding: 12px 16px; }
  .summary-bar-inner {
    padding: 14px 16px;
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .summary-bar-inner .metric-row {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
  }
  .tab-bar-inner { padding: 0 16px; overflow-x: auto; }
  .main { padding: 16px; }
  .lever-section {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 20px 0;
  }
  .lever-section .lever-meta { padding-right: 0; }
  .radio-cards { grid-template-columns: 1fr; }
  .scenario-pill { display: none; }
  h1 { font-size: 22px; }
  .exit-value-display { font-size: 22px; }
}

/* Hide tab bar in compact mobile view? No, keep. Maybe hide secondary chrome */
.hide-mobile { display: initial; }
  /* Mobile-specific overrides for the v2 layout */
  @media (max-width: 600px) {
    .hide-mobile { display: none; }
    .app-footer { display: none; }
    .app-header-inner { padding: 10px 14px; }
    .brand { font-size: 14px; }
    .brand-glyph { width: 24px; height: 24px; font-size: 11px; }
    .exit-value-display { font-size: 22px; }
    .main { padding: 12px; }
    .hero { padding: 14px; border-radius: 12px; }
    .hero-title { font-size: 14px; }
    .hero-sub { font-size: 11.5px; }
    .hero-head { flex-wrap: wrap; }
    h3 { font-size: 13.5px; }

    .summary-bar { top: 45px; }
    .scenario-rail { padding: 8px 14px 10px; top: 137px; max-height: 70vh; overflow-y: auto; }
    .scenario-rail-head h2 { font-size: 12px; }
    .scenario-cols {
      grid-auto-flow: row;
      grid-auto-columns: unset;
      grid-template-columns: 1fr;
      gap: 10px;
    }
    .scenario-col { padding: 8px 10px; }
    .scenario-col .col-kpi .pps { font-size: 19px; }
    .scenario-col .details-mini { padding: 3px 6px; font-size: 11px; }
    .quick-select-strip {
      grid-template-columns: 1fr;
      gap: 6px;
    }
    .quick-select-strip .qs-global-checks {
      grid-template-columns: 1fr;
    }
    .add-scenario { min-width: 0; padding: 18px; }
    .add-scenario .plus { width: 28px; height: 28px; }
    .summary-bar-inner { padding: 14px; }
    .summary-bar-inner .exit-slider .row.between { flex-wrap: wrap; }
    .holder-compare-table { font-size: 11.5px; min-width: 540px; }
    .holder-compare-table th, .holder-compare-table td { padding: 6px 8px; }
    .holder-compare-table td.scenario-cell .amt { font-size: 11.5px; }
    .holder-compare-table td.scenario-cell .delta { font-size: 9.5px; }
    .drawer { width: 100vw; }
    .drawer-body { padding: 0 14px; }
    .drawer-body .lever-section { padding: 18px 0; }
    .lever-section .lever-title { font-size: 15px; }
    .lever-section .lever-desc { font-size: 12px; }
    .radio-card { padding: 11px; }
    .card-head { padding: 14px 14px 0; }
    .card-body { padding: 14px; }
    .tbl th, .tbl td { padding: 9px 10px; font-size: 12px; }
  }

/* ============================================================
   v2 additions — docked editor, library picker, empty states
   ============================================================ */
:root { --dock-w: 468px; }

/* ---------------- Docked, non-modal editor ---------------- */
.app-shell { transition: margin-right .25s cubic-bezier(.4,.2,.2,1); }
.app-shell.editor-open { margin-right: var(--dock-w); }

.dock {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: var(--dock-w);
  background: var(--bg);
  z-index: 60;
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border);
  box-shadow: -16px 0 36px -22px rgba(50,50,93,.28);
  animation: dock-in .25s cubic-bezier(.4,.2,.2,1);
}
@keyframes dock-in { from { transform: translateX(20px); opacity: .3; } to { transform: none; opacity: 1; } }
.dock-head {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 22px;
  display: flex; align-items: center; gap: 14px;
  flex-shrink: 0;
}
.dock-head .swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.dock-head input.title {
  flex: 1; font-size: 18px; font-weight: 600; color: var(--ink-900);
  background: transparent; border: none; outline: none; font-family: inherit;
  border-radius: 6px; padding: 4px 6px; margin: -4px -6px; min-width: 0;
}
.dock-head input.title:hover { background: var(--bg); }
.dock-head input.title:focus { background: var(--bg); box-shadow: 0 0 0 2px var(--accent-soft); }
.dock-head .close {
  background: var(--bg); border: 1px solid var(--border);
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-500); flex-shrink: 0;
}
.dock-head .close:hover { color: var(--ink-900); background: var(--border-soft); }
.dock-body { flex: 1; overflow-y: auto; padding: 0 22px; }
/* In the narrow dock, tables never force horizontal scroll — they render as
   compact stacked cards instead (see .grant-cards). Safety net for the rest. */
.dock-body .tbl { min-width: 0; }

/* Compact stacked card list — the dock-friendly replacement for the wide
   grant/SAFE tables. One card per grant/SAFE; full-width controls; no overflow. */
.grant-cards { display: flex; flex-direction: column; gap: 8px; }
.grant-card {
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); padding: 11px 12px;
  display: flex; flex-direction: column; gap: 9px;
}
.grant-card-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  flex-wrap: wrap;
}
.grant-card-head .gid { font-weight: 600; font-size: 13px; font-family: var(--mono); }
.grant-card-head .gvest,
.grant-card-head .ghold { font-size: 11px; color: var(--ink-500); text-align: right; }
.grant-card-head .grole { color: var(--ink-400); text-transform: capitalize; }
.grant-card-stats {
  display: flex; gap: 14px; font-size: 12px; color: var(--ink-700);
  font-family: var(--mono);
}
.segmented.full { display: flex; width: 100%; }
.segmented.full button { flex: 1; text-align: center; padding: 7px 6px; }
.grant-card-regrant {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px;
  align-items: center; padding-top: 2px; border-top: 1px dashed var(--border-soft);
}
.grant-card-regrant .field-label { margin: 0; }
/* A grant that can only be kept (e.g. James's ES-01 @ $0 strike — no reason to reprice). */
.grant-card-keeponly {
  font-size: 12.5px; font-weight: 600; color: var(--ink-700);
  padding: 6px 2px;
}
.grant-card-keeponly .note { font-weight: 400; color: var(--ink-400); }
/* Footnote explaining the "Reprice*" asterisk. */
.reprice-note {
  font-size: 11px; line-height: 1.5; color: var(--ink-400);
  padding: 4px 2px 0;
}
.reprice-note sup { color: var(--accent-ink); font-weight: 700; }
/* Persistent in-card nudge shown while a James grant is repriced. */
.reprice-warn {
  font-size: 11.5px; line-height: 1.45; color: var(--warn);
  background: var(--warn-soft); border-radius: 8px; padding: 8px 10px;
}
.segmented.full button sup { font-size: 9px; }

/* Baseline banner — only on a derived "New scenario". Calm/accent while it matches the
   "James & Hjalti as new founders" template; turns warn-colored once a lever is moved off it. */
.baseline-banner {
  margin: 16px 0 4px; padding: 11px 13px; border-radius: 10px;
  background: var(--accent-soft); border: 1px solid transparent;
}
.baseline-banner.warn { background: var(--warn-soft); }
.baseline-banner-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--ink-700);
}
.baseline-banner.warn .baseline-banner-head { color: var(--warn); }
.baseline-banner-head b { font-weight: 600; }
.baseline-banner-icon { font-size: 13px; line-height: 1; }
.baseline-banner-note {
  font-size: 11.5px; line-height: 1.45; color: var(--ink-500); margin-top: 5px;
}
.baseline-banner.warn .baseline-banner-note { color: var(--warn); }
.baseline-banner-list {
  margin: 6px 0 0; padding-left: 18px;
  font-size: 11.5px; line-height: 1.55; color: var(--warn);
}
.baseline-banner-list li { margin: 1px 0; }

/* Read-only cap-table basis indicator (replaces the old founder-state lever). */
.basis-note {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 0; border-bottom: 1px solid var(--border-soft);
}
.basis-note .basis-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ink-400);
}
.basis-note .basis-val { font-size: 12.5px; color: var(--ink-700); }

/* "(i)" rationale affordance + popover (James/Hjalti split explainer). */
.rationale-info { position: relative; display: inline-block; margin-bottom: 8px; }
.info-btn {
  width: 18px; height: 18px; border-radius: 50%; padding: 0;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--ink-500); font-size: 11px; font-style: italic; font-weight: 700;
  font-family: Georgia, 'Times New Roman', serif; cursor: pointer; line-height: 1;
}
.info-btn:hover { color: var(--accent-ink); border-color: var(--accent); background: var(--accent-soft); }
.rationale-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 50;
  width: 340px; max-width: 86vw; max-height: 60vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 12px 14px;
  font-size: 12px; line-height: 1.5; color: var(--ink-700);
}
.rationale-pop-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.rationale-pop-head b { font-size: 13px; color: var(--ink-900); }
.rationale-pop .x { border: none; background: transparent; font-size: 16px; line-height: 1; cursor: pointer; color: var(--ink-400); }
.rationale-pop p { margin: 6px 0; }
.rationale-pop .rationale-ev { display: flex; flex-direction: column; gap: 7px; margin: 8px 0; }
.rationale-pop .rationale-ev > div { padding-left: 10px; border-left: 2px solid var(--border); }
.rationale-pop a { color: var(--accent-ink); text-decoration: none; font-weight: 500; }
.rationale-pop a:hover { text-decoration: underline; }
.rationale-pop .rationale-note { font-size: 11px; color: var(--ink-400); border-top: 1px solid var(--border-soft); padding-top: 8px; }

/* New Founders split — inline hero control attributing the synthetic block to
   the James and Hjalti anchors. */
.nf-split {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 18px; border-top: 1px solid var(--border-soft);
  background: var(--bg);
}
.nf-split-label { font-size: 13px; font-weight: 600; color: var(--ink-700); }
.nf-split-tag {
  font-size: 14.5px; font-weight: 700; color: var(--ink-900);
  padding: 4px 13px; border-radius: 999px; white-space: nowrap;
}
.nf-split-range { flex: 1; min-width: 140px; max-width: 320px; }

/* Group-rollup payout table — bucket rows + expandable member rows. */
.holder-compare-table tr.bucket-row td { background: var(--surface); }
.holder-compare-table tr.bucket-row:hover td { background: var(--bg); }
.holder-compare-table tr.bucket-member td { background: var(--bg); }
.holder-compare-table tr.bucket-member .amt { font-weight: 500; }
.holder-compare-table .caret {
  display: inline-block; font-size: 10px; color: var(--ink-400);
  transition: transform .12s; transform-origin: center; width: 10px;
}
.holder-compare-table .caret.open { transform: rotate(90deg); }
.dock-body .lever-section { grid-template-columns: 1fr; gap: 14px; padding: 20px 0; }
.dock-body .lever-section .lever-meta { padding-right: 0; }
.dock-foot {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 12px 22px; display: flex; justify-content: space-between; align-items: center;
  flex-shrink: 0;
}
.dock .hint, .dock-foot .hint { font-size: 12px; color: var(--ink-400); }
.dock-note {
  margin-top: 12px; padding: 8px 10px;
  background: var(--accent-soft); color: var(--accent-ink);
  border-radius: 8px; font-size: 12px;
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
}

/* Below this width the dock overlays content instead of reflowing the page. */
@media (max-width: 1200px) {
  .app-shell.editor-open { margin-right: 0; }
  .dock { box-shadow: -16px 0 48px -16px rgba(50,50,93,.4); }
}
@media (max-width: 600px) {
  :root { --dock-w: 100vw; }
}

/* ---------------- Boot / loading / error states ---------------- */
.boot-screen {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 40px 20px; text-align: center; color: var(--ink-500);
}
.boot-screen h3 { font-size: 18px; color: var(--ink-900); margin-top: 6px; }
.boot-screen .hint { font-size: 13px; color: var(--ink-400); line-height: 1.6; }
.boot-screen code {
  font-family: var(--mono); font-size: 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px;
}
.boot-err {
  font-family: var(--mono); font-size: 12px; color: var(--neg);
  background: var(--neg-soft); border-radius: 8px; padding: 10px 12px;
  max-width: 560px; white-space: pre-wrap; word-break: break-word; text-align: left;
}
.chart-loading, .comparison-loading {
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-400); font-size: 13px; padding: 48px 20px;
}
.comparison-loading {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.error-banner {
  padding: 12px 14px; border-radius: 10px; font-size: 13px;
  background: var(--neg-soft); color: var(--neg); border: 1px solid transparent;
}
.scenario-col .col-error { font-size: 13px; font-weight: 600; color: var(--neg); padding: 4px 0; }

/* ---------------- Empty states ---------------- */
.empty-comparison {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  color: var(--ink-400); font-size: 13px;
  padding: 18px; border: 1.5px dashed var(--border-strong); border-radius: 12px;
}
.empty-main { text-align: center; padding: 60px 20px; color: var(--ink-500); }
.empty-main h3 { font-size: 16px; color: var(--ink-700); margin-bottom: 6px; }
.empty-main p { font-size: 13px; margin-bottom: 16px; }
.link-btn {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--accent-ink); font: inherit; text-decoration: underline;
}

/* ---------------- Scenario library picker ---------------- */
.library-backdrop {
  position: fixed; inset: 0; background: rgba(26,31,54,.4);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  z-index: 110; animation: backdrop-in .18s ease;
}
.library-modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: min(880px, calc(100vw - 32px)); max-height: calc(100vh - 64px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lg);
  z-index: 111; display: flex; flex-direction: column; overflow: hidden;
  animation: dock-in .2s ease;
}
.library-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 18px 22px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.library-head h2 { font-size: 16px; font-weight: 700; color: var(--ink-900); }
.library-head .sub { font-size: 12px; color: var(--ink-400); margin-top: 2px; font-family: var(--mono); }
.library-head .close {
  background: var(--bg); border: 1px solid var(--border);
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-500); flex-shrink: 0;
}
.library-head .close:hover { color: var(--ink-900); }
.library-body { flex: 1; overflow-y: auto; padding: 8px 12px; }
.library-row {
  display: grid;
  grid-template-columns: 28px 14px 1fr auto auto;
  align-items: center; gap: 12px;
  padding: 12px 10px; border-radius: 10px;
  border: 1px solid transparent;
}
.library-row:hover { background: var(--bg); }
.library-row.in-set { background: var(--accent-soft); border-color: var(--accent-soft); }
.lib-check { display: flex; align-items: center; justify-content: center; }
.lib-check input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }
.library-row .swatch { width: 12px; height: 12px; border-radius: 3px; }
.lib-main { min-width: 0; }
.lib-name { font-size: 14px; font-weight: 600; color: var(--ink-900); }
.lib-summary { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 3px; }
.lib-summary .chip-line { font-size: 11px; color: var(--ink-500); }
.lib-summary .chip-line b { color: var(--ink-400); font-weight: 500; }
.lib-pps { text-align: right; white-space: nowrap; }
.lib-pps .num { font-family: var(--mono); font-size: 15px; font-weight: 700; color: var(--ink-900); }
.lib-pps .lbl { font-size: 10px; color: var(--ink-400); }
.lib-actions { display: flex; gap: 4px; }
.library-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 22px; border-top: 1px solid var(--border); background: var(--bg); flex-shrink: 0;
}
.library-foot .hint { font-size: 12px; color: var(--ink-400); }

@media (max-width: 700px) {
  .library-row { grid-template-columns: 24px 12px 1fr; }
  .lib-pps, .lib-actions { grid-column: 3; justify-self: start; }
  .lib-actions { margin-top: 6px; }
}

/* ---------------- Balance deviation splash (friendly, non-blocking) ---------------- */
.balance-splash {
  position: fixed; right: 20px; bottom: 20px; z-index: 200;
  width: min(380px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 12px; box-shadow: var(--shadow-lg);
  overflow: hidden; animation: splash-in .26s cubic-bezier(.2,.8,.2,1);
}
@keyframes splash-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.balance-splash-head {
  display: flex; align-items: center; gap: 9px;
  padding: 12px 14px 8px;
}
.balance-splash-icon { font-size: 17px; }
.balance-splash-title { font-size: 13.5px; font-weight: 700; color: var(--ink-900); flex: 1; }
.balance-splash-x {
  background: transparent; border: none; cursor: pointer; color: var(--ink-400);
  padding: 3px; border-radius: 6px; display: flex;
}
.balance-splash-x:hover { background: var(--bg); color: var(--ink-700); }
.balance-splash-body {
  padding: 0 14px; max-height: 46vh; overflow-y: auto;
  font-size: 12px; line-height: 1.5; color: var(--ink-600);
}
.balance-splash-body p { margin: 0 0 8px; }
.balance-splash-foot {
  display: flex; justify-content: flex-end;
  padding: 8px 14px 12px;
}

/* ---------------- Calibration panel ---------------- */
.cal-modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: min(1040px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lg);
  z-index: 111; display: flex; flex-direction: column; overflow: hidden;
  animation: dock-in .2s ease;
}
.cal-body { flex: 1; overflow-y: auto; padding: 16px 22px; }
.cal-chart-wrap { background: var(--bg); border: 1px solid var(--border-soft); border-radius: 12px; padding: 12px 14px 8px; }
.cal-svg { display: block; touch-action: none; }
.cal-anchor { cursor: ns-resize; transition: r .1s; }
.cal-anchor:hover { fill: var(--accent-hover); }
.cal-chart-hint { font-size: 11.5px; color: var(--ink-400); margin-top: 4px; text-align: center; }

.cal-controls { display: grid; grid-template-columns: 1fr 1.2fr; gap: 16px; margin-top: 16px; }
.cal-col-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-500); margin-bottom: 8px; }
.cal-anchor-table, .cal-knobs { background: var(--bg); border: 1px solid var(--border-soft); border-radius: 10px; padding: 12px 14px; }
.cal-anchor-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.cal-anchor-row .cal-exit { font-family: var(--mono); font-size: 12.5px; font-weight: 600; color: var(--ink-700); width: 58px; flex-shrink: 0; }
.cal-anchor-row label, .cal-knob, .cal-knob-row label {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 10.5px; color: var(--ink-400); font-weight: 600;
}
.cal-anchor-row label { flex-direction: row; align-items: center; gap: 5px; }
.cal-anchor-row input { width: 62px; }
.cal-anchor-row input, .cal-knob input, .cal-knob-row input {
  font-family: var(--mono); font-size: 12.5px; color: var(--ink-900);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 4px 7px; outline: none; width: 100%;
}
.cal-anchor-row input:focus, .cal-knob input:focus, .cal-knob-row input:focus { border-color: var(--accent); }
.cal-knobs { display: flex; flex-direction: column; gap: 9px; }
.cal-knob-row { display: flex; gap: 8px; }
.cal-knob-row label { flex: 1; }
.cal-shares { border-top: 1px solid var(--border-soft); padding-top: 9px; display: flex; flex-direction: column; gap: 8px; }
.cal-check-inline { display: flex; align-items: flex-start; gap: 7px; font-size: 11.5px; font-weight: 600; color: var(--ink-700); line-height: 1.3; cursor: pointer; }
.cal-check-inline input { width: 15px; height: 15px; margin-top: 1px; accent-color: var(--accent); flex-shrink: 0; }

.cal-results { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.cal-result-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.cal-fit { font-size: 12px; color: var(--ink-500); font-family: var(--mono); }
.cal-result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.cal-card { background: var(--bg); border: 1px solid var(--border-soft); border-radius: 10px; padding: 12px 14px; }
.cal-card-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-500); margin-bottom: 9px; }
.cal-lever-table { width: 100%; border-collapse: collapse; }
.cal-lever-table td { padding: 4px 0; font-size: 12.5px; color: var(--ink-700); }
.cal-lever-table td.num { text-align: right; font-family: var(--mono); font-weight: 600; color: var(--ink-900); }
.cal-vs { color: var(--ink-400); font-weight: 500; font-size: 11px; }
.cal-con-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.cal-con-label { font-size: 12.5px; font-weight: 600; color: var(--ink-700); flex-shrink: 0; }
.cal-con-detail { font-size: 11px; color: var(--ink-400); margin-left: auto; text-align: right; }
.cal-cost-headline { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; flex-wrap: wrap; }
.cal-cost-est { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--ink-900); }
.cal-cost-item { padding: 5px 0; border-top: 1px solid var(--border-soft); }
.cal-cost-lever { font-size: 12px; font-weight: 600; color: var(--ink-800); }
.cal-cost-tier { font-size: 10.5px; font-weight: 500; color: var(--ink-400); font-family: var(--mono); }
.cal-cost-note { font-size: 11px; color: var(--ink-500); line-height: 1.4; margin-top: 1px; }

.cal-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 22px; border-top: 1px solid var(--border); background: var(--bg); flex-shrink: 0;
}
@media (max-width: 760px) { .cal-controls { grid-template-columns: 1fr; } }
