/* ==========================================================================
   Учёт финансов — «Чёрное море и сосны»
   Одна смелая вещь — главная цифра на «Обзоре» (Unbounded). Всё остальное тихое.
   ========================================================================== */

@font-face { font-family: "Golos Text"; src: url("/static/fonts/golos-text.woff2") format("woff2");
  font-weight: 400 900; font-display: swap; }
@font-face { font-family: "Unbounded"; src: url("/static/fonts/unbounded.woff2") format("woff2");
  font-weight: 200 900; font-display: swap; }

/* ---------- цветовые схемы ----------
   Две независимые оси: тема (светлая / тёмная / как в системе) и акцент (море / сосна / графит / сумерки).
   Каждая схема задаёт светлые (--l-*) и тёмные (--d-*) значения; блоки тем ниже выбирают нужные.
   Цвета серий графиков общие для всех схем — проверены валидатором dataviz на каждой поверхности. */
:root, [data-accent="sea"] {
  --l-bg: #EEF2F0; --l-surface-2: #F6F8F7; --l-line: #DCE3E0; --l-line-strong: #C5D0CC;
  --l-accent: #0F6E74; --l-accent-hover: #0C5C61; --l-accent-ink: #FFFFFF; --l-accent-soft: #DDEDEC;
  --d-bg: #11171A; --d-surface: #182024; --d-surface-2: #1D262A; --d-line: #2A3438; --d-line-strong: #37444A;
  --d-accent: #3FA9AE; --d-accent-hover: #5BBDC2; --d-accent-ink: #0B1A1C; --d-accent-soft: #1D3335;
}
[data-accent="pine"] {
  --l-bg: #EDF1EC; --l-surface-2: #F5F8F4; --l-line: #DAE3DB; --l-line-strong: #C3D0C5;
  --l-accent: #2D6A4F; --l-accent-hover: #245840; --l-accent-ink: #FFFFFF; --l-accent-soft: #DEEBE3;
  --d-bg: #121714; --d-surface: #19201B; --d-surface-2: #1E2620; --d-line: #29342C; --d-line-strong: #36443A;
  --d-accent: #5DB38A; --d-accent-hover: #76C49F; --d-accent-ink: #0C1A12; --d-accent-soft: #1E3328;
}
[data-accent="graphite"] {
  --l-bg: #EFF1F4; --l-surface-2: #F6F7F9; --l-line: #DDE1E7; --l-line-strong: #C7CDD6;
  --l-accent: #3F516A; --l-accent-hover: #334257; --l-accent-ink: #FFFFFF; --l-accent-soft: #E2E7EE;
  --d-bg: #121418; --d-surface: #1A1D23; --d-surface-2: #1F232A; --d-line: #2B3038; --d-line-strong: #383E48;
  --d-accent: #93A9C6; --d-accent-hover: #A9BCD5; --d-accent-ink: #11161D; --d-accent-soft: #263142;
}
[data-accent="dusk"] {
  --l-bg: #F0EFF5; --l-surface-2: #F7F6FA; --l-line: #E0DEEA; --l-line-strong: #CBC8DA;
  --l-accent: #5B4BB0; --l-accent-hover: #4C3E96; --l-accent-ink: #FFFFFF; --l-accent-soft: #E7E3F6;
  --d-bg: #14131B; --d-surface: #1C1A25; --d-surface-2: #22202D; --d-line: #2F2C3C; --d-line-strong: #3D394D;
  --d-accent: #A597EE; --d-accent-hover: #B9AEF3; --d-accent-ink: #15112A; --d-accent-soft: #2A2546;
}

/* светлая тема (по умолчанию) */
:root {
  --bg: var(--l-bg); --surface: #FFFFFF; --surface-2: var(--l-surface-2);
  --ink: #1F2A2E; --ink-2: #44555B; --muted: #6B7B80; --line: var(--l-line); --line-strong: var(--l-line-strong);
  --accent: var(--l-accent); --accent-hover: var(--l-accent-hover); --accent-ink: var(--l-accent-ink); --accent-soft: var(--l-accent-soft);
  --good: #2F7D5B; --warn: #A86B12; --bad: #C23B4A;
  --series-in: #1E73A8; --series-out: #C23B4A; --series-neutral: #8A9A9E;
  --r-panel: 14px; --r-ctrl: 8px;
  --font: "Golos Text", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Unbounded", "Golos Text", system-ui, sans-serif;
  color-scheme: light;
}
/* тёмная тема: явно выбрана — или «как в системе» при тёмной системе */
:root[data-theme="dark"] {
  --bg: var(--d-bg); --surface: var(--d-surface); --surface-2: var(--d-surface-2);
  --ink: #E4ECEA; --ink-2: #B4C2C0; --muted: #8A9A9C; --line: var(--d-line); --line-strong: var(--d-line-strong);
  --accent: var(--d-accent); --accent-hover: var(--d-accent-hover); --accent-ink: var(--d-accent-ink); --accent-soft: var(--d-accent-soft);
  --good: #55B98C; --warn: #E0A645; --bad: #EA6070;
  --series-in: #4E9BD6; --series-out: #EA6070; --series-neutral: #6E7E82;
  --bad-hero: color-mix(in oklab, var(--bad) 74%, var(--d-bg));   /* в тёмной теме — приглушаем к фону */
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--d-bg); --surface: var(--d-surface); --surface-2: var(--d-surface-2);
    --ink: #E4ECEA; --ink-2: #B4C2C0; --muted: #8A9A9C; --line: var(--d-line); --line-strong: var(--d-line-strong);
    --accent: var(--d-accent); --accent-hover: var(--d-accent-hover); --accent-ink: var(--d-accent-ink); --accent-soft: var(--d-accent-soft);
    --good: #55B98C; --warn: #E0A645; --bad: #EA6070;
    --series-in: #4E9BD6; --series-out: #EA6070; --series-neutral: #6E7E82;
  --bad-hero: color-mix(in oklab, var(--bad) 74%, var(--d-bg));   /* в тёмной теме — приглушаем к фону */
    color-scheme: dark;
  }
}

/* Статусные цвета для текста и полос — приглушены к основному тексту/фону, чтобы не «резали» глаз.
   Чистые --bad / --warn остаются для мелких сигналов (ошибки, «просрочен»). */
:root {
  --bad-ink: color-mix(in oklab, var(--bad) 72%, var(--ink));
  --bad-fill: color-mix(in oklab, var(--bad) 64%, var(--surface));
  --bad-hero: color-mix(in oklab, var(--bad) 58%, var(--ink));
  --warn-ink: color-mix(in oklab, var(--warn) 78%, var(--ink));
  --warn-fill: color-mix(in oklab, var(--warn) 66%, var(--surface));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--font);
  font-feature-settings: "tnum" 1, "lnum" 1; }
h1, h2 { font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 17px; line-height: 1.3; }
small { font-size: 12.5px; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- каркас: боковое меню + содержимое ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px;
  padding: 22px 14px; border-right: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 0 8px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; left: 6px; right: 6px; top: 9px; height: 9px;
  border: 2.5px solid var(--accent-ink); border-bottom: 0; border-radius: 10px 10px 0 0; }
.tabs { display: flex; flex-direction: column; gap: 2px; }
.tabs button { text-align: left; border: 0; background: none; color: var(--ink-2); font: 500 15px var(--font);
  padding: 9px 12px; border-radius: var(--r-ctrl); cursor: pointer; }
.tabs button:hover { background: var(--surface-2); color: var(--ink); }
.tabs button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.logout { margin-top: auto; padding: 9px 12px; color: var(--muted); text-decoration: none; font-size: 14px; }
.logout:hover { color: var(--bad); }

.main { min-width: 0; }
.pagebar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 26px 40px 6px; max-width: 1480px; margin: 0 auto; }
.period { margin-left: auto; display: flex; gap: 8px; align-items: center; color: var(--muted); }
main { max-width: 1480px; margin: 0 auto; padding: 14px 40px 120px; }
.tab { display: none; flex-direction: column; gap: 20px; }
.tab.active { display: flex; }

/* ---------- главная фраза ---------- */
.hero { padding: 18px 2px 26px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.hero p { margin: 0; }
.hero-lead { font-size: 18px; font-weight: 500; color: var(--ink-2); }
.hero-figure { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 16px; margin: 2px 0 8px !important; }
#heroNum { font-family: var(--font-display); font-weight: 600; font-size: clamp(44px, 6.6vw, 84px);
  line-height: 1.04; letter-spacing: -0.035em; color: var(--ink); }
.hero.over #heroNum { color: var(--bad-hero); }
.hero-unit { font-size: 22px; font-weight: 500; color: var(--ink-2); }
.hero-sub { font-size: 17px; color: var(--ink-2); max-width: 62ch; }
.hero-meta { font-size: 14px; color: var(--muted); margin-top: 6px !important; max-width: 70ch; }
.hero-meta b { color: var(--ink-2); font-weight: 600; }

.section-title { font-size: 15px; font-weight: 600; color: var(--ink-2); margin: 10px 2px -6px; }
.section-title .hint { font-weight: 400; margin-left: 6px; }

/* ---------- панели ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 18px 20px; min-width: 0; }
.panel.narrow { max-width: 640px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head .hint { margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid2.wide-left { grid-template-columns: 1.35fr 1fr; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpis.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 6px; }
.kpis.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px;
  display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.panel .kpi { background: var(--surface-2); border-color: transparent; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi b { font-size: 21px; font-weight: 600; letter-spacing: -0.01em; }
.kpi .small-b { font-size: 16px; }
.kpi small { font-size: 12px; }
.kpi #cSync { align-self: flex-start; margin-top: 6px; }
.pos { color: var(--good); } .neg { color: var(--bad-ink); }

/* ---------- элементы управления ---------- */
input, select, button, textarea { font: inherit; color: inherit; }
input, select { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-ctrl);
  padding: 8px 11px; min-width: 0; min-height: 38px; }
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
button { border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-ctrl);
  padding: 8px 15px; min-height: 38px; cursor: pointer; font-weight: 500; }
button:hover { border-color: var(--ink-2); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.ghost { background: none; border-color: transparent; color: var(--ink-2); }
button.ghost:hover { background: var(--surface-2); }
button.square { width: 36px; padding: 0; font-size: 20px; line-height: 1; }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; padding: 2px 0; min-height: 0; color: var(--accent); font-size: 14px; font-weight: 500; }
button.link:hover { text-decoration: underline; }
button.icon { border: 0; background: none; color: var(--muted); padding: 4px 6px; min-height: 0; }
button.icon:hover { color: var(--bad); }
button.icon.debt-btn { font-size: 12.5px; }
button.icon.debt-btn:hover { color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-ctrl); overflow: hidden; }
.seg label { padding: 7px 13px; cursor: pointer; color: var(--ink-2); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }

form.inline { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 12px; }
form.inline input { flex: 1 1 160px; }
form.inline .w-amount { flex: 0 1 120px; } form.inline .w-day { flex: 0 1 80px; }
label.stack { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 13.5px; }
.stack { display: flex; flex-direction: column; gap: 6px; }
.inline-label { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); }
.check, .cat-checks label { display: flex; gap: 7px; align-items: center; font-size: 14px; color: var(--ink); }

.hint { color: var(--muted); font-size: 13.5px; margin: 6px 0 0; }
.msg { margin-top: 8px; color: var(--muted); font-size: 14px; }
.msg.ok { color: var(--good); } .msg.err { color: var(--bad); }
.empty { color: var(--muted); padding: 22px 0; text-align: center; font-size: 14px; }
.tag { font-size: 11.5px; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 10px; padding: 1px 8px; margin-left: 6px; white-space: nowrap; }
code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: 13px; }

/* ---------- деньги сейчас (счета) ---------- */
.accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.acc { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.acc .name { color: var(--muted); font-size: 13.5px; }
.acc .bal { font-size: 19px; font-weight: 600; margin: 1px 0; }
.acc .sub { color: var(--muted); font-size: 12.5px; }
.acc .stale { color: var(--bad); }
.acc.networth { background: var(--accent-soft); border-color: transparent; }
.acc.networth .name, .acc.networth .sub { color: var(--accent); }
.acc.networth .bal { font-size: 21px; }
.acc .link { font-size: 13px; margin-top: 4px; }

/* ---------- бюджет ---------- */
.month-nav { display: flex; align-items: center; gap: 4px; }
.month-nav h2 { min-width: 200px; text-align: center; }
.budget-list { display: flex; flex-direction: column; gap: 4px; }
.budget-row { cursor: pointer; padding: 9px 10px; margin: 0 -10px; border-radius: 10px; }
.budget-row:hover { background: var(--surface-2); }
.brow-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.budget-row .nm { font-weight: 600; }
.budget-row .nums { white-space: nowrap; }
.budget-row .sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.bbar { position: relative; height: 8px; background: var(--surface-2); border-radius: 4px; margin-top: 7px; box-shadow: inset 0 0 0 1px var(--line); }
.bbar .fill { height: 100%; border-radius: 4px; background: var(--accent); }
.bbar .fill.warn { background: var(--warn-fill); } .bbar .fill.over { background: var(--bad-fill); }
.bbar .pace { position: absolute; top: -4px; bottom: -4px; width: 2px; border-radius: 1px; background: var(--ink); opacity: .7; }
.budget-list.compact .budget-row { padding: 6px 10px; }
.budget-list.compact .bbar { height: 6px; margin-top: 5px; }
.state-over { color: var(--bad-ink); } .state-warn { color: var(--warn-ink); }
.cat-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; max-height: 280px; overflow: auto; padding: 6px 0; }
.cat-checks .taken { color: var(--muted); }

/* ---------- «Скоро» и регулярные платежи ---------- */
.upcoming { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.upcoming li { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: baseline; padding: 9px 0; border-top: 1px solid var(--line); }
.upcoming li:first-child { border-top: 0; padding-top: 2px; }
.upcoming .when { color: var(--muted); font-size: 13.5px; }
.upcoming .what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upcoming .amt { white-space: nowrap; font-weight: 500; }
.upcoming .rent .what { font-weight: 600; }
.upcoming .overdue .when { color: var(--bad-ink); font-weight: 600; }
.recurring table { width: 100%; border-collapse: collapse; }
.recurring td { padding: 8px 4px; border-top: 1px solid var(--line); vertical-align: top; }
.recurring tr:first-child td { border-top: 0; }
.recurring tr.total td { border-top: 1px solid var(--line-strong); }

/* ---------- графики ---------- */
.chart { width: 100%; min-height: 220px; }
.chart svg { width: 100%; display: block; overflow: visible; }
.chart .axis { fill: var(--muted); font-size: 11.5px; font-family: var(--font); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .baseline { stroke: var(--line-strong); stroke-width: 1; }
.chart .ref { stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .ref-label { fill: var(--ink-2); font-size: 12px; font-family: var(--font); }
.chart .val-label { fill: var(--ink); font-size: 12px; font-weight: 600; font-family: var(--font); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .mark, .chart .mark.hover { filter: brightness(1.12); }
.legend { display: flex; gap: 16px; color: var(--ink-2); font-size: 13px; margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 160px) 1fr 120px; gap: 12px; align-items: center; cursor: pointer; padding: 2px 0; }
.bar-row .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--surface-2); border-radius: 4px; height: 10px; }
.bar-fill { background: var(--series-out); height: 100%; border-radius: 4px; }
.bar-row:hover .bar-fill { filter: brightness(1.1); }
.bar-row .val { text-align: right; white-space: nowrap; }
.bar-row .val small { color: var(--muted); margin-left: 4px; }
.tooltip { position: fixed; pointer-events: none; background: var(--ink); color: var(--surface); padding: 7px 10px;
  border-radius: 8px; font-size: 12.5px; line-height: 1.45; z-index: 30; max-width: 280px; white-space: pre-line; }

/* ---------- таблицы ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters #fQ { flex: 1 1 240px; }
.table-wrap { overflow-x: auto; margin: 0 -6px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; white-space: nowrap; }
td.date { white-space: nowrap; color: var(--muted); }
td.desc { max-width: 380px; }
td select { padding: 4px 8px; min-height: 32px; max-width: 200px; }
tr.transfer td { color: var(--muted); }
.debt-link { color: var(--accent); cursor: pointer; border-color: var(--accent); }
table.ops td { padding: 5px 6px; font-size: 13.5px; }

/* ---------- долги ---------- */
.debt-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.debt-form input[name=person] { flex: 1 1 180px; }
.debt-form input[name=amount] { width: 130px; }
.debt-form input[name=note] { flex: 1 1 160px; }
.debt-list { display: flex; flex-direction: column; gap: 10px; }
.debt { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.debt-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.debt-head .who { font-weight: 600; }
.debt-head .rem { font-size: 17px; font-weight: 600; white-space: nowrap; }
.debt .meta { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.debt .meta .overdue { color: var(--bad-ink); font-weight: 600; }
.debt .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.debt .actions button { padding: 4px 11px; min-height: 32px; font-size: 13.5px; }
.debt details { margin-top: 8px; font-size: 13.5px; }
.debt details summary, .closed-debts summary, .howto summary { cursor: pointer; color: var(--ink-2); }
.debt .ops { width: 100%; margin-top: 4px; }
.debt.closed { opacity: .65; }
.closed-debts summary { font-weight: 600; }
.closed-debts .debt-list { margin-top: 14px; }

/* ---------- импорт и настройки ---------- */
.drop { display: block; border: 2px dashed var(--line-strong); border-radius: var(--r-panel); padding: 34px 20px;
  text-align: center; color: var(--ink-2); cursor: pointer; margin-bottom: 14px; }
.drop small { color: var(--muted); }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop input { display: none; }
#importForm label.stack { margin-bottom: 14px; }
.howto { margin-top: 18px; color: var(--muted); font-size: 14px; }
.acc-row { display: grid; grid-template-columns: 1fr 140px auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.rules { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 22px; max-height: 320px; overflow: auto; }
.rule { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 2px 4px 2px 11px;
  font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.rule em { color: var(--muted); font-style: normal; }
ol.setup { margin: 0 0 8px; padding-left: 20px; line-height: 1.8; }

/* ---------- кнопка «+», окна, уведомление ---------- */
.fab { position: fixed; right: 28px; bottom: 28px; width: 58px; height: 58px; border-radius: 50%; padding: 0;
  background: var(--accent); color: var(--accent-ink); border: 0; font-size: 30px; font-weight: 300; line-height: 1;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .28); z-index: 20; }
.fab:hover { background: var(--accent-hover); }

dialog { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink);
  padding: 22px 24px; width: min(460px, 94vw); box-shadow: 0 20px 60px rgba(10, 30, 32, .3); }
dialog::backdrop { background: rgba(12, 24, 27, .45); }
dialog form { display: flex; flex-direction: column; gap: 12px; }
dialog h2 { font-size: 19px; margin-bottom: 2px; }
dialog[open] { animation: dlg .14s ease-out; }
@keyframes dlg { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.dialog-actions .spacer { flex: 1; }
.ask-text { margin: 0; color: var(--ink-2); white-space: pre-line; }
dialog.sheet { width: min(560px, 94vw); }
#quickForm { display: flex; flex-direction: row; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
#quickForm #quickText { flex: 1 1 260px; }
#openFull { align-self: flex-start; margin-top: 8px; }
#fullForm { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--line); }
#fullForm .seg, #fullForm input[name=description], #fullForm button { grid-column: 1 / -1; }
#fullForm .seg { justify-self: start; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--ink); color: var(--surface);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 40; max-width: min(520px, 90vw); box-shadow: 0 8px 24px rgba(0,0,0,.2); }

/* ---------- узкие экраны ---------- */
@media (max-width: 1080px) {
  .grid2, .grid2.wide-left { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; z-index: 10; height: auto; flex-direction: row; align-items: center; gap: 12px;
    padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .brand { font-size: 0; padding: 0; gap: 0; }
  .tabs { flex-direction: row; }
  .tabs button { white-space: nowrap; padding: 7px 11px; }
  .logout { margin: 0 0 0 auto; white-space: nowrap; }
  .pagebar { padding: 18px 18px 4px; }
  main { padding: 10px 18px 110px; }
  .kpis.compact { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 110px 1fr 100px; }
  .fab { right: 18px; bottom: 18px; }
  #fullForm { grid-template-columns: 1fr; }
}
/* подписи поверх меток — с «ореолом» цвета фона, чтобы читались */
.chart .ref-label, .chart .val-label { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.budget-more { margin-top: 6px; }
#askDialog { width: min(540px, 94vw); }
#txTable td:nth-child(2) { white-space: nowrap; }

/* ---------- окно «Оформление» ---------- */
.appearance-btn { border: 0; background: none; text-align: left; padding: 9px 12px; color: var(--muted); font-size: 14px; min-height: 0; margin-top: auto; }
.appearance-btn:hover { color: var(--ink); background: var(--surface-2); }
.appearance-btn + .logout { margin-top: 0; }
.swatches { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.swatch { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; cursor: pointer; color: var(--ink-2); }
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch i { width: 22px; height: 22px; border-radius: 6px; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.swatch:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: var(--ink); font-weight: 600; }
.swatch:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.seg.full { display: flex; } .seg.full label { flex: 1; text-align: center; }
@media (max-width: 860px) { .appearance-btn { margin: 0 0 0 auto; white-space: nowrap; } .appearance-btn + .logout { margin-left: 0; } }
