:root {
  --sage: #4F7A63; --sage-dark: #3B5E4B; --sage-soft: #E7EFEA;
  --terra: #C8643F; --terra-dark: #A44E2F; --terra-soft: #F7E6DE;
  --cream: #FBF7F2; --card: #FFFFFF; --ink: #1F2A24; --muted: #5C6660; --line: #E3DED6;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink); background: var(--cream);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; padding-bottom: calc(76px + env(safe-area-inset-bottom)); line-height: 1.45; font-size: 16px; }
[hidden] { display: none !important; }
.band { padding: 8px 16px; font-size: 14px; text-align: center; }
.band.demo { background: var(--terra-soft); color: var(--terra-dark); font-weight: 600; }
.band.warn { background: #FFF1C9; color: #5B4300; font-weight: 600; position: sticky; top: 0; z-index: 5; }
.top { display: flex; align-items: center; gap: 10px; padding: 14px 16px 6px; max-width: 760px; margin: 0 auto; padding-top: calc(14px + env(safe-area-inset-top)); }
.logo { border-radius: 8px; }
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font-size: 18px; }
.brand span { font-size: 12px; color: var(--muted); }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tabs button { flex: 1; border: 0; background: none; padding: 14px 4px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--sage-dark); box-shadow: inset 0 3px 0 var(--sage); }
@media (min-width: 760px) {
  body { padding-bottom: 32px; }
  .tabs { position: static; max-width: 760px; margin: 6px auto 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
}
main { max-width: 760px; margin: 0 auto; padding: 8px 16px 24px; }
h2 { font-size: 17px; margin: 26px 0 8px; }
h2:first-child { margin-top: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 10px 0; }
.hero { background: var(--sage); color: #fff; border: 0; }
.hero .label { font-size: 14px; opacity: .92; }
.hero .big { font-size: 42px; font-weight: 700; letter-spacing: -0.5px; margin: 2px 0; font-variant-numeric: tabular-nums; }
.hero .sub { font-size: 15px; }
.hero .math { font-size: 13px; opacity: .9; margin-top: 10px; border-top: 1px solid rgba(255,255,255,.25); padding-top: 8px; }
.hero.short { background: var(--terra-dark); }
.msg { font-size: 15px; color: var(--sage-dark); background: var(--sage-soft); border-radius: 10px; padding: 10px 12px; margin: 8px 0; }
.msg.soft-warn { color: #5B4300; background: #FFF6DB; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .name { font-weight: 600; overflow-wrap: anywhere; }
.amt { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.neg { color: var(--terra-dark); }
form.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 12px; }
form.grid > * { min-width: 0; }
/* labels of different lengths: keep the fields of one row on the same line */
form.grid > label { justify-content: flex-end; }
form.grid .full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; font-size: 13px; font-weight: 600; color: var(--muted); gap: 4px; }
input, select { font: inherit; font-size: 16px; color: var(--ink); padding: 10px 11px; border: 1px solid #CFC8BD; border-radius: 10px; background: #fff; width: 100%; min-height: 44px; }
/* iPhone Safari: date fields keep their own width, height and centred text unless reset */
input[type="date"] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; height: 46px; line-height: 1.2; text-align: left; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
input:not([type="date"]), select { height: 46px; }
input:focus, select:focus, button:focus-visible { outline: 3px solid rgba(79,122,99,.35); outline-offset: 1px; border-color: var(--sage); }
.btn { font: inherit; font-weight: 600; border: 0; border-radius: 10px; padding: 11px 16px; cursor: pointer; min-height: 44px; background: var(--sage); color: #fff; }
.btn:hover { background: var(--sage-dark); }
.btn.ghost { background: transparent; color: var(--sage-dark); border: 1px solid var(--sage); }
.btn.danger { background: var(--terra-dark); }
.btn.link { background: none; color: var(--sage-dark); padding: 6px 8px; min-height: 36px; text-decoration: underline; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.icon-btn { border: 0; background: none; color: var(--muted); font: inherit; font-size: 13px; padding: 8px; cursor: pointer; text-decoration: underline; min-height: 36px; }
.bar { height: 8px; border-radius: 6px; background: var(--sage-soft); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--sage); }
.bar.over > i { background: var(--terra); }
.monthnav { display: flex; align-items: center; justify-content: space-between; }
.monthnav strong { font-size: 18px; }
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.totals div { background: var(--sage-soft); border-radius: 10px; padding: 8px 4px; }
.totals b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.totals span { font-size: 12px; color: var(--muted); }
details.card > summary { cursor: pointer; font-weight: 700; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "Show"; float: right; font-weight: 600; font-size: 13px; color: var(--sage-dark); text-decoration: underline; }
details.card[open] > summary::after { content: "Hide"; }
details.card[open] > summary { margin-bottom: 12px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); background: var(--ink); color: #fff;
  padding: 10px 14px; border-radius: 10px; display: flex; gap: 12px; align-items: center; z-index: 20; max-width: calc(100% - 32px); font-size: 15px; }
.toast button { background: none; border: 0; color: #BFE3CF; font: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; }
.confirm { border: 2px solid var(--terra); }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--sage-soft); color: var(--sage-dark); font-weight: 600; }
.pill.paid { background: #EEE; color: var(--muted); }
.err { color: var(--terra-dark); font-size: 14px; font-weight: 600; }
.mt6 { margin-top: 6px; } .mt12 { margin-top: 12px; } .m0 { margin: 0; } .w160 { max-width: 160px; }
.list li.block { display: block; } .row.between { justify-content: space-between; }
.btn.file-btn { flex-direction: row; display: inline-flex; align-items: center; color: var(--sage-dark); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
