:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --rail: #0f172a;
  --rail-text: #cbd5e1;
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-faint: #94a3b8;
  --line: #e2e8f0;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --good: #059669;
  --warn: #d97706;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }
.sub { margin: 2px 0 0; color: var(--ink-soft); font-size: 12.5px; }

/* ---------- layout ---------- */
.shell {
  display: grid;
  grid-template-columns: 216px 340px 1fr;
  height: 100vh;
}

/* ---------- left rail: screens ---------- */
.rail {
  background: var(--rail);
  color: var(--rail-text);
  display: flex;
  flex-direction: column;
  padding: 18px 0;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 0 18px 18px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  background: linear-gradient(140deg, #3b82f6, #0ea5e9);
}
.brand-text { color: #fff; font-weight: 650; font-size: 13.5px; }
.screens { list-style: none; margin: 0; padding: 0 10px; flex: 1; }
.screens li { margin-bottom: 2px; }
.screens button {
  width: 100%; text-align: left; cursor: pointer;
  background: transparent; border: 0; border-radius: 8px;
  color: var(--rail-text); padding: 9px 12px; font: inherit; font-size: 13px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.screens button:hover:not([disabled]) { background: rgba(255,255,255,.07); color: #fff; }
.screens button[aria-current="page"] { background: var(--accent); color: #fff; font-weight: 600; }
.screens button[disabled] { opacity: .42; cursor: not-allowed; }
.soon {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em;
  border: 1px solid currentColor; border-radius: 999px; padding: 1px 6px; opacity: .75;
}
.rail-foot { padding: 14px 18px 0; border-top: 1px solid rgba(255,255,255,.09); margin-top: 12px; }
.file-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: #64748b; }
.file-name { font-size: 12px; color: #e2e8f0; word-break: break-all; margin-top: 3px; }

/* ---------- assumptions panel ---------- */
.panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.panel-head { padding: 18px 20px 12px; border-bottom: 1px solid var(--line); }
.controls { flex: 1; overflow-y: auto; padding: 6px 20px 12px; }

.control { padding: 14px 0; border-bottom: 1px solid #f1f5f9; }
.control:last-child { border-bottom: 0; }
.control-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.control-label { font-weight: 560; font-size: 13px; }
.control-value {
  font-variant-numeric: tabular-nums; font-weight: 650; font-size: 13px;
  color: var(--accent); background: var(--accent-soft);
  border-radius: 6px; padding: 1px 7px; white-space: nowrap;
}
.control-value.is-default { color: var(--ink-soft); background: #f1f5f9; }
.control-help { color: var(--ink-faint); font-size: 11.5px; margin: 4px 0 9px; }

input[type=range] {
  width: 100%; -webkit-appearance: none; appearance: none;
  background: transparent; cursor: pointer; margin: 0;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 3px; background: var(--line);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; margin-top: -5.5px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent);
  box-shadow: 0 1px 3px rgba(15,23,42,.25);
}
input[type=range]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=range]::-moz-range-track { height: 5px; border-radius: 3px; background: var(--line); }
input[type=range]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: #fff;
  border: 2px solid var(--accent); box-shadow: 0 1px 3px rgba(15,23,42,.25);
}

.scale {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--ink-faint); font-size: 10.5px; margin-top: 5px;
  font-variant-numeric: tabular-nums;
}
.scale .mid { color: var(--ink-faint); }
.scale .mid b { font-weight: 600; }

.control-date { display: flex; gap: 8px; align-items: center; }
.control-date input {
  font: inherit; padding: 6px 9px; border: 1px solid var(--line);
  border-radius: 7px; color: var(--ink); background: #fff;
}

.panel-actions {
  display: flex; gap: 8px; padding: 14px 20px;
  border-top: 1px solid var(--line); background: #fbfcfe;
}
.btn {
  font: inherit; font-size: 13px; font-weight: 560; cursor: pointer;
  border-radius: 8px; padding: 8px 14px; border: 1px solid transparent;
  transition: background .12s, border-color .12s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.status {
  padding: 0 20px 14px; font-size: 12px; min-height: 18px;
  color: var(--good); background: #fbfcfe;
}
.status.err { color: #dc2626; }

/* ---------- main ---------- */
.main { overflow-y: auto; padding: 20px 24px 32px; min-width: 0; }
.main-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.dirty {
  font-size: 11.5px; font-weight: 600; color: var(--warn);
  background: #fef3c7; border-radius: 999px; padding: 4px 11px; white-space: nowrap;
}

/* Pending edits on a screen the user is not looking at. Still worth showing --
   Save only writes the current one -- but it is not a warning about what is in
   front of them, so it does not shout like one. */
.dirty.is-elsewhere { color: var(--ink-soft); background: var(--line); }

.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin: 16px 0 18px;
}
.kpi {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 11px 13px;
}
.kpi-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-faint); font-weight: 600;
}
.kpi-value {
  font-size: 19px; font-weight: 660; margin-top: 3px;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.kpi-note { font-size: 11px; color: var(--ink-soft); margin-top: 1px; }

/* The plan cannot pay for itself. Every other card on the strip is a detail
   about a projection that does not hold, so this one is not styled to blend. */
.kpi.is-alarm { border-color: #dc2626; background: #fef2f2; }
.kpi.is-alarm .kpi-label { color: #991b1b; }
.kpi.is-alarm .kpi-value { color: #dc2626; }
.kpi.is-alarm .kpi-note { color: #b91c1c; }

.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px 10px; box-shadow: var(--shadow);
  min-width: 0;
}
.card.wide { grid-column: 1 / -1; }
.card h3 { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.card-note { font-weight: 400; font-size: 11.5px; color: var(--ink-faint); }
/* A full-period total pinned to the right of a chart's header. */
.card-total { margin-left: auto; font-weight: 700; font-size: 12.5px;
  color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Ending-balance-by-strategy comparison table. */
.strat-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 13px; }
.strat-table th, .strat-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.strat-table thead th { color: var(--ink-soft); font-weight: 600; font-size: 12px;
  text-align: left; vertical-align: bottom; }
.strat-table th.num, .strat-table td.num { text-align: right;
  font-variant-numeric: tabular-nums; }
.strat-table .th-sub { display: block; font-weight: 400; font-size: 10.5px;
  color: var(--ink-faint); }
.strat-table td.strong { font-weight: 700; }
.strat-table td.roth { color: var(--good); font-weight: 600; }
.strat-table td.pretax { color: #b45309; }        /* amber: still owes tax */
.strat-table .strat-name { font-weight: 600; }
.strat-table .strat-active { display: inline-block; margin-left: 7px; padding: 1px 7px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent);
  font-size: 10.5px; font-weight: 700; vertical-align: middle; }
.strat-table tr.is-active { background: #f8fbff; }
.strat-table tbody tr:last-child td { border-bottom: 0; }
.strat-foot { margin: 8px 2px 0; font-size: 11px; color: var(--ink-faint); line-height: 1.5; }
.chart { margin-top: 8px; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }

.legend { display: flex; flex-wrap: wrap; gap: 5px 13px; margin-top: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--ink-soft); }
.legend i { width: 9px; height: 9px; border-radius: 2px; flex: none; }

.axis text { fill: var(--ink-faint); font-size: 10px; }
.axis line { stroke: var(--line); }
.gridline { stroke: #eef2f7; }
.phase-band { fill: #0f172a; opacity: .028; }
.phase-label { fill: var(--ink-faint); font-size: 9.5px; letter-spacing: .04em; text-transform: uppercase; }
.hover-line { stroke: var(--ink-faint); stroke-dasharray: 3 3; }

.tip {
  position: fixed; pointer-events: none; z-index: 50;
  background: #0f172a; color: #fff; border-radius: 7px;
  padding: 7px 10px; font-size: 11.5px; line-height: 1.45;
  box-shadow: 0 6px 20px rgba(15,23,42,.28); max-width: 260px;
}
.tip b { font-variant-numeric: tabular-nums; }
.tip .row { display: flex; justify-content: space-between; gap: 12px; }
.tip .row i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; }

/* ---------- line-item screen ---------- */
.lineitems[hidden], .cards[hidden] { display: none; }
.group {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 12px; overflow: hidden;
  box-shadow: var(--shadow);
}
.group-head {
  display: grid; grid-template-columns: 1fr 130px 190px 120px;
  gap: 12px; align-items: center;
  padding: 11px 16px; background: #f8fafc; border-bottom: 1px solid var(--line);
}
.group-name { font-weight: 650; font-size: 13.5px; }
.group-count { font-weight: 400; color: var(--ink-faint); font-size: 11.5px; margin-left: 7px; }
.group-total { font-variant-numeric: tabular-nums; font-weight: 650; text-align: right; font-size: 13.5px; }
.group-delta { font-size: 11px; font-weight: 600; text-align: right; }
.up { color: #dc2626; } .down { color: var(--good); } .flat { color: var(--ink-faint); }

.rows { padding: 2px 0; }
.row-item {
  /* name | base | scale | effective | start-end window */
  /* Name gets a guaranteed floor (minmax) so it never collapses to zero and
     clips its label; the wide scale column flexes/shrinks instead when the main
     area is narrow. */
  display: grid; grid-template-columns: minmax(120px, 1fr) 96px minmax(180px, 2fr) 210px;
  gap: 12px; align-items: center; padding: 7px 16px;
  border-bottom: 1px solid #f6f8fa;
}
.row-item:last-child { border-bottom: 0; }
.row-item.is-off .row-name, .row-item.is-off .row-base { opacity: .4; text-decoration: line-through; }
.row-item.is-zero { opacity: .55; }
.row-name { font-size: 12.5px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.row-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-base, .row-eff { font-variant-numeric: tabular-nums; text-align: right; font-size: 12.5px; }
.row-base { color: var(--ink-faint); }
.row-eff { font-weight: 620; }
.row-scale { display: flex; align-items: center; gap: 7px; }
.row-scale input[type=range] { flex: 1; }
.scale-pct { font-variant-numeric: tabular-nums; font-size: 11.5px; font-weight: 620;
  width: 46px; text-align: right; color: var(--accent);
}
.scale-pct.at-base { color: var(--ink-faint); font-weight: 500; }
.row-item input[type=checkbox], .group-head input[type=checkbox] { accent-color: var(--accent); cursor: pointer; }
.lineitems-note { color: var(--ink-faint); font-size: 11.5px; margin: 0 0 12px; }

.summary { display: grid; gap: 9px; }
.summary-row { display: flex; justify-content: space-between; font-size: 12.5px; }
.summary-row b { font-variant-numeric: tabular-nums; }
.summary-total { border-top: 1px solid var(--line); padding-top: 9px; font-weight: 650; }

.btn-open {
  margin-top: 9px; width: 100%; font: inherit; font-size: 12px; font-weight: 560;
  cursor: pointer; border-radius: 7px; padding: 6px 10px;
  background: rgba(255,255,255,.08); color: #e2e8f0;
  border: 1px solid rgba(255,255,255,.16);
}
.btn-open:hover { background: rgba(255,255,255,.15); color: #fff; }

.modal-wide { width: min(640px, 94vw); }
.open-list {
  margin-top: 14px; max-height: 300px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 8px;
}
.open-row {
  display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center;
  padding: 9px 12px; border-bottom: 1px solid #f1f5f9;
  cursor: pointer; background: #fff; width: 100%; text-align: left;
  font: inherit; border-left: 0; border-right: 0; border-top: 0;
}
.open-row:last-child { border-bottom: 0; }
.open-row:hover:not([disabled]) { background: #f8fafc; }
.open-row[disabled] { cursor: not-allowed; background: #fcfcfd; }
.open-row.is-current { background: var(--accent-soft); }
.open-name { font-weight: 560; font-size: 13px; }
.open-name .badge {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em;
  background: var(--accent); color: #fff; border-radius: 999px;
  padding: 1px 7px; margin-left: 8px; font-weight: 700;
}
.open-dir { color: var(--ink-faint); font-size: 11px; margin-top: 2px; word-break: break-all; }
.open-meta { color: var(--ink-faint); font-size: 11px; text-align: right; white-space: nowrap; }
.open-bad { color: #dc2626; font-size: 11px; }

.obligations { border-top: 2px solid var(--line); background: #fcfdff; }
.obligations-head {
  padding: 9px 16px 4px; font-size: 12px; font-weight: 650; color: var(--ink-soft);
}
.obligations-note { font-weight: 400; color: var(--ink-faint); font-size: 11px; margin-left: 8px; }
.row-item.is-obligation { padding-top: 9px; padding-bottom: 9px; }
.row-item.is-obligation .row-name span { font-weight: 560; }
.row-sub { font-size: 10px; color: var(--ink-faint); }
.row-item.is-obligation input[type=month] {
  font: inherit; font-size: 12px; padding: 4px 8px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff; width: 100%;
}

/* ---------- Roth strategy screen ---------- */
.strategy-grid[hidden] { display: none; }
.strategy-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.strat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 0;
}
.strat.is-active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.strat-head { padding: 13px 15px 11px; border-bottom: 1px solid var(--line); }
.strat-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.strat-title h4 { margin: 0; font-size: 13.5px; font-weight: 650; }
.strat-blurb { color: var(--ink-faint); font-size: 11.5px; margin: 5px 0 0; min-height: 30px; }
.strat-pick {
  font: inherit; font-size: 11px; font-weight: 620; cursor: pointer; white-space: nowrap;
  border-radius: 999px; padding: 3px 11px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-soft);
}
.strat-pick:hover { border-color: var(--accent); color: var(--accent); }
.strat.is-active .strat-pick { background: var(--accent); border-color: var(--accent); color: #fff; }
.strat-body { padding: 12px 15px; display: grid; gap: 14px; }
.strat-field .control-top { margin-bottom: 3px; }
.strat-derived { border-top: 1px solid var(--line); padding: 11px 15px 13px; background: #fbfcfe; margin-top: auto; }
.derived-row { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; }
.derived-row b { font-variant-numeric: tabular-nums; }
.derived-row.binds b { color: var(--accent); }
.derived-note { font-size: 10.5px; color: var(--ink-faint); margin-top: 6px; }
.bar-wrap { margin-top: 9px; }
.bar {
  height: 7px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 3px;
}
.bar span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.bar-label { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink-faint); }

@media (max-width: 1180px) { .strategy-grid { grid-template-columns: 1fr; } }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(15,23,42,.42);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
/* `display:flex` above outranks the UA stylesheet's rule for [hidden], so the
   dialog needs this or it shows on load. Same for any other flex/grid element
   toggled with the hidden attribute. */
.modal[hidden], .dirty[hidden], .tip[hidden] { display: none; }
.modal-box {
  background: #fff; border-radius: 12px; padding: 20px 22px;
  width: min(430px, 92vw); box-shadow: 0 18px 50px rgba(15,23,42,.3);
}
.modal-label { display: block; font-size: 12px; font-weight: 560; margin: 14px 0 5px; }
.modal-box input:not([type=checkbox]) {
  width: 100%; font: inherit; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px;
}
.modal-box input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.modal-error { color: #dc2626; font-size: 12px; margin-top: 7px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

@media (max-width: 1180px) {
  .shell { grid-template-columns: 64px 300px 1fr; }
  .brand-text, .screens button span:not(.soon), .rail-foot { display: none; }
  .cards { grid-template-columns: 1fr; }
}

/* A bare [hidden] loses to display:flex/grid, so these need saying explicitly.
   The tax-table screen has nothing to save, and hiding the buttons is the only
   honest way to show that. */
.panel-actions[hidden], .kpis[hidden], .params[hidden] { display: none; }

/* ---------------------------------------------------- output dashboard */
.control-block { padding: 13px 16px; border-bottom: 1px solid var(--line); }
.control-head { font-weight: 600; font-size: 12.5px; letter-spacing: .01em; }

/* A segmented picker: one option on at a time. segmented-col stacks them so
   long strategy names stay readable in the narrow left panel. */
.segmented { display: flex; gap: 6px; }
.segmented-col { flex-direction: column; }
.seg-btn {
  flex: 1; text-align: left; padding: 8px 11px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  font: inherit; font-size: 12px; transition: background .12s, border-color .12s, color .12s;
}
.seg-btn:hover { border-color: #94a3b8; color: var(--ink); }
.seg-btn.is-on {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}

.params-card .card-note { flex: 1 1 100%; }
.params {
  display: grid; gap: 8px; margin-top: 10px;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
}
.param { background: #fff; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; }
.param-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em;
               color: var(--ink-faint); }
.param-value { font-size: 14px; font-weight: 600; margin-top: 2px; }
.param-note { font-size: 11px; color: var(--ink-soft); margin-top: 1px; line-height: 1.35; }

/* ---------------------------------------------------------- tax tables */
.taxtables[hidden] { display: none; }
.taxtables { display: grid; gap: 14px; }
.table-scroll { overflow-x: auto; margin-top: 10px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-faint); font-weight: 600; padding: 6px 10px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.data-table td { padding: 6px 10px; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #f8fafc; }
.dash { color: var(--ink-faint); }

/* The total sits above the parts it sums, so it needs to read as a heading
   rather than as another series. */
.tip .row.is-total {
  border-bottom: 1px solid rgba(255, 255, 255, .22);
  padding-bottom: 4px; margin-bottom: 4px; font-weight: 600;
}
.tip .row.is-total span { color: #fff; }

/* Two legends under the sources-and-uses chart, one per stack, so a colour is
   read against the bar it belongs to rather than a single merged list. */
.legend-group { align-items: baseline; margin-top: 2px; }
.legend-title { font-weight: 600; color: var(--ink); margin-right: 4px; }
.tip-sep { height: 1px; background: rgba(255, 255, 255, .18); margin: 6px 0; }

/* Start / end window per expense line. Blank means the whole projection, so an
   empty box is the normal state and must not read as missing data. */
.row-dates { display: flex; align-items: center; gap: 4px; }
.row-dates input[type=month] {
  font: inherit; font-size: 11px; padding: 2px 4px; width: 104px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
  color: var(--ink-soft);
}
.row-dates input[type=month]:hover { border-color: #94a3b8; }
.row-dates-sep { color: var(--ink-faint); font-size: 11px; }
.row-managed {
  grid-column: 1 / -1; font-size: 11px; color: #b45309;
  background: #fffbeb; border-radius: 6px; padding: 4px 8px; margin-top: 2px;
}

/* A blank window shows the projection default in grey; the user's own choice is
   bold. Grey therefore means "inherited", not "empty". */
.row-dates input.is-default { color: var(--ink-faint); font-weight: 400; }
.row-dates input.is-set { color: var(--ink); font-weight: 700; border-color: #94a3b8; }

/* The real ends of the slider's travel. Without them the base amount sitting
   left of the track reads as the range's lower bound, which it is not — the
   track runs from half the base to one and a half times it. */
.range-end {
  font-size: 10px; color: var(--ink-faint); font-variant-numeric: tabular-nums;
  white-space: nowrap; flex: 0 0 auto;
}

/* The amount is editable: the slider is for exploring, the box for when you
   already know the number. Both write the same value. */
.amount-box {
  display: inline-flex; align-items: center; gap: 1px; flex: 0 0 auto;
  border: 1px solid var(--line); border-radius: 7px; padding: 2px 6px; background: #fff;
}
.amount-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(37,99,235,.12); }
.amount-box input {
  font: inherit; font-size: 12px; font-weight: 620; border: 0; outline: none;
  width: 62px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink);
  background: transparent; -moz-appearance: textfield;
}
.amount-box input::-webkit-outer-spin-button,
.amount-box input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.amount-prefix, .amount-suffix { font-size: 10.5px; color: var(--ink-faint); }

/* Save As folder browser. Scrollable so a deep folder cannot push the file-name
   box off screen. */
.save-shortcuts { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 8px; }
.btn-chip {
  font: inherit; font-size: 11.5px; padding: 4px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
}
.btn-chip:hover { border-color: #94a3b8; color: var(--ink); }
.save-path {
  font-size: 11.5px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--ink-soft); background: #f8fafc; border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 9px; margin-bottom: 6px; overflow-wrap: anywhere;
}
.save-path.is-readonly { color: #b45309; background: #fffbeb; border-color: #fde68a; }
.save-browser {
  max-height: 220px; overflow-y: auto; border: 1px solid var(--line);
  border-radius: 9px; margin-bottom: 12px; background: #fff;
}
.save-row {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  font: inherit; font-size: 12.5px; padding: 7px 11px; border: 0; background: none;
  border-bottom: 1px solid #f1f5f9; cursor: pointer; color: var(--ink);
}
.save-row:last-child { border-bottom: 0; }
.save-row:hover { background: #f8fafc; }
.save-row.is-file { color: var(--ink-faint); cursor: default; }
.save-row.is-file:hover { background: none; }
.save-row.is-up { color: var(--ink-soft); }
.save-icon { color: var(--ink-faint); font-size: 11px; }
.save-empty { padding: 10px 11px; font-size: 12px; color: var(--ink-faint); }

/* ---------- v2 SaaS header bits (rail) ---------- */
.brand-tag {
  font-size: 9px; font-weight: 700; background: var(--accent); color: #fff;
  padding: 1px 5px; border-radius: 999px; margin-left: 6px; vertical-align: middle;
  letter-spacing: .04em;
}
.rail-user { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.09); }
.ws-name { font-size: 11.5px; color: #cbd5e1; word-break: break-word; }
.user-chip { font-size: 11px; color: #94a3b8; margin-top: 2px; word-break: break-all; }

/* ---------- login gate (auth.js) ---------- */
.btn-logout {
  margin-top: 8px; font: inherit; font-size: 11px; cursor: pointer;
  background: transparent; color: #94a3b8; border: 1px solid rgba(255,255,255,.14);
  border-radius: 7px; padding: 4px 10px;
}
.btn-logout:hover { color: #fff; border-color: rgba(255,255,255,.3); }

.login-overlay {
  position: fixed; inset: 0; z-index: 100; display: flex;
  align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(150deg, #0f172a, #1e293b);
}
.login-card {
  width: 100%; max-width: 360px; background: #fff; border-radius: 14px;
  padding: 28px 26px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-brand { font-weight: 700; font-size: 18px; color: var(--ink); }
.login-brand span {
  font-size: 10px; font-weight: 700; background: var(--accent); color: #fff;
  padding: 1px 6px; border-radius: 999px; margin-left: 4px; vertical-align: middle;
}
.login-sub { color: var(--ink-soft); font-size: 13px; margin: 6px 0 18px; }
.login-google {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 9px;
  font: inherit; font-size: 13.5px; font-weight: 560; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 9px; padding: 10px;
}
.login-google:hover { background: #f8fafc; border-color: #cbd5e1; }
.g-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; background: #4285f4; color: #fff;
  font-weight: 700; font-size: 12px;
}
.login-or { display: flex; align-items: center; gap: 10px; color: var(--ink-faint);
  font-size: 11px; margin: 16px 0; }
.login-or::before, .login-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
#login-form { display: flex; flex-direction: column; gap: 9px; }
#login-form input {
  font: inherit; font-size: 13.5px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 9px;
}
#login-form input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.login-submit {
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; margin-top: 4px;
  background: var(--accent); color: #fff; border: 0; border-radius: 9px; padding: 10px;
}
.login-submit:hover { background: #1d4ed8; }
.login-submit[disabled] { opacity: .6; cursor: default; }
.login-error { color: #dc2626; font-size: 12.5px; }
.login-note { color: var(--good); font-size: 12.5px; margin-top: 10px; }
.login-toggle { margin-top: 16px; font-size: 12.5px; color: var(--ink-soft); text-align: center; }
.login-toggle a { color: var(--accent); text-decoration: none; margin-left: 5px; font-weight: 560; }
.login-toggle a:hover { text-decoration: underline; }

/* ---------- plan import/export buttons (rail) ---------- */
.rail-files { display: flex; gap: 6px; margin-top: 6px; }
.rail-files .btn-open { flex: 1; margin-top: 0; font-size: 11px; padding: 5px 8px; }

/* ---------- export-state badge (replaces the old "unsaved changes") ---------- */
/* Default .dirty (amber) = saved to your workspace, but no up-to-date file copy. */
.dirty.is-exported { color: var(--good); background: #d1fae5; }
.dirty.is-error { color: #dc2626; background: #fee2e2; }

/* ---------- first-run welcome ---------- */
.welcome-card { max-width: 460px; }
.welcome-list {
  margin: 14px 0 18px; padding-left: 18px; color: var(--ink-soft);
  font-size: 13px; line-height: 1.7;
}
.welcome-list b { color: var(--ink); }

.plan-manager-row {
  display: grid; grid-template-columns: 40px minmax(0, 1fr);
  align-items: center; border-bottom: 1px solid #f1f5f9;
}
.plan-manager-row:last-child { border-bottom: 0; }
.plan-manager-row .plan-select {
  width: 16px; height: 16px; margin: 0; padding: 0;
  justify-self: center; accent-color: var(--accent); cursor: pointer;
}
.plan-manager-row .open-row {
  min-width: 0; min-height: 44px; border-bottom: 0;
}
.plan-manager-row .open-name { min-width: 0; overflow-wrap: anywhere; }

.model-scope { margin: 0 0 20px; font-size: 12px; line-height: 1.6; color: #475569; }
.model-scope summary { cursor: pointer; }
.model-scope li { margin-bottom: 8px; }

.portfolio-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
  margin: 16px 0 18px;
}
.portfolio-summary[hidden] { display: none; }
.portfolio-pair { display: grid; grid-template-rows: 1fr 1fr; gap: 10px; min-width: 0; }
.portfolio-initial { background: #f8fafc; }

.assumptions-changed {
  margin: 16px 0; padding: 14px 18px;
  border: 1px solid #d97706; border-left: 5px solid #d97706;
  border-radius: 8px; background: #fffbeb; color: #78350f;
  font-size: 15px; font-weight: 650; line-height: 1.5;
}
.assumptions-changed[hidden] { display: none; }

.assumptions-changed.is-synced {
  border-color: #16a34a; background: #f0fdf4; color: #166534;
}

.shell.is-administration { grid-template-columns: 216px minmax(0, 1fr); }
.panel[hidden], .administration-page[hidden], .members-editor[hidden] { display: none; }
.administration-page { max-width: 1080px; display: grid; gap: 20px; margin-top: 24px; }
.admin-overview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.admin-card { background: white; border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.admin-card h2 { margin-bottom: 8px; font-size: 17px; }
.admin-card label { display: block; font-weight: 600; margin: 18px 0 6px; }
.admin-card input, .admin-card select {
  width: 100%; min-height: 40px; padding: 8px 10px; font: inherit;
  color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 6px;
}
.admin-card .sub { overflow-wrap: anywhere; }
.members-list { margin-top: 18px; }
.member-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.member-row > div { min-width: 0; overflow-wrap: anywhere; }
.members-editor { display: grid; grid-template-columns: minmax(0, 2fr) minmax(120px, 1fr) auto; align-items: end; gap: 14px; }
.members-editor button { min-height: 40px; }
@media (max-width: 800px) {
  .admin-overview, .members-editor { grid-template-columns: 1fr; }
}
.shell.is-administration .screens button span { display: inline; }
.shell.is-administration .brand-text, .shell.is-administration .rail-foot { display: block; }
