/* Minimal theme: neutral greys, one ink accent, hairlines instead of shadows. */
:root {
  --bg: #fafafa; --card: #ffffff; --text: #0a0a0a; --muted: #737373; --faint: #a3a3a3;
  --line: #ececec; --input: #f4f4f5; --soft: #f4f4f5;
  --accent: #0a0a0a; --on-accent: #ffffff;
  --danger: #dc2626; --good: #15803d;
  --radius: 16px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0a0a0a; --card: #141414; --text: #fafafa; --muted: #a1a1a1; --faint: #6b6b6b;
    --line: #232323; --input: #1b1b1b; --soft: #1e1e1e;
    --accent: #fafafa; --on-accent: #0a0a0a; --danger: #f87171; --good: #4ade80; }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15.5px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text);
  -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; letter-spacing: -.005em; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
svg.i { flex: none; display: block; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 14px; }
.good { color: var(--good); }
.bad { color: var(--danger); }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 340px; background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  padding: 32px 22px; display: grid; gap: 12px; text-align: center; }
.login-card img { margin: 0 auto 4px; border-radius: 14px; }
.login-card h1 { font-size: 22px; }

/* Layout */
#app { max-width: 600px; margin: 0 auto; padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: flex-end; justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top)) 20px 12px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.top .greet { font-size: 13px; color: var(--muted); }
.top h1 { font-size: 26px; font-weight: 650; letter-spacing: -.6px; }
.net { font-size: 12px; border: 1px solid var(--danger); color: var(--danger); padding: 2px 9px; border-radius: 99px; }
main { padding: 0 16px; display: grid; gap: 12px; }
main > * { min-width: 0; }

.tabs { position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
.tabs button { flex: 1; max-width: 120px; background: none; border: 0; padding: 4px 0; font-size: 11px; font-weight: 500;
  color: var(--faint); display: grid; justify-items: center; gap: 3px; cursor: pointer; transition: color .15s; }
.tabs button.on { color: var(--text); }
.tabs button.on svg { stroke-width: 2.1; }

/* Cards & inputs */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-h { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.card-h h2, .card > h2 { font-size: 14px; font-weight: 600; }
.card > h2 { margin-bottom: 10px; }
.big { font-size: 30px; font-weight: 650; letter-spacing: -1px; }
input, select, textarea { width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid transparent;
  background: var(--input); outline: none; min-height: 46px; font-size: 16px; /* 16px stops iOS zoom-on-focus */
  transition: border-color .15s, background .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--text); background: var(--card); }
input::placeholder { color: var(--faint); }
input[type=checkbox] { accent-color: var(--accent); }
label.f { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.search { position: relative; display: block; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search input { padding-left: 40px; }

.btn { border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; min-height: 46px; font-weight: 550; cursor: pointer;
  background: var(--card); color: var(--text); display: inline-flex; gap: 7px; align-items: center; justify-content: center;
  text-decoration: none; transition: transform .08s, opacity .15s, background .15s; font-size: 15px; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.ghost { background: transparent; border-style: dashed; color: var(--muted); }
.btn.danger { background: transparent; color: var(--danger); border-color: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .45; }
.icon-btn { background: none; border: 0; padding: 8px; cursor: pointer; color: var(--muted); border-radius: 10px; display: grid; place-items: center; }
.icon-btn:hover { background: var(--soft); color: var(--text); }

/* Hero: just the number */
.hero { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px 14px; display: grid; gap: 2px; }
.hero .lbl { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hero .amt { font-size: 40px; font-weight: 650; letter-spacing: -1.6px; line-height: 1.15; }
.pill { font-size: 12px; font-weight: 500; padding: 2px 8px 2px 6px; border-radius: 99px; background: var(--soft); color: var(--muted);
  white-space: nowrap; display: inline-flex; align-items: center; gap: 3px; }
.hero .budget { margin-top: 10px; display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.hero .budget b { color: var(--text); font-weight: 550; }
.hero .budget .track { height: 4px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.hero .budget .track i { display: block; height: 100%; border-radius: 99px; background: var(--text); }
.hero .budget.over b, .hero .budget.over { color: var(--danger); }
.hero .budget.over .track i { background: var(--danger); }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 14px -16px 0; border-top: 1px solid var(--line); padding-top: 12px; }
.hero-stats > * { padding: 0 16px; border: 0; background: none; color: inherit; text-align: left; font: inherit; }
.hero-stats > * + * { border-left: 1px solid var(--line); }
.hero-stats small { display: block; font-size: 12px; color: var(--muted); }
.hero-stats b { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
button.hero-stat { cursor: pointer; }
button.hero-stat small::after { content: " ›"; }

/* Quick add */
.quick { display: grid; gap: 12px; }
.quick .preview { display: flex; gap: 10px; align-items: center; min-height: 36px; }
.quick .p-amt { font-size: 24px; font-weight: 650; letter-spacing: -.6px; }
.quick .p-desc { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 500; padding: 4px 10px 4px 8px; border-radius: 99px;
  background: var(--soft); white-space: nowrap; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 2px; }
main > .chips { margin: 0; padding: 0 0 2px; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 6px 12px 6px 10px;
  font-size: 14px; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; color: var(--muted);
  transition: background .15s, color .15s, border-color .15s; }
.chip:not([data-c]) { padding-left: 12px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* Lists */
.list { display: grid; }
.item { display: flex; gap: 12px; align-items: center; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line);
  background: none; width: 100%; text-align: left; cursor: pointer; }
.item:last-child { border-bottom: 0; padding-bottom: 2px; }
.ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--soft); color: var(--text); }
.item .main { flex: 1; min-width: 0; }
.item .t1 { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .amt { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.day { font-size: 12px; color: var(--muted); font-weight: 500; margin: 16px 0 2px; display: flex; justify-content: space-between; }
.day:first-child { margin-top: 0; }
.pending-tag { font-size: 11px; border: 1px solid var(--danger); color: var(--danger); border-radius: 6px; padding: 0 5px; margin-left: 6px; }
.link { background: none; border: 0; color: var(--muted); font-size: 13px; cursor: pointer; padding: 0; }
.link:hover { color: var(--text); }

/* Category bars */
.bars { display: grid; gap: 14px; }
.bar-row { display: grid; grid-template-columns: auto 1fr auto; gap: 6px 12px; align-items: center; font-size: 14px; }
.bar-row .ico { width: 34px; height: 34px; border-radius: 10px; grid-row: span 2; }
.bar-row .val { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.bar-row .val small { color: var(--muted); font-weight: 400; margin-left: 6px; display: inline-block; min-width: 30px; }
.bar { grid-column: 2 / -1; height: 4px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--text); border-radius: 99px; }

.month-nav { display: flex; align-items: center; justify-content: space-between; padding: 8px; }
.month-nav strong { font-size: 16px; font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 26px 8px; font-size: 14px; }
.empty .e-ico { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 10px; border-radius: 16px; background: var(--soft); color: var(--text); }

/* Bottom sheet */
.sheet { border: 0; padding: 0; width: 100%; max-width: 600px; margin: auto auto 0; border-radius: 22px 22px 0 0;
  background: var(--card); color: var(--text); max-height: 92dvh; border-top: 1px solid var(--line); }
.sheet[open] { animation: up .22s cubic-bezier(.2,.8,.2,1); }
@keyframes up { from { transform: translateY(30px); opacity: .3; } }
.sheet::backdrop { background: rgba(0,0,0,.35); }
#sheet-body { padding: 10px 18px calc(20px + env(safe-area-inset-bottom)); display: grid; gap: 13px; }
#sheet-body::before { content: ""; width: 36px; height: 4px; border-radius: 99px; background: var(--line); margin: 0 auto 4px; }
#sheet-body h3 { font-size: 18px; }

/* Lend */
.person { padding: 14px 0; border-bottom: 1px solid var(--line); }
.person:first-child { padding-top: 0; }
.person:last-child { border-bottom: 0; padding-bottom: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 14px;
  color: var(--text); background: var(--soft); flex: none; }
.loan { display: flex; gap: 8px; align-items: center; padding: 10px 0 0 52px; font-size: 14px; }
.loan .main { flex: 1; min-width: 0; }
.settled { opacity: .45; }
.friend { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; }

.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--accent); color: var(--on-accent); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 50;
  max-width: 90vw; animation: up .2s ease-out; }
