:root {
  --bg: #F6F5F2;
  --surface: #FFFFFF;
  --ink: #121212;
  --muted: #767469;
  --line: #E3E1DA;
  --line-strong: #cfcdc2;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, sans-serif;
}
.page {
  max-width: 1080px;
  margin: 0 auto;
  height: 100dvh;
  padding: 2vh 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.6vh;
  overflow-y: auto; /* safety net only — layout is sized to avoid needing this */
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.mark {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: 'Archivo', sans-serif;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.02em;
}
.mark-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
  align-items: center;
  flex-shrink: 0;
}
.eyebrow {
  font-size: clamp(9px, 1.3vh, 11px);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.8vh;
}
.headline {
  font-family: 'Archivo', sans-serif;
  font-weight: 900;
  font-size: clamp(22px, 4.4vh, 46px);
  line-height: 0.98;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  margin: 0 0 1vh;
}
.lede {
  font-size: clamp(11px, 1.5vh, 14px);
  line-height: 1.4;
  color: #454338;
  max-width: 40ch;
  margin: 0;
}
.hero-mark {
  width: min(100%, 18vh);
  height: auto;
  justify-self: end;
}

/* ---------- Stat row (live results) ---------- */
.stats {
  border: 1px solid var(--line);
  overflow: hidden;
  background: var(--surface);
  flex-shrink: 0;
}
.stat-hero {
  padding: 2vh 28px 1.6vh;
  border-bottom: 1px solid var(--line);
}
.stat-num-hero {
  font-family: 'Archivo', sans-serif;
  font-weight: 900;
  font-size: clamp(36px, 7.5vh, 88px);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 0.95;
  margin-bottom: 0.6vh;
}
.stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}
.stat {
  padding: 1.4vh 28px;
  border-right: 1px solid var(--line);
}
.stat:last-child { border-right: none; }
.stat-num {
  font-family: 'Archivo', sans-serif;
  font-weight: 800;
  font-size: clamp(18px, 2.8vh, 28px);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-bottom: 0.5vh;
  white-space: nowrap;
}
.stat-label {
  font-size: clamp(9px, 1.2vh, 11px);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Controls panel ---------- */
.panel {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
  flex: 1;
  min-height: 0;
}
.controls-card {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 2vh 24px;
  display: flex;
  flex-direction: column;
}
.panel-title {
  font-family: 'Archivo', sans-serif;
  font-weight: 800;
  font-size: clamp(11px, 1.4vh, 13px);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0 0 1.6vh;
}
.field { margin-bottom: 1.6vh; }
.field:last-child { margin-bottom: 0; }
.field-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.7vh;
}
.field-label {
  font-size: clamp(10px, 1.3vh, 12px);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.field-value {
  font-family: 'Archivo', sans-serif;
  font-weight: 700;
  font-size: clamp(13px, 1.7vh, 16px);
  font-variant-numeric: tabular-nums;
}
.field-input {
  font-family: 'Archivo', sans-serif;
  font-weight: 700;
  font-size: clamp(13px, 1.7vh, 16px);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  text-align: right;
  padding: 0 1px 1px;
  -moz-appearance: textfield;
}
.field-input::-webkit-outer-spin-button,
.field-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.field-input:hover {
  border-bottom-color: var(--line-strong);
}
.field-input:focus {
  outline: none;
  border-bottom-color: var(--ink);
}
.field-input--price { width: 92px; }
.field-input--pct { width: 40px; }
.field-input--term { width: 32px; }
.rate-toggle-row {
  display: flex;
  gap: 8px;
  margin-bottom: 1vh;
}
.rate-toggle {
  flex: 1;
  font-family: 'Archivo', sans-serif;
  font-weight: 700;
  font-size: clamp(9px, 1.2vh, 11px);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 0.9vh 8px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  cursor: pointer;
}
.rate-toggle.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}
input[type="range"] {
  width: 100%;
  height: 2px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--line-strong);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--ink);
  margin-top: -7px;
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--ink);
}
input[type="range"]::-moz-range-track {
  height: 2px;
  background: var(--line-strong);
}

/* ---------- Split visual (deposit vs loan) ---------- */
.split-card {
  overflow: hidden;
  background: var(--ink);
  display: flex;
  flex-direction: column;
}
.split-bars {
  flex: 1;
  display: flex;
  min-height: 0;
}
.split-seg {
  display: flex;
  align-items: flex-end;
  padding: 1.4vh 18px;
  transition: flex-basis 0.15s ease;
  position: relative;
}
.split-seg.deposit {
  background: #fff;
  color: var(--ink);
}
.split-seg.loan {
  background: var(--ink);
  color: #fff;
}
.split-seg-label {
  font-family: 'Archivo', sans-serif;
  font-weight: 800;
  font-size: clamp(11px, 1.5vh, 13px);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1.3;
}
.split-seg-amount {
  font-size: clamp(9px, 1.2vh, 11px);
  font-weight: 500;
  opacity: 0.7;
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.rate-note {
  grid-column: 1 / -1;
  font-size: clamp(9px, 1.2vh, 12px);
  color: var(--muted);
  margin-top: 1.4vh;
  padding-top: 1.2vh;
  border-top: 1px solid var(--line);
}
.rate-note b { color: var(--ink); }

.disclaimer {
  font-size: clamp(8px, 1.05vh, 10px);
  line-height: 1.5;
  color: var(--muted);
  max-width: 72ch;
  flex-shrink: 0;
  margin: 0;
  padding-top: 1.2vh;
  border-top: 1px solid var(--line);
}

@media (max-width: 720px) {
  .page { overflow-y: auto; }
  .hero { grid-template-columns: 1fr; }
  .hero-mark { justify-self: start; width: 100px; margin-top: 8px; }
  .stats { grid-template-columns: 1fr; }
  .stat { border-right: none; border-bottom: 1px solid var(--line); }
  .stat:last-child { border-bottom: none; }
  .panel { grid-template-columns: 1fr; }
  .split-card { min-height: 140px; }
}
