@import url("/fonts/fonts.css");

/* ============================================================
   Barabar — design tokens
   Purple = brand & navigation. Green/rose = money direction only.
   ============================================================ */

:root {
  --violet-50: #F7F4FF;
  --violet-100: #EDE9FF;
  --violet-200: #DDD3FE;
  --violet-300: #C3ADFD;
  --violet-500: #8B5CF6;
  --violet-600: #7C3AED;
  --violet-700: #6926D4;

  --brand: #7C3AED;
  --brand-strong: #6D28D9;
  --brand-soft: #EEE9FE;
  --brand-ink: #5B21B6;
  --on-brand: #ffffff;
  --grad: linear-gradient(135deg, #6D28D9 0%, #8B32E8 46%, #A21CAF 100%);
  --grad-soft: linear-gradient(160deg, color-mix(in srgb, var(--brand) 7%, var(--surface)) 0%, var(--surface) 72%);

  /* Neutrals stay neutral — a faint cool gray, never purple. */
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --surface-2: #EFF2F6;
  --surface-3: #E4E9F0;
  --border: #E2E7EE;
  --border-strong: #CFD6E0;

  --ink: #0F1524;
  --ink-2: #475269;
  --ink-3: #667085;

  --pos: #12A474;
  --pos-ink: #047857;
  --pos-soft: #D8F5E9;
  --neg: #E11D48;
  --neg-ink: #BE123C;
  --neg-soft: #FFE4EA;
  --warn: #D97706;
  --warn-ink: #B45309;
  --warn-soft: #FDF0DB;

  --shadow-sm: 0 1px 2px rgba(15, 21, 36, .06);
  --shadow: 0 1px 2px rgba(15, 21, 36, .04), 0 8px 24px rgba(15, 21, 36, .07);
  --shadow-lg: 0 18px 48px rgba(15, 21, 36, .22);
  --ring: 0 0 0 3px color-mix(in srgb, var(--brand) 32%, transparent);

  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --r-xl: 26px;
  --pill: 999px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Plus Jakarta Sans", "Inter", -apple-system, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --appbar-h: 56px;
  --tabbar-h: 62px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}
:root[data-theme="dark"] { color-scheme: dark; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #7C3AED;
    --brand-strong: #6D28D9;
    --brand-soft: #241B3D;
    --brand-ink: #C4B5FD;
    --grad: linear-gradient(135deg, #5B21B6 0%, #7E22CE 48%, #86198F 100%);
    --grad-soft: linear-gradient(160deg, color-mix(in srgb, var(--brand) 18%, var(--surface)) 0%, var(--surface) 72%);
    --bg: #0B0E14;
    --surface: #141924;
    --surface-2: #1C2230;
    --surface-3: #262E3D;
    --border: #28303F;
    --border-strong: #3A4456;
    --ink: #EEF1F6;
    --ink-2: #C3CAD8;
    --ink-3: #94A0B4;
    --pos: #10B981;
    --pos-ink: #6EE7B7;
    --pos-soft: #0C3A2B;
    --neg: #F43F5E;
    --neg-ink: #FDA4AF;
    --neg-soft: #431A28;
    --warn: #F59E0B;
    --warn-ink: #FCD34D;
    --warn-soft: #3A2A10;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 28px rgba(0, 0, 0, .45);
    --shadow-lg: 0 18px 52px rgba(0, 0, 0, .65);
  }
}
:root[data-theme="dark"] {
  --brand: #7C3AED;
  --brand-strong: #6D28D9;
  --brand-soft: #241B3D;
  --brand-ink: #C4B5FD;
  --grad: linear-gradient(135deg, #5B21B6 0%, #7E22CE 48%, #86198F 100%);
  --grad-soft: linear-gradient(160deg, color-mix(in srgb, var(--brand) 18%, var(--surface)) 0%, var(--surface) 72%);
  --bg: #0B0E14;
  --surface: #141924;
  --surface-2: #1C2230;
  --surface-3: #262E3D;
  --border: #28303F;
  --border-strong: #3A4456;
  --ink: #EEF1F6;
  --ink-2: #C3CAD8;
  --ink-3: #94A0B4;
  --pos: #10B981;
  --pos-ink: #6EE7B7;
  --pos-soft: #0C3A2B;
  --neg: #F43F5E;
  --neg-ink: #FDA4AF;
  --neg-soft: #431A28;
  --warn: #F59E0B;
  --warn-ink: #FCD34D;
  --warn-soft: #3A2A10;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 28px rgba(0, 0, 0, .45);
  --shadow-lg: 0 18px 52px rgba(0, 0, 0, .65);
}

/* ============================================================
   Base
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 700; letter-spacing: -.015em; line-height: 1.22; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--brand-soft); color: var(--brand-ink); }

.money { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.pos { color: var(--pos-ink); }
.neg { color: var(--neg-ink); }
.muted { color: var(--ink-3); }
.strong { font-weight: 650; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { text-align: center; }
.row-flex { display: flex; align-items: center; gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.label {
  font-size: .6875rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); font-family: var(--font);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ============================================================
   App shell
   ============================================================ */

.boot { min-height: 100svh; display: grid; place-items: center; gap: 14px; }
.boot img { width: 64px; height: 64px; border-radius: 18px; animation: breathe 1.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(.88); opacity: .6; } }

.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  height: calc(var(--appbar-h) + var(--safe-top));
  padding: var(--safe-top) 8px 0 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.appbar.scrolled { border-bottom-color: var(--border); }
.appbar h1 { font-size: 1.0625rem; }
.appbar .sub { font-size: .75rem; color: var(--ink-3); margin-top: 1px; }
.appbar-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.iconbtn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 0; border-radius: var(--pill); background: transparent; color: var(--ink-2); font-size: 1.05rem;
  transition: background .15s, transform .1s;
}
.iconbtn:hover { background: var(--surface-2); color: var(--ink); }
.iconbtn:active { transform: scale(.92); }
.iconbtn.solid { background: var(--surface); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }

.page { padding: 4px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 28px); max-width: 640px; margin: 0 auto; }
.page > * + * { margin-top: 20px; }
/* Home stacks its sections in columns; the gap is the section rhythm. */
.col { display: flex; flex-direction: column; gap: 30px; min-width: 0; }
.page > .col + .col { margin-top: 30px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; padding: 0 2px; }
.section-head h2 { font-size: 1.0625rem; letter-spacing: -.02em; }

/* Stat line above a chart */
.stat { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 0 14px; }
.stat .v { font-family: var(--font); font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; }
.stat .k { font-size: .75rem; color: var(--ink-3); margin-top: 2px; }
.linkish { color: var(--brand-ink); font-weight: 600; font-size: .8125rem; background: none; border: 0; padding: 0; }

/* Bottom navigation (mobile) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: none; border: 0; color: var(--ink-3); font-size: .625rem; font-weight: 600; letter-spacing: .02em;
  height: 100%; padding-top: 4px; position: relative;
}
.tab .tabic { display: grid; place-items: center; transition: transform .16s; }
.tab .tabic .ic { width: 22px; height: 22px; vertical-align: 0; }
.tab[aria-current="page"] { color: var(--brand-ink); }
.tab[aria-current="page"] .tabic { transform: translateY(-1px); }
.tab[aria-current="page"] .tabic .ic { stroke-width: 2.1; }
.tab[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; width: 26px; height: 3px; border-radius: 0 0 4px 4px; background: var(--brand);
}
.tabic { position: relative; }
.badge {
  position: absolute; top: -5px; left: 11px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--neg); color: #fff; font-size: .625rem; font-weight: 700;
  display: grid; place-items: center; box-shadow: 0 0 0 2px var(--surface);
}
.rail .badge { position: static; box-shadow: none; }
.seg .ic { width: 1em; height: 1em; vertical-align: -.15em; margin-right: 2px; }

.tab-add { position: relative; }
.tab-add .plus .ic { width: 24px; height: 24px; stroke-width: 2.2; vertical-align: 0; }
.tab-add .plus {
  display: grid; place-items: center; width: 52px; height: 52px; margin-top: -22px;
  border-radius: 18px; background: var(--grad); color: #fff;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--brand) 45%, transparent);
  transition: transform .14s;
}
.tab-add:active .plus { transform: scale(.94); }

.rail { display: none; }

/* ============================================================
   Cards, rows, chips
   ============================================================ */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); padding: 16px;
}
.card.flush { padding: 0; overflow: hidden; }
.card + .card { margin-top: 14px; }

.hero {
  position: relative; overflow: hidden; border-radius: var(--r-xl); padding: 20px;
  background: var(--grad); color: #fff; box-shadow: 0 12px 32px color-mix(in srgb, var(--brand) 32%, transparent);
}
.hero::after {
  content: ""; position: absolute; inset: auto -40px -70px auto; width: 210px; height: 210px; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}
.hero .label { color: rgba(255, 255, 255, .78); }
.hero-amount {
  font-family: var(--font); font-weight: 750; font-size: clamp(2.25rem, 11vw, 2.75rem);
  letter-spacing: -.03em; line-height: 1.05; margin: 6px 0 2px;
}
.hero .hero-sub { font-size: .875rem; color: rgba(255, 255, 255, .86); }
.hero-split { display: flex; gap: 8px; margin-top: 16px; position: relative; z-index: 1; }
.hero-pill {
  flex: 1; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .22);
  border-radius: var(--r); padding: 9px 12px; backdrop-filter: blur(4px);
}
.hero-pill .k { font-size: .6875rem; text-transform: uppercase; letter-spacing: .07em; color: rgba(255, 255, 255, .8); font-weight: 700; }
.hero-pill .v { font-weight: 700; font-size: 1.0625rem; margin-top: 2px; }
.hero-actions { display: flex; gap: 8px; margin-top: 14px; position: relative; z-index: 1; }
.hero-actions .btn { font-size: .875rem; padding: 0 12px; min-height: 42px; }
.act-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.act-row .btn { font-size: .875rem; padding: 0 12px; }

.row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; background: none; border: 0; border-radius: var(--r); min-height: 60px;
  transition: background .14s;
}
.card.flush .row { border-radius: 0; }
.row + .row { border-top: 1px solid var(--border); }
.row:hover { background: var(--surface-2); }
.row:active { background: var(--surface-3); }
.row .title { font-weight: 600; font-size: .9375rem; }
.row .sub { font-size: .8125rem; color: var(--ink-3); margin-top: 1px; }
.row .end { margin-left: auto; text-align: right; flex: none; }
.row .end .amt { font-weight: 700; font-size: .9375rem; }
.row .end .cap { font-size: .6875rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.chev { color: var(--ink-3); font-size: .9rem; flex: none; }

/* Line icons: one stroke weight everywhere, colour inherited from the parent. */
.ic { width: 1.15em; height: 1.15em; flex: none; display: inline-block; vertical-align: -.22em; }
.ic.lg { width: 1.6em; height: 1.6em; }
.ic.flip { transform: rotate(180deg); }
.ic.rot45 { transform: rotate(45deg); }
.btn .ic, .chip .ic, .linkish .ic { vertical-align: -.2em; }
.chev .ic { width: 1.05em; height: 1.05em; opacity: .7; }

.tile {
  display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 13px;
  background: hsl(var(--h, 265) 74% 95%); color: hsl(var(--h, 265) 48% 34%);
}
.tile .ic { width: 21px; height: 21px; vertical-align: 0; }
.tile.sm { width: 32px; height: 32px; border-radius: 10px; }
.tile.sm .ic { width: 17px; height: 17px; }
.tile.lg { width: 54px; height: 54px; border-radius: 17px; }
.tile.lg .ic { width: 26px; height: 26px; }
:root[data-theme="dark"] .tile { background: hsl(var(--h, 265) 32% 20%); color: hsl(var(--h, 265) 62% 76%); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tile { background: hsl(var(--h, 265) 32% 20%); color: hsl(var(--h, 265) 62% 76%); }
}

.avatar {
  display: inline-grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 50%;
  background: hsl(var(--h) 66% 90%); color: hsl(var(--h) 52% 30%);
  font-family: var(--font-display); font-weight: 700; font-size: .95rem; letter-spacing: -.01em;
}
.avatar.xs { width: 26px; height: 26px; font-size: .6875rem; }
.avatar.sm { width: 32px; height: 32px; font-size: .8125rem; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.25rem; }
.avatar.xl { width: 76px; height: 76px; font-size: 1.75rem; }
:root[data-theme="dark"] .avatar { background: hsl(var(--h) 32% 27%); color: hsl(var(--h) 74% 82%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { background: hsl(var(--h) 32% 27%); color: hsl(var(--h) 74% 82%); } }
.avatar-stack { display: flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2.5px var(--surface); }
.avatar-stack .avatar + .avatar { margin-left: -10px; }
.avatar-stack .more {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; margin-left: -10px;
  background: var(--surface-3); color: var(--ink-2); font-size: .6875rem; font-weight: 700; box-shadow: 0 0 0 2.5px var(--surface);
}

.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: var(--pill);
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border);
  font-size: .8125rem; font-weight: 600; white-space: nowrap;
}
.chip.tap { transition: transform .1s, border-color .15s; }
.chip.tap:active { transform: scale(.96); }
.chip.pos { background: var(--pos-soft); color: var(--pos-ink); border-color: color-mix(in srgb, var(--pos) 25%, transparent); }
.chip.neg { background: var(--neg-soft); color: var(--neg-ink); border-color: color-mix(in srgb, var(--neg) 25%, transparent); }
.chip.warn { background: var(--warn-soft); color: var(--warn-ink); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.chip.brand { background: var(--brand-soft); color: var(--brand-ink); border-color: color-mix(in srgb, var(--brand) 25%, transparent); }
.chip.ghost { background: transparent; }
.chip.lg { padding: 8px 14px; font-size: .875rem; }

.badge-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.badge-dot.pos { background: var(--pos); }
.badge-dot.neg { background: var(--neg); }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 18px; border-radius: var(--pill); border: 1px solid transparent;
  background: var(--surface-2); color: var(--ink); font-weight: 650; font-size: .9375rem; white-space: nowrap;
  transition: transform .1s, background .15s, box-shadow .15s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 32%, transparent); }
.btn.primary:hover { background: var(--brand-strong); }
.btn.soft { background: var(--brand-soft); color: var(--brand-ink); }
.btn.outline { background: transparent; border-color: var(--border-strong); color: var(--ink); }
.btn.glass { background: rgba(255, 255, 255, .2); border-color: rgba(255, 255, 255, .34); color: #fff; backdrop-filter: blur(6px); }
.btn.glass:hover { background: rgba(255, 255, 255, .3); }
.btn.danger { background: var(--neg-soft); color: var(--neg-ink); }
.btn.sm { min-height: 34px; padding: 0 13px; font-size: .8125rem; border-radius: var(--pill); }
.btn.block { width: 100%; }
.btn.lg { min-height: 52px; font-size: 1rem; }

/* ============================================================
   Forms
   ============================================================ */

.field { display: block; margin-bottom: 14px; }
.field > .label { display: block; margin-bottom: 6px; }
.input, .field input, .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 12px 14px; font-size: 1rem; /* 16px avoids iOS zoom */
  background: var(--surface-2); border: 1.5px solid transparent; border-radius: var(--r);
  color: var(--ink); transition: border-color .15s, box-shadow .15s, background .15s;
}
.field textarea { min-height: 76px; resize: vertical; line-height: 1.5; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus {
  outline: none; background: var(--surface); border-color: var(--brand); box-shadow: var(--ring);
}
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 14px) 21px; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 38px; }
.field .help { font-size: .75rem; color: var(--ink-3); margin-top: 6px; }
.err { color: var(--neg-ink); font-size: .8125rem; font-weight: 600; margin: 8px 0; display: flex; gap: 6px; align-items: flex-start; }
.err .ic { width: 16px; height: 16px; flex: none; margin-top: 1px; vertical-align: 0; }
.err:empty { display: none; }

.amount-field { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 0 4px; }
.amount-field .cur { font-size: 1.75rem; font-weight: 600; color: var(--ink-3); font-family: var(--font); }
.amount-field input {
  width: 100%; max-width: 260px; border: 0; background: none; padding: 0;
  font-family: var(--font); font-size: clamp(2.5rem, 13vw, 3.25rem); font-weight: 750; letter-spacing: -.035em;
  text-align: center; min-height: 0;
}
.amount-field input:focus { outline: none; box-shadow: none; background: none; }
.amount-field input::-webkit-outer-spin-button, .amount-field input::-webkit-inner-spin-button { appearance: none; margin: 0; }

.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; padding: 3px;
  background: var(--surface-2); border-radius: var(--pill);
}
.seg button {
  border: 0; background: transparent; border-radius: var(--pill); padding: 9px 6px; min-height: 40px;
  font-size: .8125rem; font-weight: 650; color: var(--ink-3); transition: background .15s, color .15s;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.switch-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; }
.switch { appearance: none; width: 50px; height: 30px; border-radius: var(--pill); background: var(--border-strong); position: relative; flex: none; transition: background .18s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .18s; }
.switch:checked { background: var(--brand); }
.switch:checked::after { transform: translateX(20px); }

.pick-list { display: flex; flex-direction: column; }
.pick {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r);
  border: 1.5px solid transparent; background: none; width: 100%; text-align: left; min-height: 56px;
}
.pick:hover { background: var(--surface-2); }
.pick[aria-pressed="true"], .pick.on { border-color: var(--brand); background: var(--brand-soft); }
.pick .tick { margin-left: auto; color: var(--brand); font-weight: 700; }
.pick input[type="checkbox"], .pick input[type="radio"] { width: 22px; height: 22px; accent-color: var(--brand); flex: none; }

.money-input { display: flex; align-items: center; gap: 4px; background: var(--surface-2); border: 1.5px solid transparent; border-radius: var(--r-sm); padding: 0 10px; width: 118px; flex: none; }
.money-input:focus-within { border-color: var(--brand); background: var(--surface); }
.money-input span { font-size: .8125rem; color: var(--ink-3); }
.money-input input { width: 100%; min-height: 40px; border: 0; background: none; text-align: right; font-size: 1rem; font-variant-numeric: tabular-nums; padding: 0; }
.money-input input:focus { outline: none; }

/* ============================================================
   Sheets & dialogs
   ============================================================ */

.scrim {
  position: fixed; inset: 0; z-index: 60; background: rgba(23, 12, 46, .48);
  backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center;
  animation: fadein .18s ease-out;
}
@keyframes fadein { from { opacity: 0; } }
.sheet {
  width: 100%; max-height: 92svh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0; box-shadow: var(--shadow-lg);
  animation: slideup .26s cubic-bezier(.22, 1, .36, 1);
}
@keyframes slideup { from { transform: translateY(6%); opacity: .6; } }
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 8px auto 0; flex: none; }
.sheet-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px 10px; flex: none;
}
.sheet-head h2 { font-size: 1.0625rem; flex: 1; min-width: 0; }
.sheet-body { padding: 4px 18px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot {
  padding: 12px 18px calc(12px + var(--safe-bottom)); border-top: 1px solid var(--border); flex: none;
  display: flex; gap: 10px; background: var(--surface); border-radius: 0 0 var(--r-xl) var(--r-xl);
}
.sheet-foot .btn { flex: 1; }

.toast .ic { width: 18px; height: 18px; vertical-align: 0; }
.toast {
  position: fixed; left: 50%; transform: translate(-50%, 24px); z-index: 90;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  display: flex; align-items: center; gap: 9px; max-width: calc(100vw - 32px);
  padding: 12px 16px; border-radius: var(--pill); font-size: .875rem; font-weight: 600;
  background: #1A2031; color: #fff; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .24s cubic-bezier(.22, 1, .36, 1);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--neg-ink); }

/* ============================================================
   Auth & invite screens
   ============================================================ */

.auth {
  min-height: 100svh; display: flex; flex-direction: column; justify-content: center;
  padding: 32px 20px calc(32px + var(--safe-bottom)); max-width: 460px; margin: 0 auto;
}
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 22px; text-align: center; }
.auth-logo img { width: 68px; height: 68px; border-radius: 21px; box-shadow: 0 10px 26px color-mix(in srgb, var(--brand) 35%, transparent); }
.auth-logo h1 { font-size: 1.875rem; letter-spacing: -.03em; }
.auth-logo p { color: var(--ink-3); font-size: .9375rem; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow); padding: 20px; }
.invite-banner {
  display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: var(--r-lg);
  background: var(--grad-soft); border: 1px solid var(--border-strong); margin-bottom: 16px;
}
.invite-banner .t { font-size: .875rem; color: var(--ink-2); }
.invite-banner .t strong { color: var(--ink); }
.auth-alt { text-align: center; margin-top: 16px; font-size: .875rem; color: var(--ink-3); }

.centered-page { max-width: 460px; margin: 0 auto; padding: 24px 20px calc(var(--tabbar-h) + var(--safe-bottom) + 24px); text-align: center; }
.centered-page h2 { font-size: 1.5rem; margin: 14px 0 6px; }
.centered-page > p { color: var(--ink-3); margin-bottom: 20px; }

/* ============================================================
   Empty states, skeletons
   ============================================================ */

.empty { text-align: center; padding: 34px 18px; }
.empty .bubble {
  width: 74px; height: 74px; border-radius: 24px; display: grid; place-items: center; margin: 0 auto 14px;
  background: var(--brand-soft); color: var(--brand-ink);
}
.empty .bubble .ic { width: 32px; height: 32px; vertical-align: 0; }
.empty h3 { font-size: 1.125rem; margin-bottom: 6px; }
.empty p { color: var(--ink-3); font-size: .9375rem; max-width: 330px; margin: 0 auto 16px; }
.empty .btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.skel { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--r); }
@keyframes shimmer { to { background-position: -200% 0; } }


/* A person's balance, broken down by where it comes from. */
.person-block + .person-block { border-top: 1px solid var(--border); }
.ladder {
  margin: -2px 14px 12px 66px; border-left: 2px solid var(--border);
  padding: 0 0 0 12px; display: flex; flex-direction: column;
}
.ladder > * { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: .8125rem; color: var(--ink-3); }
.ladder a:hover { color: var(--ink); }
.ladder .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ladder .amt { font-variant-numeric: tabular-nums; font-weight: 650; }

.archive { width: 100%; text-align: left; border: 1px dashed var(--border-strong); background: transparent; }
.archive:hover { background: var(--surface-2); }
.archive.open { border-style: solid; background: var(--surface); }

/* ============================================================
   Expense list
   ============================================================ */

.daygroup + .daygroup { margin-top: 16px; }
.daygroup > .label { padding: 0 4px 6px; display: block; }

.exp-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; background: none; border: 0; text-align: left; min-height: 66px; }
.exp-row + .exp-row { border-top: 1px solid var(--border); }
.exp-row:hover { background: var(--surface-2); }
.exp-row .who { font-size: .8125rem; color: var(--ink-3); margin-top: 2px; display: flex; align-items: center; gap: 5px; }
.exp-row .title { font-weight: 600; font-size: .9375rem; }
.exp-row .end { margin-left: auto; text-align: right; }
.exp-row .end .amt { font-weight: 700; font-size: .9375rem; }
.exp-row .end .delta { font-size: .75rem; font-weight: 650; margin-top: 2px; }
.exp-row.settled .tile { background: var(--pos-soft); color: var(--pos-ink); }

.detail-block { background: var(--surface-2); border-radius: var(--r-lg); padding: 14px; }
.detail-line { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: .9375rem; }
.detail-line + .detail-line { border-top: 1px dashed var(--border); }
.note-box { display: flex; gap: 8px; background: var(--warn-soft); color: var(--warn-ink); border-radius: var(--r); padding: 10px 12px; font-size: .875rem; }
.note-box span { white-space: pre-wrap; overflow-wrap: anywhere; }

.comment { display: flex; gap: 10px; margin-bottom: 12px; }
.comment .bubble { background: var(--surface-2); border-radius: 4px 14px 14px 14px; padding: 9px 12px; flex: 1; min-width: 0; }
.comment .meta { display: flex; justify-content: space-between; gap: 8px; font-size: .75rem; color: var(--ink-3); margin-bottom: 2px; }
.comment p { font-size: .875rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { display: flex; gap: 8px; align-items: center; }
.comment-form .input { min-height: 44px; }

/* ============================================================
   Charts
   ============================================================ */

.chart { position: relative; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 104px; margin: 6px 0 4px; }
.bar-slot { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; position: relative; }
.bar-slot .bar-val { font-size: .6875rem; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.bar {
  width: 100%; max-width: 24px; border-radius: 4px 4px 0 0; background: color-mix(in srgb, var(--brand) 28%, var(--surface-2));
  min-height: 3px; transition: background .15s;
}
.bar.now { background: var(--brand); }
.bar-slot:hover .bar { background: var(--brand-strong); }
.bar-axis { display: flex; gap: 2px; border-top: 1px solid var(--border); padding-top: 6px; }
.bar-axis span { flex: 1; text-align: center; font-size: .6875rem; color: var(--ink-3); font-weight: 600; }

.catbar { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; padding: 7px 0; }
.catbar .track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.catbar .fill { display: block; height: 100%; border-radius: 4px; background: var(--brand); }
.catbar .nm { font-size: .8125rem; margin-bottom: 4px; color: var(--ink-2); }
.catbar .v { font-size: .8125rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.tip {
  position: absolute; z-index: 5; transform: translate(-50%, -100%); pointer-events: none;
  background: #1A2031; color: #fff; padding: 6px 10px; border-radius: 8px; font-size: .75rem; font-weight: 600; white-space: nowrap;
  box-shadow: var(--shadow); opacity: 0; transition: opacity .12s;
}
.tip.show { opacity: 1; }

/* ============================================================
   QR
   ============================================================ */

.qr-box { text-align: center; }
.qr-box .frame {
  display: inline-block; padding: 14px; border-radius: var(--r-xl); background: #fff;
  box-shadow: var(--shadow); border: 1px solid var(--border);
}
.qr-box img { width: min(230px, 62vw); height: min(230px, 62vw); display: block; }
.copy-row { display: flex; gap: 8px; margin-top: 16px; }
.copy-row input { flex: 1; min-width: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 11px 13px; font-size: .8125rem; color: var(--ink-3); }
.note {
  display: flex; gap: 8px; text-align: left; font-size: .8125rem; color: var(--ink-2);
  background: var(--warn-soft); border-radius: var(--r); padding: 11px 13px; margin-top: 14px;
}

/* ============================================================
   Tabs
   ============================================================ */

.tabs { display: flex; gap: 6px; padding: 3px; background: var(--surface-2); border-radius: var(--pill); }
.tabs button {
  flex: 1; border: 0; background: none; border-radius: var(--pill); min-height: 38px; font-size: .875rem; font-weight: 650;
  color: var(--ink-3);
}
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ============================================================
   Desktop
   ============================================================ */

@media (min-width: 900px) {
  :root { --appbar-h: 64px; }
  body { display: grid; grid-template-columns: 250px minmax(0, 1fr); }
  .tabbar { display: none; }
  .rail {
    display: flex; flex-direction: column; gap: 4px; padding: 20px 14px; position: sticky; top: 0;
    height: 100svh; border-right: 1px solid var(--border); background: var(--surface);
  }
  .rail .brandmark { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
  .rail .brandmark img { width: 38px; height: 38px; border-radius: 12px; }
  .rail .brandmark b { font-family: var(--font-display); font-size: 1.25rem; letter-spacing: -.02em; }
  .rail a {
    display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: var(--r);
    color: var(--ink-2); font-weight: 600; font-size: .9375rem;
  }
  .rail a:hover { background: var(--surface-2); color: var(--ink); }
  .rail a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); }
  .rail .spacer { flex: 1; }
  .rail .btn { margin-top: 10px; }
  .appbar { padding-left: 24px; padding-right: 16px; background: transparent; backdrop-filter: none; }
  .page { max-width: 1040px; padding: 8px 24px 48px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .page.two-col { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); align-items: start; }
  .page.two-col > * { margin-top: 0; }
  .page.two-col .col { gap: 24px; }
  .page > .col + .col { margin-top: 0; }
  .scrim { align-items: center; padding: 24px; }
  .sheet { max-width: 540px; border-radius: var(--r-xl); max-height: 86svh; animation: pop .2s cubic-bezier(.22, 1, .36, 1); }
  @keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
  .sheet-grip { display: none; }
  .sheet-foot { border-radius: 0 0 var(--r-xl) var(--r-xl); padding-bottom: 14px; }
  .toast .ic { width: 18px; height: 18px; vertical-align: 0; }
.toast { bottom: 28px; }
  .hero-amount { font-size: 3rem; }
}

@media (min-width: 640px) and (max-width: 899px) {
  .page { max-width: 620px; }
}
