/* =========================================================
   SLATE — Family Budget PWA
   2026-05-13 · полный rewrite по концепции C1 SLATE.

   Midnight indigo (#1b1a31, тёплый undertone) + ECG teal brand
   (#1fbfa0). Собственная айдентика, уход от generic-лайма.
   Layout — POCKET BANK: hero с двумя числами (расход+остаток),
   3 inline-KPI, top-3 pills, 2px progress bars в категориях,
   underline-сверху индикатор активного таба.
   ========================================================= */

/* =========================================================
   0. TOKENS
   ========================================================= */
:root {
  /* MIDNIGHT INDIGO — полночный фиолет-индиго, тёплый undertone */
  --bg:           #1b1a31;
  --bg-soft:      #201e3a;
  --surface:      #232244;
  --surface-2:    #2d2b52;
  --surface-3:    #3a3766;

  /* hairlines */
  --rule:         #2d2b52;
  --rule-2:       #3a3766;
  --rule-3:       #494680;

  /* ink — подняли контраст (текст был блеклым, #8.4): основной ближе к белому,
     вторичный/третичный заметно ярче. */
  --ink:          #f3f6fa;
  --ink-2:        #c3ccd6;
  --ink-3:        #aeb7c2;
  --ink-4:        #545c66;

  /* BRAND — ECG teal (эмеральд-бирюза, «линия пульса») */
  --brand:        #1fbfa0;
  --brand-2:      #4fdcc0;
  --brand-deep:   #0c8f78;
  --brand-on:     #041613;
  --brand-tint:   rgba(31, 191, 160, 0.14);
  --brand-edge:   rgba(31, 191, 160, 0.34);
  --on-accent:    #ffffff;

  /* PRO — акцент платных/премиум-разделов (фиолетовый, отдельный от бренда и
     семантики, чтобы PRO-плашки не сливались с обычным лаймовым акцентом). */
  --pro:          #c084fc;
  --pro-2:        #d4a8fd;
  --pro-tint:     rgba(192, 132, 252, 0.13);
  --pro-edge:     rgba(192, 132, 252, 0.36);
  --pro-on:       #0d1117;

  /* semantic — финтех-приглушённые */
  --income:       #3fb950;
  --income-2:     #56d364;
  --income-tint:  rgba(63, 185, 80, 0.13);
  --expense:      #f85149;
  --expense-2:    #ff6b63;
  --expense-tint: rgba(248, 81, 73, 0.13);
  --warn:         #d29922;
  --warn-tint:    rgba(210, 153, 34, 0.14);
  --info:         #58a6ff;
  --danger:       #f85149;
  --danger-deep:  #b62324;

  /* category palette — GitHub-ish accent colors */
  --c-food:       #a3e635;
  --c-trans:      #58a6ff;
  --c-cafe:       #d29922;
  --c-health:     #bc8cff;
  --c-cloth:      #79c0ff;
  --c-home:       #ff7b72;
  --c-fun:        #ffa657;
  --c-other:      #8b949e;

  /* type — Onest на всё приложение. Токены --font-display / --font-ui /
     --font-numeric разделены семантически (заголовки / интерфейс / числовые
     данные с tabular-nums), но намеренно используют одну гарнитуру: для
     плотного финтех-UI один выверенный гротеск цельнее дисплейной пары.
     Моно-шрифты (JetBrains Mono) отвергнуты — нуль с точкой внутри. */
  --font-display: 'Onest', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-ui:      'Onest', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-numeric: 'Onest', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* spacing 4pt */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;
  --page-px:    16px;
  --page-px-lg: 24px;
  --content-max: 460px;

  /* radii */
  --r-xs: 4px; --r-sm: 8px; --r-md: 10px;
  --r-lg: 14px; --r-xl: 18px; --r-2xl: 22px;
  --r-pill: 999px;

  /* shadows — inner refraction only */
  --sh-edge:   inset 0 1px 0 rgba(255,255,255,0.04);
  --sh-edge-2: inset 0 1px 0 rgba(255,255,255,0.07);

  /* motion */
  --ease:        cubic-bezier(0.32, 0.72, 0, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-press:  cubic-bezier(0.4, 0, 0.2, 1);
  --dur-1: 100ms; --dur-2: 180ms; --dur-3: 280ms; --dur-4: 380ms;

  /* Движение — выровнено с Flutter Motion */
  --mo-fast: 120ms;     /* нажатие, чекбокс, chevron */
  --mo-base: 220ms;     /* смена состояния, sliding-индикатор, switcher */
  --mo-layout: 320ms;   /* аккордеон, bar-fill, staggered reveal */
  --mo-hero: 520ms;     /* count-up сумм */
  --mo-ease: cubic-bezier(0.33, 1, 0.68, 1);       /* easeOutCubic */
  --mo-decisive: cubic-bezier(0.22, 1, 0.36, 1);   /* sliding-индикатор */

  --nav-h:        62px;
  --nav-pb:       calc(var(--nav-h) + env(safe-area-inset-bottom, 0) + 28px);
  --safe-top:     env(safe-area-inset-top, 0);
  --safe-bottom:  env(safe-area-inset-bottom, 0);
}

/* =========================================================
   1. RESET + GLOBALS
   ========================================================= */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
html { color-scheme: dark; }
body {
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* =========================================================
   2. TYPE
   ========================================================= */
h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-wrap: balance;
}
h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(20px, 5vw, 26px);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
h2 { font-size: 16px; font-weight: 600; }
h3 {
  font-size: 11px; font-weight: 700;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
p { margin: 0; }
.muted { color: var(--ink-2); }
.dim   { color: var(--ink-3); }

/* =========================================================
   3. BUTTONS + INPUTS
   ========================================================= */
button {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: background var(--dur-2) var(--ease-press),
              transform var(--dur-1) var(--ease-press),
              border-color var(--dur-2) var(--ease-press);
}
/* :where() — нулевая специфичность: не перекрывает фон кнопок со
   своим цветом (свотчи палитры, лаймовая «Добавить операцию» и т.п.) */
button:where(:hover) { background: var(--surface-3); border-color: var(--rule-2); }
button:active { transform: scale(0.97); }

button.primary {
  background: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand-deep) 70%, transparent);
  color: var(--brand-on);
  font-weight: 700;
  letter-spacing: -0.005em;
  padding: 12px 16px;
  box-shadow: var(--sh-edge-2);
}
button.primary:hover  { filter: brightness(1.06); }
button.primary:active { filter: brightness(0.94); }
.form-actions .primary[disabled],
button.primary[disabled] {
  background: var(--surface-2);
  border-color: var(--rule-2);
  color: var(--ink-4);
  box-shadow: none;
  cursor: not-allowed;
  filter: none;
}
.form-actions .primary[disabled]:hover,
button.primary[disabled]:hover {
  background: var(--surface-2);
  border-color: var(--rule-2);
  filter: none;
}

button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}
button.ghost:hover { color: var(--ink); background: var(--surface-2); }

button.primary.danger {
  background: var(--danger);
  color: var(--on-accent);
  border-color: var(--danger-deep);
}

button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

input, select, textarea {
  width: 100%;
  min-height: 44px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font: inherit;
  /* 16px — иначе iOS Safari зумит страницу при фокусе на инпут */
  font-size: 16px;
  outline: none;
  transition: border-color var(--dur-2) var(--ease),
              background var(--dur-2) var(--ease);
}
input:focus, select:focus, textarea:focus,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: var(--brand);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px var(--brand-tint);
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

/* =========================================================
   3b. SLIDING SEGMENTS
   ========================================================= */
.seg {
  position: relative;
  display: flex;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: 3px;
  isolation: isolate;
}
.seg--surface2 { background: var(--surface-2); }
.seg-ind {
  position: absolute;
  top: 3px; left: 3px; bottom: 3px;
  width: calc((100% - 6px) / var(--seg-n, 2));
  border-radius: var(--r-sm);
  background: var(--brand-tint);
  transform: translateX(calc(var(--seg-i, 0) * 100%));
  transition: transform var(--mo-base) var(--mo-decisive);
  z-index: 0;
}
.seg-btn {
  flex: 1 1 0;
  z-index: 1;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: var(--seg-vpad, 7px) 4px;
  font: inherit;
  font-size: var(--seg-fs, 13px);
  font-weight: 600;
  color: var(--ink-3);
  transition: color var(--mo-base) var(--mo-ease);
}
.seg-btn[aria-selected="true"] { color: var(--brand-2); }
.seg-btn:disabled { color: var(--ink-4); cursor: default; }
@media (prefers-reduced-motion: reduce) {
  .seg-ind { transition: none; }
}

/* Переключатель разделов вкладки «Планы»: Планы / Цели / Регулярные */
.plan-sections {
  display: flex;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: 3px;
  margin: 8px 0 4px;
}
.plan-sec-btn {
  /* base=auto (по контенту): длинный лейбл «Регулярные» не ужимается ниже своей
     ширины и не режется многоточием; grow=1 растягивает сегменты, заполняя
     плашку. Было flex:1 1 0 — равная нулевая база, из-за неё «Регулярные»
     получал столько же, сколько «Цели», и обрезался. */
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 7px 6px;
  font: inherit;
  /* overflow:hidden+ellipsis — последняя страховка на сверхузких экранах. */
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  color: var(--ink-3);
  border-radius: var(--r-sm);
  transition: color var(--mo-base) var(--mo-ease),
              background var(--mo-base) var(--mo-ease);
}
.plan-sec-btn.active { color: var(--brand-2); background: var(--brand-tint); }

/* Заголовок группы внутри секции (Долги: Мне должны / Я должен). */
.plan-group-title {
  font-size: 11px; font-weight: 700; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--ink-3);
  margin: var(--sp-4) 4px var(--sp-2);
}
#plan-section-debts .plan-group-title:first-of-type { margin-top: 4px; }

/* =========================================================
   4. MODAL + SHEET
   ========================================================= */
.modal-scrim {
  position: fixed; inset: 0;
  background: rgba(1, 4, 9, 0.65);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  transition: opacity var(--dur-3) var(--ease),
              background-color var(--dur-3) var(--ease);
}
@starting-style {
  .modal-scrim { opacity: 0; background: rgba(1,4,9,0); }
}
.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  margin: 0 auto;
  background: var(--surface);
  border-top-left-radius: var(--r-2xl);
  border-top-right-radius: var(--r-2xl);
  border-top: 1px solid var(--rule-2);
  padding: 14px 18px calc(20px + var(--safe-bottom));
  transform: translateY(0);
  transition: transform var(--dur-4) var(--ease);
}
@starting-style {
  .sheet { transform: translateY(110%); }
}
.sheet .grabber {
  width: 36px; height: 4px;
  background: var(--rule-3);
  border-radius: var(--r-pill);
  margin: 0 auto 12px;
}
.sheet h2 { font-size: 18px; margin-bottom: 14px; font-weight: 600; }
.sheet-sm  { max-width: 420px; }
.sheet-full {
  max-width: none;
  max-height: 100dvh;
  height: 100dvh;
  border-radius: 0;
  border-top: none;
  padding-top: calc(14px + var(--safe-top));
}

.form-actions {
  display: flex; gap: 8px;
  margin-top: var(--sp-5);
}
.form-actions .ghost { flex: 1; min-height: 48px; }
.form-actions .primary { flex: 2; min-height: 48px; }
.form-actions .danger-ghost {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  color: var(--expense-2);
  font-weight: 600;
  padding: 10px 14px;
  border-radius: var(--r-md);
}
.form-actions .danger-ghost:hover {
  background: var(--expense-tint);
  border-color: color-mix(in srgb, var(--danger) 60%, transparent);
}

/* Кнопки листа операции: «Сохранить» во всю ширину + «Удалить» аутлайном
   снизу (паритет с Flutter). */
.op-actions { flex-direction: column; gap: 10px; }
/* Кнопки сохранения липнут к низу листа — всегда видны, даже когда контент
   (Перевод) выше экрана и лист скроллится. Фон перекрывает прокручиваемое. */
.sheet-op .op-actions {
  position: sticky;
  bottom: 0;
  z-index: 1;
  background: var(--surface);
  padding-top: 12px;
  margin-top: 8px;
}
.op-actions .op-save,
.op-actions .op-delete {
  flex: none; width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px;
}
.op-actions .op-save .op-save-check { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.6; }
.op-actions .op-delete svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
/* «Повторить сегодня» — зелёная контурная кнопка (без заливки, как «Удалить»). */
.op-actions .op-repeat {
  flex: none; width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px;
  background: transparent;
  color: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand) 45%, transparent);
  border-radius: var(--r-md);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-2) var(--ease);
}
.op-actions .op-repeat:hover { background: color-mix(in srgb, var(--brand) 12%, transparent); }
.op-actions .op-repeat svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* Верхние листы (докаются к верху экрана) — у #rename-sheet это критично:
   снизу его перекрывала экранная клавиатура при вводе названия бюджета. */
#add-sheet, #settings-sheet, #rename-sheet, #adjust-sheet, #prog-sheet { align-items: flex-start; }
#add-sheet .sheet, #settings-sheet .sheet, #rename-sheet .sheet, #adjust-sheet .sheet, #prog-sheet .sheet {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-bottom-left-radius: var(--r-2xl);
  border-bottom-right-radius: var(--r-2xl);
  border-top: none;
  border-bottom: 1px solid var(--rule-2);
  padding-top: calc(16px + var(--safe-top));
}
/* Верхний лист — грабер (ручка нижнего листа) убираем, иначе висит у верх. края. */
#prog-sheet .grabber { display: none; }
@starting-style {
  #add-sheet .sheet, #settings-sheet .sheet, #rename-sheet .sheet, #adjust-sheet .sheet, #prog-sheet .sheet { transform: translateY(-110%); }
}

/* DB-005 · Корректировка баланса — содержимое модалки */
.adjust-body { display: flex; flex-direction: column; }
.adjust-sub { font-size: 12.5px; color: var(--ink-2); line-height: 1.45; margin: 2px 0 16px; }
.adjust-calc {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-soft); border: 1px solid var(--rule);
  border-radius: var(--r-lg, 14px); padding: 11px 13px; margin-bottom: 12px;
}
.adjust-calc-l { font-size: 12.5px; color: var(--ink-2); }
.adjust-calc-v { font-size: 15px; font-weight: 800; color: var(--ink); }
.adjust-field { display: block; margin-bottom: 12px; }
.adjust-field-label {
  display: block; font-size: 11px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .04em; font-weight: 700; margin-bottom: 6px;
}
.adjust-input-wrap { position: relative; display: block; }
.adjust-input {
  width: 100%; box-sizing: border-box;
  background: var(--bg-soft); border: 1.5px solid var(--brand);
  border-radius: var(--r-lg, 14px); padding: 13px 38px 13px 52px;
  font-size: 20px; font-weight: 800; color: var(--ink); outline: none;
}
/* ± переключатель знака фактического остатка (минуса на цифр. клаве нет) — #4. */
.adjust-sign {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  z-index: 1; width: 34px; height: 34px; border-radius: 8px; padding: 0;
  border: 1px solid color-mix(in srgb, var(--income) 50%, transparent);
  background: transparent; color: var(--income-2);
  font-size: 20px; font-weight: 800; line-height: 1; cursor: pointer;
}
.adjust-sign.is-neg {
  color: var(--expense-2);
  border-color: color-mix(in srgb, var(--expense) 50%, transparent);
}
.adjust-cur-sym {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  font-size: 16px; font-weight: 700; color: var(--ink-3); pointer-events: none;
}
.adjust-preview {
  display: flex; align-items: center; gap: 9px;
  border-radius: var(--r-lg, 14px); padding: 11px 13px; margin-bottom: 18px;
}
.adjust-preview-ic { width: 18px; height: 18px; flex: 0 0 18px; }
.adjust-preview-ic svg { width: 18px; height: 18px; }
.adjust-preview-tx { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.adjust-preview-tx small { display: block; font-weight: 500; font-size: 11px; color: var(--ink-2); }
.adjust-preview.is-expense {
  background: var(--expense-tint); border: 1px solid color-mix(in srgb, var(--expense) 30%, transparent);
}
.adjust-preview.is-expense .adjust-preview-ic, .adjust-preview.is-expense .adjust-preview-tx { color: var(--expense-2); }
.adjust-preview.is-income {
  background: var(--income-tint); border: 1px solid color-mix(in srgb, var(--income) 30%, transparent);
}
.adjust-preview.is-income .adjust-preview-ic, .adjust-preview.is-income .adjust-preview-tx { color: var(--income-2); }
.adjust-preview.is-zero {
  background: var(--bg-soft); border: 1px solid var(--rule);
}
.adjust-preview.is-zero .adjust-preview-tx { color: var(--ink-2); }
.adjust-actions { display: flex; gap: 10px; }
.adjust-btn {
  flex: 1; font: inherit; font-size: 15px; font-weight: 800;
  padding: 13px; border-radius: var(--r-lg, 14px); cursor: pointer; border: none;
}
.adjust-cancel { background: transparent; border: 1px solid var(--rule-3); color: var(--ink-2); }
.adjust-save { background: var(--brand); color: var(--brand-on, #102b06); }
.adjust-save:disabled { opacity: .45; cursor: default; }
#add-sheet .sheet > .grabber,
#settings-sheet .sheet > .grabber,
#rename-sheet .sheet > .grabber { order: 99; margin: 14px auto 0; }
#add-sheet .sheet { display: flex; flex-direction: column;
  /* Длинная форма (особенно «Перевод») должна скроллиться внутри листа, иначе
     низ (Сохранить/комментарий) обрывается. */
  overflow-y: auto; overscroll-behavior: contain;
  padding-bottom: calc(16px + env(safe-area-inset-bottom)); }

/* =========================================================
   5. LOGIN
   ========================================================= */
#login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(20px + var(--safe-top)) 20px calc(20px + var(--safe-bottom));
}
.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-2xl);
  padding: 28px;
  box-shadow: var(--sh-edge);
  position: relative;
  overflow: hidden;
}
/* Шапка центрирована (паритет с Flutter-экраном входа). */
.login-mark {
  width: 64px; height: 64px;
  margin: 0 auto 14px;
}
.login-mark img { width: 100%; height: 100%; display: block; }
.login-card h1 { text-align: center; font-size: 26px; font-weight: 800; letter-spacing: -0.01em; }
.login-card .sub { text-align: center; color: var(--ink-2); margin-top: 6px; font-size: 14px; }
.login-card form { display: grid; gap: 10px; margin-top: 18px; }
.error { color: var(--expense-2); font-size: 13px; }

/* Поле входа с ведущей иконкой (паритет с Flutter prefixIcon). */
.lf { position: relative; }
.lf-ic {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px;
  stroke: currentColor; fill: none; stroke-width: 1.8;
  color: var(--ink-3); pointer-events: none;
  transition: color var(--dur-2) var(--ease);
}
.lf:focus-within .lf-ic { color: var(--brand); }
.lf input { padding-left: 44px; }
.lf.has-eye input { padding-right: 46px; }
/* Кнопка показать/скрыть пароль. */
.lf-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; min-height: 0;
  display: grid; place-items: center;
  background: transparent; border: none; padding: 0;
  color: var(--ink-3); cursor: pointer; border-radius: var(--r-sm);
}
.lf-eye:hover { color: var(--ink); }
.lf-eye svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.lf-help { color: var(--ink-3); font-size: 12px; margin-top: -4px; }

.login-demo { margin-top: 16px; display: grid; gap: 12px; }
/* Разделитель «или» с линиями по бокам (паритет с Flutter Divider). */
.login-or {
  display: flex; align-items: center; gap: 12px;
  color: var(--ink-3); font-size: 12px; letter-spacing: 0.05em;
}
.login-or::before, .login-or::after {
  content: ""; flex: 1; height: 1px; background: var(--rule-2);
}
/* Демо — обведённая кнопка с иконкой play (паритет с Flutter OutlinedButton). */
.demo-btn {
  width: 100%; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: transparent;
  border: 1px solid var(--rule-2);
  border-radius: var(--r-md);
  color: var(--ink); font-size: 14px; font-weight: 600;
}
.demo-btn:hover { background: var(--surface-2); border-color: var(--brand-edge); }
.demo-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; color: var(--brand); }
.login-demo-hint { text-align: center; color: var(--ink-3); font-size: 12px; }

/* =========================================================
   6. APP SHELL
   ========================================================= */
#app {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr;
  padding-bottom: var(--nav-pb);
}
.demo-ribbon {
  display: none;
  text-align: center;
  font-size: 11px;
  background: color-mix(in srgb, var(--brand) 10%, var(--bg-soft));
  border-bottom: 1px solid color-mix(in srgb, var(--brand) 22%, var(--rule));
  color: var(--brand-2);
  padding: calc(4px + var(--safe-top)) 12px 4px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
body.is-demo .demo-ribbon { display: block; }
.demo-ribbon b { font-weight: 800; }
.demo-ribbon[hidden] { display: none !important; }

/* DB-001 · Sync banner — неблокирующая полоса статуса синхронизации.
   Геометрия по образцу .demo-ribbon (full-width, учитывает --safe-top). */
.sync-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + var(--safe-top)) 14px 8px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.25;
}
.sync-banner[hidden] { display: none !important; }
.sync-banner .sync-banner-ic { flex: 0 0 18px; width: 18px; height: 18px; display: grid; place-items: center; }
.sync-banner .sync-banner-ic svg { width: 18px; height: 18px; }
.sync-banner .sync-banner-txt { flex: 1; min-width: 0; }
.sync-banner .sync-banner-txt small { display: block; font-weight: 500; font-size: 11px; opacity: .82; }
.sync-banner .sync-banner-btn {
  flex: 0 0 auto;
  font: inherit;
  font-size: 11.5px;
  font-weight: 800;
  padding: 5px 11px;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
}
/* Ошибка синка (нет сети / сервер) — danger-tint */
.sync-banner.is-error {
  background: var(--expense-tint);
  border-bottom: 1px solid color-mix(in srgb, var(--danger) 30%, var(--rule));
  color: #ff8079;
}
.sync-banner.is-error .sync-banner-ic { color: var(--danger); }
.sync-banner.is-error .sync-banner-btn {
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
}
/* Не синхронизировалось >48ч — предупреждение (warn-tint) */
.sync-banner.is-warn {
  background: var(--warn-tint);
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, var(--rule));
  color: #e8b94a;
}
.sync-banner.is-warn .sync-banner-ic { color: var(--warn); }
.sync-banner.is-warn .sync-banner-btn {
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
}

main.tab {
  padding: 0 var(--page-px) 36px;
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-rows: max-content;
  gap: 20px;
  /* Таб никогда не скроллится по горизонтали. overflow-x: clip — без
     скролл-контейнера, не ломает position:sticky внутри (в отличие от
     overflow:hidden). */
  overflow-x: clip;
  /* Таб = высота контента. Без этого 1fr-строка #app растягивает таб
     на весь экран, и растяжение каскадом раздувает вложенные гриды. */
  align-self: start;
}

/* Карточки/секции таба не раздуваются по min-content (длинный nowrap-текст
   внутри вложенного грида) — на iOS Safari это давало «Анализ шире экрана». */
main.tab > * { min-width: 0; }

/* =========================================================
   7. PAGE HEAD + PERIOD PICKER
   ========================================================= */
.page-head {
  padding: calc(14px + var(--safe-top)) 0 4px;
  display: grid;
  gap: 12px;
  position: relative;
}
.ph-title {
  /* 3 колонки 1fr·auto·1fr — версия строго по центру ВСЕЙ шапки
     (не «в остатке места»), заголовок слева, кнопки справа. */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}
.ph-title-text { display: grid; gap: 2px; min-width: 0; justify-self: start; }
.ph-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-self: end;
  flex: 0 0 auto;
  /* Всегда в последней колонке (справа). Без этого в шапках без центрального
     блока (Платежи/История) кнопки уезжали во 2-ю колонку — «по центру». */
  grid-column: 3;
}
.ph-actions .icon-btn { color: var(--ink-3); }
.ph-actions .icon-btn:hover { color: var(--ink); }
.ph-actions .icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.ph-actions .js-hide-amounts.is-hidden { color: var(--brand); }
.ph-actions .icon-btn.spinning svg { animation: ph-spin 0.7s linear infinite; }
@keyframes ph-spin { to { transform: rotate(360deg); } }
.ph-h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(20px, 5vw, 26px);
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--ink);
}
.ph-sub {
  font-family: var(--font-numeric);
  color: var(--ink-3);
  font-size: 11px;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.ph-nav { display: grid; gap: 16px; }

/* ---- Чип версии (Настройки) ---- */
.version-chip {
  flex: 0 0 auto;
  align-self: center;
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--rule);
  color: var(--ink-2);
  font-family: var(--font-numeric);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  cursor: pointer;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.version-chip:hover { color: var(--ink); background: var(--surface-3); }

/* ---- Блок версии по центру шапки Обзора ---- */
.version-dash {
  min-width: 0;
  align-self: center;
  justify-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 2px 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: center;
  font-family: var(--font-numeric);
  line-height: 1.15;
}
.version-dash-v {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.version-dash-upd {
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.version-dash:hover .version-dash-v { color: var(--ink); }
/* На узких экранах не даём блоку теснить заголовок/кнопки — прячем «Обновлено». */
@media (max-width: 380px) {
  .version-dash-upd { display: none; }
}

/* ---- Модалка «Что нового» — полноэкранная ---- */
.version-modal {
  display: flex;
  flex-direction: column;
  /* Тело прокручивается само (.version-body), сам лист не скроллим. */
  overflow: hidden;
  padding-left: 0;
  padding-right: 0;
  padding-bottom: 0;
}
.version-modal-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px 12px;
  border-bottom: 1px solid var(--rule);
}
.version-modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.version-subhead {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  padding: 12px 16px 12px;
  border-bottom: 1px solid var(--rule);
}
.version-nav { margin: 0; }
.version-nav .period-name { min-width: 140px; }
.version-date {
  text-align: center;
  font-family: var(--font-numeric);
  font-size: 12px;
  color: var(--ink-3);
  margin: 6px 0 0;
  font-variant-numeric: tabular-nums;
}

/* Прокручиваемое тело версии */
.version-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 16px calc(28px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 26px;
}

/* Блок (Новые фичи / Исправления) */
.version-group { display: flex; flex-direction: column; gap: 16px; }
.version-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.005em;
  color: var(--brand-2);
}
.version-group-title::before {
  content: "";
  width: 4px;
  height: 16px;
  border-radius: var(--r-pill);
  background: var(--brand);
}
.version-group.fixes .version-group-title { color: var(--ink); }
.version-group.fixes .version-group-title::before { background: var(--ink-3); }

/* Раздел внутри блока */
.version-sec { display: flex; flex-direction: column; gap: 8px; }
.version-sec-label {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.version-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 9px;
}
.version-item {
  position: relative;
  padding-left: 18px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}
.version-item::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
}
.version-group.fixes .version-item::before { background: var(--ink-4); }

.range-segment {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 3px;
  border-radius: var(--r-md);
  gap: 0;
  position: relative;
  isolation: isolate;
  --seg-n: 5;
}
/* Скользящая лаймовая «таблетка» под активной кнопкой */
.range-segment::before {
  content: "";
  position: absolute;
  top: 3px; left: 3px; bottom: 3px;
  width: calc((100% - 6px) / var(--seg-n, 5));
  border-radius: var(--r-sm);
  background: var(--brand-tint);
  transform: translateX(calc(var(--seg-i, 0) * 100%));
  transition: transform var(--mo-base) var(--mo-decisive);
  z-index: 0;
  pointer-events: none;
}
.range-segment button {
  background: transparent;
  border: none;
  padding: 11px 4px;
  min-height: 44px;
  border-radius: var(--r-sm);
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  position: relative;
  z-index: 1;
  transition: color var(--dur-2) var(--ease),
              background var(--dur-2) var(--ease);
}
.range-segment button:hover { color: var(--ink-2); }
/* П4: контрастный фокус на кнопках переключателя периода */
.range-segment button:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 1px;
  z-index: 1;
}
.range-segment button.active {
  color: var(--brand-2);
  font-weight: 600;
}
@media (prefers-reduced-motion: reduce) {
  .range-segment::before { transition: none; }
}

/* Переключатель «Расходы/Доходы» — два таба вместо пяти. Размеры кнопок
   приведены к сегменту Сводка/Статистика (.seg-btn), чтобы оба сегмента были
   одинаковыми: 7px паддинг (без min-height 44px периодного пикера), 13px/600. */
.cat-kind-segment {
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 12px;
  --seg-n: 2;
}
.cat-kind-segment button {
  padding: 7px 4px;
  min-height: 0;
  font-size: 13px;
  font-weight: 600;
}

.period-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.period-nav .period-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.02em;
  min-width: 150px;
  text-align: center;
  color: var(--ink);
}
/* Стрелки периода — заметные круглые кнопки (раньше были «слабыми»). */
.period-nav .icon-btn {
  width: 40px; height: 40px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--rule-2);
  border-radius: 50%; transition: filter var(--dur-2) var(--ease),
    background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.period-nav .icon-btn svg { width: 20px; height: 20px; stroke: var(--ink); fill: none; stroke-width: 2.2; }
.period-nav .icon-btn:hover { background: var(--surface-3); border-color: var(--rule-3); }
.period-nav .icon-btn:active { filter: brightness(0.92); }
.period-nav .icon-btn[disabled] { opacity: 0.35; }

.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--rule);
  color: var(--ink-2);
  padding: 0;
  touch-action: manipulation;
}
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; }
.icon-btn[disabled] { opacity: 0.35; cursor: not-allowed; }

/* Активный вид «календарь» в Истории */
#hist-view-toggle[aria-pressed="true"] {
  background: color-mix(in srgb, var(--brand) 16%, transparent);
}
#hist-view-toggle[aria-pressed="true"] svg { stroke: var(--brand); }

.period-picker { display: grid; gap: 8px; }
.period-custom {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  align-items: center;
  gap: 8px;
}
.period-custom input[type="date"] {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: 8px 10px;
  color: var(--ink);
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  color-scheme: dark;
  min-width: 0; width: 100%;
}
.period-custom .apply-period { padding: 8px 14px; font-size: 13px; }
.period-custom .apply-period[disabled] { opacity: 0.45; cursor: not-allowed; }
.period-custom-field { display: contents; }
@media (max-width: 460px) {
  .period-custom { grid-template-columns: 1fr 1fr; }
  .period-custom .dim { display: none; }
  .period-custom .apply-period { grid-column: 1 / -1; }
}

/* =========================================================
   8. HERO — single big number (расход за период)
   POCKET BANK-influence: ".pace" → "Осталось 18 200 ₽" pseudo-row
   ========================================================= */
.hero {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-xl);
  padding: 20px;
}
.hero-lbl-row {
  display: flex; align-items: center; justify-content: space-between;
}
.hero-lbl {
  font-size: 12px;
  color: var(--ink-3);
}
.hero-amount {
  margin-top: 4px;
  display: flex; align-items: baseline; gap: 4px;
}
.hero-amount .num {
  font-size: 30px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.hero-amount .cur {
  font-size: 18px;
  color: var(--ink-2);
}
.hero-kpi {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.hero-kpi-tile {
  background: var(--bg-soft);
  border-radius: var(--r-md);
  padding: 12px 10px;
  display: flex; flex-direction: column; gap: 3px;
  min-width: 0;
}
.hero-kpi-tile .lbl {
  font-size: 11px;
  color: var(--ink-3);
}
/* Округлённое значение без копеек (как FittedBox+formatRounded во Flutter) —
   крупнее; JS досжимает шрифт для экстремальных сумм; ellipsis — страховка. */
.hero-kpi-tile .val {
  font-size: clamp(13px, 3.8vw, 15px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* delta-pill в hero */
.delta-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 11px; font-weight: 700;
}
.delta-badge svg { width: 12px; height: 12px; }
/* cls «up» = рост значения; для расходов (hero, invert=true) это плохо → красный. */
.delta-badge.up   { background: rgba(248,81,73,.14); color: var(--expense-2); }
.delta-badge.down { background: rgba(86,211,100,.14); color: var(--income-2); }
.delta-badge.flat { background: rgba(160,170,182,.14); color: var(--ink-2); }

/* === MOVERS (что изменилось) ===================================== */
/* Норма сбережений */
#ana-savings { margin-bottom: var(--sp-5); }
#ana-savings .h-section {
  font-size: 10px; font-weight: 700; letter-spacing: 0.14em;
  color: var(--ink-3); margin: 0 0 2px;
}
#ana-savings .sav-hint { display: block; font-size: 11px; margin: 0 0 8px; }
.sav-card { border: 1px solid var(--rule); border-radius: var(--r-xl); padding: var(--sp-4);
  background: var(--bg-soft, rgba(255,255,255,0.02)); }
.sav-top { display: flex; align-items: baseline; justify-content: space-between; }
.sav-pct { font-size: 30px; font-weight: 700; line-height: 1; }
.sav-note { font-size: 13px; }
.sav-track { height: 8px; border-radius: 999px; background: var(--surface-2, rgba(255,255,255,0.06));
  overflow: hidden; margin: 12px 0 8px; }
.sav-fill { height: 100%; border-radius: 999px; }
.sav-sub { font-size: 11px; }

.movers-card { margin-top: var(--sp-5); margin-bottom: var(--sp-5); }
/* Личная инфляция: плашка-заголовок с общей цифрой + суммы справа. */
.infl-hero {
  display: flex; align-items: center; justify-content: space-between;
  border: 1px solid var(--rule); border-radius: var(--r-xl);
  padding: 12px 16px; margin-bottom: var(--sp-2);
}
.infl-hero .infl-pct { font-size: 26px; font-weight: 700; line-height: 1.1; }
.infl-hero .infl-cap { font-size: 12px; margin-top: 2px; }
.infl-hero .infl-sums { text-align: right; font-size: 13px; }
.infl-hero .infl-sums .muted { font-size: 11px; }
/* Заголовок «ЧТО ИЗМЕНИЛОСЬ» сверху + подзаголовок снизу (как Flutter
   _WhatChanged), а не в одну строку space-between. */
.movers-card .head { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; margin-bottom: var(--sp-2); }
.movers-card .head .h-section {
  font-size: 10px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-3); margin: 0;
}
.movers-card .head .muted { font-size: 11px; color: var(--ink-3); }
.movers-list { display: flex; flex-direction: column; }
/* Flex-строка (не grid): сумма и чип-дельта сжаты по содержимому, БЕЗ общей
   auto-колонки, которая резервировала ширину самого длинного чипа (+499.9%) и
   растягивала короткие. Размер чипа ДИНАМИЧЕСКИЙ, кластер сумма+чип прижат
   вправо (паритет с APK). */
.mover {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--rule);
}
.mover .cat-icon { flex: 0 0 auto; }
.mover .mover-mid { flex: 1 1 auto; min-width: 0; }
.mover .cur, .mover .delta-badge { flex: 0 0 auto; }
.mover:last-child { border-bottom: 0; }
.mover .mover-mid { min-width: 0; }
.mover .name { font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mover .was { font-size: 11px; color: var(--ink-3); }
.mover .cur { font-size: 13px; color: var(--ink); font-variant-numeric: tabular-nums; }
.delta-badge.new { background: rgba(88,166,255,.16); color: var(--info); }

/* delta-badges (inline, в списках/анализе) */
.delta {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700;
  font-family: var(--font-numeric);
  padding: 3px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  border: 1px solid var(--rule-2);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.delta.up {
  color: var(--expense-2);
  background: color-mix(in srgb, var(--expense) 20%, transparent);
  border-color: color-mix(in srgb, var(--expense) 50%, transparent);
}
.delta.down {
  color: var(--income-2);
  background: color-mix(in srgb, var(--income) 20%, transparent);
  border-color: color-mix(in srgb, var(--income) 50%, transparent);
}
.delta.flat { color: var(--ink-2); }
.delta svg { width: 10px; height: 10px; stroke: currentColor; stroke-width: 2.6; }

/* =========================================================
   9. KPI — 3 inline rows под hero (не 3 карточки, не grid)
   ========================================================= */
.kpi-grid {
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--rule-2) 70%, transparent);
  border-radius: var(--r-xl);
  padding: 6px 16px;
  display: grid;
  gap: 0;
}
.kpi {
  background: transparent;
  padding: 12px 0;
  border: none;
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 12px;
}
.kpi:last-child { border-bottom: none; }
.kpi .lbl {
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  text-transform: none;
}
.kpi .val {
  font-family: var(--font-numeric);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.kpi.income  .val { color: var(--income-2); }
.kpi.expense .val { color: var(--expense-2); }
.kpi.net.positive .val { color: var(--income-2); }
.kpi.net.negative .val { color: var(--expense-2); }
.kpi.net .val { font-weight: 700; font-size: 16px; }
.kpi.lg { grid-column: 1 / -1; }

/* =========================================================
   10. SPARK CARD (по периодам)
   ========================================================= */
.spark-card {
  /* Отступ сверху отделяет «По периодам» от блока выше (KPI/Сводка) — в #ov-stats
     нет grid-gap, поэтому секции расставляются собственными margin. */
  margin-top: var(--sp-5);
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--rule-2) 70%, transparent);
  border-radius: var(--r-xl);
  padding: var(--sp-4);
}
.spark-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: var(--sp-2); gap: 10px;
}
.spark-head .ttl {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: -0.01em;
}
.spark-head .sub {
  color: var(--ink-3);
  font-size: 11px;
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
}
.spark-toggle {
  display: inline-flex;
  background: var(--bg-soft);
  border-radius: var(--r-pill);
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--rule);
}
.spark-toggle button {
  background: transparent; border: none; color: var(--ink-3);
  padding: 4px 10px; font-size: 11px;
  border-radius: var(--r-pill);
}
.spark-toggle button.active { background: var(--surface-3); color: var(--ink); }

.spark { display: grid; gap: 8px; }
.spark-row {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  padding: 4px 0;
}
.spark-row .lbl {
  color: var(--ink-2);
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  font-size: 11px;
}
.spark-row .stack { display: grid; gap: 4px; }
.spark-row .track {
  height: 6px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.spark-row .track.prev { height: 4px; }
.spark-row .fill {
  height: 100%;
  background: var(--brand);
  border-radius: var(--r-pill);
  transition: width 500ms var(--ease);
}
.spark-row .fill.prev { background: var(--ink-3); }
.spark-row .val-col { display: grid; gap: 1px; justify-items: end; }
.spark-row .val {
  font-family: var(--font-numeric);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  font-size: 12px;
  color: var(--ink);
}
.spark-row .delta { font-size: 10px; padding: 1px 6px; }
.spark-legend {
  display: flex; gap: 14px;
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
}
.spark-legend i {
  display: inline-block; width: 8px; height: 8px;
  border-radius: var(--r-pill);
  margin-right: 6px; vertical-align: 1px;
}
.spark-legend .now  i { background: var(--brand); }
.spark-legend .past i { background: var(--ink-3); }

/* =========================================================
   11. SECTION HEADER — "─── КАТЕГОРИИ ─── 8/16"
   ========================================================= */
/* minmax(0,1fr) — колонка не раздувается под длинный непереносимый контент
   (имя категории), иначе центрированный донат выше уезжает вбок. */
.section { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.section > .head {
  display: flex; align-items: center; gap: 10px;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.section > .head .h-section,
.section > .head h2 {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--ink-3);
  text-transform: uppercase;
  white-space: nowrap;
}
/* Декоративная линия после заголовка убрана — выглядела как лишняя «черта»
   после количества категорий (фидбэк). */
.section > .head a,
.section > .head .muted {
  color: var(--ink-3);
  font-size: 11px;
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.h-section {
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin: 0;
}

/* =========================================================
   12. CAT LIST — inline 2px progress bar
   ========================================================= */
.cat-list { display: grid; grid-template-columns: minmax(0, 1fr); }
.cat-list-toggle {
  width: 100%;
  margin-top: 6px;
  padding: 13px;
  background: transparent;
  border: none;
  border-radius: var(--r-md);
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}
.cat-list-toggle:hover { background: var(--surface); color: var(--ink); }
.cat-item {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: var(--sp-3) 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  position: relative;
  transition: background var(--dur-2) var(--ease);
  touch-action: manipulation;
}
.cat-item:hover { background: color-mix(in srgb, var(--surface) 50%, transparent); }
.cat-item:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
  background: var(--surface);
}
.cat-item .dot {
  width: 10px; height: 10px;
  border-radius: var(--r-pill);
  align-self: center;
  background: var(--cat-color, var(--brand));
}
.cat-item .name {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.cat-item .num {
  font-family: var(--font-numeric);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.cat-item .meta {
  grid-column: 2 / -1;
  min-width: 0;
  margin-top: 2px;
  color: var(--ink-3);
  font-size: 11px;
  display: flex; gap: 8px; align-items: center;
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.cat-item .delta { font-size: 10px; padding: 1px 6px; max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* inline progress bar — на ::after, на самой строке */
.cat-item::after {
  content: "";
  position: absolute;
  bottom: 1px; left: 0;
  height: 2px;
  width: var(--share, 0%);
  background: var(--cat-color, var(--brand));
  border-radius: 2px;
  transition: width 600ms var(--ease);
  pointer-events: none;
  opacity: 0.85;
}

/* === CATEGORY ACCORDION — уплотнённые карточки V2 ================= */
/* Каждая категория — карточка. Шеврон+squircle-иконка центрированы по
   вертикали слева, контент (имя/сумма/чип, бар-доля, доля%/N оп.) — справа.
   Раскрытые операции рендерятся ВНУТРИ карточки. */
.cat-acc {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  margin-bottom: 5px;
  padding: 0 10px;
}
.cat-acc-head {
  display: flex; align-items: center; gap: 10px;
  width: 100%; border: 0; background: transparent; cursor: pointer;
  padding: 9px 0; color: var(--ink); text-align: left;
}
.cat-lead { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }
.cat-acc-head .chev { width: 13px; height: 13px; color: var(--ink-3); flex: 0 0 auto;
  stroke: currentColor; fill: none; stroke-width: 2;
  transition: transform var(--mo-fast) var(--mo-ease); }
.cat-acc-head[aria-expanded="true"] .chev { transform: rotate(90deg); }
.cat-content { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.cat-top { display: flex; align-items: center; gap: 8px; }
.cat-top .name {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 600;
}
/* Текст имени ужимается с многоточием; бейдж-иконка (.over-badge) рядом не клиппится. */
.cat-top .name-text {
  flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cat-right { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.cat-acc-head .sum  { font-size: 12px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.cat-acc.cat-over .sum { color: var(--expense-2); }
.lim-chip { font-size: 10px; font-weight: 700; padding: 1px 7px;
  border-radius: var(--r-pill); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lim-chip.lim-ok   { background: var(--income-tint);  color: var(--income-2); }
.lim-chip.lim-warn { background: var(--warn-tint); color: var(--warn); }
.lim-chip.lim-over { background: var(--expense-tint); color: var(--expense-2); }
/* Компактный значок «превышение» (красный кружок со стрелкой вверх) — не клиппится
   на длинном имени, в отличие от прежнего текстового бейджа «Превышение». */
.over-badge { flex: 0 0 auto; display: grid; place-items: center;
  width: 16px; height: 16px; border-radius: var(--r-pill);
  background: var(--expense-tint); color: var(--expense-2); }
.over-badge svg { width: 10px; height: 10px; stroke: currentColor; fill: none; stroke-width: 2.4; }
.cat-acc-bar { display: block; height: 3px; margin-top: 7px; border-radius: var(--r-pill);
  background: var(--surface-3); overflow: hidden; }
.cat-acc-bar > i { display: block; height: 100%; width: 0; border-radius: inherit; transition: width var(--mo-layout) var(--mo-ease); }
.cat-acc-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 5px; font-size: 11px; color: var(--ink-3); }
.cat-acc-meta .cat-share { color: var(--brand-2); font-weight: 600; font-variant-numeric: tabular-nums; }
.cat-acc-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--mo-base) var(--mo-ease); }
.cat-acc-head[aria-expanded="true"] ~ .cat-acc-body { grid-template-rows: 1fr; }
.cat-acc-body > div { overflow: hidden; min-height: 0; }
/* Операции развёрнутой категории — список внутри карточки (как Flutter). */
.cat-acc-ops {
  list-style: none; margin: 0; padding: 1px 10px;
  background: var(--bg);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-lg);
}
.cat-acc-head[aria-expanded="true"] ~ .cat-acc-body > div { padding-bottom: 9px; }
.cat-acc-ops .tx-item.cat-op:last-child { border-bottom: none; }
@media (prefers-reduced-motion: reduce) {
  .cat-acc-head .chev, .cat-acc-bar > i, .cat-acc-body { transition: none; }
}

/* category icon */
.cat-icon {
  display: inline-grid;
  place-items: center;
  border-radius: var(--r-pill);
  background: var(--cat-color, var(--brand-tint));
  color: var(--cat-on, var(--brand-on));
  flex: 0 0 auto;
  position: relative;
  flex-shrink: 0;
}
/* Маска-иконка рисуется ТОЛЬКО когда задана иконка (applyCatIcon ставит
   data-icon). Без гейта ::before без mask-url заливал всю плитку сплошным
   --cat-on → чёрный квадрат в превью новой категории (баг #2). */
.cat-icon[data-icon]::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--cat-on, currentColor);
  -webkit-mask: var(--cat-icon-url) no-repeat center / 65%;
          mask: var(--cat-icon-url) no-repeat center / 65%;
}
.cat-icon-sm { width: 24px; height: 24px; }
.cat-icon-md { width: 32px; height: 32px; }
/* Squircle (скруглённый квадрат) — для карточек категорий V2. */
.cat-icon-sq { border-radius: 9px; }
.cat-icon-lg { width: 48px; height: 48px; }
.cat-icon-xl { width: 56px; height: 56px; }
.cat-icon-empty {
  background: var(--surface-2);
  border: 1px dashed var(--rule-2);
}
.cat-icon-empty::before { display: none; }

/* Бейдж счёта B1 (Task 5): цветной квадрат + мини-иконка типа в углу иконки
   категории. Кольцо цвета фона строки — визуально «вырезано» из иконки. */
.acc-badge {
  position: absolute; right: -4px; bottom: -4px;
  width: 20px; height: 20px; border-radius: 8px;
  border: 2px solid var(--bg);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.acc-badge svg { width: 11px; height: 11px; stroke: #11151b; fill: none; stroke-width: 2; }
.acc-badge::before { content: none; }
.cat-picker-tile .cat-icon:not([style*="--cat-icon-url"]) {
  background: var(--surface-2);
  border: 1px dashed var(--rule-2);
}
.cat-picker-tile .cat-icon:not([style*="--cat-icon-url"])::before {
  display: none;
}

/* =========================================================
   13. ADD-CTA — на странице "Обзор" над категориями
   ========================================================= */
.add-cta {
  width: 100%;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 10px 14px 10px 10px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-xl);
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: background var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease),
              transform var(--dur-1) var(--ease-press);
  touch-action: manipulation;
}
.add-cta:hover {
  background: var(--surface-2);
  border-color: var(--brand-edge);
}
.add-cta:active { transform: scale(0.985); }
.add-cta-icon {
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--brand);
  color: var(--brand-on);
  flex: 0 0 auto;
  box-shadow: var(--sh-edge-2);
}
.add-cta-icon svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2.4; }
.add-cta-text { display: grid; gap: 2px; min-width: 0; }
.add-cta-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.add-cta-sub { font-size: 12px; color: var(--ink-3); }
.add-cta-chev { width: 18px; height: 18px; stroke: var(--ink-3); fill: none; stroke-width: 2; }

/* =========================================================
   14. TX LIST
   ========================================================= */
/* Поиск по операциям (История). */
.hist-search {
  position: relative;
  margin: 0 0 12px;
}
.hist-search-ic {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px;
  stroke: currentColor; fill: none; stroke-width: 1.8;
  color: var(--ink-3); pointer-events: none;
}
.hist-search input {
  width: 100%;
  padding-left: 42px; padding-right: 42px;
}
/* Прячем нативный крестик type=search — используем свою кнопку очистки. */
.hist-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.hist-search-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; min-height: 0;
  display: grid; place-items: center;
  background: transparent; border: none; padding: 0;
  color: var(--ink-3); cursor: pointer; border-radius: var(--r-sm);
}
.hist-search-clear:hover { color: var(--ink); }
.hist-search-clear svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
.hist-empty {
  text-align: center; color: var(--ink-3); font-size: 14px;
  padding: 32px 16px;
}

/* Одноразовая подсказка про переключатель вида Истории */
.coach-tip {
  position: fixed; z-index: 60; max-width: 172px;
  background: var(--brand); color: var(--brand-on);
  font-size: 13px; font-weight: 600; line-height: 1.25;
  padding: 8px 11px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  opacity: 0; transform: translateY(-6px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}
.coach-tip.show { opacity: 1; transform: translateY(0); }
.coach-tip::before {
  content: ""; position: absolute; top: -5px; right: 16px;
  width: 11px; height: 11px; background: var(--brand);
  border-radius: 2px; transform: rotate(45deg);
}

/* Календарь месяца в Истории (Task 4) */
.hist-cal { margin: 0 0 var(--sp-3); }
.hc-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); margin-bottom: var(--sp-1); }
.hc-weekdays span { font-size: 11px; color: var(--ink-3); text-align: center; text-transform: uppercase; letter-spacing: .4px; }
.hc-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.hc-day {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 52px; padding: 5px 1px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid transparent; cursor: pointer;
}
.hc-day .hc-n { font-size: 14px; font-weight: 500; color: var(--ink-2); line-height: 1.15; }
.hc-day.today .hc-n { color: var(--brand); font-weight: 700; }
.hc-day.sel {
  background: color-mix(in srgb, var(--brand) 14%, transparent);
  border-color: var(--brand);
}
.hc-exp, .hc-inc {
  font-size: 10px; font-weight: 700; line-height: 1.15;
  white-space: nowrap; max-width: 100%; overflow: hidden;
}
.hc-exp { color: var(--expense); }
.hc-inc { color: var(--income); }

.tx-list {
  list-style: none; padding: 0; margin: 0;
  display: grid;
  gap: 0;
}
.tx-day {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 0 0 var(--sp-2);
  margin: var(--sp-5) 0 var(--sp-2);
  border-bottom: 1px solid var(--rule);
  font-family: var(--font-numeric);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.tx-day-label {
  letter-spacing: 0.14em;
  min-width: 0;
}
.tx-day-sums {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  flex: none;
}
.tx-day-sum {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
}
.tx-day-sum.income { color: var(--income); }
.tx-day-sum.expense { color: var(--expense); }
/* Индикатор «день скрыт» — приглушённый перечёркнутый глаз рядом с датой. */
.tx-day-eye {
  width: 13px;
  height: 13px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  color: var(--ink-3);
  opacity: 0.6;
}
.tx-day-eye[hidden] { display: none; }
.tx-day:first-child { margin-top: 2px; }
.tx-day-wrap { text-align: left; }
/* Блок периода и hero — не выделять текст при тапах. */
.hero, .ph-nav, .period-picker, .period-nav, .range-segment,
.ov-seg, .ov-kind-segment, .cat-kind-segment {
  -webkit-user-select: none;
  user-select: none;
}

.tx-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) minmax(64px, auto);
  gap: 12px;
  align-items: center;
  padding: var(--sp-3) 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  /* Не выделять текст при тапах/long-press (мешало жесту скрытия и просто
     выделялось при обычных тапах). */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
  position: relative;
  transition: background var(--dur-2) var(--ease);
  touch-action: pan-y;
}
.tx-item:hover { background: color-mix(in srgb, var(--surface) 50%, transparent); }
.tx-item:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
  background: var(--surface);
}
.tx-item.swiping { transition: none; }
.tx-item .avatar {
  width: 10px; height: 10px;
  border-radius: var(--r-pill);
  background: var(--cat-color, var(--ink-4));
  align-self: center;
}
.tx-item .meta-col { display: grid; gap: 1px; min-width: 0; }
.tx-item .name {
  font-size: 16px; font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tx-item .sub {
  color: var(--ink-3); font-size: 11px;
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  /* Длинный комментарий переносим на 2-ю строку (не режем в одну). */
  white-space: normal; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  line-height: 1.3;
}
.tx-item .amt {
  font-family: var(--font-numeric);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  font-size: 14px;
  color: var(--ink);
  text-align: right;
  white-space: nowrap;
}
.tx-item.expense .amt { color: var(--expense-2); }
.tx-item.income  .amt { color: var(--income-2); }
/* Приблизительный рублёвый эквивалент валютной операции — под суммой. */
.amt-approx { display: block; margin-top: 1px; font-size: 10px; font-weight: 500;
  color: var(--ink-3); letter-spacing: 0; }
/* При открытом свайп-трее сумма ужимается по шрифту, чтобы влезть рядом с
   кнопками (overflow:hidden на .tx-surface — страховка на очень длинных). */
#history-list .tx-item .amt,
#account-page-ops .tx-item .amt { transition: font-size 180ms cubic-bezier(0.22, 1, 0.36, 1); }
#history-list .tx-item.swipe-open .amt,
#account-page-ops .tx-item.swipe-open .amt { font-size: 11.5px; }

/* История: ряд — flex-контейнер. Контент .tx-surface занимает всё место и
   СЖИМАЕТСЯ при свайпе, .tx-actions выезжает справа (ширина 0 → трей). Сумма
   подъезжает к названию, вся строка влево НЕ уезжает (нет рывка к центру). */
#history-list .tx-item {
  display: flex;
  align-items: stretch;
  position: relative;
  overflow: hidden;
  padding: 0;
  background: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: pan-y;
  cursor: default;
}
#history-list .tx-item:hover { background: transparent; }
#history-list .tx-surface {
  order: 0;
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) minmax(64px, auto);
  gap: 12px;
  align-items: center;
  padding: var(--sp-3) 0;
  /* При свайпе surface сжимается — контент (в т.ч. длинная сумма) клипается по
     своему краю, а не наезжает на кнопки трея. */
  overflow: hidden;
}
#history-list .tx-actions {
  order: 1; /* DOM: actions раньше surface, но визуально — справа */
  flex: 0 0 auto;
  width: 0;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  /* Плавный доезд после отпускания (во время драга снимается классом .swiping). */
  transition: width 240ms cubic-bezier(0.22, 1, 0.36, 1);
}
#history-list .tx-item.swipe-open .tx-actions { width: 168px; } /* 3 × 64px */
#history-list .tx-item.tx-2acts.swipe-open .tx-actions { width: 112px; } /* DB-005: корректировка — 2 кнопки */
#history-list .tx-item.swiping .tx-actions { transition: none; }
.tx-act {
  width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: none;
  background: transparent;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tx-act-ic {
  width: 36px; height: 36px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter var(--dur-2) var(--ease);
}
.tx-act:active .tx-act-ic { filter: brightness(1.15); }
.tx-act-ic svg {
  width: 20px; height: 20px;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tx-act-lbl {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
.tx-act.edit   .tx-act-ic { background: var(--surface-3); }
.tx-act.edit   .tx-act-ic svg { stroke: var(--ink-2); }
.tx-act.edit   .tx-act-lbl    { color: var(--ink-2); }
.tx-act.repeat .tx-act-ic { background: var(--brand-tint); }
.tx-act.repeat .tx-act-ic svg { stroke: var(--brand); }
.tx-act.repeat .tx-act-lbl    { color: var(--brand); }
.tx-act.del    .tx-act-ic { background: var(--expense-tint); }
.tx-act.del    .tx-act-ic svg { stroke: var(--expense); }
.tx-act.del    .tx-act-lbl    { color: var(--expense); }
.tx-act:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; border-radius: 8px; }

/* Десктоп (мышь): без свайпа — трей раскрывается при наведении на ряд
   (та же flex-механика: контент сжимается, действия выезжают справа). */
@media (hover: hover) and (pointer: fine) {
  #history-list .tx-item:hover .tx-actions { width: 192px; }
  #history-list .tx-item.tx-2acts:hover .tx-actions { width: 128px; }
}

#history-more {
  width: 100%; margin-top: 14px;
  background: transparent;
  color: var(--ink-2);
  border: 1px dashed var(--rule-2);
  min-height: 44px;
}

/* =========================================================
   15. BOTTOM NAV — underline-top indicator on active
   ========================================================= */
.side-nav { display: none; }
.bottom-nav {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 84px 1fr 1fr;
  background: var(--surface);
  border-top: 1px solid var(--rule);
  padding: 6px 4px calc(6px + var(--safe-bottom));
  z-index: 20;
}
.bottom-nav-slot { flex: 0 0 84px; }
.fab {
  position: fixed;
  left: 50%;
  /* centerDocked как во Flutter: центр круга на верхней кромке бара (бар ~67px,
     радиус 29) → половина круга утоплена в бар, половина над ним. */
  bottom: calc(env(safe-area-inset-bottom, 0px) + 38px);
  transform: translateX(-50%);
  width: 58px; height: 58px;
  border: 0; border-radius: 999px;
  background: var(--brand);
  box-shadow: 0 3px 8px rgba(0,0,0,.32), 0 1px 4px rgba(31,191,160,.12);
  color: var(--brand-on);
  display: grid; place-items: center;
  cursor: pointer;
  z-index: 30;            /* над навбаром (20), но под модалками (scrim 50) */
  transition: transform var(--mo-fast) var(--mo-ease);
}
.fab svg { width: 30px; height: 30px; stroke: currentColor; }
.fab:active { transform: translateX(-50%) scale(.92); }
@media (min-width: 1024px) { .fab { display: none; } }
.bottom-nav button {
  background: transparent;
  border: none;
  border-radius: var(--r-md);
  padding: 7px 2px 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink-3);
  min-height: 54px;
  position: relative;
  touch-action: manipulation;
}
.bottom-nav button > span {
  font-size: 10px;
  line-height: 1;
}
.bottom-nav button svg {
  width: 22px; height: 22px;
  stroke: currentColor;
  flex: 0 0 auto;
  stroke-width: 1.7;
  fill: none;
}
/* Как во Flutter: активна только ИКОНКА (brand), подпись остаётся светлой (ink). */
.bottom-nav button.active {
  color: var(--brand);
  font-weight: 600;
}
.bottom-nav button.active > span {
  color: var(--ink);
}
.bottom-nav button:hover { background: transparent; border-color: transparent; }
.bottom-nav button:hover:not(.active) { color: var(--ink-2); }
.bottom-nav button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

/* =========================================================
   16. ADD-SHEET form
   ========================================================= */
/* Лист операции — паритет с Flutter add_transaction_sheet. */
.sheet-op-title { text-align: center; }
/* Шапка полноэкранной модалки операции: заголовок строго по центру, кнопка
   выхода — в правом верхнем углу (задача #6). */
.op-head { position: relative; display: flex; align-items: center;
  justify-content: center; margin-bottom: 14px; min-height: 32px; }
.op-head .sheet-op-title { margin: 0; }
/* Выразительная кнопка выхода: круглый фон + крупная яркая стрелка (#1). */
.op-close-btn { position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2);
  border: 1px solid var(--rule-2); display: inline-flex; align-items: center; justify-content: center; }
.op-close-btn:hover { background: var(--surface-3); }
.op-close-btn svg { width: 24px; height: 24px; stroke: var(--ink); stroke-width: 2.6; }
/* В режиме перевода зазоры между Откуда/Сумма/Куда задаёт только стрелка —
   убираем margin-bottom поля суммы, иначе снизу больше, чем сверху (задача #5). */
.field.op-field:has(+ #transfer-extra:not([hidden])) { margin-bottom: 0; }
/* Поле курса не задано — подсветка, что без него перевод не сохранится (#3). */
.transfer-fx.needs-rate { border-color: var(--warn); }
.transfer-fx.needs-rate .transfer-fx-label { color: var(--warn); }
/* Превью зачисляемой суммы в валюте получателя (#2). */
.transfer-conv { font-size: 12px; color: var(--ink-2); margin: 6px 2px 0;
  font-variant-numeric: tabular-nums; }
/* Комментарий — многострочный (2 строки по умолчанию, растёт по содержимому). */
.op-input-wrap:has(textarea) { align-items: start; }
.op-input-wrap textarea {
  border: none; background: transparent; padding: 0;
  width: 100%; color: var(--ink); font: inherit; font-size: 16px;
  resize: none; overflow: hidden; line-height: 1.4; min-height: 2.8em;
}
.op-input-wrap textarea:focus { box-shadow: none; background: transparent; }
/* Запас снизу под кнопку «Сохранить». Высокий потолок (98dvh) — у Перевода
   блоков больше, чем у Расхода/Дохода, поэтому окну операции даём почти весь
   экран, чтобы не резалось снизу. */
.sheet-op { padding-bottom: calc(24px + var(--safe-bottom)); max-height: 98dvh; }
/* При открытой модалке нижний навбар и FAB не должны просвечивать снизу. */
body.modal-open .bottom-nav,
body.modal-open .fab { display: none; }
/* Плавающие лейблы на рамке поля (Material outline, как Flutter). */
.sheet-op .op-field { position: relative; }
.sheet-op .op-field > label {
  position: absolute;
  top: 0; left: 12px;
  transform: translateY(-50%);
  z-index: 1;
  padding: 0 5px;
  background: var(--surface);
  text-transform: none; letter-spacing: 0;
  font-size: 12px; color: var(--ink-3); font-weight: 500;
  pointer-events: none;
}
.sheet-op .op-field:focus-within > label { color: var(--brand-2); }

.kind-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
  margin-bottom: 16px;
}
.kind-toggle button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  background: transparent;
  border-radius: var(--r-sm);
  padding: 11px 0;
  font-size: 14px;
  color: var(--ink-2);
  font-weight: 600;
}
.kind-toggle .kind-check { display: none; width: 15px; height: 15px; stroke: var(--income-2); fill: none; stroke-width: 2.6; }
/* Активный сегмент — зелёный акцент + галочка (как Flutter, независимо от вида). */
.kind-toggle button.active {
  background: color-mix(in srgb, var(--income-2) 14%, var(--surface-3));
  color: var(--income-2);
  box-shadow: var(--sh-edge);
}
.kind-toggle button.active .kind-check { display: inline-block; }

/* Поля листа: прозрачный outline-бокс + иконка слева + инпут (как Flutter). */
.op-input-wrap {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 12px 13px;
  min-height: 58px;
}
.op-input-wrap:focus-within { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
/* Категория-триггер в листе — тоже прозрачный outline. */
.sheet-op .cat-trigger { background: transparent; }
.sheet-op .cat-trigger:hover { background: transparent; border-color: var(--rule-2); }
.op-input-icon { width: 22px; height: 22px; stroke: var(--ink-3); fill: none; stroke-width: 1.7; }
.op-input-wrap input {
  border: none; background: transparent; padding: 0;
  min-height: auto; width: 100%;
  color: var(--ink);
  font-size: 16px;
}
.op-input-wrap input:focus { box-shadow: none; background: transparent; }
#amount {
  font-family: var(--font-numeric);
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Умные суммы-чипы под полем «Сумма»: частые/последние суммы пользователя.
   Горизонтальный ряд с прокруткой, тап задаёт сумму. */
.amount-chips {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.amount-chips::-webkit-scrollbar { display: none; }
.amount-chips[hidden] { display: none; }
.amount-chip {
  flex: 0 0 auto;
  padding: 7px 13px;
  border: 1px solid var(--rule-2, var(--rule));
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-2) var(--ease),
              color var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease);
}
.amount-chip:hover {
  background: var(--brand-tint);
  border-color: color-mix(in srgb, var(--brand) 40%, transparent);
  color: var(--brand);
}
.amount-chip:active { transform: scale(0.96); }
.amount-chip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Дата — безрамочная строка-триггер (как Flutter): иконка + дата + шеврон. */
/* .field.op-date-field — выше специфичность, чем у `.field{display:grid}`
   (иначе дата и время встают в стопку). Дата слева, время рядом — как во Flutter. */
/* .field.op-date-field — выше специфичность, чем у `.field{display:grid}`
   (иначе дата и время встают в стопку). Дата + время компактно в строку,
   иконка вплотную к тексту — как во Flutter. */
.field.op-date-field { position: relative; display: flex; align-items: center; gap: 22px; }
.op-date-field .date-trigger-chev { display: none; }
.date-trigger {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex: 0 1 auto;
  min-width: 0;
  background: transparent;
  border: none;
  border-radius: var(--r-md);
  padding: 10px 2px;
  min-height: 44px;
  color: var(--ink);
  text-align: left;
  font: inherit;
  touch-action: manipulation;
}
.date-trigger:hover { background: transparent; }
.date-trigger-cal { width: 22px; height: 22px; stroke: var(--ink-3); fill: none; stroke-width: 1.7; flex: 0 0 auto; }
.date-trigger-text { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date-trigger-chev { width: 16px; height: 16px; stroke: var(--ink-3); fill: none; stroke-width: 2; }
.time-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  background: transparent;
  border: none;
  border-radius: var(--r-md);
  padding: 10px 4px;
  min-height: 44px;
  color: var(--ink);
  font: inherit;
  touch-action: manipulation;
}
.date-native {
  position: absolute; left: 14px; bottom: 8px;
  width: 1px; height: 1px; opacity: 0; pointer-events: none;
}

/* П6: маркер обязательного поля — красная звёздочка */
.req-mark { color: var(--expense-2); margin-left: 2px; }

/* =========================================================
   Material-пикеры даты/времени (паритет с Flutter)
   ========================================================= */
.picker-scrim {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(1,4,9,.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; transition: opacity .16s var(--ease, ease);
}
.picker-scrim.open { opacity: 1; }
/* Открытый лист-модалка, над которым показан пикер даты — прячем, чтобы он не
   просвечивал сквозь полупрозрачный скрим пикера (пикер сам затемняет фон). */
.modal-scrim.under-picker { visibility: hidden; }
.picker-card {
  width: 100%; max-width: 360px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 24px;
  padding: 18px 18px 12px;
  box-shadow: 0 18px 50px rgba(0,0,0,.5);
  transform: translateY(8px) scale(.98);
  transition: transform .16s var(--ease, ease);
}
.picker-scrim.open .picker-card { transform: none; }
.picker-head-label { font-size: 13px; color: var(--ink-3); margin-bottom: 8px; }
.picker-actions {
  display: flex; align-items: center; gap: 6px;
  margin-top: 14px; justify-content: flex-end;
}
.picker-btn {
  background: transparent; border: none; cursor: pointer;
  color: var(--brand); font: inherit; font-weight: 600; font-size: 15px;
  padding: 8px 14px; border-radius: var(--r-md);
}
.picker-btn:hover { background: var(--surface-3); }
.picker-icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px;
  background: transparent; border: none; cursor: pointer; color: var(--ink-2);
  border-radius: var(--r-md);
}
.picker-icon-btn:hover { background: var(--surface-3); }
.picker-icon-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.tp-spacer { flex: 1; }

/* ---- DatePicker ---- */
.dp-head { border-bottom: 1px solid var(--rule); padding-bottom: 14px; margin-bottom: 10px; }
.dp-head-date { font-size: 30px; font-weight: 500; color: var(--ink); letter-spacing: -.5px; }
.dp-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.dp-month-btn {
  display: inline-flex; align-items: center; gap: 4px;
  background: transparent; border: none; cursor: pointer; color: var(--ink-2);
  font: inherit; font-size: 14px; padding: 8px 4px; border-radius: var(--r-md);
}
.dp-month-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
.dp-arrows { display: flex; gap: 2px; }
.dp-arrows button {
  display: grid; place-items: center; width: 38px; height: 38px;
  background: transparent; border: none; cursor: pointer; color: var(--ink-2); border-radius: 999px;
}
.dp-arrows button:hover { background: var(--surface-3); }
.dp-arrows svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
.dp-weekdays, .dp-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
}
.dp-weekdays span {
  text-align: center; font-size: 12px; color: var(--ink-3); padding: 6px 0;
}
.dp-day {
  aspect-ratio: 1; display: grid; place-items: center;
  /* min-width:0 — иначе aspect-ratio у грид-элемента раздувает ширину сверх
     1fr-колонки, и числа уезжают за правый край / не встают под дни недели. */
  min-width: 0; width: 100%;
  background: transparent; border: none; cursor: pointer;
  color: var(--ink); font: inherit; font-size: 14px; border-radius: 999px;
}
.dp-day:hover { background: var(--surface-3); }
.dp-day.today { box-shadow: inset 0 0 0 1.5px var(--brand); color: var(--brand); }
.dp-day.selected { background: var(--brand); color: var(--brand-on); font-weight: 700; }
.dp-years { max-height: 280px; overflow-y: auto; display: grid; grid-template-columns: repeat(3,1fr); gap: 4px; }
.dp-year {
  padding: 12px 0; text-align: center; background: transparent; border: none; cursor: pointer;
  color: var(--ink); font: inherit; font-size: 15px; border-radius: 999px;
}
.dp-year:hover { background: var(--surface-3); }
.dp-year.selected { background: var(--brand); color: var(--brand-on); font-weight: 700; }

/* ---- TimePicker ---- */
.tp-readout { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 4px 0 2px; }
.tp-seg {
  min-width: 96px; padding: 8px 10px; border: none; cursor: pointer;
  background: var(--surface-3); border-radius: var(--r-lg);
  font: inherit; font-size: 44px; font-weight: 500; color: var(--ink);
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.tp-seg.active { background: var(--brand-tint); color: var(--brand); }
.tp-colon { font-size: 40px; color: var(--ink-2); font-weight: 500; }
.tp-labels { display: flex; justify-content: center; gap: 96px; font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.tp-clock { width: 256px; max-width: 100%; margin: 14px auto 4px; touch-action: none; }
.tp-clock svg { width: 100%; height: auto; display: block; }
#tp-svg { background: var(--surface-3); border-radius: 999px; }
.tp-num { font-size: 15px; fill: var(--ink); font-family: inherit; }
.tp-num.sel { fill: var(--brand-on); font-weight: 700; }
#tp-hand { stroke: var(--brand); stroke-width: 2; }
#tp-hub { fill: var(--brand); }
#tp-knob { fill: var(--brand); }
.tp-actions { margin-top: 8px; }

.field { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.field label {
  color: var(--ink-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  font-weight: 700;
}

.cat-trigger {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: 12px 14px;
  color: var(--ink);
  text-align: left;
  font: inherit;
  min-height: 48px;
  touch-action: manipulation;
}
.cat-trigger:hover { background: var(--surface-3); }
.cat-trigger-text { font-size: 14px; }
.cat-trigger-chev { width: 16px; height: 16px; stroke: var(--ink-3); fill: none; stroke-width: 2; }

.chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 4px;
}
.chip {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 10px 14px;
  min-height: 44px;
  border-radius: var(--r-pill);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease),
              color var(--dur-2) var(--ease);
  touch-action: manipulation;
}
.chip:hover { background: var(--surface-3); }
.chip.active {
  background: var(--brand-tint);
  border-color: var(--brand);
  color: var(--brand-2);
  font-weight: 600;
}

.quick-dates { display: flex; gap: 6px; margin-top: 4px; }
.quick-dates button {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  padding: 10px 8px;
  font-size: 13px;
  color: var(--ink-2);
  border-radius: var(--r-md);
  min-height: 40px;
  touch-action: manipulation;
}
.quick-dates button:hover { color: var(--ink); }

.flash {
  background: var(--income-tint);
  color: var(--income-2);
  padding: 10px 14px;
  border-radius: var(--r-md);
  border: 1px solid color-mix(in srgb, var(--income) 35%, transparent);
  font-weight: 500;
  font-size: 13px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.flash::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--income);
  flex: 0 0 auto;
}
.flash.error {
  background: var(--expense-tint);
  color: var(--expense-2);
  border-color: color-mix(in srgb, var(--expense) 35%, transparent);
}
.flash.error::before { background: var(--expense); }

/* Инлайн-валидация полей формы операции: красная подсветка САМОЙ ячейки поля +
   подсказка прямо под ней. Заменяет нижний тост — тот уезжал под фиксированную
   кнопку «Сохранить» и был не виден. */
.op-input-wrap.is-invalid,
.cat-trigger.is-invalid,
.acc-flow-card.is-invalid,
.transfer-fx.is-invalid {
  border-color: var(--expense);
  box-shadow: 0 0 0 1px var(--expense);
  background: var(--expense-tint);
}
.field-err {
  color: var(--expense-2);
  font-size: 12.5px;
  font-weight: 500;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.field-err::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--expense);
  flex: 0 0 auto;
}

/* =========================================================
   17. TOAST
   ========================================================= */
.toast-host {
  position: fixed;
  left: 50%;
  /* Выше навбара и FAB (+) — тост не должен перекрываться кнопкой добавления. */
  bottom: calc(var(--nav-h) + var(--safe-bottom) + 88px);
  transform: translateX(-50%);
  z-index: 60;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.toast {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  max-width: min(92vw, 420px);
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--rule-3);
  border-radius: var(--r-pill);
  padding: 8px 8px 8px 10px;
  font-size: 14px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(1, 4, 9, 0.5);
}
/* Иконка-кружок успеха слева (premium-акцент). */
.toast .toast-ic {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border-radius: var(--r-pill);
  background: var(--brand-tint);
  display: flex; align-items: center; justify-content: center;
}
.toast .toast-ic svg {
  width: 17px; height: 17px;
  fill: none; stroke: var(--brand);
  stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
}
/* Текст тоста — одной строкой (тексты короткие), без переноса в столбик. */
.toast .toast-text, .toast > span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}
/* Инфо-тост без иконки/кнопки — текст по центру, симметричные поля, до 2 строк
   (не рвётся криво влево, #8). */
.toast.toast-info {
  padding: 12px 18px;
  justify-content: center;
}
.toast.toast-info .toast-text {
  white-space: normal;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  text-overflow: clip;
}
/* «Отменить» — компактная brand-ссылка в pill, не кричащая заливка. */
.toast .toast-btn, .toast button {
  flex: 0 0 auto;
  background: transparent;
  color: var(--brand);
  border: none;
  border-radius: var(--r-pill);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--dur-2) var(--ease);
}
.toast .toast-btn:hover, .toast button:hover { background: var(--brand-tint); }
.toast .progress {
  position: absolute;
  inset: auto 14px 3px 50px;
  height: 2px;
  background: color-mix(in srgb, var(--brand) 55%, transparent);
  border-radius: var(--r-pill);
  transform-origin: left;
  animation: shrink 5s linear forwards;
}
@keyframes shrink { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* Тост ошибки — заметная красная обводка. */
.toast.toast-error {
  background: var(--expense-tint);
  color: var(--expense-2);
  border-color: color-mix(in srgb, var(--expense) 40%, transparent);
  padding: 10px 18px;
}

/* =========================================================
   18. CAT SHEET
   ========================================================= */
.cat-sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  margin-bottom: var(--sp-4);
}
.cat-sheet-title-wrap {
  display: flex; align-items: center; gap: 12px;
  min-width: 0;
}
.cat-sheet-dot {
  width: 12px; height: 12px;
  border-radius: var(--r-pill);
  background: var(--cat-color, var(--brand));
  flex-shrink: 0;
}
.cat-sheet-head .cat-icon {
  width: 32px;
  height: 32px;
}
.cat-sheet-head h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cat-sheet-meta {
  display: grid; gap: 6px;
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-4);
}
.cat-sheet-num {
  display: flex; align-items: baseline; gap: 6px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.cat-sheet-num .cur {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  color: var(--ink-3);
}
.cat-sheet-sub {
  color: var(--ink-2);
  font-size: 12px;
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline;
  letter-spacing: 0.02em;
}
.cat-sheet-sub .dot-sep { color: var(--ink-4); }
.cat-sheet-list { gap: 0; }
.cat-sheet-list .tx-item {
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 4px;
  min-height: 44px;
}
.cat-sheet-list .tx-item .meta-col .name { font-size: 13px; }
.cat-sheet-list .tx-item .meta-col .sub  { font-size: 11px; }
.cat-sheet-list .tx-item .amt { font-size: 13px; }
.cat-sheet-add {
  width: 100%;
  margin-top: 12px;
  padding: 12px 14px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: transparent;
  border: 1px dashed var(--rule-2);
  color: var(--ink-2);
  border-radius: var(--r-md);
  font: inherit; font-size: 14px;
  cursor: pointer;
  min-height: 44px;
}
.cat-sheet-add:hover {
  background: var(--surface-2); color: var(--ink);
  border-color: var(--brand);
}
.cat-sheet-add svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.cat-sheet-list .tx-day { margin: 16px 4px 6px; }

/* =========================================================
   19. CAT PICKER
   ========================================================= */
.cat-picker-scrim .sheet.sheet-full {
  background: var(--bg);
  display: grid;
  grid-template-rows: auto 1fr auto;
}
.cat-picker-head {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 14px;
}
.cat-picker-head h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  text-align: center;
  margin: 0;
}
.cat-picker-kind {
  font-size: 10px;
  background: var(--expense-tint);
  color: var(--expense-2);
  border: 1px solid color-mix(in srgb, var(--expense) 35%, transparent);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}
/* Доход — зелёный чип (#6). */
.cat-picker-kind.income {
  background: var(--income-tint);
  color: var(--income-2);
  border-color: color-mix(in srgb, var(--income) 35%, transparent);
}
/* Невидимый спейсер в шапке (баланс flex напротив кнопки закрытия) — чтобы
   заголовок был по центру, без паразитной красной плашки cat-picker-kind. */
.cat-picker-spacer { width: 40px; flex: 0 0 auto; }
.cat-picker-body { overflow-y: auto; padding: 0 2px; }
/* Выбор категории — как в менеджере (#6/#7): сетка 4 в ряд, имя под иконкой. */
.cat-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding-bottom: 8px;
}
@media (min-width: 640px) {
  .cat-picker-grid { grid-template-columns: repeat(6, 1fr); }
}
/* Плитка категории в пикере: колонка «иконка сверху + имя снизу». */
.cat-picker-grid .cat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
  padding: 12px 6px;
  min-height: 96px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
}
.cat-picker-grid .cat-chip:hover { background: var(--surface-2); border-color: var(--rule-2); }
.cat-picker-grid .cat-chip.selected { background: var(--brand-tint); border-color: var(--brand); }
.cat-picker-grid .cat-chip .cat-chip-name {
  font-size: 11px;
  line-height: 1.25;
  text-align: center;
  color: var(--ink-2);
  letter-spacing: 0;
  width: 100%;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cat-picker-tile {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  cursor: pointer;
  height: auto;
  min-height: 60px;
  font: inherit;
  color: var(--ink);
  text-align: left;
  touch-action: manipulation;
  transition: background var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease),
              transform var(--dur-1) var(--ease-press);
}
.cat-picker-tile:hover { background: var(--surface-2); border-color: var(--rule-2); }
.cat-picker-tile:active { transform: scale(0.97); }
.cat-picker-tile.selected {
  background: var(--brand-tint);
  border-color: var(--brand);
}
.cat-picker-tile .cat-icon {
  background: var(--cat-color, var(--surface-2));
  flex: 0 0 auto;
}
.cat-picker-tile .name {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.3;
  letter-spacing: -0.005em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}
.cat-picker-tile.selected .name { color: var(--ink); font-weight: 600; }
.cat-picker-empty {
  color: var(--ink-3);
  font-size: 13px;
  text-align: center;
  padding: 24px 14px;
}
.cat-picker-foot {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 8px;
  padding: 12px 0 0;
  border-top: 1px solid var(--rule);
}
.cat-picker-foot input { min-height: 44px; }
.cat-picker-foot .primary {
  padding: 0;
  display: grid; place-items: center;
  min-height: 44px;
  border-radius: var(--r-md);
}
.cat-picker-foot .primary svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.4; }
.cat-picker-foot .primary[disabled] { opacity: 0.45; cursor: not-allowed; }
.cat-picker-hint {
  grid-column: 1 / -1;
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--warn);
}

/* =========================================================
   20. CATS-MGR + CAT EDIT
   ========================================================= */
.cats-mgr-head, .cat-edit-head {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
}
/* Шапка менеджера категорий: кнопки и заголовок в одну линию + отступ до
   вкладок Расходы/Доходы (image #5). */
.cats-mgr-head {
  align-items: center;
  gap: 12px;
  padding: 0 0 12px;
  margin-bottom: var(--sp-4);
  border-bottom: 1px solid var(--rule);
}
/* В редактировании категории справа кнопка «Сохранить» — ей нужна своя ширина
   (иначе при 44px её режет). Заголовок остаётся по центру за счёт 1fr. */
.cat-edit-head {
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--sp-4);
  position: relative; /* якорь для абсолютно-центрированного заголовка (#4) */
}
/* Заголовок вынесен из потока (absolute), поэтому grid авто-размещает кнопки
   не по своим колонкам (правая кнопка сползала в 1fr и растягивалась). Явно
   закрепляем: назад/закрыть → колонка 1, действия/сохранить → колонка 3. */
.cat-edit-head > #cat-edit-back,
.cat-edit-head > #cat-create-close { grid-column: 1; justify-self: start; }
.cat-edit-head > .cat-edit-head-actions,
.cat-edit-head > .cat-edit-save { grid-column: 3; justify-self: end; }
/* Кластер действий справа: корзина + «Сохранить» (#5). */
.cat-edit-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* Корзина в шапке (#5): всегда красная, справа. */
.cat-edit-trash svg { stroke: var(--expense-2, #f87171); }
.cat-edit-trash:hover { background: color-mix(in srgb, var(--expense-2, #f87171) 14%, transparent); }
/* «+» в шапке менеджера категорий (#1). */
.cats-mgr-add { justify-self: end; }
.cats-mgr-add svg { stroke: var(--brand); }
.cats-mgr-head h2, .cat-edit-head h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  text-align: center;
  margin: 0;
  overflow: hidden; text-overflow: ellipsis;
}
.cats-mgr-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  padding: 3px;
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-4);
}
.cats-mgr-tabs button {
  border: none;
  background: transparent;
  border-radius: var(--r-sm);
  padding: 9px 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  min-height: 38px;
}
.cats-mgr-tabs button.active {
  background: var(--surface-3);
  color: var(--brand);
  font-weight: 700;
}
.cats-mgr-list {
  list-style: none;
  padding: 4px 2px 8px;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
/* На узком телефоне 5 колонок рвут русские слова посреди («Путешест-вия»);
   4 колонки — длинные слова влезают одной строкой. /critique P2. */
@media (max-width: 479px) {
  .cats-mgr-list { grid-template-columns: repeat(4, 1fr); }
}
.cats-mgr-list > li { display: contents; }
.cats-mgr-list .cat-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0;
  width: 100%;
  /* без min-width:0 грид-плитка не сжимается ниже длины слова в имени —
     при 5 колонках на телефоне это ломало сетку вправо за экран */
  min-width: 0;
  padding: 12px 6px;
  min-height: 96px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
}
.cats-mgr-list .cat-chip:hover {
  background: var(--surface-2);
  border-color: var(--rule-2);
}
.cats-mgr-list .cat-chip .cat-chip-name {
  font-size: 11px;
  line-height: 1.25;
  text-align: center;
  color: var(--ink-2);
  letter-spacing: 0;
  width: 100%;
  /* Перенос ТОЛЬКО по границам слов — без разрыва слова посреди
     («Корректир-овка»). fitCatChipNames() ужимает шрифт, пока длинное слово
     не влезет в одну строку и всё имя — в ≤2 строки (#6). */
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cat-chip {
  width: 100%;
  display: grid;
  grid-template-columns: 40px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  min-height: 56px;
  background: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
  text-align: left;
  touch-action: manipulation;
}
.cat-chip:hover { background: var(--surface); }
.cat-chip .name,
.cat-chip .cat-chip-name { font-size: 16px; letter-spacing: -0.005em; }
.cat-chip .sub {
  font-size: 11px; color: var(--ink-3);
  font-family: var(--font-numeric);
  letter-spacing: 0.02em;
}
.cat-chip svg.cat-chip-chev {
  width: 16px; height: 16px;
  stroke: var(--ink-3);
  fill: none; stroke-width: 2;
}

/* Заголовок абсолютно центрирован по ширине экрана — не зависит от разной
   ширины боковых кластеров (назад слева vs корзина+Сохранить справа), из-за
   которой в grid 1fr он уезжал влево (#4). Вертикаль — по строке кнопок
   (top:0…bottom:12px = высота ряда без padding-bottom). Клики проходят к
   кнопкам под ним (pointer-events:none). */
.cat-edit-title-wrap {
  position: absolute;
  left: 0; right: 0; top: 0; bottom: 12px;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  gap: 2px;
  padding: 0 100px;
  pointer-events: none;
  z-index: 0;
}
.cat-edit-title-wrap h2 {
  font-size: 17px;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cat-edit-kind {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
  font-weight: 700;
  /* h2 в шапке выровнен по центру — бейдж типа под ним тоже */
  text-align: center;
}
/* Чип «Тип» в теле (фиксированный, цветной): расход красный / доход зелёный.
   Заменил заголовок+тип в шапке — убрал наезд «Сохранить» и обрезание имени. */
.cat-kind-chip {
  display: inline-block;
  align-self: flex-start;
  /* Секция — grid, поэтому без justify-self:start чип растягивался на всю
     ширину. Ужимаем до содержимого — «РАСХОД» одной строкой. */
  justify-self: start;
  width: fit-content;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: var(--r-pill);
  background: var(--expense-tint);
  color: var(--expense-2);
  border: 1px solid color-mix(in srgb, var(--expense) 35%, transparent);
}
.cat-kind-chip.income {
  background: var(--income-tint);
  color: var(--income-2);
  border-color: color-mix(in srgb, var(--income) 35%, transparent);
}
.cat-edit-save { padding: 10px 16px; font-size: 13px; min-height: 40px; }
/* Нет изменений → кнопку «Сохранить» прячем (место сохраняем), появляется при правке. */
.cat-edit-save[disabled] { visibility: hidden; }
.cat-edit-preview { display: grid; place-items: center; padding: var(--sp-5) 0 var(--sp-6); }
.cat-edit-section {
  display: grid;
  gap: var(--sp-3);
  padding-bottom: var(--sp-5);
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--sp-5);
}
.cat-edit-section:last-child { border-bottom: none; margin-bottom: 0; }
/* Тип/Название/Лимит — лейбл и поле в ОДНУ строку (лейбл слева, поле справа). */
.cat-edit-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 14px;
  row-gap: 6px;
}
.cat-edit-row > .cat-edit-h { margin: 0; white-space: nowrap; }
.cat-edit-row > .cat-kind-chip,
.cat-edit-row > .limit-field { justify-self: end; }
.cat-edit-row > .cat-create-name { margin: 0; }
/* Подсказка валидности — на всю ширину под полем, не в строке лейбла. */
.cat-edit-row > .cat-picker-hint { grid-column: 1 / -1; margin: 0; }
.cat-edit-h {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-2);
  font-weight: 700;
  margin: 0;
}
.cat-edit-palette {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}
.cat-color-swatch {
  width: 100%; aspect-ratio: 1 / 1;
  background: var(--swatch-color, var(--brand));
  border-radius: var(--r-md);
  cursor: pointer;
  position: relative;
  border: 2px solid var(--rule-2);
  padding: 0;
  display: grid; place-items: center;
  transition: transform var(--dur-1) var(--ease-press),
              border-color var(--dur-2) var(--ease);
  touch-action: manipulation;
}
.cat-color-swatch:hover { transform: scale(1.07); }
.cat-color-swatch:active { transform: scale(0.94); }
.cat-color-swatch.selected {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--bg);
}
.cat-color-swatch svg {
  width: 18px; height: 18px;
  stroke: var(--on-accent);
  stroke-width: 2.4;
  fill: none;
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease);
}
.cat-color-swatch.selected svg { opacity: 1; }
.cat-edit-shades-btn {
  width: 100%;
  display: grid;
  grid-template-columns: 18px 1fr 16px;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  min-height: 44px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.cat-edit-shades-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.cat-edit-shades-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.cat-edit-shades-btn svg.chev {
  width: 14px; height: 14px;
  transition: transform var(--dur-2) var(--ease);
}
.cat-edit-shades-btn[aria-expanded="true"] svg.chev { transform: rotate(90deg); }
.cat-edit-shades-btn[aria-expanded="true"] {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.cat-edit-icons {
  display: block;
}
.cat-icon-tile {
  width: 100%; aspect-ratio: 1 / 1;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  display: grid; place-items: center;
  transition: background var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease),
              transform var(--dur-1) var(--ease-press);
  touch-action: manipulation;
}
.cat-icon-tile::before {
  content: "";
  position: absolute; inset: 0;
  background: var(--ink-2);
  -webkit-mask: var(--cat-icon-url) no-repeat center / 60%;
          mask: var(--cat-icon-url) no-repeat center / 60%;
}
.cat-icon-tile:hover { border-color: var(--rule-2); }
.cat-icon-tile:active { transform: scale(0.94); }
.cat-icon-tile.selected {
  background: var(--cat-color, var(--brand));
  border-color: var(--cat-color, var(--brand));
}
.cat-icon-tile.selected::before { background: var(--bg); }
/* П16: усиленный фокус на иконках категорий — 3px + box-shadow для контраста */
.cat-icon-tile:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--brand-tint);
}

/* Создание категории: имя, палитра, иконки по группам */
.cat-create-name {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  color: var(--ink);
  padding: 10px 12px;
  font-size: 15px;
}
.cat-create-name:focus { outline: none; border-color: var(--brand); }
.cat-create-hint-inline { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.cat-create-palette { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-pal-swatch {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid var(--rule-2);
  cursor: pointer;
  padding: 0;
  touch-action: manipulation;
}
.cat-pal-swatch.selected {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink);
}
.cat-create-group-title {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: var(--sp-4) 0 var(--sp-2);
}
.cat-create-group-title:first-child { margin-top: 0; }
.cat-create-icons-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

/* --- Двухуровневый пикер иконок (#3): группы → иконки группы + назад --- */
.cat-icon-picker { display: block; }
.cat-icon-groups {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
/* Плитка группы: превью-иконка + название темы (как карточка категории). */
.cat-icon-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 12px 6px;
  min-height: 96px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--ink);
  font: inherit;
  touch-action: manipulation;
  transition: background var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease),
              transform var(--dur-1) var(--ease-press);
}
.cat-icon-group:hover { background: var(--surface-2); border-color: var(--rule-2); }
.cat-icon-group:active { transform: scale(0.97); }
.cat-icon-group.selected { background: var(--brand-tint); border-color: var(--brand); }
.cat-icon-group-name {
  font-size: 11px;
  line-height: 1.25;
  text-align: center;
  color: var(--ink-2);
  width: 100%;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Кнопка возврата к списку групп — строка «‹ Название темы». */
.cat-icon-group-back {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 6px 12px;
  margin-bottom: 4px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  touch-action: manipulation;
}
.cat-icon-group-back svg {
  width: 20px; height: 20px;
  stroke: var(--brand); fill: none; stroke-width: 2;
  flex: 0 0 auto;
}
.cat-icon-group-back:hover span { color: var(--brand); }
.cat-icon-group-view { display: block; }
.cat-edit-empty {
  text-align: center; color: var(--ink-3); padding: 24px 14px; font-size: 13px;
}

.cat-edit-delete-section {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.cat-edit-delete-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 16px;
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  border-radius: var(--r-md);
  color: var(--danger);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-2) var(--ease),
              border-color var(--dur-2) var(--ease);
}
.cat-edit-delete-btn svg {
  width: 18px; height: 18px;
  stroke: currentColor; fill: none; stroke-width: 1.8;
  flex-shrink: 0;
}
.cat-edit-delete-btn:hover {
  background: var(--expense-tint, color-mix(in srgb, var(--danger) 10%, transparent));
  border-color: color-mix(in srgb, var(--danger) 60%, transparent);
}
.cat-edit-delete-btn:active { filter: brightness(0.94); }

/* Confirm sheet — operations list */
/* Премиум-confirm — паритет с Flutter showDangerConfirm:
   круг-иконка expense-tint, центрированные заголовок/текст, кнопки в ряд. */
.confirm-card { text-align: center; }
.confirm-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px; height: 56px;
  margin: 4px auto 16px;
  border-radius: var(--r-pill);
  background: var(--expense-tint);
}
.confirm-icon svg {
  width: 26px; height: 26px;
  fill: none;
  stroke: var(--expense-2, var(--expense));
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.confirm-card h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--ink);
}
.confirm-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-3);
  margin: 0 0 20px;
  white-space: pre-line; /* многострочная сводка операции (дата/время/коммент) */
}
/* Первая строка сводки (категория · сумма) — акцентнее остального. */
.confirm-text { font-weight: 500; }
.confirm-text:empty { display: none; }
.confirm-actions {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}
.confirm-btn {
  flex: 1;
  padding: 14px 0;
  border: none;
  border-radius: var(--r-md);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: filter var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.confirm-btn.cancel { background: var(--surface-2); color: var(--ink-2); }
.confirm-btn.cancel:hover { background: var(--surface-3); }
.confirm-btn.danger { background: var(--expense); color: #fff; font-weight: 700; }
.confirm-btn.danger:hover { filter: brightness(1.06); }
.confirm-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
/* Когда показан список операций (удаление категории) — текст слева, не центр. */
.confirm-card .confirm-list { text-align: left; }

.confirm-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.confirm-list-item {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 8px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--rule);
}
.confirm-list-item:last-child { border-bottom: none; }
.confirm-list-item .cli-date {
  color: var(--ink-3);
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 12px;
}
.confirm-list-item .cli-amt {
  color: var(--expense, var(--danger));
  white-space: nowrap;
  flex-shrink: 0;
  font-weight: 600;
}
.confirm-list-item .cli-comment {
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Shades — инлайн-панель внутри секции «Цвет» редактора категории */
.shades-fam {
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
  margin-left: 8px;
}
.shades-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--dur-3) var(--ease);
}
.shades-panel[hidden] { display: grid; }
.shades-panel.open { grid-template-rows: 1fr; }
.shades-panel-inner {
  overflow: hidden;
  min-height: 0;
}
.shades-grid-49 {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-top: none;
  border-radius: 0 0 var(--r-md) var(--r-md);
}
.shades-grid-49 .cat-color-swatch { aspect-ratio: 1 / 1; }
@media (prefers-reduced-motion: reduce) {
  .shades-panel { transition: none; }
}

/* =========================================================
   21. CAT SUGGEST
   ========================================================= */
.cat-input-wrap { position: relative; }
.cat-suggest {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  z-index: 5;
  margin: 0; padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-md);
  max-height: 220px;
  overflow-y: auto;
  box-shadow: var(--sh-edge-2);
}
.cat-suggest li {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 14px;
  cursor: pointer;
  color: var(--ink);
  display: flex; align-items: center; gap: 8px;
  min-height: 44px;
}
.cat-suggest li mark {
  background: transparent;
  color: var(--brand);
  font-weight: 700;
  padding: 0;
}
.cat-suggest li:hover,
.cat-suggest li[aria-selected="true"] {
  background: var(--surface-2);
}

/* =========================================================
   22. ANALYSIS TAB
   ========================================================= */
.ana-hero {
  display: grid;
  gap: var(--sp-4);
  padding: 4px 0;
}
.ana-hero-headline {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-xl);
  padding: 16px;
  display: grid;
  gap: 6px;
}
.ana-hero-headline .hero-amount { margin: 4px 0 0; }
.ana-hero-headline .hero-amount .num { font-size: clamp(30px, 8vw, 42px); }
.ana-hero-headline .hero-lbl { color: var(--ink-2); }
.hero-meta {
  display: flex; gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
  font-family: var(--font-numeric);
}
.hero-meta b {
  color: var(--ink);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.hero-meta .sep { color: var(--ink-4); }
.hero-meta .dim { color: var(--ink-3); }

/* KPI-сетка «Анализа» — двухуровневая иерархия, в отличие от плоского
   inline-ряда «Обзора»: 2 ключевые метрики крупно, 4 — компактной плиткой. */
.ana-hero-kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.ana-kpi {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: grid;
  gap: 4px;
}
.ana-kpi .lbl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-2);
  font-weight: 700;
}
.ana-kpi .val {
  font-family: var(--font-numeric);
  font-weight: 700;
  font-size: clamp(18px, 5.2vw, 23px);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.ana-kpi .sub {
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-numeric);
  letter-spacing: 0.02em;
}

/* Акцентная плашка «Средний» — зелёная подложка (как ключевая метрика Flutter).
   Все 4 плашки вертикальные в сетке 2×2 (паритет с Flutter _KpiGrid). */
.ana-kpi.is-accent {
  background:
    linear-gradient(180deg, var(--brand-tint), transparent 80%),
    var(--surface);
  border-color: color-mix(in srgb, var(--brand-edge) 60%, var(--rule-2));
  box-shadow: var(--sh-edge);
}
.ana-kpi.is-accent .lbl { color: var(--brand-2); }

/* PRO-вариант плашки — фиолетовый акцент (платный набор «Статистика периода»). */
.ana-kpi.is-pro {
  background:
    linear-gradient(180deg, var(--pro-tint), transparent 80%),
    var(--surface);
  border-color: var(--pro-edge);
  box-shadow: var(--sh-edge);
}
.ana-kpi.is-pro .lbl { color: var(--pro-2); }

/* Заголовок набора «Статистика периода» с PRO-бейджем + отступ от блока выше. */
.ana-stats-kpis { margin-top: var(--sp-5); }
.ana-stats-kpis .ana-stats-head {
  display: flex; align-items: center; gap: 8px; margin: 0;
}
.pro-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--pro);
  color: var(--pro-on);
  vertical-align: middle;
}

.ana-hero-trend {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
}
.ana-hero-trend-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 6px;
}
.ana-trend-line { color: var(--ink-2); font-size: 13px; line-height: 1.5; }

.ana-card {
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--rule-2) 70%, transparent);
  border-radius: var(--r-xl);
  padding: var(--sp-4);
}
.ana-card.scrollable {
  max-height: none;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  padding: 0;
}
.ana-card.scrollable .ana-card-head {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--rule);
  margin: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.ana-card.scrollable .ana-scroll-body {
  overflow-y: visible;
  padding: 12px 16px 14px;
}

@media (min-width: 1024px) {
  .ana-card.scrollable {
    max-height: clamp(380px, 62vh, 720px);
  }
  .ana-card.scrollable .ana-scroll-body {
    overflow-y: auto;
  }
}
.ana-card-head h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-2);
  font-weight: 700;
  margin: 0;
}

.ana-bars { display: grid; gap: 10px; }
.ana-bar-row {
  display: grid;
  gap: 4px;
}
.ana-bar-head {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}
.ana-bar-head .cat-icon { flex: 0 0 auto; }
.ana-bar-head .name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.ana-bar-head .amt {
  font-family: var(--font-numeric);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--ink);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.ana-bar-track {
  height: 4px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-left: 42px;
}
.ana-bar-fill {
  height: 100%;
  border-radius: var(--r-pill);
  transition: width 500ms var(--ease);
}
.ana-bar-meta {
  display: flex;
  gap: 10px;
  margin-left: 42px;
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  margin-top: 2px;
}
.ana-bar-meta b {
  color: var(--ink-2);
  font-weight: 600;
}
.ana-bar {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  padding: 4px 0;
}
.ana-bar .cat-icon { background: var(--cat-color, var(--brand)); }
.ana-bar .body {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.ana-bar .name {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 14px;
  color: var(--ink);
  font-weight: 500;
  overflow: hidden;
  min-width: 0;
}
.ana-bar .track {
  height: 4px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.ana-bar .fill {
  height: 100%;
  background: var(--cat-color, var(--brand));
  border-radius: var(--r-pill);
  transition: width 500ms var(--ease);
}
.ana-bar .num {
  font-family: var(--font-numeric);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.ana-top-list {
  list-style: none;
  padding: 0; margin: 0;
  display: grid; gap: 0;
}
/* Тот же паттерн, что у «Топ категорий»: иконка+имя+сумма — центрированный
   верхний ряд, описание уходит строкой ниже под именем. Иконка центрируется
   относительно имени, а не относительно стопки имя+описание. */
.ana-top-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 40px 1fr auto;
  grid-template-areas:
    "icon name amt"
    ".    sub  .";
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
  min-height: 44px;
}
.ana-top-list li > .cat-icon { grid-area: icon; }
.ana-top-list li > .name { grid-area: name; }
.ana-top-list li > .amt  { grid-area: amt; }
.ana-top-list li > .sub  { grid-area: sub; }
.ana-top-list li:last-child { border-bottom: none; }
/* П5: фокус-индикатор для фокусируемых строк топ-расходов */
.ana-top-list li:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: -2px;
  border-radius: var(--r-sm);
  background: var(--brand-tint);
}
.ana-top-list .rank {
  font-family: var(--font-numeric);
  font-size: 11px;
  color: var(--ink-4);
  font-weight: 700;
  text-align: right;
}
.ana-top-list .name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ana-top-list .sub {
  font-size: 11px; color: var(--ink-3);
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ana-top-list .amt {
  font-family: var(--font-numeric);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--expense-2);
  white-space: nowrap;
  text-align: right;
}
.ana-top-list .num {
  font-family: var(--font-numeric);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--expense-2);
}

.ana-yoy { display: grid; gap: 10px; }
.ana-yoy-legend {
  font-size: 11px;
  line-height: 1.4;
  margin: 0 0 4px;
}
.ana-yoy-totals {
  display: grid;
  gap: 6px;
  margin: 0 0 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
}
.ana-yoy-totals > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--font-numeric);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.ana-yoy-totals > div .dim { font-size: 12px; }
.ana-yoy-totals > div b { font-weight: 700; color: var(--ink); }
.ana-yoy-totals .d {
  justify-content: flex-start;
  margin-top: 2px;
}
.ana-yoy .row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}
.ana-yoy .row:last-child { border-bottom: none; }
.ana-yoy .name { font-size: 13px; color: var(--ink); }
.ana-yoy .pair {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-family: var(--font-numeric);
}
.ana-yoy .vals { color: var(--ink-2); }
.ana-yoy .delta { font-size: 11px; }

/* Dynamic yoy rows (JS-rendered: ana-yoy-row) */
.ana-yoy-row {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  min-height: 44px;
}
.ana-yoy-row:last-child { border-bottom: none; }
.ana-yoy-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ana-yoy-vals {
  display: grid;
  gap: 1px;
  text-align: right;
  font-family: var(--font-numeric);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.ana-yoy-vals .cur {
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.ana-yoy-vals .dim { color: var(--ink-3); }
.ana-yoy-d .ana-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ana-pill.up {
  background: color-mix(in srgb, var(--expense) 18%, transparent);
  color: var(--expense-2);
}
.ana-pill.down {
  background: color-mix(in srgb, var(--income) 18%, transparent);
  color: var(--income-2);
}
.ana-pill.flat {
  background: var(--surface-2);
  color: var(--ink-3);
}

.yoy-picker {
  display: flex; align-items: center; gap: 8px;
}
.yoy-label {
  font-size: 11px;
  color: var(--ink-2);
  font-family: var(--font-numeric);
  letter-spacing: 0.02em;
  min-width: 110px;
  text-align: center;
}
.yoy-picker .icon-btn { width: 36px; height: 36px; }

/* На desktop карточки Анализа стоят в 2–3 колонки и заметно уже —
   имена категорий и подписи переносим, а не обрезаем многоточием. */
@media (min-width: 1024px) {
  /* Строки «Год к году» центрируют иконку относительно текста — как
     «Топ категорий»; раньше align-items: start уводил имя выше центра. */
  .ana-yoy-name {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.25;
  }
  .ana-top-list .sub {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.35;
  }
}

/* =========================================================
   23. PLANNING TAB
   ========================================================= */
/* KPI-сводка: 3 отдельные карточки в ряд (паритет с Flutter). */
.plan-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.plan-sum-kpi {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr;
  align-content: start;
  gap: 3px;
  min-width: 0;
}
.plan-sum-kpi .lbl {
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 500;
}
.plan-sum-kpi .val {
  font-family: var(--font-numeric);
  font-weight: 700;
  font-size: clamp(14px, 4.2vw, 17px);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.plan-sum-kpi .val.val-long { font-size: clamp(10px, 3vw, 13px); }
.plan-sum-kpi.closed .val    { color: var(--income-2); }
.plan-sum-kpi.remaining .val { color: var(--brand); }
/* Долги: «Мне должны» зелёным (как доход), «Я должен» красным (как расход).
   После .remaining — перебивает brand у «Я должен» по порядку (равная специфичность). */
.plan-sum-kpi .val.income  { color: var(--income-2); }
.plan-sum-kpi .val.expense { color: var(--expense-2); }
.plan-sum-kpi .sub {
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-numeric);
  /* Резервируем строку подписи всегда (даже пустую) — чтобы плашки в ряду были
     одинаковой высоты, когда у части нет подписи (напр. «Осталось»/«Оплачено»). */
  min-height: 14px;
}

/* Пустую подпись скрываем — не оставляет «воздух» под значением. */
.plan-sum-kpi .sub:empty { display: none; min-height: 0; }

/* Платежи: сводка из 2 KPI + группы (Разовые / Подписки) */
.pay-summary { grid-template-columns: repeat(2, 1fr); }
/* «Регулярные»: крупнее значение, меньше пустоты снизу (фидбэк #13). */
.pay-summary .plan-sum-kpi .val { font-size: clamp(16px, 4.6vw, 20px); }
.pay-group { display: grid; gap: 10px; }
.pay-group + .pay-group { margin-top: var(--sp-5); }
/* Отступ между KPI-плашками и заголовком группы / следующей сводкой,
   чтобы «РАЗОВЫЕ»/«ПОДПИСКИ» не липли к плашкам. */
.pay-summary + .pay-group { margin-top: var(--sp-5); }
.pay-group + .pay-summary { margin-top: var(--sp-5); }
.pay-group-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 0 2px;
}
.pay-group-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0;
}
.pay-group-sub {
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--font-numeric);
}

/* KPI-плашки Платежей (Разовые/Регулярные) — как в Планах/Целях: данные слева
   (без центрирования), такой же отступ до карточки ниже (см. grid gap:20px). */

/* Кастомные триггеры мета-строки Платежей (дата/категория/период) — кнопки
   в стиле формы операции вместо нативных <input type=date>/<select>. */
.meta-trig {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  transition: border-color var(--dur-2) var(--ease);
}
.meta-trig:hover { border-color: var(--rule-2); }
.meta-trig.is-empty { color: var(--ink-3); }
/* Иконки даты/периода/категории — одного размера (18px). */
.meta-trig-ic { width: 18px; height: 18px; flex: 0 0 auto; stroke: var(--ink-3); }
.meta-trig-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta-trig-chev { width: 14px; height: 14px; flex: 0 0 auto; stroke: var(--ink-3); margin-left: auto; }
.meta-cat-dot { flex: 0 0 auto; width: 18px; height: 18px; }
/* Раскладка мета-строки: дата по содержимому, категория растягивается. */
/* Мета-строка платежа: дата/списание и категория — две равные колонки, чтобы
   категории во всём списке стояли по одной линейке (не «прыгали» от ширины
   соседнего чипа). Селектор .plan-line2.pe-meta перебивает display:flex из
   .plan-line2. Чипы тянутся на всю колонку и сжимаются с многоточием. */
.plan-line2.pe-meta {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px; align-items: center;
}
/* Регулярные: чип «списание» (числовая дата + период) чуть длиннее категории,
   отдаём ему немного больше колонки. Граница колонок фиксирована → категории
   всё равно стоят по линейке. */
.sub-row .plan-line2.pe-meta {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
}
.sub-row .meta-sched-trig { padding-left: 8px; padding-right: 8px; gap: 5px; }
/* Регулярные: чуть мельче шрифт чипов, чтобы «каждые N …» вмещалось целиком. */
.sub-row .meta-trig { font-size: 11px; }
.pe-meta .meta-date-trig,
.pe-meta .meta-sched-trig,
.pe-meta .meta-cat-trig { min-width: 0; width: 100%; justify-content: flex-start; }
/* Период — в строке 1 перед суммой: компактный, по содержимому. */
/* Сумма + период (мес/год) стопкой: период ПОД суммой, выровнены вправо.
   В строке 1 подписки выравниваем по ВЕРХУ — чтобы сумма была на уровне
   названия, а период висел под ней (а не центрировался вместе с колонкой). */
/* Редактор «Списание»: дата (строка-триггер) + периодичность + превью дат. */
.sched-date-row {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  color: var(--ink);
  font: inherit; cursor: pointer;
  margin-bottom: var(--sp-3);
}
.sched-row-lbl { font-size: 12px; color: var(--ink-3); margin-bottom: 8px; }
.sched-date-row .sched-row-lbl { margin: 0; }
.sched-date-val { font-family: var(--font-numeric); font-weight: 600; color: var(--brand-2); }
.sched-block { margin-bottom: var(--sp-3); }
.sched-every { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sched-every-lbl { font-size: 14px; color: var(--ink-2); }
.sched-stepper {
  display: inline-flex; align-items: center;
  background: var(--surface-2); border: 1px solid var(--rule); border-radius: var(--r-md);
  overflow: hidden;
}
.sched-stepper button {
  width: 34px; height: 34px; border: 0; background: transparent; color: var(--ink);
  font-size: 19px; line-height: 1; cursor: pointer;
}
.sched-stepper button:hover { background: var(--surface-3, var(--surface)); }
.sched-stepper input {
  width: 54px; height: 34px; border: 0; background: transparent; text-align: center;
  font-family: var(--font-numeric); font-weight: 700; font-size: 15px; color: var(--ink);
  outline: none;
}
.sched-unit { flex: 1 1 auto; min-width: 156px; grid-template-columns: repeat(4, 1fr); }
.sched-unit button { padding: 11px 2px; }
.sched-preview { display: flex; flex-wrap: wrap; gap: 6px; }
.sched-preview .sched-date {
  font-family: var(--font-numeric); font-size: 13px; color: var(--ink-2);
  background: var(--surface-2); border-radius: var(--r-sm); padding: 5px 9px;
}
.plan-row.is-done .meta-trig { opacity: 0.6; }

/* Сводка периода (дайджест) — отдельный блок НИЖЕ KPI-сетки. Карточки в том же
   акцентном feature-стиле, что и KPI-сетка (.ana-kpi.is-accent): зелёный
   градиент + зелёная рамка + зелёный лейбл, — чтобы оба набора плашек выглядели
   одинаково. Отступ сверху (20px) отделяет блок от KPI по ритму main.tab. */
.digest-card { margin-top: var(--sp-5); }
.digest-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: var(--sp-2);
}
.digest-item {
  background:
    linear-gradient(180deg, var(--brand-tint), transparent 80%),
    var(--surface);
  border: 1px solid color-mix(in srgb, var(--brand-edge) 60%, var(--rule-2));
  border-radius: var(--r-md);
  box-shadow: var(--sh-edge);
  padding: 12px 16px;
  display: grid;
  gap: 4px;
  align-content: start;
  min-width: 0;
}
.digest-lbl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brand-2);
  font-weight: 700;
}
.digest-val {
  font-family: var(--font-numeric);
  font-weight: 700;
  font-size: clamp(18px, 5.2vw, 23px);
  color: var(--ink);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.digest-sub {
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-numeric);
  letter-spacing: 0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Разделы хаба «Планы»: тот же вертикальный ритм, что у прямых детей main.tab
   (gap 20px) — обёртка не должна съедать зазор между KPI-строкой и блоком. */
#plan-section-plans, #plan-section-goals,
#plan-section-onetime, #plan-section-recurring {
  display: grid;
  gap: 20px;
  grid-auto-rows: max-content;
}

.plan-halves { display: grid; gap: var(--sp-3); }
.plan-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-xl);
  padding: 14px;
  display: grid;
  gap: 0;
}
.plan-card-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
  padding: 0 0 8px;
  margin: 0;
  border: 0; border-bottom: 1px solid var(--rule);
  background: none; width: 100%; text-align: left;
  cursor: pointer; color: inherit; font: inherit;
  -webkit-tap-highlight-color: transparent;
}
.plan-head-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.plan-chev {
  width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2;
  color: var(--ink-3); transition: transform var(--mo-base) var(--mo-ease);
}
/* Свёрнуто — шеврон вверх «^», развёрнуто — вниз «v» (паритет с Flutter). */
.plan-card-head[aria-expanded="false"] .plan-chev { transform: rotate(180deg); }
/* В свёрнутом виде — компактная полоса: без нижней линии и отступа (как Flutter). */
.plan-card-head[aria-expanded="false"] { border-bottom-color: transparent; padding-bottom: 0; }
/* Свёрнутый период не должен быть высоким — ужимаем вертикальные поля карточки
   и кегль заголовка. */
.plan-card:has(.plan-card-head[aria-expanded="false"]) { padding-top: 6px; padding-bottom: 6px; }
.plan-card-head[aria-expanded="false"] h2 { font-size: 14.5px; line-height: 1.15; }
.plan-card-head[aria-expanded="false"] .plan-chev { width: 16px; height: 16px; }
.plan-card-body {
  display: grid; grid-template-rows: 1fr;
  transition: grid-template-rows var(--mo-base) var(--mo-ease);
}
.plan-card-head[aria-expanded="false"] + .plan-card-body { grid-template-rows: 0fr; }
.plan-card-body-inner { overflow: hidden; min-height: 0; display: grid; gap: 12px; padding-top: 12px; }
.plan-card-head h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0;
}
.plan-range {
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--font-numeric);
  letter-spacing: 0;
}
/* Триггер периода: тап открывает модалку выбора диапазона дат (с-по). */
.plan-range-trig {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; border: none; padding: 3px 6px;
  border-radius: var(--r-sm);
  color: var(--ink-3); font: inherit; font-size: 12px;
  font-family: var(--font-numeric);
  cursor: pointer;
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
}
.plan-range-trig:hover { color: var(--ink-2); background: var(--surface-2); }
.plan-range-ic {
  width: 13px; height: 13px; stroke: var(--ink-4); fill: none;
  stroke-width: 1.8; flex: 0 0 auto;
}
/* Модалка «Период»: превью диапазона для текущего месяца + подсказка. */
.period-preview {
  font-family: var(--font-numeric); font-size: 17px; font-weight: 600;
  color: var(--brand-2); margin-top: 2px;
}
.period-hint { font-size: 12px; color: var(--ink-3); margin-top: 8px; line-height: 1.3; }
/* Осталось/Закрыто половины — простой 2-колоночный текст (как Flutter),
   без рамок-подкарт. */
.plan-totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.plan-total {
  background: transparent;
  padding: 0;
  display: grid;
  gap: 2px;
}
.plan-total .lbl {
  font-size: 13px;
  letter-spacing: 0;
  color: var(--ink-2);
  font-weight: 500;
}
.plan-total .val {
  font-family: var(--font-numeric);
  font-weight: 700;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.plan-total.remaining .val { color: var(--brand); }
.plan-total.spent .val     { color: var(--income-2); }
.plan-total .sub {
  font-size: 10px;
  color: var(--ink-4);
  font-family: var(--font-numeric);
}

.plan-list { display: grid; }
.plan-empty {
  padding: 20px 12px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.5;
  border: 1px dashed var(--rule-2);
  border-radius: var(--r-md);
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Компактная строка плана (паритет с приложением): две линии —
   (1) чекбокс + название + сумма + удалить; (2) прогресс-бар + % · закрыто. */
.plan-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
}
.plan-row:last-child { border-bottom: none; }
.plan-row.is-done .plan-text-input,
.plan-row.is-done .plan-note-input { text-decoration: line-through; color: var(--ink-3); }
.plan-row.is-done .plan-amount-input { color: var(--ink-3); }

/* ── Линия 1 ── */
.plan-line1 {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* Центрирование по вертикали → старые top-сдвиги не нужны. */
.plan-line1 .plan-check, .plan-line1 .plan-del { margin-top: 0; }
.plan-line1 .plan-amount-wrap { margin-top: 0; }
.plan-check {
  width: 22px; height: 22px;
  min-height: 22px;
  flex: 0 0 auto;
  margin-top: 2px;
  border: 1.5px solid var(--rule-3);
  background: transparent;
  border-radius: var(--r-sm);
  padding: 0;
  display: grid; place-items: center;
  cursor: pointer;
  color: transparent;
  transition: all var(--dur-2) var(--ease);
  position: relative;
}
.plan-check::after {
  content: "";
  position: absolute;
  inset: -9px;
}
.plan-check svg {
  width: 14px; height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.6;
}
.plan-check.checked {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--brand-on);
}
/* Тумблер активна/пауза у регулярного платежа — вместо галочки: понятнее, что
   подписку можно поставить на паузу, а не «закрыть» как разовый пункт. */
.sub-toggle {
  flex: 0 0 auto;
  margin-top: 2px;
  width: 38px; height: 22px;
  padding: 0;
  border: 1.5px solid var(--rule-3);
  background: var(--surface-2);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
}
.sub-toggle-knob {
  position: absolute;
  top: 50%; left: 2px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--ink-3);
  transform: translateY(-50%);
  transition: transform var(--dur-2) var(--ease), background var(--dur-2) var(--ease);
}
.sub-toggle.on {
  background: var(--brand);
  border-color: var(--brand);
}
.sub-toggle.on .sub-toggle-knob {
  background: var(--brand-on);
  transform: translate(16px, -50%);
}
/* Увеличенная зона тапа (как у .plan-check). */
.sub-toggle::after { content: ""; position: absolute; inset: -9px; }
/* Название — на всю ширину линии, переносится (не режется суммой). */
.plan-text-input {
  /* flex-basis 0 (а не content): ширина берётся из доступного места, и одно
     длинное слово не раздувает поле и не выталкивает сумму за край блока. */
  flex: 1 1 0;
  min-width: 0;
  max-width: 100%;
  background: transparent;
  border: none;
  resize: none;
  min-height: auto;
  /* padding-left ≥2px: иначе overflow:hidden срезает левый bearing первой буквы
     названия (#8.13). */
  padding: 2px 2px;
  font: inherit;
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.25;
  outline: none;
  overflow: hidden;
  /* Длинное слово без пробелов переносится (а не уезжает вправо). */
  overflow-wrap: anywhere;
  word-break: break-word;
  field-sizing: content;
}
.plan-text-input::placeholder { color: var(--ink-3); font-weight: 400; }
.plan-text-input:focus {
  box-shadow: none;
  background: var(--surface-2);
  border-radius: var(--r-xs);
  padding-left: 6px; padding-right: 6px;
}
.plan-amount-wrap {
  flex: 0 0 auto;
  display: flex; align-items: baseline;
  gap: 4px; white-space: nowrap;
  margin-top: 1px;
}
.plan-amount-input {
  background: transparent;
  border: none;
  text-align: right;
  font-family: var(--font-numeric);
  font-weight: 600;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--ink);
  width: 92px;
  padding: 2px 0;
  min-height: auto;
}
.plan-amount-input:focus {
  background: var(--surface-2);
  border-radius: var(--r-xs);
  padding-left: 6px; padding-right: 6px;
}
.plan-amount-input::placeholder { color: var(--ink-3); }
.plan-amount-rub {
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--font-numeric);
}
.plan-del {
  width: 24px; height: 24px;
  flex: 0 0 auto;
  margin-top: 2px;
  background: transparent;
  border: none;
  border-radius: var(--r-pill);
  color: var(--ink-4);
  display: grid; place-items: center;
  padding: 0;
  position: relative;
}
.plan-del::after {
  content: "";
  position: absolute;
  inset: -8px;
}
.plan-del:hover { color: var(--expense-2); background: var(--expense-tint); }
.plan-del svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* Комментарий — скрыт пока пуст; виден, когда заполнен или строка в фокусе. */
.plan-note-input {
  display: block;
  margin-left: 32px;
  width: calc(100% - 32px);
  max-width: calc(100% - 32px);
  box-sizing: border-box;
  background: transparent;
  border: none;
  resize: none;
  min-height: auto;
  /* padding-left ≥2px: иначе overflow:hidden срезает левый bearing первой буквы
     комментария (#8.13). */
  padding: 2px 2px;
  font: inherit;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.25;
  outline: none;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
  field-sizing: content;
}
.plan-note-input::placeholder { color: var(--ink-3); }
.plan-note-input:focus {
  background: var(--surface-2);
  border-radius: var(--r-xs);
  padding-left: 6px; padding-right: 6px;
}
.plan-note-input:placeholder-shown { display: none; }
/* Пустое поле комментария показываем ТОЛЬКО когда строка в режиме правки
   названия/комментария — класс .note-open ставится из JS (focusin/focusout с
   проверкой relatedTarget), чтобы поле НЕ исчезало в момент клика по нему
   (иначе фокус названия теряется раньше, чем клик доходит). Не мигает при
   фокусе суммы/чипов. Непустой комментарий виден всегда (не placeholder-shown). */
.plan-row.note-open .plan-note-input,
.plan-note-input:focus { display: block; }

/* ── Линия 2: прогресс-бар во всю ширину + % · закрыто ── */
.plan-line2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 32px;
}
.plan-progress {
  flex: 1 1 auto;
  height: 6px;
  background: var(--rule);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.plan-progress-bar {
  height: 100%;
  width: 0;
  background: var(--income);
  border-radius: var(--r-pill);
  transition: width 0.3s var(--ease);
  min-width: 0;
}
.plan-progress-bar.full,
.plan-row.is-done .plan-progress-bar { background: var(--brand); }
.plan-closed-pct {
  flex: 0 0 auto;
  font-size: 11px;
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  color: var(--income-2);
}
.plan-closed-pct.full { color: var(--brand-2); }
.plan-closed-pct.zero { color: var(--ink-4); }
.plan-closed-lbl {
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--ink-4);
}
.plan-closed-input {
  flex: 0 0 auto;
  width: 64px;
  min-height: 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule-2);
  border-radius: 0;
  padding: 1px 2px;
  font-family: var(--font-numeric);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  color: var(--income-2);
  text-align: right;
}
.plan-closed-input:focus {
  border-bottom-color: var(--brand);
  background: var(--surface-2);
  outline: none;
}
.plan-closed-rub {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--ink-3);
  font-family: var(--font-numeric);
}
/* Долг/цель/план: «погашено/накоплено/закрыто N ₽» — тап-таблетка открывает
   лист пополнения (вместо инлайн-инпута). */
.prog-trig {
  flex: 0 0 auto;
  display: inline-flex; align-items: baseline; gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-pill);
  padding: 3px 9px;
  cursor: pointer;
  font: inherit;
  transition: border-color var(--mo-base) var(--mo-ease),
              background var(--mo-base) var(--mo-ease);
}
.prog-trig:hover { border-color: var(--brand); }
.prog-trig .plan-closed-lbl { font-size: 10px; color: var(--ink-4); }
.prog-trig .plan-closed-val {
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--income-2);
}

/* Лист «Пополнение» (долг/цель/план) */
.prog-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin: var(--sp-1) 0 var(--sp-4);
}
.prog-name { font-weight: 600; color: var(--ink); font-size: 15px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prog-remain { flex: 0 0 auto; font-size: 13px; color: var(--ink-3); }
.prog-remain b { color: var(--ink); font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums; font-weight: 700; }
.prog-mode { grid-template-columns: repeat(2, 1fr); margin-bottom: 14px; --seg-n: 2; }
.prog-mode button { padding: 8px 4px; min-height: 0; font-size: 13px; font-weight: 600; }
.prog-field { display: flex; align-items: stretch; gap: 10px; }
.prog-wrap {
  flex: 1 1 auto;
  display: flex; align-items: baseline; gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-md);
  padding: 10px 14px;
  margin-top: 0;
  transition: border-color var(--mo-base) var(--mo-ease);
}
.prog-wrap:focus-within { border-color: var(--rule-2); }
.prog-wrap .plan-amount-input {
  width: 100%; text-align: left; font-size: 18px; color: var(--ink);
}
/* Без неонового кольца/подсветки внутри — рамку рисует только .prog-wrap. */
.prog-wrap .plan-amount-input:focus {
  background: transparent; padding: 2px 0;
  box-shadow: none; border-color: transparent;
}
.prog-wrap .plan-amount-rub { font-size: 14px; }
.prog-allchip {
  flex: 0 0 auto;
  background: var(--surface-2);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-pill);
  padding: 8px 13px;
  font: inherit; font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color var(--mo-base) var(--mo-ease), color var(--mo-base) var(--mo-ease);
}
.prog-allchip:hover { border-color: var(--brand); color: var(--ink); }
/* Быстрые суммы (+шаг, кратно сумме) */
.prog-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.prog-chip {
  background: var(--surface-2);
  border: 1px solid var(--rule-2);
  border-radius: var(--r-pill);
  padding: 7px 14px;
  font: inherit; font-size: 13px;
  font-family: var(--font-numeric);
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color var(--mo-base) var(--mo-ease),
              color var(--mo-base) var(--mo-ease),
              background var(--mo-base) var(--mo-ease);
}
.prog-chip:hover { border-color: var(--brand); color: var(--ink); }
.prog-chip:active { background: var(--brand-tint); }
.plan-add {
  width: 100%;
  padding: 11px 12px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent;
  border: 1px dashed var(--rule-2);
  color: var(--ink-3);
  border-radius: var(--r-md);
  font: inherit; font-size: 13px;
  cursor: pointer;
  min-height: 44px;
}
.plan-add:hover { color: var(--ink); border-color: var(--brand); background: var(--brand-tint); }
.plan-add svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

/* «Скопировать прошлый месяц» — между KPI и карточками половин. */
.plan-copy-prev {
  width: 100%;
  margin-top: 14px;
  padding: 11px 12px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--brand);
  border-radius: var(--r-md);
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; min-height: 44px;
}
.plan-copy-prev svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.plan-copy-prev:hover { background: var(--brand-tint); }
.plan-copy-prev.emphasized { border-color: rgba(31, 191, 160, 0.40); }

/* Native checkbox styling for plan rows (future-proof / progressive enhancement) */
.plan-row input[type="checkbox"] {
  appearance: none;
  width: 22px;
  height: 22px;
  min-height: 22px;
  border: 2px solid var(--rule-2);
  border-radius: var(--r-sm);
  background: transparent;
  cursor: pointer;
  position: relative;
  flex: 0 0 auto;
  transition: all var(--dur-2) var(--ease);
}
.plan-row input[type="checkbox"]:checked {
  background: var(--brand);
  border-color: var(--brand);
}
.plan-row input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  inset: 2px;
  background: var(--brand-on);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3.5'%3E%3Cpath d='M4 12l5 5L20 6'/%3E%3C/svg%3E") no-repeat center / 80%;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3.5'%3E%3Cpath d='M4 12l5 5L20 6'/%3E%3C/svg%3E") no-repeat center / 80%;
}

/* =========================================================
   24. SETTINGS
   ========================================================= */
.settings-list {
  list-style: none;
  padding: 0; margin: 0;
  display: grid;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-xl);
  overflow: hidden;
}
.settings-list li { border-bottom: 1px solid var(--rule); }
.settings-list li:last-child { border-bottom: none; }
/* APK-паритет: плоские строки (Приватность/Управление/Данные) — без карточки и разделителей. */
.settings-list.flat {
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
}
.settings-list.flat li { border-bottom: none; }
.settings-list.flat .settings-row { padding-left: 4px; padding-right: 4px; }
.settings-row {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 1fr 18px;
  gap: 12px;
  align-items: center;
  padding: 8px 16px;
  background: transparent;
  border: none;
  border-radius: 0;
  font: inherit;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}
.settings-row:hover { background: var(--surface-2); }
.settings-row-icon {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: var(--r-md);
  background: var(--brand-tint);
  color: var(--brand);
}
.settings-row-icon svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.settings-row-text { display: grid; gap: 2px; min-width: 0; }
.settings-row-title { font-size: 15px; font-weight: 500; }
.settings-row-chev { width: 18px; height: 18px; stroke: var(--ink-3); fill: none; stroke-width: 2; }
.settings-row-danger .settings-row-icon {
  background: var(--expense-tint);
  color: var(--expense-2);
}
/* Профиль и бюджет в Настройках (паритет с прилой) */
.settings-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-xl);
  padding: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.settings-profile-info { flex: 1; min-width: 0; }
.settings-profile-name { font-size: 18px; font-weight: 700; color: var(--ink); }
.settings-profile-email { font-size: 13px; color: var(--ink-3); margin-top: 3px; }
/* Кнопка «Выйти» в карточке аккаунта (danger-тинт пилюля). */
.profile-logout-btn {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  background: var(--expense-tint);
  color: var(--expense-2);
  border: none;
  border-radius: var(--r-pill);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: background var(--dur-2) var(--ease);
}
.profile-logout-btn:hover { background: color-mix(in srgb, var(--danger) 22%, transparent); }
.profile-logout-btn svg {
  width: 16px; height: 16px;
  stroke: currentColor; fill: none; stroke-width: 1.8;
}
.settings-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-3);
  margin: 0 0 8px 4px;
}
/* Заголовок секции, идущий сразу за списком — отделяем сверху. */
.settings-list + .settings-section-label { margin-top: var(--sp-5); }
#settings-budget-list { margin-bottom: var(--sp-5); }
.settings-budget-row { grid-template-columns: 34px 1fr auto !important; }
.settings-budget-row .sb-role { font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.settings-budget-row .settings-row-icon { background: var(--surface-3); color: var(--ink-3); }
.settings-budget-row.active .settings-row-icon { background: var(--brand-tint); color: var(--brand); }
.settings-row-sub { font-size: 12.5px; color: var(--ink-3); line-height: 1.3; }
#settings-data-list { margin-bottom: var(--sp-5); }

/* ---- Приватность: скрытие сумм ---- */
/* Глаз в шапке Обзора — ненавязчивый icon-btn без фона. */
.hero-eye {
  margin-left: auto;
  width: 32px; height: 32px;
  color: var(--ink-3);
  background: transparent;
  border: none;
  flex: 0 0 auto;
}
.hero-eye:hover { color: var(--ink); background: var(--surface-2); }
.hero-eye svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.hero-eye.is-hidden { color: var(--brand); }
/* dela-badge не должен расталкивать глаз вправо: глаз сам уходит margin-left:auto */
.hero-lbl-row .delta-badge { margin-left: 8px; }

/* Строка-переключатель в Настройках (label вместо button). */
.settings-row-toggle { cursor: pointer; }
.switch {
  position: relative;
  display: inline-grid; place-items: center;
  width: 44px; height: 26px;
  flex: 0 0 auto;
}
.settings-row-toggle { grid-template-columns: 34px 1fr 44px; }
.switch-input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  margin: 0; opacity: 0; cursor: pointer;
  z-index: 1;
}
.switch-track {
  position: absolute; inset: 0;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--rule);
  transition: background var(--mo-fast) var(--mo-ease), border-color var(--mo-fast) var(--mo-ease);
}
.switch-thumb {
  position: absolute; top: 50%; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--ink);
  transform: translate(0, -50%);
  transition: transform var(--mo-fast) var(--mo-ease), background var(--mo-fast) var(--mo-ease);
}
.switch-input:checked ~ .switch-track {
  background: var(--brand);
  border-color: var(--brand);
}
.switch-input:checked ~ .switch-track .switch-thumb {
  transform: translate(18px, -50%);
  background: var(--brand-on);
}
.switch-input:focus-visible ~ .switch-track {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---- Совместный доступ (инвайты) ---- */
.share-body { padding: 16px 16px calc(28px + var(--safe-bottom)); overflow-y: auto; }
.share-budget { font-size: 13px; color: var(--ink-3); margin: 0 0 var(--sp-5); }
.share-section { margin-bottom: var(--sp-5); }
.share-h {
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  margin: 0 0 var(--sp-2);
}
.share-members { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.share-member {
  display: grid; grid-template-columns: 28px 1fr auto auto; align-items: center; gap: 10px;
  padding: 12px; background: var(--surface); border: 1px solid var(--rule);
  border-radius: var(--r-lg);
}
.share-member-act { display: grid; place-items: center; width: 32px; height: 32px;
  border: none; background: transparent; color: var(--ink-2); cursor: pointer;
  border-radius: var(--r-md); margin: -4px -6px -4px 0; }
.share-member-act:hover { background: var(--surface-3); }
.share-member-act svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.share-member-act.danger { color: var(--expense-2); }
.share-member-dot { width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: var(--bg); }
.share-member-name { font-size: 14px; font-weight: 500; color: var(--ink); min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-member-role { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.share-member-role.me { color: var(--brand); }

.share-gen-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 46px; }
.share-gen-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.share-codes { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.share-code {
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 6px;
  padding: 10px 8px 10px 14px; background: var(--surface-2);
  border: 1px solid var(--rule); border-radius: var(--r-lg);
}
.share-code-val { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 20px; font-weight: 700; letter-spacing: 2px; color: var(--brand); }
.share-code-act { display: grid; place-items: center; width: 36px; height: 36px;
  border: none; background: transparent; color: var(--ink-2); cursor: pointer; border-radius: var(--r-md); }
.share-code-act:hover { background: var(--surface-3); }
.share-code-act svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.share-code-act.danger { color: var(--expense-2); }
.share-hint { font-size: 11.5px; color: var(--ink-3); line-height: 1.5; margin: 12px 0 0; }

.share-code-input {
  width: 100%; min-height: 48px; padding: 0 14px;
  background: var(--surface-2); border: 1px solid var(--rule); border-radius: var(--r-lg);
  color: var(--ink); font-size: 18px; font-weight: 600; letter-spacing: 2px;
  text-transform: uppercase; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
.share-code-input:focus { outline: none; border-color: var(--brand); }
.share-code-input::placeholder { color: var(--ink-3); letter-spacing: 2px; }
.share-error { font-size: 12.5px; color: var(--expense-2); margin: 8px 0 0; }
.share-join-btn { width: 100%; min-height: 48px; margin-top: 12px; }

/* ---- Переименование бюджета ---- */
.rename-input {
  width: 100%; min-height: 48px; padding: 0 14px; margin: 0 0 4px;
  background: var(--surface-2); border: 1px solid var(--rule); border-radius: var(--r-lg);
  color: var(--ink); font-size: 16px; font-weight: 500;
}
.rename-input:focus { outline: none; border-color: var(--brand); }
.rename-input::placeholder { color: var(--ink-3); }
.sb-trail { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.sb-edit { display: grid; place-items: center; color: var(--ink-3); }
.sb-edit svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.settings-budget-row.active .sb-edit { color: var(--brand); }

/* ---- Импорт данных ---- */
.import-tile {
  display: grid; grid-template-columns: 40px 1fr; align-items: start; gap: 14px;
  width: 100%; text-align: left; padding: 16px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-xl);
  color: var(--ink); cursor: pointer; touch-action: manipulation;
}
.import-tile:hover { background: var(--surface-2); }
.import-tile-icon { display: grid; place-items: center; width: 40px; height: 40px;
  border-radius: var(--r-lg); background: var(--brand-tint); color: var(--brand); }
.import-tile-icon svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.import-tile-text { display: grid; gap: 4px; min-width: 0; }
.import-tile-title { font-size: 15px; font-weight: 600; }
.import-tile-sub { font-size: 12.5px; color: var(--ink-3); line-height: 1.4; }
.import-tile-sub.import-danger { color: var(--expense-2); }
.import-status { font-size: 13px; color: var(--ink-2); margin: 10px 0 0; padding: 0 4px; }

/* ---- Экспорт данных: объём ---- */
.export-scope { margin-bottom: 10px; }
.export-scope-hint { font-size: 12.5px; color: var(--ink-3); margin: 0 0 14px;
  padding: 0 4px; line-height: 1.4; }

/* ---- Резервные копии ---- */
.backup-note { font-size: 13px; color: var(--ink-2); margin: 0 0 14px;
  padding: 0 4px; line-height: 1.45; }
#backup-freq-wrap { margin-top: 12px; }
.backup-freq-label { font-size: 12px; font-weight: 600; color: var(--ink-2);
  margin: 0 0 8px; padding: 0 4px; }

/* ---- Поиск дубликатов ---- */
.dup-intro { font-size: 13px; color: var(--ink-2); margin: 0 0 8px;
  padding: 0 4px; line-height: 1.45; }
.dup-warn { font-size: 12.5px; color: var(--ink-2); line-height: 1.45;
  margin: 0 0 14px; padding: 10px 12px; border-radius: 10px;
  background: rgba(248, 81, 73, .12);
  border: 1px solid rgba(248, 81, 73, .28); }
.dup-empty { font-size: 15px; color: var(--ink-2); text-align: center;
  padding: 32px 0; }
.dup-group { background: var(--surface); border: 1px solid var(--rule);
  border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; }
.dup-group-head { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; margin-bottom: 8px; }
.dup-group-head-text { flex: 1 1 auto; min-width: 0; }
/* «Не дубли» — brand-tint пилюля: помечает группу как проверенную. */
.dup-approve-btn { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px; background: var(--brand-tint); color: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
  border-radius: var(--r-pill); font-size: 12px; font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: background var(--dur-2) var(--ease); }
.dup-approve-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.2; }
.dup-approve-btn:hover { background: color-mix(in srgb, var(--brand) 22%, transparent); }
.dup-approve-btn:disabled { opacity: .5; cursor: default; }
.dup-g-main { display: flex; align-items: baseline; gap: 10px; }
.dup-g-amt { font-weight: 700; font-size: 15px; }
.dup-g-amt.expense { color: var(--expense); }
.dup-g-amt.income { color: var(--income); }
.dup-g-cat { font-size: 14px; color: var(--ink); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dup-g-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.dup-op { display: flex; align-items: center; gap: 10px; padding: 7px 0;
  border-top: 1px solid var(--rule); cursor: pointer; }
.dup-op-cb { width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--expense);
  outline: none; border-radius: 4px; }
/* Гасим «странный прямоугольник» после галочки: глобальное input:focus даёт
   box-shadow-кольцо (--brand-tint) на любой сфокусированный инпут. Тут оно
   лишнее — состояние и так видно по галочке и подписи «удалить/оставить». */
.dup-op-cb:focus,
.dup-op-cb:focus-visible { box-shadow: none; outline: none; }
.dup-op-info { flex: 1 1 auto; font-size: 13px; color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dup-op-tag { flex: 0 0 auto; font-size: 11px; color: var(--ink-3); }
.dup-footer { padding: 12px 16px calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--rule); background: var(--surface); flex: 0 0 auto; }
.dup-footer .dup-delete { width: 100%; background: var(--expense); }
.dup-footer .dup-delete:disabled { opacity: .5; }
/* Прижатый футер: тело скроллится, шапка/футер фиксированы. */
#dup-sheet .sheet { display: flex; flex-direction: column; overflow: hidden; }
#dup-sheet .share-body { flex: 1 1 auto; }

/* =========================================================
   25. EMPTY + SKELETON
   ========================================================= */
.empty {
  padding: 32px 22px 28px;
  text-align: center;
  color: var(--ink-2);
  font-size: 14px;
  background: var(--surface);
  border: 1px dashed var(--rule-2);
  border-radius: var(--r-xl);
  display: grid;
  gap: 8px;
  justify-items: center;
}
.empty .empty-art {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  color: var(--ink-3);
  margin-bottom: 4px;
}
.empty .empty-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.empty .empty-sub {
  font-size: 13px;
  color: var(--ink-3);
  max-width: 280px;
  line-height: 1.5;
}
.empty .cta {
  margin-top: 8px;
  color: var(--brand-on);
  font-weight: 700;
  background: var(--brand);
  border: none;
  padding: 9px 16px;
  border-radius: var(--r-pill);
  font-size: 13px;
  box-shadow: var(--sh-edge-2);
}
.empty .cta:hover { filter: brightness(1.06); }

.skeleton {
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skel-text {
  display: inline-block;
  position: relative;
  color: transparent !important;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-xs);
  user-select: none;
  min-width: 64px;
}
.skel-text * { visibility: hidden; }
.skel-block {
  display: block;
  width: 100%;
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-md);
}

/* filter-bar (history) */
.filter-bar { display: flex; gap: 8px; margin-bottom: 10px; }
.filter-bar select { width: auto; flex: 1; }
.ana-head .filter-bar { margin: 0; }
.hist-period-nav { margin-bottom: 0; }

/* =========================================================
   26. TABLET / DESKTOP
   ========================================================= */
@media (min-width: 700px) and (max-width: 1023px) {
  main.tab {
    max-width: 560px;
    padding: 0 var(--page-px-lg) 32px;
    gap: 20px;
  }
}

@media (min-width: 1024px) {
  html, body { overflow-x: hidden; }
  #app {
    padding-left: 220px;
    padding-bottom: 0;
    grid-template-rows: 1fr;
  }
  .side-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 220px;
    padding: 24px 14px calc(20px + var(--safe-bottom));
    background: var(--bg-soft);
    border-right: 1px solid var(--rule);
    z-index: 30;
  }
  .side-nav-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 8px;
    margin-bottom: 22px;
  }
  .side-nav-mark {
    width: 36px; height: 36px;
    border-radius: var(--r-md);
    display: grid; place-items: center;
    background: var(--brand);
    color: var(--brand-on);
    font-family: var(--font-display);
    font-size: 19px; font-weight: 800;
    box-shadow: var(--sh-edge-2);
  }
  .side-nav-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.01em;
    color: var(--ink);
  }
  .side-nav-list {
    display: grid; gap: 4px;
    align-content: start;
    grid-auto-rows: min-content;
    flex: 1 1 auto;
    margin: 0; padding: 0;
  }
  .side-nav-item {
    width: 100%;
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px;
    min-height: 46px;
    background: transparent; border: none;
    color: var(--ink-2);
    border-radius: var(--r-md);
    font: inherit; font-size: 14px; font-weight: 500;
    text-align: left;
    cursor: pointer;
    position: relative;
    transition: background var(--dur-2) var(--ease),
                color var(--dur-2) var(--ease);
  }
  .side-nav-item:hover { background: var(--surface); color: var(--ink); }
  .side-nav-item:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
  }
  .side-nav-item.active {
    background: var(--brand-tint);
    color: var(--brand);
    font-weight: 700;
  }
  .side-nav-item.active::before {
    content: "";
    position: absolute;
    left: -14px; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 22px;
    border-radius: 999px;
    background: var(--brand);
  }
  .side-nav-item svg {
    width: 18px; height: 18px;
    stroke: currentColor; fill: none; stroke-width: 1.8;
    flex: 0 0 auto;
  }
  .side-nav-add {
    margin-top: 10px;
    width: 100%;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px;
    background: var(--brand);
    color: var(--brand-on);
    border: none;
    border-radius: var(--r-md);
    font: inherit; font-size: 14px; font-weight: 700;
    cursor: pointer;
    box-shadow: var(--sh-edge-2);
  }
  .side-nav-add:hover  { filter: brightness(1.06); }
  .side-nav-add svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2.4; }

  main.tab {
    margin: 0 auto;
    padding: 28px 32px 40px;
    max-width: 860px;
    gap: var(--sp-5);
  }
  main.tab > .page-head {
    padding-top: 0;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--rule);
    gap: 12px;
  }
  /* .ph-period-nav — внук .page-head, grid-area на него не действует;
     раскладываем .ph-nav flex'ом: сегмент слева, период справа. */
  main.tab > .page-head .ph-nav {
    display: flex;
    align-items: center;
    gap: 22px;
  }
  main.tab > .page-head .ph-period-nav { margin-left: auto; }
  main.tab > .page-head .ph-h1 { font-size: 28px; }
  #tab-dash > .add-cta { display: none; }
  .hero-amount .num { font-size: clamp(40px, 4vw, 56px); }
  #tab-analysis {
    grid-template-columns: 1fr 1fr;
    column-gap: 22px;
  }
  #tab-analysis > .page-head,
  #tab-analysis > .ana-hero { grid-column: 1 / -1; }
  /* Карточка не тянется на высоту соседа: короткая (доходы) не получает
     пустой провал внутри — ряд просто заканчивается раньше. */
  #tab-analysis > .ana-card { align-self: start; }
  /* Планирование на desktop: половины месяца рядом (KPI уже 3-в-ряд). */
  .plan-halves {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  /* hero Анализа: число и meta в один ряд — без воздуха справа */
  .ana-hero-headline {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "label  label"
      "amount meta";
    column-gap: 32px;
    align-items: baseline;
  }
  .ana-hero-headline .hero-lbl { grid-area: label; }
  .ana-hero-headline .hero-amount { grid-area: amount; }
  .ana-hero-headline .hero-meta {
    grid-area: meta;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    align-self: end;
  }
  .modal-scrim { align-items: center; }
  .sheet, #add-sheet .sheet, #settings-sheet .sheet {
    border-radius: var(--r-2xl);
    border: 1px solid var(--rule-2);
    margin: auto;
    padding-top: 18px;
    padding-bottom: 22px;
  }
  #add-sheet .sheet, #settings-sheet .sheet {
    border-top-left-radius: var(--r-2xl);
    border-top-right-radius: var(--r-2xl);
    border-bottom-left-radius: var(--r-2xl);
    border-bottom-right-radius: var(--r-2xl);
  }
  .sheet-full {
    height: auto;
    max-height: 88dvh;
    width: min(760px, calc(100vw - 48px));
    max-width: 760px;
    border-radius: var(--r-2xl);
    padding-top: calc(18px + var(--safe-top));
  }
  #cat-edit .sheet-full {
    width: min(820px, calc(100vw - 48px));
    max-width: 820px;
  }
  #cat-edit .cat-edit-preview {
    padding: 10px 0 14px;
  }
  #cat-edit .cat-edit-palette {
    grid-template-columns: repeat(10, 1fr);
  }
  #cat-edit .cat-edit-icons .cat-create-icons-grid {
    grid-template-columns: repeat(auto-fill, 72px);
    justify-content: start;
  }
  #cat-edit .cat-icon-tile {
    width: 72px;
  }
  .sheet > .grabber,
  #add-sheet .sheet > .grabber,
  #settings-sheet .sheet > .grabber { display: none; }
  .empty { max-width: 480px; margin-inline: auto; }
  .bottom-nav { display: none !important; }
}
@media (min-width: 1440px) {
  main.tab { max-width: 1000px; }
  /* Анализ остаётся в 2 колонки и на широких экранах — 3 колонки при
     max-width 1000px давали тесные карточки с наездом текста. */
}

/* =========================================================
   27. MOTION (View Transitions, fade-in)
   ========================================================= */
@keyframes tab-fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
main.tab > * { animation: tab-fade 240ms var(--ease) both; }
main.tab > *:nth-child(1) { animation-delay: 0ms; }
main.tab > *:nth-child(2) { animation-delay: 30ms; }
main.tab > *:nth-child(3) { animation-delay: 60ms; }
main.tab > *:nth-child(4) { animation-delay: 90ms; }
main.tab > *:nth-child(5) { animation-delay: 120ms; }

@supports (view-transition-name: none) {
  ::view-transition-old(root) {
    animation: vt-out 180ms var(--ease-press) both;
  }
  ::view-transition-new(root) {
    animation: vt-in 260ms var(--ease) both;
  }
  @keyframes vt-out { to { opacity: 0; } }
  @keyframes vt-in  { from { opacity: 0; transform: translateY(4px); } }
}

/* === SHIMMER SKELETON ============================================ */
.skel {
  background: var(--surface-2);
  border-radius: var(--r-sm);
  position: relative;
  overflow: hidden;
}
.skel::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg,
    transparent 0%, var(--surface-3) 50%, transparent 100%);
  transform: translateX(-100%);
  animation: skel-sweep 1300ms infinite;
}
/* Имя было «shimmer» и ПЕРЕБИВАЛО keyframes background-position у .skel-text/
   .skel-block (последнее определение выигрывает) → блоки уезжали за пределы.
   Переименовано в skel-sweep (этот sweep живёт в .skel::after с overflow:hidden). */
@keyframes skel-sweep { to { transform: translateX(100%); } }
/* Скелетон строк Истории — премиальная загрузка вместо резкого «выскакивания»
   строк на первой загрузке (#8.6/#8.7). Повторяет грид .tx-item. */
.tx-skel { pointer-events: none; cursor: default; }
.tx-skel-ic { width: 40px; height: 40px; border-radius: 50%; }
.tx-skel-meta { display: grid; gap: 7px; min-width: 0; align-content: center; }
.tx-skel-l1 { height: 12px; width: 62%; }
.tx-skel-l2 { height: 10px; width: 38%; }
.tx-skel-amt { height: 14px; width: 64px; justify-self: end; }

/* === STAGGERED REVEAL ============================================ */
.stagger {
  opacity: 0;
  animation: stagger-in var(--mo-layout) var(--mo-ease) forwards;
  animation-delay: min(calc(var(--index, 0) * 45ms), 360ms);
}
@keyframes stagger-in {
  from { opacity: 0; transform: translateY(6%); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   28. REDUCED MOTION + FORCED COLORS
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  *:hover, *:focus-visible {
    transform: none !important;
    filter: none !important;
  }
  ::view-transition-old(root),
  ::view-transition-new(root) { animation-duration: 1ms !important; }
  main.tab > * {
    animation: none !important;
    animation-delay: 0 !important;
  }
  .skel::after { animation: none; }
  .stagger { opacity: 1; animation: none; }
}

@media (forced-colors: active) {
  .kpi-grid, .hero, .ana-card, .plan-card, .login-card, .sheet,
  .settings-list, .add-cta {
    border: 1px solid CanvasText !important;
  }
  .delta, .chip.active, .range-segment button.active {
    forced-color-adjust: none;
  }
}

/* Режим повышенной контрастности: усиливаем хайрлайны — границы карточек,
   разделители и рамки полей становятся заметно ярче на тёмном фоне. */
@media (prefers-contrast: more) {
  :root {
    --rule:   #4a5566;
    --rule-2: #6b7787;
    --rule-3: #8b97a8;
  }
}

/* ======= Обзор: сегмент Сводка | Статистика + панели ======= */
.ov-seg { margin-top: 12px; }
/* Общий переключатель Расходы/Доходы — вплотную к сегменту Сводка/Статистика
   (это под-контрол). main.tab — grid с gap:20px, поэтому отрицательный
   margin-top гасит лишний зазор до ~8px между двумя сегментами. */
.ov-kind-segment { margin-top: -12px; }
/* min-width:0 по цепочке — длинный непереносимый контент (имя категории) НЕ
   раздувает ширину панели/списка; иначе центрированный по grid донат уезжает
   вбок, а карточки категорий вылезают за экран. Колонки grid с minmax(0,1fr)
   не растут по min-content. (БЕЗ overflow:clip — он бы обрезал карточки.) */
.ov-pane { animation: ov-in var(--mo-base) var(--mo-ease); min-width: 0; }
.ov-pane .section, .ov-pane .donut-wrap, .ov-pane .cat-list { min-width: 0; max-width: 100%; }
/* Отключённый сегмент «Статистика» (режим «День») — приглушён и без курсора. */
.seg-btn.is-disabled,
.seg-btn:disabled { opacity: 0.4; cursor: default; }
@keyframes ov-in {
  from { opacity: 0; transform: translateY(2%); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) { .ov-pane { animation: none; } }

/* Появление секций хаба Планов (Планы/Цели/Разовые/Регулярные) при
   переключении сегмента и первой загрузке — лёгкий fade+slide, как .ov-pane.
   Панели тогглятся через [hidden] (display:none→block) → анимация перезапускается. */
#plan-section-plans:not([hidden]), #plan-section-goals:not([hidden]),
#plan-section-onetime:not([hidden]), #plan-section-recurring:not([hidden]) {
  animation: ov-in var(--mo-base) var(--mo-ease);
}
@media (prefers-reduced-motion: reduce) {
  #plan-section-plans, #plan-section-goals,
  #plan-section-onetime, #plan-section-recurring { animation: none; }
}

/* === DONUT ======================================================= */
.donut-wrap { display: grid; place-items: center; padding: 8px 0 16px; }
.donut { position: relative; width: 168px; height: 168px; }
.donut svg { transform: rotate(-90deg); transform-origin: 84px 84px; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-total { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; }
/* Инлайн-операция в развороте категории/листе: 2 колонки (имя + сумма),
   без 32px-колонки иконки; дата-префикс приглушена (как Flutter). */
.tx-item.cat-op { grid-template-columns: 1fr auto; padding: 10px 0; gap: 10px; align-items: baseline; }
.tx-item.cat-op .amt { font-size: 13px; }
/* Уплотнённый список операций внутри карточки категории V2. */
.cat-acc-ops .tx-item.cat-op { padding: 7px 0; }
.cat-acc-ops .tx-item.cat-op .amt { font-size: 12px; font-weight: 600; }
.cat-acc-ops .cat-op-line { grid-template-columns: 54px auto minmax(0, 1fr); }
.cat-acc-ops .cat-op-date,
.cat-acc-ops .cat-op-sep,
.cat-acc-ops .cat-op-comment { font-size: 12px; }
.cat-acc-ops .cat-op-t { font-size: 9px; }
/* Дата — фикс-колонка (все даты «ДД.ММ.ГГ» одинаковой ширины), комментарий —
   гибкая колонка справа. */
.cat-op-line {
  display: grid;
  /* Дата — ФИКС-ширина (все «дд.мм.гг» одинаковы), «·» — отдельная колонка,
     комментарий — гибкая колонка. Так обе строки комментария при переносе
     начинаются одинаково (вторая не сдвигается под «·»). */
  grid-template-columns: 62px auto minmax(0, 1fr);
  column-gap: 6px;
  align-items: start;
}
.cat-op-date {
  display: flex;
  flex-direction: column;
  color: var(--ink-3);
  font-size: 13px;
  white-space: nowrap;
  /* Табличные (моноширинные) цифры — чтобы дата не «дышала» по ширине. */
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
.cat-op-t { font-size: 10px; color: var(--ink-3); line-height: 1.15; }
.cat-op-sep { color: var(--ink-3); font-size: 13px; }
.cat-op-comment { font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Если комментарий не влезает — ужимаем ТОЛЬКО его: 2 строки меньшим шрифтом
   (дата остаётся 13px). op-2l ставится замером в renderCatOps. */
.tx-item.cat-op.op-2l .cat-op-comment {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.25;
}
.donut-sub { font-size: 11px; color: var(--ink-3); margin-top: 2px; }

/* Лимит на месяц — компактное поле (не во всю ширину) в редакторе категории */
.limit-field {
  display: flex; align-items: center; gap: 8px;
  width: 200px; max-width: 100%;
  height: 44px; padding: 0 14px;
  background: var(--bg-soft);
  border: 1px solid var(--rule-2);
  border-radius: 10px;
  cursor: text;
  transition: border-color var(--mo-fast) var(--mo-ease);
}
.limit-field input {
  flex: 1 1 auto; min-width: 0;
  background: transparent; border: 0; outline: none;
  color: var(--ink); font: inherit; font-size: 15px; font-weight: 600;
  text-align: right; font-variant-numeric: tabular-nums;
}
.limit-field input::placeholder { color: var(--ink-3); font-weight: 500; text-align: left; }
.limit-field .cur { flex: 0 0 auto; color: var(--ink-3); font-size: 15px; font-weight: 600; }
.limit-field:focus-within { border-color: var(--brand); }

/* ===== DB-004: счета / валюты ===== */
/* В форме счёта поля Тип/Валюта/Цвет — не инпуты с рамкой, поэтому плавающая
   absolute-подпись из .sheet-op .op-field>label наезжает на контент. Делаем
   подписи обычными блочными (над содержимым). */
#account-form .op-field > label {
  position: static; transform: none; background: none;
  padding: 0; margin-bottom: var(--sp-2); display: block; left: auto; top: auto;
}
.account-form-body { padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto; flex: 1; }
.accounts-body { padding: 0 var(--sp-4, 16px); overflow-y: auto; flex: 1; }
.accounts-foot { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
.accounts-foot .primary { width: 100%; min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.accounts-foot .primary svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.4; }
.acc-free { display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--rule-2); border-radius: 14px;
  padding: 16px; margin: var(--sp-3) 0 var(--sp-5); }
.acc-free-label { font-size: 14px; color: var(--ink-3); font-weight: 600; }
.acc-free-value { font-size: 20px; font-weight: 800; color: var(--brand);
  font-variant-numeric: tabular-nums; white-space: nowrap; flex: 0 0 auto; }
.accounts-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.acc-card { display: flex; align-items: center; gap: 12px; background: var(--surface);
  border: 1px solid var(--rule-2); border-radius: var(--r-lg); padding: var(--sp-4); cursor: pointer;
  transition: background var(--mo-fast) var(--mo-ease), border-color var(--mo-fast) var(--mo-ease); }
.acc-card:hover { background: var(--surface-2); border-color: var(--rule-3); }
.acc-card-ic { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center;
  justify-content: center; background: color-mix(in srgb, var(--acc-color) 18%, transparent); }
.acc-card-ic svg { width: 22px; height: 22px; stroke: var(--acc-color); fill: none; stroke-width: 1.8; }
.acc-card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.acc-card-name { font-size: 15px; font-weight: 600; color: var(--ink); }
.acc-card-sub { font-size: 12px; color: var(--ink-3); }
.acc-tag { background: var(--surface-2); border-radius: 4px; padding: 1px 6px; font-size: 10px; }
.acc-card-bal { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
/* Перетаскивание порядка счетов (#8.11) — грип + состояние drag (как у курсов). */
.acc-card { touch-action: pan-y; }
.acc-grip { flex: 0 0 auto; width: 24px; height: 24px; color: var(--ink-3);
  display: flex; align-items: center; justify-content: center; cursor: grab; touch-action: none; }
.acc-grip svg { width: 22px; height: 22px; fill: currentColor; }
.acc-grip:active { cursor: grabbing; color: var(--brand); }
.acc-card.acc-dragging { position: relative; z-index: 10; opacity: .97;
  box-shadow: 0 8px 24px rgba(1,4,9,.45); }
.accounts-empty { text-align: center; color: var(--ink-3); padding: 40px 0; }
.acc-type-seg { display: flex; flex-wrap: wrap; gap: 8px; }
.acc-type-chip { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--rule-2);
  color: var(--ink-2); font-size: 13px; font-weight: 600; cursor: pointer; }
.acc-type-chip svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.acc-type-chip.active { background: var(--brand-tint); border-color: var(--brand-edge); color: var(--ink); }
.acc-type-chip.active svg { stroke: var(--brand); }
/* Тумблеры в форме счёта без иконки → 2 колонки (текст + переключатель). */
#account-form .settings-row-toggle { grid-template-columns: 1fr 44px; padding-left: 0; padding-right: 0; }
.acc-select { width: 100%; padding: 12px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--rule-2); color: var(--ink); font-size: 15px; }
/* Палитра цвета счёта — сетка 8 колонок (два полных ряда при 16 цветах). */
.acc-color-row { display: grid; grid-template-columns: repeat(8, 1fr); gap: 10px; }
.acc-color-dot { width: 100%; aspect-ratio: 1; max-width: 38px; justify-self: center;
  border-radius: 50%; border: 2.5px solid transparent; cursor: pointer; padding: 0; }
.acc-color-dot.active { border-color: var(--ink); }
/* Заголовок full-screen шапки — строго по центру (стрелка/крестик не смещают). */
.cat-picker-head { position: relative; }
.cat-picker-head .cat-picker-title { grid-column: 1 / -1; text-align: center; }
.cat-picker-head > button { z-index: 1; }
/* Свободные деньги — с поясняющей подписью. */
.acc-free-text { display: flex; flex-direction: column; gap: 2px; }
.acc-free-sub { font-size: 11px; color: var(--ink-3); font-weight: 400; }
/* Кнопка «Показать все иконки» в редакторе категории (ленивая загрузка). */
.cat-icons-more { width: 100%; margin-top: 12px; padding: 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--rule-2); color: var(--ink-2);
  font: inherit; font-weight: 600; cursor: pointer; }
.cat-icons-more:hover { background: var(--surface-3); }
/* Иконка перевода в строке операции — отдельный кружок (без .cat-icon::before). */
.tx-xfer-ic { display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-pill); background: var(--surface-2); flex: 0 0 auto; }
.tx-xfer-ic svg { width: 20px; height: 20px; stroke: var(--ink-2); fill: none; stroke-width: 1.8; }
.tx-item.transfer .amt { color: var(--ink); }
.tx-list { list-style: none; margin: 0; padding: 0; }
/* Операции страницы счёта — тот же свайп-layout, что и в Истории (#history-list
   стили заскоплены, дублируем для #account-page-ops). */
#account-page-ops .tx-item { display: flex; align-items: stretch; position: relative;
  overflow: hidden; padding: 0; background: transparent; touch-action: pan-y;
  -webkit-user-select: none; user-select: none; }
#account-page-ops .tx-surface { order: 0; flex: 1 1 auto; min-width: 0; display: grid;
  grid-template-columns: 48px minmax(0, 1fr) minmax(64px, auto); gap: 12px; align-items: center; padding: var(--sp-3) 0; overflow: hidden; }
#account-page-ops .tx-actions { order: 1; flex: 0 0 auto; width: 0; overflow: hidden;
  display: flex; align-items: stretch; transition: width 240ms cubic-bezier(0.22,1,0.36,1); }
#account-page-ops .tx-item.swipe-open .tx-actions { width: 168px; }
#account-page-ops .tx-item.tx-2acts.swipe-open .tx-actions { width: 112px; }
#account-page-ops .tx-item.swiping .tx-actions { transition: none; }
.cur-row { display: flex; align-items: center; gap: 12px; background: var(--surface);
  border: 1px solid var(--rule-2); border-radius: var(--r-lg); padding: var(--sp-4); margin-bottom: var(--sp-2); cursor: pointer;
  transition: background var(--mo-fast) var(--mo-ease), border-color var(--mo-fast) var(--mo-ease); }
.cur-row:hover { background: var(--surface-2); border-color: var(--rule-3); }
.cur-code { font-size: 15px; font-weight: 700; }
.cur-main { flex: 1; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.cur-val { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cur-val-empty { color: var(--ink-3); font-weight: 600; font-size: 15px; }
.cur-sub { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.currencies-updated { text-align: center; font-size: 12.5px; font-weight: 600;
  color: var(--ink-2); margin: 0 0 12px; }
.currencies-hint { font-size: 12px; color: var(--ink-3); margin: 12px 4px 16px; line-height: 1.45; }

/* Строка валюты в «Валюты и курсы»: drag-хэндл + код + курс + правка. */
.cur-row { gap: 10px; touch-action: pan-y; }
.cur-grip { flex: 0 0 auto; width: 24px; height: 24px; color: var(--ink-3);
  cursor: grab; touch-action: none; margin-left: -2px;
  display: inline-flex; align-items: center; justify-content: center; }
.cur-grip svg { width: 22px; height: 22px; fill: currentColor; }
.cur-grip:active { cursor: grabbing; color: var(--brand); }
.cur-row.cur-dragging { position: relative; z-index: 10; opacity: .97;
  background: var(--surface-2);
  box-shadow: 0 10px 28px rgba(0,0,0,.45);
  border-color: color-mix(in srgb, var(--brand) 50%, transparent);
  cursor: grabbing; }
.cur-acc-badge { display: inline-flex; align-items: center; margin-left: 7px;
  padding: 2px 7px; border-radius: 999px; font-size: 10px; font-weight: 700;
  background: var(--brand-tint); color: var(--brand); }
/* Карандаш — компактный индикатор «можно изменить курс» (вся строка тапабельна). */
.cur-edit-ic { flex: 0 0 auto; width: 18px; height: 18px;
  stroke: var(--ink-3); fill: none; stroke-width: 1.8; }
.cur-row:active .cur-edit-ic { stroke: var(--brand); }
/* Кнопка удаления отслеживаемой валюты из списка курсов. */
.cur-del-btn { flex: 0 0 auto; width: 30px; height: 30px; margin-left: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid var(--rule-2); background: var(--surface-2);
  color: var(--ink-2); cursor: pointer;
  transition: color var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease); }
.cur-del-btn svg { flex: 0 0 auto; width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.2; }
/* Зона действий (карандаш + ×) фикс-ширины → суммы выровнены в столбец у строк
   со счётом (без ×) и отслеживаемых (с ×). */
.cur-trail { flex: 0 0 auto; display: inline-flex; align-items: center;
  justify-content: flex-end; gap: 4px; width: 52px; }
.cur-del-btn:hover { color: var(--danger, #ff6b6b);
  border-color: color-mix(in srgb, var(--danger, #ff6b6b) 45%, transparent); }

/* CTA «Добавить валюту» под списком. */
.cur-add-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; margin-top: 10px; padding: 13px;
  background: var(--brand-tint); color: var(--brand);
  border: 1px dashed color-mix(in srgb, var(--brand) 38%, transparent);
  border-radius: 14px; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: background var(--dur-2) var(--ease);
}
.cur-add-btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; }
.cur-add-btn:hover { background: color-mix(in srgb, var(--brand) 20%, transparent); }

/* Кнопка «Вернуть курс ЦБ» в правке курса (только для ручного курса). */
.fx-reset-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; margin-top: 14px; padding: 11px;
  background: transparent; color: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand) 34%, transparent);
  border-radius: 12px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.fx-reset-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.fx-reset-btn:hover { background: var(--brand-tint); }
/* «Удалить из списка» в окне правки курса — контурная, в цвет опасного действия. */
.fx-delete-btn {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; margin-top: 8px; padding: 11px;
  background: transparent; color: var(--expense-2, #f87171);
  border: 1px solid color-mix(in srgb, var(--expense, #f85149) 40%, transparent);
  border-radius: 12px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.fx-delete-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.fx-delete-btn:hover { background: var(--expense-tint); }

/* Строка курса: слева код+название (растягивается), справа курс+подпись, карандаш. */
.cur-left { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cur-name { font-size: 11px; color: var(--ink-3); overflow: hidden;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.cur-row .cur-main { flex: 0 0 auto; }
.cur-row .cur-edit-ic { margin-left: 16px; }

/* Каталог валют ЦБ (пикер «Добавить валюту»). */
.cur-cat-searchwrap { margin: 6px 0 12px; }
.cur-cat-search { width: 100%; box-sizing: border-box; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--rule-2); border-radius: 12px;
  color: var(--ink-1); font: inherit; font-size: 14px; }
.cur-cat-search::placeholder { color: var(--ink-4); }
.cur-cat-list { list-style: none; margin: 0; padding: 0; }
.cur-cat-loading { color: var(--ink-3); font-size: 13px; text-align: center; padding: 24px 0; }
.cur-cat-row { display: flex; align-items: center; gap: 10px; padding: 13px 12px;
  border-radius: 12px; cursor: pointer; }
.cur-cat-row:hover { background: var(--surface-2); }
.cur-cat-row.active { background: var(--brand-tint); }
.cur-cat-code { font-size: 14px; font-weight: 700; flex: 0 0 auto; min-width: 64px; }
.cur-cat-name { flex: 1; min-width: 0; font-size: 13px; color: var(--ink-3);
  text-align: center; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical;
  -webkit-line-clamp: 2; line-clamp: 2; }
.cur-cat-code { min-width: 52px; }
.cur-cat-rate { font-size: 13px; font-weight: 600; color: var(--ink-2);
  font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.cur-cat-check { flex: 0 0 auto; width: 22px; height: 22px; display: inline-flex;
  align-items: center; justify-content: center; border-radius: 7px;
  border: 1.5px solid var(--rule-2); opacity: 0; transition: opacity var(--dur-2) var(--ease); }
.cur-cat-row.active .cur-cat-check { opacity: 1; background: var(--brand);
  border-color: var(--brand); }
.cur-cat-check svg { width: 14px; height: 14px; stroke: #04130a; fill: none; stroke-width: 2.6; }
.cur-cat-chev { flex: 0 0 auto; width: 18px; height: 18px; stroke: var(--ink-4); fill: none; stroke-width: 2; }

/* Sticky-кнопка «Сохранить» внизу каталога (выбор накапливается локально). */
.cur-cat-body { padding-bottom: 8px; }
.cur-cat-savebar { position: sticky; bottom: 0; z-index: 5;
  margin: 0 -18px; padding: 12px 18px calc(10px + var(--safe-bottom));
  background: linear-gradient(to top, var(--surface) 78%, transparent); }
.cur-cat-save { display: block; width: 100%; padding: 14px;
  border: none; border-radius: 14px; cursor: pointer;
  background: var(--brand); color: #04130a; font-size: 15px; font-weight: 700;
  transition: filter var(--dur-2) var(--ease); }
.cur-cat-save:hover { filter: brightness(1.06); }
.cur-cat-save:active { transform: translateY(1px); }

/* CTA «Добавить валюту» в пикере валют редактора счёта. */
.acc-pick-add { display: flex; align-items: center; justify-content: center; gap: 7px;
  margin-top: 8px; padding: 13px; border-radius: 12px; cursor: pointer;
  color: var(--brand); font-size: 14px; font-weight: 700;
  background: var(--brand-tint);
  border: 1px dashed color-mix(in srgb, var(--brand) 38%, transparent); }
.acc-pick-add svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; }
.acc-pick-add:hover { background: color-mix(in srgb, var(--brand) 20%, transparent); }

/* Кнопка «ЦБ» (устаревшая, в UI больше не используется — обновление серверное). */
.cbr-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 12px;
  background: var(--brand-tint); color: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
  border-radius: var(--r-pill);
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background var(--dur-2) var(--ease);
}
.cbr-btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.cbr-btn:hover { background: color-mix(in srgb, var(--brand) 22%, transparent); }
.cbr-btn:disabled { opacity: .5; cursor: default; }

/* ===== DB-004: пилл счёта + перевод в форме операции ===== */
.kind-toggle-3 { grid-template-columns: repeat(3, 1fr); }
/* mt:0 — над пилюлей уже 16px от .kind-toggle; mb:16 → равный отступ снизу. */
.op-account-pill { display: inline-flex; align-items: center; gap: 8px; margin: 0 auto 16px;
  padding: 7px 13px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--rule-2); color: var(--ink); font: inherit; font-size: 13px;
  font-weight: 600; cursor: pointer; }
.op-account-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); }
.op-account-pill .cat-trigger-chev { width: 18px; height: 18px; stroke: var(--ink-3); fill: none; stroke-width: 1.8; }
.op-account-pill.is-locked { cursor: default; }
.op-account-pill.is-locked .cat-trigger-chev { display: none; }
.acc-flow-card { display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 12px 13px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--rule-2); color: var(--ink); font: inherit; cursor: pointer; text-align: left; }
.acc-flow-ic { width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center;
  justify-content: center; background: var(--surface-2); --acc-color: var(--ink-3); }
.acc-flow-ic.acc-flow-ic-filled { background: color-mix(in srgb, var(--acc-color) 18%, transparent); }
.acc-flow-ic svg { width: 18px; height: 18px; stroke: var(--acc-color); fill: none; stroke-width: 1.8; }
.acc-flow-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.acc-flow-label { font-size: 11px; color: var(--ink-3); }
.acc-flow-name { font-size: 14px; font-weight: 600; }
.acc-flow-card .cat-trigger-chev { width: 18px; height: 18px; stroke: var(--ink-3); fill: none; stroke-width: 1.8; }
.transfer-arrow { display: flex; justify-content: center; padding: 4px 0; }
.transfer-arrow svg { width: 18px; height: 18px; stroke: var(--ink-4); fill: none; stroke-width: 2; }
.transfer-fx { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 10px 12px;
  border-radius: 10px; background: var(--bg-soft); border: 1px solid var(--rule-2); }
.transfer-fx input { flex: 0 0 110px; background: var(--surface-2); border: 1px solid var(--rule-2);
  border-radius: 8px; padding: 8px 10px; color: var(--ink); font: inherit; font-size: 14px; }
.transfer-fx-label { font-size: 12px; color: var(--ink-3); }
.op-fee-toggle { grid-template-columns: 1fr 44px; padding-left: 0; padding-right: 0; margin-top: 4px; }
.transfer-note { font-size: 11px; color: var(--ink-4); margin: 8px 2px 0; line-height: 1.5; }
.acc-pick-row { display: flex; align-items: center; gap: 12px; padding: var(--sp-3) 4px;
  border-radius: 10px; cursor: pointer; }
.acc-pick-row.active { background: var(--brand-tint); }
.acc-pick-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; }
.acc-pick-bal { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
#account-picker-list { list-style: none; margin: 0; padding: 0 12px; max-height: 50vh; overflow-y: auto; }

/* ===== DB-004: чипы счетов + тикер курсов на Обзоре ===== */
/* Симметричный отступ вокруг переключателя периода: верх (ph-nav gap 16) ≈ низ.
   main.tab gap(20)+page-head pad(4) давали снизу ~28 — компенсируем -8. */
.dash-accounts { margin: -8px 0 16px; }
.dash-accounts-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dash-accounts-title { font-size: 14px; font-weight: 700; color: var(--ink); }
.dash-accounts-all { display: inline-flex; align-items: center; gap: 2px; background: none; border: none;
  color: var(--brand); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; padding: 2px 4px; }
.dash-accounts-all svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
/* align-items: stretch — все плашки одной высоты (рублёвый без ≈-строки
   тянется до высоты валютных) (#5). */
.dash-chips { display: flex; align-items: stretch; gap: 9px; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch;
  /* Прячем горизонтальный скроллбар (мелькал полосой под «Счета» на десктопе/
     вебвью), скролл жестом/колесом остаётся. */
  scrollbar-width: none; }
.dash-chips::-webkit-scrollbar { display: none; }
/* Чипы счетов — ровно 3 помещаются по ширине (треть контейнера минус 2 зазора);
   при >3 счетах остальные доступны горизонтальным скроллом. Баланс ужимается JS. */
.dash-chip { flex: 0 0 calc((100% - 18px) / 3); width: calc((100% - 18px) / 3); box-sizing: border-box;
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 6px; padding: 11px 13px; border-radius: 14px; background: var(--surface);
  border: 1px solid var(--rule-2); color: var(--ink); font: inherit; cursor: pointer;
  text-align: left; overflow: hidden; }
.dash-chip.active { background: var(--brand-tint); border-color: var(--brand-edge); }
.dash-chip-skel { height: 64px; flex: 0 0 calc((100% - 18px) / 3); width: calc((100% - 18px) / 3); opacity: 0.5; pointer-events: none; }
.dash-chip-top { display: flex; align-items: center; gap: 6px; font-size: 12px;
  color: var(--ink-2); font-weight: 600; max-width: 100%; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis; }
.dash-chip-top > :not(.dash-chip-dot) { overflow: hidden; text-overflow: ellipsis; }
.dash-chip-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto;
  background: var(--acc-color, var(--ink-3)); }
/* Цветная иконка типа счёта вместо точки (#5). */
.dash-chip-ic { width: 14px; height: 14px; flex: 0 0 auto;
  stroke: var(--acc-color, var(--ink-3)); fill: none; stroke-width: 1.9; }
.dash-chip-bal { display: block; max-width: 100%; font-size: 16px; font-weight: 700;
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; }
/* solo-чип (без ≈): сумма заполняет оставшуюся высоту и центрируется по центру
   под названием — плашка одной высоты с валютными, без пустого низа (#5). */
.dash-chip-solo .dash-chip-bal { flex: 1 1 auto; display: flex; align-items: center;
  justify-content: center; width: 100%; text-align: center; }
.dash-chip-approx { display: block; margin-top: 2px; font-size: 11px; line-height: 14px;
  color: var(--ink-3); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }

/* Блок «Курсы»: плашки валют — как чипы счетов, но компактнее по высоте (задача 4). */
.dash-rates-head { margin-top: var(--sp-3); }
.dash-rate-chips { gap: 8px; }
.dash-rate-chip { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-start;
  gap: 3px; padding: 7px 12px; border-radius: var(--r-lg); background: var(--surface);
  border: 1px solid var(--rule-2); color: var(--ink); font: inherit; cursor: pointer;
  text-align: left; white-space: nowrap; }
.dash-rate-chip:active { background: var(--brand-tint); border-color: var(--brand-edge); }
.dash-rate-code { font-size: 11px; font-weight: 700; color: var(--ink-3); }
.dash-rate-val { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dash-ticker { display: flex; align-items: center; gap: 8px; width: 100%; margin-top: var(--sp-3);
  padding: 9px 12px; border-radius: 10px; background: var(--bg-soft); border: 1px solid var(--rule);
  color: var(--ink-2); font: inherit; font-size: 12px; cursor: pointer; font-variant-numeric: tabular-nums; }
.dash-ticker-rates { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.dash-ticker-chev { width: 16px; height: 16px; stroke: var(--ink-4); fill: none; stroke-width: 2; flex: 0 0 auto; }

/* ===== DB-004: страница счёта (герой + операции) ===== */
.acc-hero { border-radius: 18px; padding: 20px; margin: var(--sp-3) 0 var(--sp-5); }
.acc-hero-top { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; opacity: 0.92; }
.acc-hero-ic { width: 18px; height: 18px; fill: none; stroke-width: 1.8; }
.acc-hero-bal { font-size: 30px; font-weight: 800; margin-top: 8px; font-variant-numeric: tabular-nums; }
.acc-hero-approx { font-size: 13px; opacity: 0.85; margin-top: 2px; }
.acc-hero-flag { font-size: 12px; opacity: 0.85; margin-top: 4px; }
.acc-hero-actions { display: flex; gap: 3px; margin-top: 16px; }
/* Вертикальная раскладка (иконка над подписью) — все кнопки одинаковы независимо
   от длины подписи; паритет с Flutter (#8.8). Узкий зазор → кнопки шире, у
   «Коррекция» появляется воздух по бокам (#2). */
.acc-hero-actions button { flex: 1; display: inline-flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; text-align: center;
  padding: 10px 4px; border-radius: var(--r-md); border: none; cursor: pointer;
  font: inherit; font-size: 10.5px; line-height: 1.1;
  font-weight: 700; color: inherit; background: rgba(4, 19, 10, 0.16); }
.acc-hero-actions button svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; flex: 0 0 auto; }
.acc-op { display: flex; align-items: center; gap: 12px; padding: var(--sp-3) 2px; border-bottom: 1px solid var(--rule); cursor: default; }
.acc-op-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.acc-op-title { font-size: 14px; }
.acc-op-date { font-size: 11px; color: var(--ink-3); }
.acc-op-amt { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.acc-op-amt.pos { color: var(--income); }
.acc-op-amt.neg { color: var(--expense); }
#account-page-ops { list-style: none; margin: 0; padding: 0; }

/* ===== DB-004: брендовые модалки (валюта, курс) вместо нативных ===== */
.acc-currency-trigger { width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--rule-2);
  color: var(--ink); font: inherit; font-size: 15px; cursor: pointer; }
.acc-currency-trigger .cat-trigger-chev { width: 18px; height: 18px; stroke: var(--ink-3); fill: none; stroke-width: 1.8; }
.acc-currency-trigger.is-locked { opacity: .6; cursor: not-allowed; }
/* DB-005: лок категории при правке корректировки — гасим тап и прячем шеврон. */
#category-trigger.is-locked { opacity: .6; cursor: default; pointer-events: none; }
#category-trigger.is-locked .cat-trigger-chev { display: none; }
.acc-currency-lock { margin-top: 6px; font-size: 12px; color: var(--ink-3); }
.acc-pick-check { width: 18px; height: 18px; stroke: var(--brand); fill: none; stroke-width: 2.4; flex: 0 0 auto; }
#currency-picker-list { list-style: none; margin: 0; padding: 0 12px 8px; }
#currency-picker-list .acc-pick-row { justify-content: space-between; }
.confirm-btn.primary { background: var(--brand); color: var(--brand-on); font-weight: 700; }
.confirm-btn.primary:hover { filter: brightness(1.06); }
#fx-edit-sheet .field { margin-bottom: var(--sp-3); }
/* Модалку ввода курса — К ВЕРХУ (иначе прячется за клавиатурой). */
#fx-edit-sheet { align-items: flex-start; }
#fx-edit-sheet .sheet { margin: calc(24px + env(safe-area-inset-top)) auto 0; }
.cur-name { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.acc-pick-sub { font-size: 11px; color: var(--ink-3); }
.acc-pick-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }

/* Калькулятор суммы (MASTER-PLAN п.4). Токены темы, стандарт отступов ФинПульс. */
.op-input-wrap { position: relative; }
#amount.calc-on { padding-right: 52px; } /* место под иконку в режиме калькулятора */
.calc-trigger {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--surface-3); border: 1px solid var(--rule);
  color: var(--ink-3); display: flex; align-items: center; justify-content: center;
  padding: 0; cursor: pointer;
}
.calc-trigger[aria-pressed="true"] {
  background: var(--brand-tint); border-color: var(--brand-edge); color: var(--brand-2);
}
/* Сохранить центрирование при нажатии: глобальный button:active{transform:scale}
   иначе перебивает translateY(-50%) и иконка скачет вниз. */
.calc-trigger:active { transform: translateY(-50%) scale(0.94); }
.calc-exprbar {
  background: var(--surface); border: 1px solid var(--rule); border-radius: 14px;
  padding: 9px 14px; margin-top: 12px; display: flex; flex-direction: column; gap: 3px;
}
.calc-exprbar-lbl {
  font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3);
}
.calc-exprbar-txt {
  font-size: 17px; color: var(--ink); font-variant-numeric: tabular-nums;
  letter-spacing: .02em; line-height: 1.5; word-break: break-word; min-height: 1.5em;
}
.calc-panel {
  background: var(--bg-soft); border: 1px solid var(--rule); border-radius: 16px;
  padding: 10px; margin-top: 10px;
}
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.calc-key {
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--rule);
  border-radius: 11px; padding: 7px 0; font-size: 26px; line-height: 1; font-weight: 600;
  cursor: pointer; transition: background .12s;
}
.calc-key:hover { background: var(--surface-3); }
.calc-key.op { color: var(--brand-2); font-size: 30px; font-weight: 700; }
.calc-key.op:hover { background: var(--brand-tint); }
.calc-key.muted { color: var(--ink-3); font-weight: 700; }
.calc-key svg { display: block; margin: 0 auto; }

/* =================================================================
   PIN-замок приватности (PWA) — полноэкранный слой поверх всего.
   Дайлпад визуально консистентен с калькулятором суммы (.calc-key).
   ================================================================= */
.pin-lock {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  overflow-y: auto;
}
.pin-lock[hidden] { display: none; }
.pin-lock-inner {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.pin-mark {
  width: 56px; height: 56px;
  display: grid; place-items: center;
  margin-bottom: 18px;
}
.pin-mark img { width: 56px; height: 56px; display: block; }
.pin-title {
  font-size: 20px; font-weight: 700; color: var(--ink); margin: 0;
}
.pin-sub {
  font-size: 13px; color: var(--ink-3); margin: 6px 0 0;
}
.pin-pad-wrap { width: 100%; }
.pin-dots {
  display: flex; justify-content: center; gap: 16px;
  margin: 28px 0 14px;
}
.pin-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: transparent;
  border: 2px solid var(--ink-4);
  transition: background var(--mo-fast) var(--mo-ease), border-color var(--mo-fast) var(--mo-ease);
}
.pin-dot.filled {
  background: var(--brand);
  border-color: var(--brand);
}
.pin-error {
  font-size: 13px; color: var(--expense-2); min-height: 1.2em;
  margin: 0 0 10px;
}
.pin-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-width: 280px;
  margin: 0 auto;
}
.pin-key {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 16px;
  aspect-ratio: 1 / 1;
  font-size: 28px; font-weight: 600; line-height: 1;
  cursor: pointer;
  transition: background .12s, transform .06s;
  touch-action: manipulation;
}
.pin-key:hover { background: var(--surface-3); }
.pin-key:active { transform: scale(0.96); }
.pin-key:disabled { opacity: .4; cursor: default; }
.pin-key-muted { color: var(--ink-3); font-weight: 700; }
.pin-key-spacer { visibility: hidden; }
.pin-key:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
/* Шейк при неверном PIN */
.pin-dots.shake { animation: pin-shake .4s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes pin-shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}
@media (prefers-reduced-motion: reduce) {
  .pin-dots.shake { animation: none; }
}
/* Восстановление */
.pin-recovery { width: 100%; margin-top: 24px; }
.pin-recovery-hint {
  font-size: 13px; color: var(--ink-2); margin: 0 0 16px; line-height: 1.5;
}
.pin-recovery-hint span { color: var(--ink); font-weight: 600; }
.pin-recovery .lf { margin-bottom: 10px; }
.pin-recovery-btn { width: 100%; margin-top: 6px; }
/* Нижние ссылки */
.pin-foot {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  margin-top: 22px;
}
.pin-link {
  background: none; border: none; cursor: pointer;
  color: var(--brand); font: inherit; font-size: 14px; font-weight: 600;
  padding: 8px 12px; border-radius: 10px;
}
.pin-link:hover { background: var(--brand-tint); }
.pin-link[hidden] { display: none; }
/* Пока замок открыт — блокируем прокрутку фона */
body.pin-locked { overflow: hidden; }
#currency-picker-list .acc-pick-row { justify-content: flex-start; }

/* ==================================================================== */
/* Чеки: фото-вложения операции (Phase B3) — секция в op-sheet,          */
/* чип в Истории, фуллскрин-вьюер. Стили портированы из утверждённого    */
/* макета (scratchpad _B_mid / viewer_detail). Без × на миниатюрах.      */
/* ==================================================================== */
.op-receipts { margin-bottom: 12px; }
.op-receipts[hidden] { display: none; }
.op-receipts > label { display: block; margin-bottom: 7px; font-size: 12.5px; color: var(--ink-2); font-weight: 550; }
.op-receipts .rcpt-count { color: var(--ink-3); font-size: 11px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--rule-2); border-radius: var(--r-pill); padding: 1px 7px; margin-left: 6px; }
.op-receipts .rcpt-count[hidden] { display: none; }
.rcpt-strip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
.rcpt-add { width: 64px; height: 64px; border-radius: var(--r-lg); flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; background: var(--brand-tint); border: 1.5px dashed var(--brand-edge); color: var(--brand-2); cursor: pointer; }
.rcpt-add svg { width: 20px; height: 20px; }
.rcpt-add small { font-size: 9.5px; }
.rcpt-thumb { width: 64px; height: 64px; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--rule-2); flex: 0 0 auto; position: relative; background: var(--surface-2); cursor: pointer; padding: 0; }
.rcpt-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rcpt-thumb.loading { opacity: .6; }
.rcpt-thumb.loading::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.08) 50%, transparent 70%); background-size: 200% 100%; animation: rcpt-shimmer 1.1s linear infinite; }
@keyframes rcpt-shimmer { to { background-position: -200% 0; } }

/* Маркер «есть фото» в Истории — чип 📷N в подстроке (.sub) */
.tx-photobadge { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 650; color: var(--brand-deep); background: var(--brand-tint); border: 1px solid var(--brand-edge); border-radius: var(--r-pill); padding: 1px 6px 1px 5px; margin-right: 8px; align-self: center; }
.tx-photobadge svg { width: 11px; height: 11px; }
.tx-photobadge.sub-chip { margin-right: 6px; padding: 0 5px 0 4px; font-size: 10px; }

/* Фуллскрин-вьюер чека */
/* touch-action:none + overscroll: гасим нативные жесты браузера (pinch-зум
   страницы, свайп-скролл) — иначе на iOS position:fixed уезжает за визуальным
   вьюпортом и тапы попадают в форму ПОД фото. Зум/свайпы делаем сами в JS. */
.rcpt-viewer { position: fixed; inset: 0; z-index: 1200; background: #000; overflow: hidden; touch-action: none; overscroll-behavior: contain; -webkit-user-select: none; user-select: none; }
.rcpt-viewer[hidden] { display: none; }
.rv-photo { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #0a0c10; touch-action: none; }
.rv-photo img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; transition: transform .18s ease; transform-origin: center center; will-change: transform; }
.rv-photo.zoomed img,
.rv-photo.grabbing img { transition: none; }
.rv-top { position: absolute; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: center; gap: 10px; padding: max(14px, env(safe-area-inset-top)) 14px 26px; background: linear-gradient(rgba(0,0,0,.62), transparent); transition: opacity .2s; }
.rv-top.faded { opacity: 0; pointer-events: none; }
.rv-btn { width: 52px; height: 52px; border-radius: var(--r-pill); background: rgba(20,27,36,.62); border: 1px solid var(--rule-3); color: var(--ink); display: flex; align-items: center; justify-content: center; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); flex: 0 0 auto; cursor: pointer; }
.rv-btn svg { width: 26px; height: 26px; }
/* Корзина — НЕЙТРАЛЬНАЯ, белая как ×, НЕ красная (утв. дизайн) */
.rv-btn.rv-trash { color: var(--ink); }
/* Счётчик занимает середину и центрируется САМ (flex:1 + text-align), без
   margin:auto — иначе конфликт с margin-left:auto корзины сдвигал его влево. */
.rv-counter { flex: 1 1 auto; margin: 0; text-align: center; font-size: 14px; font-weight: 600; color: var(--ink); letter-spacing: .02em; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.rv-dots { position: absolute; bottom: max(46px, calc(env(safe-area-inset-bottom) + 40px)); left: 0; right: 0; z-index: 3; display: flex; gap: 7px; justify-content: center; transition: opacity .2s; }
/* Одиночный тап скрывает панель (кнопки + счётчик + точки). В зуме показанная
   панель остаётся на затемнённой градиент-полосе .rv-top — она и есть фон. */
.rcpt-viewer.controls-hidden .rv-top,
.rcpt-viewer.controls-hidden .rv-dots { opacity: 0; pointer-events: none; }
.rv-dots i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.32); }
.rv-dots i.on { background: var(--brand); width: 18px; border-radius: var(--r-pill); }
.rv-dots:empty { display: none; }
.rv-hint { position: absolute; bottom: max(18px, calc(env(safe-area-inset-bottom) + 12px)); left: 0; right: 0; z-index: 3; text-align: center; font-size: 11.5px; color: rgba(255,255,255,.5); transition: opacity .2s; }
.rv-hint.faded { opacity: 0; }
/* Подтверждение удаления */
.rv-scrim { position: absolute; inset: 0; z-index: 5; background: rgba(3,5,9,.72); display: flex; align-items: center; justify-content: center; padding: 22px; }
.rv-scrim[hidden] { display: none; }
.rv-confirm { width: 100%; max-width: 320px; background: var(--surface); border: 1px solid var(--rule-2); border-radius: var(--r-xl); padding: 20px 18px 16px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.6); }
.rv-confirm .rv-ic { width: 46px; height: 46px; border-radius: var(--r-pill); background: rgba(248,81,73,.14); border: 1px solid rgba(248,81,73,.35); color: var(--danger); display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; }
.rv-confirm .rv-ic svg { width: 22px; height: 22px; }
.rv-confirm h3 { font-size: 16px; margin: 0 0 5px; font-weight: 650; color: var(--ink); }
.rv-confirm p { font-size: 12.5px; color: var(--ink-3); margin: 0 0 16px; }
.rv-btns { display: flex; gap: 10px; }
.rv-btns button { flex: 1; padding: 11px; border-radius: var(--r-md); font-weight: 650; font-size: 14px; border: 1px solid var(--rule-2); background: var(--surface-2); color: var(--ink-2); cursor: pointer; }
/* Красный ТОЛЬКО на кнопке подтверждения «Удалить» */
.rv-btns button.del { background: var(--danger); border-color: var(--danger-deep); color: #fff; }

/* Лист выбора источника фото чека (камера / галерея) */
.rcpt-src-sheet { padding-bottom: calc(16px + var(--safe-bottom)); }
.rcpt-src-opt { display: flex; align-items: center; gap: 14px; width: 100%; padding: 13px 12px; margin-bottom: 10px; background: var(--surface-2); border: 1px solid var(--rule-2); border-radius: var(--r-lg); color: var(--ink); text-align: left; cursor: pointer; }
.rcpt-src-opt:active { border-color: var(--brand); }
.rcpt-src-ic { width: 44px; height: 44px; flex: 0 0 auto; border-radius: var(--r-pill); background: color-mix(in srgb, var(--brand) 14%, transparent); border: 1px solid var(--rule-3); color: var(--brand); display: flex; align-items: center; justify-content: center; }
.rcpt-src-ic svg { width: 22px; height: 22px; }
.rcpt-src-tx { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rcpt-src-tx b { font-size: 15px; font-weight: 650; color: var(--ink); }
.rcpt-src-tx small { font-size: 12px; color: var(--ink-3); }
.rcpt-src-cancel { width: 100%; padding: 12px; margin-top: 2px; border-radius: var(--r-md); background: transparent; border: 1px solid var(--rule-2); color: var(--ink-2); font-weight: 600; font-size: 14px; cursor: pointer; }
