/* Car Loan Calculator Canada — styles */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e1e4e9;
  --text: #0e1726;
  --text-2: #4a5466;
  --muted: #6b7486;
  --brand: #c8102e;
  --brand-ink: #a50d26;
  --accent: #1f5fbf;
  --accent-soft: #e7effb;
  --good: #137a3f;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
  --radius: 16px;
  /* chart series (validated reference palette, slots 1–4) */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --grid: #e6e8ec;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1218;
    --surface: #171b23;
    --surface-2: #1f2430;
    --border: #2b3240;
    --text: #eef1f6;
    --text-2: #c0c7d4;
    --muted: #949cab;
    --brand: #ef4b5f;
    --brand-ink: #ff6b7d;
    --accent: #5b9bf0;
    --accent-soft: #1d2a40;
    --good: #4cc27c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --s4: #c98500;
    --grid: #2a303c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1218;
  --surface: #171b23;
  --surface-2: #1f2430;
  --border: #2b3240;
  --text: #eef1f6;
  --text-2: #c0c7d4;
  --muted: #949cab;
  --brand: #ef4b5f;
  --brand-ink: #ff6b7d;
  --accent: #5b9bf0;
  --accent-soft: #1d2a40;
  --good: #4cc27c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --s4: #c98500;
  --grid: #2a303c;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-feature-settings: "tnum" 1;
}
a { color: var(--accent); }
img, svg { max-width: 100%; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -.01em; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.site-header .wrap { display: flex; align-items: center; gap: 16px; height: 60px; }
.logo { display: flex; align-items: center; gap: 10px; min-width: 0; font-weight: 800; color: var(--text); text-decoration: none; font-size: 17px; white-space: nowrap; }
.logo svg { width: 28px; height: 28px; flex: none; }
.logo span em { font-style: normal; color: var(--brand); }
.nav { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.nav a { color: var(--text-2); text-decoration: none; font-size: 14px; font-weight: 600; padding: 8px 10px; border-radius: 8px; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); }
.theme-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 8px; width: 36px; height: 36px; cursor: pointer; display: grid; place-items: center; }
.menu-btn { display: none; }
@media (max-width: 760px) {
  .nav { display: none; position: absolute; top: 60px; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); flex-direction: column; align-items: stretch; padding: 8px 16px 16px; }
  .nav.open { display: flex; }
  .menu-btn { display: grid; margin-left: auto; }
  .nav + .theme-btn { margin-left: 0; }
}

/* hero */
.hero { padding: 32px 0 20px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }
.hero h1 { font-size: clamp(28px, 4.2vw, 42px); margin: 0 0 10px; }
.hero p.lead { margin: 0; color: var(--text-2); font-size: 17px; max-width: 760px; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.badge { font-size: 13px; font-weight: 600; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); padding: 4px 10px; border-radius: 999px; }

/* calculator shell */
.calc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.tabs { display: flex; gap: 4px; padding: 8px; background: var(--surface-2); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { flex: 1 0 auto; border: 0; background: transparent; color: var(--text-2); font: inherit; font-weight: 700; font-size: 14px; padding: 10px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap; }
@media (max-width: 560px) { .tab { flex: 1 1 0; white-space: normal; font-size: 13px; padding: 8px 6px; line-height: 1.25; } }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.panel { display: none; }
.panel.active { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
@media (max-width: 900px) { .panel.active { grid-template-columns: 1fr; } }
.inputs { padding: 22px; border-right: 1px solid var(--border); }
@media (max-width: 900px) { .inputs { border-right: 0; border-bottom: 1px solid var(--border); } }
.results { padding: 22px; background: linear-gradient(180deg, var(--surface) 0%, var(--surface) 100%); min-width: 0; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 340px) { .grid2 { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field label, .field .lbl { font-size: 13px; font-weight: 700; color: var(--text-2); display: flex; justify-content: space-between; gap: 8px; }
.field label .hint { font-weight: 500; color: var(--muted); }
.ctl { position: relative; display: flex; align-items: center; }
.ctl input, .ctl select, select.ctl-sel {
  width: 100%; height: 46px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 10px; font: inherit; font-size: 16px; font-weight: 600; padding: 0 12px; outline: none; appearance: none;
}
.ctl select { padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%236b7486' stroke-width='2'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; cursor: pointer; }
.ctl input:focus, .ctl select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ctl.pre input { padding-left: 26px; }
.ctl.suf input { padding-right: 36px; }
.ctl .pre, .ctl .suf { position: absolute; color: var(--muted); font-weight: 600; pointer-events: none; }
.ctl .pre { left: 12px; }
.ctl .suf { right: 12px; }
input[type="range"] { width: 100%; accent-color: var(--accent); margin: 2px 0 0; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 700; color: var(--text-2); padding: 8px 4px; border-radius: 8px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.seg.terms { grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--text-2); margin: 4px 0 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin-top: 2px; flex: none; }
details.more { border: 1px dashed var(--border); border-radius: 12px; padding: 0 14px; margin-top: 4px; }
details.more summary { cursor: pointer; font-weight: 700; font-size: 14px; padding: 12px 0; color: var(--text-2); }
details.more[open] summary { margin-bottom: 4px; }
.taxline { font-size: 13px; color: var(--muted); margin: -6px 0 14px; }

/* results */
.hero-num { background: var(--accent-soft); border-radius: 14px; padding: 18px 20px; margin-bottom: 16px; }
.hero-num .k { font-size: 13px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.hero-num .v { font-size: clamp(34px, 6vw, 48px); font-weight: 800; line-height: 1.1; margin: 4px 0; color: var(--text); }
.hero-num .v small { font-size: 16px; font-weight: 600; color: var(--text-2); }
.hero-num .sub { font-size: 14px; color: var(--text-2); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.stat { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 18px; font-weight: 800; overflow-wrap: anywhere; }
.warn { background: #fff4e5; color: #7a4a00; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; display: none; }
:root[data-theme="dark"] .warn { background: #3a2a10; color: #ffd28a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .warn { background: #3a2a10; color: #ffd28a; } }
.warn.show { display: block; }

.sec-title { font-size: 14px; font-weight: 800; margin: 18px 0 10px; color: var(--text); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sec-title span { font-weight: 500; color: var(--muted); font-size: 12px; }
.breakdown { display: grid; grid-template-columns: 132px 1fr; gap: 16px; align-items: center; }
@media (max-width: 400px) { .breakdown { grid-template-columns: 1fr; justify-items: center; } }
.legend { list-style: none; margin: 0; padding: 0; width: 100%; }
.legend li { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; font-size: 14px; padding: 5px 0; border-bottom: 1px solid var(--border); color: var(--text-2); }
.legend li:last-child { border-bottom: 0; font-weight: 800; color: var(--text); }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: block; }
.legend b { color: var(--text); font-weight: 700; }

.chart-box { position: relative; }
.chart-box svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-box text { fill: var(--muted); font-size: 11px; }
.tip { position: absolute; pointer-events: none; background: var(--text); color: var(--surface); font-size: 12px; line-height: 1.45; padding: 8px 10px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -110%); opacity: 0; transition: opacity .1s; z-index: 2; }
.tip.on { opacity: 1; }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin-top: 6px; flex-wrap: wrap; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }

.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 700; border-radius: 10px; padding: 9px 14px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

/* tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tr.cur td { background: var(--accent-soft); font-weight: 700; }
.sched { max-height: 420px; overflow: auto; }
.sched-wrap { padding: 0 22px 22px; }
.sched-wrap .sec-title { margin-top: 4px; }
.sched-toggle { display: flex; gap: 8px; }

/* content */
main.content { padding: 28px 0 40px; }
.article { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 32px; }
@media (max-width: 960px) { .article { grid-template-columns: 1fr; } }
.prose { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; min-width: 0; }
@media (max-width: 560px) { .prose { padding: 20px 16px; } }
.prose h2 { font-size: 24px; margin: 36px 0 12px; padding-top: 4px; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 18px; margin: 24px 0 8px; }
.prose p, .prose li { color: var(--text-2); }
.prose strong { color: var(--text); }
.prose table { margin: 8px 0; }
.formula { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; color: var(--text); overflow-x: auto; }
.callout { border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 0 12px 12px 0; padding: 12px 16px; margin: 16px 0; color: var(--text-2); }
.callout.red { border-color: var(--brand); }
.toc { position: sticky; top: 76px; align-self: start; display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.card ul { margin: 0; padding: 0; list-style: none; }
.card li a { display: block; padding: 6px 0; font-size: 14px; color: var(--text-2); text-decoration: none; border-bottom: 1px solid var(--border); }
.card li:last-child a { border-bottom: 0; }
.card li a:hover { color: var(--accent); }
@media (max-width: 960px) { .toc { position: static; } }
.faq details { border: 1px solid var(--border); border-radius: 12px; padding: 0 16px; margin-bottom: 10px; background: var(--surface); }
.faq summary { cursor: pointer; font-weight: 700; padding: 14px 0; color: var(--text); list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.faq summary::after { content: "+"; font-size: 20px; line-height: 1; color: var(--muted); }
.faq details[open] summary::after { content: "–"; }
.faq summary::-webkit-details-marker { display: none; }
.faq details p { margin-top: 0; }
.prov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 12px 0; }
.prov-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; text-decoration: none; color: var(--text); background: var(--surface); display: block; }
.prov-card:hover { border-color: var(--accent); }
.prov-card b { display: block; }
.prov-card span { font-size: 13px; color: var(--muted); }

/* footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 28px 0; font-size: 14px; color: var(--muted); }
.site-footer .cols { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; }
@media (max-width: 700px) { .site-footer .cols { grid-template-columns: 1fr; } }
.site-footer h4 { color: var(--text); margin: 0 0 8px; font-size: 14px; }
.site-footer a { color: var(--text-2); text-decoration: none; display: block; padding: 3px 0; }
.site-footer a:hover { color: var(--accent); }
.site-footer .copy { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; }

@media print {
  .site-header, .tabs, .inputs, .btns, .toc, .site-footer, .prose, .hero .badges { display: none !important; }
  .panel.active { display: block; }
  .calc { box-shadow: none; border: 0; }
  .sched { max-height: none; overflow: visible; }
}

/* hero with illustration */
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: 32px; align-items: center; }
.hero-img img { width: 100%; height: auto; border-radius: 20px; display: block; }
@media (max-width: 900px) { .hero-grid { grid-template-columns: 1fr; } .hero-img { display: none; } }

/* content figures */
figure.fig { margin: 20px 0; }
figure.fig img { width: 100%; height: auto; display: block; border-radius: 14px; border: 1px solid var(--border); background: #fff; }
figure.fig figcaption { font-size: 13px; color: var(--muted); margin-top: 8px; text-align: center; }

/* provinces dropdown */
.dd { position: relative; }
.dd summary { list-style: none; cursor: pointer; color: var(--text-2); font-size: 14px; font-weight: 600; padding: 8px 10px; border-radius: 8px; }
.dd summary::-webkit-details-marker { display: none; }
.dd summary::after { content: " ▾"; font-size: 11px; }
.dd summary:hover { background: var(--surface-2); color: var(--text); }
.dd-menu { position: absolute; right: 0; top: 40px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 170px; display: flex; flex-direction: column; }
.dd-menu a { padding: 8px 10px; }
@media (max-width: 1180px) { .nav a, .dd summary { padding: 8px 7px; font-size: 13px; } }
.nav a, .dd summary { white-space: nowrap; }
@media (max-width: 1100px) {
  .nav { display: none; position: absolute; top: 60px; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); flex-direction: column; align-items: stretch; padding: 8px 16px 16px; }
  .nav.open { display: flex; }
  .nav a, .dd summary { font-size: 15px; padding: 10px; }
  .menu-btn { display: grid; margin-left: auto; }
  .dd-menu { position: static; box-shadow: none; border: 0; padding: 0 0 0 12px; }
}
.card li a[aria-current="page"] { color: var(--accent); font-weight: 700; }
.logo img { width: 30px; height: 30px; flex: none; }
.logo span { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 380px) { .logo { font-size: 15px; } }

/* ---------- mobile refinements ---------- */
.site-header .wrap > .theme-btn { flex: none; }
@media (max-width: 600px) {
  .site-header .wrap { gap: 8px; height: 56px; }
  .nav { top: 56px; }
  .logo { font-size: 15px; gap: 8px; }
  .logo img { width: 26px; height: 26px; }
  .theme-btn { width: 34px; height: 34px; }
  .hero { padding: 20px 0 14px; }
  .hero p.lead { font-size: 16px; }
  .badges { gap: 6px; margin-top: 10px; }
  .badge { font-size: 12px; padding: 3px 9px; }
  .inputs, .results { padding: 16px; }
  .sched-wrap { padding: 0 16px 16px; }
  .field { margin-bottom: 12px; }
  .ctl input, .ctl select, select.ctl-sel { height: 44px; }
  .hero-num { padding: 14px 16px; }
  .stats { gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat .v { font-size: 16px; }
  .seg button { font-size: 12px; padding: 8px 2px; }
  .breakdown { grid-template-columns: 110px 1fr; gap: 12px; }
  .breakdown svg { width: 110px; height: 110px; }
  .legend li { font-size: 13px; }
  th, td { padding: 8px 10px; font-size: 13px; }
  .prose h2 { font-size: 21px; margin-top: 30px; }
  .prose { font-size: 15.5px; }
  .btns .btn { flex: 1 1 auto; justify-content: center; }
  main.content { padding: 20px 0 32px; }
}
@media (max-width: 360px) {
  .logo span { font-size: 13.5px; }
  .tab { font-size: 12px; }
}

/* sticky payment bar (phones/tablets): keeps the result visible while editing inputs */
.mbar { display: none; }
@media (max-width: 900px) {
  .mbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border);
    box-shadow: 0 -6px 20px rgba(0,0,0,.12); transform: translateY(110%); transition: transform .2s ease; }
  .mbar.show { transform: none; }
  .mbar .k { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
  .mbar b { font-size: 20px; font-weight: 800; color: var(--text); }
  .mbar b small { font-size: 13px; font-weight: 600; color: var(--text-2); }
  .mbar .btn { flex: none; padding: 9px 12px; }
}
@media print { .mbar { display: none !important; } }
.glossary { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
.glossary dt { font-weight: 700; color: var(--text); }
.glossary dd { margin: 0; color: var(--text-2); }
@media (max-width: 600px) { .glossary { grid-template-columns: 1fr; gap: 2px; } .glossary dd { margin-bottom: 10px; } }
.prose th, .prose td { white-space: normal; }
.prose td:first-child { min-width: 110px; }
.prose table.txt th, .prose table.txt td { text-align: left; vertical-align: top; }
@media (max-width: 600px) { .prose table.txt td:first-child { min-width: 0; font-weight: 600; } }
