/* Same system as dscr-calculator / rental-cashflow (type, spacing, fields, cards); indigo accent, lavender paper from the Canva art. */
:root {
  color-scheme: light;
  --paper: #F4F4FA;
  --panel: #FFFFFF;
  --ink: #1E2A2D;
  --muted: #545A6E;
  --line: #DCDCEA;
  --field: #A7A9C0;
  --accent: #3B3FA8;
  --accent-bg: #ECECFA;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 7vw, 2.75rem); font-weight: 760; margin: 0 0 8px; }
h2 { font-size: 1.5rem; font-weight: 700; margin: 40px 0 12px; }
h3 { font-size: 1.15rem; font-weight: 680; margin: 28px 0 8px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.top { border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 52px; font-weight: 680; color: var(--ink); text-decoration: none; }
.brand img { border-radius: 6px; }

.intro { padding: 28px 0 20px; max-width: 62ch; }
.lede { font-size: 1.125rem; color: var(--muted); margin: 0; }
.note { background: var(--accent-bg); padding: 10px 14px; border-radius: 8px; }

/* Calculator: one column on phones, inputs | results from 900px. */
.calc { display: grid; gap: 16px; }
@media (min-width: 900px) {
  .calc { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 24px; align-items: start; }
}

fieldset { margin: 0 0 16px; padding: 8px 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); min-width: 0; }
fieldset:last-child { margin-bottom: 0; }
legend { padding: 0 6px; margin-left: -6px; font-weight: 700; font-size: 1.05rem; }
.field { display: grid; gap: 6px; margin-top: 14px; min-width: 0; }
legend + .field { margin-top: 2px; }
.field > label, .flabel { font-weight: 560; }
.row { display: grid; gap: 0 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
.affix {
  display: flex; align-items: center; min-height: 48px;
  border: 1px solid var(--field); border-radius: 8px; background: var(--panel);
}
.affix:focus-within { outline: 3px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.affix span { padding: 0 12px; color: var(--muted); white-space: nowrap; }
.affix input:first-child { padding-left: 12px; }
input, select, textarea { font: inherit; font-size: 1.0625rem; color: var(--ink); }
.affix input {
  flex: 1; min-width: 0; width: 100%; height: 46px; padding: 0 8px;
  border: 0; background: transparent; font-variant-numeric: tabular-nums;
}
.affix input:focus { outline: none; }
textarea {
  width: 100%; min-height: 128px; padding: 10px 12px; resize: vertical;
  border: 1px solid var(--field); border-radius: 8px; background: var(--panel); font-size: 1rem; line-height: 1.5;
}
textarea:focus { outline: 3px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.hint { margin: 6px 0 0; font-size: 0.9rem; color: var(--muted); }
.check { display: flex; align-items: center; gap: 10px; min-height: 48px; margin-top: 10px; font-weight: 560; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 40px; padding: 0 14px; border: 1px solid var(--field); border-radius: 999px; cursor: pointer;
  background: var(--panel); color: var(--ink); font: inherit; font-size: 0.95rem; font-weight: 560;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }

.tokens { display: grid; grid-template-columns: 1fr auto; margin: 12px 0 0; font-variant-numeric: tabular-nums; }
.tokens dt, .tokens dd { margin: 0; padding: 6px 0; border-bottom: 1px solid var(--line); }
.tokens dd { text-align: right; font-weight: 650; }
.tokens small { color: var(--muted); font-weight: 400; }
.btn {
  min-height: 48px; padding: 0 18px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff; font: inherit; font-weight: 650;
}
.btn:hover { background: #2F3287; }
.btn.ghost { background: var(--panel); color: var(--accent); border: 1px solid var(--accent); margin-top: 14px; }
.btn.ghost:hover { background: var(--accent-bg); }
.btn:disabled { opacity: 0.55; cursor: default; }

/* Results */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 16px 20px; }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 1.1rem; margin: 0 0 6px; }
.result { border-top: 6px solid var(--accent); }
.ratio { margin: 0; display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; }
.big { font-size: clamp(3rem, 14vw, 4.25rem); font-weight: 760; line-height: 1.05; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.per { color: var(--muted); font-weight: 600; }
.best { margin: 6px 0 0; font-size: 1.05rem; }
.best b { font-weight: 700; }
.stamp { margin: 14px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--accent-bg); font-size: 0.9rem; }
.share { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 16px; }
#share-status { color: var(--muted); font-size: 0.9rem; }

.filter { margin: 10px 0 12px; }
.table-wrap { overflow-x: auto; }
.costs { width: 100%; border-collapse: collapse; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.costs th, .costs td { padding: 9px 0 9px 10px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
.costs th:first-child, .costs td:first-child { text-align: left; padding-left: 0; }
.costs thead th { font-size: 0.85rem; color: var(--muted); font-weight: 560; white-space: nowrap; vertical-align: bottom; }
.costs td { white-space: nowrap; }
.costs td:first-child { white-space: normal; }
.costs td b { font-weight: 650; }
.costs td small { display: block; color: var(--muted); font-size: 0.8rem; line-height: 1.35; }
.costs tr.best-row td { background: var(--accent-bg); }
.costs tr.best-row td:first-child { box-shadow: inset 4px 0 0 var(--accent); padding-left: 10px; }
.costs tr.nofit td { color: var(--muted); }
.sort { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; min-height: 32px; color: inherit; font: inherit; }
.sort:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sort::after { content: "↕"; font-size: 0.8em; opacity: 0.6; }
th[aria-sort="ascending"] .sort::after { content: "↑"; opacity: 1; }
th[aria-sort="descending"] .sort::after { content: "↓"; opacity: 1; }
/* Phones: one card per model. Name and notes on the full width, the three costs underneath. */
@media (max-width: 599px) {
  .costs thead tr { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); }
  .costs thead th { border: 0; padding: 0 0 4px; }
  .costs thead th:nth-child(2), .costs thead th:nth-child(3) { display: none; }
  .costs tbody tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .costs tbody td { border: 0; padding: 0; text-align: left; }
  .costs tbody td:first-child { grid-column: 1 / -1; margin-bottom: 6px; }
  .costs tbody td:last-child { text-align: right; }
  .costs tbody td[data-label]::before { content: attr(data-label); display: block; font-size: 0.8rem; color: var(--muted); }
  .costs tr.best-row { background: var(--accent-bg); box-shadow: inset 4px 0 0 var(--accent); padding: 10px 10px 10px 14px; }
  .costs tr.best-row td, .costs tr.best-row td:first-child { background: none; box-shadow: none; padding-left: 0; }
}
.tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 0.75rem; font-weight: 650; vertical-align: 1px; }
.small { font-size: 0.875rem; color: var(--muted); margin: 10px 0 0; }

/* Space held until prices.json arrives, so the first render shifts nothing. */
[data-loading].table-wrap { min-height: 760px; }
[data-loading].chart { min-height: 420px; }
.chart svg { display: block; width: 100%; height: auto; font-family: inherit; }
.chart .lbl { fill: var(--ink); font-size: 13px; }
.chart .val { fill: var(--ink); font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--accent); }
.chart .track { fill: var(--accent-bg); }

/* Reserved for ads later, so adding them shifts nothing. Empty until then. */
.ad-slot { min-height: 250px; margin: 16px 0; }

/* Article */
.guide, .faq, .disclaimer, .prose { max-width: 68ch; }
.guide { margin-top: 24px; }
.guide ul, .guide ol { padding-left: 1.2em; }
.guide li { margin-bottom: 10px; }
.formula {
  margin: 18px 0; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  font-size: 1.05rem; font-weight: 650; font-variant-numeric: tabular-nums;
}
.formula span { display: block; }
.guide .table-wrap { margin: 0 -16px; padding: 0 16px; }
.guide table { border-collapse: collapse; min-width: 560px; width: 100%; font-size: 0.95rem; }
.guide th, .guide td { padding: 10px 12px 10px 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.guide thead th { border-bottom: 2px solid var(--ink); }
.guide tbody th { font-weight: 650; }
.faq h2 { margin-top: 8px; }
.disclaimer { margin: 32px 0 48px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-size: 0.95rem; }
.disclaimer p { margin: 0; }

.prose { padding-top: 28px; padding-bottom: 48px; }
.prose h1 { font-size: clamp(1.9rem, 6vw, 2.4rem); }
.prose ul { padding-left: 1.2em; }

.foot { border-top: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 0.95rem; padding: 18px 0 28px; }
.foot nav { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.foot nav a { display: inline-flex; align-items: center; min-height: 44px; }
.foot .tools { margin-top: 4px; align-items: center; }
.foot .tools span { color: var(--muted); }
.foot p { margin: 8px 0 0; }
