:root {
  --ink: #17211d;
  --muted: #64706b;
  --line: #d7ddd9;
  --soft: #f3f6f4;
  --paper: #fbfcfb;
  --white: #fff;
  --forest: #176b52;
  --forest-dark: #0e4c3a;
  --coral: #d7654f;
  --gold: #c08a25;
  --blue: #3478a8;
  --violet: #745f98;
  --principal: #2b7a66;
  --interest: #d7654f;
  --mortgage: #176b52;
  --treasury: #3478a8;
  --fed: #c08a25;
  --positive: #18704f;
  --negative: #b84a3b;
  --shadow: 0 8px 28px rgba(24, 43, 35, .08);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr) 292px; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px; background: #11231d; color: #eaf3ef; overflow-y: auto; }
.brand { display: flex; gap: 11px; align-items: center; padding: 0 8px 22px; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; background: #d9f2e8; color: var(--forest-dark); font: 800 18px Georgia, serif; border-radius: 6px; }
.brand strong { display: block; font-size: 14px; }
.brand span { display: block; color: #a9bdb5; font-size: 11px; margin-top: 2px; }
.nav-list { display: grid; gap: 3px; }
.nav-button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 5px; color: #b9cbc4; background: transparent; text-align: left; font-size: 12px; }
.nav-button:hover, .nav-button.active { color: white; background: #203c32; }
.nav-index { color: #6fa38f; font: 700 10px ui-monospace, monospace; }
.sidebar-footer { margin: 22px 8px 0; padding-top: 16px; border-top: 1px solid #294238; color: #8ca39a; font-size: 10px; line-height: 1.5; }
.main { min-width: 0; }
.topbar { height: 64px; padding: 0 30px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: rgba(251,252,251,.94); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(10px); }
.breadcrumb { font-size: 12px; color: var(--muted); }
.mode-switch { display: flex; align-items: center; padding: 3px; border: 1px solid var(--line); background: var(--soft); border-radius: 6px; }
.mode-switch button { border: 0; background: transparent; padding: 6px 9px; border-radius: 4px; color: var(--muted); font-size: 11px; }
.mode-switch button.active { background: white; color: var(--forest-dark); box-shadow: 0 1px 4px rgba(0,0,0,.09); }
.mobile-nav { display: none; }
.content { width: min(1180px, 100%); margin: 0 auto; padding: 38px 34px 80px; }
.content, .card, .band, .callout { min-width: 0; }
.hero { position: relative; overflow: hidden; min-height: 300px; margin: -38px -34px 32px; padding: 46px 42px 36px; color: white; background: #14382e; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); align-items: center; gap: 36px; }
.hero::after { content: ''; position: absolute; inset: auto -12% -62% 38%; height: 110%; background: repeating-linear-gradient(115deg, rgba(255,255,255,.04) 0 1px, transparent 1px 42px); transform: skewY(-8deg); pointer-events: none; }
.hero-copy { position: relative; z-index: 1; }
.eyebrow { color: #7abca4; text-transform: uppercase; font-size: 10px; font-weight: 800; letter-spacing: 1.4px; }
h1 { font: 600 clamp(35px, 4.2vw, 61px)/1.02 Georgia, serif; letter-spacing: 0; margin: 11px 0 15px; max-width: 650px; }
.hero p { color: #c2d7cf; font-size: 15px; line-height: 1.6; max-width: 610px; }
.hero-stats { position: relative; z-index: 1; border-left: 1px solid rgba(255,255,255,.18); padding-left: 30px; display: grid; grid-template-columns: 1fr 1fr; gap: 22px 18px; }
.hero-stat span { display: block; color: #a7c4b9; font-size: 10px; text-transform: uppercase; margin-bottom: 6px; }
.hero-stat strong { font: 600 24px Georgia, serif; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 0 0 22px; }
.section-head h2, h2 { font: 600 28px/1.15 Georgia, serif; letter-spacing: 0; margin: 0 0 6px; }
.section-head p, .lede { margin: 0; color: var(--muted); max-width: 730px; line-height: 1.55; font-size: 13px; }
.band { margin: 34px -34px; padding: 32px 34px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #f0f5f2; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.card { background: white; border: 1px solid var(--line); border-radius: 7px; padding: 20px; }
.card h3 { margin: 0 0 8px; font-size: 14px; }
.card p { color: var(--muted); font-size: 12px; line-height: 1.55; }
.metric { padding: 15px 16px; background: white; border: 1px solid var(--line); border-radius: 6px; min-width: 0; }
.metric .label { color: var(--muted); font-size: 10px; text-transform: uppercase; font-weight: 700; }
.metric .value { display: block; margin-top: 5px; font: 600 21px Georgia, serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric .detail { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.metric.positive { border-top: 3px solid var(--positive); }
.metric.negative { border-top: 3px solid var(--negative); }
.formula { overflow-x: auto; padding: 18px; background: #102b23; color: #e6f3ee; border-radius: 6px; font: 15px/1.7 Georgia, serif; text-align: center; }
.formula small { display: block; color: #9fbab0; font: 10px/1.5 ui-sans-serif, sans-serif; margin-top: 6px; }
.math-detail { display: none; }
body.math-heavy .math-detail { display: block; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { border: 0; background: none; color: var(--muted); font-size: 11px; padding: 9px 12px; border-bottom: 2px solid transparent; }
.tab.active { color: var(--forest-dark); border-color: var(--forest); font-weight: 700; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 13px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.field input, .field select { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 5px; background: white; padding: 0 10px; color: var(--ink); }
.field input:focus, .field select:focus { outline: 2px solid #a7d2c2; border-color: var(--forest); }
.range-row { display: grid; grid-template-columns: 1fr 76px; gap: 9px; align-items: center; }
input[type="range"] { accent-color: var(--forest); padding: 0; border: 0; }
.assumptions { position: sticky; top: 0; height: 100vh; overflow-y: auto; border-left: 1px solid var(--line); background: white; padding: 22px 18px; }
.assumptions-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.assumptions h2 { font: 600 16px Georgia, serif; margin: 0; }
.icon-button { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; background: white; color: var(--muted); }
.assumptions .field { margin-bottom: 12px; }
.assumption-summary { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.summary-row { display: flex; justify-content: space-between; gap: 12px; font-size: 11px; }
.summary-row span { color: var(--muted); }
.chart { width: 100%; min-height: 260px; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-empty { height: 260px; display: grid; place-items: center; color: var(--muted); background: var(--soft); border: 1px dashed var(--line); font-size: 12px; }
.chart-tooltip { position: fixed; z-index: 40; pointer-events: none; display: none; background: #10231d; color: white; padding: 8px 10px; border-radius: 4px; font-size: 10px; box-shadow: var(--shadow); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 8px 0 14px; font-size: 10px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 3px; margin-right: 5px; vertical-align: middle; }
.axis-label { fill: #6c7772; font-size: 9px; }
.chart-grid { stroke: #e4e9e6; stroke-width: 1; }
.callout { padding: 22px 24px; border-left: 4px solid var(--gold); background: #fff9eb; }
.callout strong { display: block; font: 600 19px Georgia, serif; margin-bottom: 6px; }
.callout p { margin: 0; color: #655c47; line-height: 1.6; font-size: 12px; }
.term { border-bottom: 1px dotted currentColor; cursor: help; }
.term[data-tip]:hover::after, .term[data-tip]:focus::after { content: attr(data-tip); position: absolute; z-index: 30; width: 230px; transform: translate(-30%, 22px); padding: 9px 11px; background: #10231d; color: white; font-size: 10px; line-height: 1.45; border-radius: 4px; box-shadow: var(--shadow); }
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 6px; max-height: 470px; }
table { width: 100%; border-collapse: collapse; background: white; font-size: 10px; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 2; text-align: right; padding: 10px; background: #edf2ef; color: var(--muted); font-weight: 800; text-transform: uppercase; }
td { text-align: right; padding: 9px 10px; border-top: 1px solid #e9eeeb; font-variant-numeric: tabular-nums; }
th:first-child, td:first-child, th:nth-child(2), td:nth-child(2) { text-align: left; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 0 12px; border: 1px solid var(--forest); border-radius: 5px; color: white; background: var(--forest); font-size: 11px; font-weight: 700; }
.button.secondary { color: var(--forest-dark); background: white; border-color: var(--line); }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.entry { min-height: 150px; display: flex; flex-direction: column; justify-content: space-between; border-top: 3px solid var(--forest); transition: transform .15s, box-shadow .15s; }
.entry:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.entry button { align-self: flex-start; }
.stack-bar { height: 18px; display: flex; overflow: hidden; border-radius: 4px; background: var(--soft); }
.stack-principal { background: var(--principal); }
.stack-interest { background: var(--interest); }
.split-labels { display: flex; justify-content: space-between; margin-top: 7px; font-size: 10px; color: var(--muted); }
.comparison-table { display: grid; grid-template-columns: 130px repeat(var(--offers, 3), minmax(150px,1fr)); overflow-x: auto; }
.comparison-table > div { padding: 10px; border-bottom: 1px solid var(--line); min-width: 0; font-size: 11px; }
.comparison-table .row-label { color: var(--muted); background: var(--soft); }
.best { color: var(--positive); font-weight: 800; }
.heatmap { display: grid; gap: 3px; align-items: stretch; }
.heat-cell { min-height: 54px; padding: 7px; display: grid; place-items: center; text-align: center; border-radius: 3px; font-size: 9px; color: #173028; }
.heat-cell { min-width: 0; overflow: hidden; overflow-wrap: anywhere; }
.flow { display: grid; grid-template-columns: 1fr auto 1.35fr auto 1fr; align-items: center; gap: 10px; }
.flow-node { padding: 16px; min-height: 96px; border: 1px solid var(--line); background: white; border-radius: 6px; }
.flow-node strong { display: block; font-size: 12px; margin-bottom: 5px; }
.flow-node span { color: var(--muted); font-size: 10px; line-height: 1.45; }
.flow-arrow { color: var(--forest); font-size: 20px; }
.status { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }
.status-dot.live { background: var(--positive); }
.notice { padding: 11px 13px; border: 1px solid #e6d6b4; background: #fffaf0; color: #6c5a35; border-radius: 5px; font-size: 10px; line-height: 1.45; }
.glossary { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.glossary-item { padding: 16px; background: white; }
.glossary-item dt { font-weight: 800; font-size: 12px; }
.glossary-item dd { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.footer { padding: 24px 34px; border-top: 1px solid var(--line); color: var(--muted); font-size: 9px; line-height: 1.6; }
@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 210px minmax(0, 1fr); }
  .assumptions { display: none; position: fixed; right: 0; top: 0; z-index: 50; width: 310px; box-shadow: var(--shadow); }
  .assumptions.open { display: block; }
  .assumption-toggle { display: inline-grid !important; }
}
@media (max-width: 800px) {
  body { overflow-x: hidden; }
  .app-shell { display: block; }
  .main, .content { width: 100%; max-width: 100vw; overflow-x: hidden; }
  .grid-2, .grid-3, .grid-4, .field-grid, .card, .callout, .band, .section-head { width: 100%; max-width: 100%; min-width: 0; }
  .grid-2 > *, .grid-3 > *, .grid-4 > *, .field-grid > * { min-width: 0; max-width: 100%; }
  .sidebar { display: none; }
  .topbar { height: auto; min-height: 58px; padding: 10px 16px; gap: 10px; }
  .mobile-nav { display: block; max-width: 180px; height: 34px; border: 1px solid var(--line); background: white; border-radius: 5px; }
  .breadcrumb { display: none; }
  .content { padding: 26px 16px 60px; }
  .hero { margin: -26px -16px 24px; padding: 34px 20px 28px; grid-template-columns: 1fr; gap: 24px; }
  .hero-stats { border-left: 0; border-top: 1px solid rgba(255,255,255,.18); padding: 20px 0 0; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .band { margin: 28px -16px; padding: 26px 16px; }
  .flow { grid-template-columns: 1fr; }
  .flow-arrow { transform: rotate(90deg); text-align: center; }
  .glossary { grid-template-columns: 1fr; }
  .heatmap { width: 100%; gap: 2px; }
  .heat-cell { padding: 4px 2px; font-size: 8px; }
  .callout p, .section-head p { overflow-wrap: anywhere; }
  .field input, .field select { min-width: 0; }
  .footer { padding: 20px 16px; }
}
@media (max-width: 480px) {
  .grid-4, .field-grid { grid-template-columns: 1fr; }
  .hero-stat strong { font-size: 20px; }
  .mode-switch button { padding: 6px; }
  .comparison-table { grid-template-columns: 105px repeat(var(--offers, 3), 150px); }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
