:root {
  --ink: #1c2430;
  --muted: #5d6877;
  --line: #dcd8cf;
  --paper: #faf8f3;
  --card: #ffffff;
  --accent: #c96a00;
  --accent-ink: #ffffff;
  --good: #1f6b43;
  --good-bg: #e6f3ec;
  --info-bg: #e8eef7;
  --warn-bg: #fdf1d8;
  --bad: #a32020;
  --bad-bg: #fbe9e7;
  --loss: #d9827d;
  --total: #b9b7ab;
}
* { box-sizing: border-box; }
html { font-size: 17px; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--paper); line-height: 1.55; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 48px; min-height: 70vh; }
.narrow { max-width: 640px; }
h1 { font-size: 1.8rem; line-height: 1.2; margin: 0.4em 0 0.6em; }
h2 { font-size: 1.25rem; margin: 1.8em 0 0.5em; }
h3 { font-size: 1.05rem; margin: 1.2em 0 0.3em; }
a { color: #0b5cab; }
code { background: #efece4; padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.sr { position: absolute; left: -9999px; }

.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.sun { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px #f4d6ad; display: inline-block; }
nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
nav a { color: var(--ink); text-decoration: none; }
nav a:hover { text-decoration: underline; }
.inline { display: inline; margin: 0; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--ink); cursor: pointer; }
.linklike.underline { text-decoration: underline; }
.test-note { background: var(--warn-bg); border-bottom: 1px solid var(--line); font-size: 0.9rem; padding: 6px 0; }
.site-footer { border-top: 1px solid var(--line); padding: 18px 0; color: var(--muted); font-size: 0.9rem; }

.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 10px 18px; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { filter: brightness(0.95); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.small { padding: 5px 12px; font-size: 0.9rem; color: var(--accent-ink); }
.btn.secondary { background: var(--card); color: var(--ink); border: 1px solid var(--line); }

.hero { padding: 28px 0 8px; max-width: 760px; }
.hero h1 { font-size: 2.2rem; }
.lead { font-size: 1.12rem; }
.steps { padding-left: 1.2em; }
.steps li { margin-bottom: 0.5em; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; margin-bottom: 14px; }
.card h3 { margin-top: 0.2em; }
.card.row { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.note { margin-top: 12px; }
.audit-list { flex-basis: 100%; margin: 0; padding: 8px 0 0 1.1em; border-top: 1px solid var(--line); font-size: 0.92rem; color: var(--muted); }

.flash { border-radius: 8px; padding: 10px 14px; background: var(--info-bg); margin: 0 0 14px; }
.flash.success { background: var(--good-bg); color: var(--good); }
.flash.error { background: var(--bad-bg); color: var(--bad); }
.flash.warning { background: var(--warn-bg); }
.flash ul { margin: 4px 0 0; padding-left: 1.1em; }
.flash li { margin-bottom: 4px; }
.error { color: var(--bad); margin: 4px 0 0; font-size: 0.9rem; }
.disclosure { background: var(--warn-bg); border-radius: 8px; padding: 10px 14px; }

.choices { border: 0; padding: 0; margin: 0 0 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choices legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.choice { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 1px solid #b9b4a8; border-radius: 10px; padding: 12px 14px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px #f4d6ad; }
.choice input { margin-top: 5px; }
.choice span span { display: block; font-size: 0.9rem; }
.choices .error { grid-column: 1 / -1; }

.progress { list-style: none; padding: 0; margin: 18px 0; counter-reset: step; }
.progress li { counter-increment: step; position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 12px 52px; margin-bottom: 10px; display: grid; gap: 4px; }
.progress li::before { content: counter(step); position: absolute; left: 14px; top: 12px; width: 26px; height: 26px; border-radius: 50%; background: #efece4; color: var(--muted); font-weight: 700; display: grid; place-items: center; }
.progress li.done::before { content: "✓"; background: var(--good-bg); color: var(--good); }
.progress li.now { border-color: var(--accent); }
.progress li.now::before { background: var(--accent); color: #fff; }
.progress li > span { color: var(--muted); }
.progress .actions { margin-top: 4px; }
details summary { cursor: pointer; color: var(--muted); }

.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea, .chat-form input {
  width: 100%; padding: 9px 11px; border: 1px solid #b9b4a8; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
.field textarea + input, .field input + textarea { margin-top: 6px; }
.field .help { color: var(--muted); font-size: 0.86rem; margin: 4px 0 0; }
.field.has-error input, .field.has-error select { border-color: var(--bad); }
.field label.check, .field div label { font-weight: 400; display: flex; gap: 8px; align-items: baseline; }
.field > div { columns: 2; }
.field > div > div { break-inside: avoid; }
.filter { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.filter select { padding: 7px 10px; border-radius: 8px; border: 1px solid #b9b4a8; font: inherit; }

.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 0.86rem; color: var(--muted); font-weight: 600; }
.table.numbers td:not(:first-child), .table.numbers th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.tags { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags li { background: #efece4; border-radius: 999px; padding: 2px 10px; font-size: 0.86rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 14px 0; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.stats dt { color: var(--muted); font-size: 0.82rem; }
.stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.rating { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 6px 0 10px; }
.price { font-size: 2rem; font-weight: 700; margin: 0.2em 0; }

.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; align-items: start; }
.messages { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; height: 420px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 82%; padding: 9px 13px; border-radius: 14px; white-space: pre-wrap; }
.msg.assistant { background: #f1eee6; align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.user { background: #2b4a6f; color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.waiting { color: var(--muted); }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; min-height: 4px; }
.chip { border: 1px solid var(--accent); color: var(--accent); background: #fff; border-radius: 999px; padding: 5px 13px; font: inherit; cursor: pointer; }
.chip:hover { background: #fdf1e0; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; }
.next-step { margin-top: 14px; }
.facts dl, dl.compact { margin: 0; }
.facts dt, dl.compact dt { color: var(--muted); font-size: 0.82rem; margin-top: 8px; }
.facts dd, dl.compact dd { margin: 0; }

.report { max-width: 780px; }
.legal li { margin-bottom: 0.35em; }
.chart { margin: 18px 0; }
.chart svg { width: 100%; height: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.chart figcaption { color: var(--muted); font-size: 0.86rem; margin-top: 4px; }
.chart .axis { stroke: #8b8f96; }
.chart .link { stroke: #8b8f96; stroke-dasharray: 2 3; }
.chart .bar.total { fill: var(--total); }
.chart .bar.loss { fill: var(--loss); }
.chart text { font-size: 12px; fill: var(--muted); text-anchor: middle; }
.chart text.value { font-size: 13px; fill: var(--ink); }
.bars { display: none; list-style: none; margin: 0; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.bars li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; margin-bottom: 10px; }
.bars li:last-child { margin-bottom: 0; }
.bars .value { font-weight: 600; font-variant-numeric: tabular-nums; }
.bars .track { grid-column: 1 / -1; display: block; height: 14px; background: #f1eee6; border-radius: 4px; overflow: hidden; }
.bars .fill { display: block; height: 100%; border-radius: 4px; background: var(--total); }
.bars .loss .fill { background: var(--loss); }

.review-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.fixrow { display: grid; grid-template-columns: 2fr 130px 1fr 1.6fr; gap: 6px; }
.fixrow textarea, .fixrow input, .fixrow select { margin: 0 !important; }
.preview { border: 1px dashed var(--line); border-radius: 10px; padding: 6px 18px; background: var(--card); }

@media (max-width: 760px) {
  .chat-layout, .review-layout { grid-template-columns: 1fr; }
  .choices { grid-template-columns: 1fr; }
  .messages { height: min(420px, 52vh); }
  .fixrow { grid-template-columns: 1fr; }
  .field > div { columns: 1; }
  .hero h1 { font-size: 1.7rem; }
  .table { display: block; overflow-x: auto; }
  .table.numbers th, .table.numbers td { padding: 7px 6px; font-size: 0.9rem; }
  /* On a phone the loss chart becomes a list of bars, and the table of measures a stack of cards. */
  .chart svg { display: none; }
  .bars { display: block; }
  .table.stack { border: 0; background: none; overflow: visible; }
  .table.stack thead { display: none; }
  .table.stack tbody, .table.stack tr, .table.stack td { display: block; }
  .table.stack tr { background: var(--card); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; padding: 6px 0; }
  .table.stack td { border: 0; padding: 4px 12px; }
  .table.stack td:first-child { font-weight: 600; }
  .table.stack td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: 0.82rem; }
}
@media print {
  .site-header, .site-footer, .noprint, .flash, .bars { display: none !important; }
  .chart svg { display: block !important; }
  body { background: #fff; font-size: 12pt; }
  a { color: inherit; text-decoration: none; }
}
