/* ───────────── Токены ───────────── */
:root {
  --bg: #0B0B10;
  --surface: #16161D;
  --surface-2: #1E1E27;
  --surface-3: #282833;
  --track: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.06);
  --text: #F4F4F7;
  --text-2: #9C9CAB;
  --text-3: #5F5F6E;
  --accent: #7C6CFF;
  --accent-2: #A594FF;
  --accent-soft: rgba(124, 108, 255, 0.16);
  --green: #2FD07C;
  --green-soft: rgba(47, 208, 124, 0.15);
  --red: #FF5C5C;
  --red-soft: rgba(255, 92, 92, 0.15);
  --blue: #3EA6FF;
  --blue-soft: rgba(62, 166, 255, 0.15);
  --warn: #FFB224;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  --glass: rgba(14, 14, 20, 0.78);
  --r-lg: 24px;
  --r-md: 18px;
  --r-sm: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, sans-serif;
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --safe-top: var(--tg-content-safe-area-inset-top, 0px);
  --tabbar-h: 66px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="light"] {
  --bg: #F2F3F7;
  --surface: #FFFFFF;
  --surface-2: #F3F4F8;
  --surface-3: #E8E9F0;
  --track: rgba(15, 15, 40, 0.07);
  --border: rgba(15, 15, 40, 0.07);
  --text: #0F0F17;
  --text-2: #6C6C7C;
  --text-3: #A6A6B4;
  --accent-soft: rgba(124, 108, 255, 0.12);
  --green: #12B262;
  --green-soft: rgba(18, 178, 98, 0.12);
  --red: #F04848;
  --red-soft: rgba(240, 72, 72, 0.1);
  --blue-soft: rgba(62, 166, 255, 0.12);
  --shadow: 0 10px 28px rgba(20, 20, 50, 0.08);
  --glass: rgba(250, 250, 253, 0.82);
}

/* ───────────── База ───────────── */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  user-select: none;
  -webkit-user-select: none;
}
input, textarea { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { opacity: 0.45; cursor: default; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); letter-spacing: -0.02em; }
.ic { flex: none; display: block; }
.muted { color: var(--text-2); font-size: 13px; }
.center { text-align: center; }
.pad { padding: 24px 0; }
.pos { color: var(--green) !important; }
.neg { color: var(--red) !important; }
.fg { color: var(--text); font-weight: 600; }
.mt { margin-top: 12px; }
body.sheet-open { overflow: hidden; }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 10px) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 36px);
}
#screen.enter > * { animation: rise 0.5s var(--ease) both; }
#screen.enter > *:nth-child(2) { animation-delay: 0.03s; }
#screen.enter > *:nth-child(3) { animation-delay: 0.06s; }
#screen.enter > *:nth-child(4) { animation-delay: 0.09s; }
#screen.enter > *:nth-child(5) { animation-delay: 0.12s; }
#screen.enter > *:nth-child(n + 6) { animation-delay: 0.15s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ───────────── Кнопки ───────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 52px; padding: 0 20px; border-radius: 16px;
  font-weight: 600; font-size: 16px; letter-spacing: -0.01em;
  transition: transform 0.15s var(--ease), background 0.2s, opacity 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn.sm { height: 38px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn.wide { flex: 1; width: 100%; }
.btn.primary { background: linear-gradient(135deg, #8B7BFF, #6A4DF5); color: #fff; box-shadow: 0 8px 22px -8px rgba(124, 108, 255, 0.7); }
.btn.soft { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--text-2); height: 46px; }
.btn.danger-soft { background: var(--red-soft); color: var(--red); width: 56px; flex: none; padding: 0; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
  background: var(--surface); color: var(--text-2); transition: transform 0.15s, background 0.2s;
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn.sm { width: 34px; height: 34px; border-radius: 11px; background: var(--surface-2); }
.link { color: var(--accent-2); font-weight: 600; font-size: 14px; padding: 4px 2px; }
[data-theme="light"] .link { color: var(--accent); }

/* ───────────── Шапка ───────────── */
.top { display: flex; align-items: center; gap: 12px; padding: 6px 0 16px; }
.top-text { flex: 1; min-width: 0; }
.top-hello { font: 600 17px/1.2 var(--font-display); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; overflow: hidden; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 15px; color: #fff;
  background: linear-gradient(135deg, #FF8AD8, #7C6CFF 60%, #3EA6FF);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.xl { width: 84px; height: 84px; font-size: 30px; box-shadow: 0 12px 30px -10px rgba(124, 108, 255, 0.7); }

/* ───────────── Карта баланса ───────────── */
.card-balance {
  position: relative; overflow: hidden; isolation: isolate;
  border-radius: 28px; padding: 20px 20px 18px; color: #fff; cursor: pointer;
  background:
    radial-gradient(90% 120% at 100% 0%, rgba(255, 128, 214, 0.85) 0%, rgba(255, 128, 214, 0) 55%),
    radial-gradient(80% 110% at 0% 100%, rgba(56, 196, 255, 0.75) 0%, rgba(56, 196, 255, 0) 55%),
    linear-gradient(140deg, #6B55FF 0%, #5A34E0 45%, #2D1A8F 100%);
  box-shadow: 0 22px 50px -18px rgba(108, 80, 255, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: transform 0.2s var(--ease);
}
.card-balance:active { transform: scale(0.985); }
.card-balance::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: 0.22;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.5) 0 1px, transparent 1.5px),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 22px);
  background-size: 18px 18px, auto;
  mask-image: linear-gradient(160deg, #000 10%, transparent 75%);
  -webkit-mask-image: linear-gradient(160deg, #000 10%, transparent 75%);
}
.cb-shine {
  position: absolute; inset: -40% -60%; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.18) 50%, transparent 60%);
  animation: shine 6s ease-in-out 1s infinite;
}
@keyframes shine { 0%, 70% { transform: translateX(-40%); } 100% { transform: translateX(40%); } }
.cb-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.cb-brand { display: inline-flex; align-items: center; gap: 7px; font: 700 15px/1 var(--font-display); letter-spacing: 0.01em; opacity: 0.95; }
.cb-brand i { width: 18px; height: 18px; border-radius: 6px; background: rgba(255, 255, 255, 0.9); box-shadow: 7px 0 0 -2px rgba(255, 255, 255, 0.45); margin-right: 6px; }
.cb-cur { font: 600 11px/1 var(--font); letter-spacing: 0.08em; padding: 6px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.16); backdrop-filter: blur(8px); }
.cb-label { font-size: 13px; opacity: 0.78; }
.cb-amount {
  font: 700 40px/1.1 var(--font-display); letter-spacing: -0.035em; margin: 2px 0 18px;
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cb-amount .bm-cents { font-size: 0.6em; opacity: 0.7; letter-spacing: -0.02em; }
.cb-amount .bm-cur { font-size: 0.66em; opacity: 0.75; margin-left: 6px; font-weight: 600; }
.cb-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cb-stat {
  display: flex; align-items: center; gap: 9px; padding: 10px 11px; border-radius: 16px; min-width: 0;
  background: rgba(255, 255, 255, 0.13); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.cb-stat > div { min-width: 0; }
.cb-stat-ic { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; background: rgba(255, 255, 255, 0.92); }
.cb-stat-ic.in { color: #0FA45A; }
.cb-stat-ic.out { color: #5A34E0; }
.cb-stat-l { font-size: 11px; opacity: 0.75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-stat-v { font: 600 14.5px/1.25 var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ───────────── Быстрые действия ───────────── */
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 18px 0 14px; }
.act { display: flex; flex-direction: column; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.act-ic {
  width: 58px; height: 58px; border-radius: 20px; display: grid; place-items: center;
  background: var(--surface); transition: transform 0.18s var(--ease);
  box-shadow: inset 0 0 0 1px var(--border);
}
.act:active .act-ic { transform: scale(0.9); }
.act-ic.red { color: var(--red); background: linear-gradient(var(--red-soft), var(--red-soft)), var(--surface); }
.act-ic.green { color: var(--green); background: linear-gradient(var(--green-soft), var(--green-soft)), var(--surface); }
.act-ic.accent { color: #fff; background: linear-gradient(135deg, #8B7BFF, #6A4DF5); box-shadow: 0 10px 24px -10px rgba(124, 108, 255, 0.9); }
.act-ic.blue { color: var(--blue); background: linear-gradient(var(--blue-soft), var(--blue-soft)), var(--surface); }

/* ───────────── Карточки ───────────── */
.card {
  display: block; width: 100%; text-align: left;
  background: var(--surface); border-radius: var(--r-lg); padding: 16px;
  margin-bottom: 12px; box-shadow: inset 0 0 0 1px var(--border);
  transition: transform 0.18s var(--ease);
}
button.card:active, .card[role="button"]:active { transform: scale(0.985); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head h3 { font-size: 17px; }
.card-head .muted { text-align: right; }

.onboard { display: grid; grid-template-columns: auto 1fr; gap: 12px 14px; align-items: start; background: linear-gradient(135deg, var(--accent-soft), transparent 70%), var(--surface); }
.onboard-ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #8B7BFF, #6A4DF5); }
.onboard-text b { display: block; font-size: 15px; margin-bottom: 4px; }
.onboard-text span { color: var(--text-2); font-size: 13.5px; }
.onboard .btn { grid-column: 2; justify-self: start; }

.month-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 14px; }
.month-total { font: 700 26px/1.15 var(--font-display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.month-net { text-align: right; display: flex; flex-direction: column; gap: 3px; }
.month-net .muted { font-size: 12px; }
.month-net b { font: 600 16px/1.2 var(--font-display); font-variant-numeric: tabular-nums; }
.stack-bar { display: flex; gap: 3px; height: 10px; border-radius: 6px; overflow: hidden; margin-bottom: 12px; }
.stack-bar i { display: block; min-width: 4px; border-radius: 3px; animation: grow-x 0.8s var(--ease) both; transform-origin: left; }
@keyframes grow-x { from { transform: scaleX(0); } }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.lg { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); min-width: 0; }
.lg-n { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg i { width: 8px; height: 8px; border-radius: 3px; flex: none; }
.lg b { margin-left: auto; color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }

.cta { display: flex; align-items: center; gap: 12px; color: var(--text); }
.cta-ic { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; color: var(--warn); background: rgba(255, 178, 36, 0.14); flex: none; }
.cta-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.cta-text span { font-size: 13px; color: var(--text-2); }
.cta > .ic:last-child { color: var(--text-3); }

.budget { display: flex; align-items: center; gap: 14px; }
.budget-ring { position: relative; width: 58px; height: 58px; flex: none; }
.budget-ring > span { position: absolute; inset: 0; display: grid; place-items: center; font: 700 13px/1 var(--font-display); }
.ring-val { transition: stroke-dasharray 1s var(--ease); }
.budget-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.budget-text b { font: 600 17px/1.2 var(--font-display); letter-spacing: -0.01em; }
.budget-sub { font-size: 12.5px; color: var(--text-2); }

/* ───────────── Список операций ───────────── */
.block { margin-top: 20px; }
.block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; padding: 0 2px; }
.block-head h2 { font-size: 21px; }
.day { margin-top: 12px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 6px 4px 8px; font-weight: 600; font-size: 14px; }
.day-head em { font-style: normal; color: var(--text-3); font-weight: 500; margin-left: 6px; font-size: 13px; }
.day-sum { color: var(--text-2); font-variant-numeric: tabular-nums; font-size: 13.5px; }
.day-list { background: var(--surface); border-radius: var(--r-lg); padding: 4px 0; box-shadow: inset 0 0 0 1px var(--border); }
.tx {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 14px; text-align: left; cursor: pointer; transition: background 0.15s;
}
.tx:active { background: var(--surface-2); }
.tx + .tx::before { content: ""; position: absolute; top: 0; left: 70px; right: 14px; height: 1px; background: var(--border); }
.tx-ic { width: 44px; height: 44px; border-radius: 15px; display: grid; place-items: center; font-size: 21px; flex: none; }
.tx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tx-title { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub { color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-amt { font: 600 15.5px/1.2 var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -0.01em; }
.tx-amt.income { color: var(--green); }
.tx-end { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.tx-orig { color: var(--text-2); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-x { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: none; margin-left: 2px; }

.empty { text-align: center; padding: 30px 12px 10px; }
.empty.small { padding-top: 40px; }
.empty-art { position: relative; height: 84px; margin-bottom: 8px; }
.empty-art span { position: absolute; top: 18px; width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; font-size: 26px; background: var(--surface); box-shadow: var(--shadow), inset 0 0 0 1px var(--border); animation: float 4s ease-in-out infinite; }
.empty-art .e1 { left: calc(50% - 90px); transform: rotate(-10deg); }
.empty-art .e2 { left: calc(50% - 28px); top: 4px; z-index: 1; animation-delay: -1.3s; }
.empty-art .e3 { left: calc(50% + 34px); transform: rotate(10deg); animation-delay: -2.6s; }
@keyframes float { 50% { translate: 0 -6px; } }
.empty-title { font: 600 17px/1.3 var(--font-display); }
.empty-text { color: var(--text-2); font-size: 14px; margin-top: 4px; }
.empty-actions { display: flex; gap: 8px; justify-content: center; margin-top: 18px; }
.empty-actions .btn { height: 46px; font-size: 15px; }

/* ───────────── Заголовки страниц, сегменты, чипы ───────────── */
.page-head { padding: 8px 2px 16px; }
.page-head h1 { font-size: 30px; }

.seg {
  position: relative; display: grid; grid-template-columns: repeat(var(--n), 1fr);
  padding: 4px; border-radius: 15px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); margin-bottom: 12px;
}
.seg button { position: relative; z-index: 1; height: 38px; border-radius: 11px; font-weight: 600; font-size: 14.5px; color: var(--text-2); transition: color 0.25s; }
.seg button.on { color: var(--text); }
.seg-pill {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / var(--n));
  border-radius: 11px; background: var(--surface-3); transform: translateX(calc(var(--i) * 100%));
  transition: transform 0.35s var(--ease); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}
[data-theme="light"] .seg-pill { background: #fff; box-shadow: 0 2px 10px rgba(20, 20, 50, 0.1); }
[data-theme="light"] .seg { background: var(--surface-3); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 12px;
  background: var(--surface); color: var(--text-2); font-weight: 500; font-size: 14px; white-space: nowrap;
  box-shadow: inset 0 0 0 1px var(--border); transition: background 0.2s, color 0.2s, transform 0.15s;
}
.chip:active { transform: scale(0.95); }
.chip.on { background: var(--text); color: var(--bg); box-shadow: none; }
.chip.cat.on { background: var(--accent-soft); color: var(--accent-2); }
[data-theme="light"] .chip.cat.on { color: var(--accent); }

.period-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.period-tabs .chip { flex: 1; justify-content: center; }
.period-nav { align-self: stretch; display: flex; align-items: center; justify-content: space-between; gap: 8px; font: 600 16px/1.2 var(--font-display); margin: -8px 0 14px; }
.period-nav span { text-align: center; white-space: nowrap; }
.period-nav .icon-btn:disabled { opacity: 0.3; }

/* ───────────── Аналитика ───────────── */
.an-main { display: flex; flex-direction: column; align-items: center; padding-top: 18px; }
.donut { position: relative; margin-bottom: 18px; }
.donut svg { display: block; overflow: visible; }
.donut-seg { transition: stroke-dasharray 0.9s var(--ease); }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0 24px; }
.dc-label { color: var(--text-2); font-size: 13px; }
.dc-value { font: 700 25px/1.15 var(--font-display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; margin: 3px 0 6px; }
.dc-delta { font-size: 12px; font-weight: 600; white-space: nowrap; padding: 4px 8px; border-radius: 8px; background: var(--surface-2); color: var(--text-2); }
.dc-delta.good { color: var(--green); background: var(--green-soft); }
.dc-delta.bad { color: var(--red); background: var(--red-soft); }
.cat-list { width: 100%; display: flex; flex-direction: column; }
.cat-row { display: flex; align-items: center; gap: 12px; padding: 9px 2px; text-align: left; width: 100%; border-radius: 14px; transition: background 0.15s; }
.cat-row:active { background: var(--surface-2); }
.cat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.cat-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; font-size: 14.5px; }
.cat-top span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-top b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cat-bar { height: 5px; border-radius: 3px; background: var(--track); overflow: hidden; }
.cat-bar i { display: block; height: 100%; border-radius: 3px; animation: grow-x 0.9s var(--ease) both; transform-origin: left; }
.cat-sub { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); }

.bars { --h: 150px; }
.bars-plot { position: relative; height: var(--h); display: flex; align-items: flex-end; gap: 6px; }
.bars-dense .bars-plot { gap: 3px; }
.bar-col { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.bar {
  display: block; width: 100%; max-width: 26px; height: max(var(--v), 3px); border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, var(--c), color-mix(in srgb, var(--c) 55%, transparent)); opacity: 0.8; transform-origin: bottom;
  animation: grow-y 0.7s var(--ease) var(--d) both; transition: opacity 0.2s;
}
.bars-dense .bar { border-radius: 3px; }
.bar-col.is-today .bar { opacity: 1; }
.bar-col.is-future .bar { opacity: 0.12; height: 3px; }
.bar-col.is-sel .bar { opacity: 1; }
.bars:has(.is-sel) .bar-col:not(.is-sel) .bar { opacity: 0.25; }
@keyframes grow-y { from { transform: scaleY(0); } }
.no-anim .bar, .no-anim .stack-bar i, .no-anim .cat-bar i { animation: none; }
.bars-avg { position: absolute; left: 0; right: 0; border-top: 1.5px dashed var(--text-3); z-index: 1; pointer-events: none; }
.bars-avg span { position: absolute; right: 0; top: -18px; font-size: 10.5px; color: var(--text-3); background: var(--surface); padding: 0 3px; }
.bars-labels { display: flex; gap: 6px; margin-top: 8px; }
.bars-dense .bars-labels { gap: 3px; }
.bars-labels span { flex: 1; text-align: center; font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: visible; }

.insights { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.ins { background: var(--surface); border-radius: var(--r-lg); padding: 14px; display: flex; flex-direction: column; gap: 4px; box-shadow: inset 0 0 0 1px var(--border); min-width: 0; }
.ins-ic { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 16%, transparent); margin-bottom: 6px; }
.ins-l { font-size: 12.5px; color: var(--text-2); }
.ins b { font: 700 19px/1.2 var(--font-display); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.ins-s { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.flow-row { display: grid; grid-template-columns: 70px 1fr auto; align-items: center; gap: 10px; font-size: 13.5px; color: var(--text-2); margin-bottom: 10px; }
.flow-row b { color: var(--text); font-variant-numeric: tabular-nums; font-size: 14.5px; }
.flow-bar { height: 10px; border-radius: 6px; background: var(--track); overflow: hidden; }
.flow-bar i { display: block; height: 100%; border-radius: 6px; animation: grow-x 0.9s var(--ease) both; transform-origin: left; }
.flow-bar .in { background: linear-gradient(90deg, #1FBF6D, #5BE59C); }
.flow-bar .out { background: linear-gradient(90deg, #6A4DF5, #A594FF); }
.flow-net { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--border); font-size: 13.5px; color: var(--text-2); }
.flow-net b { font: 700 18px/1.2 var(--font-display); font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.flow-net em { font-style: normal; font-size: 12px; font-weight: 600; color: var(--text-2); }

/* ───────────── История ───────────── */
.search {
  display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; border-radius: 15px;
  background: var(--surface); color: var(--text-3); margin-bottom: 10px; box-shadow: inset 0 0 0 1px var(--border);
}
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: var(--text); font: 16px var(--font); }
.search input::placeholder { color: var(--text-3); }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.hist-sum { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; background: var(--surface); border-radius: var(--r-md); padding: 12px 14px; box-shadow: inset 0 0 0 1px var(--border); }
.hist-sum span { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--text-2); min-width: 0; }
.hist-sum b { font: 600 14.5px/1.2 var(--font-display); color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#hist-results > .btn { margin-top: 14px; }

/* ───────────── Профиль ───────────── */
.profile-head { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 0 18px; text-align: center; }
.profile-name { font: 700 22px/1.2 var(--font-display); letter-spacing: -0.02em; margin-top: 8px; }
.pstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.pstats > div { background: var(--surface); border-radius: var(--r-md); padding: 12px 10px; text-align: center; box-shadow: inset 0 0 0 1px var(--border); min-width: 0; }
.pstats b { display: block; font: 700 17px/1.25 var(--font-display); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pstats span { font-size: 11.5px; color: var(--text-2); }
.group-title { font-size: 13px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding: 18px 6px 8px; }
.group { background: var(--surface); border-radius: var(--r-lg); overflow: hidden; box-shadow: inset 0 0 0 1px var(--border); }
.group.flat { background: transparent; box-shadow: none; }
.row { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 54px; padding: 8px 14px; text-align: left; transition: background 0.15s; }
.row:active { background: var(--surface-2); }
.row + .row::before { content: ""; position: absolute; top: 0; left: 58px; right: 0; height: 1px; background: var(--border); }
.group.flat .row + .row::before { left: 14px; }
.row-ic { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-2); flex: none; }
[data-theme="light"] .row-ic { color: var(--accent); }
.row-l { flex: 1; font-weight: 500; min-width: 0; }
.row-v { color: var(--text-2); font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row > .ic:last-child { color: var(--text-3); }
.row.danger .row-ic { background: var(--red-soft); color: var(--red); }
.row.danger .row-l { color: var(--red); }
.row .check { width: 22px; color: var(--accent-2); }
.switch { width: 50px; height: 30px; border-radius: 99px; background: var(--surface-3); position: relative; transition: background 0.25s; flex: none; }
.switch i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25); transition: transform 0.3s var(--ease); }
.switch.on { background: var(--green); }
.switch.on i { transform: translateX(20px); }
.foot { text-align: center; color: var(--text-3); font-size: 12px; padding: 24px 0 4px; }

/* ───────────── Нижняя панель ───────────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding: 0 8px var(--safe-bottom);
  background: var(--glass); backdrop-filter: saturate(180%) blur(22px); -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-top: 1px solid var(--border);
}
@media (min-width: 560px) { .tabbar { left: 50%; transform: translateX(-50%); width: 560px; border-radius: 22px 22px 0 0; } }
.tabbar > button { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; color: var(--text-3); transition: color 0.2s; height: 100%; justify-content: center; }
.tabbar > button.on { color: var(--text); }
.tabbar > button.on .ic { animation: pop 0.35s var(--ease); }
@keyframes pop { 40% { transform: scale(0.82); } }
.tabbar .fab {
  justify-self: center; width: 58px; height: 58px; border-radius: 50%; margin-top: -26px;
  color: #fff; background: linear-gradient(140deg, #9A8BFF, #6A4DF5 60%, #4F2FD8);
  box-shadow: 0 10px 26px -6px rgba(110, 85, 255, 0.85), 0 0 0 5px var(--bg);
  transition: transform 0.18s var(--ease);
}
.tabbar .fab:active { transform: scale(0.9); }
.tabbar .fab .ic { margin: 0 auto; }

/* ───────────── Шторки ───────────── */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); opacity: 0; transition: opacity 0.3s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px;
  max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 28px 28px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 var(--border);
  transform: translateY(100%); transition: transform 0.38s var(--ease);
}
[data-theme="light"] .sheet { background: var(--bg); }
.sheet-wrap.open .sheet-backdrop { opacity: 1; }
.sheet-wrap.open .sheet { transform: none; }
.sheet-wrap.closing .sheet { transition-duration: 0.26s; }
.sheet-handle { width: 38px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 8px auto 2px; flex: none; }
.sheet-body { overflow-y: auto; padding: 4px 16px calc(var(--safe-bottom) + 18px); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 0 14px; }
.sheet-head h3 { font-size: 20px; display: flex; align-items: center; gap: 8px; }
.sheet-head .icon-btn { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); }
.sheet-hint { color: var(--text-2); font-size: 14px; margin: -4px 0 14px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 16px; position: sticky; bottom: 0; padding-top: 8px; background: linear-gradient(transparent, var(--bg) 30%); }
.label { font-size: 13px; color: var(--text-2); font-weight: 600; margin: 16px 2px 10px; }

/* форма */
.amount-box { background: var(--surface); border-radius: var(--r-lg); padding: 18px 14px 12px; box-shadow: inset 0 0 0 1px var(--border); text-align: center; }
.amount-box.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.amount-field { display: flex; align-items: baseline; justify-content: center; gap: 6px; font: 700 42px/1.1 var(--font-display); letter-spacing: -0.03em; }
.amount-sign { color: var(--text-2); }
.amount-box.income .amount-sign, .amount-box.income input { color: var(--green); }
.amount-field input {
  width: 100%; max-width: 260px; min-width: 60px; border: 0; outline: 0; background: none; color: var(--text);
  font: inherit; letter-spacing: inherit; text-align: center; padding: 0; font-variant-numeric: tabular-nums;
}
.amount-field input::placeholder { color: var(--text-3); }
.amount-cur {
  display: inline-flex; align-items: center; gap: 3px; align-self: center; flex: none;
  color: var(--text); font: 600 22px/1 var(--font-display); letter-spacing: 0;
  padding: 7px 9px 7px 11px; border-radius: 12px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border);
  transition: transform 0.12s;
}
.amount-cur:active { transform: scale(0.94); }
.amount-cur .ic { color: var(--text-2); }
.amount-calc { min-height: 20px; color: var(--accent-2); font-weight: 600; font-size: 14px; margin-top: 4px; }
.amount-conv { color: var(--text-2); font-size: 13px; line-height: 1.45; margin-top: -2px; font-variant-numeric: tabular-nums; }
.amount-conv:empty { display: none; }
.amount-conv b { color: var(--text); font-size: 15px; font-weight: 700; }
.sheet-note { color: var(--text-2); font-size: 14px; line-height: 1.4; margin: -4px 4px 10px; }
.cur-sym { display: inline-block; min-width: 34px; font-weight: 700; color: var(--text-2); }
.group-note { color: var(--text-3); font-size: 12.5px; line-height: 1.4; padding: 8px 6px 0; }
.foot a { color: inherit; }
.ops { display: flex; justify-content: center; gap: 8px; margin-top: 10px; }
.ops button { width: 44px; height: 36px; border-radius: 11px; background: var(--surface-2); color: var(--text-2); font-size: 18px; font-weight: 600; transition: transform 0.12s; }
.ops button:active { transform: scale(0.9); background: var(--surface-3); }
.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cat {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px 9px; border-radius: 16px;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); transition: transform 0.15s, box-shadow 0.2s, background 0.2s; min-width: 0;
}
.cat:active { transform: scale(0.94); }
.cat-ic { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; font-size: 21px; background: var(--cs); }
.cat-n { font-size: 11.5px; line-height: 1.2; color: var(--text-2); text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.cat.on { background: var(--cs); box-shadow: inset 0 0 0 2px var(--cc); }
.cat.on .cat-n { color: var(--text); font-weight: 600; }
.field { display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 14px; margin-top: 14px; border-radius: 15px; background: var(--surface); color: var(--text-3); box-shadow: inset 0 0 0 1px var(--border); }
.field input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--text); font: 16px var(--font); height: 100%; }
.field input::placeholder { color: var(--text-3); }
.date-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.date-pick { position: relative; overflow: hidden; }
.date-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

/* голосовой ввод */
.vs { min-height: 340px; display: flex; flex-direction: column; }
.vs-center { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 10px 0 14px; }
.vs-center.small { padding: 34px 0 10px; }
.vs-title { font: 600 19px/1.3 var(--font-display); letter-spacing: -0.01em; margin-top: 18px; }
.vs-title.left { margin: 0 0 12px; text-align: left; }
.vs-hint { color: var(--text-2); font-size: 14px; margin-top: 6px; max-width: 300px; }
.vs-sub { color: var(--text-2); font-size: 13px; margin: 14px 2px 8px; }
.vs-timer { font: 600 18px/1 var(--font-display); font-variant-numeric: tabular-nums; margin-top: 20px; color: var(--red); }
.orb { --lvl: 0; position: relative; width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; margin-top: 18px; }
.orb-core {
  position: relative; z-index: 2; width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: radial-gradient(circle at 30% 25%, #B3A6FF, #7C6CFF 45%, #4F2FD8);
  box-shadow: 0 16px 40px -10px rgba(124, 108, 255, 0.9), inset 0 2px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.1s linear;
}
.orb.idle .orb-core { animation: breathe 2.6s ease-in-out infinite; }
.orb.idle:active .orb-core { transform: scale(0.92); }
@keyframes breathe { 50% { transform: scale(1.05); } }
.orb-ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(124, 108, 255, 0.45); }
.orb.idle .orb-ring { animation: ripple 2.6s ease-out infinite; }
@keyframes ripple { from { transform: scale(0.72); opacity: 1; } to { transform: scale(1.25); opacity: 0; } }
.orb.rec .orb-core { background: radial-gradient(circle at 30% 25%, #FF9A9A, #FF5C5C 45%, #D92F4F); box-shadow: 0 16px 40px -10px rgba(255, 92, 92, 0.9); transform: scale(calc(1 + var(--lvl) * 0.12)); }
.orb.rec .orb-ring { border-color: rgba(255, 92, 92, 0.35); background: rgba(255, 92, 92, 0.08); transform: scale(calc(0.85 + var(--lvl) * 0.5)); transition: transform 0.12s linear; }
.orb.rec .orb-ring.r2 { transform: scale(calc(0.9 + var(--lvl) * 0.85)); opacity: 0.6; }
.orb.busy .orb-core { animation: breathe 1.4s ease-in-out infinite; }
.orb-spin { position: absolute; inset: 6px; border-radius: 50%; border: 3px solid transparent; border-top-color: var(--accent); border-right-color: rgba(124, 108, 255, 0.3); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.wave { display: flex; align-items: center; justify-content: center; gap: 4px; height: 54px; margin-top: 16px; }
.wave i { display: block; width: 4px; height: 100%; border-radius: 2px; background: linear-gradient(var(--red), #FF9A9A); transform: scaleY(0.12); transition: transform 0.08s linear; }
.vs-actions { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-top: auto; padding: 8px 10px 4px; }
.round-btn { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; transition: transform 0.15s; }
.round-btn:active { transform: scale(0.9); }
.round-btn.ghost { background: var(--surface-2); color: var(--text-2); justify-self: start; }
.round-btn.stop { width: 76px; height: 76px; color: #fff; background: linear-gradient(140deg, #9A8BFF, #6A4DF5); box-shadow: 0 12px 28px -8px rgba(110, 85, 255, 0.9); }
.examples { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 10px; }
.examples.center { justify-content: center; }
.examples .chip { height: 34px; font-size: 13.5px; }
.quote { display: flex; gap: 8px; align-items: flex-start; padding: 12px 14px; border-radius: 16px; background: var(--surface); color: var(--text-2); font-size: 14.5px; box-shadow: inset 0 0 0 1px var(--border); margin-top: 6px; text-align: left; }
.vs-center .quote { margin-top: 18px; max-width: 100%; }
.quote .ic { margin-top: 2px; color: var(--accent-2); }
.draft-list { background: var(--surface); border-radius: var(--r-lg); padding: 4px 0; box-shadow: inset 0 0 0 1px var(--border); }
.draft-list .tx { padding-right: 8px; }
.draft-total { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 6px 0; color: var(--text-2); font-weight: 500; }
.draft-total b { font: 700 19px/1.2 var(--font-display); color: var(--text); font-variant-numeric: tabular-nums; }
.textbox { position: relative; }
.textbox textarea {
  width: 100%; resize: none; border: 0; outline: 0; border-radius: 18px; padding: 14px 58px 14px 16px;
  background: var(--surface); color: var(--text); font: 16px/1.45 var(--font); box-shadow: inset 0 0 0 1px var(--border);
}
.textbox textarea:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.textbox textarea::placeholder { color: var(--text-3); }
.send { position: absolute; right: 8px; bottom: 10px; width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #8B7BFF, #6A4DF5); }
.note-box { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 14px; background: rgba(255, 178, 36, 0.12); color: var(--warn); font-size: 13px; margin-bottom: 12px; }
.note-box .ic { margin-top: 1px; }

.help { display: flex; flex-direction: column; gap: 4px; }
.help-row { display: flex; gap: 12px; padding: 10px 2px; }
.help-row > span { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; font-size: 20px; background: var(--surface); flex: none; }
.help-row b { font-size: 15px; }
.help-row p { margin: 3px 0 0; color: var(--text-2); font-size: 14px; }

/* ───────────── Тост ───────────── */
.toast {
  position: fixed; left: 50%; top: calc(var(--safe-top) + 12px); z-index: 100;
  display: flex; align-items: center; gap: 14px; width: max-content; max-width: calc(100vw - 32px);
  padding: 12px 14px 12px 16px; border-radius: 16px; font-weight: 500; font-size: 14.5px;
  color: #fff; background: rgba(30, 30, 40, 0.92); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  transform: translate(-50%, -140%); opacity: 0; transition: transform 0.4s var(--ease), opacity 0.3s; pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.toast.err { background: rgba(200, 40, 60, 0.95); }
.toast button { color: #B9AEFF; font-weight: 700; font-size: 14px; white-space: nowrap; }

/* ───────────── Заставка и ошибки ───────────── */
#splash { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; background: var(--bg); transition: opacity 0.4s; }
#splash.hide { opacity: 0; pointer-events: none; }
.splash-logo { animation: breathe 1.6s ease-in-out infinite; filter: drop-shadow(0 14px 30px rgba(124, 108, 255, 0.6)); }
.splash-dots { display: flex; gap: 6px; }
.splash-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: dot 1.2s ease-in-out infinite; }
.splash-dots i:nth-child(2) { animation-delay: 0.15s; }
.splash-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 40% { transform: translateY(-5px); background: var(--accent); } }
body:not(.ready) .tabbar { opacity: 0; }
body.is-fatal .tabbar { display: none; }
.fatal { min-height: 80vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 20px; }
.fatal-ic { width: 76px; height: 76px; border-radius: 24px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #8B7BFF, #6A4DF5); margin-bottom: 8px; }
.fatal h2 { font-size: 22px; }
.fatal p { color: var(--text-2); margin: 0 0 12px; max-width: 300px; }

@media (max-width: 360px) {
  .cb-amount { font-size: 34px; }
  .act-ic { width: 52px; height: 52px; border-radius: 18px; }
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
  .period { flex-direction: column; align-items: stretch; }
  .period-nav { justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
