/* ==========================================================================
   Walletrack — прототип MVP. Единый CSS без сборки.
   Mobile-first (360–430px) → планшет (≥600px) → десктоп (≥1024px, боковое меню).
   Темы: системная (prefers-color-scheme) + ручная: <html data-theme="light|dark">.
   Токены описаны в design/style-guide.md.
   ========================================================================== */

/* ---------- 1. Токены: светлая тема ---------- */
:root {
  color-scheme: light dark;

  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --surface-3: #e3e8ef;
  --border: #d5dbe3;
  --text: #141821;
  --text-muted: #566072;          /* 6.1:1 на --surface */
  --text-faint: #6b7385;          /* 4.7:1 — только для второстепенных подписей */

  --primary: #0f766e;             /* teal-700: 5.5:1 с белым */
  --primary-hover: #0b5f58;
  --primary-soft: #d6f2ee;
  --on-primary: #ffffff;

  --accent: #f59e0b;              /* акцент для FAB-ореола / выделений, не для текста */

  --success: #067647;  --success-soft: #dcfae6;
  --warning: #9a4a07;  --warning-soft: #fef0c7;
  --danger:  #b42318;  --danger-soft:  #fee4e2;
  --info:    #1d4ed8;  --info-soft:    #dbe7fe;

  /* бейджи источников */
  --src-receipt-bg: #fef0c7; --src-receipt-fg: #7a3a06;
  --src-bank-bg:    #dbe7fe; --src-bank-fg:    #1e3a8a;
  --src-manual-bg:  #eef1f5; --src-manual-fg:  #374151;

  --focus: #2563eb;
  --shadow-1: 0 1px 2px rgb(16 24 40 / .06), 0 1px 3px rgb(16 24 40 / .08);
  --shadow-2: 0 8px 24px rgb(16 24 40 / .14);
  --scrim: rgb(10 14 20 / .45);

  /* типографика */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --fs-xs: .75rem;   /* 12 */
  --fs-sm: .875rem;  /* 14 */
  --fs-md: 1rem;     /* 16 — минимум для input, чтобы iOS не зумил */
  --fs-lg: 1.125rem; /* 18 */
  --fs-xl: 1.375rem; /* 22 */
  --fs-2xl: 1.75rem; /* 28 */
  --fs-3xl: 2.25rem; /* 36 */

  /* отступы (шаг 4px) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;

  --r-sm: 8px; --r-md: 12px; --r-lg: 20px; --r-pill: 999px;
  --tap: 44px;                     /* минимальная зона касания */
  --appbar-h: 56px;
  --tabbar-h: 64px;
  --sidebar-w: 248px;
  --content-w: 640px;
}

/* ---------- 1b. Токены: тёмная тема ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116; --surface: #171b22; --surface-2: #1f252e; --surface-3: #2a313c; --border: #313946;
    --text: #e8ebf0; --text-muted: #a3adbb; --text-faint: #8d97a6;
    --primary: #2dd4bf; --primary-hover: #5eead4; --primary-soft: #0f3b38; --on-primary: #04201d;
    --success: #47cd89; --success-soft: #0d3320;
    --warning: #fdb022; --warning-soft: #3d2a06;
    --danger: #f97066;  --danger-soft: #4a1714;
    --info: #84adff;    --info-soft: #172554;
    --src-receipt-bg: #3d2a06; --src-receipt-fg: #fedf89;
    --src-bank-bg: #172554;    --src-bank-fg: #b2ccff;
    --src-manual-bg: #2a313c;  --src-manual-fg: #d0d5dd;
    --focus: #84adff;
    --shadow-1: 0 1px 2px rgb(0 0 0 / .4);
    --shadow-2: 0 8px 28px rgb(0 0 0 / .55);
    --scrim: rgb(0 0 0 / .6);
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116; --surface: #171b22; --surface-2: #1f252e; --surface-3: #2a313c; --border: #313946;
  --text: #e8ebf0; --text-muted: #a3adbb; --text-faint: #8d97a6;
  --primary: #2dd4bf; --primary-hover: #5eead4; --primary-soft: #0f3b38; --on-primary: #04201d;
  --success: #47cd89; --success-soft: #0d3320;
  --warning: #fdb022; --warning-soft: #3d2a06;
  --danger: #f97066;  --danger-soft: #4a1714;
  --info: #84adff;    --info-soft: #172554;
  --src-receipt-bg: #3d2a06; --src-receipt-fg: #fedf89;
  --src-bank-bg: #172554;    --src-bank-fg: #b2ccff;
  --src-manual-bg: #2a313c;  --src-manual-fg: #d0d5dd;
  --focus: #84adff;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-2: 0 8px 28px rgb(0 0 0 / .55);
  --scrim: rgb(0 0 0 / .6);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

/* ---------- 2. База ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s-4));
}
body.no-nav { padding-bottom: env(safe-area-inset-bottom); }
body.task  { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }

h1, h2, h3, h4 { margin: 0 0 var(--s-2); line-height: 1.25; font-weight: 650; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p  { margin: 0 0 var(--s-3); }
small, .small { font-size: var(--fs-sm); }
.muted { color: var(--text-muted); }
a { color: var(--primary); text-underline-offset: 2px; }
img, svg { max-width: 100%; }
svg { flex-shrink: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-4) 0; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -999px; top: 0; z-index: 100; background: var(--surface); padding: var(--s-2) var(--s-3); }
.skip-link:focus { left: var(--s-2); top: var(--s-2); }

/* Деньги: табличные цифры, без переноса */
.money, data.money { font-variant-numeric: tabular-nums; white-space: nowrap; }

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

/* ---------- 3. Каркас приложения ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s-2);
  min-height: calc(var(--appbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(var(--s-3), env(safe-area-inset-right)) 0 max(var(--s-3), env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
}
.appbar h1 { margin: 0; font-size: var(--fs-lg); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar__actions { display: flex; align-items: center; gap: var(--s-1); }

.content {
  width: 100%;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: var(--s-3) max(var(--s-4), env(safe-area-inset-right)) var(--s-5) max(var(--s-4), env(safe-area-inset-left));
}
.stack > * + * { margin-top: var(--s-4); }
.stack-sm > * + * { margin-top: var(--s-2); }
.row { display: flex; align-items: center; gap: var(--s-2); }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* Нижняя панель вкладок (мобайл) → боковое меню (десктоп) */
.tabbar {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.tabbar .tabbar__brand, .tabbar__add-label, .tabbar__footer { display: none; }
.tabbar ul { display: contents; list-style: none; margin: 0; padding: 0; }
.tabbar li { display: contents; }
.tabbar__link {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--tabbar-h); min-width: var(--tap);
  color: var(--text-muted); text-decoration: none; font-size: 11px; font-weight: 550;
}
.tabbar__link svg { width: 24px; height: 24px; }
.tabbar__link[aria-current="page"] { color: var(--primary); }
.tabbar__link[aria-current="page"] svg { stroke-width: 2.4; }
.tabbar__slot-fab { display: flex; justify-content: center; align-items: center; height: var(--tabbar-h); }

/* FAB «+» */
.fab {
  display: inline-grid; place-items: center;
  width: 60px; height: 60px; margin-top: -26px;
  border: 0; border-radius: 50%;
  background: var(--primary); color: var(--on-primary);
  box-shadow: 0 6px 16px rgb(15 118 110 / .35), 0 0 0 5px var(--bg);
  cursor: pointer;
  transition: transform .15s ease;
}
.fab:active { transform: scale(.94); }
.fab svg { width: 28px; height: 28px; }

body.task .tabbar { display: none; }

/* ---------- 4. Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: var(--tap); padding: 10px 18px;
  font: inherit; font-weight: 600; font-size: var(--fs-md); line-height: 1.2;
  border-radius: var(--r-md); border: 1px solid transparent;
  background: var(--surface-2); color: var(--text);
  text-decoration: none; cursor: pointer; user-select: none;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 20px; height: 20px; }
.btn--primary { background: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-hover); }
.btn--secondary { background: var(--surface); border-color: var(--border); }
.btn--secondary:hover { background: var(--surface-2); }
.btn--ghost { background: transparent; color: var(--primary); }
.btn--ghost:hover { background: var(--primary-soft); }
.btn--danger { background: var(--danger); color: #fff; }
:root[data-theme="dark"] .btn--danger { color: #2b0a07; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn--danger { color: #2b0a07; } }
.btn--danger-ghost { background: transparent; color: var(--danger); border-color: var(--border); }
.btn--block { display: flex; width: 100%; }
.btn--lg { min-height: 56px; font-size: var(--fs-lg); border-radius: var(--r-lg); }
.btn--sm { min-height: 36px; padding: 6px 12px; font-size: var(--fs-sm); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: var(--tap); height: var(--tap); padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--text);
  cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn[disabled] { color: var(--text-faint); opacity: .45; pointer-events: none; }

/* Липкая панель основного действия (формы на мобайле) */
.actionbar {
  position: fixed; z-index: 25; left: 0; right: 0; bottom: 0;
  display: flex; gap: var(--s-2);
  padding: var(--s-3) max(var(--s-4), env(safe-area-inset-right)) calc(var(--s-3) + env(safe-area-inset-bottom)) max(var(--s-4), env(safe-area-inset-left));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
}
.actionbar > .btn { flex: 1; }
.actionbar > .btn--secondary { flex: 0 0 auto; }

/* ---------- 5. Карточки, списки ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  box-shadow: var(--shadow-1);
}
.card--flush { padding: 0; overflow: hidden; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin-bottom: var(--s-3); }
.card__head h2 { margin: 0; font-size: var(--fs-md); }
.card__head a { font-size: var(--fs-sm); font-weight: 600; text-decoration: none; min-height: var(--tap); display: inline-flex; align-items: center; }

.section-title { font-size: var(--fs-sm); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: var(--s-5) 0 var(--s-2); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--border); }
.list-item {
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 56px; padding: var(--s-2) var(--s-4);
  color: inherit; text-decoration: none;
}
a.list-item:hover, button.list-item:hover { background: var(--surface-2); }
button.list-item { width: 100%; border: 0; background: transparent; font: inherit; text-align: left; cursor: pointer; }
.list-item__body { flex: 1; min-width: 0; }
.list-item__title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item__meta { font-size: var(--fs-sm); color: var(--text-muted); display: flex; flex-wrap: wrap; align-items: center; gap: 2px var(--s-2); }
.list-item__end { text-align: right; flex-shrink: 0; }
.chevron { color: var(--text-faint); width: 20px; height: 20px; }

/* ---------- 6. Категории ---------- */
/* Цвет категории передаётся инлайн: style="--c:#16a34a" */
.cat-icon {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 40px; height: 40px; border-radius: 12px;
  font-size: 20px; line-height: 1;
  background: color-mix(in srgb, var(--c, #64748b) 18%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c, #64748b) 35%, transparent);
}
.cat-icon--sm { width: 28px; height: 28px; border-radius: 8px; font-size: 15px; }
.cat-icon--none { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); color: var(--text-muted); font-weight: 700; }

.cat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 4px 12px 4px 6px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--c, #64748b) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c, #64748b) 40%, transparent);
  color: var(--text); font-size: var(--fs-sm); font-weight: 550; white-space: nowrap;
}
.cat-chip__emoji { font-size: 16px; line-height: 1; }
.cat-chip__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
button.cat-chip, a.cat-chip { cursor: pointer; text-decoration: none; min-height: 36px; font: inherit; font-size: var(--fs-sm); }

/* Сетка выбора категории (radio) */
.cat-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-2); border: 0; margin: 0; padding: 0; }
.cat-picker legend { font-weight: 600; margin-bottom: var(--s-2); padding: 0; }
.cat-option { position: relative; }
.cat-option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.cat-option label {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 4px;
  min-height: 76px; padding: var(--s-2) 2px;
  border-radius: var(--r-md); border: 1.5px solid var(--border); background: var(--surface);
  font-size: 11.5px; line-height: 1.2; text-align: center; cursor: pointer;
  hyphens: auto; overflow-wrap: anywhere;
}
.cat-option label .cat-icon { width: 36px; height: 36px; font-size: 19px; }
.cat-option input:checked + label {
  border-color: var(--c, var(--primary));
  background: color-mix(in srgb, var(--c, var(--primary)) 12%, var(--surface));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--c, var(--primary)) 45%, transparent);
  font-weight: 650;
}
.cat-option input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
.cat-picker--more .cat-option:nth-child(n+10):not(.cat-option--toggle) { display: none; }
/* :nth-child(n) lifts specificity above the hiding rule above (prototype bug: «Ещё…» did nothing). */
.cat-picker--more.is-expanded .cat-option:not(.cat-option--toggle):nth-child(n) { display: block; }
.cat-picker--more.is-expanded .cat-option--toggle { display: none; }
.cat-option--toggle button {
  width: 100%; min-height: 76px; border-radius: var(--r-md); border: 1.5px dashed var(--border); background: transparent;
  color: var(--text-muted); font: inherit; font-size: 12px; cursor: pointer;
}

/* ---------- 7. Бейджи ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; min-height: 20px;
  border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 650; line-height: 1.4;
  background: var(--surface-2); color: var(--text-muted); white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; }
.badge--receipt { background: var(--src-receipt-bg); color: var(--src-receipt-fg); }
.badge--bank    { background: var(--src-bank-bg);    color: var(--src-bank-fg); }
.badge--manual  { background: var(--src-manual-bg);  color: var(--src-manual-fg); }
.badge--ai      { background: var(--primary-soft); color: var(--primary); }
:root[data-theme="dark"] .badge--ai { color: var(--primary-hover); }
.badge--warn    { background: var(--warning-soft); color: var(--warning); }
.badge--danger  { background: var(--danger-soft); color: var(--danger); }
.badge--ok      { background: var(--success-soft); color: var(--success); }
.badge--muted   { background: var(--surface-2); color: var(--text-muted); }

/* ---------- 8. Формы ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field, .field + .row, .row + .field { margin-top: var(--s-4); }
.field > label, .label { font-weight: 600; font-size: var(--fs-sm); }
.field__hint { font-size: var(--fs-sm); color: var(--text-muted); }
.field__error { font-size: var(--fs-sm); color: var(--danger); font-weight: 550; display: flex; gap: 6px; align-items: flex-start; }
.optional { font-weight: 400; color: var(--text-muted); }

.input, .select, .textarea,
input:not([type]), input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="date"], input[type="number"], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px;
  font: inherit; font-size: var(--fs-md); color: var(--text);
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--r-md);
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
textarea { min-height: 88px; resize: vertical; }
select, .select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%23808a99' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
[aria-invalid="true"] { border-color: var(--danger) !important; }
[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent) !important; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }

.input-group { position: relative; display: flex; }
.input-group input { padding-right: 52px; }
.input-group .icon-btn { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); }

.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--text-muted); pointer-events: none; }
.search input { padding-left: 44px; border-radius: var(--r-pill); }

.check { display: flex; align-items: flex-start; gap: var(--s-3); min-height: var(--tap); padding: var(--s-2) 0; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--primary); flex-shrink: 0; }

/* Поле суммы с выбором валюты */
.amount-field {
  display: flex; align-items: stretch;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden;
}
.amount-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
.amount-field input {
  flex: 1; min-width: 0; border: 0 !important; box-shadow: none !important; background: transparent;
  font-size: var(--fs-3xl); font-weight: 700; min-height: 72px; padding: 8px 16px;
  font-variant-numeric: tabular-nums; text-align: right;
}
.amount-field select {
  width: auto; min-width: 104px; border: 0; border-left: 1px solid var(--border) !important; border-radius: 0;
  background-color: var(--surface-2); font-weight: 650; box-shadow: none !important;
}
.amount-field--sm input { font-size: var(--fs-lg); min-height: 48px; }
.amount-field--sm select { min-width: 88px; }
.amount-field[data-invalid] { border-color: var(--danger); }

/* Сегментированный переключатель (radio-группа): период, валюта, тема */
.segmented {
  display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  margin: 0; padding: 3px; border: 0; border-radius: var(--r-pill);
  background: var(--surface-2);
}
.segmented legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  display: grid; place-items: center;
  min-height: 38px; min-width: 44px; padding: 0 12px;
  border-radius: var(--r-pill); cursor: pointer;
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted);
}
.segmented input:checked + label { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.segmented input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 1px; }
.segmented--block { display: grid; width: 100%; }

.currency-switch label { padding: 0 8px; min-width: 44px; font-size: 13px; letter-spacing: .02em; }

.period-switch { display: flex; flex-direction: column; gap: var(--s-2); }
.period-nav { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.period-nav__label { font-weight: 650; font-size: var(--fs-lg); text-align: center; flex: 1; }

/* Горизонтально прокручиваемые фильтры-чипы */
.chips { display: flex; gap: var(--s-2); overflow-x: auto; padding: 2px 2px var(--s-1); scrollbar-width: none; margin: 0 calc(-1 * var(--s-4)); padding-inline: var(--s-4); }
.chips::-webkit-scrollbar { display: none; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
  min-height: 40px; padding: 0 14px; border-radius: var(--r-pill);
  background: var(--surface); border: 1.5px solid var(--border); color: var(--text);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.filter-chip svg { width: 16px; height: 16px; }
.filter-chip[aria-pressed="true"], .filter-chip.is-active { background: var(--primary-soft); border-color: var(--primary); color: var(--text); }

/* ---------- 9. Строка операции ---------- */
.tx-group__head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: var(--s-4) var(--s-1) var(--s-2); font-size: var(--fs-sm); color: var(--text-muted); font-weight: 600;
}
.tx {
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 64px; padding: var(--s-2) var(--s-4);
  color: inherit; text-decoration: none; background: var(--surface);
}
.tx:hover { background: var(--surface-2); }
.tx__body { flex: 1; min-width: 0; }
.tx__title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx__meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: var(--fs-sm); color: var(--text-muted); margin-top: 2px; }
.tx__amount { text-align: right; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; }
.tx__amount-main { font-weight: 650; font-variant-numeric: tabular-nums; }
.tx__amount-alt { font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.tx__amount-alt--warn { color: var(--warning); }
.tx--needs-cat .tx__title::after { content: ""; }
.tx--excluded { opacity: .62; }
.tx--excluded .tx__amount-main { text-decoration: line-through; }

/* ---------- 10. Дашборд: итог, диаграммы ---------- */
.total-card { display: flex; flex-direction: column; gap: var(--s-1); }
.total-card__label { color: var(--text-muted); font-size: var(--fs-sm); font-weight: 600; }
.total-card__value { font-size: 2.5rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; }
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); font-weight: 600; padding: 2px 10px; border-radius: var(--r-pill); width: fit-content; }
.delta svg { width: 14px; height: 14px; }
.delta--up { background: var(--warning-soft); color: var(--warning); }
.delta--down { background: var(--success-soft); color: var(--success); }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
.quick-action {
  display: flex; align-items: center; gap: var(--s-3);
  min-height: 64px; padding: var(--s-3) var(--s-4);
  border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none; font-weight: 650; box-shadow: var(--shadow-1);
}
.quick-action--primary { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.quick-action svg { width: 26px; height: 26px; }
.quick-action small { display: block; font-weight: 500; opacity: .85; font-size: var(--fs-xs); }

.donut-wrap { position: relative; width: 210px; max-width: 70%; margin: 0 auto var(--s-4); aspect-ratio: 1; }
.donut-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.donut-wrap circle { fill: none; stroke-width: 5.2; }
.donut-wrap .donut-track { stroke: var(--surface-2); }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center__label { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600; }
.donut-center__value { font-size: var(--fs-lg); font-weight: 750; }

.cat-breakdown .list-item { padding-inline: 0; }
.share-bar { height: 6px; border-radius: 3px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.share-bar > span { display: block; height: 100%; background: var(--c); border-radius: 3px; }

.bars { width: 100%; height: auto; display: block; }
.bars .bar { fill: var(--primary); }
.bars .bar--future { fill: var(--surface-3); }
.bars .bar--today { fill: var(--accent); }
.bars .axis { fill: var(--text-muted); font-size: 10px; font-family: var(--font); }
.bars .grid { stroke: var(--border); stroke-dasharray: 2 3; }
.bars .avg { stroke: var(--text-muted); stroke-dasharray: 4 3; stroke-width: 1; }
.bars .avg-label { fill: var(--text-muted); font-size: 10px; font-family: var(--font); }
.chart-legend { display: flex; gap: var(--s-4); flex-wrap: wrap; font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--s-2); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

/* ---------- 11. Уведомления, пустые состояния ---------- */
.alert {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  background: var(--info-soft); color: var(--text);
  border-left: 4px solid var(--info);
}
.alert > svg { width: 22px; height: 22px; color: var(--info); margin-top: 1px; }
.alert p:last-child { margin-bottom: 0; }
.alert__title { font-weight: 650; margin-bottom: 2px; }
.alert--warning { background: var(--warning-soft); border-color: var(--warning); }
.alert--warning > svg { color: var(--warning); }
.alert--error { background: var(--danger-soft); border-color: var(--danger); }
.alert--error > svg { color: var(--danger); }
.alert--success { background: var(--success-soft); border-color: var(--success); }
.alert--success > svg { color: var(--success); }
/* Overview: install hint and "photos will be deleted" banner above the period switch. */
#install-hint, #photos-expiring { margin-bottom: var(--s-3); }

.empty {
  text-align: center; padding: var(--s-7) var(--s-4);
  display: flex; flex-direction: column; align-items: center; gap: var(--s-2);
}
.empty__art { font-size: 56px; line-height: 1; margin-bottom: var(--s-2); }
.empty h2 { margin: 0; }
.empty p { color: var(--text-muted); max-width: 32ch; }
.empty .btn { min-width: 220px; }

.toast {
  position: fixed; z-index: 60; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s-4));
  max-width: min(92vw, 420px); padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md); background: var(--text); color: var(--bg);
  box-shadow: var(--shadow-2); font-size: var(--fs-sm); font-weight: 550;
  display: flex; align-items: center; gap: var(--s-3);
}
.toast a, .toast button { color: inherit; font-weight: 700; background: none; border: 0; font: inherit; text-decoration: underline; cursor: pointer; min-height: 32px; }

/* ---------- 12. Прогресс распознавания ---------- */
.progress { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: var(--primary); border-radius: 4px; transition: width .4s ease; }
.steps-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.steps-list li { display: flex; align-items: center; gap: var(--s-3); color: var(--text-muted); min-height: 32px; }
.steps-list li .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; flex-shrink: 0; }
.steps-list li.is-active { color: var(--text); font-weight: 600; }
.steps-list li.is-active .dot { border-color: var(--primary); border-top-color: transparent; animation: spin 0.9s linear infinite; }
.steps-list li.is-done { color: var(--text); }
.steps-list li.is-done .dot { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.steps-list li.is-done .dot svg { width: 14px; height: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

.receipt-thumb {
  position: relative; display: grid; place-items: center;
  border-radius: var(--r-md); overflow: hidden;
  background: repeating-linear-gradient(135deg, var(--surface-2) 0 10px, var(--surface-3) 10px 20px);
  color: var(--text-muted); border: 1px solid var(--border);
}
.receipt-thumb--scan::after {
  content: ""; position: absolute; left: 0; right: 0; height: 3px; top: 0;
  background: var(--primary); box-shadow: 0 0 12px var(--primary);
  animation: scan 1.8s ease-in-out infinite alternate;
}
@keyframes scan { to { top: calc(100% - 3px); } }

/* Большая зона «сфотографировать» */
.capture {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 220px; padding: var(--s-5);
  border-radius: var(--r-lg); border: 2px dashed color-mix(in srgb, var(--primary) 55%, var(--border));
  background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface));
  color: var(--text); text-align: center; cursor: pointer; position: relative;
}
.capture svg { width: 48px; height: 48px; color: var(--primary); }
.capture strong { font-size: var(--fs-lg); }
.capture input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.capture:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- 13. Позиции чека ---------- */
.line-items { list-style: none; margin: 0; padding: 0; }
.line-item { padding: var(--s-3) 0; border-top: 1px solid var(--border); display: grid; grid-template-columns: 1fr auto; gap: var(--s-2) var(--s-3); align-items: center; }
.line-item:first-child { border-top: 0; }
.line-item__name input { font-weight: 600; }
.line-item__qty { display: flex; gap: var(--s-2); align-items: center; font-size: var(--fs-sm); color: var(--text-muted); }
.line-item__qty input { width: 64px; min-height: 40px; padding: 6px 8px; text-align: right; }
.line-item__price input { width: 96px; min-height: 40px; padding: 6px 8px; text-align: right; font-variant-numeric: tabular-nums; }
.line-item__cat { grid-column: 1 / -1; display: flex; gap: var(--s-2); align-items: center; }
.line-item__cat select { min-height: 40px; padding-top: 6px; padding-bottom: 6px; font-size: var(--fs-sm); flex: 1; }
.line-item__total { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }

/* Позиции чека на узком экране: колонки сжимаются, поля переносятся (390 px без прокрутки) */
.line-items .line-item { grid-template-columns: minmax(0, 1fr) auto; }
.line-items .line-item__qty { flex-wrap: wrap; min-width: 0; }
.line-items .line-item__qty input { width: 56px; }
.line-items .line-item__price input { width: 76px; }
.line-items .line-item__cat select { min-width: 0; }
.line-item__total input { width: 92px; min-height: 40px; padding: 6px 8px; text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.line-item__discount { display: inline-flex; align-items: center; gap: 2px; color: var(--success); }
.line-item__discount input { width: 64px; min-height: 40px; padding: 6px 8px; text-align: right; }
.line-item--review { background: color-mix(in srgb, var(--warning-soft) 45%, transparent); border-radius: var(--r-sm); padding-inline: var(--s-2); }

/* Файлы чека: миниатюры фото и ссылка на PDF */
.receipt-files { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: var(--s-2); }
.receipt-files .receipt-thumb { width: 100%; text-decoration: none; cursor: zoom-in; }
.receipt-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.receipt-thumb--pdf { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-1); padding: var(--s-2); text-align: center; cursor: pointer; }
.capture.is-dragover { border-color: var(--primary); background: var(--primary-soft); }

/* «Уточните N позиций»: варианты категорий чипами-радиокнопками */
.review-item { border: 0; margin: 0; padding: var(--s-3) 0 var(--s-2); border-top: 1px solid var(--border); min-width: 0; }
.review-item legend { padding: 0; margin-bottom: var(--s-2); }
.choice-chips { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-2); }
.choice-chips .filter-chip { position: relative; white-space: normal; }
.choice-chips input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choice-chips .filter-chip:has(input:checked) { background: var(--primary-soft); border-color: var(--primary); }
.choice-chips .filter-chip:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

.sumcheck { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 600; }
.sumcheck--ok { background: var(--success-soft); color: var(--success); }
.sumcheck--bad { background: var(--warning-soft); color: var(--warning); }

/* ---------- 14. Таблицы (импорт, маппинг) ---------- */
.table-wrap { position: relative; overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-weight: 650; color: var(--text-muted); background: var(--surface-2); white-space: nowrap; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.csv-row--error td { background: var(--danger-soft); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* Список строк предпросмотра импорта (мобайл) */
.import-row { display: grid; grid-template-columns: auto 1fr auto; gap: 2px var(--s-3); align-items: start; padding: var(--s-3) var(--s-4); background: var(--surface); }
.import-row + .import-row { border-top: 1px solid var(--border); }
.import-row input[type="checkbox"] { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--primary); }
.import-row__desc { font-weight: 600; overflow-wrap: anywhere; }
.import-row__meta { grid-column: 2 / -1; display: flex; gap: var(--s-2); align-items: center; flex-wrap: wrap; font-size: var(--fs-sm); color: var(--text-muted); }
.import-row__meta select { width: auto; min-height: 36px; padding: 4px 36px 4px 10px; font-size: var(--fs-sm); background-position: right 8px center; }
.import-row--excluded .import-row__desc, .import-row--excluded .money { color: var(--text-muted); }
.import-row--dupe { background: color-mix(in srgb, var(--warning-soft) 55%, var(--surface)); }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
.stat { padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); }
.stat__value { font-size: var(--fs-xl); font-weight: 750; }
.stat__label { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600; }

/* Степпер мастера */
.stepper { display: flex; gap: var(--s-2); list-style: none; padding: 0; margin: 0 0 var(--s-4); counter-reset: st; }
.stepper li { flex: 1; font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600; counter-increment: st; }
.stepper li::before { content: ""; display: block; height: 4px; border-radius: 2px; background: var(--surface-3); margin-bottom: 6px; }
.stepper li[aria-current="step"], .stepper li.is-done { color: var(--text); }
.stepper li[aria-current="step"]::before, .stepper li.is-done::before { background: var(--primary); }

/* Выбор банка */
.choice-list { display: grid; gap: var(--s-2); }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; }
.choice label {
  display: flex; align-items: center; gap: var(--s-3); min-height: 68px; padding: var(--s-3) var(--s-4);
  border: 1.5px solid var(--border); border-radius: var(--r-lg); background: var(--surface); cursor: pointer;
}
.choice input:checked + label { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 40%, transparent); background: color-mix(in srgb, var(--primary-soft) 45%, var(--surface)); }
.choice input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
.bank-logo { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 14px; color: #fff; flex-shrink: 0; }

/* ---------- 15. Диалоги / bottom sheet ---------- */
dialog {
  border: 0; padding: 0; color: var(--text); background: var(--surface);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  width: min(92vw, 480px); max-height: 88dvh;
}
dialog::backdrop { background: var(--scrim); }
.dialog__body { padding: var(--s-5) var(--s-4) var(--s-4); }
.dialog__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin-bottom: var(--s-3); }
.dialog__head h2 { margin: 0; }
.dialog__actions { display: flex; gap: var(--s-2); justify-content: flex-end; margin-top: var(--s-5); flex-wrap: wrap; }
.dialog__actions .btn { flex: 1; }

/* Шторка снизу на мобайле */
dialog.sheet {
  margin: auto 0 0; width: 100%; max-width: 100%;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding-bottom: env(safe-area-inset-bottom);
}
dialog.sheet[open] { animation: sheet-up .22s ease-out; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } }
.sheet__grip { width: 40px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: var(--s-2) auto 0; }

.add-options { display: grid; gap: var(--s-2); list-style: none; padding: 0; margin: 0; }
.add-option {
  display: flex; align-items: center; gap: var(--s-4);
  min-height: 72px; padding: var(--s-3) var(--s-4);
  border-radius: var(--r-lg); background: var(--surface-2);
  color: var(--text); text-decoration: none;
}
.add-option:hover { background: var(--surface-3); }
.add-option__icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--surface); color: var(--primary); flex-shrink: 0; }
.add-option__icon svg { width: 26px; height: 26px; }
.add-option--primary { background: var(--primary); color: var(--on-primary); }
.add-option--primary:hover { background: var(--primary-hover); }
.add-option--primary .add-option__icon { background: rgb(255 255 255 / .18); color: var(--on-primary); }
.add-option strong { display: block; font-size: var(--fs-lg); }
.add-option small { display: block; opacity: .85; }
.add-option strong .badge { vertical-align: middle; margin-left: var(--s-1); }
.add-option--primary strong .badge { background: rgb(255 255 255 / .22); color: var(--on-primary); }

/* ---------- 16. Детали операции ---------- */
.detail-hero { text-align: center; padding: var(--s-4) 0 var(--s-2); }
.detail-hero .cat-icon { width: 64px; height: 64px; font-size: 32px; border-radius: 20px; margin-bottom: var(--s-3); }
.detail-hero__amount { font-size: var(--fs-3xl); font-weight: 750; letter-spacing: -.02em; }
.detail-hero__alt { color: var(--text-muted); font-size: var(--fs-sm); }
.detail-hero__alt--warn { color: var(--warning); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0; margin: 0; }
.kv dt, .kv dd { padding: var(--s-3) 0; border-top: 1px solid var(--border); margin: 0; }
.kv dt { color: var(--text-muted); font-size: var(--fs-sm); padding-right: var(--s-4); }
.kv dd { text-align: right; font-weight: 550; overflow-wrap: anywhere; }
.kv > :nth-child(1), .kv > :nth-child(2) { border-top: 0; }

.dupe-compare { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
.dupe-compare > div { padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); }
.dupe-compare strong { display: block; }

/* Цветовые образцы для категорий */
.swatches { display: flex; flex-wrap: wrap; gap: var(--s-2); border: 0; padding: 0; margin: 0; }
.swatches legend { font-weight: 600; font-size: var(--fs-sm); margin-bottom: var(--s-2); padding: 0; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; inset: 0; }
.swatch label { display: block; width: var(--tap); height: var(--tap); border-radius: 50%; background: var(--c); cursor: pointer; box-shadow: inset 0 0 0 2px rgb(0 0 0 / .1); }
.swatch input:checked + label { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--text); }
.swatch input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 4px; }
.emoji-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--s-1); }
.emoji-grid label { display: grid; place-items: center; height: var(--tap); border-radius: var(--r-sm); font-size: 22px; cursor: pointer; }
.emoji-grid input { position: absolute; opacity: 0; }
.emoji-grid input:checked + label { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }

/* ---------- 17. Панель состояний прототипа (не для продакшена) ---------- */
.proto-states {
  position: fixed; z-index: 70; left: max(8px, env(safe-area-inset-left));
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  font-size: 12px;
}
.proto-states summary {
  list-style: none; cursor: pointer; padding: 6px 10px; border-radius: var(--r-pill);
  background: #111827; color: #f9fafb; font-weight: 700; opacity: .82; min-height: 32px; display: flex; align-items: center;
}
.proto-states summary::-webkit-details-marker { display: none; }
.proto-states[open] summary { opacity: 1; }
.proto-states__menu { position: absolute; bottom: 100%; left: 0; margin-bottom: 6px; background: #111827; color: #f9fafb; border-radius: 12px; padding: 8px; display: grid; gap: 4px; min-width: 180px; box-shadow: var(--shadow-2); }
.proto-states__menu button, .proto-states__menu a { all: unset; cursor: pointer; padding: 8px 10px; border-radius: 8px; color: #f9fafb; }
.proto-states__menu button:hover, .proto-states__menu a:hover { background: #374151; }
.proto-states__menu button[aria-pressed="true"] { background: #0f766e; }

/* ---------- 18. Логин ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: max(var(--s-5), env(safe-area-inset-top)) var(--s-4) max(var(--s-5), env(safe-area-inset-bottom)); }
.auth__card { width: 100%; max-width: 400px; }
.brand { display: flex; align-items: center; gap: var(--s-3); font-weight: 800; font-size: var(--fs-xl); letter-spacing: -.01em; color: var(--text); text-decoration: none; }
.brand__mark { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); }
.brand__mark svg { width: 24px; height: 24px; }

/* ---------- 19. Карта экранов (index.html) ---------- */
.screen-grid { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.screen-card { display: flex; flex-direction: column; gap: var(--s-2); text-decoration: none; color: inherit; }
.screen-card h3 { margin: 0; display: flex; align-items: center; gap: var(--s-2); }
.screen-card ul { margin: 0; padding-left: 1.1em; font-size: var(--fs-sm); color: var(--text-muted); }

/* ---------- 20. Планшет ---------- */
@media (min-width: 600px) {
  :root { --content-w: 720px; }
  .cat-picker { grid-template-columns: repeat(5, 1fr); }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  dialog.sheet { margin: auto; width: min(92vw, 480px); border-radius: var(--r-lg); padding-bottom: 0; }
  .sheet__grip { display: none; }
  .quick-actions { display: none; } /* на планшете/десктопе хватает FAB/кнопки в меню */
}

/* ---------- 21. Десктоп: боковое меню ---------- */
@media (min-width: 1024px) {
  :root { --content-w: 1080px; }
  body, body.task { padding-bottom: var(--s-6); padding-left: var(--sidebar-w); }
  body.no-nav { padding-left: 0; }
  body.task .tabbar { display: flex; }
  .actionbar { position: static; background: transparent; border: 0; padding: var(--s-5) 0 0; backdrop-filter: none; -webkit-backdrop-filter: none; justify-content: flex-end; }
  .actionbar > .btn { flex: 0 0 auto; min-width: 180px; }
  body.task .content { max-width: 760px; }

  .tabbar {
    top: 0; right: auto; width: var(--sidebar-w); height: 100dvh;
    display: flex; flex-direction: column; align-items: stretch; gap: var(--s-1);
    padding: var(--s-5) var(--s-3);
    border-top: 0; border-right: 1px solid var(--border);
  }
  .tabbar .tabbar__brand { display: flex; padding: 0 var(--s-2) var(--s-5); }
  .tabbar ul { display: flex; flex-direction: column; gap: var(--s-1); }
  .tabbar li { display: block; }
  .tabbar__link { flex-direction: row; justify-content: flex-start; gap: var(--s-3); height: 44px; padding: 0 var(--s-3); border-radius: var(--r-md); font-size: var(--fs-md); }
  .tabbar__link:hover { background: var(--surface-2); color: var(--text); }
  .tabbar__link[aria-current="page"] { background: var(--primary-soft); color: var(--text); }
  .tabbar__link[aria-current="page"] svg { color: var(--primary); }
  .tabbar li.has-fab { order: -1; margin-bottom: var(--s-4); }
  .tabbar__slot-fab { height: auto; }
  .fab { width: 100%; height: 48px; margin: 0; border-radius: var(--r-md); grid-auto-flow: column; gap: var(--s-2); box-shadow: var(--shadow-1); font: inherit; font-weight: 650; }
  .fab svg { width: 22px; height: 22px; }
  .tabbar__add-label { display: inline; }
  .tabbar__footer { display: block; margin-top: auto; padding: var(--s-3); font-size: var(--fs-xs); color: var(--text-muted); }

  .appbar { padding-inline: var(--s-6); }
  .content { padding: var(--s-4) var(--s-6) var(--s-6); }
  .dash-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: var(--s-4); align-items: start; }
  .dash-grid > * + * { margin-top: 0 !important; }
  .dash-grid .span-2 { grid-column: 1 / -1; }
  .split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-5); align-items: start; }
  .split > * + * { margin-top: 0 !important; }
  .toast { bottom: var(--s-5); left: calc(50% + var(--sidebar-w) / 2); }
  .proto-states, body.task .proto-states { bottom: 12px; left: auto; right: 12px; }
  .proto-states__menu { left: auto; right: 0; }
  .cat-picker { grid-template-columns: repeat(7, 1fr); }
  .cat-picker--more .cat-option:nth-child(n+10):not(.cat-option--toggle) { display: block; }
  .cat-picker--more .cat-option--toggle { display: none; }
}

/* раскрывашка «Ещё N категорий» */
details.more > summary { list-style: none; margin-top: var(--s-2); }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] > summary { display: none; }
body.task .proto-states, body.no-nav .proto-states { bottom: calc(96px + env(safe-area-inset-bottom)); }
body.no-nav .proto-states { bottom: 12px; }
@media (max-width: 599px) { .hide-sm { display: none; } }

/* ---------- Operations list: filters sheet, "show more" (M4) ---------- */
.filters-sheet__group { border: 0; padding: 0; margin: var(--s-4) 0 0; }
.filters-sheet__summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; }
/* "Custom period" dates are shown only when the period select is set to "custom". */
.custom-range { display: none; border: 0; padding: 0; margin: var(--s-3) 0 0; }
.custom-range__dates { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); margin-top: var(--s-2); }
.custom-range__dates .field { margin: 0; }
.filters-sheet:has(#f-period option[value="custom"]:checked) .custom-range { display: block; }
.tx-more { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); margin-top: var(--s-4); }
.tx-more p { margin: 0; }
/* The row just saved or restored ("?hl=<id>"). */
.is-new > .tx { background: var(--primary-soft); }

/* ---------- Dashboard: period arrows, delta, charts (M5) ---------- */
/* "›" on the current period (and "‹" before year 2000) is a link without href. */
.icon-btn[aria-disabled="true"] { color: var(--text-faint); opacity: .45; pointer-events: none; }
.delta--same { background: var(--surface-2); color: var(--text-muted); }
.total-card a { color: inherit; }
.bars .bar--empty { fill: var(--surface-3); }
.bars .grid--base { stroke-dasharray: none; }
.chart-legend .legend-swatch { background: var(--primary); }
.chart-legend .legend-swatch--current { background: var(--accent); }
.chart-legend .legend-swatch--average { background: none; border-top: 2px dashed var(--text-muted); height: 0; border-radius: 0; }
.chart-summary { margin: var(--s-2) 0 0; }
.share-percent { min-width: 4ch; text-align: right; }
.top-merchants { padding: 0; }
.empty--period { padding: var(--s-5) var(--s-4); }

/* ---------- Правила (M7): строка списка — кнопка «изменить» + корзина ---------- */
.rule-edit {
  background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit;
  text-align: left; cursor: pointer; flex: 1; min-width: 0;
}
.rule-edit:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: var(--r-sm, 4px); }

/* Политика и условия (US-28) */
.legal h2 { font-size: var(--fs-lg); margin: var(--s-4) 0 var(--s-2); }
.legal h2:first-child { margin-top: 0; }
.legal ul { padding-left: 1.25em; margin: 0; }
.legal li + li { margin-top: var(--s-1); }
.legal-links a { color: inherit; }
