:root {
  --accent: #17664f; --accent2: #2f4f9e; --ok: #1e6b3a; --late: #b3261e; --warnc: #8a4b00;
  --bg: #f4f6f3; --card: #ffffff; --text: #18201c; --muted: #5e6a64; --line: #dde3df; --soft: #e7f1ec;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --accent: #5cc6a3; --accent2: #9db4ff; --ok: #7fd49a; --late: #ffb4ab; --warnc: #ffc078;
    --bg: #111513; --card: #1b211e; --text: #edf2ef; --muted: #a2ada7; --line: #2f3833; --soft: #1f3129; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.45 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent2); }
h1 { font-size: 1.45rem; margin: 6px 0 12px; }
h2 { font-size: .95rem; margin: 0 0 8px; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 6px 0; }
.muted { color: var(--muted); } .small { font-size: .86rem; } .center { text-align: center; }
.warn { color: var(--warnc); }
.danger { color: var(--late) !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { font-size: 1.15rem; }
.hb { flex: 0 0 auto; background: var(--card); color: var(--accent); border: 1px solid var(--line); border-radius: 20px; padding: 6px 14px; font-weight: 600; min-height: 36px; }
main { padding: 12px 16px calc(96px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { background: none; border: 0; padding: 8px 0 6px; font-size: .72rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 52px; }
.tabs button span { font-size: 1.3rem; line-height: 1; }
.tabs button.on { color: var(--accent); font-weight: 700; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin: 0 0 12px; display: block; width: 100%; }
.btn, button.btn { display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 12px; padding: 10px 16px; font-weight: 600; text-decoration: none; text-align: center; min-height: 44px; }
@media (prefers-color-scheme: dark) { .btn, button.btn { color: #06231a; } }
.btn.big { display: block; width: 100%; padding: 14px; font-size: 1.05rem; }
.btn.light { background: #fff; color: var(--accent); }
.ghost, button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; min-height: 40px; }
button.ghost.small { padding: 4px 10px; font-size: .8rem; min-height: 32px; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); min-height: 44px; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[disabled] { opacity: .55; }
.form label { display: block; margin-bottom: 10px; font-size: .86rem; color: var(--muted); }
.form label input, .form label select { margin-top: 4px; color: var(--text); font-size: 1rem; }
.form .help { margin: -6px 0 12px; }
.form label.dim { opacity: .6; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-size: .86rem; color: var(--muted); margin-bottom: 4px; }
.check { display: flex !important; align-items: center; gap: 10px; padding: 6px 0; color: var(--text) !important; font-size: .95rem !important; }
.check input { width: 22px; height: 22px; min-height: 0; flex-shrink: 0; accent-color: var(--accent); margin: 0; }
[hidden] { display: none !important; }

.hero { background: linear-gradient(135deg, #17664f, #2f4f9e); color: #fff; border-radius: 18px; padding: 16px; margin-bottom: 12px; border: 0; }
.hero h1, .hero-h { color: #fff; text-transform: none; letter-spacing: 0; font-size: 1.2rem; margin: 4px 0 6px; }
.hero-k { color: rgba(255,255,255,.85); font-size: .9rem; }
.hero .big { font-size: 2.6rem; font-weight: 800; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.hero p { color: rgba(255,255,255,.92); }
.amount { font-size: 1.8rem; font-weight: 800; margin: 4px 0 8px; font-variant-numeric: tabular-nums; }
.alert { border: 2px solid var(--late); }
.next { border-left: 6px solid var(--accent); }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.kv:last-child { border-bottom: 0; }
.kv > span:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kv .l { flex: 1 1 auto; min-width: 0; }
.kv.sub { padding-left: 14px; font-size: .9rem; color: var(--muted); }
.kv.strong .l { font-weight: 600; }
.kv.total { border-top: 2px solid var(--line); }
.kv.pick { background: var(--soft); margin: 0 -8px; padding: 7px 8px; border-radius: 10px; }
.kv s { text-decoration-thickness: 1px; }

details.card > summary { list-style: none; display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary h2 { margin: 0; }
details.card > summary h2::after { content: " ▾"; }
details[open].card > summary { margin-bottom: 8px; }

.chip { display: inline-block; font-size: .78rem; font-weight: 700; border-radius: 20px; padding: 2px 10px; border: 1px solid var(--line); white-space: nowrap; }
.chip.ok, .chip.paid { background: var(--soft); color: var(--ok); border-color: transparent; }
.chip.late { background: var(--late); color: #fff; border-color: transparent; }
@media (prefers-color-scheme: dark) { .chip.late { color: #3b0907; } }
.chip.next { background: var(--accent); color: #fff; border-color: transparent; }
@media (prefers-color-scheme: dark) { .chip.next { color: #06231a; } }
.chip.none { color: var(--muted); }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; color: var(--warnc); border: 1px solid currentColor; border-radius: 6px; padding: 0 6px; text-transform: uppercase; letter-spacing: .03em; }

.quarter .qhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; font-size: 1.05rem; }
.quarter.late { border-color: var(--late); }
.quarter.paid { opacity: .85; }
.quarter .btn { margin-top: 8px; }
.item { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.acts { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; flex-shrink: 0; text-align: right; }
.paylink { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; margin: 8px 0; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--text); background: var(--bg); }
.paylink b { color: var(--accent2); }
.chipsrow { display: flex; gap: 8px; flex-wrap: wrap; }
.chipsrow button { border: 1px solid var(--line); background: var(--card); border-radius: 20px; padding: 8px 16px; min-height: 40px; }
.chipsrow button.on { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
@media (prefers-color-scheme: dark) { .chipsrow button.on { color: #06231a; } }
.live { font-weight: 700; color: var(--accent); margin: 4px 0 8px; min-height: 1.2em; }
.sticky { position: sticky; bottom: calc(60px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(8px); padding: 8px 0; margin: 0 0 12px; }
.note { background: var(--soft); border-radius: 12px; padding: 10px 12px; font-size: .9rem; }
.foot { margin-top: 18px; text-align: center; }
.src { padding-left: 18px; word-break: break-all; }
.nw { white-space: nowrap; }
.foot a { color: inherit; }

.tblwrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 10px 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { text-align: left; padding: 6px 6px 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.tbl td.conf { word-break: break-all; }
.report h1 { margin-top: 14px; }

/* pay links and the annualized income method */
.paylink.primary { border: 2px solid var(--accent); background: var(--soft); }
.paylink.primary b { color: var(--accent); }
.quarter .row { margin-top: 8px; }
.quarter .row .btn { margin-top: 0; }
.ai { border-left: 6px solid var(--accent2); }
.ai .tbl td:nth-child(n+2), .ai .tbl th:nth-child(n+2) { text-align: right; padding-right: 0; padding-left: 8px; }
.ai .tbl tr.hl td { background: var(--soft); }
.ok-line { color: var(--ok); margin: 8px 0; }
.kv > span.wrap { white-space: normal; }
#ai .live { font-weight: 600; }
#ai .live button { margin-left: 4px; }

@media (max-width: 380px) { .grid2 { grid-template-columns: 1fr; } .hero .big { font-size: 2.2rem; } }

@media print {
  :root { --bg: #fff; --card: #fff; --text: #000; --muted: #444; --line: #bbb; --accent: #000; }
  html, body { background: #fff; color: #000; font-size: 10.5pt; }
  .top, .tabs, .noprint { display: none !important; }
  main { padding: 0; max-width: none; }
  .tblwrap { overflow: visible; }
  .tbl { font-size: 9.5pt; }
  .tbl tr { break-inside: avoid; page-break-inside: avoid; }
  a { color: #000; text-decoration: none; }
}

/* Appearance overrides are opt-in. Default System / Green / Plain / Normal adds no overrides. */
.photo-label { display: block; margin: 10px 0; }
.photo-label input { display: block; margin-top: 6px; }
[data-appearance] { text-align: start; }
html[data-text-size="small"], html[data-text-size="small"] body { font-size: 15px; }
html[data-text-size="large"], html[data-text-size="large"] body { font-size: 20px; }
html[data-background] body { background-image: var(--appearance-image, none); background-size: var(--appearance-size, 48px 48px); background-repeat: var(--appearance-repeat, repeat); background-attachment: fixed; min-height: 100vh; }
/* Even unwrapped headings, help text and reports have an opaque surface over every decorative background. */
html[data-background] main { background: var(--card); width: calc(100% - 24px); padding-inline: 8px; margin-top: 12px; border-radius: 16px; }
html[data-background] .top { background: var(--card); }
html[data-appearance="light"] .btn, html[data-appearance="light"] button.btn,
html[data-appearance="light"] .chip.next, html[data-appearance="light"] .chipsrow button.on { color: #fff; }
html[data-appearance="dark"] .btn, html[data-appearance="dark"] button.btn,
html[data-appearance="dark"] .chip.next, html[data-appearance="dark"] .chipsrow button.on { color: #06231a; }
html[data-appearance] .btn.light { background: var(--card); color: var(--accent); }
html[data-appearance] .btn.ghost { color: var(--accent); }
html[data-appearance="light"] .chip.late { color: #fff; }
html[data-appearance="dark"] .chip.late { color: #3b0907; }
@media print {
  html[data-background] body { background-image: none !important; }
  html[data-background] main { width: 100%; padding: 0; margin-top: 0; border-radius: 0; }
  html[data-appearance] { --bg: #fff !important; --card: #fff !important; --text: #000 !important; --muted: #444 !important; --accent: #000 !important; --line: #bbb !important; }
  html[data-text-size], html[data-text-size] body { font-size: 10.5pt; }
}
