:root {
  --brand: #4f46e5; --brand2: #9333ea; --bg: #f4f4fb; --card: #fff; --ink: #17162b;
  --muted: #66647f; --line: #e4e3f1; --field: #fff; --good: #0f7a4d; --bad: #c0262d;
  --shadow: 0 2px 10px rgba(35, 30, 90, .07);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f0e1a; --card: #1a1929; --ink: #efeefc; --muted: #a4a2c0; --line: #2d2b44; --field: #131222;
    --good: #4ade9b; --bad: #ff8388; --shadow: none; color-scheme: dark; }
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.45;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", sans-serif; }
a { color: var(--brand); }
@media (prefers-color-scheme: dark) { a { color: #a5a0ff; } }
h1, h2 { margin: 0 0 .5rem; line-height: 1.3; }
h2 { font-size: 1.25rem; }
.muted { color: var(--muted); }
.wrap { max-width: 640px; margin: 0 auto; padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
main.wrap { padding-top: 4px; padding-bottom: calc(112px + env(safe-area-inset-bottom)); }

.topbar { position: sticky; top: 0; z-index: 10; background: var(--bg); padding-top: env(safe-area-inset-top); }
.bar { display: flex; align-items: center; gap: 8px; padding-top: 10px; padding-bottom: 8px; }
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.who strong, .who small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--muted); }
.pill { font: inherit; font-size: .85rem; font-weight: 600; min-height: 36px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }

.avatar { --hue: 245; flex: 0 0 42px; width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-weight: 700; font-size: 1.1rem;
  background: hsl(var(--hue) 75% 92%); color: hsl(var(--hue) 60% 32%); }
.avatar.me { border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; }

.hero { color: #fff; border-radius: 24px; padding: 20px 18px 14px; margin-bottom: 14px;
  background: radial-gradient(circle at 90% 0, rgba(255,255,255,.22), transparent 45%), linear-gradient(135deg, var(--brand), var(--brand2));
  box-shadow: 0 12px 28px rgba(90, 60, 220, .28); }
.hero-label { font-size: .85rem; opacity: .9; }
.hero > strong { display: block; font-size: clamp(2rem, 11vw, 3rem); letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.stats div { background: rgba(255,255,255,.16); border-radius: 14px; padding: 8px 10px; }
.stats span { display: block; font-size: .72rem; opacity: .9; }
.stats b { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

input, textarea { width: 100%; font: inherit; font-size: 16px; /* stops iOS zoom */
  color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; }
input[type="date"] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; min-height: 48px; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input.big { font-size: 1.8rem; font-weight: 700; }
textarea { resize: vertical; }
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #f59e0b; outline-offset: 1px; }
label { display: block; margin: 12px 0 4px; font-size: .88rem; font-weight: 600; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips:empty { display: none; }
.chip { flex: 0 0 auto; display: flex; gap: 8px; align-items: center; font: inherit; font-size: .85rem; min-height: 36px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.chip span { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }

.day h3 { display: flex; justify-content: space-between; gap: 8px; margin: 18px 4px 8px; font-size: .85rem; color: var(--muted); }
.day h3 b { color: var(--ink); }
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: 18px; box-shadow: var(--shadow); }
.item { display: flex; gap: 12px; align-items: center; padding: 12px; }
.item + .item { border-top: 1px solid var(--line); }
.info { flex: 1; min-width: 0; }
.title, .sub, .date { display: block; overflow-wrap: anywhere; }
.title { font-weight: 650; }
.sub { font-size: .88rem; color: var(--muted); }
.date { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.side { text-align: right; flex-shrink: 0; }
.amount { display: block; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; margin-top: 2px; }
.icon { font: inherit; width: 36px; height: 34px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; }
.icon:hover { background: var(--bg); }
.empty { text-align: center; padding: 36px 0; }

.dock { position: fixed; z-index: 15; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); max-width: 480px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr); align-items: center; gap: 8px; padding: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 10px 30px rgba(20, 15, 60, .18); }
.dock button { font: inherit; font-size: .75rem; font-weight: 600; line-height: 1.2; border: 0; background: none; color: var(--ink); cursor: pointer; min-height: 48px; }
.dock button span { display: block; font-size: 1.2rem; }
.dock .add { height: 60px; border-radius: 20px; font-size: 1.9rem; color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand2)); }

.btn { font: inherit; font-weight: 650; min-height: 46px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); cursor: pointer; }
.btn.primary { border: 0; color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand2)); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.block { width: 100%; margin-top: 18px; }
.btn:disabled { opacity: .45; cursor: default; }
.linkbtn { font: inherit; font-size: .85rem; background: none; border: 0; color: var(--muted); text-decoration: underline; min-height: 36px; cursor: pointer; }

dialog { width: min(520px, calc(100vw - 20px)); max-height: calc(100dvh - 20px); overflow-y: auto; border: 1px solid var(--line); border-radius: 24px; padding: 18px; color: var(--ink); background: var(--card); }
dialog::backdrop { background: rgba(12, 10, 35, .6); backdrop-filter: blur(3px); }
@media (max-width: 560px) {
  #entryDialog, #pasteDialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 24px 24px 0 0; max-height: 94dvh; }
}
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.actions.three { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.actions.three .btn { padding-left: 4px; padding-right: 4px; }
.actions:has(> :only-child) { grid-template-columns: 1fr; }
.actions.sticky { position: sticky; bottom: -18px; background: var(--card); padding: 10px 0 18px; margin-bottom: -18px; }

#preview { font-size: .88rem; overflow-wrap: anywhere; }
#preview .ok { color: var(--good); font-weight: 700; margin-bottom: 0; }
#preview .ok + .muted { margin-top: 0; }
.warn { color: var(--bad); }
.draft { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 8px; border: 1px solid var(--line); border-radius: 16px; padding: 10px; margin-bottom: 10px; position: relative; }
.draft label { margin: 0; font-size: .72rem; color: var(--muted); }
.draft input { margin-top: 2px; padding: 8px 10px; min-height: 42px; }
.draft .f-paid_to, .draft .f-title { grid-column: 1 / -1; }
.draft { padding-top: 34px; }
.draft .remove { position: absolute; right: 4px; top: 2px; }
.draft .warn { grid-column: 1 / -1; margin: 0; }

.alert { background: rgba(220, 38, 38, .12); color: var(--bad); border-radius: 12px; padding: 10px 12px; font-size: .92rem; overflow-wrap: anywhere; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(100px + env(safe-area-inset-bottom)); max-width: 420px; margin: 0 auto; background: var(--ink); color: var(--bg); text-align: center; border-radius: 14px; padding: 11px 14px; z-index: 20; }

.auth { max-width: 420px; margin: 0 auto; padding: calc(36px + env(safe-area-inset-top)) 16px 32px; text-align: center; }
.brand { color: var(--ink); margin-bottom: 0; font-size: 2rem; }
.card { background: var(--card); box-shadow: var(--shadow); border-radius: 24px; padding: 22px 18px; text-align: left; margin: 20px 0; border-top: 6px solid var(--brand); }
.steps { margin: 0; font-size: .8rem; font-weight: 700; color: var(--brand2); }
.inline-form { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.verified { color: var(--good); overflow-wrap: anywhere; min-width: 0; }
