/* CashApp — веб-интерфейс. Дизайн «Воздух» (docs/design/README.md): цвета — роли темы, а не значения в правилах. */

:root {
  --bg: #ffffff;
  --surface: #f4f5f7;
  --raised: #ffffff;
  --sheet: #ffffff;
  --divider: #f0f1f3;
  --inactive: #d1d5db;
  --text: #111827;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --icon: #374151;
  --accent: #12805c;
  --link: #12805c;
  --on-accent: #ffffff;
  --expense-bg: #fceaea;
  --expense: #b42318;
  --income-bg: #e9f6f0;
  --income: #0b6b4c;
  --transfer-bg: #eaf0fd;
  --transfer: #1d4ed8;
  --warning-bg: #fef3e2;
  --warning: #9a5a00;
  --veil: rgba(255, 255, 255, 0.6);
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.04), 0 8px 24px rgba(17, 24, 39, 0.06);
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100; --c5: #e87ba4; --c-other: #a3a7ae;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
  --shadow-knob: 0 1px 2px rgba(17, 24, 39, 0.2);
  --knob: #ffffff;
  /* Шкалы из DESIGN.md: размеры шрифта и радиусы — только эти шаги */
  --fs-caption: 11px;
  --fs-label: 13px;
  --fs-body: 15px;
  --fs-title: 17px;
  --fs-form: 20px;
  --fs-headline-phone: 24px;
  --fs-headline: 28px;
  --fs-display: 40px;
  --r-bar: 3px;
  --r-icon: 10px;
  --r-button: 14px;
  --r-field: 14px;
  --r-tile: 20px;
  --r-sheet: 24px;
  --r-pill: 999px;
  --radius-tile: var(--r-tile);
  --radius-field: var(--r-field);
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* Кривые движения: встроенные ease-out слишком мягкие. Появление и отклик — --ease-out, шторка — --ease-drawer */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --press: 180ms;
  /* Перемещение по экрану (бегунок вкладок) — плавный разгон и торможение */
  --ease-in-out: cubic-bezier(0.645, 0.045, 0.355, 1);
  color-scheme: light;
}

:root[data-accent="teal"] { --accent: #0f766e; --link: #0f766e; }
:root[data-accent="blue"] { --accent: #3b5bdb; --link: #3b5bdb; }
:root[data-accent="violet"] { --accent: #6741d9; --link: #6741d9; }

:root.dark {
  --bg: #0f1113;
  --surface: #1e2124;
  --raised: #2e3237;
  --sheet: #17191c;
  --divider: #2a2d31;
  --inactive: #3a3e44;
  --text: #eceef0;
  --text-2: #9ba1ab;
  --text-3: #6b7280;
  --icon: #c9cdd3;
  --link: #4cc495;
  --expense-bg: #3a1f1e;
  --expense: #f2867b;
  --income-bg: #16352a;
  --income: #5fcb9c;
  --transfer-bg: #1b2740;
  --transfer: #8ab0ff;
  --warning-bg: #3a2e17;
  --warning: #f2c26b;
  --veil: rgba(15, 17, 19, 0.7);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-knob: 0 1px 2px rgba(0, 0, 0, 0.4);
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181;
  color-scheme: dark;
}
:root.dark[data-accent="teal"] { --link: #4fc7bc; }
:root.dark[data-accent="blue"] { --link: #8aa4f5; }
:root.dark[data-accent="violet"] { --link: #a990f2; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: var(--fs-body)/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); text-decoration: none; text-underline-offset: 3px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Поверхности браузера — тоже из палитры: выделение, курсор, полосы прокрутки, стандартные элементы */
html { accent-color: var(--accent); caret-color: var(--accent); scrollbar-color: var(--inactive) transparent; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text); }
::placeholder { color: var(--text-2); opacity: 1; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--inactive); border-radius: var(--r-pill); border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
/* Меньше движения — не ноль движения: сдвиги и масштаб убираем, затухания и смену цвета оставляем.
   Правила для окон, меню и тостов — в конце файла, рядом с их анимациями. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}

/* ── Каркас ───────────────────────────────────────────── */
/* dvh учитывает адресную строку мобильного браузера; vh — запасное значение для старых браузеров */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
  padding: 20px 14px; border-right: 1px solid var(--divider); background: var(--bg);
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: var(--fs-title); }
.brand-mark {
  width: 32px; height: 32px; border-radius: var(--r-icon); background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center;
}
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-button); border: 0;
  background: none; color: var(--text-2); font-weight: 500; text-align: left; width: 100%; text-decoration: none;
}
.nav-item.active { background: var(--surface); color: var(--accent); }
.nav-item .icon { width: 22px; height: 22px; }
.nav-sep { height: 1px; background: var(--divider); margin: 10px 8px; }
.nav-add {
  margin: 4px 0 14px; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--on-accent); border: 0; border-radius: var(--r-button); padding: 11px 14px; font-weight: 600;
}
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; color: var(--text-3); font-size: var(--fs-label); }

.main { min-width: 0; padding: 28px 32px 48px; max-width: 1440px; width: 100%; }
.page-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0;
  box-shadow: 0 1px 0 transparent; transition: box-shadow .15s ease;
}
/* Шапка прилипла к верху: черта отделяет её от ленты, которая уходит под неё (класс ставит app.js) */
.page-head.stuck { box-shadow: 0 1px 0 var(--divider); }
.page-head h1 { font-size: var(--fs-headline); font-weight: 700; letter-spacing: -0.6px; margin: 0; flex: 1; min-width: 0; }
.page-head .sub { color: var(--text-2); font-size: var(--fs-label); }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.bottom-nav { display: none; }

/* Планшет: узкая колонка значков */
@media (max-width: 1100px) {
  .app { grid-template-columns: 76px 1fr; }
  .sidebar { padding: 16px 10px; align-items: center; }
  .sidebar .brand span, .nav-item span, .nav-add span, .sidebar-foot { display: none; }
  .nav-item, .nav-add { justify-content: center; padding: 12px; }
  .main { padding: 24px 24px 48px; }
}

/* Телефон: нижняя панель как в приложении */
@media (max-width: 720px) {
  /* Высота нижней панели: от неё отступ ленты снизу и место тостов */
  :root { --nav-h: 61px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 12px 16px calc(var(--nav-h) + 35px + env(safe-area-inset-bottom)); }
  /* iOS увеличивает страницу при фокусе в поле со шрифтом меньше 16px — на телефоне поля 16px (исключение из шкалы) */
  .input:not(.money-input), .search input { font-size: 16px; }
  .page-head h1 { font-size: var(--fs-headline-phone); }
  .page-head .btn.add { display: none; }
  .page-head .head-actions:has(.quick) { flex: 1 1 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .page-head .head-icon { order: 1; }
  .page-head .head-actions { order: 2; }
  .page-head .head-actions.editing { flex: 1 1 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); }
  .btn.quick { padding: 6px 8px 6px 6px; gap: 8px; font-size: var(--fs-label); justify-content: flex-start; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--bg); border-top: 1px solid var(--divider);
    min-height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav > a, .bottom-nav > button {
    border: 0; background: none; color: var(--text-2); display: flex; flex-direction: column; align-items: center;
    gap: 2px; font-size: var(--fs-caption); padding: 4px 0; min-height: 44px; text-decoration: none; border-radius: var(--r-button);
  }
  .bottom-nav > a.active { color: var(--accent); }
  .bottom-nav .plus {
    width: 48px; height: 48px; border-radius: var(--r-button); background: var(--accent); color: var(--on-accent);
    justify-self: center; display: grid; place-items: center;
    transition: transform var(--press) var(--ease-out);
  }
  /* Нажатие на «+» — сжимается сама кнопка, а не вся ячейка панели */
  .bottom-nav .add-cell:active .plus { transform: scale(0.94); }
  /* Рамка фокуса — вокруг самого «+», а не всей ячейки панели */
  .bottom-nav .add-cell:focus-visible { outline: none; }
  .bottom-nav .add-cell:focus-visible .plus { outline: 2px solid var(--accent); outline-offset: 2px; }
}

/* ── Иконки ───────────────────────────────────────────── */
.icon { width: 20px; height: 20px; flex: none; }
.icon path { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.icon path.fill { fill: currentColor; stroke: none; }
.tile-icon {
  width: 40px; height: 40px; border-radius: var(--r-icon); display: grid; place-items: center; flex: none;
  background: var(--surface); color: var(--icon); font-size: var(--fs-form); overflow: hidden;
}
.tile-icon.sm { width: 32px; height: 32px; border-radius: var(--r-icon); font-size: var(--fs-body); }
.tile-icon.sm .icon { width: 18px; height: 18px; }
.tile-icon.xs { width: 32px; height: 32px; border-radius: var(--r-icon); }
.tile-icon.xs .icon { width: 16px; height: 16px; }
.tile-icon img { width: 100%; height: 100%; object-fit: cover; }
.tile-icon.round { border-radius: var(--r-pill); }
.tile-icon.symbol { font-size: var(--fs-body); font-weight: 700; }
/* На серой карточке нейтральная плитка значка — на приподнятом слое, иначе она сливается с подложкой */
.card .tile-icon:not([class*="tone-"]), .block-head .tile-icon:not([class*="tone-"]) { background: var(--raised); }
.tone-expense { background: var(--expense-bg); color: var(--expense); }
.tone-income { background: var(--income-bg); color: var(--income); }
.tone-transfer { background: var(--transfer-bg); color: var(--transfer); }
.tone-warning { background: var(--warning-bg); color: var(--warning); }

/* ── Суммы: копейки и символ на 3 пикселя мельче, табличные цифры ── */
.money { font-variant-numeric: tabular-nums; white-space: nowrap; font-feature-settings: "tnum"; }
.money .minor { font-size: calc(1em - 3px); }
.money.plus { color: var(--income); }
.money.minus { color: var(--expense); }
.money.muted { color: var(--text-2); }
.big-money { font-size: var(--fs-display); font-weight: 600; letter-spacing: -1.2px; line-height: 1.1; }
.big-money .minor { color: var(--text-3); }
.big-money.medium { font-size: var(--fs-headline); letter-spacing: -0.6px; }

/* ── Бенто ────────────────────────────────────────────── */
.bento {
  display: grid; gap: 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-flow: dense;
}
.card {
  background: var(--surface); border-radius: var(--radius-tile); padding: 18px 20px; min-width: 0;
  display: flex; flex-direction: column; gap: 12px;
}
.card.span-2 { grid-column: span 2; }
.card.span-4 { grid-column: 1 / -1; }
.card-head { display: flex; align-items: center; gap: 8px; }
.card-head h2 { font-size: var(--fs-title); font-weight: 600; margin: 0; flex: 1; }
/* Ссылка в шапке плитки: текст мелкий, а область нажатия — не меньше 32 px */
.card-head .link {
  font-size: var(--fs-label); font-weight: 500; display: inline-flex; align-items: center;
  min-height: 32px; padding: 0 8px; margin: -6px -8px; border-radius: var(--r-icon);
}
.card .muted { color: var(--text-2); font-size: var(--fs-label); }
/* Опасное действие текстом (удаление аккаунта под «Выйти») */
@media (max-width: 1280px) { .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); } .card.span-2 { grid-column: span 1; } }
@media (max-width: 600px) { .bento { grid-template-columns: 1fr; gap: 12px; } }

/* Главная: плитки на сетке рядов по 80px; колонок 4, уже — 2, на телефоне — одна и высота по содержимому.
   Число колонок выбирает dashboard.js по ширине сетки (data-cols), размеры плиток — span в CSSOM. */
.dash { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 80px; grid-auto-flow: row dense; }
.dash[data-cols="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dash[data-cols="1"] { grid-template-columns: minmax(0, 1fr); grid-auto-rows: auto; gap: 12px; }
.tile { position: relative; overflow: hidden; container-type: inline-size; }
.tile[hidden] { display: none; }
.tile-body { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 12px; scrollbar-width: thin; }
.tile-body.fill { overflow: hidden; }
/* Пока плитка грузится, пустых полос прокрутки нет */
.tile-body:has(> .loading), .tile-body:has(> .error-state) { overflow: hidden; }
.chart-box.fill { flex: 1; min-height: 0; }
.dash[data-cols="1"] .tile, .dash[data-cols="1"] .tile-body { overflow: visible; }
.dash[data-cols="1"] .chart-box.fill { flex: none; height: 220px; }
@container (max-width: 440px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } }

/* Настройка главной: ручки поверх плиток, содержимое не нажимается */
.tile-tools, .tile-resize { display: none; }
.dash.editing .tile { cursor: grab; user-select: none; box-shadow: inset 0 0 0 1.5px var(--inactive); }
.dash.editing .tile > :not(.tile-tools):not(.tile-resize) { pointer-events: none; }
.dash.editing .card-head { padding-right: 80px; }
.dash.editing .tile-tools { display: flex; gap: 4px; position: absolute; top: 12px; right: 12px; }
.dash.editing:not([data-cols="1"]) .tile-resize { display: grid; }
.tile-tools button, .tile-resize {
  place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--r-icon);
  background: var(--raised); color: var(--icon); cursor: pointer; transition: background-color .15s ease, color .15s ease;
}
.tile-tools button { display: grid; }
.tile-grip { cursor: grab; touch-action: none; }
.tile-resize { position: absolute; right: 8px; bottom: 8px; width: 32px; height: 32px; border-radius: var(--r-icon); cursor: nwse-resize; touch-action: none; }
.tile.dragging { z-index: 3; cursor: grabbing; box-shadow: var(--shadow), inset 0 0 0 1.5px var(--accent); }
.dash.editing .tile.resizing { box-shadow: inset 0 0 0 1.5px var(--accent); }
.dash-tray {
  display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; padding: 14px 16px;
  border: 1.5px dashed var(--inactive); border-radius: var(--radius-tile);
}
.dash-tray[hidden] { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Колонки страниц-разделов: список и подробности рядом на широком экране */
.split-view { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.split-view > .side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 1100px) { .split-view { grid-template-columns: 1fr; } .split-view > .side { position: static; } }

/* ── Списки ───────────────────────────────────────────── */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: var(--r-button); min-height: 56px;
  border: 0; background: none; width: 100%; text-align: left; position: relative;
}
/* Строки ленты нажимают десятки раз за день: отклик — только фон, без масштаба */
button.row:active, .row.clickable:active { background: var(--surface); }
.card button.row:active, .card .row.clickable:active { background: var(--raised); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { color: var(--text-2); font-size: var(--fs-label); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.with-icon { display: inline-flex; align-items: center; gap: 4px; vertical-align: bottom; }
.with-icon .icon { width: 14px; height: 14px; }
.row-end { text-align: right; flex: none; }
.row-end .row-sub { font-size: var(--fs-caption); }
.row.archived .row-title { color: var(--text-2); }
.row .reconciled { position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: var(--r-bar); background: var(--inactive); }
.row .reconciled.on { background: var(--income); }
.row.compact { min-height: 44px; padding: 6px 8px; }
/* Имя устройства переносится, а не прячется в многоточие рядом с кнопкой «Отключить» */
.row.device .row-title { white-space: normal; overflow-wrap: anywhere; }

.block { border: 1px solid var(--divider); border-radius: var(--radius-tile); overflow: hidden; margin-bottom: 16px; }
.block-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface);
  font-weight: 600; font-size: var(--fs-label);
}
.block-head .grow { flex: 1; }
.block .list { padding: 4px 8px; }
.block .row + .row::before {
  content: ""; position: absolute; left: 60px; right: 8px; top: 0; height: 1px; background: var(--divider);
}
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 14px 8px 4px; color: var(--text-2); font-size: var(--fs-label); font-weight: 600; }
.day-head .day-total { font-weight: 500; text-align: right; }
.feed-page, .main.column > * { max-width: 800px; }
.empty { color: var(--text-2); text-align: center; padding: 36px 12px; }
.tree-toggle {
  width: 28px; height: 28px; border-radius: var(--r-icon); border: 0; background: none; color: var(--text-2);
  display: grid; place-items: center; flex: none;
}
.tree-toggle.leaf { visibility: hidden; }
.dots { color: var(--text-3); font-size: var(--fs-title); line-height: 0; }

/* ── Кнопки и поля ────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: var(--r-button);
  padding: 10px 16px; font-weight: 600; background: var(--surface); color: var(--text); min-height: 44px;
}
.btn { transition: background-color .15s ease, color .15s ease, transform var(--press) var(--ease-out); }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn.on { background: var(--raised); color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.btn.quick { padding: 6px 14px 6px 6px; gap: 10px; font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.danger { background: var(--expense-bg); color: var(--expense); }
.btn.ghost { background: none; color: var(--link); padding: 8px 10px; }
.btn.icon-only { padding: 10px; width: 44px; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: var(--fs-label); border-radius: var(--r-button); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: var(--fs-label); color: var(--text-2); font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; border: 1.5px solid transparent; background: var(--surface); border-radius: var(--radius-field);
  padding: 11px 14px; min-height: 46px; outline: none;
}
.input:focus { border-color: var(--accent); background: var(--bg); }
.input.invalid { border-color: var(--expense); }
textarea.input { resize: vertical; min-height: 80px; }
.input.money-input { font-size: var(--fs-form); font-weight: 600; font-variant-numeric: tabular-nums; }
.field-hint { font-size: var(--fs-label); color: var(--text-2); }
.field-error { font-size: var(--fs-label); color: var(--expense); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

.segmented {
  display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface);
  border-radius: var(--r-button); padding: 4px; gap: 4px;
}
/* Выбранный сегмент отмечает бегунок .seg-thumb: он переезжает к новой кнопке (ui.js → segmented()),
   а кнопки лежат поверх него и меняют только цвет текста */
.segmented { position: relative; }
.segmented button {
  position: relative; z-index: 1;
  border: 0; background: none; padding: 8px 14px; border-radius: var(--r-icon); font-weight: 600; color: var(--text-2);
  min-height: 38px; white-space: nowrap;
}
.segmented button.on { color: var(--text); }
.seg-thumb {
  position: absolute; left: 0; top: 4px; bottom: 4px; width: 0; z-index: 0; pointer-events: none;
  border-radius: var(--r-icon); background: var(--raised); box-shadow: var(--shadow-sm);
  transition: transform 280ms var(--ease-in-out), width 280ms var(--ease-in-out), opacity 150ms ease;
}
.seg-thumb.instant { transition: none; }
.segmented.accent .seg-thumb { background: var(--accent); box-shadow: none; }
.segmented.expense button.on { color: var(--expense); }
.segmented.wide { display: grid; width: 100%; }
/* Вкладки шире экрана прокручиваются вбок; край, за которым есть ещё вкладки, затухает */
.segmented.scroll-x { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented.scroll-x::-webkit-scrollbar { display: none; }
.segmented.scroll-x[data-fade="end"] { mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); }
.segmented.scroll-x[data-fade="start"] { mask-image: linear-gradient(to left, #000 calc(100% - 40px), transparent); }
.segmented.scroll-x[data-fade="both"] { mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 40px), transparent); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; cursor: pointer; }
.switch input { appearance: none; width: 48px; height: 30px; border-radius: var(--r-pill); background: var(--inactive); position: relative; flex: none; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: var(--r-pill); background: var(--knob); transition: transform 240ms var(--ease-out); box-shadow: var(--shadow-knob); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(18px); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: var(--surface); color: var(--text);
  border-radius: var(--r-pill); padding: 6px 12px; font-size: var(--fs-label); font-weight: 500; min-height: 34px;
}
.chip.on { background: var(--accent); color: var(--on-accent); }
.chip .x { opacity: .7; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.search {
  display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: var(--r-button); padding: 0 12px;
  min-height: 44px; flex: 1; min-width: 180px;
}
.search input { border: 0; background: none; outline: none; flex: 1; min-width: 0; padding: 10px 0; }

/* ── Окна: по центру на компьютере, шторка снизу на телефоне ── */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: var(--veil);
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fade 200ms var(--ease-out);
}
.dialog {
  background: var(--sheet); border-radius: var(--r-sheet); box-shadow: var(--shadow); width: 100%; max-width: 560px;
  max-height: calc(100vh - 48px); max-height: calc(100dvh - 48px); display: flex; flex-direction: column; border: 1px solid var(--divider);
  animation: rise 260ms var(--ease-out);
}
/* Закрытие быстрее открытия; пока окно уходит, оно уже не нажимается (класс ставит dialog() в ui.js) */
.overlay.closing { animation: fade-out 180ms var(--ease-out) forwards; pointer-events: none; }
.overlay.closing .dialog { animation: sink 180ms var(--ease-out) forwards; }
.dialog.wide { max-width: 760px; }
.dialog.narrow { max-width: 420px; }
.dialog-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 8px; }
.dialog-head h2 { font-size: var(--fs-form); font-weight: 600; margin: 0; flex: 1; }
.dialog-body { padding: 8px 20px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.dialog-foot { display: flex; gap: 10px; padding: 12px 20px 20px; }
.dialog-foot .btn { flex: 1; }
.dialog-foot .btn.danger { flex: 0 0 auto; }
@media (max-width: 720px) {
  .overlay { align-items: flex-end; padding: 0; }
  .dialog, .dialog.wide, .dialog.narrow {
    max-width: none; border-radius: var(--r-sheet) var(--r-sheet) 0 0; max-height: 94vh; max-height: 94dvh; border: 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: sheet-in 400ms var(--ease-drawer);
  }
  .overlay.closing .dialog { animation: sheet-out 260ms var(--ease-out) forwards; }
  .dialog::before { content: ""; width: 36px; height: 4px; border-radius: var(--r-bar); background: var(--inactive); margin: 8px auto 0; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
/* Окно только выезжает: без прозрачности, чтобы лента не просвечивала сквозь форму в первые кадры */
@keyframes rise { from { transform: translateY(8px) scale(0.98); } }
@keyframes sink { to { transform: translateY(6px) scale(0.98); } }
/* Шторка на телефоне выезжает из-за нижнего края на свою высоту */
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
/* Всплывающие меню растут из кнопки: начало — в углу у неё (transform-origin ставит JS) */
@keyframes pop { from { opacity: 0; transform: scale(0.97); } }

.menu {
  position: fixed; z-index: 60; background: var(--sheet); border: 1px solid var(--divider); border-radius: var(--r-button);
  box-shadow: var(--shadow); padding: 6px; min-width: 200px; max-width: 300px;
  animation: pop 180ms var(--ease-out);
}
.menu button {
  display: flex; gap: 10px; align-items: center; width: 100%; border: 0; background: none; padding: 10px 12px;
  border-radius: var(--r-icon); text-align: left;
}
.menu button:focus-visible { outline-offset: -2px; background: var(--surface); }
.menu button.danger { color: var(--expense); }
.menu-head { padding: 8px 12px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--divider); min-width: 0; }
.menu-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-sub { color: var(--text-2); font-size: var(--fs-label); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Профиль в шапке главной: круглая кнопка после действий; на телефоне — рядом с приветствием */
.head-icon {
  order: 3; flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-button); border: 0;
  background: var(--surface); color: var(--icon);
}
.head-icon[aria-expanded="true"] { background: var(--divider); color: var(--accent); }
.head-icon .icon { width: 22px; height: 22px; }
.account-btn { border-radius: var(--r-pill); }

.picker-list { max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; }
.picker-list .row { min-height: 46px; }
.picker-list .row.selected { background: var(--surface); }
.picker-list .row.selected .row-title { color: var(--accent); }

.toast-area { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; }
/* Тост выезжает снизу и уходит туда же; переход, а не keyframes — несколько тостов подряд не дёргаются.
   Пока на тосте курсор или вкладка скрыта, таймер стоит (ui.js) */
.toast {
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--r-button); font-size: var(--fs-label);
  box-shadow: var(--shadow); max-width: 90vw;
  transition: opacity 360ms ease, transform 360ms var(--ease-out);
}
@starting-style { .toast { opacity: 0; transform: translateY(100%); } }
.toast.leaving { opacity: 0; transform: translateY(8px); transition-duration: 200ms; }
.toast.error { background: var(--expense); color: var(--knob); }
@media (max-width: 720px) { .toast-area { bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); } }

/* ── Форма операции ───────────────────────────────────── */
.parts { display: flex; flex-direction: column; gap: 10px; }
.part { background: var(--surface); border-radius: var(--r-button); padding: 12px; display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.part .wide { grid-column: 1 / -1; }
.part .input { background: var(--bg); }
.part-head { display: flex; align-items: center; gap: 8px; grid-column: 1 / -1; }
.part-head .grow { flex: 1; }
.remaining { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-radius: var(--r-icon); background: var(--warning-bg); color: var(--warning); font-size: var(--fs-label); }
.remaining.ok { background: var(--income-bg); color: var(--income); }
.share { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) auto; gap: 8px; align-items: center; }
@media (max-width: 600px) { .part { grid-template-columns: 1fr; } }

/* ── Отчёты и графики ─────────────────────────────────── */
.chart { width: 100%; height: auto; display: block; }
.chart-box { width: 100%; min-width: 0; }
.chart-box .chart { width: auto; height: auto; }
.chart .bar-hit { fill: transparent; }
.chart .base-line { stroke: var(--inactive); }
.chart text { fill: var(--text-2); font-size: var(--fs-caption); font-family: var(--font); }
.chart .grid-line { stroke: var(--divider); }
.chart .pickable { cursor: pointer; }
.chart text.chart-center { fill: var(--text); font-size: var(--fs-body); font-weight: 600; }
.bar-income { fill: var(--income); }
.bar-expense { fill: var(--expense); }
.legend { display: flex; flex-direction: column; gap: 4px; }
.legend-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: var(--r-icon); }
.legend-row.clickable { cursor: pointer; }
.swatch { width: 12px; height: 12px; border-radius: var(--r-bar); flex: none; }
.legend-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-row .pct { color: var(--text-2); font-size: var(--fs-label); width: 48px; text-align: right; }
/* Линия капитала: заливка под линией — тот же акцент, едва заметно */
.chart .line-stroke { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line-area { fill: var(--accent); opacity: .1; }
.chart .line-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
/* Наведение на сектор круга или строку легенды: пара подсвечивается, остальное приглушается */
.donut-seg { transition: opacity .15s, stroke-width .15s; }
.donut.focused .donut-seg:not(.hl) { opacity: .35; }
.donut .donut-seg.hl { stroke-width: 26; }
.legend-row { transition: opacity .15s, background .15s; }
.legend.focused .legend-row:not(.hl) { opacity: .5; }
.legend-row.hl { background: var(--raised); }
@media (prefers-reduced-motion: reduce) { .donut-seg, .legend-row { transition: none; } }
.bar-track { height: 6px; border-radius: var(--r-bar); background: var(--divider); overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--r-bar); background: var(--accent); }
.donut-wrap { display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: center; }
@media (max-width: 600px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } }
.period { display: flex; align-items: center; gap: 4px; }
.period .label { min-width: 140px; text-align: center; font-weight: 600; }
.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi .label { color: var(--text-2); font-size: var(--fs-label); }
.kpi .value { font-size: var(--fs-form); font-weight: 600; letter-spacing: -0.4px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }

/* ── Вход ─────────────────────────────────────────────── */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px; }
.auth-card h1 { font-size: var(--fs-headline); letter-spacing: -0.6px; margin: 8px 0 0; }
.auth-card p { color: var(--text-2); margin: 0; }
.auth-card .brand { padding: 0; }
.notice { padding: 10px 14px; border-radius: var(--r-icon); background: var(--warning-bg); color: var(--warning); font-size: var(--fs-label); }
.notice.error { background: var(--expense-bg); color: var(--expense); }
.notice.ok { background: var(--income-bg); color: var(--income); }

/* Окно иконки — как в приложении: вкладки «Иконки | Эмодзи | Своя», выбранная клетка — в цвете элемента */
.icon-dialog { --pick: var(--accent); --pick-bg: color-mix(in srgb, var(--accent) 16%, transparent); max-width: 460px; }
.icon-dialog[data-tone="income"] { --pick: var(--income); --pick-bg: var(--income-bg); }
.icon-dialog[data-tone="expense"] { --pick: var(--expense); --pick-bg: var(--expense-bg); }
.icon-dialog .dialog-body { gap: 10px; }
.icon-preview .tile-icon { width: 40px; height: 40px; }
.icon-pane { height: min(460px, 56vh); overflow-y: auto; display: flex; flex-direction: column; }
.icon-pane.emoji { overflow: hidden; gap: 6px; }
.icon-group-title { font-size: var(--fs-label); color: var(--text-2); margin: 14px 0 8px; font-weight: 600; }
.icon-pane > .icon-group-title:first-child { margin-top: 4px; }
.icon-cells { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.icon-cells .icon-cell {
  aspect-ratio: 1; border: 0; border-radius: var(--r-button); background: var(--surface); color: var(--icon);
  display: grid; place-items: center; cursor: pointer;
}
.icon-cells .icon-cell svg { width: 24px; height: 24px; }
.icon-cell.on, .icon-cell.on:hover { background: var(--pick-bg); color: var(--pick); box-shadow: inset 0 0 0 2px var(--pick); }
.icon-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.emoji-tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: none; }
.emoji-tabs::-webkit-scrollbar { display: none; }
.emoji-tabs button {
  flex: none; width: 40px; height: 40px; border: 0; border-radius: var(--r-pill); background: none; font-size: 22px; cursor: pointer;
}
.emoji-tabs button.on { background: var(--surface); }
.emoji-scroll { flex: 1; min-height: 0; overflow-y: auto; }
.emoji-scroll > .icon-group-title:first-child { margin-top: 4px; }
.emoji-cells { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 4px; }
.emoji-cells .icon-cell {
  aspect-ratio: 1; border: 0; border-radius: 12px; background: none; font-size: 26px; line-height: 1; cursor: pointer;
  display: grid; place-items: center; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}
.emoji-scroll .loading { min-height: 200px; }
.icon-drop { margin-top: 12px; height: 220px; justify-content: center; padding: 0 24px; width: 100%; font: inherit; color: var(--text); }
.icon-drop .drop-icon { width: 56px; height: 56px; background: var(--raised); color: var(--accent); }
.icon-drop .drop-icon .icon { width: 26px; height: 26px; }
.icon-dialog .dialog-foot .btn[disabled] { opacity: .45; cursor: default; }

.loading { display: grid; place-items: center; min-height: 40vh; color: var(--text-2); }
.spinner { width: 28px; height: 28px; border-radius: var(--r-pill); border: 3px solid var(--divider); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Приложение не запустилось (модуль не загрузился): через 15 с вместо спиннера — объяснение и ссылка «Обновить».
   Только CSS: встроенные скрипты запрещены политикой CSP. */
.loading.boot { gap: 16px; text-align: center; padding: 0 16px; }
.boot-stuck { display: none; }
.loading.boot .spinner { animation: spin .8s linear infinite, boot-hide 0s linear 15s forwards; }
.loading.boot .boot-stuck { display: block; visibility: hidden; animation: boot-show 0s linear 15s forwards; }
@keyframes boot-hide { to { visibility: hidden; } }
@keyframes boot-show { to { visibility: visible; } }
/* Место, где не загрузились данные: причина и «Повторить» вместо пустоты */
.error-state {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  padding: 32px 16px; color: var(--text-2);
}
.error-state .error-title { color: var(--text); font-weight: 600; }
.error-state .error-sub { font-size: var(--fs-label); }
.error-state .btn { margin-top: 8px; }
.error-state.compact { padding: 12px 8px; margin: auto 0; }
.sync-dot { width: 8px; height: 8px; border-radius: var(--r-pill); background: var(--income); display: inline-block; }
.sync-dot.off { background: var(--inactive); }
.tag { font-size: var(--fs-caption); padding: 2px 8px; border-radius: var(--r-pill); background: var(--surface); color: var(--text-2); font-weight: 600; }
.tag.accent { background: var(--income-bg); color: var(--income); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.more-grid > a, .more-grid > button {
  border: 0; background: var(--surface); border-radius: var(--r-tile); padding: 16px 8px; display: flex; flex-direction: column;
  align-items: center; gap: 8px; font-size: var(--fs-label); color: var(--text); text-decoration: none;
}
.more-grid .icon { width: 24px; height: 24px; color: var(--icon); }
.text-2 { color: var(--text-2); }
.caption { font-size: var(--fs-label); }
.section-title { margin: 0; font-size: var(--fs-title); font-weight: 600; }
.text-3 { color: var(--text-3); }
.grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.hstack { display: flex; gap: 10px; align-items: center; }
.wrap { flex-wrap: wrap; }

/* ── Сверка с выпиской ─────────────────────────────────── */
.statement { display: flex; flex-direction: column; gap: 12px; }
.statement .center { text-align: center; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; cursor: pointer;
  padding: 40px 24px; border: 2px dashed var(--divider); border-radius: var(--r-tile); background: var(--surface);
  transition: border-color .15s, background .15s;
}
.dropzone.over { border-color: var(--accent); }
.dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone-title { font-weight: 600; font-size: var(--fs-title); }
.dropzone .muted { color: var(--text-2); font-size: var(--fs-label); max-width: 460px; }
.stack.tight { gap: 4px; }
.row.choice { cursor: pointer; border-radius: var(--r-icon); }
.row.choice.on { background: var(--raised); }
.row.choice input { accent-color: var(--accent); }
/* Пары строк: слева — выписка, справа — CashApp; половина без пары — серая подпись */
.sv-head {
  display: grid; grid-template-columns: 28px 1fr 1fr 40px; gap: 8px; padding: 0 8px;
  color: var(--text-2); font-size: var(--fs-label); font-weight: 600;
}
.sv-head span:first-child { grid-column: 2; }
.sv-list { display: flex; flex-direction: column; gap: 4px; }
.sv-line {
  display: grid; grid-template-columns: 28px 1fr 1fr 40px; gap: 8px; align-items: center;
  padding: 6px 8px; border-radius: var(--r-button); background: var(--surface);
}
.sv-cell { position: relative; display: flex; align-items: center; gap: 10px; min-width: 0; padding-left: 8px; }
.sv-cell.empty { color: var(--text-2); font-size: var(--fs-label); font-style: italic; }
.sv-cell .reconciled { position: absolute; left: 0; top: 4px; bottom: 4px; width: 3px; border-radius: var(--r-bar); background: var(--inactive); }
.sv-cell .reconciled.on { background: var(--income); }
.sv-mark {
  width: 24px; height: 24px; border-radius: var(--r-pill); display: grid; place-items: center;
  font-weight: 700; font-size: var(--fs-label);
}
.sv-mark .icon { width: 14px; height: 14px; }
.sv-line.matched .sv-mark { background: var(--income-bg); color: var(--income); }
.sv-line.missing .sv-mark, .sv-line.extra .sv-mark { background: var(--expense-bg); color: var(--expense); }
.sv-line.similar .sv-mark { background: var(--warning-bg); color: var(--warning); }
.sv-line.skipped { opacity: .45; }
@media (max-width: 700px) {
  .sv-head { display: none; }
  .sv-line { grid-template-columns: 28px 1fr 40px; }
  .sv-line .sv-cell:nth-of-type(2) { grid-column: 2; grid-row: 2; }
  .sv-line > .btn { grid-column: 3; grid-row: 1; }
}

/* ── Отчёт «Сравнение периодов» — как в приложении ──────────────────────────────── */
.cmp { max-width: 800px; display: flex; flex-direction: column; gap: 14px; }
.cmp-head { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.cmp-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; }
.cmp-title h2 { margin: 0; font-size: var(--fs-title); font-weight: 600; }
.cmp-account { max-width: 240px; }
.segmented.accent button.on { color: var(--on-accent); }
.cmp-periods { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.cmp-group { display: flex; gap: 6px; }
.cmp-with { color: var(--text); margin: 0 6px; }
.period-chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 36px; padding: 6px 8px 6px 12px; border: 0;
  border-radius: var(--r-icon); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.period-chip .icon { width: 16px; height: 16px; color: var(--text-2); }
.period-chip[aria-expanded="true"] { background: var(--divider); }
.period-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.period-pop {
  position: fixed; z-index: 60; background: var(--sheet); border: 1px solid var(--divider); border-radius: var(--r-button);
  box-shadow: var(--shadow); padding: 10px; width: 260px;
  animation: pop 180ms var(--ease-out);
}
.period-pop-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; margin-bottom: 6px; }
.period-pop-head.center { justify-content: center; min-height: 32px; }
.period-pop-head .btn.icon-only { width: 36px; padding: 6px; }
.period-pop-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.period-pop-grid button, .period-pop-list button {
  border: 0; background: none; border-radius: var(--r-icon); min-height: 40px; color: var(--text); font: inherit; cursor: pointer;
}
.period-pop-grid button[disabled] { color: var(--text-3); cursor: default; }
.period-pop-grid button.on, .period-pop-list button.on { background: var(--income-bg); color: var(--income); font-weight: 600; }
.period-pop-list { display: flex; flex-direction: column; gap: 2px; max-height: min(60vh, 420px); overflow-y: auto; }
.period-pop-list button { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 10px; text-align: left; }
.period-pop-note { color: var(--text-2); font-size: var(--fs-label); }
.period-pop-list button.on .period-pop-note { color: inherit; }
.period-pop-list .period-pop-more { justify-content: center; color: var(--text-2); }
.cmp-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cmp-tile { background: var(--surface); border-radius: 16px; padding: 10px 12px; min-width: 0; }
.cmp-tile-label { color: var(--text-2); font-size: var(--fs-label); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-tile-value { font-weight: 600; margin-top: 2px; }
.cmp-legend { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: var(--fs-label); }
.cmp-dot { width: 10px; height: 10px; border-radius: var(--r-pill); background: var(--accent); }
.cmp-dot.before { background: var(--text-3); margin-left: 10px; }
.cmp .block { margin-bottom: 0; }
.cmp-row { align-items: center; padding: 12px 8px; }
.cmp-row .tile-icon { width: 40px; height: 40px; }
.tile-icon.tone-accent { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.cmp-more { color: var(--text-3); }
.cmp-bar { height: 4px; border-radius: 2px; background: var(--divider); margin: 6px 12px 0 0; overflow: hidden; }
.cmp-bar i { display: block; height: 100%; border-radius: 2px; background: var(--accent); }
.cmp-bar.before i { background: var(--text-3); }
.cmp-amount { font-weight: 600; }
.cmp-pct.plus { color: var(--income); }
.cmp-pct.minus { color: var(--expense); }
.cmp-body .loading { min-height: 200px; }
@media (max-width: 600px) {
  .cmp-tiles { gap: 6px; }
  .cmp-tile { padding: 8px 10px; }
  .cmp-with { flex-basis: 100%; margin: 4px 0 0; }
}

/* ── Счета: итог, сортировка, сворачиваемые блоки ─────────────────────────────── */
.accounts-total { max-width: 800px; margin-bottom: 12px; }
.accounts-tools { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.accounts-tools .muted { font-size: var(--fs-label); }
.sort-button { color: var(--text); font-weight: 600; padding: 6px 8px; gap: 4px; }
.sort-button .icon { width: 16px; height: 16px; color: var(--text-2); }
button.fold { width: 100%; border: 0; font: inherit; text-align: left; cursor: pointer; color: inherit; }
button.block-head.fold { font-size: var(--fs-label); font-weight: 600; }
button.day-head.fold { background: none; align-items: center; }
button.fold:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.fold-mark { display: inline-flex; color: var(--text-2); }
.fold-mark .icon { width: 16px; height: 16px; }
.fold-count { color: var(--text-2); font-weight: 500; }

/* ── Нажатие: всё, что нажимается, чуть сжимается — интерфейс «слышит» палец и мышь ── */
.nav-item, .chip, .segmented button, .head-icon, .period-chip, .icon-cells .icon-cell, .emoji-cells .icon-cell,
.emoji-tabs button, .more-grid > a, .more-grid > button, .tile-tools button, .tree-toggle, .bottom-nav > a {
  transition: background-color .15s ease, color .15s ease, transform var(--press) var(--ease-out);
}
.nav-item:active, .chip:active, .segmented button:active, .head-icon:active, .period-chip:active,
.icon-cells .icon-cell:active, .emoji-cells .icon-cell:active, .emoji-tabs button:active,
.more-grid > a:active, .more-grid > button:active, .tile-tools button:active, .tree-toggle:active,
.bottom-nav > a:active { transform: scale(0.97); }

/* ── Наведение: только там, где есть мышь. На телефоне нажатие вызывает :hover, и подсветка залипает на строке ── */
@media (hover: hover) and (pointer: fine) {
  a:hover { text-decoration: underline; }
  .nav-item:hover { background: var(--surface); color: var(--text); text-decoration: none; }
  .tile-tools button:hover, .tile-resize:hover { color: var(--accent); }
  button.row:hover, .row.clickable:hover { background: var(--surface); }
  .card button.row:hover, .card .row.clickable:hover { background: var(--raised); }
  .tree-toggle:hover { background: var(--raised); }
  /* Наведение на кнопку — смена фона по роли темы, а не filter: фон плавно меняется и виден в тёмной теме */
  .btn:hover:not(:disabled) { background: var(--divider); }
  .btn.on:hover:not(:disabled) { background: var(--raised); }
  .btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
  .btn.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--expense-bg) 85%, var(--expense)); }
  .btn.ghost:hover:not(:disabled) { background: var(--surface); }
  .card .btn.ghost:hover:not(:disabled) { background: var(--raised); }
  .menu button:hover { background: var(--surface); }
  .head-icon:hover { background: var(--divider); color: var(--accent); }
  .chart .pickable:hover .bar-hit, .chart .line-point.pickable:hover .bar-hit { fill: var(--divider); }
  .legend-row.clickable:hover { background: var(--raised); }
  .icon-cell:hover { background: var(--divider); }
  .emoji-tabs button:hover { background: var(--surface); }
  .dropzone:hover { border-color: var(--accent); }
  .period-chip:hover { background: var(--divider); }
  .period-pop-grid button:hover:not([disabled]), .period-pop-list button:hover { background: var(--surface); }
  button.block-head.fold:hover { background: var(--divider); }
}

/* ── Меньше движения: без сдвигов и масштаба, остаются затухания ── */
@media (prefers-reduced-motion: reduce) {
  .dialog, .overlay.closing .dialog { animation: none; }
  .menu, .period-pop { animation: fade 180ms ease; }
  .toast { transition: opacity 200ms ease; }
  .toast.leaving { transform: none; }
  .btn:active:not(:disabled), .bottom-nav .add-cell:active .plus,
  .nav-item:active, .chip:active, .segmented button:active, .head-icon:active, .period-chip:active,
  .icon-cells .icon-cell:active, .emoji-cells .icon-cell:active, .emoji-tabs button:active,
  .more-grid > a:active, .more-grid > button:active, .tile-tools button:active, .tree-toggle:active,
  .bottom-nav > a:active { transform: none; }
  .switch input::after { transition: none; }
  .seg-thumb { transition: opacity 150ms ease; }
  /* Вращение — тоже движение: спиннер мягко пульсирует, а не мигает */
  .spinner, .loading.boot .spinner { border-color: var(--accent); animation: breathe 1.6s ease-in-out infinite; }
  .loading.boot .spinner { animation: breathe 1.6s ease-in-out infinite, boot-hide 0s linear 15s forwards; }
}
@keyframes breathe { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { @starting-style { .toast { transform: none; } } }
