:root {
  --bg: #f6f5f1; --surface: #ffffff; --surface-2: #f0efe9; --border: #e3e1d8; --text: #1d2321; --muted: #66706b;
  --accent: #0f6b5c; --accent-2: #12806d; --accent-soft: #e2f1ec; --warn: #b4580b; --warn-soft: #fdf0e1; --bad: #b42318; --bad-soft: #fde8e6; --good: #1a7f37;
  --c1: #0f6b5c; --c2: #3c7dd9; --c3: #d08a1e; --c4: #8e5bd3; --c5: #c0485e; --c6: #6a9a2f; --c7: #5c6670; --c8: #2aa3a3;
  --radius: 12px; --shadow: 0 1px 2px rgba(20,30,25,.06), 0 4px 16px rgba(20,30,25,.05);
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #121614; --surface: #1a1f1d; --surface-2: #222826; --border: #2e3532; --text: #e7ece9; --muted: #98a39e;
  --accent: #3fbfa6; --accent-2: #5fd0b9; --accent-soft: #19332d; --warn: #f0a24b; --warn-soft: #33281a; --bad: #f2867b; --bad-soft: #3a2220; --good: #5cc775;
  --c1: #3fbfa6; --c2: #6ea6f0; --c3: #e8b04f; --c4: #b38df0; --c5: #ec7b90; --c6: #9cc95c; --c7: #9aa5ae; --c8: #4fd0d0;
  --shadow: none; color-scheme: dark;
}}
:root[data-theme="dark"] {
  --bg: #121614; --surface: #1a1f1d; --surface-2: #222826; --border: #2e3532; --text: #e7ece9; --muted: #98a39e;
  --accent: #3fbfa6; --accent-2: #5fd0b9; --accent-soft: #19332d; --warn: #f0a24b; --warn-soft: #33281a; --bad: #f2867b; --bad-soft: #3a2220; --good: #5cc775;
  --c1: #3fbfa6; --c2: #6ea6f0; --c3: #e8b04f; --c4: #b38df0; --c5: #ec7b90; --c6: #9cc95c; --c7: #9aa5ae; --c8: #4fd0d0;
  --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
.num, td.n, .kpi .v { font-variant-numeric: tabular-nums; }

/* Layout */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; letter-spacing: -.01em; white-space: nowrap; }
.brand svg { width: 22px; height: 22px; color: var(--accent); }
.plan-picker { display: flex; align-items: center; gap: 6px; min-width: 0; }
.plan-picker select { max-width: 200px; }
.spacer { flex: 1; }
.status { color: var(--muted); font-size: 12px; white-space: nowrap; }
.status.ok::before { content: "●"; color: var(--good); margin-right: 4px; }
.status.local::before { content: "●"; color: var(--warn); margin-right: 4px; }
.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 53px); }
nav.tabs { position: sticky; top: 53px; align-self: start; padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; height: calc(100vh - 53px); overflow: auto; border-right: 1px solid var(--border); }
nav.tabs button { all: unset; cursor: pointer; padding: 9px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; display: flex; gap: 10px; align-items: center; }
nav.tabs button:hover { background: var(--surface-2); color: var(--text); }
nav.tabs button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
nav.tabs .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 12px 4px; }
nav.tabs .step { width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; background: var(--surface-2); }
nav.tabs button.active .step { background: var(--accent); color: var(--surface); }
main { min-width: 0; padding: 24px clamp(16px, 3vw, 36px) 80px; max-width: 1280px; width: 100%; }
section.tab { display: none; }
section.tab.active { display: block; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; }
.lede { color: var(--muted); margin: 0 0 20px; max-width: 760px; }

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.card > h2:first-child { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Forms */
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
label.f .help { font-weight: 400; font-size: 11px; }
.inp { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.inp:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.inp span { padding: 0 8px; color: var(--muted); font-size: 13px; background: var(--surface-2); align-self: stretch; display: flex; align-items: center; }
input, select { font: inherit; color: var(--text); background: transparent; border: 0; padding: 7px 9px; width: 100%; min-width: 0; outline: none; }
select { cursor: pointer; }
.inp select { padding-right: 4px; }
select.plain, input.plain { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
label.chk { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text); cursor: pointer; }
label.chk input { width: auto; accent-color: var(--accent); }
input[type=range] { padding: 0; accent-color: var(--accent); }
.btn { font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 7px 12px; border-radius: 8px; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--surface); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-2); color: var(--surface); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.icon { padding: 4px 8px; color: var(--muted); border-color: transparent; }
.btn.icon:hover { color: var(--bad); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { all: unset; cursor: pointer; padding: 6px 12px; font-size: 13px; color: var(--muted); }
.seg button.on { background: var(--accent); color: var(--surface); }

/* Tables */
.tbl-wrap { overflow-x: auto; margin: 0 -4px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 6px 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 4px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
td.n, th.n { text-align: right; }
table.edit td { padding: 3px 4px; }
table.edit select { min-width: 96px; }
table.edit input[type=number] { min-width: 52px; }
.fields .wide { grid-column: span 2; }
table.edit .inp { border-color: transparent; background: var(--surface-2); }
table.edit .inp:focus-within { border-color: var(--accent); background: var(--surface); }
table.data td { white-space: nowrap; }
table.data tr.ret td:first-child { box-shadow: inset 3px 0 var(--accent); }
table.data tr.short td { color: var(--bad); }
tfoot td { font-weight: 600; border-bottom: 0; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi .v { font-size: 22px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; }
.kpi .s { font-size: 12px; color: var(--muted); }
.kpi.good .v { color: var(--good); } .kpi.bad .v { color: var(--bad); } .kpi.warn .v { color: var(--warn); }

.chart { position: relative; height: 300px; }
.chart.tall { height: 380px; }
.chart.short { height: 220px; }

.note { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--muted); }
.callout { border-radius: 8px; padding: 10px 12px; font-size: 13px; margin: 8px 0; border: 1px solid transparent; }
.callout.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.callout.bad { background: var(--bad-soft); color: var(--bad); }
.callout.good { background: var(--accent-soft); color: var(--accent); }
ul.facts { margin: 6px 0 0; padding-left: 18px; }
ul.facts li { margin: 4px 0; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.pill.good { background: var(--accent-soft); color: var(--accent); } .pill.bad { background: var(--bad-soft); color: var(--bad); } .pill.warn { background: var(--warn-soft); color: var(--warn); }
.bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.muted { color: var(--muted); }
.big { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.split { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px dashed var(--border); }
.split:last-child { border-bottom: 0; }
.slider-row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; }
.slider-row output { font-weight: 700; font-size: 18px; min-width: 2.5ch; text-align: right; }
.person-tag { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
details summary { cursor: pointer; color: var(--accent); font-weight: 500; margin: 6px 0; }

/* Donate */
[hidden] { display: none !important; }
:root { --donate: #ffdd00; --donate-ink: #1d1a00; --donate-hover: #ffe74d; }
.btn.donate { background: var(--donate); border-color: var(--donate); color: var(--donate-ink); font-weight: 600; text-decoration: none; }
.btn.donate:hover { background: var(--donate-hover); border-color: var(--donate-hover); color: var(--donate-ink); }
a.btn { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.donate-card { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 16px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
@media (max-width: 760px) { .btn.donate span { display: none; } }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(10,15,12,.55); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal[hidden] { display: none; }
#disclaimer { z-index: 110; }
.modal .box { background: var(--surface); border-radius: 14px; max-width: 620px; width: 100%; max-height: 90vh; overflow: auto; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal .box h2 { font-size: 20px; }
.footer-note { color: var(--muted); font-size: 12px; margin-top: 30px; border-top: 1px solid var(--border); padding-top: 12px; }

@media (max-width: 960px) {
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  nav.tabs { position: sticky; top: 53px; z-index: 15; height: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); background: var(--bg); padding: 8px 10px; }
  nav.tabs .grp { display: none; }
  nav.tabs button { white-space: nowrap; padding: 7px 10px; }
  nav.tabs .step { display: none; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .topbar { padding: 8px 12px; flex-wrap: wrap; }
  .status { display: none; }
  main { padding: 16px 16px 60px; }
  .chart { height: 260px; }
}
@media print { nav.tabs, .topbar { display: none; } .layout { display: block; } section.tab { display: block !important; page-break-after: always; } }

/* Intro: animated logo, then sign-in or continue */
.intro { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 24px 16px; overflow: auto;
  background: radial-gradient(120% 90% at 50% 0%, #17836f 0%, #0f6b5c 45%, #0a4a40 100%); color: #fff; transition: opacity .45s ease, visibility .45s; }
.intro.out { opacity: 0; visibility: hidden; pointer-events: none; }
.intro[hidden] { display: none; }
.intro-inner { width: 100%; max-width: 380px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.intro-logo { position: relative; width: 132px; height: 132px; border-radius: 30px; background: rgba(255,255,255,.08);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14), 0 18px 50px rgba(0,0,0,.25); display: grid; place-items: center; animation: i-pop .6s cubic-bezier(.2,.9,.3,1.2) both; }
.intro-logo svg { width: 100px; height: 100px; overflow: visible; }
.intro-logo path { stroke-dasharray: 1 2; stroke-dashoffset: 1; opacity: 0; }
.i-ground { animation: i-draw .5s .25s ease-out forwards; }
.i-climb  { animation: i-draw .75s .6s cubic-bezier(.5,0,.3,1) forwards; }
.i-arrow  { animation: i-draw .35s 1.25s ease-out forwards; }
.intro-lights { position: absolute; left: 22px; right: 22px; bottom: 14px; display: flex; justify-content: space-between; }
.intro-lights i { width: 5px; height: 5px; border-radius: 50%; background: #ffdd00; opacity: 0; animation: i-light 1.6s ease-in-out infinite; }
.intro-lights i:nth-child(2) { animation-delay: .12s } .intro-lights i:nth-child(3) { animation-delay: .24s }
.intro-lights i:nth-child(4) { animation-delay: .36s } .intro-lights i:nth-child(5) { animation-delay: .48s } .intro-lights i:nth-child(6) { animation-delay: .6s }
.intro-word { margin: 22px 0 4px; font-size: 40px; font-weight: 700; letter-spacing: -.02em; animation: i-up .6s 1.35s ease-out both; }
.intro-tag { margin: 0; font-size: 18px; color: rgba(255,255,255,.88); animation: i-up .6s 1.6s ease-out both; }
.intro-by { margin: 14px 0 0; font-size: 12px; letter-spacing: .04em; color: rgba(255,255,255,.62); animation: i-up .6s 1.85s ease-out both; }
.intro-by b { color: rgba(255,255,255,.9); font-weight: 600; }
.intro-actions { margin-top: 30px; width: 100%; animation: i-up .5s ease-out both; }
.intro-actions[hidden] { display: none; }
.intro-btn { all: unset; box-sizing: border-box; cursor: pointer; display: block; width: 100%; padding: 13px 18px; border-radius: 12px; background: #fff; color: #0a4a40;
  font-weight: 700; font-size: 15px; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,.2); transition: transform .15s, box-shadow .15s; }
.intro-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(0,0,0,.25); }
.intro-btn:focus-visible, .intro-link:focus-visible { outline: 2px solid #ffdd00; outline-offset: 3px; }
.intro-note { margin: 10px 0 18px; font-size: 12px; color: rgba(255,255,255,.7); }
.intro-link { all: unset; cursor: pointer; font-size: 14px; color: #fff; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(255,255,255,.4); }
.intro-link span { font-weight: 400; color: rgba(255,255,255,.7); }
.intro-msg { margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: rgba(0,0,0,.22); font-size: 13px; text-align: left; }
.intro.fast *, .intro.fast { animation-duration: .01s !important; animation-delay: 0s !important; }
.intro.fast .intro-lights i { animation: none; opacity: .8; }
.intro.fast .intro-logo path { opacity: 1; stroke-dashoffset: 0; }
@keyframes i-draw { from { stroke-dashoffset: 1; opacity: 1; } to { stroke-dashoffset: 0; opacity: 1; } }
@keyframes i-pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes i-up { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes i-light { 0%, 100% { opacity: .15; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .intro *, .intro { animation-duration: .01s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition: none !important; }
  .intro-lights i { opacity: .8; }
}
.intro-link[hidden] { display: none; }

/* Children */
.kid { border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin: 0 0 14px; background: var(--surface); }
.kid-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.kid h4 { margin: 16px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.kid h4 .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.post-q { border-radius: 10px; }
.post-q.ask { outline: 2px solid var(--warn); outline-offset: 6px; }
#lockTop.warnbtn { border-color: var(--warn); color: var(--warn); }
@media (max-width: 760px) { #lockTop .lbl { display: none; } }
nav.tabs .nav-settings { margin-top: auto; border-top: 1px solid var(--border); border-radius: 0 0 8px 8px; padding-top: 12px; }
nav.tabs .nav-settings .step { background: transparent; font-size: 14px; }
@media (max-width: 760px) { nav.tabs .nav-settings { margin-top: 0; border-top: 0; border-radius: 8px; padding-top: 7px; } }

/* PDF report (printed via the browser's Save as PDF) */
#report { display: none; }
@media print {
  html:has(body.print-report), body.print-report { background: #fff !important; color: #111; }
  body.print-report > *:not(#report) { display: none !important; }
  body.print-report #report { display: block; font: 11pt/1.45 var(--font); color: #111; }
  #report header { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid #0f6b5c; padding-bottom: 6px; }
  #report .brand { font-weight: 700; font-size: 16pt; color: #0f6b5c; }
  #report .muted { color: #666; font-size: 9pt; }
  #report h1 { font-size: 20pt; margin: 14px 0 2px; }
  #report h2 { font-size: 13pt; margin: 18px 0 6px; color: #0f6b5c; break-after: avoid; }
  #report h2.pb { break-before: page; }
  #report .rkpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
  #report .rk { border: 1px solid #ddd; border-radius: 8px; padding: 8px 10px; break-inside: avoid; }
  #report .rk .l { font-size: 8.5pt; color: #666; } #report .rk .v { font-size: 15pt; font-weight: 700; } #report .rk .s { font-size: 8pt; color: #888; }
  #report img { width: 100%; height: auto; break-inside: avoid; }
  #report table { width: 100%; border-collapse: collapse; font-size: 8.5pt; }
  #report th, #report td { padding: 3px 5px; border-bottom: 1px solid #e5e5e5; text-align: left; }
  #report td.n, #report th.n { text-align: right; font-variant-numeric: tabular-nums; }
  #report tr.hl td { background: #e2f1ec; font-weight: 600; }
  #report table.plain td { border: 0; padding: 2px 8px 2px 0; }
  #report .disc { margin-top: 18px; font-size: 8pt; color: #777; border-top: 1px solid #ddd; padding-top: 6px; }
  @page { margin: 14mm; }
}
