/* Frontwater Capital brand: navy + bronze on warm cream (matches www.frontwater.ca),
   series colours from the Frontwater report palette. */
:root {
  --navy: #0E2747;
  --bronze: #B08D57;
  --bg: #FAF7F2;
  --surface: #ffffff;
  --surface-2: #F4EDE0;
  --border: #d0cdc8;
  --text: #1c1b18;
  --muted: #6a6860;
  --accent: #0E2747;
  --accent-soft: #e6ebf2;
  --on-accent: #ffffff;
  --good: #1a6e45;
  --good-soft: #e8f5ee;
  --warn: #7a5100;
  --warn-soft: #fbf1dc;
  --bad: #9e2a1c;
  --bad-soft: #fdf0ee;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(14, 39, 71, .05), 0 1px 3px rgba(14, 39, 71, .09);
  --grid: #ebe6dd;
  --s1: #1a4fa0; --s2: #B08D57; --s3: #0f6058; --s4: #5c3b9e;
  --s5: #4cad7a; --s6: #7a9cc6; --s7: #0E2747; --s8: #b5614a;
  --serif: 'Cormorant Garamond', 'Palatino Linotype', Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1626; --surface: #112037; --surface-2: #182a45; --border: #2b3d5a;
    --text: #ecebe6; --muted: #a4abb8; --accent: #d4b07a; --accent-soft: #2b2619; --on-accent: #0b1626;
    --good: #5fc592; --good-soft: #15291f; --warn: #e8b64a; --warn-soft: #2a2413;
    --bad: #ef7f6b; --bad-soft: #2e1a18; --shadow: 0 1px 3px rgba(0, 0, 0, .45);
    --grid: #1f3150;
    --s1: #5b8fdc; --s2: #d4b07a; --s3: #3aa597; --s4: #9c82d6;
    --s5: #6fcf9a; --s6: #a9c3e6; --s7: #e8e2d4; --s8: #de8b72;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1626; --surface: #112037; --surface-2: #182a45; --border: #2b3d5a;
  --text: #ecebe6; --muted: #a4abb8; --accent: #d4b07a; --accent-soft: #2b2619; --on-accent: #0b1626;
  --good: #5fc592; --good-soft: #15291f; --warn: #e8b64a; --warn-soft: #2a2413;
  --bad: #ef7f6b; --bad-soft: #2e1a18; --shadow: 0 1px 3px rgba(0, 0, 0, .45);
  --grid: #1f3150;
  --s1: #5b8fdc; --s2: #d4b07a; --s3: #3aa597; --s4: #9c82d6;
  --s5: #6fcf9a; --s6: #a9c3e6; --s7: #e8e2d4; --s8: #de8b72;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.25; }
h1, h2 { font-family: var(--serif); font-weight: 600; letter-spacing: .005em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: .95rem; margin-top: 1.2em; }
a { color: var(--accent); }
.num, td, .kpi-value { font-variant-numeric: tabular-nums; }

/* ── header */
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.bar { border-bottom: 2px solid var(--bronze); }
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
.swan { height: 36px; width: auto; }
.wordmark { display: flex; flex-direction: column; line-height: 1.15; font-family: Georgia, 'Times New Roman', serif; }
.wm-name { font-size: .95rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--navy); }
.wm-tag { font-size: .55rem; letter-spacing: .32em; text-transform: uppercase; color: var(--muted); }
.flag { height: 12px; width: auto; border-radius: 2px; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
:root[data-theme="dark"] .swan { filter: brightness(0) invert(1); }
:root[data-theme="dark"] .wm-name { color: #fff; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .swan { filter: brightness(0) invert(1); }
  :root:not([data-theme="light"]) .wm-name { color: #fff; }
}
.titlebar { background: var(--navy); color: #fff; padding: 22px 20px 20px; }
.titlebar h1 { margin: 0; color: #fff; }
.titlebar .sub { color: rgba(255,255,255,.72); margin-top: 2px; }
.titlebar h1::after { content: ""; display: block; width: 48px; height: 2px; background: var(--bronze); margin: 8px 0 6px; }
.sub { margin: 0; color: var(--muted); font-size: .9rem; }
.bar-right { display: flex; gap: 6px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font: inherit; font-size: .9rem; padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); text-decoration: none; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; font-size: .82rem; }
.btn-x { border: none; background: transparent; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: 4px 8px; }
.btn-x:hover { color: var(--bad); }

/* ── live strip */
.live {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  background: var(--surface); border-bottom: 1px solid var(--border); overflow: hidden;
}
.live > div { padding: 10px 20px; border-right: 1px solid var(--border); margin-bottom: -1px; border-bottom: 1px solid var(--border); }
.live .lbl { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.live .val { font-size: 1.15rem; font-weight: 600; }
.live .val.good { color: var(--good); }
.live .val.bad { color: var(--bad); }

/* ── stepper */
.steps {
  display: flex; gap: 4px; padding: 10px 20px 0; overflow-x: auto;
  border-bottom: 1px solid var(--border); background: var(--surface);
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.step {
  flex: none; border: none; background: none; cursor: pointer; font: inherit; font-size: .9rem;
  padding: 8px 12px 10px; color: var(--muted); border-bottom: 3px solid transparent;
}
.step:hover { color: var(--text); }
.step.is-active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.step .n {
  display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 6px;
  border-radius: 50%; background: var(--surface-2); font-size: .75rem;
}
.step.is-active .n { background: var(--accent); color: var(--on-accent); }
.step.is-active { border-bottom-color: var(--bronze); }

main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 40px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
.lead { color: var(--muted); margin: 0 0 16px; }

/* ── questions */
.q { margin: 0 0 18px; }
.q > .q-label { display: block; font-weight: 600; margin-bottom: 6px; }
.q .hint { display: block; color: var(--muted); font-size: .82rem; margin-top: 4px; }
.choices { display: flex; gap: 10px; flex-wrap: wrap; }
.choice {
  flex: 1 1 200px; text-align: left; cursor: pointer; font: inherit;
  padding: 14px 16px; border-radius: var(--radius); border: 2px solid var(--border);
  background: var(--surface); color: var(--text);
}
.choice strong { display: block; }
.choice span { color: var(--muted); font-size: .85rem; }
.choice.is-on { border-color: var(--accent); background: var(--accent-soft); }

.grid { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.people { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.person h3 { margin-top: 0; }
.f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.f > span { font-size: .85rem; color: var(--muted); }
.f small { color: var(--muted); font-size: .78rem; }
input[type=number], input[type=text], select {
  font: inherit; font-size: .95rem; padding: 7px 10px; width: 100%;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.money { position: relative; }
.money::before { content: "$"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.money input { padding-left: 22px; }
.pctw { position: relative; }
.pctw::after { content: "%"; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.pctw input { padding-right: 26px; }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }

/* accounts */
.acct {
  display: grid; gap: 10px 12px; align-items: end;
  grid-template-columns: 1.3fr 1fr 1fr 1fr 1fr 1fr auto;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.acct:last-child { border-bottom: none; }
.acct .extra { grid-column: 1 / -1; display: flex; gap: 12px; flex-wrap: wrap; }
.acct .extra .f { width: 180px; }
@media (max-width: 860px) { .acct { grid-template-columns: 1fr 1fr; } }
.addbar { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; background: var(--surface-2); color: var(--muted); }

.goal { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 10px; align-items: end; margin-bottom: 8px; }

.nav { display: flex; justify-content: space-between; margin-top: 8px; }

/* ── results */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi-label { font-size: .8rem; color: var(--muted); }
.kpi-value { font-size: 1.5rem; font-weight: 650; margin: 2px 0; }
.kpi-note { font-size: .8rem; color: var(--muted); }

.objectives { list-style: none; margin: 0; padding: 0; }
.objectives li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.objectives li:last-child { border-bottom: none; }
.badge { flex: none; font-size: .78rem; font-weight: 600; padding: 2px 8px; border-radius: 6px; height: fit-content; }
.badge.ok { background: var(--good-soft); color: var(--good); }
.badge.no { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: none; background: var(--surface); color: var(--muted); font: inherit; font-size: .85rem; padding: 6px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.is-on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 12px; overflow-x: auto; }
.tab { flex: none; border: none; background: none; font: inherit; padding: 8px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tab.is-on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.tablewrap { overflow: auto; max-height: 70vh; border: 1px solid var(--border); border-radius: 8px; }
table.data { border-collapse: separate; border-spacing: 0; font-size: .82rem; width: max-content; min-width: 100%; }
table.data th, table.data td { padding: 5px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--grid); }
table.data thead th { position: sticky; top: 0; background: var(--surface-2); z-index: 2; font-weight: 600; vertical-align: bottom; }
table.data th:first-child, table.data td:first-child { position: sticky; left: 0; background: var(--surface); text-align: left; z-index: 1; }
table.data thead th:first-child { z-index: 3; background: var(--surface-2); }
table.data td.sub, table.data th.sub { color: var(--muted); }
table.data tr.total td { font-weight: 650; border-top: 2px solid var(--border); }
table.data tr.retire td { border-top: 2px solid var(--accent); }
table.data td.neg { color: var(--bad); }
table.data tr.section td { background: var(--surface-2); font-weight: 600; text-align: left; }
table.data td.grp { border-left: 1px solid var(--border); }

/* charts */
.charts { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
@media (max-width: 520px) { .charts { grid-template-columns: 1fr; } }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .gridline { stroke: var(--grid); }
.chart .baseline { stroke: var(--border); }
.chart .cross { stroke: var(--muted); stroke-dasharray: 3 3; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .8rem; color: var(--muted); margin: 6px 0 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 180px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  padding: 8px 10px; font-size: .8rem;
}
.tip b { display: block; margin-bottom: 4px; }
.tip div { display: flex; justify-content: space-between; gap: 12px; }
.tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.tip .tot { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; font-weight: 600; }

.foot { max-width: 1180px; margin: 0 auto; padding: 0 16px 30px; color: var(--muted); font-size: .8rem; }
.foot-cta { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--bronze);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 14px; color: var(--text); font-size: .9rem; }
.foot-cta strong { display: block; font-family: var(--serif); font-size: 1.2rem; font-weight: 600; }
.foot-cta span { color: var(--muted); }
.foot-links a { color: var(--muted); }

@media (max-width: 600px) {
  .bar, .steps, .titlebar { padding-left: 16px; padding-right: 16px; }
  .titlebar h1 { font-size: 1.55rem; }
  .live > div { padding: 8px 16px; }
  .card { padding: 16px; }
  .goal { grid-template-columns: 1fr 1fr; }
}

@media print {
  .bar-right, .steps, .nav, .toolbar .seg, .addbar, .btn, .foot-cta { display: none !important; }
  .titlebar { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tablewrap { max-height: none; overflow: visible; }
  body { background: #fff; }
}

/* contribution recommendations */
.compare { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 14px; }
.compare > div { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.compare small { font-size: .8rem; font-weight: 400; color: var(--muted); }
.delta { font-weight: 600; color: var(--muted); }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
table.advice td { vertical-align: top; }
table.advice td:nth-child(2) { text-align: left; }
table.advice td.why { text-align: left; white-space: normal; min-width: 280px; max-width: 420px; color: var(--muted); }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; max-width: 420px; }
.progress > div { height: 100%; background: var(--accent); transition: width .15s; }
.seg button:disabled { opacity: .5; cursor: default; }
@media (prefers-reduced-motion: reduce) { .progress > div { transition: none; } }

/* cottage and estate */
.facts { display: grid; gap: 10px 20px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: 0 0 16px; }
.facts div { border-bottom: 1px solid var(--grid); padding-bottom: 6px; }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.recommend { background: var(--accent-soft); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.recommend p { margin: 0 0 8px; max-width: 75ch; }
.recommend .btn { margin-top: 4px; }
table.advice tr.best td { background: var(--good-soft); }
table.advice td .badge { margin-left: 6px; }

/* what-if analysis */
.chart .reflabel { fill: var(--muted); font-size: 11px; }
.chart .rowlabel { fill: var(--text); font-size: 12px; }
.chart .barlabel { fill: var(--text); font-size: 11px; font-variant-numeric: tabular-nums; }
#sensitivity .toolbar .f { flex: 1 1 220px; }

/* business owners edition */
.titlebar .edition { font-style: italic; font-weight: 500; color: var(--bronze); }
#advisorBtn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }

/* one-time expenses: how they are paid */
.goal .goal-pay { grid-column: 1 / -1; display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); align-items: end; padding-bottom: 8px; border-bottom: 1px solid var(--grid); }
.f strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }

/* annual budget */
table.budget { width: 100%; }
table.budget td:first-child { white-space: normal; min-width: 180px; }
table.budget th { text-align: right; }
