:root {
  --blue-dark: #071f5c;
  --blue: #005cff;
  --blue-soft: #1f8cff;
  --green: #20b978;
  --red: #ff4d4f;
  --bg: #f6f8fc;
  --text: #14213d;
  --muted: #6b7280;
  --card: #ffffff;
  --border: #e5eaf2;
  --shadow: 0 18px 40px rgba(7, 31, 92, 0.11);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: #e9eef8; }
body { display: flex; justify-content: center; }
button, input, textarea { font: inherit; }
button { cursor: pointer; border: 0; }

.phone-shell { width: min(100%, 430px); min-height: 100vh; position: relative; background: var(--bg); box-shadow: 0 24px 80px rgba(20, 33, 61, 0.18); overflow-x: hidden; }
.app { min-height: 100vh; padding: 10px 18px 120px; background: var(--bg); }
.status-bar { height: 24px; display: flex; align-items: center; justify-content: space-between; padding: 0 6px; font-size: 13px; font-weight: 700; color: #0f172a; }
.status-icons { display: flex; align-items: center; gap: 6px; }
.signal { width: 18px; height: 12px; background: linear-gradient(to top, #0f172a 25%, transparent 25%), linear-gradient(to top, #0f172a 45%, transparent 45%), linear-gradient(to top, #0f172a 65%, transparent 65%); background-size: 4px 100%; background-repeat: no-repeat; background-position: 0 0, 7px 0, 14px 0; }
.wifi { width: 16px; height: 12px; border: 3px solid #0f172a; border-left-color: transparent; border-right-color: transparent; border-bottom: 0; border-radius: 16px 16px 0 0; }
.battery { width: 22px; height: 11px; border: 2px solid #0f172a; border-radius: 3px; position: relative; }
.battery::after { content: ""; position: absolute; right: -5px; top: 2px; width: 3px; height: 5px; background: #0f172a; border-radius: 0 2px 2px 0; }

.app-shell[hidden], .login-screen[hidden] { display: none !important; }
.login-screen { min-height: 100vh; background: #fff; display: grid; grid-template-rows: minmax(430px, 56vh) auto; overflow: hidden; }
.login-hero { position: relative; color: #fff; padding: 10px 22px 0; background: radial-gradient(circle at 78% 16%, rgba(31, 140, 255, 0.45), transparent 24%), linear-gradient(180deg, #061646 0%, #08266f 54%, #005cff 100%); border-radius: 0 0 38px 38px; overflow: hidden; }
.login-hero::after { content: ""; position: absolute; left: -8%; right: -8%; bottom: -1px; height: 92px; background: #fff; clip-path: ellipse(64% 54% at 50% 100%); z-index: 3; }
.login-status-bar { height: 24px; display: flex; align-items: center; justify-content: space-between; padding: 0 2px; font-size: 13px; font-weight: 800; color: #fff; position: relative; z-index: 4; }
.login-status-bar .signal { background: linear-gradient(to top, #fff 25%, transparent 25%), linear-gradient(to top, #fff 45%, transparent 45%), linear-gradient(to top, #fff 65%, transparent 65%); background-size: 4px 100%; background-repeat: no-repeat; background-position: 0 0, 7px 0, 14px 0; }
.login-status-bar .wifi { border-color: #fff; border-left-color: transparent; border-right-color: transparent; border-bottom: 0; }
.login-status-bar .battery { border-color: #fff; }
.login-status-bar .battery::after { background: #fff; }
.login-brand { position: relative; z-index: 4; display: grid; justify-items: center; text-align: center; margin-top: 32px; }
.login-logo { width: 72px; height: 72px; border-radius: 24px; display: grid; place-items: center; color: #07246c; font-size: 24px; font-weight: 950; letter-spacing: -0.08em; background: linear-gradient(145deg, #fff, #e9f5ff); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18); }
.login-brand h1 { margin-top: 18px; color: #fff; font-size: clamp(31px, 9vw, 40px); line-height: 1; letter-spacing: -0.06em; }
.login-brand h1 strong { color: #62d4ff; font-weight: 950; }
.login-brand p { color: rgba(255, 255, 255, 0.82); font-size: 16px; line-height: 1.35; margin-top: 12px; }
.login-illustration { position: absolute; left: 0; right: 0; bottom: 24px; z-index: 2; height: 230px; pointer-events: none; }
.login-illustration svg { width: 100%; height: 100%; display: block; }
.login-wave-back { fill: rgba(25, 169, 255, 0.28); }
.login-wave-front { fill: url(#waveGradient); opacity: 0.92; }
.chart-bars rect { fill: url(#barGradient); filter: drop-shadow(0 12px 16px rgba(0, 92, 255, 0.35)); }
.growth-line, .growth-arrow { fill: none; stroke: #b7f0ff; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 8px 12px rgba(0, 0, 0, 0.24)); }
.donut-shape circle:first-child { fill: none; stroke: rgba(255, 255, 255, 0.22); stroke-width: 22; }
.donut-shape path { fill: none; stroke: #9be7ff; stroke-width: 22; stroke-linecap: round; }
.donut-shape circle:last-child { fill: rgba(6, 22, 70, 0.26); }
.small-orb { fill: rgba(255, 255, 255, 0.3); }
.login-panel { margin-top: -30px; position: relative; z-index: 5; padding: 0 24px 30px; background: #fff; }
.login-dots { display: flex; gap: 8px; justify-content: center; margin: 0 0 20px; }
.login-dots span { width: 8px; height: 8px; border-radius: 50%; background: #d7e4fb; }
.login-dots span:first-child { width: 24px; border-radius: 999px; background: var(--blue); }
.login-form { display: grid; gap: 14px; }
.login-field { gap: 8px; font-size: 13px; color: #17325f; }
.login-input-wrap { min-height: 56px; display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px; padding: 0 14px; border: 1px solid #dfe8f7; border-radius: 20px; background: #f8fafd; box-shadow: 0 10px 24px rgba(7, 31, 92, 0.05); }
.login-input-wrap:focus-within { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0, 92, 255, 0.08); }
.login-input-icon { font-size: 17px; opacity: 0.72; }
.login-input-wrap input { border: 0; padding: 0; background: transparent; box-shadow: none; min-height: 52px; }
.login-input-wrap input:focus { border: 0; box-shadow: none; }
.toggle-password { width: 38px; height: 38px; border-radius: 14px; color: var(--blue); background: rgba(0, 92, 255, 0.09); }
.login-error { min-height: 20px; margin: -2px 0 0; color: var(--red); font-weight: 800; font-size: 13px; text-align: center; }
.login-submit { width: 100%; min-height: 56px; border-radius: 20px; color: #fff; background: linear-gradient(145deg, var(--blue), var(--blue-soft)); font-size: 17px; font-weight: 950; box-shadow: 0 18px 30px rgba(0, 92, 255, 0.28); }
.login-secondary { display: block; margin: 16px auto 0; color: var(--blue); background: transparent; font-weight: 850; font-size: 14px; }
.logout-card { width: 100%; min-height: 76px; display: grid; gap: 4px; text-align: left; margin-top: 12px; padding: 18px; border-radius: 24px; border: 1px solid rgba(255, 77, 79, 0.2); color: var(--red); background: rgba(255, 77, 79, 0.07); font-weight: 900; }
.logout-card small { color: #9a4b4c; font-weight: 650; }
@media (max-width: 360px) {
  .login-screen { grid-template-rows: minmax(410px, 54vh) auto; }
  .login-hero { padding-left: 18px; padding-right: 18px; }
  .login-brand { margin-top: 22px; }
  .login-logo { width: 64px; height: 64px; border-radius: 22px; }
  .login-illustration { bottom: 16px; height: 214px; }
  .login-panel { padding-left: 18px; padding-right: 18px; }
}


.screen { display: none; animation: fade 0.18s ease; }
.screen-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.top-header, .page-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 16px 0 18px; }
h1 { margin: 0; font-size: clamp(22px, 6vw, 28px); letter-spacing: -0.04em; }
p { margin: 5px 0 0; color: var(--muted); font-size: 14px; line-height: 1.35; }
.icon-button { flex: 0 0 44px; width: 44px; height: 44px; border-radius: 16px; background: var(--card); box-shadow: 0 10px 25px rgba(7, 31, 92, 0.08); }

.balance-card { background: radial-gradient(circle at 85% 0%, rgba(31, 140, 255, 0.65), transparent 30%), linear-gradient(145deg, #071f5c 0%, #005cff 100%); color: #fff; border-radius: 30px; padding: 24px; box-shadow: 0 24px 40px rgba(0, 92, 255, 0.25); overflow: hidden; position: relative; }
.balance-card::after { content: ""; position: absolute; right: -30px; bottom: -45px; width: 145px; height: 145px; border: 24px solid rgba(255,255,255,0.08); border-radius: 50%; }
.balance-top, .forecast-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; position: relative; z-index: 1; }
.balance-top span, .forecast-row span { color: rgba(255,255,255,0.76); font-size: 14px; }
.eye { width: 34px; height: 34px; border-radius: 50%; color: #fff; background: rgba(255,255,255,0.15); }
.balance-card strong { display: block; margin: 8px 0 30px; font-size: clamp(32px, 10vw, 42px); letter-spacing: -0.05em; position: relative; z-index: 1; }
.forecast-row b { display: block; margin-top: 4px; font-size: 18px; }
.growth { text-align: right; }
.growth span { display: inline-block; color: #dfffee; background: rgba(32, 185, 120, 0.28); padding: 6px 10px; border-radius: 999px; font-weight: 800; }
.growth small { display: block; margin-top: 5px; color: rgba(255,255,255,0.72); }

.section-block { margin-top: 24px; }
.last-section { padding-bottom: 14px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
h2 { margin: 0; font-size: 19px; letter-spacing: -0.03em; }
.section-title button { color: var(--blue); background: transparent; font-weight: 700; font-size: 13px; white-space: nowrap; }
.summary-card, .chart-card, .donut-card, .empty-card, .backup-card, .entry-card { background: var(--card); border: 1px solid var(--border); border-radius: 24px; box-shadow: var(--shadow); }
.summary-card { min-height: 116px; display: grid; grid-template-columns: 1fr 1px 1fr; padding: 18px; }
.summary-card article { display: grid; gap: 5px; align-content: center; }
.divider { background: var(--border); }
.metric-icon { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; font-weight: 900; }
.metric-icon.income { color: var(--green); background: rgba(32, 185, 120, 0.11); }
.metric-icon.outcome { color: var(--red); background: rgba(255, 77, 79, 0.12); }
.summary-card span { color: var(--muted); font-size: 13px; }
.summary-card strong { font-size: clamp(18px, 5vw, 22px); letter-spacing: -0.04em; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.chart-card { padding: 18px 12px 10px; }
.legend { display: flex; gap: 18px; padding: 0 8px 10px; color: var(--muted); font-size: 13px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.green { background: var(--green); } .red { background: var(--red); }
.donut-card { display: grid; grid-template-columns: 132px 1fr; gap: 12px; align-items: center; padding: 18px; }
.category-list { display: grid; gap: 10px; min-width: 0; }
.category-row { display: grid; grid-template-columns: 9px 1fr auto; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; }
.category-row b { color: var(--text); font-size: 13px; white-space: nowrap; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 6px; background: #edf2fb; border-radius: 18px; margin-bottom: 14px; }
.tab { padding: 11px 8px; border-radius: 14px; background: transparent; color: var(--muted); font-weight: 800; font-size: 13px; }
.tab.active { background: #fff; color: var(--blue); box-shadow: 0 8px 20px rgba(7, 31, 92, 0.08); }
.list { display: grid; gap: 12px; }
.entry-card { padding: 16px; }
.entry-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.entry-card strong { font-size: 24px; letter-spacing: -0.04em; }
.entry-date { color: var(--muted); font-size: 13px; margin-top: 4px; }
.entry-card p { color: var(--text); }
.entry-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.entry-actions button, .backup-card { min-height: 44px; border-radius: 14px; padding: 0 14px; font-weight: 800; }
.edit { background: rgba(0, 92, 255, 0.1); color: var(--blue); }
.delete { background: rgba(255, 77, 79, 0.11); color: var(--red); }
.restore { background: rgba(32, 185, 120, 0.13); color: var(--green); }
.empty-card { padding: 22px; color: var(--muted); text-align: center; line-height: 1.45; }
.backup-card { width: 100%; height: auto; display: grid; gap: 4px; text-align: left; padding: 18px; color: var(--text); }
.backup-card small { color: var(--muted); }

.bottom-nav { position: fixed; z-index: 20; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(calc(100% - 24px), 406px); height: 78px; background: #fff; border: 1px solid var(--border); border-radius: 28px; box-shadow: 0 18px 45px rgba(7, 31, 92, 0.18); display: grid; grid-template-columns: 1fr 1fr 76px 1fr 1fr; align-items: center; padding: 8px; }
.nav-item { height: 58px; border-radius: 20px; display: grid; place-items: center; gap: 2px; background: transparent; color: #718096; font-size: 11px; font-weight: 800; }
.nav-item span { font-size: 20px; line-height: 1; }
.nav-item.active { color: var(--blue); }
.add-button { width: 62px; height: 62px; margin: -28px auto 0; border-radius: 50%; color: #fff; font-size: 34px; font-weight: 600; background: linear-gradient(145deg, var(--blue), var(--blue-soft)); box-shadow: 0 18px 28px rgba(0, 92, 255, 0.34); }

.sheet-backdrop { position: fixed; inset: 0; z-index: 30; display: grid; align-items: end; justify-items: center; background: rgba(7, 31, 92, 0.38); padding: 18px; }
.sheet-backdrop[hidden] { display: none; }
.sheet { width: min(100%, 430px); max-height: min(88vh, 760px); overflow-y: auto; background: #fff; border-radius: 30px 30px 24px 24px; padding: 24px 20px 22px; position: relative; box-shadow: 0 -20px 60px rgba(7, 31, 92, 0.24); }
.close-sheet { position: absolute; right: 16px; top: 14px; width: 38px; height: 38px; border-radius: 50%; background: #f1f5fb; color: var(--muted); font-size: 25px; }
.type-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.choice { min-height: 74px; border-radius: 20px; color: #fff; font-size: 18px; font-weight: 900; }
.income-choice { background: linear-gradient(145deg, #1bc47c, var(--green)); }
.outcome-choice { background: linear-gradient(145deg, #ff7678, var(--red)); }
.entry-form { margin-top: 16px; display: grid; gap: 12px; }
.entry-form[hidden] { display: none; }
label { display: grid; gap: 6px; color: var(--text); font-weight: 800; font-size: 13px; }
label small { color: var(--muted); font-weight: 600; }
input, textarea { width: 100%; border: 1px solid var(--border); border-radius: 16px; background: #f8fafd; color: var(--text); padding: 13px 14px; outline: none; }
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0, 92, 255, 0.08); }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.save-button { min-height: 54px; border-radius: 18px; color: #fff; background: var(--blue); font-size: 16px; font-weight: 900; margin-top: 6px; }
.toast { position: fixed; z-index: 40; left: 50%; bottom: 108px; transform: translateX(-50%) translateY(18px); width: min(calc(100% - 32px), 390px); padding: 13px 16px; border-radius: 16px; background: #14213d; color: #fff; opacity: 0; pointer-events: none; transition: 0.2s ease; box-shadow: 0 18px 35px rgba(20, 33, 61, 0.2); }
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 340px) {
  .app { padding-left: 12px; padding-right: 12px; }
  .donut-card { grid-template-columns: 1fr; justify-items: center; }
  .category-list { width: 100%; }
  .bottom-nav { grid-template-columns: 1fr 1fr 66px 1fr 1fr; }
  .nav-item { font-size: 10px; }
  .add-button { width: 56px; height: 56px; }
}

@media (min-width: 640px) {
  body { padding: 22px 0; }
  .phone-shell { min-height: calc(100vh - 44px); border-radius: 34px; overflow: hidden; }
  .login-screen { min-height: calc(100vh - 44px); }
  .bottom-nav { bottom: 34px; }
}
