/* One column, calculator first. Quiet neutrals with a slight green bias; one accent. */
:root {
  --bg: #f7f8f6; --surface: #ffffff; --fg: #18211c; --muted: #5d6862; --line: #dfe4e0;
  --accent: #0d6b4c; --accent-soft: #e3f1ea; --warn: #8a5a00; --ok: #1e7b34;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121614; --surface: #1a201d; --fg: #e7ece9; --muted: #9aa69f; --line: #2a322e;
    --accent: #5fd0a2; --accent-soft: #1d3329; --warn: #f0b35c; --ok: #6fcf8a; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121614; --surface: #1a201d; --fg: #e7ece9; --muted: #9aa69f; --line: #2a322e;
  --accent: #5fd0a2; --accent-soft: #1d3329; --warn: #f0b35c; --ok: #6fcf8a; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 17px/1.55 var(--font); }
.wrap { max-width: 640px; margin: 0 auto; padding-inline: 16px; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2 { line-height: 1.2; text-wrap: balance; }
h1 { font-size: 2rem; margin: 0 0 8px; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; margin: 0 0 12px; }
.lead { color: var(--muted); margin: 0 0 24px; }
.small { font-size: .85rem; color: var(--muted); }

header.site { display: flex; justify-content: space-between; align-items: center; padding-block: 16px; }
header.site .brand { font-weight: 700; color: var(--fg); text-decoration: none; }
header.site nav { display: flex; gap: 16px; font-size: .95rem; }
main { padding-block: 16px 40px; display: flex; flex-direction: column; gap: 32px; }

/* Calculator */
.calc { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); min-width: 0; }
input, select { font: inherit; font-size: 1rem; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); width: 100%; }
details summary { cursor: pointer; font-size: .9rem; color: var(--muted); }
details .fields { margin-top: 12px; }
.answer { border-top: 1px solid var(--line); padding-top: 16px; }
.answer .big { font-size: 2.6rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.answer .big small { display: block; font-size: 1rem; font-weight: 400; color: var(--muted); margin-top: 4px; }
.answer p { margin: 6px 0 0; }
.save { color: var(--ok); font-weight: 600; }
.rebates { margin: 0; padding-left: 18px; }
.rebates:empty { display: none; }
.note { font-size: .9rem; color: var(--muted); margin: 0; }

/* Referral */
.referral { background: var(--accent-soft); border-radius: 12px; padding: 16px 20px; }
.referral p { margin: 0; }
.referral .small { margin-top: 6px; }
.button { display: inline-block; background: var(--accent); color: var(--bg); text-decoration: none; font-weight: 600; padding: 10px 16px; border-radius: 8px; border: 0; font: inherit; font-weight: 600; cursor: pointer; }
.button:disabled { opacity: .6; cursor: default; }
.button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }

/* Lists of pages and programs */
.links { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.program { padding-block: 12px; border-bottom: 1px solid var(--line); }
.program:last-child { border-bottom: 0; }
.badge { font-size: .72rem; padding: 2px 8px; border-radius: 99px; border: 1px solid currentColor; margin-left: 6px; white-space: nowrap; }
.badge.warn { color: var(--warn); } .badge.ok { color: var(--ok); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }

/* Community codes */
.codebox { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.codebox .code { font-size: 1.4rem; font-weight: 700; word-break: break-all; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; }
.form-row > input, .form-row > label { flex: 1 1 240px; }
.msg { margin: 0; font-size: .95rem; }
.msg.err { color: var(--warn); }
.rules { margin: 0; padding-left: 18px; color: var(--muted); font-size: .92rem; }

/* Ads, preview, footer */
.ad { padding-top: 8px; border-top: 1px solid var(--line); min-height: 100px; }
.ad-label { font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.ad-placeholder { display: flex; flex-direction: column; justify-content: center; align-items: center; background: var(--surface); border: 1px dashed var(--line); color: var(--muted); border-radius: 8px; }
.preview-banner { background: var(--surface); border-bottom: 1px solid var(--line); color: var(--muted); text-align: center; padding: 8px 16px; font-size: .85rem; }
footer.site { border-top: 1px solid var(--line); padding-block: 20px 32px; display: flex; flex-direction: column; gap: 8px; }
footer.site p { margin: 0; }
footer.site nav { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: .9rem; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); text-decoration: underline; cursor: pointer; }
.linkish:disabled { text-decoration: none; cursor: default; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 12px; }
.stats > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.when { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 20px; }
.when legend { font-size: .85rem; color: var(--muted); margin-bottom: 6px; padding: 0; }
.choice { flex-direction: row; align-items: center; gap: 8px; font-size: 1rem; color: var(--fg); }
.choice input { width: auto; }
.code-note { margin: 4px 0 0; font-size: 1.05rem; color: var(--fg); font-style: italic; overflow-wrap: anywhere; }
.answer .big .per { font-size: 1.4rem; font-weight: 700; color: var(--fg); margin-left: 4px; }
