/* Interest Calculator Canada — styles */
:root {
  color-scheme: light;
  --bg: #f4f7f4;
  --surface: #ffffff;
  --surface-2: #eef3ef;
  --border: #dde5df;
  --text: #102018;
  --text-2: #3f5248;
  --muted: #66786e;
  --brand: #0b6e4f;
  --brand-2: #0a8f66;
  --brand-ink: #08533b;
  --mint: #e3f3eb;
  --gold: #c98a00;
  --gold-soft: #fff4d6;
  --danger-bg: #fff1ec;
  --danger-ink: #8a2d0c;
  --shadow: 0 1px 2px rgba(16, 32, 24, .05), 0 12px 32px rgba(16, 32, 24, .08);
  --radius: 20px;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --grid: #e3e8e4;
  --panel-a: #0b6e4f;
  --panel-b: #064533;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1411; --surface: #141d19; --surface-2: #1b2621; --border: #2a3832;
    --text: #ecf3ef; --text-2: #c2d0c8; --muted: #93a59b;
    --brand: #3fc492; --brand-2: #4fd6a3; --brand-ink: #7fe3bd; --mint: #17302a; --gold: #f0b429; --gold-soft: #3a2f12;
    --danger-bg: #3a1f14; --danger-ink: #ffb79a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.3);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --grid: #26332d;
    --panel-a: #0d5a42; --panel-b: #07382a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1411; --surface: #141d19; --surface-2: #1b2621; --border: #2a3832;
  --text: #ecf3ef; --text-2: #c2d0c8; --muted: #93a59b;
  --brand: #3fc492; --brand-2: #4fd6a3; --brand-ink: #7fe3bd; --mint: #17302a; --gold: #f0b429; --gold-soft: #3a2f12;
  --danger-bg: #3a1f14; --danger-ink: #ffb79a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px rgba(0,0,0,.3);
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --grid: #26332d;
  --panel-a: #0d5a42; --panel-b: #07382a;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.65 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; font-feature-settings: "tnum" 1; }
a { color: var(--brand); }
img, svg { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.015em; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* ---------- header ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.site-header .wrap { display: flex; align-items: center; gap: 12px; height: 64px; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; font-size: 17px; white-space: nowrap; min-width: 0; }
.logo img { width: 34px; height: 34px; flex: none; }
.logo span { overflow: hidden; text-overflow: ellipsis; }
.logo em { font-style: normal; color: var(--brand); }
.nav { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.nav > a, .dd > summary { color: var(--text-2); text-decoration: none; font-size: 14px; font-weight: 700; padding: 8px 12px; border-radius: 999px; white-space: nowrap; cursor: pointer; list-style: none; }
.nav > a:hover, .dd > summary:hover, .nav a[aria-current="page"] { background: var(--mint); color: var(--brand-ink); }
.dd { position: relative; }
.dd > summary::-webkit-details-marker { display: none; }
.dd > summary::after { content: " ▾"; font-size: 11px; }
.dd-menu { position: absolute; right: 0; top: 44px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; min-width: 250px; display: flex; flex-direction: column; }
.dd-menu a { color: var(--text-2); text-decoration: none; font-size: 14px; font-weight: 600; padding: 9px 12px; border-radius: 10px; }
.dd-menu a:hover, .dd-menu a[aria-current="page"] { background: var(--mint); color: var(--brand-ink); }
.icon-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 12px; width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer; flex: none; font-size: 16px; }
.menu-btn { display: none; }
@media (max-width: 1040px) {
  .menu-btn { display: grid; margin-left: auto; }
  .nav { display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; align-items: stretch; background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 16px 16px; max-height: calc(100vh - 64px); overflow: auto; }
  .nav.open { display: flex; }
  .dd-menu { position: static; box-shadow: none; border: 0; padding: 0 0 0 12px; min-width: 0; }
  .nav > a, .dd > summary { font-size: 15px; padding: 11px 12px; border-radius: 10px; }
}

/* ---------- hero band ---------- */
.band { background: radial-gradient(1200px 400px at 85% -10%, rgba(240, 180, 41, .28), transparent 60%), linear-gradient(135deg, #0b6e4f 0%, #075a41 55%, #054231 100%); color: #fff; padding: 34px 0 118px; }
.band-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); gap: 28px; align-items: center; }
.band-img img { width: 100%; height: auto; display: block; filter: drop-shadow(0 18px 30px rgba(0,0,0,.25)); }
@media (max-width: 900px) { .band-grid { grid-template-columns: 1fr; } .band-img { display: none; } .band { padding-bottom: 96px; } }
.crumbs { font-size: 13px; opacity: .85; margin-bottom: 10px; }
.crumbs a { color: #fff; }
.band h1 { font-size: clamp(30px, 4.6vw, 48px); margin: 0 0 12px; font-weight: 800; }
.band p.lead { margin: 0; font-size: 17px; opacity: .93; max-width: 700px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip { font-size: 13px; font-weight: 700; padding: 5px 12px; border-radius: 999px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25); }

/* ---------- calculator shell ---------- */
.calculator { margin-top: -84px; position: relative; z-index: 2; }
.calc-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.pills { display: flex; gap: 6px; padding: 12px; border-bottom: 1px solid var(--border); overflow-x: auto; background: var(--surface); }
.pill { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font: inherit; font-size: 14px; font-weight: 700; padding: 9px 16px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.pill[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.pane { display: none; }
.pane.active { display: block; }
.pane-main { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); }
@media (max-width: 900px) { .pane-main { grid-template-columns: 1fr; } }
.form { padding: 24px; }
.result { padding: 24px; background: linear-gradient(160deg, var(--panel-a), var(--panel-b)); color: #fff; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 600px) { .form, .result { padding: 18px 16px; } }

/* field: label + value box on one row, slider below */
.row { margin-bottom: 18px; }
.row-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.row-top label, .row-top .lbl { font-size: 14px; font-weight: 700; color: var(--text-2); }
.row-top .help { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.val { display: flex; align-items: center; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); height: 42px; padding: 0 10px; min-width: 0; width: 150px; flex: none; }
.val:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--mint); background: var(--surface); }
.val span { color: var(--muted); font-weight: 700; font-size: 14px; }
.val input { border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-weight: 800; font-size: 16px; width: 100%; min-width: 0; text-align: right; padding: 0 4px; }
.val.wide { width: 100%; }
input[type="range"] { width: 100%; accent-color: var(--brand); margin: 4px 0 0; height: 22px; }
select.sel { width: 100%; height: 44px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--text); font: inherit; font-weight: 700; font-size: 15px; padding: 0 36px 0 12px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%2366786e' stroke-width='2'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.opts { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 4px; }
.opts.wrap3 { grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); }
.opts button { border: 0; background: transparent; color: var(--text-2); font: inherit; font-size: 13px; font-weight: 700; padding: 8px 4px; border-radius: 9px; cursor: pointer; line-height: 1.25; }
.opts button[aria-pressed="true"] { background: var(--surface); color: var(--brand-ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 340px) { .two { grid-template-columns: 1fr; } }
.two .val { width: 100%; }
.tick { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--text-2); margin: 0 0 12px; cursor: pointer; }
.tick input { width: 18px; height: 18px; accent-color: var(--brand); margin-top: 2px; flex: none; }
.note { font-size: 13px; color: var(--muted); margin: -6px 0 14px; }
details.adv { border: 1px dashed var(--border); border-radius: 14px; padding: 0 14px; }
details.adv summary { cursor: pointer; font-weight: 700; font-size: 14px; color: var(--text-2); padding: 12px 0; }

/* result panel */
.big .k { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .85; }
.big .v { font-size: clamp(34px, 6vw, 50px); font-weight: 800; line-height: 1.08; margin: 4px 0 2px; }
.big .v small { font-size: 16px; font-weight: 600; opacity: .85; }
.big .s { font-size: 14px; opacity: .88; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kv div { background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.14); border-radius: 14px; padding: 10px 12px; min-width: 0; }
.kv span { display: block; font-size: 12px; opacity: .8; font-weight: 600; }
.kv b { font-size: 18px; font-weight: 800; overflow-wrap: anywhere; }
.flag { background: var(--gold-soft); color: #5a3d00; border-radius: 12px; padding: 10px 12px; font-size: 14px; display: none; }
:root[data-theme="dark"] .flag { color: #ffe3a3; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .flag { color: #ffe3a3; } }
.flag.show { display: block; }
.donut-row { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: center; }
.donut-row svg { width: 120px; height: 120px; }
.lg { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.lg li { display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,.14); }
.lg li:last-child { border-bottom: 0; }
.lg i { width: 12px; height: 12px; border-radius: 3px; display: block; border: 1px solid rgba(255,255,255,.5); }
.result .btn { background: #fff; color: var(--panel-b); border-color: #fff; }

/* insights (charts + tables under the calculator) */
.insights { padding: 22px 24px 26px; border-top: 1px solid var(--border); }
@media (max-width: 600px) { .insights { padding: 18px 16px; } }
.ins-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); gap: 24px; }
@media (max-width: 900px) { .ins-grid { grid-template-columns: 1fr; } }
.h4 { font-size: 15px; font-weight: 800; margin: 0 0 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.h4 span { font-size: 12px; font-weight: 600; color: var(--muted); }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart 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: 3; }
.tip.on { opacity: 1; }
.keys { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.keys span { display: inline-flex; gap: 6px; align-items: center; }
.keys i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 700; border-radius: 12px; padding: 9px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { filter: brightness(.97); }
.btn.go { background: var(--brand); border-color: var(--brand); color: #fff; }

/* tables */
.tw { overflow-x: auto; border: 1px solid var(--border); border-radius: 14px; }
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.hl td { background: var(--mint); font-weight: 800; }
.scroll { max-height: 400px; overflow: auto; }
@media (max-width: 600px) { th, td { padding: 8px 9px; font-size: 13px; } }

/* ---------- article ---------- */
main.content { padding: 34px 0 44px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 30px; }
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } }
.article { min-width: 0; }
.article section.block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px 28px; margin-bottom: 18px; }
@media (max-width: 600px) { .article section.block { padding: 20px 16px; } }
.article h2 { font-size: clamp(21px, 2.6vw, 26px); margin: 0 0 12px; }
.article h3 { font-size: 18px; margin: 22px 0 8px; }
.article p, .article li { color: var(--text-2); }
.article strong { color: var(--text); }
.article .tw table th, .article .tw table td { white-space: normal; }
.article table.txt th, .article table.txt td { text-align: left; vertical-align: top; }
.formula { background: var(--mint); border-radius: 14px; padding: 14px 16px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; color: var(--text); overflow-x: auto; }
.callout { background: var(--gold-soft); border-radius: 14px; padding: 14px 16px; margin: 16px 0; color: var(--text-2); }
figure.fig { margin: 18px 0; }
figure.fig img { width: 100%; height: auto; display: block; border-radius: 16px; border: 1px solid var(--border); background: #fff; }
figure.fig figcaption { font-size: 13px; color: var(--muted); text-align: center; margin-top: 8px; }
.steps { counter-reset: s; list-style: none; padding: 0; }
.steps li { counter-increment: s; position: relative; padding-left: 44px; margin-bottom: 12px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 14px; }
.faq details { border: 1px solid var(--border); border-radius: 14px; 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::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 20px; line-height: 1; color: var(--brand); }
.faq details[open] summary::after { content: "–"; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tile { display: block; border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; text-decoration: none; color: var(--text); background: var(--surface); }
.tile:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--mint); }
.tile b { display: block; }
.tile span { font-size: 13px; color: var(--muted); }
.side { position: sticky; top: 80px; align-self: start; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 980px) { .side { position: static; } }
.side .box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.side h3 { margin: 0 0 8px; font-size: 15px; }
.side ul { list-style: none; margin: 0; padding: 0; }
.side li a { display: block; padding: 6px 0; font-size: 14px; color: var(--text-2); text-decoration: none; border-bottom: 1px solid var(--border); }
.side li:last-child a { border-bottom: 0; }
.side li a:hover, .side li a[aria-current="page"] { color: var(--brand); font-weight: 700; }
dl.gloss { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
dl.gloss dt { font-weight: 800; color: var(--text); }
dl.gloss dd { margin: 0; color: var(--text-2); }
@media (max-width: 600px) { dl.gloss { grid-template-columns: 1fr; gap: 2px; } dl.gloss dd { margin-bottom: 10px; } }

/* sticky mobile result bar */
.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(--panel-b); color: #fff; box-shadow: 0 -6px 20px rgba(0,0,0,.18);
    transform: translateY(110%); transition: transform .2s ease; }
  .mbar.show { transform: none; }
  .mbar .k { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; opacity: .8; }
  .mbar b { font-size: 20px; font-weight: 800; }
  .mbar .btn { background: #fff; color: var(--panel-b); border-color: #fff; flex: none; }
}

/* footer */
.site-footer { background: #062e22; color: #b9cdc3; padding: 34px 0 24px; font-size: 14px; }
.site-footer .cols { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 24px; }
@media (max-width: 860px) { .site-footer .cols { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .site-footer .cols { grid-template-columns: 1fr; } }
.site-footer h4 { color: #fff; margin: 0 0 8px; font-size: 14px; }
.site-footer a { color: #b9cdc3; text-decoration: none; display: block; padding: 3px 0; }
.site-footer a:hover { color: #fff; }
.site-footer .logo { color: #fff; }
.site-footer .logo em { color: #f0b429; }
.site-footer .copy { border-top: 1px solid rgba(255,255,255,.12); margin-top: 22px; padding-top: 16px; font-size: 13px; }

@media print {
  .site-header, .pills, .form, .btns, .side, .site-footer, .article, .mbar, .band .chips { display: none !important; }
  .pane.active { display: block; }
  .band { padding: 10px 0; background: none; color: #000; }
  .calculator { margin-top: 0; }
  .scroll { max-height: none; }
}

/* keep grid children from growing wider than the screen on phones */
.pane-main > *, .ins-grid > *, .layout > * { min-width: 0; }
@media (max-width: 900px) { .pane-main, .ins-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 980px) { .layout { grid-template-columns: minmax(0, 1fr); } }
/* paired fields: label above the value box */
.two .row-top { flex-direction: column; align-items: stretch; gap: 6px; }
@media (max-width: 420px) {
  .val { width: 132px; }
  .row-top label, .row-top .lbl { font-size: 13.5px; }
  .opts button { font-size: 12px; }
  .logo { font-size: 15px; }
  .logo img { width: 30px; height: 30px; }
}
.lg li span { font-weight: 800; }
@media (max-width: 600px) { .chart text { font-size: 19px; } }
