/* MyFinanceApp — дизайн F3 «Рублёвая нить».
   Спокойная графитовая база, один янтарный акцент (нить месяца), доход зелёный, долг/превышение красный.
   Все цвета — только через токены ниже. Тема: системная (prefers-color-scheme) или ручная (data-theme). */

/* ============ ШРИФТЫ ============
   Unbounded (крупные суммы) и Golos Text (текст) распространяются по лицензии SIL OFL.
   Файлы лежат локально в /static/vendor/fonts (работают офлайн и проходят CSP). */
@font-face { font-family: "Golos Text"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("vendor/fonts/GolosText-wght.ttf") format("truetype"); }
@font-face { font-family: "Unbounded"; font-style: normal; font-weight: 200 900; font-display: swap;
  src: url("vendor/fonts/Unbounded-wght.ttf") format("truetype"); }

/* ============ ТОКЕНЫ ============ */
:root {
  color-scheme: light;
  --bg: #EFF0EE;
  --surface: #FFFFFF;
  --surface-2: #F6F7F5;
  --ink: #16181B;
  --ink-2: #4A4F56;
  --ink-3: #62676E;
  --line: #DADCD8;
  --line-strong: #C3C6C1;
  --amber: #F0A92E;
  --amber-line: #B87A0B;
  --amber-ink: #875100;
  --on-amber: #1D1405;
  --bar: #3A3E44;
  --muted-bar: #8A8F95;
  --aug: #8E9297;
  --income: #1E6F4E;
  --income-soft: #E3F1EA;
  --expense: #A8322F;
  --expense-soft: #F7E1DF;
  --warn: #7A5410;
  --warn-soft: #F3ECDD;
  --focus: #1D5FD1;
  --scrim: rgba(20, 22, 25, .42);
  --shadow-sheet: 0 -1px 0 var(--line), 0 18px 48px rgba(20, 22, 25, .18);
  /* Категориальная палитра графиков «Аналитики»: приглушённые, различимые в обеих темах */
  --c1: #3A3E44; --c2: #B87A0B; --c3: #1E6F4E; --c4: #7A8FA8; --c5: #A8322F;
  --c6: #8C7A5B; --c7: #5E7F73; --c8: #7D8186; --c9: #6D5E80;

  --f-display: "Unbounded", "Golos Text", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --f-text: "Golos Text", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;

  --t-hero: clamp(2.25rem, 1.2rem + 3.6vw, 4rem);
  --t-kpi: 1.5rem;
  --t-h2: 1.0625rem;
  --t-body: .9375rem;
  --t-small: .8125rem;
  --t-xs: .6875rem;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --r-s: 6px; --r-m: 12px; --r-l: 16px;
  --r-inner: calc(var(--r-m) - 3px); /* сегменты внутри подложки с padding 3px */
  --t-meta: .75rem;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --d-press: 140ms; --d-micro: 200ms; --d-sheet: 420ms;
  --nav-h: 68px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #131416; --surface: #1B1C1F; --surface-2: #222327;
    --ink: #ECEDEE; --ink-2: #B7BBC1; --ink-3: #979CA3;
    --line: #2D2F33; --line-strong: #3D4045;
    --amber: #F2B24A; --amber-line: #F2B24A; --amber-ink: #F4BE62; --on-amber: #1D1405;
    --bar: #C9CCD1; --muted-bar: #7E838A; --aug: #767B81;
    --income: #62C79C; --income-soft: #17362A;
    --expense: #F08C85; --expense-soft: #3B1F1D;
    --warn: #E6C27A; --warn-soft: #302817;
    --focus: #7FA8F5;
    --scrim: rgba(0, 0, 0, .60); --shadow-sheet: 0 -1px 0 var(--line), 0 18px 48px rgba(0, 0, 0, .5);
    --c1: #C9CCD1; --c2: #F2B24A; --c3: #62C79C; --c4: #8FA6C2; --c5: #F08C85;
    --c6: #C4AE85; --c7: #7FA89A; --c8: #7E838A; --c9: #A493BD;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131416; --surface: #1B1C1F; --surface-2: #222327;
  --ink: #ECEDEE; --ink-2: #B7BBC1; --ink-3: #979CA3;
  --line: #2D2F33; --line-strong: #3D4045;
  --amber: #F2B24A; --amber-line: #F2B24A; --amber-ink: #F4BE62; --on-amber: #1D1405;
  --bar: #C9CCD1; --muted-bar: #7E838A; --aug: #767B81;
  --income: #62C79C; --income-soft: #17362A;
  --expense: #F08C85; --expense-soft: #3B1F1D;
  --warn: #E6C27A; --warn-soft: #302817;
  --focus: #7FA8F5;
  --scrim: rgba(0, 0, 0, .60); --shadow-sheet: 0 -1px 0 var(--line), 0 18px 48px rgba(0, 0, 0, .5);
  --c1: #C9CCD1; --c2: #F2B24A; --c3: #62C79C; --c4: #8FA6C2; --c5: #F08C85;
  --c6: #C4AE85; --c7: #7FA89A; --c8: #7E838A; --c9: #A493BD;
}

/* ============ БАЗА ============ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 var(--t-body)/1.5 var(--f-text); overflow-x: hidden; min-height: 100dvh; transition: background-color 240ms ease, color 240ms ease; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled { cursor: default; opacity: .45; }
a { color: inherit; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
.num { font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
[hidden] { display: none !important; }
.hidden { display: none !important; }
.vh { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-s); }
svg { display: block; }
.ico { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ico.s14 { width: 14px; height: 14px; }
.ico.s16 { width: 16px; height: 16px; }
.neg { color: var(--expense); }
.pos { color: var(--income); }
.muted-line { font-size: var(--t-small); color: var(--ink-3); margin: var(--s2) 0 0; }
.error { color: var(--expense); font-size: var(--t-small); font-weight: 600; min-height: 1em; }

/* ============ КНОПКИ ============ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s4); border-radius: var(--r-m); font-weight: 600; font-size: var(--t-small); letter-spacing: .005em; transition: transform var(--d-press) var(--ease-out), background-color var(--d-micro) ease, color var(--d-micro) ease, box-shadow var(--d-micro) ease; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn-amber { background: var(--amber); color: var(--on-amber); }
.btn-ink { background: var(--ink); color: var(--surface); }
.btn-line { color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn-ghost { color: var(--ink-2); padding: 0 var(--s3); }
.btn-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: var(--r-m); color: var(--ink-2); transition: background-color var(--d-micro) ease, transform var(--d-press) var(--ease-out); }
.btn-icon:active { transform: scale(.97); }
.btn-icon:disabled { opacity: .4; }
.link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; font-size: var(--t-small); color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 4px; border-radius: var(--r-s); }
@media (hover: hover) and (pointer: fine) {
  .btn-amber:hover { background: color-mix(in oklab, var(--amber) 86%, var(--ink)); }
  .btn-ink:hover { background: color-mix(in oklab, var(--ink) 86%, var(--surface)); }
  .btn-line:hover, .btn-icon:not(:disabled):hover, .btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
  .link:hover { text-decoration-thickness: 2px; }
}
/* Кнопки, которые рисует app.js в модалках и списках (старые классы, новый вид) */
button.primary { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s4); border-radius: var(--r-m); background: var(--ink); color: var(--surface); font-weight: 600; font-size: var(--t-small); transition: transform var(--d-press) var(--ease-out); }
button.primary:active, button.ghost:active, button.danger:active { transform: scale(.97); }
button.ghost { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 var(--s3); border-radius: var(--r-m); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); font-weight: 600; font-size: var(--t-small); }
button.danger { display: inline-flex; align-items: center; min-height: 44px; padding: 0 var(--s4); border-radius: var(--r-m); color: var(--expense); box-shadow: inset 0 0 0 1px var(--expense); font-weight: 600; font-size: var(--t-small); }
.mini-primary { min-height: 40px !important; padding: 0 var(--s3) !important; }
.mini-btn { display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 var(--s2); border-radius: var(--r-m); color: var(--ink-2); font-weight: 600; }
.mini-btn .icon, .icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) {
  button.ghost:hover, .mini-btn:hover { background: var(--surface-2); color: var(--ink); }
  .mini-btn.del:hover { color: var(--expense); }
}

/* ============ ШАПКА ============ */
.top { position: sticky; top: 0; z-index: 30; background: var(--bg); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1320px; margin: 0 auto; padding: 0 var(--s5); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 64px; gap: var(--s4); }
.brand { font-weight: 700; font-size: 1.0625rem; letter-spacing: -.01em; white-space: nowrap; margin: 0; }
.period { position: relative; display: flex; align-items: center; gap: var(--s1); }
.period-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 var(--s2); border-radius: var(--r-m); }
.period-btn .ico { color: var(--ink-3); }
.period-name { font-weight: 600; font-size: 1.0625rem; min-width: 9em; text-align: center; white-space: nowrap; }
@media (hover: hover) and (pointer: fine) { .period-btn:hover { background: var(--surface-2); } }
.seg { display: inline-flex; padding: 3px; border-radius: var(--r-m); background: var(--surface-2); margin-left: var(--s3); }
.seg button { min-height: 38px; padding: 0 var(--s3); border-radius: var(--r-inner); font-size: var(--t-small); font-weight: 500; color: var(--ink-2); transition: background-color var(--d-micro) ease, color var(--d-micro) ease; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: var(--s2); }
.sync { display: flex; align-items: center; gap: 6px; font-size: var(--t-small); color: var(--ink-3); margin-right: var(--s1); white-space: nowrap; }
.sync i, .msync i { width: 7px; height: 7px; border-radius: 50%; background: var(--income); flex: none; }
body.is-offline .sync i, body.is-offline .msync i { background: var(--warn); }
body.is-error .sync i, body.is-error .msync i { background: var(--expense); }
.topnav { max-width: 1320px; margin: 0 auto; padding: 0 var(--s5); display: flex; gap: var(--s1); }
.navtab { position: relative; display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s3); font-size: var(--t-small); font-weight: 500; color: var(--ink-2); text-decoration: none; border-radius: var(--r-s); }
.navtab[aria-current="page"] { color: var(--ink); font-weight: 600; }
.navtab[aria-current="page"]::after { content: ""; position: absolute; left: var(--s3); right: var(--s3); bottom: -1px; height: 2px; background: var(--ink); }
@media (hover: hover) and (pointer: fine) { .navtab:hover { color: var(--ink); } }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-s); background: var(--ink); color: var(--surface); font-size: var(--t-xs); font-weight: 700; display: inline-grid; place-items: center; }
.msync { display: none; }
.ask-s { display: none; }

/* поповер периода */
.period-pop { position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); z-index: 50; width: 340px; max-width: calc(100vw - 24px); background: var(--surface); border-radius: var(--r-l); box-shadow: var(--shadow-sheet), 0 0 0 1px var(--line); padding: var(--s3); }
.pp-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: var(--r-m); background: var(--surface-2); margin-bottom: var(--s3); }
.pp-tab { min-height: 38px; border-radius: var(--r-inner); font-size: var(--t-small); font-weight: 500; color: var(--ink-2); }
.pp-tab.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.pp-month { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; max-height: 320px; overflow: auto; }
.pp-month-item { min-height: 40px; padding: 0 var(--s3); border-radius: var(--r-s); text-align: left; font-size: var(--t-small); }
.pp-month-item.active { background: var(--ink); color: var(--surface); font-weight: 600; }
.pp-cal-head { display: flex; align-items: center; justify-content: space-between; }
.pp-cal-title { font-size: var(--t-small); font-weight: 600; text-align: center; }
.pp-cal-wrap { display: grid; gap: var(--s3); max-height: 360px; overflow: auto; }
.pp-cal-name { font-size: var(--t-small); font-weight: 600; margin: var(--s2) 0 var(--s1); }
.pp-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.pp-wd { font-size: var(--t-xs); color: var(--ink-3); text-align: center; padding: 2px 0; }
.pp-day { min-height: 36px; border-radius: var(--r-s); font-size: var(--t-small); font-variant-numeric: tabular-nums; }
.pp-day.in-range { background: var(--surface-2); }
.pp-day.sel { background: var(--ink); color: var(--surface); font-weight: 600; }
@media (hover: hover) and (pointer: fine) { .pp-day:not(.empty):not(.sel):hover, .pp-month-item:not(.active):hover { background: var(--surface-2); } }
.pp-range-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-top: var(--s3); }
.pp-range-foot .muted-line { margin: 0; }

/* полосы состояния */
.banner { max-width: 1320px; margin: var(--s4) auto 0; padding: 0 var(--s5); }
.banner-in { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); padding: var(--s3) var(--s4); border-radius: var(--r-m); font-size: var(--t-small); }
.banner-in strong { font-weight: 600; }
.banner.err .banner-in { background: var(--expense-soft); color: var(--ink); }
.banner.err .banner-in strong { color: var(--expense); }
.banner.off .banner-in { background: var(--warn-soft); color: var(--ink); }
.banner.off .banner-in strong { color: var(--warn); display: inline-flex; align-items: center; gap: 6px; }
.spacer { flex: 1; }
.session { max-width: 1320px; margin: var(--s4) auto 0; padding: 0 var(--s5); }
.session-in { background: var(--surface-2); border-radius: var(--r-m); padding: var(--s4) var(--s5); display: flex; flex-wrap: wrap; gap: var(--s3) var(--s5); align-items: end; box-shadow: inset 0 0 0 1px var(--line); }
.session-in p { margin: 0; flex: 1 1 260px; font-size: var(--t-small); color: var(--ink-2); }
.session-in b { display: block; font-size: var(--t-body); color: var(--ink); }
.session-in label { display: flex; flex-direction: column; gap: 6px; font-size: var(--t-small); color: var(--ink-2); }
.session-in .input { min-height: 44px; min-width: 220px; background: var(--surface); }
.session-in .error { flex-basis: 100%; }

/* ============ СЕТКА ============ */
main { max-width: 1320px; margin: 0 auto; padding: var(--s5) var(--s5) 96px; }
.cols { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: var(--s5); align-items: start; }
.col-a, .col-b { display: grid; gap: var(--s5); min-width: 0; }
.view-h { margin: 0 0 var(--s5); }
.view-h h1 { margin: 0; font: 500 1.75rem/1.15 var(--f-display); letter-spacing: -.03em; }
.view-h .muted-line { margin-top: var(--s2); }
.stack { display: grid; gap: var(--s5); }

.panel { background: var(--surface); border-radius: var(--r-l); padding: var(--s5); min-width: 0; }
.panel-h { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); flex-wrap: wrap; }
.panel-h h2 { margin: 0; font-size: var(--t-h2); font-weight: 600; letter-spacing: -.01em; }
.panel-h .sub { font-size: var(--t-small); color: var(--ink-3); }
.panel-note { font-size: var(--t-small); color: var(--ink-2); margin: calc(var(--s3) * -1) 0 var(--s4); }
.panel-foot { display: flex; justify-content: flex-end; align-items: center; margin-top: var(--s2); gap: var(--s3); }
.head-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.empty-note { padding: var(--s3) 0; font-size: var(--t-small); color: var(--ink-3); }

/* ===== ДЕНЬГИ СЕЙЧАС ===== */
.hero { padding: var(--s6) var(--s6) var(--s5); display: grid; grid-template-columns: minmax(max-content, 1.25fr) minmax(0, 1fr); gap: var(--s5); }
.hero-left { display: flex; flex-direction: column; justify-content: flex-start; min-width: 0; }
.hero-label { font-size: var(--t-small); color: var(--ink-2); margin: 0 0 var(--s2); }
.hero-sum { font: 500 var(--t-hero)/1 var(--f-display); letter-spacing: -.035em; margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hero-sum.neg { color: var(--expense); }
.hero-sum .kop { font-size: .42em; letter-spacing: -.01em; color: var(--ink-3); vertical-align: .95em; margin-left: .06em; }
.hero-sum .cur { font-size: .5em; color: var(--amber-ink); margin-left: .12em; letter-spacing: 0; }
.hero-delta { display: inline-block; margin-top: var(--s3); font-size: var(--t-small); font-weight: 600; color: var(--income); }
.hero-delta.minus { color: var(--expense); }
.hero-lines { margin: var(--s6) 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.hero-lines li { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); min-height: 52px; padding: var(--s2) 0; border-bottom: 1px solid var(--line); font-size: var(--t-small); color: var(--ink-2); }
.hero-lines li:last-child { border-bottom: 0; }
.hero-lines .num { color: var(--ink); font-weight: 600; font-size: var(--t-body); }
.hero-lines .debt .num { color: var(--expense); }
.accts-h { display: flex; justify-content: space-between; align-items: center; font-size: var(--t-small); color: var(--ink-3); min-height: 44px; margin-top: -10px; }
.accts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.acct { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name sum" "meta meta"; align-items: baseline; column-gap: var(--s3); padding: var(--s2) 0; border-top: 1px solid var(--line); min-height: 52px; align-content: center; }
.acct-btn { position: absolute; inset: 0; border-radius: var(--r-s); }
/* Название счёта целиком: переносим на вторую строку, а не режем многоточием. */
.acct-name { grid-area: name; font-weight: 600; font-size: .875rem; line-height: 1.3; min-width: 0; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.acct-meta { grid-area: meta; display: block; color: var(--ink-3); font-weight: 400; font-size: var(--t-meta); line-height: 1.35; min-width: 0; }
.acct-sum { grid-area: sum; font-weight: 600; font-size: 1rem; text-align: right; }
.acct-sum.neg { color: var(--expense); }
.acct.debt { border-top: 1px solid var(--line-strong); grid-template-areas: "name sum" "meta meta" "lim lim"; padding-bottom: var(--s3); }
.acct.debt .acct-sum { color: var(--expense); }
.limit { grid-area: lim; height: 4px; border-radius: 2px; background: var(--surface-2); position: relative; overflow: hidden; margin-top: 6px; }
.limit i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--expense); border-radius: 2px; }
.acct.all { display: none; }
@media (hover: hover) and (pointer: fine) { .acct-btn:hover { background: color-mix(in oklab, var(--surface-2) 60%, transparent); } }
#recon:empty { display: none; }
#recon { margin-top: var(--s3); padding: var(--s3); border-radius: var(--r-m); background: var(--warn-soft); font-size: var(--t-small); }
#recon .muted-line { margin: 0 0 var(--s1); color: var(--warn); font-weight: 600; }
.recon-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.recon-main { display: flex; flex: 1; justify-content: space-between; gap: var(--s2); }
.recon-clear { min-width: 36px; height: 36px; }

/* ===== ИТОГ МЕСЯЦА ===== */
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); margin: 0 0 var(--s5); }
.trio > div { min-width: 0; }
.trio dt { font-size: var(--t-small); color: var(--ink-2); margin-bottom: var(--s1); }
.trio dd { margin: 0; font-weight: 700; font-size: var(--t-kpi); letter-spacing: -.02em; line-height: 1.15; }
.trio dd .kp { font-weight: 600; color: var(--ink-3); font-size: .72em; }
.trio .inc { color: var(--income); }
.trio .inc .kp { color: inherit; opacity: .8; }
.trio dd.neg { color: var(--expense); }
.trio small { display: block; margin-top: var(--s1); font-size: var(--t-meta); color: var(--ink-3); line-height: 1.35; }
.pace-say { font-size: var(--t-body); margin: 0 0 var(--s1); max-width: 62ch; }
.pace-say b, .pace-fc b { font-weight: 600; }
.pace-say .dim { color: var(--ink-3); }
.pace-fc { font-size: var(--t-small); color: var(--ink-2); margin: 0; display: flex; align-items: center; gap: var(--s1); min-height: 20px; }
.pace-fc > span { min-width: 0; }
.tip { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-m); color: var(--ink-3); margin: -4px 0; }
.tip[aria-expanded="true"] { color: var(--ink); background: var(--surface-2); }
.fc-why { margin: 0 0 var(--s2); padding: var(--s2) var(--s3); border-radius: var(--r-m); background: var(--surface-2); font-size: var(--t-small); color: var(--ink-2); }
.chart-pace { position: relative; height: 240px; margin: var(--s2) 0 0; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); font-size: var(--t-meta); color: var(--ink-2); margin-top: var(--s3); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 18px; height: 0; border-top: 2.5px solid; }
.lg.sep { border-color: var(--amber-line); border-top-width: 3px; }
.lg.aug { border-color: var(--aug); border-top-width: 2px; }
.lg.fc { border-top-style: dashed; border-color: var(--amber-line); }
.lg.box { width: 10px; height: 10px; border: 0; border-radius: 2px; }
.avg { margin-left: auto; color: var(--ink-3); font-size: var(--t-small); }

/* ===== ПРОВЕРИТЬ ===== */
.review .panel-h { margin-bottom: var(--s1); }
.review-note { font-size: var(--t-small); color: var(--ink-2); margin: 0 0 var(--s3); }
.bulk { display: flex; align-items: center; justify-content: space-between; gap: var(--s2) var(--s3); flex-wrap: wrap; padding: var(--s3) var(--s4); border-radius: var(--r-m); background: var(--surface-2); font-size: var(--t-small); color: var(--ink-2); margin-bottom: var(--s3); }
.bulk .btn { background: var(--surface); }
.cands { list-style: none; margin: 0; padding: 0; }
.cand { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 200ms var(--ease-out); }
.cand > .cand-in { min-height: 0; overflow: hidden; transition: opacity 200ms ease, transform 200ms var(--ease-out); }
.cand.leaving > .cand-in { opacity: 0; transform: translateX(16px); }
.cand.gone { grid-template-rows: 0fr; }
.cand-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "who amt" "meta meta" "tags acts"; gap: 2px var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--line); align-items: center; }
.cand-name { grid-area: who; font-weight: 600; font-size: var(--t-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cand-sum { grid-area: amt; font-weight: 600; font-size: 1rem; text-align: right; }
.cand-sum.plus { color: var(--income); }
.cand-meta { grid-area: meta; font-size: var(--t-meta); color: var(--ink-3); }
.cand-tags { grid-area: tags; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; min-width: 0; }
.cand-act { grid-area: acts; display: flex; align-items: center; justify-content: flex-end; gap: var(--s1); margin-top: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; min-height: 24px; padding: 2px var(--s2); border-radius: var(--r-s); font-size: var(--t-xs); font-weight: 600; background: var(--surface-2); color: var(--ink-2); line-height: 1.3; }
.tag.ok { background: var(--income-soft); color: var(--income); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.dup { background: var(--expense-soft); color: var(--expense); }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); min-width: 180px; background: var(--surface); border-radius: var(--r-m); box-shadow: var(--shadow-sheet), 0 0 0 1px var(--line); padding: 6px; z-index: 20; transform-origin: top right; opacity: 0; transform: scale(.96); pointer-events: none; visibility: hidden; transition: opacity 120ms ease, transform 120ms var(--ease-out), visibility 0s 120ms; }
.menu.open { opacity: 1; transform: scale(1); pointer-events: auto; visibility: visible; transition: opacity 160ms ease, transform 160ms var(--ease-out), visibility 0s; }
.menu button { display: flex; width: 100%; min-height: 44px; align-items: center; padding: 0 var(--s3); border-radius: var(--r-s); font-size: var(--t-small); text-align: left; }
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); }
.review-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); border-top: 1px solid var(--line); padding-top: var(--s2); flex-wrap: wrap; min-height: 45px; }
.more-btn { display: none; }
.review-all { margin-left: auto; }
.rv-empty { display: none; padding: var(--s4) 0 var(--s2); align-items: flex-start; gap: var(--s3); }
.rv-empty .em-ico { width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; color: var(--income); flex: none; }
.rv-empty p { margin: 0; }
.rv-empty .big { font-weight: 600; font-size: var(--t-body); }
.rv-empty .sm { font-size: var(--t-small); color: var(--ink-3); margin-top: 2px; }
.review.is-empty .rv-empty { display: flex; }
.review.is-empty .cands, .review.is-empty .review-note, .review.is-empty .bulk, .review.is-empty .review-foot, .review.is-empty .panel-h .sub { display: none; }
body.loading .review .rv-empty, body.loading .review-all { display: none !important; }

/* ===== СКОРО СПИШЕТСЯ ===== */
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin: 0 0 var(--s3); list-style: none; padding: 0; }
.day { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 2px; padding: var(--s2) 2px; border-radius: var(--r-m); background: var(--surface-2); min-width: 0; min-height: 76px; }
.day .wd { font-size: var(--t-xs); color: var(--ink-3); }
.day .dn { font-weight: 700; font-size: 17px; line-height: 1.2; }
.day .mk { font-size: var(--t-xs); color: var(--ink-2); white-space: nowrap; display: inline-flex; align-items: center; gap: 3px; }
.day.empty-d .dn { color: var(--ink-3); font-weight: 600; }
.day.inc .mk { color: var(--income); font-weight: 600; }
.day.cr .mk { font-weight: 600; color: var(--ink); }
.day.cr .mk i { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--ink); }
.day.m-end::after { content: ""; position: absolute; right: -4px; top: 4px; bottom: 4px; width: 2px; background: var(--ink); border-radius: 1px; }
.bills { list-style: none; margin: 0; padding: 0; }
.bill { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: var(--s3); align-items: center; padding: var(--s2) 0; border-top: 1px solid var(--line); min-height: 52px; }
.bill-d { font-size: var(--t-small); color: var(--ink-3); }
.bill-n { font-weight: 600; font-size: .875rem; line-height: 1.3; min-width: 0; }
.bill-n small { display: block; font-weight: 400; color: var(--ink-3); font-size: var(--t-meta); }
.bill-s { font-weight: 600; text-align: right; }
.bill-s.plus { color: var(--income); }
.cr-mark { display: inline-flex; align-items: center; height: 26px; padding: 0 var(--s2); border-radius: var(--r-s); box-shadow: inset 0 0 0 1px var(--ink); font-size: var(--t-meta); font-weight: 600; color: var(--ink); white-space: nowrap; }

/* ===== БЮДЖЕТЫ ===== */
.budgets { list-style: none; margin: 0; padding: 22px 0 0; position: relative; }
.budgets.no-tl { padding-top: 0; }
.bud { padding: var(--s2) 0 var(--s4); }
.bud-top, .bud-bot { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: var(--s3); align-items: baseline; font-size: var(--t-small); }
.bud-top > span, .bud-bot > span { background: var(--surface); padding: 0 2px; }
.bud-top > span:first-child, .bud-bot > span:first-child { margin-left: -2px; }
.bud-top > span:last-child { margin-right: -2px; }
.bud-name { font-weight: 600; font-size: .875rem; display: inline-flex; align-items: center; gap: 6px; }
.bud-name .ico { width: 16px; height: 16px; color: var(--expense); }
.bud-of { color: var(--ink-2); }
.bud-of b { color: var(--ink); font-weight: 600; }
.track { position: relative; height: 8px; margin: 6px 0; border-radius: 4px; background: var(--surface-2); }
.track .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--bar); }
.track .over { position: absolute; top: 0; bottom: 0; border-radius: 0 4px 4px 0; background: repeating-linear-gradient(-45deg, var(--expense) 0 3px, transparent 3px 6px); box-shadow: inset 0 0 0 1px var(--expense); }
.track .tick100 { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); border-radius: 1px; z-index: 2; }
.bud-bot { font-size: var(--t-meta); }
.bud-state { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; color: var(--ink-2); }
.bud.is-over .bud-state { color: var(--expense); }
.bud.is-near .bud-state { color: var(--ink); }
.bud-state .ico { width: 14px; height: 14px; }
.timeline { position: absolute; top: 0; bottom: var(--s2); width: 0; border-left: 1px dashed var(--ink-3); pointer-events: none; z-index: 0; }
.timeline span { position: absolute; top: 0; right: 6px; font-size: var(--t-xs); color: var(--ink-2); white-space: nowrap; line-height: 16px; }

/* ===== КУДА УШЛИ ===== */
.cats { list-style: none; margin: 0; padding: 0; }
.cat { display: grid; grid-template-columns: minmax(120px, 176px) minmax(0, 1fr) 112px 44px; gap: var(--s3); align-items: center; min-height: 40px; }
.cat-n { font-size: .875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-bar { position: relative; height: 12px; }
.cat-bar .b { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--muted-bar); }
.cat-bar .ov { position: absolute; top: 0; bottom: 0; border-radius: 0 3px 3px 0; background: repeating-linear-gradient(-45deg, var(--expense) 0 3px, transparent 3px 6px); box-shadow: inset 0 0 0 1px var(--expense); }
.cat-bar .bm { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); border-radius: 1px; }
.cat-s { font-size: .875rem; font-weight: 600; text-align: right; }
.cat-p { font-size: var(--t-meta); color: var(--ink-3); text-align: right; }
.cats-more { display: inline-flex; }
.cat.extra2 { display: none; }
.cats.show-all .cat.extra2 { display: grid; }
.cats-foot { justify-content: space-between; flex-wrap: wrap; }
.cats-key { display: flex; gap: var(--s4); font-size: var(--t-meta); color: var(--ink-3); flex-wrap: wrap; margin-right: auto; }
.cats-key span { display: inline-flex; align-items: center; gap: 6px; }
.cats-key .k-bm { width: 2px; height: 12px; background: var(--ink); }
.cats-key .k-ov { width: 14px; height: 10px; border-radius: 2px; background: repeating-linear-gradient(-45deg, var(--expense) 0 3px, transparent 3px 6px); box-shadow: inset 0 0 0 1px var(--expense); }

/* ===== ДИНАМИКА ===== */
.dyn > summary { list-style: none; display: none; }
.dyn > summary::-webkit-details-marker { display: none; }
.chart-dyn { height: var(--dyn-h, 240px); }

/* ===== ОПЕРАЦИИ ===== */
.ops-day { font-size: var(--t-meta); font-weight: 600; color: var(--ink-3); margin: var(--s3) 0 0; padding-bottom: var(--s1); }
.ops-day:first-child { margin-top: 0; }
.ops { list-style: none; margin: 0; padding: 0; }
.op { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s3); padding: var(--s1) 0; border-top: 1px solid var(--line); min-height: 48px; align-items: center; }
.op-btn { position: absolute; inset: 0; border-radius: var(--r-s); }
.op-n { font-size: .875rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.op-m { font-size: var(--t-meta); color: var(--ink-3); }
.op-s { text-align: right; font-weight: 600; font-size: .875rem; }
.op-s small { display: block; font-weight: 400; color: var(--ink-3); font-size: var(--t-meta); }
.op-s.plus { color: var(--income); }
.op-s.tr { color: var(--ink-2); }
@media (hover: hover) and (pointer: fine) { .op-btn:hover { background: color-mix(in oklab, var(--surface-2) 60%, transparent); } }

/* ===== ПОДСКАЗКА ===== */
.ai { background: var(--surface-2); border-radius: var(--r-l); padding: var(--s5); box-shadow: inset 0 0 0 1px var(--line); }
.ai-h { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s3); }
.ai-h h2 { margin: 0; font-size: var(--t-h2); font-weight: 600; display: inline-flex; align-items: center; gap: var(--s2); }
.ai-h h2 .ico { color: var(--ink-2); }
.ai-h .sub { font-size: var(--t-meta); color: var(--ink-3); }
.ai p { margin: 0 0 var(--s4); max-width: 62ch; line-height: 1.5; }
.ai-act { display: flex; flex-wrap: wrap; gap: var(--s2); }
.ai-act .btn-line { background: var(--surface); }

/* ============ СКЕЛЕТОНЫ ============ */
.sk { display: none; }
body.loading .sk { display: block; }
body.loading .real { display: none !important; }
.sk-b { border-radius: var(--r-s); background: var(--surface-2); position: relative; overflow: hidden; }
.sk-b::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--surface) 70%, transparent), transparent); transform: translateX(-100%); animation: sk 1.3s linear infinite; }
@keyframes sk { to { transform: translateX(100%); } }

/* ============ ПОЛЯ ============ */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: var(--t-small); color: var(--ink-2); font-weight: 500; }
.input, input:not([type="checkbox"]):not([type="radio"]), select, textarea { min-height: 44px; padding: 0 var(--s3); border-radius: var(--r-m); background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--ink); width: 100%; min-width: 0; }
textarea { padding: var(--s2) var(--s3); min-height: 88px; }
.input:focus, input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
select option { background: var(--surface); color: var(--ink); }
label { font-size: var(--t-small); color: var(--ink-2); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--ink); width: 18px; height: 18px; }

/* ============ SHEET ============ */
.scrim { position: fixed; inset: 0; background: var(--scrim); opacity: 0; pointer-events: none; transition: opacity 240ms ease; z-index: 60; }
.scrim.open { opacity: 1; pointer-events: auto; transition: opacity 320ms ease; }
.sheet { position: fixed; z-index: 70; background: var(--surface); display: flex; flex-direction: column; top: 0; right: 0; bottom: 0; width: 440px; max-width: 100%; transform: translateX(100%); transition: transform 300ms var(--ease-drawer), visibility 0s 300ms; box-shadow: var(--shadow-sheet); visibility: hidden; }
.sheet.open { transform: none; visibility: visible; transition: transform var(--d-sheet) var(--ease-drawer), visibility 0s; }
.grab { display: none; }
.sheet-h { display: flex; align-items: center; justify-content: space-between; padding: var(--s4) var(--s5) var(--s2); }
.sheet-h h2 { margin: 0; font-size: 1.125rem; font-weight: 600; letter-spacing: -.01em; }
.sheet-b { flex: 1; overflow: auto; padding: var(--s2) var(--s5) var(--s4); display: flex; flex-direction: column; gap: var(--s4); }
.sheet-f { display: flex; gap: var(--s2); padding: var(--s3) var(--s5) calc(var(--s4) + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.sheet-f .btn { flex: 1; min-height: 48px; font-size: var(--t-body); }
.kind { display: grid; grid-template-columns: repeat(3, 1fr); padding: 3px; border-radius: var(--r-m); background: var(--surface-2); }
.kind button { min-height: 42px; border-radius: var(--r-inner); font-weight: 600; font-size: var(--t-small); color: var(--ink-2); transition: background-color var(--d-micro) ease, color var(--d-micro) ease; }
.kind button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.amount { display: flex; align-items: baseline; gap: var(--s2); padding: var(--s3) 0; border-bottom: 2px solid var(--line-strong); transition: border-color var(--d-micro) ease; }
.amount input { flex: 1; min-width: 0; border: 0 !important; background: transparent !important; font: 500 2.5rem/1.1 var(--f-display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; padding: 0; color: var(--ink); text-align: right; min-height: 0; }
.amount input:focus { outline: none; }
.amount:focus-within { border-color: var(--focus); box-shadow: 0 2px 0 0 var(--focus); }
.amount.bad { border-color: var(--expense); }
.amount .cur { font: 500 1.5rem/1 var(--f-display); color: var(--amber-ink); }
.amount-err { font-size: var(--t-small); color: var(--expense); font-weight: 600; min-height: 20px; margin: -8px 0 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }

/* ============ МОДАЛКИ (настройки, формы) ============ */
.modal-overlay { position: fixed; inset: 0; z-index: 90; background: var(--scrim); display: grid; place-items: center; padding: var(--s4); }
.modal-card { width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); border-radius: var(--r-l); padding: var(--s5); box-shadow: var(--shadow-sheet); }
.modal-card h3 { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin: 0 0 var(--s4); font-size: 1.125rem; font-weight: 600; }
.modal-card .close { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-m); color: var(--ink-2); font-size: 18px; }
.modal-card .close:hover { background: var(--surface-2); }
.modal-form { display: flex; flex-direction: column; gap: var(--s3); }
.modal-form label { display: flex; flex-direction: column; gap: 6px; }
.modal-form .row, .row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s2); }
.meta-line { font-size: var(--t-meta); color: var(--ink-3); }
.modal-raw, .raw-text { white-space: pre-wrap; word-break: break-word; font: 12px/1.45 ui-monospace, "Cascadia Mono", Consolas, monospace; color: var(--ink-3); background: var(--surface-2); border-radius: var(--r-s); padding: var(--s2) var(--s3); margin: var(--s2) 0 0; max-height: 120px; overflow: auto; }
.theme-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin: 0 0 var(--s4); }
.theme-row .muted-line { margin: 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: var(--r-m); background: var(--surface-2); margin-bottom: var(--s4); }
.tab { min-height: 38px; display: inline-flex; align-items: center; padding: 0 var(--s3); border-radius: var(--r-inner); font-size: var(--t-small); font-weight: 500; color: var(--ink-2); cursor: pointer; }
.tab.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }

/* ============ СПИСКИ УПРАВЛЕНИЯ ============ */
.manage-list { display: flex; flex-direction: column; }
.manage-row { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) 0; border-top: 1px solid var(--line); min-height: 52px; }
.manage-row:first-child { border-top: 0; }
.manage-row .grow, .grow { flex: 1; min-width: 0; }
.manage-row .grow .sub, .sub { font-size: var(--t-meta); color: var(--ink-3); }
.manage-row.archived { opacity: .55; }
.planning-main { display: flex; justify-content: space-between; gap: var(--s3); font-size: .875rem; font-weight: 600; }
.planning-main span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.progress { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin: 6px 0; }
.progress span { display: block; height: 100%; border-radius: 4px; background: var(--bar); }
.progress span.warn { background: var(--amber-line); }
.progress span.over { background: var(--expense); }
.progress span.ok { background: var(--bar); }
.sugg-title { font-size: var(--t-meta); font-weight: 600; color: var(--ink-3); margin: var(--s4) 0 var(--s1); text-transform: none; }
.chat-empty { padding: var(--s3) 0; font-size: var(--t-small); color: var(--ink-3); }
.segmented, .view-toggle { display: inline-flex; padding: 3px; border-radius: var(--r-m); background: var(--surface-2); }
.segmented button, .view-toggle button { min-height: 36px; padding: 0 var(--s3); border-radius: var(--r-inner); font-size: var(--t-small); font-weight: 500; color: var(--ink-2); }
.segmented button.active, .view-toggle button.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }

/* ============ АНАЛИТИКА ============ */
.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s5); align-items: start; }
.dash-grid .grid-wide { grid-column: span 3; }
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 380px; }
.summary { display: grid; gap: var(--s3); }
.summary .item .cap, .cap { font-size: var(--t-small); color: var(--ink-2); }
.summary .big, .big { font-weight: 700; font-size: 1.25rem; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.summary .merchants { font-size: var(--t-small); color: var(--ink-2); }
.fc-split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); margin: var(--s3) 0; }
.fc-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.fc-subs { margin-top: var(--s2); }
.fc-sub { display: flex; justify-content: space-between; gap: var(--s2); font-size: var(--t-small); padding: 6px 0; border-top: 1px solid var(--line); }
.leak-report .summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.leak-notes { margin: var(--s3) 0; display: grid; gap: 4px; }
.leak-note { font-size: var(--t-small); color: var(--ink-2); }
.leak-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s4); }
.leak-col .planning-main { font-weight: 500; padding: 6px 0; border-top: 1px solid var(--line); }
.cat-cell { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--muted-bar); }
.transfer-dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-3); }

/* ============ ПРОВЕРКА (полный раздел) ============ */
.review-list { display: flex; flex-direction: column; }
.review-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s3); padding: var(--s4) 0; border-top: 1px solid var(--line); }
.review-item:first-child { border-top: 0; }
.review-main { min-width: 0; }
.review-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.review-source { font-size: var(--t-meta); color: var(--ink-3); }
.review-title { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: baseline; margin-top: 6px; font-weight: 600; }
.review-meta { font-size: var(--t-meta); color: var(--ink-3); margin-top: 2px; }
.review-actions { display: flex; flex-wrap: wrap; gap: var(--s1); align-items: flex-start; justify-content: flex-end; max-width: 320px; }
.review-empty { padding: var(--s4) 0; color: var(--ink-3); font-size: var(--t-small); }
.status-badge { display: inline-flex; align-items: center; min-height: 22px; padding: 1px var(--s2); border-radius: var(--r-s); font-size: var(--t-xs); font-weight: 600; background: var(--surface-2); color: var(--ink-2); }
.status-badge.low_confidence, .status-badge.unparsed, .status-badge.needs_account, .status-badge.probable_duplicate { background: var(--warn-soft); color: var(--warn); }
.status-badge.confirmed, .status-badge.reviewed, .status-badge.accepted { background: var(--income-soft); color: var(--income); }
.status-badge.ignored, .status-badge.duplicate { background: var(--surface-2); color: var(--ink-3); }
.confidence { display: inline-flex; align-items: center; min-height: 20px; padding: 0 6px; margin-left: 4px; border-radius: var(--r-s); font-size: var(--t-xs); font-weight: 700; font-variant-numeric: tabular-nums; }
.confidence.good { background: var(--income-soft); color: var(--income); }
.confidence.warn { background: var(--warn-soft); color: var(--warn); }
.confidence.bad { background: var(--expense-soft); color: var(--expense); }
.amount-expense { color: var(--ink); }
.amount-income { color: var(--income); }
.amount-transfer, .amount-transfer-text { color: var(--ink-2); }

/* ============ ЗАПИСИ ============ */
.filters { display: grid; grid-template-columns: minmax(200px, 2fr) repeat(3, minmax(0, 1fr)) 110px 110px auto; gap: var(--s2); align-items: center; margin-bottom: var(--s4); }
.search { position: relative; display: flex; align-items: center; margin: 0; }
.search .ico { position: absolute; left: 12px; color: var(--ink-3); pointer-events: none; }
.search input[type="search"] { padding-left: 36px; }
.table-wrap { position: relative; overflow-x: auto; margin: 0 calc(var(--s5) * -1); padding: 0 var(--s5); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; font-size: var(--t-meta); font-weight: 600; color: var(--ink-3); padding: var(--s2) var(--s2); border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
td { padding: var(--s2); border-bottom: 1px solid var(--line); vertical-align: middle; }
th.num, td.num { text-align: right; }
td.num { font-weight: 600; }
#tx-table tbody tr[data-id] { cursor: pointer; }
@media (hover: hover) and (pointer: fine) { #tx-table tbody tr[data-id]:hover td { background: var(--surface-2); } }
.dt-cell { white-space: nowrap; }
.dt-cell .dt-date { display: block; }
.dt-cell .dt-time { display: block; font-size: var(--t-meta); color: var(--ink-3); }
td.empty { text-align: center; color: var(--ink-3); padding: var(--s5); }
.del-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-m); color: var(--ink-3); }
.del-btn:hover { color: var(--expense); background: var(--surface-2); }

/* ============ ЧАТ ============ */
.chat-card { max-width: 820px; }
.chat-log { display: flex; flex-direction: column; gap: var(--s2); min-height: 240px; max-height: 56vh; overflow: auto; padding: var(--s2) 0; }
.chat-msg { max-width: 80%; padding: var(--s2) var(--s3); border-radius: var(--r-m); font-size: var(--t-body); white-space: pre-wrap; line-height: 1.45; }
.chat-msg.me { align-self: flex-end; background: var(--ink); color: var(--surface); }
.chat-msg.ai { align-self: flex-start; background: var(--surface-2); color: var(--ink); }
.chat-msg.ai.thinking { color: var(--ink-3); }
.chat-suggest { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.chat-suggest button { min-height: 40px; padding: 0 var(--s3); border-radius: var(--r-m); font-size: var(--t-small); font-weight: 500; box-shadow: inset 0 0 0 1px var(--line); background: var(--surface-2); }
.chat-suggest button:hover { color: var(--ink); background: var(--surface); }
.chat-input { display: flex; gap: var(--s2); margin-top: var(--s3); }
.chat-input .btn { min-width: 52px; padding: 0 var(--s3); }

/* ============ КАЛЕНДАРЬ ПОДПИСОК ============ */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s2); }
.cal-title { font-weight: 600; text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: var(--t-xs); color: var(--ink-3); text-align: center; padding: 4px 0; }
.cal-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 64px; padding: 6px; border-radius: var(--r-s); background: var(--surface-2); text-align: left; min-width: 0; }
.cal-cell.empty { background: transparent; }
.cal-cell.past { opacity: .5; }
.cal-cell.today { box-shadow: inset 0 0 0 1.5px var(--amber-line); }
.cal-cell.selected { background: var(--ink); color: var(--surface); }
.cal-cell.selected .cal-sum { color: var(--surface); }
.cal-num { font-weight: 600; font-size: var(--t-small); font-variant-numeric: tabular-nums; }
.cal-sum { font-size: var(--t-xs); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.cal-sum.pos { color: var(--income); }
.cal-dots { display: flex; gap: 3px; margin-top: auto; }
.cal-dots .dot { width: 6px; height: 6px; background: var(--muted-bar); }
.cal-dots .dot.credit { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.cal-dots .dot.income { background: var(--income); }
.cal-dots .dot.payment { background: var(--amber-line); }
#cal-day-panel { margin-top: var(--s3); }
@media (hover: hover) and (pointer: fine) { .cal-cell:not(.empty):not(.selected):hover { background: var(--line); } }

/* ============ ВХОД ============ */
.login-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bg); padding: var(--s4); }
.login-card { width: min(380px, 100%); background: var(--surface); border-radius: var(--r-l); padding: var(--s6) var(--s5); display: flex; flex-direction: column; gap: var(--s3); }
.login-card .brand { color: var(--ink-3); font-size: var(--t-small); }
.login-card h1 { margin: 0; font: 500 1.75rem/1.1 var(--f-display); letter-spacing: -.03em; }
.login-card .muted-line { margin: 0 0 var(--s2); }
.login-card .btn { min-height: 48px; }

/* ============ ТОСТЫ (снэкбар) ============ */
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 95; display: flex; flex-direction: column; gap: var(--s2); align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; align-items: center; gap: var(--s3); min-height: 48px; padding: var(--s2) var(--s4); border-radius: var(--r-m); background: var(--ink); color: var(--surface); font-size: var(--t-small); box-shadow: var(--shadow-sheet); pointer-events: auto; animation: toast-in 240ms var(--ease-out); }
.toast.err { background: var(--expense); color: #fff; }
.toast button { color: inherit; text-decoration: underline; text-underline-offset: 3px; font-weight: 600; min-height: 36px; }
@keyframes toast-in { from { transform: translateY(16px); opacity: 0; } }

.bnav { display: none; }

/* ============ ПЛАНШЕТ ============ */
@media (max-width: 1180px) {
  .sync { display: none; }
  .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid .grid-wide { grid-column: span 2; }
  .filters { grid-template-columns: 1fr 1fr 1fr; }
  .filters .search { grid-column: 1 / -1; }
}
@media (max-width: 1100px) {
  .hero { grid-template-columns: 1fr; gap: var(--s5); }
  .cat { grid-template-columns: minmax(96px, 140px) minmax(0, 1fr) 104px 40px; }
  .seg { display: none; }
  .ask-l { display: none; }
  .ask-s { display: inline; }
  .period-name { min-width: 0; }
  .top-in { gap: var(--s2); }
  #theme-btn { display: none; }
}
@media (max-width: 900px) and (min-width: 768px) {
  .top-in .brand { display: none; }
  .top-in { grid-template-columns: auto 1fr; }
}
@media (max-width: 900px) {
  .cols { display: flex; flex-direction: column; align-items: stretch; }
  .col-a, .col-b { display: contents; }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-grid .grid-wide { grid-column: auto; }
}

/* ============ ТЕЛЕФОН ============ */
@media (max-width: 767px) {
  :root { --t-hero: 2.5rem; --r-l: 14px; }
  .d-only { display: none !important; }
  .seg button, .pp-tab, .kind button, .tab, .segmented button, .view-toggle button { min-height: 44px; }
  .top-in { grid-template-columns: 1fr auto; height: 56px; padding: 0 var(--s2) 0 var(--s1); }
  .top-in .brand { display: none; }
  .period { justify-content: flex-start; gap: 0; }
  .period-name { font-size: 1rem; }
  .period-pop { left: 0; transform: none; }
  .top-actions { gap: 0; }
  .top-actions .btn-line { min-height: 44px; padding: 0 var(--s3); margin-right: var(--s1); }
  .topnav { display: none; }
  .msync { display: flex; align-items: center; gap: 6px; font-size: var(--t-meta); color: var(--ink-3); padding: 0 var(--s4); height: 28px; margin-top: 2px; }
  .msync .link { margin-left: auto; min-height: 44px; font-size: var(--t-small); }
  .banner, .session { padding: 0 var(--s4); }
  .session-in .input { min-width: 0; }
  .session-in label { flex: 1 1 100%; }
  main { padding: var(--s2) var(--s4) calc(var(--nav-h) + 40px + env(safe-area-inset-bottom)); }
  .cols { gap: var(--s3); }
  .panel, .ai { padding: var(--s4); }
  .panel-h { margin-bottom: var(--s3); }
  .view-h h1 { font-size: 1.375rem; }
  .hero { padding: var(--s4); gap: var(--s3); }
  .hero-sum .kop { font-size: .46em; }
  .hero-delta { margin-top: var(--s2); }
  .hero-lines { margin-top: var(--s2); border-top: 0; }
  .hero-lines li { min-height: 0; padding: 2px 0; border: 0; }
  .hero-lines li.debt { font-weight: 600; color: var(--ink); }
  .hero-lines li.net, .hero-lines li.net .num { font-size: var(--t-small); }
  .hero-lines li.net .num { color: var(--ink-2); }
  .accts-h { display: none; }
  .accts { flex-direction: row; overflow-x: auto; gap: var(--s2); margin: 0 calc(var(--s4) * -1); padding: 0 var(--s4) 2px; scroll-snap-type: x mandatory; scrollbar-width: none; scroll-padding: 0 var(--s4); }
  .accts::-webkit-scrollbar { display: none; }
  .acct { flex: 0 0 148px; grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; grid-template-areas: "name" "meta" "sum"; gap: 2px; align-content: stretch; padding: 10px var(--s3); border: 0; border-radius: var(--r-m); background: var(--surface-2); scroll-snap-align: start; min-height: 0; }
  .acct-name { font-size: var(--t-small); }
  .acct-sum { text-align: left; font-weight: 700; font-size: var(--t-body); margin-top: auto; padding-top: 2px; }
  .acct.debt { display: none; }
  .acct.all { display: grid; align-content: center; flex-basis: 112px; }
  .trio { grid-template-columns: repeat(3, auto); justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
  .trio dd { font-size: .9375rem; font-weight: 700; letter-spacing: -.025em; }
  .trio dd .kp { font-size: .66em; letter-spacing: 0; }
  .trio dt { font-size: var(--t-meta); margin: 0; }
  .trio small { display: none; }
  .pace-say { font-size: .875rem; line-height: 1.4; }
  .pace-fc { font-size: var(--t-meta); justify-content: space-between; }
  .chart-pace { height: 128px; margin-top: 0; }
  .legend.pace-lg { display: none; }
  .review-foot { display: grid; grid-template-columns: 1fr; border-top: 0; padding-top: 0; }
  .bulk { padding: var(--s3); }
  .bulk .btn { width: 100%; min-height: 48px; }
  .cand:nth-child(n+3) { display: none; }
  .review.show-all .cand { display: grid; }
  .cand-row { grid-template-areas: "who amt" "meta meta" "tags tags" "acts acts"; }
  .cand-act { margin-top: var(--s2); }
  .cand-act .btn-ink { min-height: 48px; min-width: 132px; }
  .cand-act .btn-icon { width: 48px; height: 48px; }
  .more-btn { display: inline-flex; width: 100%; min-height: 48px; }
  .review.show-all .more-btn { display: none; }
  .days { display: flex; overflow-x: auto; gap: 6px; margin: 0 calc(var(--s4) * -1) var(--s3); padding: 0 var(--s4); scrollbar-width: none; }
  .days::-webkit-scrollbar { display: none; }
  .day { flex: 0 0 56px; }
  .bill:nth-child(n+4) { display: none; }
  .bud:nth-child(n+4) { display: none; }
  .bud-top { flex-wrap: wrap; gap: 0 var(--s3); }
  .bud-name { white-space: nowrap; }
  .bud-of { font-size: var(--t-meta); margin-left: auto; }
  .bill { grid-template-columns: 44px minmax(0, 1fr) auto; }
  .bill.cr .cr-mark { grid-column: 2 / -1; justify-self: start; }
  .cat { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto; gap: 4px var(--s3); padding: var(--s2) 0; min-height: 0; }
  .cat-n { grid-column: 1; grid-row: 1; }
  .cat-s { grid-column: 2; grid-row: 1; }
  .cat-bar { grid-column: 1 / -1; grid-row: 2; height: 10px; }
  .cat-p { display: none; }
  .cat.extra { display: none; }
  .cats.show-all .cat.extra { display: grid; }
  .cats-more { display: inline-flex; }
  .cats-key { width: 100%; padding: var(--s2) 0 var(--s1); }
  .panel-foot { justify-content: space-between; }
  .dyn > summary { display: flex; align-items: center; justify-content: space-between; min-height: 44px; cursor: pointer; border-radius: var(--r-s); }
  .dyn > summary h2 { margin: 0; font-size: var(--t-h2); font-weight: 600; }
  .dyn > summary .sm { font-size: var(--t-small); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
  .dyn[open] > summary { margin-bottom: var(--s2); }
  .dyn .panel-h { display: none; }
  .chart-dyn { --dyn-h: 160px; }
  .ops .op:nth-child(n+3) { display: none; }
  .sheet { top: auto; left: 0; right: 0; width: 100%; height: auto; max-height: 92dvh; border-radius: var(--r-l) var(--r-l) 0 0; transform: translateY(100%); }
  .grab { display: block; width: 100%; padding: 10px 0 4px; }
  .grab i { display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 0 auto; }
  .sheet-h { padding: var(--s1) var(--s4); }
  .sheet-b { gap: var(--s3); padding: var(--s2) var(--s4) var(--s3); }
  .sheet-f { padding: var(--s3) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom)); }
  .toasts { bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); }
  .bnav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding: 0 4px env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); }
  .bnav a, .bnav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: var(--t-xs); font-weight: 500; color: var(--ink-3); text-decoration: none; position: relative; min-height: 48px; }
  .bnav [aria-current="page"] { color: var(--ink); font-weight: 600; }
  .bnav [aria-current="page"]::after { content: ""; position: absolute; bottom: 6px; width: 4px; height: 4px; border-radius: 50%; background: var(--ink); }
  .bnav .badge { position: absolute; top: 8px; left: calc(50% + 4px); height: 18px; min-width: 18px; font-size: var(--t-xs); padding: 0 5px; }
  .bnav .add { color: var(--ink); font-weight: 600; }
  .bnav .add .plus { width: 56px; height: 40px; border-radius: var(--r-m); background: var(--amber); color: var(--on-amber); display: grid; place-items: center; transition: transform var(--d-press) var(--ease-out); }
  .bnav .add .plus .ico { stroke-width: 2.25; }
  .bnav .add:active .plus { transform: scale(.97); }
  .ai-act .btn-line { flex: 1 1 100%; }
  .ai-act .btn-ghost { flex: 1 1 0; }
  .filters { grid-template-columns: 1fr 1fr; }
  .table-wrap { margin: 0 calc(var(--s4) * -1); padding: 0 var(--s4); }
  .review-item { grid-template-columns: 1fr; }
  .review-actions { justify-content: flex-start; max-width: none; }
  .leak-report .summary { grid-template-columns: 1fr; }
  .chart-box { height: 240px; }
  .chart-box.tall { height: 320px; }
  .cal-cell { min-height: 48px; padding: 4px; }
  .cal-sum { font-size: var(--t-xs); }
  .modal-card { padding: var(--s4); }
  .modal-form .row, .row { grid-template-columns: 1fr; }
  .chat-msg { max-width: 92%; }
}

/* ============ REDUCED MOTION ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
  .sheet, .menu, .scrim { transition: opacity 180ms ease, visibility 0s !important; }
  .sheet { transform: none !important; opacity: 0; }
  .sheet.open { opacity: 1; }
  .menu, .menu.open { transform: none; }
  .cand.leaving > .cand-in { transform: none; }
  .btn:active, .btn-icon:active, .bnav .add:active .plus { transform: none; }
  .sk-b::after { animation: none; }
}
