:root {
  --bg: #f4f6f5; --card: #ffffff; --text: #16221f; --muted: #66756f; --line: #e1e7e4;
  --brand: #0f766e; --brand-ink: #ffffff; --good: #0f766e; --bad: #c0262d; --warn: #b45309;
  --track: #e6ecea; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1513; --card: #18211e; --text: #e8f0ed; --muted: #8fa19a; --line: #26332f;
    --brand: #2dd4bf; --brand-ink: #062a25; --good: #2dd4bf; --bad: #ff7b7f; --warn: #fbbf24;
    --track: #26332f; --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#app { max-width: 520px; margin: 0 auto; padding: 16px 16px calc(150px + env(safe-area-inset-bottom)); }
h1 { font-size: 22px; margin: 8px 0 4px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.card { background: var(--card); border-radius: 16px; padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row + .row { margin-top: 6px; }
.right { text-align: right; }
.neg { color: var(--bad); }
.pos { color: var(--good); }

/* hero */
.hero { text-align: center; padding: 22px 16px 18px; }
.hero .lbl { color: var(--muted); font-size: 14px; }
.hero .big { font-size: 56px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin: 4px 0; }
.hero.neg .big { color: var(--bad); }
.hero .sub { color: var(--muted); }
.hero .perday { margin-top: 6px; font-weight: 600; }

.banner { display: block; width: 100%; border: 0; border-radius: 14px; padding: 14px; margin-bottom: 10px;
  background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 700; cursor: pointer; }
.notice { border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; font-size: 14px;
  background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.notice.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.hint { text-align: center; }

/* bars */
.bar { height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.bar.over > i { background: var(--bad); }
.bar.warn > i { background: var(--warn); }
.cat .row b, .bill .row b { font-weight: 600; }

/* bills */
.bill.overdue { border: 1.5px solid var(--bad); }
.bill .due { font-size: 13px; color: var(--muted); }
.bill.overdue .due { color: var(--bad); font-weight: 600; }
.bill .actions { display: flex; gap: 8px; margin-top: 10px; }

/* expenses list */
.exp { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.exp:first-child { border-top: 0; }
.exp .grow { flex: 1; min-width: 0; }
.exp .note { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.x { border: 0; background: none; color: var(--muted); font-size: 20px; padding: 4px 8px; cursor: pointer; }

/* buttons + forms */
button, .btn { font: inherit; }
.btn { display: inline-block; border: 0; border-radius: 12px; padding: 11px 16px; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); font-weight: 700; text-align: center; text-decoration: none; }
.btn.ghost { background: transparent; color: var(--text); border: 1.5px solid var(--line); }
.btn.danger { background: transparent; color: var(--bad); border: 1.5px solid var(--bad); }
.btn.block { display: block; width: 100%; }
.btn.small { padding: 8px 12px; font-size: 14px; }
label.f { display: block; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
label.f > span { display: block; margin-bottom: 4px; }
input[type=text], input[type=number], input[type=date], select {
  width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px; }
input:focus, select:focus { outline: 2px solid var(--brand); border-color: transparent; }
.amount { font-size: 34px; font-weight: 800; text-align: center; padding: 14px 12px !important; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 9px 14px; border-radius: 99px; border: 1.5px solid var(--line);
  background: var(--card); cursor: pointer; font-size: 15px; }
.chip input:checked + span { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; }
.chip input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1.5px solid var(--line);
  border-radius: 12px; margin-bottom: 8px; cursor: pointer; }
.opt input { margin-top: 4px; }
.opt.disabled { opacity: .5; }
[hidden] { display: none !important; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin-bottom: 8px; }
input[type=password] { width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px; }
input[type=password]:focus { outline: 2px solid var(--brand); border-color: transparent; }
.opt input[type=checkbox] { width: 20px; height: 20px; flex: none; }

/* floating add button + tabs */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
#tabs:empty { display: none; }
#tabs .inner { display: flex; width: 100%; max-width: 520px; }
#tabs button { flex: 1; border: 0; background: none; color: var(--muted); padding: 12px 4px; font-size: 14px; cursor: pointer; }
#tabs button.on { color: var(--brand); font-weight: 700; }
.fab { position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 9;
  width: min(calc(100% - 32px), 488px); box-shadow: 0 6px 20px rgba(0,0,0,.25); padding: 15px; font-size: 17px; }

/* sheet */
#sheet:empty { display: none; }
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
  border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.sheet h1 { margin-top: 0; }
.sheet .head { display: flex; justify-content: space-between; align-items: center; }

#toast { position: fixed; left: 50%; bottom: calc(130px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #16221f; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 30; max-width: 90%;
  font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; text-align: center; }
#toast.show { opacity: 1; }
