:root {
  color-scheme: light dark;
  --bg: #f5f6f0;
  --surface: #ffffff;
  --surface-soft: #edf4ee;
  --surface-elevated: #ffffff;
  --text: #17211b;
  --muted: #6f7c74;
  --line: #dfe7e0;
  --primary: #0f8f60;
  --primary-deep: #08734c;
  --primary-soft: #dff3e9;
  --accent: #f1b63c;
  --accent-soft: #fff2cf;
  --danger: #db635d;
  --danger-soft: #fce9e7;
  --shadow: 0 12px 32px rgba(34, 61, 45, 0.08);
  --shadow-soft: 0 4px 16px rgba(34, 61, 45, 0.06);
  --nav-bg: rgba(255, 255, 255, 0.92);
  --hero-1: #0b8458;
  --hero-2: #0a6a49;
  --hero-text: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c1410;
    --surface: #132019;
    --surface-soft: #192a21;
    --surface-elevated: #18271f;
    --text: #f1f6f2;
    --muted: #9aaba0;
    --line: #293a30;
    --primary: #48c990;
    --primary-deep: #32ac77;
    --primary-soft: #173d2c;
    --accent: #f3bd50;
    --accent-soft: #493a19;
    --danger: #f08079;
    --danger-soft: #472724;
    --shadow: 0 16px 42px rgba(0, 0, 0, 0.24);
    --shadow-soft: 0 6px 20px rgba(0, 0, 0, 0.18);
    --nav-bg: rgba(19, 32, 25, 0.94);
    --hero-1: #16734f;
    --hero-2: #105e41;
  }
}

:root[data-theme="dark"] {
  --bg: #0c1410;
  --surface: #132019;
  --surface-soft: #192a21;
  --surface-elevated: #18271f;
  --text: #f1f6f2;
  --muted: #9aaba0;
  --line: #293a30;
  --primary: #48c990;
  --primary-deep: #32ac77;
  --primary-soft: #173d2c;
  --accent: #f3bd50;
  --accent-soft: #493a19;
  --danger: #f08079;
  --danger-soft: #472724;
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.24);
  --shadow-soft: 0 6px 20px rgba(0, 0, 0, 0.18);
  --nav-bg: rgba(19, 32, 25, 0.94);
  --hero-1: #16734f;
  --hero-2: #105e41;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 15% 0%, color-mix(in srgb, var(--primary) 10%, transparent) 0, transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button { color: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; touch-action: manipulation; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.auth-shell {
  min-height: 100dvh; padding: calc(24px + env(safe-area-inset-top)) 18px calc(24px + env(safe-area-inset-bottom));
  display: grid; place-items: center;
}
.auth-card {
  width: min(100%, 430px); padding: 26px 22px; border: 1px solid var(--line); border-radius: 28px;
  background: color-mix(in srgb, var(--surface) 95%, transparent); box-shadow: var(--shadow); backdrop-filter: blur(18px);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 34px; }
.auth-brand strong, .auth-brand small { display: block; }
.auth-brand strong { font-size: 1.05rem; }
.auth-brand small { color: var(--muted); font-size: .75rem; margin-top: 3px; }
.auth-card h1 { margin: 6px 0 8px; font-size: 2rem; letter-spacing: -.045em; }
.auth-lead { margin: 0 0 22px; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1.4fr; gap: 4px; padding: 4px; margin-bottom: 18px; border-radius: 15px; background: var(--surface-soft); }
.auth-tabs:has(button[hidden]) { grid-template-columns: 1fr; }
.auth-tabs button { min-height: 42px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-size: .84rem; font-weight: 750; }
.auth-tabs button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-soft); }
.auth-form { display: grid; gap: 14px; }
.auth-form label { display: grid; gap: 7px; color: var(--muted); font-size: .76rem; font-weight: 700; }
.auth-form input {
  width: 100%; min-height: 52px; border: 1px solid var(--line); border-radius: 15px; padding: 0 14px;
  outline: 0; background: var(--surface); color: var(--text); font-size: 1rem;
}
.auth-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }
.auth-form label small { font-size: .68rem; font-weight: 500; }
.auth-form .submit-button { margin-top: 2px; }
.auth-link { justify-self: center; border: 0; background: transparent; color: var(--primary); padding: 5px; font-size: .78rem; font-weight: 750; }
.auth-status { min-height: 20px; margin: 14px 0 0; color: var(--muted); font-size: .76rem; line-height: 1.45; text-align: center; }
.danger-row strong, .danger-row .setting-symbol { color: var(--danger); }

.app-shell { min-height: 100vh; }
.desktop-sidebar, .desktop-insights { display: none; }
.main-column { width: 100%; max-width: 540px; margin: 0 auto; padding: 0 18px 112px; }
.mobile-header {
  min-height: calc(82px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: env(safe-area-inset-top);
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 13px;
  background: var(--primary); color: #fff; box-shadow: 0 7px 18px color-mix(in srgb, var(--primary) 26%, transparent);
}
.brand-mark svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.nav-icon svg, .tab-icon svg, .chat-notification-button svg, .attach-button svg, .send-button svg, .attachment-option-icon svg, .setting-symbol svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 0.95rem; letter-spacing: -.02em; }
.brand small { color: var(--muted); font-size: 0.69rem; margin-top: 2px; }
.avatar-button, .large-avatar, .mini-avatar {
  border: 0; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 800; display: grid; place-items: center;
}
.avatar-button { width: 40px; height: 40px; }

.screen { display: none; animation: screenIn .28s ease; }
.screen.is-active { display: block; }
@keyframes screenIn { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 12px 0 20px; }
.page-heading h1 { font-size: clamp(1.75rem, 7vw, 2.25rem); line-height: 1.08; letter-spacing: -.045em; margin: 3px 0 0; }
.eyebrow { color: var(--primary); font-size: .82rem; font-weight: 800; letter-spacing: .02em; margin: 0; }
.icon-button { width: 44px; height: 44px; border: 1px solid var(--line); background: var(--surface); border-radius: 15px; box-shadow: var(--shadow-soft); position: relative; }
.notification-button span { font-size: 1.3rem; transform: rotate(-12deg); display: block; }
.notification-button i { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); right: 8px; top: 8px; }

.month-switcher { display: flex; align-items: center; justify-content: center; gap: 13px; margin-bottom: 14px; }
.month-arrow { width: 34px; height: 34px; border: 0; border-radius: 11px; background: var(--surface); box-shadow: var(--shadow-soft); font-size: 1.45rem; }
.month-arrow:disabled { opacity: .3; cursor: default; }
.month-label { border: 0; background: transparent; font-weight: 750; min-width: 140px; }
.month-label span { color: var(--muted); font-size: .8rem; margin-left: 3px; }
.segment-control, .type-toggle, .plan-tabs {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; background: var(--surface-soft); border-radius: 15px; margin-bottom: 16px;
}
.segment-control button, .type-toggle button, .plan-tabs button {
  border: 0; background: transparent; color: var(--muted); min-height: 38px; border-radius: 11px; font-size: .85rem; font-weight: 700;
}
.segment-control button.is-active, .type-toggle button.is-active, .plan-tabs button.is-active {
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-soft);
}

.summary-card {
  min-height: 276px; padding: 22px; color: var(--hero-text); border-radius: 29px;
  background: linear-gradient(145deg, var(--hero-1), var(--hero-2));
  box-shadow: 0 22px 45px color-mix(in srgb, var(--primary-deep) 25%, transparent);
  position: relative; overflow: hidden;
}
.summary-glow { position: absolute; width: 170px; height: 170px; border-radius: 50%; background: rgba(255,255,255,.09); filter: blur(3px); top: -90px; right: -35px; }
.summary-top, .summary-stats { display: flex; justify-content: space-between; align-items: flex-start; position: relative; z-index: 1; }
.summary-top p { opacity: .78; margin: 0 0 5px; font-size: .82rem; }
.summary-top strong { font-size: 2rem; letter-spacing: -.04em; }
.trend-pill { border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.12); border-radius: 999px; padding: 7px 9px; font-size: .72rem; font-weight: 800; }
.pulse-chart { height: 95px; margin: 14px -22px 7px; }
.pulse-chart svg { width: 100%; height: 100%; overflow: visible; }
.chart-fill { fill: url(#pulseFill); }
.chart-line { fill: none; stroke: rgba(255,255,255,.92); stroke-width: 2.4; vector-effect: non-scaling-stroke; }
.pulse-chart circle { fill: var(--accent); stroke: #fff; stroke-width: 2; }
.summary-stats { border-top: 1px solid rgba(255,255,255,.15); padding-top: 15px; }
.summary-stats > div { display: grid; grid-template-columns: 9px 1fr; column-gap: 7px; align-items: center; }
.summary-stats small { opacity: .7; font-size: .71rem; }
.summary-stats strong { grid-column: 1 / -1; font-size: .92rem; margin-top: 3px; }
.stat-dot { width: 8px; height: 8px; border-radius: 3px; display: block; }
.stat-dot.income { background: #8fe3ba; }
.stat-dot.expense { background: var(--accent); }

.quick-actions { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 16px 0 28px; }
.action-button {
  min-height: 72px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-soft);
  display: flex; align-items: center; gap: 13px; padding: 12px 14px; text-align: left;
}
.action-button.primary { color: var(--bg); background: var(--text); border-color: transparent; }
.action-icon { width: 43px; height: 43px; border-radius: 14px; background: var(--primary); color: #fff; font-size: 1.65rem; display: grid; place-items: center; flex: none; }
.action-button.primary .action-icon { background: var(--accent); color: #3c2a03; }
.action-button strong, .action-button small { display: block; }
.action-button strong { font-size: .91rem; }
.action-button small { font-size: .72rem; color: var(--muted); margin-top: 3px; }
.action-button.primary small { color: color-mix(in srgb, var(--bg) 72%, transparent); }

.content-section { margin: 0 0 28px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.section-heading h2, .settings-group h2 { margin: 0; font-size: 1.15rem; letter-spacing: -.025em; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: .76rem; }
.text-button { background: transparent; border: 0; color: var(--primary); font-size: .8rem; font-weight: 800; padding: 7px 0 7px 14px; }
.budget-list { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 4px 14px; box-shadow: var(--shadow-soft); }
.budget-item { display: grid; grid-template-columns: 43px minmax(0,1fr) 40px; gap: 11px; align-items: center; min-height: 78px; border-bottom: 1px solid var(--line); }
.budget-item:last-child { border-bottom: 0; }
.category-icon { width: 43px; height: 43px; border-radius: 14px; display: grid; place-items: center; flex: none; font-weight: 800; }
.category-icon.groceries { color: #08734c; background: #dff3e9; }
.category-icon.cafe { color: #a66b06; background: #fff0ce; }
.category-icon.transport { color: #4b64a3; background: #e8edff; }
.category-icon.salary { color: #08734c; background: #dff3e9; }
.category-icon.health { color: #b74b45; background: #fce9e7; }
.budget-body { min-width: 0; }
.budget-body > div:first-child { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 9px; }
.budget-body strong { font-size: .86rem; }
.budget-body span { color: var(--muted); font-size: .66rem; white-space: nowrap; }
.progress-track, .goal-progress { height: 6px; background: var(--surface-soft); border-radius: 999px; overflow: hidden; }
.progress-track i, .goal-progress i { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.budget-percent { font-size: .74rem; font-weight: 800; text-align: right; color: var(--primary); }
.budget-percent.warning { color: #b6780a; }

.goal-card { padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow-soft); }
.goal-top { display: flex; gap: 12px; align-items: center; }
.goal-icon { width: 48px; height: 48px; border-radius: 16px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 1.25rem; flex: none; }
.goal-icon.amber { background: var(--accent-soft); color: #a66b06; }
.goal-top > div { min-width: 0; flex: 1; }
.goal-top h3 { margin: 3px 0 2px; font-size: .94rem; }
.goal-top p { margin: 0; color: var(--muted); font-size: .7rem; }
.goal-top > strong { color: var(--primary); font-size: .86rem; }
.scope-badge { display: inline-block; background: var(--primary-soft); color: var(--primary); border-radius: 999px; padding: 3px 7px; font-size: .58rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.scope-badge.personal { color: #9a690d; background: var(--accent-soft); }
.goal-progress { margin: 17px 0 10px; height: 8px; }
.goal-progress.amber i { background: var(--accent); }
.goal-values { display: flex; align-items: baseline; gap: 5px; }
.goal-values strong { font-size: .95rem; }
.goal-values span { color: var(--muted); font-size: .72rem; }
.goal-hint { margin: 13px 0 0; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: .71rem; line-height: 1.45; }

.payment-card { display: grid; grid-template-columns: 48px minmax(0,1fr) auto; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 15px; box-shadow: var(--shadow-soft); }
.payment-date { width: 48px; height: 55px; background: var(--accent-soft); color: #94620c; border-radius: 15px; display: grid; place-items: center; align-content: center; }
.payment-date strong, .payment-date span { display: block; line-height: 1; }
.payment-date strong { font-size: 1.05rem; }
.payment-date span { text-transform: uppercase; font-size: .58rem; margin-top: 4px; font-weight: 800; }
.payment-info strong, .payment-info small { display: block; }
.payment-info strong { font-size: .88rem; margin: 5px 0 2px; }
.payment-info small { color: var(--muted); font-size: .66rem; }
.payment-sum { text-align: right; }
.payment-sum strong { display: block; font-size: .82rem; margin-bottom: 6px; white-space: nowrap; }
.payment-sum button { border: 0; background: transparent; padding: 0; color: var(--primary); font-size: .67rem; font-weight: 800; }
.payment-card.confirmed { opacity: .72; }

.transaction-list { background: var(--surface); border-radius: 22px; border: 1px solid var(--line); padding: 3px 14px; box-shadow: var(--shadow-soft); }
.transaction-row { min-height: 70px; display: grid; grid-template-columns: 43px minmax(0,1fr) auto; gap: 11px; align-items: center; border-bottom: 1px solid var(--line); }
.transaction-row:last-child { border-bottom: 0; }
.transaction-row strong, .transaction-row small { display: block; }
.transaction-row strong { font-size: .86rem; }
.transaction-row small { color: var(--muted); margin-top: 3px; font-size: .68rem; }
.transaction-amount { font-size: .82rem; font-weight: 800; white-space: nowrap; }
.transaction-amount.expense { color: var(--text); }
.transaction-amount.income { color: var(--primary); }

.bottom-nav {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: calc(76px + env(safe-area-inset-bottom));
  padding: 8px 12px env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5,1fr);
  background: var(--nav-bg); border-top: 1px solid var(--line); backdrop-filter: blur(18px);
}
.bottom-nav button { border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); }
.bottom-nav button small { font-size: .62rem; font-weight: 700; }
.bottom-nav button.is-active { color: var(--primary); }
.tab-icon { width: 28px; height: 28px; display: grid; place-items: center; position: relative; }
.tab-icon svg { width: 24px; height: 24px; }
.tab-badge { position: absolute; top: -4px; right: -8px; min-width: 18px; height: 18px; border: 2px solid var(--nav-bg); border-radius: 999px; display: grid; place-items: center; padding: 0 4px; background: var(--accent); color: #352400; font-size: .56rem; font-weight: 900; font-style: normal; }
.tab-badge[hidden], .nav-badge[hidden] { display: none; }

.subpage-heading { margin-top: 16px; }
.round-add { width: 46px; height: 46px; border-radius: 16px; border: 0; background: var(--primary); color: #fff; font-size: 1.6rem; box-shadow: 0 9px 20px color-mix(in srgb, var(--primary) 25%, transparent); }
.search-field { height: 51px; display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 17px; padding: 0 15px; box-shadow: var(--shadow-soft); }
.search-field span { color: var(--muted); font-size: 1.2rem; }
.search-field input { border: 0; outline: 0; background: transparent; color: var(--text); min-width: 0; flex: 1; font-size: .9rem; }
.filter-chips { display: flex; gap: 8px; overflow-x: auto; margin: 14px -18px 23px; padding: 0 18px; scrollbar-width: none; }
.filter-chips::-webkit-scrollbar { display: none; }
.filter-chips button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 9px 14px; white-space: nowrap; font-size: .76rem; font-weight: 700; }
.filter-chips button.is-active { color: var(--bg); background: var(--text); border-color: var(--text); }
.day-group { margin-bottom: 23px; }
.day-heading { display: flex; justify-content: space-between; align-items: center; margin: 0 3px 10px; }
.day-heading strong { font-size: .8rem; }
.day-heading span { color: var(--muted); font-size: .75rem; }
.card-list { padding-top: 3px; }
.transaction-row[hidden] { display: none; }

.plan-tabs { margin: 0 0 20px; }
.plan-panel { display: none; animation: screenIn .23s ease; }
.plan-panel.is-active { display: block; }
.planning-summary { color: #fff; background: linear-gradient(145deg, var(--hero-1), var(--hero-2)); border-radius: 24px; padding: 22px; margin-bottom: 16px; }
.planning-summary span, .planning-summary strong, .planning-summary small { display: block; }
.planning-summary span { font-size: .76rem; opacity: .75; }
.planning-summary strong { font-size: 1.7rem; letter-spacing: -.035em; margin: 6px 0 3px; }
.planning-summary small { opacity: .65; font-size: .68rem; }
.planning-summary .goal-progress { background: rgba(255,255,255,.18); margin-bottom: 0; }
.planning-summary .goal-progress i { background: var(--accent); }
.standalone { margin-bottom: 20px; }
.large-goal { margin-bottom: 12px; padding: 20px; }
.secondary-button { margin-top: 16px; min-height: 44px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); color: var(--text); padding: 0 16px; font-weight: 800; font-size: .8rem; }
.secondary-button.wide { width: 100%; }
.regular-card { display: grid; grid-template-columns: 45px 1fr auto; gap: 12px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-soft); margin-bottom: 10px; }
.regular-date { width: 45px; height: 45px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: #98620a; font-weight: 850; }
.regular-card strong, .regular-card small { display: block; }
.regular-card strong { margin: 5px 0 2px; font-size: .86rem; }
.regular-card small { color: var(--muted); font-size: .69rem; }
.more-button { border: 0; background: transparent; color: var(--muted); letter-spacing: 2px; }

.family-profile-card { display: grid; grid-template-columns: 62px 1fr auto; gap: 14px; align-items: center; padding: 18px; border-radius: 22px; background: linear-gradient(135deg, var(--primary-soft), var(--surface)); border: 1px solid var(--line); margin-bottom: 25px; }
.large-avatar { width: 62px; height: 62px; font-size: 1.3rem; }
.family-profile-card strong, .family-profile-card span { display: block; }
.family-profile-card strong { font-size: 1rem; }
.family-profile-card span { color: var(--muted); font-size: .76rem; margin-top: 4px; }
.edit-button { width: 36px; height: 36px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.settings-group { margin-bottom: 23px; }
.settings-group h2 { font-size: .86rem; margin: 0 4px 9px; }
.setting-row { width: 100%; min-height: 68px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 11px; text-align: left; padding: 10px 14px; }
.settings-group .setting-row:first-of-type { border-radius: 18px 18px 0 0; }
.settings-group .setting-row:last-child { border-radius: 0 0 18px 18px; border-bottom: 0; }
.settings-group .setting-row:only-of-type { border-radius: 18px; }
.mini-avatar { width: 38px; height: 38px; }
.mini-avatar.second { color: #9a690d; background: var(--accent-soft); }
.setting-symbol { width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; background: var(--surface-soft); color: var(--primary); font-weight: 800; }
.setting-row strong, .setting-row small { display: block; }
.setting-row strong { font-size: .85rem; }
.setting-row small { color: var(--muted); font-size: .69rem; margin-top: 3px; }
.setting-row i { color: var(--muted); font-style: normal; font-size: 1.2rem; }
.theme-setting select { border: 0; background: var(--surface-soft); color: var(--text); border-radius: 10px; padding: 8px; font-size: .73rem; font-weight: 700; max-width: 112px; }

.chat-screen.is-active { min-height: calc(100dvh - 194px); display: flex; flex-direction: column; }
.chat-header {
  min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 4px 0 13px; border-bottom: 1px solid var(--line);
}
.chat-person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.chat-avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: #9a690d; font-weight: 850; flex: none; }
.chat-person h1 { margin: 0; font-size: 1rem; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-person p { display: flex; align-items: center; gap: 5px; margin: 4px 0 0; color: var(--muted); font-size: .7rem; }
.chat-person p i { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
.chat-notification-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 14px; display: grid; place-items: center; background: var(--surface); color: var(--primary); flex: none; }
.chat-notification-button.is-muted { color: var(--muted); }
.chat-date { display: flex; align-items: center; justify-content: center; margin: 18px 0 8px; }
.chat-date span { padding: 6px 10px; border-radius: 999px; color: var(--muted); background: var(--surface-soft); font-size: .66rem; font-weight: 750; }
.messages { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 4px 0 22px; min-height: 320px; }
.message { max-width: 82%; border-radius: 19px 19px 19px 6px; padding: 10px 12px 7px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-soft); animation: messageIn .2s ease; }
.message.outgoing { align-self: flex-end; border-radius: 19px 19px 6px 19px; background: var(--primary); color: #fff; border-color: transparent; }
.message p { margin: 0; font-size: .88rem; line-height: 1.38; }
.message time { display: block; margin-top: 5px; color: var(--muted); font-size: .58rem; text-align: right; }
.message.outgoing time { color: rgba(255,255,255,.72); }
.message.outgoing time span { color: #d8ffea; margin-left: 3px; }
.message.image-message { padding: 4px; overflow: hidden; }
.message.image-message img { display: block; width: min(260px, 68vw); max-height: 320px; object-fit: cover; border-radius: 15px; }
.message.image-message time { padding: 0 6px 3px; }
@keyframes messageIn { from { opacity: 0; transform: translateY(5px) scale(.98); } to { opacity: 1; transform: none; } }
.chat-composer {
  position: sticky; z-index: 20; bottom: calc(76px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: 44px minmax(0,1fr) 44px; gap: 8px; align-items: end;
  padding: 10px 0; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(18px);
}
.chat-input { min-width: 0; margin: 0; }
.chat-input textarea { display: block; width: 100%; min-height: 44px; max-height: 112px; resize: none; border: 1px solid var(--line); border-radius: 19px; outline: none; background: var(--surface); color: var(--text); padding: 11px 13px; font-size: 1rem; line-height: 1.28; }
.chat-input textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }
.attach-button, .send-button { width: 44px; height: 44px; border: 0; border-radius: 16px; display: grid; place-items: center; }
.attach-button { color: var(--primary); background: var(--surface-soft); }
.send-button { color: #fff; background: var(--primary); box-shadow: 0 7px 16px color-mix(in srgb, var(--primary) 24%, transparent); }
.attachment-menu {
  position: absolute; z-index: 5; left: 0; bottom: 68px; width: min(310px, calc(100vw - 36px)); padding: 8px;
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface-elevated); box-shadow: var(--shadow);
}
.attachment-menu button { width: 100%; min-height: 64px; display: grid; grid-template-columns: 42px 1fr; align-items: center; gap: 11px; border: 0; border-radius: 14px; background: transparent; padding: 8px; text-align: left; }
.attachment-menu button:active { background: var(--surface-soft); }
.attachment-menu strong, .attachment-menu small { display: block; }
.attachment-menu strong { font-size: .82rem; }
.attachment-menu small { color: var(--muted); font-size: .67rem; margin-top: 3px; }
.attachment-option-icon { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); }
.attachment-option-icon.amber { color: #9a690d; background: var(--accent-soft); }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; display: grid; place-items: center; background: var(--accent); color: #332200; font-size: .62rem; font-weight: 850; }

.sheet-backdrop { position: fixed; z-index: 60; inset: 0; background: rgba(4,12,8,.55); backdrop-filter: blur(4px); }
.bottom-sheet {
  position: fixed; z-index: 70; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow-y: auto;
  background: var(--surface-elevated); border-radius: 28px 28px 0 0; padding: 14px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 60px rgba(0,0,0,.22); animation: sheetUp .28s cubic-bezier(.2,.8,.2,1);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet-handle { width: 42px; height: 5px; border-radius: 999px; background: var(--line); margin: 0 auto 12px; }
.sheet-close { position: absolute; right: 17px; top: 18px; width: 34px; height: 34px; border: 0; border-radius: 11px; background: var(--surface-soft); font-size: 1.3rem; }
.sheet-view { max-width: 480px; margin: 0 auto; }
.sheet-view h2 { margin: 4px 0 20px; font-size: 1.5rem; letter-spacing: -.035em; }
.sheet-choice-list { display: grid; gap: 10px; }
.sheet-choice { display: grid; grid-template-columns: 46px 1fr auto; align-items: center; gap: 12px; min-height: 76px; padding: 12px; border: 1px solid var(--line); background: var(--surface); border-radius: 18px; text-align: left; }
.choice-icon { width: 44px; height: 44px; border-radius: 14px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 1.3rem; }
.choice-icon.amber { background: var(--accent-soft); color: #9a690d; }
.sheet-choice strong, .sheet-choice small { display: block; }
.sheet-choice strong { font-size: .88rem; }
.sheet-choice small { color: var(--muted); font-size: .68rem; margin-top: 3px; }
.sheet-choice i { font-size: 1.2rem; color: var(--muted); font-style: normal; }
.type-toggle { grid-template-columns: 1fr 1fr; margin-bottom: 18px; }
.sheet-view label { display: block; margin-bottom: 14px; }
.sheet-view label > span { display: block; font-size: .72rem; color: var(--muted); font-weight: 700; margin: 0 0 7px 2px; }
.sheet-view input, .sheet-view select { width: 100%; height: 51px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); outline: 0; padding: 0 13px; }
.sheet-view input:focus, .sheet-view select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent); }
.amount-field > div { display: flex; align-items: center; border: 1px solid var(--line); background: var(--surface); border-radius: 17px; padding-right: 15px; }
.amount-field > div:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent); }
.amount-field input { border: 0; box-shadow: none !important; font-size: 2rem; font-weight: 800; letter-spacing: -.04em; }
.amount-field b { font-size: 1.25rem; color: var(--muted); }
.amount-field.compact input { font-size: 1.3rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.submit-button { width: 100%; min-height: 53px; border: 0; border-radius: 16px; background: var(--primary); color: #fff; font-weight: 850; margin-top: 5px; box-shadow: 0 10px 22px color-mix(in srgb, var(--primary) 24%, transparent); }
.receipt-scanner { height: 280px; border-radius: 24px; background: linear-gradient(145deg, #24362c, #0c1711); display: grid; place-items: center; align-content: center; position: relative; overflow: hidden; margin-bottom: 14px; color: #fff; }
.receipt-scanner:before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 45%, rgba(255,255,255,.12), transparent 55%); }
.receipt-scanner.scanning:after { content: ""; position: absolute; z-index: 3; left: 12%; right: 12%; height: 2px; background: var(--accent); box-shadow: 0 0 16px var(--accent); animation: scanReceipt 1s ease-in-out infinite alternate; }
@keyframes scanReceipt { from { top: 18%; } to { top: 78%; } }
.receipt-scanner p { position: relative; z-index: 2; margin: 15px 0 0; font-size: .74rem; opacity: .75; }
.receipt-paper { width: 100px; height: 150px; background: #fff; border-radius: 7px; padding: 24px 15px; box-shadow: 0 15px 30px rgba(0,0,0,.25); position: relative; color: #173125; }
.receipt-paper:after { content:""; position:absolute; left:0; right:0; bottom:-5px; height:10px; background: linear-gradient(135deg,transparent 5px,#fff 0) 0 0/10px 10px repeat-x; }
.receipt-paper div { height: 5px; background: #d9e2dc; border-radius: 4px; margin-bottom: 11px; }
.receipt-paper div:nth-child(2) { width: 68%; }
.receipt-paper strong { display: grid; place-items: center; margin: 22px auto 0; border: 2px solid #0f8f60; border-radius: 50%; width: 34px; height: 34px; }
.recognized-badge { display: inline-flex; background: var(--primary-soft); color: var(--primary); padding: 7px 10px; border-radius: 999px; font-size: .7rem; font-weight: 800; margin-bottom: 5px; }
.ai-note { display: flex; gap: 7px; align-items: center; margin: 3px 0 12px; padding: 11px; border-radius: 13px; background: var(--primary-soft); color: var(--primary); font-size: .7rem; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: 94px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; display: flex; align-items: center; gap: 9px; width: max-content; max-width: calc(100vw - 32px); background: var(--text); color: var(--bg); border-radius: 15px; padding: 11px 15px; box-shadow: var(--shadow); transition: .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast span { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--primary); color: #fff; font-size: .75rem; }
.toast p { margin: 0; font-size: .8rem; font-weight: 750; }

.desktop-insights .insights-sticky { position: sticky; top: 30px; }
.insight-title { display: flex; gap: 11px; align-items: center; }
.insight-title strong, .insight-title small { display: block; }
.insight-title strong { font-size: .95rem; }
.insight-title small { font-size: .7rem; color: var(--muted); margin-top: 3px; }
.pulse-mini { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; background: var(--primary); color: #fff; font-size: 1.5rem; }
.ring-wrap { width: 185px; height: 185px; margin: 24px auto 17px; position: relative; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg, .ring-value { fill: none; stroke-width: 10; }
.ring-bg { stroke: var(--surface-soft); }
.ring-value { stroke: var(--primary); stroke-linecap: round; stroke-dasharray: 79 21; }
.ring-wrap > div { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; }
.ring-wrap strong, .ring-wrap small { display: block; }
.ring-wrap strong { font-size: 2rem; letter-spacing: -.04em; }
.ring-wrap small { color: var(--muted); font-size: .7rem; margin-top: 4px; }
.insight-copy { font-size: .8rem; line-height: 1.55; text-align: center; color: var(--muted); padding: 0 8px 15px; border-bottom: 1px solid var(--line); }
.mini-stat { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.mini-stat span { font-size: .72rem; color: var(--muted); }
.mini-stat strong { font-size: .8rem; }

@media (min-width: 420px) {
  .quick-actions { grid-template-columns: 1fr 1fr; }
  .action-button { padding: 12px; }
}

@media (min-width: 960px) {
  .app-shell { max-width: 1180px; margin: 0 auto; padding: 0 25px; display: grid; grid-template-columns: 220px minmax(480px, 560px) 260px; gap: 34px; align-items: start; }
  .desktop-sidebar { display: flex; flex-direction: column; min-height: 100vh; position: sticky; top: 0; padding: 30px 0; }
  .brand-mark { width: 42px; height: 42px; }
  .brand strong { font-size: 1.03rem; }
  .side-nav { display: grid; gap: 6px; margin-top: 54px; }
  .nav-item { border: 0; background: transparent; min-height: 48px; border-radius: 15px; display: flex; align-items: center; gap: 13px; color: var(--muted); padding: 0 14px; font-weight: 750; font-size: .85rem; }
  .nav-item.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-soft); }
  .nav-icon { width: 26px; display: grid; place-items: center; }
  .chat-screen.is-active { min-height: calc(100vh - 58px); }
  .chat-composer { bottom: 0; }
  .sidebar-family { margin-top: auto; display: flex; align-items: center; gap: 11px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
  .avatar-stack { display: flex; }
  .avatar-stack span { width: 31px; height: 31px; border: 2px solid var(--surface); border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: .66rem; font-weight: 800; }
  .avatar-stack span + span { margin-left: -10px; background: var(--accent-soft); color: #97620b; }
  .sidebar-family strong, .sidebar-family small { display: block; }
  .sidebar-family strong { font-size: .76rem; }
  .sidebar-family small { font-size: .63rem; color: var(--muted); margin-top: 3px; }
  .main-column { max-width: none; padding: 28px 0 70px; }
  .mobile-header, .bottom-nav { display: none; }
  .page-heading { margin-top: 0; }
  .desktop-insights { display: block; padding-top: 30px; }
  .insights-sticky { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 18px; box-shadow: var(--shadow-soft); }
  .summary-card { min-height: 286px; }
  .bottom-sheet { left: 50%; right: auto; width: 520px; transform: translateX(-50%); border-radius: 28px; bottom: 28px; }
  @keyframes sheetUp { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
  .toast { bottom: 28px; }
}

@media (max-width: 370px) {
  .main-column { padding-left: 14px; padding-right: 14px; }
  .summary-card { padding: 18px; }
  .summary-top strong { font-size: 1.75rem; }
  .budget-item { grid-template-columns: 39px minmax(0,1fr); }
  .budget-percent { display: none; }
  .category-icon { width: 39px; height: 39px; }
  .payment-card { grid-template-columns: 44px minmax(0,1fr); }
  .payment-sum { grid-column: 2; text-align: left; display: flex; gap: 10px; align-items: center; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
}

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

@supports (-webkit-touch-callout: none) {
  input, select, textarea { font-size: 16px; }
}
