/* ═══════════ Пульс — дизайн-система «Лавандовые сумерки» ═══════════
 * Все цвета — только через переменные. Тема задаётся атрибутом data-theme на <html>
 * (light | dark), его выставляет app.js по настройке и системной теме.
 */

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

:root, [data-theme="light"] {
  color-scheme: light;
  --bg: #F7F5FB;
  --surface: #FFFFFF;
  --surface-2: #EFEBF6;
  --surface-3: #E6E1F0;
  --line: #E8E4F0;
  --text: #2B2A33;
  --text-2: #6B6778;
  --text-3: #9A96A6;
  --accent: #6E5BB8;
  --accent-ink: #FFFFFF;
  --accent-soft: #E6DFFA;
  --accent-text: #5A48A8;
  --income: #2E7A61;
  --income-soft: #DDF2E9;
  --income-solid: #8FD3B8;
  --expense: #B95F35;
  --expense-soft: #FFE6D8;
  --expense-solid: #FFC4A3;
  --save: #2F5F8A;
  --save-soft: #DFEDF9;
  --save-solid: #B5D6F2;
  --warn: #84600C;
  --warn-soft: #FBF1D3;
  --warn-solid: #F3DB8A;
  --danger: #B4413A;
  --danger-soft: #FBE3E0;
  --shadow: 0 2px 10px rgba(43, 42, 51, 0.06);
  --shadow-lg: 0 12px 40px rgba(43, 42, 51, 0.16);
  --scrim: rgba(28, 24, 40, 0.38);
  --tabbar: rgba(255, 255, 255, 0.86);
  --fab-shadow: 0 8px 22px rgba(110, 91, 184, 0.38);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #16141F;
  --surface: #211E2D;
  --surface-2: #2A2638;
  --surface-3: #332E44;
  --line: #322E42;
  --text: #F2EFF7;
  --text-2: #A7A2B3;
  --text-3: #777286;
  --accent: #B3A2EA;
  --accent-ink: #1B1530;
  --accent-soft: #2F2848;
  --accent-text: #CFC3F7;
  --income: #7CC7AB;
  --income-soft: #1E3530;
  --income-solid: #5FA88D;
  --expense: #F2B08E;
  --expense-soft: #43291F;
  --expense-solid: #C98A6A;
  --save: #9CC4E8;
  --save-soft: #1F3346;
  --save-solid: #6F9CC4;
  --warn: #E9D27F;
  --warn-soft: #3D3418;
  --warn-solid: #B9A257;
  --danger: #F0A49C;
  --danger-soft: #45221F;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --scrim: rgba(0, 0, 0, 0.55);
  --tabbar: rgba(33, 30, 45, 0.9);
  --fab-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
}

:root {
  --r-xl: 24px;
  --r-l: 20px;
  --r-m: 16px;
  --r-s: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: calc(64px + var(--safe-bottom));
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font: "Onest", -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
/* Документ не прокручивается — прокручивается только #app. Так нижнее меню и листы не «уезжают» на iPhone
   (после клавиатуры, при резкой прокрутке), а под открытым листом ничего не двигается. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); height: 100%; overflow: hidden; }
body {
  margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.4;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; }
a { color: var(--accent-text); text-decoration: none; }
img, svg { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent-soft); }

.num, .amt { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ───── каркас ───── */
#app { position: fixed; inset: 0; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-y: contain; }
body.sheet-open #app { overflow-y: hidden; }
.page {
  padding: calc(var(--safe-top) + 14px) 16px calc(var(--tabbar-h) + 28px);
  max-width: 560px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 12px;
  animation: page-in 0.32s var(--ease) both;
}
.page.no-tabbar { padding-bottom: calc(var(--safe-bottom) + 28px); }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* направление перехода: вглубь — справа, назад — слева, вкладки внутри раздела — просто проявление */
body[data-nav="push"] .page { animation: page-push 0.34s var(--ease) both; }
body[data-nav="pop"] .page { animation: page-pop 0.34s var(--ease) both; }
body[data-nav="tab"] .page { animation: page-fade 0.22s ease-out both; }
body[data-nav="tab"] .page .stagger > * { animation-duration: 0.3s; }
@keyframes page-push { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes page-pop { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
@keyframes page-fade { from { opacity: 0.4; } to { opacity: 1; } }

.page-header { display: flex; align-items: center; gap: 8px; min-height: 48px; }
.page-header .title { flex: 1; min-width: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.3px; }
.page-header .subtitle { font-size: 14px; color: var(--text-2); }
.page-header.sub .title { font-size: 20px; text-align: center; }
.back-btn { margin-left: -6px; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 17px; font-weight: 700; }
.section-title .link-btn, .section-title a { font-size: 14px; font-weight: 600; }

/* ───── карточки ───── */
.card { background: var(--surface); border-radius: var(--r-xl); padding: 16px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card.tight { padding: 4px 16px; }
.card-soft { border-radius: var(--r-xl); padding: 16px; background: var(--surface-2); }
.card-hero { border-radius: var(--r-xl); padding: 20px; background: var(--accent-soft); color: var(--text); position: relative; overflow: hidden; }
.card-hero.income { background: var(--income-soft); }
.card-hero.expense { background: var(--expense-soft); }
.card-hero.save { background: var(--save-soft); }
.card-hero.warn { background: var(--warn-soft); }
.card-tap { transition: transform 0.15s var(--ease); cursor: pointer; }
.card-tap:active { transform: scale(0.985); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
.wrap { flex-wrap: wrap; }
.center { text-align: center; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 14px; }
.tiny { font-size: 12px; }
.bold { font-weight: 700; }
.semi { font-weight: 600; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.divider { height: 1px; background: var(--line); margin: 0; border: 0; }
.hidden { display: none !important; }

/* ───── суммы ───── */
.amt { white-space: nowrap; }
.amt.exp { color: var(--text); }
.amt.inc { color: var(--income); }
.amt.neg { color: var(--expense); }
.amt.save { color: var(--save); }
.amt-xl { font-size: 44px; font-weight: 700; letter-spacing: -1px; line-height: 1.08; }
.amt-l { font-size: 30px; font-weight: 700; letter-spacing: -0.5px; line-height: 1.12; }
.amt-m { font-size: 20px; font-weight: 700; }
html.hide-amounts .amt { filter: blur(7px); transition: filter 0.2s; }
html.hide-amounts .amt.keep { filter: none; }

/* ───── списки ───── */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 8px 0;
  border: 0; background: none; width: 100%; text-align: left; color: inherit;
}
.list-item + .list-item { border-top: 1px solid var(--line); }
.list-item[role="button"], .list-item.card-tap { transition: opacity 0.15s, transform 0.15s var(--ease); }
.list-item[role="button"]:active { opacity: 0.6; }
/* только что записанная операция */
.txr.fresh { animation: fresh 2s ease-out; }
@keyframes fresh { 0%, 35% { background-color: var(--accent-soft); } 100% { background-color: var(--surface); } }
button.list-item:active, a.list-item:active { opacity: 0.6; }
.li-main { flex: 1; min-width: 0; }
.li-title { font-size: 16px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-sub { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.li-end { text-align: right; flex-shrink: 0; }
.li-chev { color: var(--text-3); flex-shrink: 0; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 4px 6px; font-size: 14px; font-weight: 600; color: var(--text-2); }

/* ───── иконки ───── */
.ic { width: 22px; height: 22px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.cat-ic {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--c-bg, var(--surface-2)); color: var(--c-fg, var(--text-2));
}
[data-theme="dark"] .cat-ic { background: var(--c-dbg, var(--surface-2)); color: var(--c-dfg, var(--text-2)); }
.cat-ic .ic { width: 20px; height: 20px; }
.cat-ic.sm { width: 32px; height: 32px; } .cat-ic.sm .ic { width: 17px; height: 17px; }
.cat-ic.lg { width: 52px; height: 52px; } .cat-ic.lg .ic { width: 26px; height: 26px; }
.cat-ic .emoji { font-size: 20px; line-height: 1; }
.cat-ic.sm .emoji { font-size: 16px; } .cat-ic.lg .emoji { font-size: 26px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--c-solid, var(--text-3)); }

/* ───── кнопки ───── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 24px; border: 0;
  font-size: 16px; font-weight: 600; background: var(--surface-2); color: var(--text);
  transition: transform 0.12s var(--ease), opacity 0.2s, background 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: var(--fab-shadow); }
.btn-soft { background: var(--accent-soft); color: var(--accent-text); }
.btn-ghost { background: transparent; color: var(--accent-text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; border-radius: 28px; font-size: 17px; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 14px; border-radius: 18px; }
.btn .ic { width: 20px; height: 20px; }
.btn.is-busy { pointer-events: none; opacity: 0.7; }
.btn.is-busy::after { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }
.link-btn { background: none; border: 0; padding: 6px 2px; color: var(--accent-text); font-weight: 600; font-size: 15px; min-height: 36px; }

.btn-icon {
  width: 44px; height: 44px; border-radius: 50%; border: 0; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  transition: transform 0.12s var(--ease);
}
.btn-icon:active { transform: scale(0.92); }
.btn-icon.plain { background: transparent; box-shadow: none; }
.btn-icon.soft { background: var(--surface-2); box-shadow: none; }
.btn-icon.primary { background: var(--accent); color: var(--accent-ink); }

/* ───── чипы ───── */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  min-height: 36px; padding: 0 14px; border-radius: 18px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 500; white-space: nowrap;
}
.chip .ic { width: 16px; height: 16px; }
.chip.active { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); font-weight: 600; }
.chip.dashed { border-style: dashed; color: var(--text-2); background: transparent; }

/* ───── сегменты ───── */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--surface-2); border-radius: 22px; padding: 4px; gap: 2px; }
.segmented button { min-height: 36px; border: 0; border-radius: 18px; background: transparent; color: var(--text-2); font-size: 14px; font-weight: 500; padding: 0 6px; transition: background 0.2s, color 0.2s; white-space: nowrap; }
.segmented button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 4px rgba(43, 42, 51, 0.1); }
[data-theme="dark"] .segmented button.active { background: var(--surface-3); }
/* ползунок: один фон, который едет под выбранную кнопку */
.segmented.ind { position: relative; gap: 0; }
.segmented.ind::before {
  content: ""; position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / var(--n, 1));
  border-radius: 18px; background: var(--surface); box-shadow: 0 1px 4px rgba(43, 42, 51, 0.1);
  transform: translateX(calc(100% * var(--i, 0))); transition: transform 0.34s var(--ease);
}
[data-theme="dark"] .segmented.ind::before { background: var(--surface-3); }
.segmented.ind.still::before { transition: none; }
.segmented.ind.none::before { opacity: 0; }
.segmented.ind button { position: relative; z-index: 1; transition: color 0.25s; }
.segmented.ind button.active, [data-theme="dark"] .segmented.ind button.active { background: transparent; box-shadow: none; }

/* ───── формы ───── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label { font-size: 14px; font-weight: 600; color: var(--text-2); padding-left: 4px; }
.field .hint { font-size: 13px; color: var(--text-3); padding-left: 4px; }
.input, .textarea, .select {
  width: 100%; min-height: 50px; padding: 12px 16px; border-radius: var(--r-m);
  border: 1px solid var(--line); background: var(--surface); font-size: 16px; color: var(--text);
  outline: none; transition: border-color 0.2s;
  -webkit-appearance: none; appearance: none;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); }
.textarea { resize: none; min-height: 90px; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.switch-row { display: flex; align-items: center; gap: 12px; min-height: 56px; }
.switch-row + .switch-row { border-top: 1px solid var(--line); }
.switch { position: relative; width: 52px; height: 32px; flex-shrink: 0; border-radius: 16px; background: var(--surface-3); border: 0; transition: background 0.2s; padding: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.2); transition: transform 0.25s var(--spring); }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(20px); }

/* ───── прогресс ───── */
.progress { position: relative; height: 10px; border-radius: 5px; background: var(--surface-2); overflow: visible; }
.progress > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 5px; background: var(--accent); width: 0; transition: width 0.7s var(--ease); }
.progress.income > i { background: var(--income-solid); }
.progress.expense > i { background: var(--expense-solid); }
.progress.warn > i { background: var(--warn-solid); }
.progress.over > i { background: var(--expense); }
.progress .mark { position: absolute; top: -4px; width: 2px; height: 18px; border-radius: 1px; background: var(--text); transform: translateX(-1px); }
.progress.thin { height: 6px; } .progress.thin .mark { top: -4px; height: 14px; }

/* ───── пустые состояния ───── */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 32px 16px; color: var(--text-2); }
.empty .empty-ic { width: 64px; height: 64px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); display: flex; align-items: center; justify-content: center; }
.empty .empty-ic .ic { width: 30px; height: 30px; }
.empty .empty-title { font-size: 18px; font-weight: 700; color: var(--text); }
.empty .empty-text { font-size: 15px; max-width: 300px; }

/* ───── нижнее меню ───── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: var(--tabbar-h); padding-bottom: var(--safe-bottom);
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: start;
  background: var(--tabbar); border-top: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(1.6) blur(18px); backdrop-filter: saturate(1.6) blur(18px);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 3px; padding-top: 9px; min-height: 52px; font-size: 11px; font-weight: 500; color: var(--text-2); }
.tabbar a.active { color: var(--accent-text); font-weight: 600; }
.tabbar a .ic { transition: transform 0.18s var(--ease); }
.tabbar a:active .ic { transform: scale(0.86); }
.tabbar a.active .ic { animation: tab-pop 0.42s var(--spring); }
@keyframes tab-pop { 0% { transform: scale(0.8); } 60% { transform: scale(1.12); } 100% { transform: none; } }
.tabbar a .ic { width: 24px; height: 24px; }
.tabbar .fab {
  justify-self: center; margin-top: -20px; width: 60px; height: 60px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--fab-shadow);
  display: flex; align-items: center; justify-content: center; transition: transform 0.15s var(--spring);
}
.tabbar .fab:active { transform: scale(0.9); }
.tabbar .fab .ic { width: 30px; height: 30px; stroke-width: 2.2; }
body.no-tabbar .tabbar { display: none; }

/* ───── нижний лист (sheet) ───── */
.sheet-scrim { position: fixed; inset: 0; z-index: 100; background: var(--scrim); opacity: 0; transition: opacity 0.28s var(--ease); }
.sheet-scrim.open { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 101; max-width: 560px; margin: 0 auto;
  max-height: calc(100dvh - var(--safe-top) - 12px); display: flex; flex-direction: column;
  background: var(--bg); border-radius: 28px 28px 0 0; box-shadow: var(--shadow-lg);
  transform: translateY(100%); transition: transform 0.36s var(--ease);
  padding-bottom: var(--safe-bottom);
}
.sheet.open { transform: none; }
.sheet.full { height: calc(100dvh - var(--safe-top) - 8px); }
.sheet-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 8px auto 2px; flex-shrink: 0; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 20px; min-height: 52px; flex-shrink: 0; }
.sheet-head .sheet-title { flex: 1; font-size: 18px; font-weight: 700; min-width: 0; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px 20px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.sheet-foot { padding: 8px 16px 12px; flex-shrink: 0; display: flex; gap: 8px; }

/* ───── тосты ───── */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + 12px); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
body.no-tabbar .toasts, body.sheet-open .toasts { bottom: calc(var(--safe-bottom) + 20px); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 520px; width: 100%;
  min-height: 52px; padding: 8px 8px 8px 18px; border-radius: 18px;
  background: #2B2A33; color: #F7F5FB; box-shadow: var(--shadow-lg); font-size: 15px;
  animation: toast-in 0.32s var(--spring) both;
}
[data-theme="dark"] .toast { background: #F2EFF7; color: #1B1530; }
.toast.error { background: var(--danger); color: #fff; }
.toast .toast-text { flex: 1; padding: 6px 0; }
.toast button { border: 0; background: rgba(255,255,255,0.14); color: inherit; font-weight: 700; border-radius: 12px; min-height: 36px; padding: 0 14px; }
[data-theme="dark"] .toast button { background: rgba(27,21,48,0.1); }
.toast.out { animation: toast-out 0.22s var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) scale(0.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ───── диалог ───── */
.dialog { position: fixed; left: 50%; top: 50%; z-index: 151; width: min(340px, calc(100vw - 40px)); transform: translate(-50%, -46%) scale(0.96); opacity: 0; background: var(--surface); border-radius: 24px; padding: 22px 20px 16px; box-shadow: var(--shadow-lg); transition: opacity 0.2s, transform 0.28s var(--spring); }
.dialog.open { opacity: 1; transform: translate(-50%, -50%); }
.dialog .dialog-text { font-size: 17px; font-weight: 600; text-align: center; }
.dialog .dialog-sub { font-size: 15px; color: var(--text-2); text-align: center; margin-top: 6px; }
.dialog .dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.dialog-scrim { z-index: 150; }

/* ───── нумпад ───── */
.numpad { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.numpad button {
  height: 54px; border: 0; border-radius: 16px; background: var(--surface); color: var(--text);
  font-size: 23px; font-weight: 500; display: flex; align-items: center; justify-content: center;
  transition: transform 0.08s, background 0.15s;
}
.numpad button:active { transform: scale(0.94); background: var(--surface-3); }
/* действия — отдельным цветом и крупнее, чтобы «+» и «×» не путались с цифрами и друг с другом */
.numpad button.op { background: var(--accent-soft); color: var(--accent-text); font-size: 30px; font-weight: 400; line-height: 1; }
.numpad button.op[aria-label="×"] { font-size: 26px; }
.numpad button.op[aria-label="÷"] { font-size: 28px; }
.numpad button.op.active { background: var(--accent); color: var(--accent-ink); }

/* ───── пикеры ───── */
.swatches { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; }
.swatch { aspect-ratio: 1; border-radius: 50%; border: 0; background: var(--c-solid); position: relative; min-height: 32px; }
.swatch.active::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--text); }
.icon-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.icon-grid button { aspect-ratio: 1; border: 0; border-radius: 14px; background: var(--surface); color: var(--text); display: flex; align-items: center; justify-content: center; min-height: 44px; font-size: 22px; }
.icon-grid button.active { background: var(--accent-soft); color: var(--accent-text); box-shadow: inset 0 0 0 2px var(--accent); }

/* ───── прочее ───── */
.badge { min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px; background: var(--expense); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.pill { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 10px; border-radius: 12px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill.accent { background: var(--accent-soft); color: var(--accent-text); }
.pill.income { background: var(--income-soft); color: var(--income); }
.pill.expense { background: var(--expense-soft); color: var(--expense); }
.pill.save { background: var(--save-soft); color: var(--save); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 0.8s linear infinite; margin: 24px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.fade-in { animation: page-in 0.3s var(--ease) both; }
.pop-in { animation: pop 0.36s var(--spring) both; }
@keyframes pop { from { opacity: 0; transform: scale(0.92); } }
.stagger > * { animation: page-in 0.38s var(--ease) both; }
.stagger > *:nth-child(2) { animation-delay: 0.04s; } .stagger > *:nth-child(3) { animation-delay: 0.08s; }
.stagger > *:nth-child(4) { animation-delay: 0.12s; } .stagger > *:nth-child(5) { animation-delay: 0.16s; }
.stagger > *:nth-child(6) { animation-delay: 0.2s; } .stagger > *:nth-child(n+7) { animation-delay: 0.24s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-delay: 0ms !important; transition-duration: 0.001ms !important; }
}

/* своя кнопка очистки в поиске — системную прячем */
input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
