:root {
  --bg: #f6f7f6; --card: #ffffff; --ink: #18211f; --muted: #5f6b68; --line: #dfe4e2;
  --accent: #0f766e; --accent-ink: #ffffff; --bad: #b42318; --warn: #b54708; --bar: #d5ebe8;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1413; --card: #18201e; --ink: #e8eeec; --muted: #9aa8a4; --line: #2a3431;
    --accent: #2dd4bf; --accent-ink: #062b27; --bad: #f97066; --warn: #fdb022; --bar: #1f3b37;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, sans-serif; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top { display: flex; align-items: center; justify-content: space-between; padding: calc(12px + env(safe-area-inset-top)) 16px 8px; }
.top h1 { font-size: 20px; margin: 0; }
.status { font-size: 13px; color: var(--muted); }
.status.warn { color: var(--warn); }
.status button { border: 0; background: none; color: var(--accent); text-decoration: underline; padding: 0; }

main { padding: 0 16px 16px; max-width: 640px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.pool .label { color: var(--muted); font-size: 13px; }
.pool .big { font-size: 28px; font-weight: 700; }
.pool.has-money { border-color: var(--accent); }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 6px; }
.row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.row:last-child { border-bottom: 0; }
.row .name { flex: 1; min-width: 0; }
.row .sub { display: block; font-size: 12px; color: var(--muted); }
.row .amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--bad); }
.bar { height: 4px; background: var(--bar); border-radius: 2px; margin-top: 4px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.bar i.over { background: var(--bad); }

.tabs { position: fixed; inset: auto 0 0 0; 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 { border: 0; background: none; padding: 12px 0; font-size: 12px; color: var(--muted); }
.tabs button[aria-current="page"] { color: var(--accent); font-weight: 600; }
.tabs .add { font-size: 30px; line-height: 1; color: var(--accent-ink); background: var(--accent); border-radius: 50%; width: 56px; height: 56px; margin: -18px auto 0; padding: 0; }

.btn { border: 0; border-radius: 10px; padding: 12px 14px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.ghost { background: none; color: var(--accent); border: 1px solid var(--line); }
.btn.danger { background: none; color: var(--bad); border: 1px solid var(--line); }
.btn.small { padding: 6px 10px; font-size: 14px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btns .btn { flex: 1; }

dialog { border: 0; padding: 0; width: 100%; max-width: 640px; margin: auto auto 0; border-radius: 18px 18px 0 0; background: var(--card); color: var(--ink); max-height: 92vh; }
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog form { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 12px; }
dialog h3 { margin: 0; font-size: 18px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input, select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font-size: 16px; }
.amount-input { font-size: 32px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: none; padding: 8px; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.chips button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.err { color: var(--bad); font-size: 13px; margin: 0; }
.month-nav { display: flex; align-items: center; justify-content: space-between; }
.month-nav strong { font-size: 18px; }
.alloc-input { width: 130px; text-align: right; padding: 6px 8px; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.empty { color: var(--muted); text-align: center; padding: 24px 0; }
