@font-face {
  font-family: 'Onest';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/onest-cyrillic-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Onest';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(fonts/onest-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+20BD, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Токены ---------- */
/* Палитра Cove: глубокий синий #006BBB → небесный #30A0E0 → абрикос #FFC973 → крем; зелёный #30B155 — доходы */
:root {
  --bg: #f7f5f0;
  --surface: #fffefb;
  --raised: #ffffff;
  --ink: #1e2b3a;
  --text: #1e2b3a;
  --text-2: #687482;
  --text-3: #a7b0ba;
  --line: rgba(30, 43, 58, .08);
  --line-strong: rgba(30, 43, 58, .15);
  --fill: rgba(30, 60, 90, .06);
  --fill-2: rgba(30, 60, 90, .1);
  --btn: #006bbb;
  --btn-text: #ffffff;
  --accent: #e1effa;
  --accent-ink: #005a9e;
  --accent-strong: #30a0e0;
  --warm: #ffc973;
  --warm-soft: #ffe7bf;
  --warm-ink: #6b4300;
  --hero: linear-gradient(145deg, #006bbb 0%, #1f8fd3 62%, #4fb0e6 100%);
  --hero-text: #ffffff;
  --hero-text-2: rgba(255, 255, 255, .74);
  --hero-line: rgba(255, 255, 255, .24);
  --pos: #23934c;
  --neg: #d4614a;
  --warn: #c9871a;
  --neg-soft: rgba(212, 97, 74, .1);
  --warn-soft: rgba(255, 201, 115, .25);
  --toast: #1e2b3a;
  --toast-text: #ffffff;
  --glass: rgba(255, 255, 255, .78);
  --shadow-float: 0 1px 0 rgba(255, 255, 255, .8) inset, 0 12px 32px -12px rgba(0, 60, 110, .28), 0 2px 6px rgba(0, 40, 80, .06);
  --radius: 22px;
  --radius-sm: 14px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

/* Тёмная тема — графитово-синяя, приглушённая, без чистого чёрного */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1f24;
    --surface: #23282f;
    --raised: #2a3038;
    --ink: #e9eef3;
    --text: #e9eef3;
    --text-2: #9aa6b2;
    --text-3: #64707c;
    --line: rgba(233, 238, 243, .08);
    --line-strong: rgba(233, 238, 243, .14);
    --fill: rgba(233, 238, 243, .06);
    --fill-2: rgba(233, 238, 243, .1);
    --btn: #30a0e0;
    --btn-text: #06192a;
    --accent: #1c3a55;
    --accent-ink: #a6d6f3;
    --accent-strong: #30a0e0;
    --warm: #ffc973;
    --warm-soft: #4a3b22;
    --warm-ink: #ffe3b3;
    --hero: linear-gradient(145deg, #00538f 0%, #12709f 60%, #2a87b8 100%);
    --hero-text: #ffffff;
    --hero-text-2: rgba(255, 255, 255, .7);
    --hero-line: rgba(255, 255, 255, .18);
    --pos: #5cc784;
    --neg: #ee8a74;
    --warn: #f2bb62;
    --neg-soft: rgba(238, 138, 116, .13);
    --warn-soft: rgba(255, 201, 115, .13);
    --toast: #e9eef3;
    --toast-text: #1b1f24;
    --glass: rgba(42, 48, 56, .78);
    --shadow-float: 0 1px 0 rgba(255, 255, 255, .05) inset, 0 12px 32px -10px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1f24;
  --surface: #23282f;
  --raised: #2a3038;
  --ink: #e9eef3;
  --text: #e9eef3;
  --text-2: #9aa6b2;
  --text-3: #64707c;
  --line: rgba(233, 238, 243, .08);
  --line-strong: rgba(233, 238, 243, .14);
  --fill: rgba(233, 238, 243, .06);
  --fill-2: rgba(233, 238, 243, .1);
  --btn: #30a0e0;
  --btn-text: #06192a;
  --accent: #1c3a55;
  --accent-ink: #a6d6f3;
  --accent-strong: #30a0e0;
  --warm: #ffc973;
  --warm-soft: #4a3b22;
  --warm-ink: #ffe3b3;
  --hero: linear-gradient(145deg, #00538f 0%, #12709f 60%, #2a87b8 100%);
  --hero-text: #ffffff;
  --hero-text-2: rgba(255, 255, 255, .7);
  --hero-line: rgba(255, 255, 255, .18);
  --pos: #5cc784;
  --neg: #ee8a74;
  --warn: #f2bb62;
  --neg-soft: rgba(238, 138, 116, .13);
  --warn-soft: rgba(255, 201, 115, .13);
  --toast: #e9eef3;
  --toast-text: #1b1f24;
  --glass: rgba(42, 48, 56, .78);
  --shadow-float: 0 1px 0 rgba(255, 255, 255, .05) inset, 0 12px 32px -10px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ---------- База ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 450 15px/1.45 'Onest', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-feature-settings: 'tnum' 1, 'cv11' 1;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; border-radius: 8px; }
.ic { width: 1.25em; height: 1.25em; flex: none; display: block; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.small { font-size: 13px; }

/* Пружинящий отклик на нажатие */
.press { transition: transform 160ms var(--ease-out), background-color 160ms ease, opacity 160ms ease; }
.press:active { transform: scale(0.97); }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 14px) 16px calc(var(--safe-bottom) + 112px);
}

/* ---------- Шапка ---------- */
.top {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  margin: 6px 2px 18px; min-height: 44px;
}
.top .eyebrow { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.top h1 { font-size: 28px; line-height: 1.1; font-weight: 650; letter-spacing: -.03em; margin: 2px 0 0; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--warm-soft); color: var(--warm-ink); font-weight: 650; font-size: 16px;
}
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; color: var(--text);
  background: var(--surface); border: 1px solid var(--line);
}
.icon-btn .ic { width: 20px; height: 20px; }
.back {
  display: inline-flex; align-items: center; gap: 2px; color: var(--text-2); font-size: 14px;
  margin-left: -4px; padding: 4px 4px 4px 0;
}
.back .ic { width: 18px; height: 18px; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); flex: none; display: inline-block; }
.dot.ok { background: var(--pos); }
.dot.syncing { background: var(--warn); }
.dot.error, .dot.auth { background: var(--neg); }

.period {
  display: inline-flex; align-items: center; height: 36px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
}
.period button { width: 34px; height: 34px; display: grid; place-items: center; color: var(--text-2); border-radius: 50%; }
.period button[disabled] { opacity: .25; pointer-events: none; }
.period .ic { width: 16px; height: 16px; }
.period span { font-size: 14px; font-weight: 550; min-width: 86px; text-align: center; white-space: nowrap; }

/* ---------- Главная карточка ---------- */
.hero {
  background: var(--hero); color: var(--hero-text);
  border-radius: 28px; padding: 22px 20px 18px; margin-bottom: 12px;
  position: relative; overflow: hidden;
}
.hero-label { font-size: 14px; color: var(--hero-text-2); display: flex; justify-content: space-between; align-items: center; }
.hero-amount { display: flex; align-items: baseline; gap: 6px; margin: 6px 0 16px; }
.hero-amount b { font-size: 54px; line-height: 1; font-weight: 650; letter-spacing: -.045em; }
.hero-amount span { font-size: 26px; font-weight: 500; color: var(--hero-text-2); }
.hero-amount.neg b { color: var(--neg); }
.track { height: 6px; border-radius: 99px; background: var(--hero-line); position: relative; }
.track > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--warm); transition: width 500ms var(--ease-out); }
.track > i.warn { background: #ffb15c; }
.track > i.over { background: #ff8f78; }
.track > b { position: absolute; top: -4px; bottom: -4px; width: 2px; border-radius: 2px; background: var(--hero-text); opacity: .7; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--hero-line); }
.hero-stats div { min-width: 0; }
.hero-stats .k { font-size: 12px; color: var(--hero-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-stats .v { font-size: 16px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.hero-note { font-size: 13px; color: var(--hero-text-2); margin-top: 12px; display: flex; gap: 8px; align-items: flex-start; }
.hero-note .ic { width: 16px; height: 16px; margin-top: 1px; color: var(--hero-text); }
.hero-empty { font-size: 15px; color: var(--hero-text-2); margin: 10px 0 14px; max-width: 32ch; }
.hero .btn { background: #ffffff; color: #005a9e; }
.hero-amount.neg b { color: #ffd2c8; }

/* ---------- Быстрый ввод ---------- */
.quick {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 6px 6px 6px 14px; margin-bottom: 12px;
  transition: border-color 160ms ease;
}
.quick:focus-within { border-color: var(--line-strong); }
.quick-row { display: flex; align-items: center; gap: 10px; }
.quick-row > .ic { color: var(--text-3); width: 20px; height: 20px; }
.quick input { flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 10px 0; font-size: 16px; }
.quick input::placeholder { color: var(--text-3); }
.send {
  width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--btn); color: var(--btn-text);
}
.send .ic { width: 18px; height: 18px; }
.send:disabled { background: var(--fill-2); color: var(--text-3); }
.quick-extra { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 220ms var(--ease-out); }
.quick-extra.open { grid-template-rows: 1fr; }
.quick-extra > div { overflow: hidden; }
.parsed { display: flex; flex-wrap: wrap; gap: 6px; padding: 6px 8px 4px 0; font-size: 13px; }
.tag { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: 99px; background: var(--fill); color: var(--text); white-space: nowrap; }
.tag .ic { width: 14px; height: 14px; }
.tag.income { background: color-mix(in srgb, var(--pos) 14%, transparent); color: var(--pos); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.ai { background: var(--accent); color: var(--accent-ink); }
.tag.ai.wait { animation: ai-pulse 1.2s ease-in-out infinite; }
@keyframes ai-pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .tag.ai.wait { animation: none; } }
.quick .chips { padding: 6px 8px 6px 0; }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; scroll-snap-type: x proximity; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px 0 8px;
  border-radius: 99px; background: var(--fill); font-size: 14px; white-space: nowrap; scroll-snap-align: start;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms var(--ease-out);
}
.chip:active { transform: scale(0.96); }
.chip .ic { width: 18px; height: 18px; color: var(--c, var(--text-2)); }
.chip.on { background: var(--accent); color: var(--accent-ink); }
.chip.on .ic { color: var(--accent-ink); }
.chip.plain { padding: 0 12px; }

/* ---------- Секции, карточки, строки ---------- */
.section { display: flex; justify-content: space-between; align-items: baseline; margin: 24px 4px 10px; }
.section h2 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; margin: 0; }
.section a, .section button { font-size: 14px; color: var(--text-2); display: inline-flex; align-items: center; gap: 2px; }
.section .ic { width: 15px; height: 15px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px;
  padding: 10px 14px; text-align: left; position: relative;
}
.row + .row::before { content: ''; position: absolute; top: 0; left: 66px; right: 0; height: 1px; background: var(--line); }
button.row { transition: background-color 120ms ease; }
button.row:active { background: var(--fill); }
@media (hover: hover) and (pointer: fine) { button.row:hover { background: var(--fill); } }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { font-size: 13px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; }
.row .meta .ic { width: 13px; height: 13px; }
.row .amt { font-weight: 600; white-space: nowrap; text-align: right; letter-spacing: -.01em; }
.row .amt small { display: block; font-size: 12px; font-weight: 450; color: var(--text-2); }
.row .chev { width: 16px; height: 16px; color: var(--text-3); }
.row-link { min-height: 48px; color: var(--text-2); font-size: 14px; }

.tile {
  --c: var(--text-2);
  width: 40px; height: 40px; border-radius: 13px; flex: none;
  display: grid; place-items: center; font-size: 19px;
  background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c);
}
.tile .ic { width: 22px; height: 22px; }
.tile.sm { width: 32px; height: 32px; border-radius: 10px; }
.tile.sm .ic { width: 18px; height: 18px; }
.tile.neutral { background: var(--fill); color: var(--text); }

.day { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-2); padding: 18px 6px 8px; }
.empty { text-align: center; color: var(--text-2); padding: 32px 20px; }
.empty .tile { margin: 0 auto 12px; width: 52px; height: 52px; border-radius: 16px; }
.empty .tile .ic { width: 26px; height: 26px; }
.empty p { margin: 0 auto 14px; max-width: 30ch; }

/* ---------- Конверты ---------- */
.rings { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 12px; padding: 0 16px; scroll-snap-type: x mandatory; scroll-padding: 16px; }
.rings::-webkit-scrollbar { display: none; }
.ring-card {
  flex: none; width: 132px; scroll-snap-align: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 12px 12px; text-align: left;
}
.ring { position: relative; width: 58px; height: 58px; margin-bottom: 10px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .ic { position: absolute; inset: 0; margin: auto; width: 22px; height: 22px; color: var(--c); }
.ring circle { fill: none; stroke-width: 5.5; }
.ring .bg { stroke: var(--fill-2); }
.ring .fg { stroke: var(--c); stroke-linecap: round; transition: stroke-dashoffset 600ms var(--ease-out); }
.ring-card.over .fg { stroke: var(--neg); }
.ring-card .name { font-weight: 550; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ring-card .left { font-size: 13px; color: var(--text-2); white-space: nowrap; }
.ring-card.over .left { color: var(--neg); }

.env { display: block; }
.env-top { display: flex; align-items: center; gap: 12px; }
.bar { height: 5px; border-radius: 99px; background: var(--fill-2); margin: 10px 0 2px 52px; position: relative; overflow: hidden; }
.bar > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--c); }
.bar > i.over { background: var(--neg); }
.bar > b { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--text); opacity: .3; }

.stack { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--fill-2); gap: 2px; margin: 14px 0 10px; }
.stack i { display: block; height: 100%; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kv .k { font-size: 12px; color: var(--text-2); }
.kv .v { font-size: 17px; font-weight: 600; letter-spacing: -.02em; white-space: nowrap; }

.note {
  display: flex; gap: 10px; align-items: flex-start; font-size: 14px;
  padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 8px;
  background: var(--fill);
}
.note .ic { width: 18px; height: 18px; margin-top: 1px; flex: none; }
.note.warn { background: var(--warn-soft); }
.note.warn .ic { color: var(--warn); }
.note.neg { background: var(--neg-soft); }
.note.neg .ic { color: var(--neg); }

/* ---------- Кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 20px; border-radius: 16px; font-weight: 600;
  background: var(--btn); color: var(--btn-text);
  transition: transform 160ms var(--ease-out), opacity 160ms ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn .ic { width: 18px; height: 18px; }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--fill); color: var(--text); }
.btn.danger { background: var(--neg-soft); color: var(--neg); }
.btn.sm { height: 38px; padding: 0 14px; border-radius: 12px; font-size: 14px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row .btn { flex: 1; }

.field { margin-bottom: 12px; }
.field > label, .label { display: block; font-size: 13px; color: var(--text-2); margin: 0 0 6px 4px; }
.input, .field input, .field select, .field textarea {
  width: 100%; height: 50px; border: 1px solid var(--line); background: var(--raised);
  border-radius: 14px; padding: 0 14px; font-size: 16px; outline: none;
  -webkit-appearance: none; appearance: none;
  transition: border-color 160ms ease;
}
.field input[type="date"] { line-height: 48px; }
.field input:focus, .field select:focus { border-color: var(--text-3); }
.field select { background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 19px) 22px, calc(100% - 14px) 22px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.field .help { font-size: 12px; color: var(--text-3); margin: 6px 4px 0; }
.field-row { display: flex; gap: 10px; }
.field-row > .field { flex: 1; min-width: 0; }

.switch { display: flex; align-items: center; gap: 12px; padding: 12px 2px; cursor: pointer; }
.switch .main { flex: 1; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .knob { width: 46px; height: 28px; border-radius: 99px; background: var(--fill-2); position: relative; flex: none; transition: background-color 200ms ease; }
.switch .knob::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--raised); box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform 220ms var(--ease-out); }
.switch input:checked + .knob { background: var(--accent-strong); }
.switch input:checked + .knob::after { transform: translateX(18px); }
.switch input:focus-visible + .knob { outline: 2px solid var(--text); outline-offset: 2px; }

/* Сегменты со скользящим индикатором */
.seg {
  --n: 2; --i: 0;
  position: relative; display: grid; grid-template-columns: repeat(var(--n), 1fr);
  background: var(--fill); border-radius: 13px; padding: 3px; margin-bottom: 14px;
}
.seg-ind {
  position: absolute; top: 3px; bottom: 3px; left: 3px;
  width: calc((100% - 6px) / var(--n));
  transform: translateX(calc(var(--i) * 100%));
  background: var(--raised); border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px var(--line);
  transition: transform 260ms var(--ease-in-out);
}
.seg button { position: relative; height: 36px; font-size: 14px; font-weight: 550; color: var(--text-2); transition: color 160ms ease; }
.seg button.on { color: var(--text); }

.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.icon-grid button { aspect-ratio: 1; border-radius: 12px; display: grid; place-items: center; background: var(--fill); color: var(--text-2); }
.icon-grid button .ic { width: 22px; height: 22px; }
.icon-grid button.on { background: var(--accent); color: var(--accent-ink); box-shadow: inset 0 0 0 1.5px var(--accent-strong); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatches button { width: 32px; height: 32px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 2px var(--surface); border: 2px solid transparent; }
.swatches button.on { border-color: var(--text); }

/* ---------- Нижняя панель (как в Telegram): широкая стеклянная плашка + отдельная круглая «+» ---------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 10px); z-index: 30;
  margin: 0 auto; max-width: 560px; padding: 0 12px;
  display: flex; align-items: center; gap: 10px;
  transition: transform 300ms var(--ease-drawer), opacity 200ms ease;
}
.dock.hidden { transform: translateY(140%); opacity: 0; pointer-events: none; }
.dock-tabs, .dock-add {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px);
  border: 1px solid var(--line); box-shadow: var(--shadow-float);
}
.dock-tabs {
  position: relative; flex: 1; min-width: 0; height: 66px; padding: 5px;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-radius: 999px;
}
.dock-ind {
  position: absolute; top: 5px; bottom: 5px; left: 5px;
  width: calc((100% - 10px) / 4); border-radius: 999px;
  background: var(--accent);
  transform: translateX(calc(var(--i, 0) * 100%));
  transition: transform 320ms var(--ease-in-out), opacity 200ms ease;
}
.dock-tab {
  position: relative; border-radius: 999px; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--text-2); font-size: 11px; font-weight: 550; letter-spacing: .01em;
  transition: color 160ms ease, transform 160ms var(--ease-out);
}
.dock-tab:active { transform: scale(0.94); }
.dock-tab .ic { width: 26px; height: 26px; }
.dock-tab .ic.f { display: none; }
.dock-tab span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.dock-tab.on { color: var(--accent-ink); }
.dock-tab.on .ic.r { display: none; }
.dock-tab.on .ic.f { display: block; }
.dock-add {
  width: 66px; height: 66px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #5a3a00;
  background: var(--warm); border-color: transparent;
  transition: transform 160ms var(--ease-out);
}
.dock-add:active { transform: scale(0.92); }
.dock-add .ic { width: 28px; height: 28px; }

/* ---------- Шторка ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(10, 10, 6, .4);
  opacity: 0; pointer-events: none; transition: opacity 300ms ease;
}
.backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; margin: 0 auto; max-width: 560px;
  max-height: calc(100dvh - var(--safe-top) - 24px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 28px 28px 0 0;
  padding: 0 16px calc(var(--safe-bottom) + 18px);
  transform: translateY(100%);
  transition: transform 240ms var(--ease-out);
  box-shadow: 0 -10px 40px -10px rgba(0, 0, 0, .25);
}
.sheet.open { transform: translateY(0); transition: transform 420ms var(--ease-drawer); }
.sheet.dragging { transition: none; }
.grab { position: sticky; top: 0; z-index: 2; padding: 10px 0 8px; background: var(--bg); touch-action: none; cursor: grab; }
.grab::before { content: ''; display: block; width: 40px; height: 5px; border-radius: 99px; background: var(--line-strong); margin: 0 auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 16px; }
.sheet-head h2 { font-size: 21px; font-weight: 650; letter-spacing: -.02em; margin: 0; display: flex; align-items: center; gap: 10px; min-width: 0; }
.sheet-head .icon-btn { width: 34px; height: 34px; }
.sheet-head .icon-btn .ic { width: 16px; height: 16px; }

/* ---------- Клавиатура суммы ---------- */
.pad-display { text-align: center; padding: 6px 0 14px; }
.pad-amount { font-size: 52px; line-height: 1.05; font-weight: 650; letter-spacing: -.045em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pad-amount .cur { color: var(--text-3); font-weight: 500; font-size: .55em; margin-left: 4px; letter-spacing: 0; }
.pad-amount.zero { color: var(--text-3); }
.pad-amount.income { color: var(--pos); }
.pad-amount.bump { animation: bump 180ms var(--ease-out); }
@keyframes bump { 50% { transform: scale(1.03); } }
.pad-note { display: flex; align-items: center; gap: 10px; background: var(--raised); border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; margin: 10px 0; }
.pad-note .ic { width: 18px; height: 18px; color: var(--text-3); }
.pad-note input { flex: 1; min-width: 0; height: 48px; border: 0; outline: none; background: none; font-size: 16px; }
.pad-dates { display: flex; gap: 6px; margin-bottom: 10px; }
.pad-dates .chip { position: relative; }
.pad-dates input[type="date"] { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.key {
  height: 54px; border-radius: 14px; font-size: 24px; font-weight: 500;
  background: var(--raised); border: 1px solid var(--line);
  display: grid; place-items: center;
  transition: transform 120ms var(--ease-out), background-color 120ms ease;
}
.key:active { transform: scale(0.95); background: var(--fill-2); }
.key .ic { width: 24px; height: 24px; }
.key.fn { background: transparent; border-color: transparent; color: var(--text-2); }

/* ---------- Графики ---------- */
.donut-wrap { display: flex; gap: 18px; align-items: center; }
.donut-wrap svg { flex: none; }
.legend { flex: 1; min-width: 0; display: grid; gap: 7px; font-size: 13px; }
.legend div { display: flex; align-items: center; gap: 8px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.legend span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--text-3); font-size: 10px; font-family: inherit; }
.chart .grid { stroke: var(--line); }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.chart-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
.card-title { font-size: 15px; font-weight: 600; margin: 0 0 12px; display: flex; justify-content: space-between; align-items: baseline; }
.story p { margin: 0 0 8px; line-height: 1.5; }
.story p:last-child { margin: 0; }
.story b { font-weight: 600; }

/* ---------- Цели ---------- */
.goal { padding: 16px; }
.goal + .goal { border-top: 1px solid var(--line); }
.goal-top { display: flex; align-items: center; gap: 12px; }
.goal-top .main { flex: 1; min-width: 0; }
.goal-track { height: 8px; border-radius: 99px; background: var(--fill-2); margin: 14px 0 8px; overflow: hidden; }
.goal-track i { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--accent-strong)); }

/* ---------- Профиль ---------- */
.profile { display: flex; align-items: center; gap: 14px; padding: 18px 16px; }
.profile .main { flex: 1; min-width: 0; }
.profile .name { font-size: 19px; font-weight: 650; letter-spacing: -.02em; }

/* ---------- Вход ---------- */
.login { min-height: calc(100dvh - 140px); display: flex; flex-direction: column; justify-content: center; max-width: 360px; margin: 0 auto; }
.login .mark { width: 56px; height: 56px; border-radius: 18px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; margin-bottom: 22px; }
.login .mark .ic { width: 30px; height: 30px; }
.login h1 { font-size: 30px; letter-spacing: -.035em; margin: 0 0 6px; font-weight: 650; }
.login p { color: var(--text-2); margin: 0 0 26px; }
.error { color: var(--neg); font-size: 14px; min-height: 20px; margin: -2px 4px 10px; }

/* ---------- Тост ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 90px); z-index: 60;
  transform: translate(-50%, 16px) scale(0.96); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 14px; width: max-content; max-width: calc(100% - 32px);
  padding: 12px 14px 12px 16px; border-radius: 16px;
  background: var(--toast); color: var(--toast-text); font-size: 14px; box-shadow: var(--shadow-float);
  transition: transform 300ms var(--ease-out), opacity 200ms ease;
}
.toast.show { transform: translate(-50%, 0) scale(1); opacity: 1; pointer-events: auto; }
.toast button { color: var(--accent-strong); font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }
.toast button .ic { width: 16px; height: 16px; }

table.preview { width: 100%; border-collapse: collapse; font-size: 12px; }
table.preview td, table.preview th { border-bottom: 1px solid var(--line); padding: 6px; text-align: left; white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
table.preview th { color: var(--text-2); font-weight: 500; }
.scroll-x { overflow-x: auto; }

@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet.open, .dock, .seg-ind, .dock-ind, .track > i, .ring .fg, .toast { transition-duration: 1ms !important; }
  .toast, .toast.show { transform: translate(-50%, 0); transition: opacity 200ms ease !important; }
  .press:active, .btn:active, .key:active, .chip:active { transform: none; }
}

/* ---------- Плашка «Доступна новая версия» ---------- */
.update {
  position: fixed; left: 50%; top: calc(var(--safe-top) + 10px); z-index: 70;
  transform: translate(-50%, -140%); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 10px; width: max-content; max-width: calc(100% - 24px);
  padding: 8px 8px 8px 14px; border-radius: 999px;
  background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px);
  border: 1px solid var(--line); box-shadow: var(--shadow-float); font-size: 14px; font-weight: 550;
  transition: transform 420ms var(--ease-drawer), opacity 200ms ease;
}
.update.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.update .ic { width: 18px; height: 18px; color: var(--accent-strong); }
.update button {
  height: 34px; padding: 0 14px; border-radius: 999px; background: var(--btn); color: var(--btn-text);
  font-weight: 600; transition: transform 160ms var(--ease-out);
}
.update button:active { transform: scale(0.96); }
@media (prefers-reduced-motion: reduce) { .update { transition: opacity 200ms ease; transform: translate(-50%, 0); } }
