:root {
  --bg: #f5f2ec; --card: #fff; --ink: #1c1a17; --muted: #6b665d; --line: #e4ded3;
  --accent: #23614f; --accent-ink: #fff; --soft: #e5efe9; --up: #17734a; --down: #b8432b; --warn: #8a5a00;
  --r: 14px; --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 4px 16px rgba(40, 30, 10, .05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.9rem; letter-spacing: -.02em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.top { display: flex; align-items: center; gap: 10px; padding: 14px 0; }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.2rem; color: var(--ink); text-decoration: none; letter-spacing: -.02em; }
.logo svg { width: 28px; height: 28px; }
.top .grow { flex: 1; min-width: 0; }
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.up { color: var(--up); }
.down { color: var(--down); }
.center { text-align: center; }
.hidden, [hidden] { display: none !important; }

label { display: block; font-weight: 600; font-size: .9rem; margin: 0 0 6px; }
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=date], input[type=number], input:not([type]), select {
  width: 100%; min-height: 46px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #8cc7b4; outline-offset: 1px; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.row > .shrink { flex: 0 0 auto; width: auto; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 10px 18px; border-radius: 999px; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.soft { background: var(--soft); color: var(--accent); }
.btn.danger { background: transparent; color: var(--down); box-shadow: inset 0 0 0 1.5px #efcdc4; }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: .9rem; }
.btn.block { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow); cursor: pointer; color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }

.hero { padding: 18px 0 8px; }
.hero h1 { font-size: 2.2rem; }
.hero p { font-size: 1.1rem; color: var(--muted); }
.people { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.person { display: flex; gap: 8px; }
.person input { flex: 1; }
.points { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.points li { display: flex; gap: 12px; align-items: flex-start; }
.points b { display: block; }
.dot { flex: 0 0 34px; height: 34px; border-radius: 50%; background: var(--soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; }
.recent a { display: flex; justify-content: space-between; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600; }
.recent a:first-of-type { border-top: 0; }

.title { font-size: 1.15rem; font-weight: 800; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sync { font-size: .8rem; color: var(--muted); }
.sync.off { color: var(--warn); }
.summary { display: flex; align-items: center; gap: 14px; }
.summary .big { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
.summary .grow { flex: 1; min-width: 0; }

.tabs { display: flex; background: #ebe6dc; border-radius: 999px; padding: 4px; margin-bottom: 16px; }
.tabs button { flex: 1; min-height: 40px; border: 0; background: none; border-radius: 999px; font-weight: 700; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected=true] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.list { list-style: none; margin: 0; padding: 0; }
.day { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 4px 6px; }
.day:first-child { margin-top: 0; }
.exp { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; background: var(--card); border: 0; border-radius: 12px; margin-bottom: 6px; text-align: left; cursor: pointer; box-shadow: var(--shadow); }
.exp .ico { flex: 0 0 38px; height: 38px; border-radius: 10px; background: var(--soft); display: grid; place-items: center; font-size: 1.1rem; }
.exp .ico.pay { background: #f1ebde; }
.exp .mid { flex: 1; min-width: 0; }
.exp .t { font-weight: 700; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp .s { font-size: .85rem; color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exp .end { text-align: right; font-size: .85rem; white-space: nowrap; }
.exp .end b { display: block; font-size: 1rem; color: var(--ink); }
.pending { font-size: .75rem; color: var(--warn); }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty .em { font-size: 2rem; display: block; margin-bottom: 4px; }

.bal { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.bal:first-child { border-top: 0; }
.bal .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bal .v { font-weight: 700; text-align: right; }
.bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: #f0ece4; position: relative; overflow: hidden; }
.bar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.bar i.up { left: 50%; background: var(--up); }
.bar i.down { right: 50%; background: var(--down); }
.xfer { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.xfer:first-child { border-top: 0; }
.xfer .who { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.xfer .amt { display: block; font-size: 1.15rem; font-weight: 800; }
.xfer .btn { flex: 0 0 auto; }
.hist li { padding: 8px 0; border-top: 1px solid var(--line); font-size: .92rem; overflow-wrap: anywhere; }
.hist li:first-child { border-top: 0; }
.hist time { display: block; font-size: .78rem; color: var(--muted); }
.mem { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.mem input { flex: 1; }

.fab { white-space: nowrap; position: fixed; left: 50%; transform: translateX(-50%); bottom: max(18px, env(safe-area-inset-bottom)); box-shadow: 0 6px 20px rgba(35, 97, 79, .35); padding: 12px 26px; font-size: 1.05rem; z-index: 5; }
.pad-fab { height: 90px; }

dialog { border: 0; padding: 0; border-radius: 18px; width: min(560px, calc(100vw - 16px)); max-height: calc(100dvh - 16px); background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(28, 26, 23, .45); }
dialog form { padding: 18px; }
.dhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.dhead h2 { margin: 0; }
.close { width: 38px; height: 38px; border-radius: 50%; border: 0; background: #f0ece4; cursor: pointer; font-size: 1.3rem; line-height: 1; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.seg button { flex: 1 1 auto; min-height: 38px; padding: 6px 12px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; font-weight: 600; cursor: pointer; }
.seg button[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: #fff; }
.splitrow { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.splitrow:first-child { border-top: 0; }
.splitrow .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; display: flex; align-items: center; gap: 10px; cursor: pointer; margin: 0; font-size: 1rem; }
.splitrow input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); flex: 0 0 auto; }
.splitrow input.v { width: 96px; flex: 0 0 96px; min-height: 40px; text-align: right; }
.splitrow .sh { flex: 0 0 auto; min-width: 72px; text-align: right; color: var(--muted); font-size: .9rem; }
.tally { font-size: .9rem; font-weight: 600; margin: 8px 0 0; }
.tally.bad { color: var(--down); }
.tally.ok { color: var(--up); }
.ratebox { background: #f7f4ee; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: .92rem; }
.ratebox .row { align-items: center; }
.ratebox input { min-height: 40px; }
.formerr { color: var(--down); font-weight: 600; min-height: 1.5em; margin: 6px 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.actions .btn { flex: 1 1 140px; }
.who-list { display: grid; gap: 8px; }

.toast { position: fixed; left: 50%; bottom: calc(max(18px, env(safe-area-inset-bottom)) + 64px); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .95rem; z-index: 20; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0, 0, 0, .2); }

.prose h2 { margin-top: 1.5em; }
.prose ul, .prose ol { padding-left: 1.25em; }
.prose li { margin-bottom: .4em; }
footer { padding: 24px 0 40px; font-size: .875rem; color: var(--muted); text-align: center; }
footer a { color: var(--muted); }
footer nav { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; margin-bottom: 6px; }

@media (min-width: 700px) {
  .hero h1 { font-size: 2.8rem; }
  dialog form { padding: 24px; }
}
.icon-btn:disabled { opacity: .35; cursor: default; }
.qr-toggle { margin-top: 12px; }
.qr { margin: 12px auto 0; width: min(220px, 70vw); }
.qr svg { display: block; width: 100%; height: auto; border-radius: 10px; box-shadow: inset 0 0 0 1.5px var(--line); }
