/* CanadaMortgageCalc.com: same family look as javascriptconverter.com (light surface, blue accent, flat buttons). */
:root {
  --bg: #f8fafd;
  --fg: #1f1f1f;
  --muted: #444746;
  --subtle: #5f6368;
  --border: #dde2ea;
  --border-strong: #c4c7c5;
  --panel: #ffffff;
  --surface: #f0f4f9;
  --surface-hover: #e8eaed;
  --accent: #0b57d0;
  --accent-hover: #0842a0;
  --accent-soft: #d3e3fd;
  --accent-tint: rgba(11, 87, 208, .07);
  --red: #c5221f;
  --green: #137333;
  --green-soft: #e6f4ea;
  --amber: #8a6100;
  --amber-soft: #fef7e0;
  --red-soft: #fce8e6;
  --interest: #f29900;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(60, 64, 67, .06), 0 2px 8px rgba(60, 64, 67, .06);
  --wrap: 1240px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--fg); line-height: 1.6;
  font-family: "Google Sans", "Segoe UI", Roboto, system-ui, -apple-system, Arial, sans-serif; font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
img, svg { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: #fff; padding: 6px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Header ---------- */
.site-header { background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 24px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: var(--fg); white-space: nowrap; }
.brand:hover { text-decoration: none; color: var(--fg); }
.brand b { color: var(--accent); font-weight: 700; }
.brand svg { width: 26px; height: 26px; flex: none; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a { color: var(--muted); font-size: .92rem; font-weight: 500; padding: 8px 12px; border-radius: 999px; }
.nav a:hover { background: var(--surface); color: var(--fg); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-tint); }
.nav .cta { background: var(--accent); color: #fff; margin-left: 8px; padding: 8px 16px; }
.nav .cta:hover { background: var(--accent-hover); color: #fff; }
.menu-btn { display: none; background: none; border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px; font: inherit; color: var(--fg); cursor: pointer; }

/* Announcement bar: shows the site is maintained */
.notice { background: var(--surface); border-bottom: 1px solid var(--border); font-size: .88rem; color: var(--muted); }
.notice .wrap { display: flex; align-items: center; gap: 10px; min-height: 40px; padding-top: 6px; padding-bottom: 6px; }
.notice .dot { width: 8px; height: 8px; border-radius: 50%; background: #1e8e3e; box-shadow: 0 0 0 4px rgba(30, 142, 62, .15); flex: none; animation: pulse 2.4s infinite; }
.notice a { font-weight: 600; white-space: nowrap; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(30, 142, 62, .05); } }
@media (prefers-reduced-motion: reduce) { .notice .dot { animation: none; } html { scroll-behavior: auto; } }

/* ---------- Hero ---------- */
.hero { padding: 48px 0 28px; }
.hero.small { padding: 36px 0 18px; }
.pill { display: inline-flex; align-items: center; gap: 8px; background: var(--accent-tint); color: var(--accent); border: 1px solid rgba(11, 87, 208, .18);
  font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; padding: 5px 12px; border-radius: 999px; }
.pill.green { background: var(--green-soft); color: var(--green); border-color: rgba(19, 115, 51, .2); }
h1 { font-size: clamp(2rem, 4.2vw, 3.2rem); line-height: 1.12; letter-spacing: -.02em; margin: 16px 0 14px; font-weight: 700; }
h1 em, h2 em { font-style: normal; color: var(--accent); }
.lead { font-size: 1.12rem; color: var(--muted); max-width: 760px; margin: 0; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 18px; color: var(--subtle); font-size: .88rem; }
.meta-row span { display: inline-flex; align-items: center; gap: 6px; }
.meta-row svg { width: 16px; height: 16px; color: var(--green); }
.crumbs { font-size: .85rem; color: var(--subtle); margin-bottom: 4px; }
.crumbs a { color: var(--subtle); }
.crumbs span { margin: 0 6px; }

/* ---------- Calculator layout ---------- */
.calc { display: grid; grid-template-columns: minmax(0, 400px) minmax(0, 1fr); gap: 24px; align-items: start; margin-bottom: 40px; }
.calc > * { min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 22px; }
.form-card { position: sticky; top: 84px; }
.form-card h2 { font-size: 1rem; margin: 0 0 14px; display: flex; justify-content: space-between; align-items: center; }
.form-card h2 button { font: inherit; font-size: .82rem; font-weight: 500; color: var(--accent); background: none; border: 0; cursor: pointer; padding: 0; }
.fields { display: grid; gap: 14px; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.field label, .field .lbl { display: block; font-size: .84rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field small, .hint { display: block; font-size: .78rem; color: var(--subtle); margin-top: 5px; line-height: 1.4; }
.input { position: relative; display: flex; align-items: center; }
.input input, .field select {
  width: 100%; height: 46px; border: 1px solid var(--border-strong); border-radius: 12px; background: #fff; color: var(--fg);
  font: inherit; font-size: 1rem; padding: 0 14px; font-variant-numeric: tabular-nums; transition: border-color .15s, box-shadow .15s;
}
.input input:hover, .field select:hover { border-color: var(--subtle); }
.input input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input .pre, .input .suf { position: absolute; color: var(--subtle); font-size: .95rem; pointer-events: none; }
.input .pre { left: 14px; }
.input .suf { right: 14px; }
.input.has-pre input { padding-left: 28px; }
.input.has-suf input { padding-right: 34px; }
.field select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235f6368' stroke-width='1.6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.field.err input { border-color: var(--red); }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 8px 0 0; }
.seg { display: flex; background: var(--surface); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; border: 0; background: none; font: inherit; font-size: .85rem; font-weight: 600; color: var(--muted); padding: 8px 6px; border-radius: 9px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--accent); box-shadow: var(--shadow); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; color: var(--fg); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check small { display: block; color: var(--subtle); font-size: .78rem; }
details.more { border-top: 1px solid var(--border); padding-top: 12px; }
details.more summary { cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--accent); list-style: none; display: flex; align-items: center; gap: 6px; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "+"; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--accent-tint); font-size: .95rem; }
details.more[open] summary::before { content: "−"; }
details.more .fields { margin-top: 14px; }
.msg { font-size: .88rem; border-radius: 12px; padding: 10px 14px; margin: 0; }
.msg.error { background: var(--red-soft); color: var(--red); }
.msg.info { background: var(--surface); color: var(--muted); }
.msg:empty { display: none; }

/* ---------- Results ---------- */
.results { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; min-width: 0; }
.results > *, .tabpanel, .panel-body { min-width: 0; }
.headline { padding: 26px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center; }
.headline .label { color: var(--muted); font-size: .92rem; font-weight: 500; }
.big { font-size: clamp(2.4rem, 5vw, 3.4rem); font-weight: 700; letter-spacing: -.02em; line-height: 1.1; color: var(--fg); margin: 4px 0; font-variant-numeric: tabular-nums; }
.big small { font-size: 1rem; font-weight: 500; color: var(--subtle); letter-spacing: 0; }
.headline .sub { color: var(--subtle); font-size: .9rem; }
.donut { width: 132px; height: 132px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .82rem; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--border); }
.stats > div { padding: 16px 20px; border-right: 1px solid var(--border); min-width: 0; }
.stats > div:last-child { border-right: 0; }
.stats dt { font-size: .78rem; color: var(--subtle); font-weight: 500; }
.stats dd { margin: 4px 0 0; font-size: 1.12rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: #fff; color: var(--fg); border-radius: 999px; padding: 8px 16px; font: inherit; font-size: .88rem; font-weight: 500; cursor: pointer; }
.btn:hover { background: var(--surface); text-decoration: none; color: var(--fg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); color: #fff; }
.btn svg { width: 16px; height: 16px; }
.status { font-size: .85rem; color: var(--green); align-self: center; }

.panel h3 { margin: 0; font-size: 1.08rem; }
.panel .desc { margin: 4px 0 16px; color: var(--muted); font-size: .9rem; }
.panel-head { padding: 20px 22px 0; }
.panel-body { padding: 0 22px 22px; }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0; margin: 0; }
.kv dt, .kv dd { padding: 9px 0; border-bottom: 1px solid #eef0f4; margin: 0; }
.kv dt { color: var(--muted); font-size: .93rem; }
.kv dd { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; padding-left: 16px; }
.kv .neg { color: var(--green); }
.kv .total { border-bottom: 0; border-top: 2px solid var(--fg); font-weight: 700; color: var(--fg); font-size: 1.02rem; }
.badge { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: .76rem; font-weight: 600; margin-left: 8px; vertical-align: 1px; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.no { background: var(--red-soft); color: var(--red); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.meter { height: 10px; background: var(--surface); border-radius: 99px; position: relative; overflow: hidden; margin: 6px 0 2px; }
.meter span { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--accent); }
.meter.over span { background: var(--red); }
.meter i { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--fg); opacity: .5; }
.ratio { margin-bottom: 14px; }
.ratio-top { display: flex; justify-content: space-between; font-size: .9rem; }
.ratio-top b { font-variant-numeric: tabular-nums; }
.callout { background: var(--accent-tint); border-radius: 14px; padding: 16px 18px; margin-top: 14px; }
.callout .big { font-size: 2rem; margin: 2px 0; }
.callout p { margin: 0; color: var(--muted); font-size: .88rem; }

/* Tabs */
.tabs { display: flex; gap: 4px; padding: 6px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { border: 0; background: none; font: inherit; font-size: .9rem; font-weight: 600; color: var(--muted); padding: 9px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap; }
.tabs button:hover { background: var(--surface); }
.tabs button[aria-selected="true"] { background: var(--accent-tint); color: var(--accent); }
.tabpanel { padding: 20px 22px 22px; }
.tabpanel[hidden] { display: none; }
.tabpanel > .desc:first-child { margin-top: 0; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: .9rem; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid #eef0f4; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { background: var(--surface); font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfd; }
tr.sel td { background: var(--accent-tint) !important; font-weight: 600; }
tr.term-end td { border-bottom: 2px dashed var(--accent-soft); }
.scroll-y { max-height: 480px; overflow-y: auto; }
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: inherit; }

.quote { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 24px; align-items: center; padding: 26px 28px; margin: -16px 0 40px; background: linear-gradient(135deg, #fff 55%, var(--accent-tint)); }
.quote h2 { margin: 10px 0 6px; font-size: 1.35rem; }
.quote p { margin: 0; color: var(--muted); max-width: 640px; }
.big-btn { padding: 13px 24px; font-size: 1rem; font-weight: 600; }
@media (max-width: 760px) { .quote { grid-template-columns: minmax(0, 1fr); padding: 20px 16px; } }

/* ---------- Content ---------- */
.section { padding: 48px 0; }
.section.alt { background: var(--panel); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); letter-spacing: -.01em; margin: 0 0 8px; line-height: 1.2; }
.section .intro { color: var(--muted); margin: 0 0 28px; max-width: 720px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.tile { display: block; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; color: var(--fg); transition: border-color .15s, box-shadow .15s, transform .15s; }
.tile:hover { text-decoration: none; color: var(--fg); border-color: var(--accent); box-shadow: 0 4px 16px rgba(11, 87, 208, .1); transform: translateY(-2px); }
.tile .ico { width: 40px; height: 40px; border-radius: 12px; background: var(--accent-tint); color: var(--accent); display: grid; place-items: center; margin-bottom: 12px; }
.tile .ico svg { width: 22px; height: 22px; }
.tile h3 { margin: 0 0 4px; font-size: 1.02rem; }
.tile p { margin: 0; color: var(--muted); font-size: .9rem; }
.tile .tag { display: inline-block; font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); margin-bottom: 6px; }
.tile .date { font-size: .8rem; color: var(--subtle); margin-top: 10px; display: block; }

.prose { max-width: 760px; font-size: 1.04rem; }
.prose h2 { font-size: 1.5rem; margin: 2.2em 0 .6em; line-height: 1.25; letter-spacing: -.01em; }
.prose h3 { font-size: 1.15rem; margin: 1.8em 0 .5em; }
.prose p, .prose ul, .prose ol { margin: 0 0 1.1em; }
.prose li { margin: .3em 0; }
.prose table { margin: 1.2em 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: block; overflow-x: auto; }
.prose table th, .prose table td { white-space: normal; }
.prose blockquote, .prose .note { margin: 1.4em 0; padding: 14px 18px; background: var(--accent-tint); border-left: 4px solid var(--accent); border-radius: 0 12px 12px 0; color: var(--muted); }
.prose .formula { font-family: ui-monospace, Consolas, monospace; background: var(--surface); padding: 12px 16px; border-radius: 10px; overflow-x: auto; font-size: .92rem; }
.prose code { background: var(--surface); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.article-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 48px; align-items: start; }
.aside { position: sticky; top: 84px; display: grid; gap: 16px; }
.aside .card { padding: 18px; }
.aside h4 { margin: 0 0 10px; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--subtle); }
.aside ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: .92rem; }
.byline { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--subtle); font-size: .88rem; margin-top: 14px; }

.faq { max-width: 860px; }
.faq details { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 10px; }
.faq summary { cursor: pointer; padding: 16px 20px; font-weight: 600; list-style: none; display: flex; justify-content: space-between; gap: 16px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--accent); font-size: 1.3rem; line-height: 1; flex: none; }
.faq details[open] summary::after { content: "−"; }
.faq details > div { padding: 0 20px 16px; color: var(--muted); }
.faq details > div p { margin: 0 0 .7em; }

.sources { font-size: .88rem; color: var(--muted); }
.sources ul { padding-left: 18px; margin: 8px 0 0; columns: 2; column-gap: 32px; }
.sources li { break-inside: avoid; margin-bottom: 4px; }
.checked { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--green); background: var(--green-soft); border-radius: 999px; padding: 3px 10px; font-weight: 600; }

/* Updates timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; max-width: 820px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: 0 0 28px 36px; }
.timeline li::before { content: ""; position: absolute; left: 0; top: 6px; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); }
.timeline time { font-size: .82rem; font-weight: 600; color: var(--accent); }
.timeline h3 { margin: 2px 0 6px; font-size: 1.08rem; }
.timeline p { margin: 0; color: var(--muted); }
.timeline .kind { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; border-radius: 6px; padding: 2px 7px; margin-left: 8px; background: var(--surface); color: var(--muted); vertical-align: 2px; }
.timeline .kind.rule { background: var(--amber-soft); color: var(--amber); }
.timeline .kind.new { background: var(--green-soft); color: var(--green); }
.mini-updates { display: grid; gap: 0; }
.mini-updates a { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); color: var(--fg); }
.mini-updates a:hover { text-decoration: none; color: var(--accent); }
.mini-updates time { color: var(--subtle); font-size: .88rem; font-variant-numeric: tabular-nums; }

.rules-table td, .rules-table th { white-space: normal; text-align: left; vertical-align: top; }
.rules-table td:last-child { white-space: nowrap; }

/* ---------- Footer ---------- */
.site-footer { background: var(--panel); border-top: 1px solid var(--border); margin-top: 48px; padding: 40px 0 28px; font-size: .9rem; color: var(--muted); }
.foot-grid { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 32px; }
.site-footer h4 { margin: 0 0 10px; color: var(--fg); font-size: .9rem; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent); }
.disclaimer { border-top: 1px solid var(--border); margin-top: 28px; padding-top: 18px; font-size: .8rem; color: var(--subtle); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .menu-btn { display: block; }
  .nav { display: none; position: absolute; top: 64px; left: 0; right: 0; background: #fff; border-bottom: 1px solid var(--border); flex-direction: column; align-items: stretch; padding: 8px 16px 16px; box-shadow: var(--shadow); }
  .nav.open { display: flex; }
  .nav a { padding: 12px; }
  .nav .cta { margin: 8px 0 0; text-align: center; }
}
@media (max-width: 980px) {
  .calc { grid-template-columns: minmax(0, 1fr); }
  .form-card { position: static; }
  .article-layout { grid-template-columns: minmax(0, 1fr); }
  .aside { position: static; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .hero { padding: 28px 0 18px; }
  .headline { grid-template-columns: minmax(0, 1fr); padding: 20px; }
  .donut { width: 110px; height: 110px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats > div:nth-child(2) { border-right: 0; }
  .stats > div:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .card-pad, .tabpanel, .panel-body { padding-left: 16px; padding-right: 16px; }
  .panel-head { padding: 16px 16px 0; }
  .sources ul { columns: 1; }
  .foot-grid { grid-template-columns: 1fr; }
  .mini-updates a { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  th, td { padding: 8px 9px; font-size: .84rem; }
  .notice .hide-sm { display: none; }
}
@media print {
  .site-header, .notice, .site-footer, .form-card, .actions, .tabs, .no-print { display: none !important; }
  .calc { grid-template-columns: 1fr; }
  .tabpanel[hidden] { display: block; }
  body { background: #fff; }
}
