:root {
  --bg: #FAF5FF;
  --card: #FFFFFF;
  --text: #1E1B2E;
  --muted: #6B7280;
  --line: #EDE4FF;
  --primary: #7C3AED;
  --primary-dark: #6D28D9;
  --accent: #EC4899;
  --green: #10B981;
  --green-bg: #D1FAE5;
  --red: #EF4444;
  --red-bg: #FEE2E2;
  --amber: #F59E0B;
  --amber-bg: #FEF3C7;
  --blue: #3B82F6;
  --blue-bg: #DBEAFE;
  --shadow-sm: 0 2px 6px rgba(124, 58, 237, .08);
  --shadow-md: 0 10px 30px rgba(124, 58, 237, .14);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-family: Inter, ui-sans-serif, system-ui, sans-serif; color: var(--text); font-size: 15px; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.page { max-width: 480px; margin: 0 auto; padding: 16px 16px 90px; }

header.app-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: linear-gradient(135deg, var(--primary), var(--accent)); position: sticky; top: 0; z-index: 10; }
header.app-header .brand { font-weight: 800; color: #fff; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
header.app-header .brand img { width: 28px; height: 28px; border-radius: 8px; }
.icon-btn { border: 1px solid rgba(255,255,255,.5); background: rgba(255,255,255,.15); color: #fff; border-radius: 10px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; }

.tabs { display: flex; gap: 6px; padding: 10px 16px 0; background: var(--card); position: sticky; top: 64px; z-index: 9; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 12px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; cursor: pointer; }
.tabs button.active { color: var(--primary); border-color: var(--primary); }

.hero-balance { background: linear-gradient(135deg, var(--primary), var(--accent)); border-radius: 20px; padding: 22px; color: #fff; margin: 16px 0; box-shadow: var(--shadow-md); }
.hero-balance .label { font-size: .8rem; opacity: .85; font-weight: 600; }
.hero-balance .amount { font-size: 2.1rem; font-weight: 900; margin: 4px 0 14px; }
.hero-balance .row { display: flex; justify-content: space-between; font-size: .84rem; opacity: .95; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; box-shadow: var(--shadow-sm); }
.stat-card .icon { font-size: 1.3rem; }
.stat-card .label { font-size: .74rem; color: var(--muted); font-weight: 600; margin-top: 4px; }
.stat-card .value { font-size: 1.15rem; font-weight: 800; margin-top: 2px; }
.stat-card.income .value { color: var(--green); }
.stat-card.expense .value { color: var(--red); }

.section-title { font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 800; margin: 22px 0 10px; display: flex; justify-content: space-between; align-items: center; }
.section-title button { font-size: .74rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
.card .row-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card .title { font-weight: 700; }
.card .meta { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.card .amount { font-weight: 800; font-size: 1.05rem; white-space: nowrap; }
.card .amount.income { color: var(--green); }
.card .amount.expense { color: var(--red); }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .7rem; font-weight: 700; border-radius: 99px; padding: 3px 9px; margin-top: 6px; }
.badge.due-soon { background: var(--amber-bg); color: #92400e; }
.badge.overdue { background: var(--red-bg); color: #991b1b; }
.badge.ok { background: var(--green-bg); color: #065f46; }
.progress-track { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 99px; }
.card .actions { display: flex; gap: 8px; margin-top: 10px; }

.btn { border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 700; cursor: pointer; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
.btn-danger { color: var(--red); }
.btn-sm { padding: 7px 10px; font-size: .8rem; }
.btn-full { width: 100%; }

.fab-add { position: fixed; bottom: 20px; right: 20px; width: 58px; height: 58px; border-radius: 99px; background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; border: 0; font-size: 1.8rem; box-shadow: var(--shadow-md); cursor: pointer; z-index: 20; }

.scrim { position: fixed; inset: 0; background: rgba(30,27,46,.35); opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 40; }
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-radius: 22px 22px 0 0; box-shadow: 0 -12px 40px rgba(30,27,46,.2); transform: translateY(100%); transition: transform .2s ease-out; z-index: 41; max-height: 88vh; overflow-y: auto; }
.sheet.open { transform: translateY(0); }
.sheet-inner { padding: 20px 18px 28px; }
.sheet-inner h2 { margin: 0 0 14px; font-size: 1.15rem; }
.sheet-inner label { display: grid; gap: 6px; font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 12px; }
.sheet-inner input, .sheet-inner select, .sheet-inner textarea { border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 12px; background: var(--bg); color: var(--text); }
.type-toggle { display: flex; gap: 8px; margin-bottom: 14px; }
.type-toggle button { flex: 1; border: 1.5px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px; font-weight: 700; cursor: pointer; }
.type-toggle button.active.income { background: var(--green-bg); border-color: var(--green); color: #065f46; }
.type-toggle button.active.expense { background: var(--red-bg); border-color: var(--red); color: #991b1b; }

.push-banner { background: linear-gradient(135deg, #FDE68A, #FCA5A5); color: #78350f; border-radius: 14px; padding: 12px 14px; font-size: .84rem; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.push-banner button { flex: none; }

.toast-stack { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; width: 100%; max-width: 440px; padding: 0 16px; }
.toast { background: var(--text); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .84rem; box-shadow: var(--shadow-md); text-align: center; }

.empty-note { color: var(--muted); font-size: .86rem; text-align: center; padding: 24px 0; }

.auth-card { max-width: 360px; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 30px 26px; box-shadow: var(--shadow-md); margin: 60px auto; text-align: center; }
.auth-card .logo { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; }
.auth-card h1 { font-size: 1.3rem; margin: 0 0 4px; }
.auth-card .sub { color: var(--muted); font-size: .85rem; margin-bottom: 20px; }
.auth-card label { display: grid; gap: 6px; font-size: .78rem; font-weight: 700; color: var(--muted); margin-bottom: 14px; text-align: left; }
.auth-card input { border: 1.5px solid var(--line); border-radius: 10px; padding: 11px 12px; background: var(--bg); color: var(--text); width: 100%; }
.auth-error { color: var(--red); font-size: .84rem; min-height: 1.2em; }
.auth-switch { margin-top: 16px; font-size: .84rem; color: var(--muted); }
.auth-switch a { color: var(--primary); font-weight: 700; text-decoration: none; }
