/* salsbury.uk tools (loan and savings calculators): same family as the Income & Bills Planner */
:root {
  --bg: #FBF5EA; --bg2: #F4EBDC; --card: #FFFFFF; --ink: #1E2A24; --muted: #5F6A64; --line: #EADFCB;
  --brand: #23664E; --brand-ink: #FFFFFF; --brand-soft: #E2F1E8; --sun: #F5A623;
  --s1: #2C6FCC; --s2: #D9731F; /* capital / interest — validated pair (CVD-safe) */
  --shadow: 0 1px 2px rgba(60, 40, 10, .06), 0 6px 20px rgba(60, 40, 10, .06);
  --head: 'Fraunces', Georgia, serif; --body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111C17; --bg2: #16241E; --card: #1A2A23; --ink: #F2EDE3; --muted: #A9B3AD; --line: #2A3C33;
    --brand: #6FD3A2; --brand-ink: #0E2219; --brand-soft: #1E3A2E; --s1: #4A88DB; --s2: #D27A2A;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--body); }
h1, h2, h3 { font-family: var(--head); font-weight: 650; line-height: 1.15; margin: 0; }
a { color: var(--brand); }
.top { display: flex; align-items: center; gap: 10px; padding: calc(12px + env(safe-area-inset-top)) 16px 8px; max-width: 1100px; margin: 0 auto; }
.top .home { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 700; }
.top .home .mk { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); font-family: var(--head); font-weight: 700; }
.top .grow { flex: 1; }
.top .gh-tools { display: flex; gap: 8px; align-items: center; }
/* the shared menus use these */
.top { --gh-line: var(--line); --gh-panel: var(--card); --gh-text: var(--ink); --gh-muted: var(--muted); --gh-accent: var(--brand); --gh-bg: var(--bg2); --gh-body: var(--body); }
main { max-width: 1100px; margin: 0 auto; padding: 6px 16px 48px; }
.intro { margin: 12px 0 18px; }
.intro h1 { font-size: clamp(30px, 6vw, 44px); }
.intro p { color: var(--muted); max-width: 60ch; margin: 8px 0 0; }
.layout { display: grid; gap: 16px; }
@media (min-width: 900px) { .layout { grid-template-columns: 360px minmax(0, 1fr); align-items: start; } .form { position: sticky; top: 12px; } }
.card { background: var(--card); border-radius: 20px; box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 20px; margin-bottom: 4px; }
label.f { display: block; margin-top: 14px; }
label.f > span { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.in { width: 100%; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); border-radius: 12px; padding: 12px 14px; font: inherit; font-size: 16px; outline: none; font-variant-numeric: tabular-nums; }
.in:focus { border-color: var(--brand); }
.pre { position: relative; } .pre::before { content: attr(data-pre); position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; } .pre .in { padding-left: 30px; }
.post { position: relative; } .post::after { content: attr(data-post); position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; } .post .in { padding-right: 70px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.seg { display: inline-flex; background: var(--bg2); border-radius: 999px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 7px 13px; border-radius: 999px; font: 700 14px/1 var(--body); color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
details.more { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 10px; }
details.more summary { cursor: pointer; font-weight: 700; color: var(--brand); }
.hero { background: var(--brand); color: var(--brand-ink); border-radius: 22px; padding: 20px; }
.hero .lab { font-weight: 700; opacity: .85; font-size: 14px; }
.hero .big { font-family: var(--head); font-size: clamp(38px, 8vw, 54px); font-weight: 700; line-height: 1.05; margin: 4px 0; font-variant-numeric: tabular-nums; }
.hero .sub { opacity: .92; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.kpi { background: var(--bg2); border-radius: 14px; padding: 12px 14px; }
.kpi .l { font-size: 13px; font-weight: 700; color: var(--muted); }
.kpi .v { font-size: 21px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 12.5px; color: var(--muted); }
.kpi i.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: 0; }
.split { display: flex; height: 16px; border-radius: 99px; overflow: hidden; margin: 14px 0 6px; gap: 2px; background: var(--card); }
.split i { display: block; height: 100%; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; }
.chart { position: relative; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .tt { position: absolute; top: 0; pointer-events: none; background: var(--ink); color: var(--bg); font-size: 13px; padding: 7px 10px; border-radius: 10px; transform: translateX(-50%); white-space: nowrap; box-shadow: var(--shadow); line-height: 1.4; }
.chart .tt i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
tr.yr { cursor: pointer; } tr.yr td:first-child::before { content: '▸ '; color: var(--muted); } tr.yr.open td:first-child::before { content: '▾ '; }
tr.mo td { color: var(--muted); font-size: 13px; background: var(--bg2); }
.tw { overflow-x: auto; }
.btn { appearance: none; border: 0; border-radius: 999px; padding: 10px 16px; font: 700 14.5px/1.2 var(--body); cursor: pointer; background: var(--bg2); color: var(--ink); }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.note { font-size: 13.5px; color: var(--muted); margin-top: 12px; }
.tip { display: flex; gap: 10px; font-size: 14px; color: var(--muted); padding: 12px 14px; border-radius: 14px; border: 1.5px dashed var(--line); margin-top: 16px; }
.good { color: #2F9E5C; font-weight: 800; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .good { color: #6FD3A2; } }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.show { opacity: 1; }
footer { max-width: 1100px; margin: 0 auto; padding: 0 16px 32px; color: var(--muted); font-size: 13px; }

/* Keep intrinsic input and table widths inside the responsive grid. */
html{-webkit-text-size-adjust:100%}
.layout{grid-template-columns:minmax(0,1fr)}
.layout>*,.row2>*,.kpis>*,.tip>*{min-width:0}
.card,.hero,.chart,.tw,.pre,.post{min-width:0;max-width:100%}
.row2{grid-template-columns:repeat(2,minmax(0,1fr))}
.in{min-width:0;max-width:100%}
.tw{width:100%;overscroll-behavior-x:contain}
.card p,.hero,.tip,.kpi{overflow-wrap:anywhere}
.chart .tt{max-width:100%;white-space:normal}
.top{flex-wrap:wrap}
.top .home{min-width:0}
.top .gh-tools{flex-wrap:wrap}
.hero .big{overflow-wrap:anywhere}
@media(min-width:900px){.layout{grid-template-columns:360px minmax(0,1fr)}}
@media(max-width:400px){.card{padding:14px}.hero{padding:16px}.kpis{grid-template-columns:minmax(0,1fr)}.top{gap:6px}.top .home{gap:6px}}
