/* Учёт «Товарищества» — стиль «бухгалтерская книга без цвета».

   Система (по taste-skill, app screens, стиль achromatic-ledger):
   - Оболочка без цвета: боковое меню на фоне страницы, активный пункт — серая плашка.
   - Фон страницы сине-серый, как у бланка (#f2f4f7); карточки белые, 1px граница, без теней.
   - Один цвет данных — синий #1d5fbf — только на главном числе/элементе экрана.
   - Деньги: поступления зелёные со знаком «+», расходы чернилами; красный — только сигнал.
   - Шрифт Geist, табличные цифры. Размеры: 24 заголовок · 16 раздел · 30 главная сумма · 14 текст · 12 подписи.
   - Радиусы: 8 у карточек, 6 у кнопок и полей. Один шаг сетки — 16px.
   Pico остаётся основой для форм и таблиц, его переменные переназначены ниже. */

/* Селектор той же силы, что у темы Pico, и ниже по файлу — поэтому побеждает. */
:root:not([data-theme=dark]), [data-theme=light] {
  --ground: #f2f4f7;
  --surface: #ffffff;
  --raised: #f7f8fa;
  --active: #e3e7ec;
  --border: #e3e6ea;
  --rule: #edf0f3;
  --control: #cfd4db;
  --text: #0a0a0a;
  --muted: #5d6470;
  --faint: #6b7280;
  --accent: #1d5fbf;          /* один цвет данных */
  --accent-soft: #e8effa;
  --primary: #141414;          /* главная кнопка почти чёрная */
  --primary-hover: #2e2e2e;
  --secondary-bg: #e7e9ec;
  --positive: #247b50;
  --negative: #c4242a;
  --warning: #92400e;
  --pill-positive-bg: #dcfae5; --pill-positive-ink: #04250e;
  --pill-negative-bg: #ffedea; --pill-negative-ink: #831c1e;
  --pill-warning-bg: #fff4d6; --pill-warning-ink: #7a3a0a;
  --pill-neutral-bg: #eceef1; --pill-neutral-ink: #3d424a;
  --seg-1: #3b4048; --seg-2: #7d838c; --seg-3: #a9aeb5; --seg-4: #cdd1d6;  /* серые доли полосы */

  --font: "Geist", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --fs-title: 24px; --fs-section: 16px; --fs-kpi: 30px; --fs-kpi-2: 20px; --fs-body: 14px; --fs-small: 12px;
  --radius-card: 8px; --radius-control: 6px;
  --gap: 16px; --card-pad: 20px; --pad: 32px;
  --sidebar-width: 248px; --nav-row: 32px; --control-height: 36px;
  --t-hover: 150ms;

  /* Pico */
  --pico-font-family: var(--font);
  --pico-font-family-sans-serif: var(--font);
  --pico-font-size: 14px;
  --pico-line-height: 1.45;
  --pico-font-weight: 400;
  --pico-background-color: var(--ground);
  --pico-color: var(--text);
  --pico-muted-color: var(--muted);
  --pico-muted-border-color: var(--border);
  --pico-primary: var(--text);
  --pico-primary-background: var(--primary);
  --pico-primary-border: var(--primary);
  --pico-primary-underline: rgba(10, 10, 10, .28);
  --pico-primary-hover: #000;
  --pico-primary-hover-background: var(--primary-hover);
  --pico-primary-hover-border: var(--primary-hover);
  --pico-primary-hover-underline: currentColor;
  --pico-primary-focus: rgba(29, 95, 191, .28);
  --pico-primary-inverse: #fff;
  --pico-secondary: var(--muted);
  --pico-secondary-background: var(--secondary-bg);
  --pico-secondary-border: var(--secondary-bg);
  --pico-secondary-hover: var(--text);
  --pico-secondary-hover-background: #dcdfe3;
  --pico-secondary-hover-border: #dcdfe3;
  --pico-secondary-focus: rgba(29, 95, 191, .2);
  --pico-secondary-inverse: var(--text);
  --pico-contrast: var(--text);
  --pico-border-radius: var(--radius-control);
  --pico-spacing: 16px;
  --pico-typography-spacing-vertical: 12px;
  --pico-block-spacing-vertical: 16px;
  --pico-block-spacing-horizontal: var(--card-pad);
  --pico-form-element-spacing-vertical: 7px;
  --pico-form-element-spacing-horizontal: 11px;
  --pico-form-element-background-color: #fff;
  --pico-form-element-border-color: var(--control);
  --pico-form-element-color: var(--text);
  --pico-form-element-placeholder-color: var(--faint);
  --pico-form-element-active-background-color: #fff;
  --pico-form-element-active-border-color: var(--accent);
  --pico-form-element-focus-color: rgba(29, 95, 191, .2);
  --pico-form-element-disabled-background-color: var(--raised);
  --pico-card-background-color: var(--surface);
  --pico-card-sectioning-background-color: var(--raised);
  --pico-card-box-shadow: none;
  --pico-box-shadow: none;
  --pico-table-border-color: var(--rule);
  --pico-table-row-stripped-background-color: transparent;
  --pico-code-background-color: var(--raised);
  --pico-text-selection-color: rgba(29, 95, 191, .18);
}

/* ---------- основа ---------- */
html { -webkit-text-size-adjust: 100%; }
body { background: var(--ground); color: var(--text); font-family: var(--font); font-size: var(--fs-body); line-height: 20px;
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 0; }
h1, h2, h3, h4 { font-family: var(--font); color: var(--text); letter-spacing: -0.01em; line-height: 1.25; text-wrap: balance; }
h1 { --pico-font-size: var(--fs-title); font-size: var(--fs-title); font-weight: 600; margin: 0; }
h2 { --pico-font-size: 18px; font-size: 18px; font-weight: 600; margin: 32px 0 12px; }
h3 { --pico-font-size: var(--fs-section); font-size: var(--fs-section); font-weight: 600; margin: 0 0 12px; }
p { text-wrap: pretty; }
small, .small-text { font-size: var(--fs-small); line-height: 16px; }
a { text-underline-offset: 3px; }
:where(a:not([role=button])) { color: var(--text); text-decoration-color: var(--pico-primary-underline); }
:where(a:not([role=button])):hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
code { font-size: 13px; }
table, .num, .kpi-value, .value { font-variant-numeric: tabular-nums; }

/* ---------- оболочка: боковое меню + холст ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 16px 12px 12px;
  overflow-y: auto; border-right: 1px solid var(--border); background: var(--ground); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 8px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.brand span { display: flex; flex-direction: column; line-height: 18px; }
.brand strong { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.brand small { color: var(--muted); font-size: var(--fs-small); }
.mark { flex: none; fill: none; stroke: var(--accent); stroke-width: 2; }
.mark circle:last-child { stroke: var(--text); }
.sidebar-nav, .sidebar-nav ul { display: block; margin: 0; padding: 0; list-style: none; }
.sidebar-nav li { display: block; list-style: none; margin: 0 0 2px; padding: 0; }
.sidebar-nav a.nav-item, .sidebar-foot a.nav-item { margin: 0; padding: 0 8px; }
.nav-group { margin: 22px 8px 6px; font-size: var(--fs-small); line-height: 16px; color: var(--faint); }
.nav-item { display: flex; align-items: center; gap: 10px; height: var(--nav-row); padding: 0 8px; border-radius: var(--radius-control);
  color: var(--muted); text-decoration: none; font-size: var(--fs-body); transition: background-color var(--t-hover), color var(--t-hover); }
.nav-item:hover { background: #e9ecf0; color: var(--text); }
.nav-item[aria-current="page"] { background: var(--active); color: var(--text); font-weight: 500; }
.nav-item span:first-of-type { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-count { flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--negative); color: #fff;
  font-size: var(--fs-small); font-weight: 500; line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-foot { margin-top: auto; padding-top: 16px; }
.user-row { display: flex; align-items: center; gap: 10px; margin: 6px 0 0; padding: 8px 8px 0; border-top: 1px solid var(--border); }
.avatar { flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  font-size: var(--fs-small); font-weight: 600; line-height: 24px; text-align: center; }
.user-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; margin: 0; padding: 0;
  border: 0; border-radius: var(--radius-control); background: transparent; color: var(--muted); cursor: pointer; }
.icon-button:hover { background: #e9ecf0; color: var(--text); }
.icon-button:focus { box-shadow: none; }
.sidebar-close, .phonebar { display: none; }

.canvas { min-width: 0; padding: 28px var(--pad) 64px; }
.canvas > * { max-width: 1280px; margin-left: auto; margin-right: auto; }
.canvas > .table-wrap, .canvas > .cashflow-wrap { max-width: 1280px; }

/* ---------- заголовок экрана ---------- */
/* Единый вид для hgroup, .page-head и старых nav с h1: заголовок слева, действия справа. */
.canvas > hgroup, .page-head, .canvas > nav:first-child, .title-row {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 20px; }
.canvas > hgroup { display: block; }
.canvas > hgroup > p, .title-row .sub, .page-head .sub { margin: 4px 0 0; color: var(--muted); font-size: var(--fs-body); font-weight: 400; }
.canvas > hgroup > p a { color: var(--text); }
.page-head h1, .page-head h2, .title-row h1 { margin: 0; font-size: var(--fs-title); font-weight: 600; }
.title-row .actions, .page-head .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.canvas > nav:first-child ul { margin: 0; padding: 0; align-items: center; gap: 4px; flex-wrap: wrap; }
.canvas > nav:first-child li { padding: 0; }
.canvas > nav:first-child h1 { margin: 0; }
.back { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 8px; color: var(--muted); font-size: var(--fs-small); text-decoration: none; }
.back:hover { color: var(--text); }

/* Переключатель (годы, подразделы): серый трек, белая активная плашка. */
.segmented { display: inline-flex; gap: 2px; padding: 3px; margin: 0; border-radius: 8px; background: #e4e7eb; list-style: none; }
.segmented li { list-style: none; padding: 0; margin: 0; }
.segmented a { display: block; padding: 5px 12px; border-radius: 6px; color: var(--muted); text-decoration: none; font-size: var(--fs-body); line-height: 20px; white-space: nowrap; }
.segmented a:hover { color: var(--text); }
.segmented a[aria-current="page"] { background: #fff; color: var(--text); font-weight: 500; box-shadow: 0 1px 2px rgba(16, 24, 40, .06); }

/* ---------- кнопки ---------- */
button, [type=submit], [type=button], [role=button] { font-weight: 500; font-size: var(--fs-body); line-height: 20px;
  border-radius: var(--radius-control); padding: 7px 14px; transition: background-color var(--t-hover), border-color var(--t-hover); }
button:active, [role=button]:active { transform: translateY(1px); }
button.outline, [role=button].outline, input[type=submit].outline,
button.secondary.outline, [role=button].secondary.outline {
  background: var(--surface); border: 1px solid var(--control); color: var(--text); }
button.outline:hover, [role=button].outline:hover { background: var(--raised); border-color: #b9bfc8; color: var(--text); }
button.secondary:not(.outline), [role=button].secondary:not(.outline) { background: var(--secondary-bg); border-color: var(--secondary-bg); color: var(--text); }
button.small, a.small[role=button], .small[role=button], button.small.outline { padding: 4px 10px; font-size: 13px; line-height: 18px; }
a.small:not([role=button]) { font-size: 13px; }
.link-button { background: none; border: 0; padding: 0; color: var(--text); text-decoration: underline; text-decoration-color: var(--pico-primary-underline); cursor: pointer; font-weight: 400; }
.danger { color: var(--negative) !important; }
button.danger.outline { border-color: #efc4c4; }

/* ---------- карточки ---------- */
article, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: none;
  padding: var(--card-pad); margin: 0 0 var(--gap); }
article > header, article > footer { margin: calc(var(--card-pad) * -1) calc(var(--card-pad) * -1) 16px; padding: 12px var(--card-pad);
  background: var(--raised); border-bottom: 1px solid var(--border); }
article > footer { margin: 16px calc(var(--card-pad) * -1) calc(var(--card-pad) * -1); border-top: 1px solid var(--border); border-bottom: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.panel-head h2, .panel-head h3 { margin: 0; font-size: var(--fs-section); font-weight: 600; }
.panel-head .meta, .meta { color: var(--muted); font-size: var(--fs-small); }
.panel-foot { margin: 12px 0 0; }
.card-link { display: inline-flex; align-items: center; gap: 2px; color: var(--text); font-weight: 500; font-size: 13px; text-decoration: none; }
.card-link::after { content: "→"; margin-left: 2px; }
.card-link:hover { text-decoration: underline; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.grid-2 > .panel, .grid-2 > .stack > .panel { margin: 0; display: flex; flex-direction: column; }
.grid-2 > .stack { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.grid-2 > .panel > .panel-foot { margin-top: auto; padding-top: 12px; }
/* Pico .grid из старых шаблонов */
.grid { gap: var(--gap); }

/* ---------- KPI: один контейнер, разделённый линиями ---------- */
.kpi-strip { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); padding: 0; margin: 0 0 var(--gap); overflow: hidden; }
.kpi-strip > div { padding: 16px var(--card-pad); border-left: 1px solid var(--border); min-width: 0; }
.kpi-strip > div:first-child { border-left: 0; }
.kpi-label { display: block; color: var(--muted); font-size: var(--fs-body); line-height: 20px; }
.kpi-value { display: block; margin-top: 4px; font-size: var(--fs-kpi-2); line-height: 28px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.kpi-note { display: block; margin-top: 4px; color: var(--muted); font-size: var(--fs-small); line-height: 16px; }
.kpi-note a { color: var(--text); }

/* Старые .kpis (Проекты, Счета, Члены): та же полоса из карточек без теней. */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0; align-items: stretch; margin-bottom: 24px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); overflow: hidden; }
.kpis > article { margin: 0; border: 0; border-left: 1px solid var(--border); border-radius: 0; padding: 16px var(--card-pad); }
.kpis > article:first-child { border-left: 0; }
.kpis article > small:first-child, .kpis article > .muted:first-child { display: block; color: var(--muted); font-size: var(--fs-body); }
.kpis .value { margin-top: 4px; font-size: var(--fs-kpi-2); line-height: 28px; font-weight: 600; letter-spacing: -0.01em; }
.kpis table { width: 100%; margin: 8px 0 0; display: table; }
.kpis td { padding: 4px 0; font-size: 13px; }
.kpis td.num { padding-left: 12px; }
@media (min-width: 900px) { .kpis .kpi-wide { grid-column: span 2; } }

/* ---------- деньги и сигналы ---------- */
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pos { color: var(--positive); }
.neg { color: var(--negative); }
/* В таблицах знак уже в тексте: расход пишется чернилами, красный остаётся сигналом вне таблиц. */
td.neg, td .neg:not(.flag), .cashflow td.neg { color: var(--text); }
td.neg a, .cashflow td a { color: inherit; }
.muted { color: var(--muted); }
.zero, td.muted { color: var(--faint); }
.flag { color: var(--negative); font-weight: 500; }
.hue { color: var(--accent); }

/* Статусы: бледная плашка с тёмным текстом того же тона. */
.st, .badge, .pill { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; border: 0;
  font-size: var(--fs-small); font-weight: 500; line-height: 22px; white-space: nowrap; flex: none;
  background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); }
.st-ok { background: transparent; color: var(--text); padding: 0; font-weight: 400; }
.st-warn, .badge.warn, .pill-warn { background: var(--pill-warning-bg); color: var(--pill-warning-ink); }
.st-bad { background: transparent; color: var(--faint); padding: 0; font-weight: 400; }
.badge.light { background: var(--pill-neutral-bg); color: var(--pill-neutral-ink); }
.pill-bad { background: var(--pill-negative-bg); color: var(--pill-negative-ink); }
.pill-ok { background: var(--pill-positive-bg); color: var(--pill-positive-ink); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--negative); margin-right: 6px; vertical-align: 1px; }

/* ---------- уведомления ---------- */
.notice, .flash { display: block; margin: 0 auto var(--gap); padding: 12px 16px; border-radius: var(--radius-card);
  border: 1px solid var(--border); background: var(--surface); font-size: var(--fs-body); }
.notice-success, .flash-success { border-color: #b7e4c7; background: #f1fbf4; color: #0d3b1e; }
.notice-error, .flash-error { border-color: #f3c4c1; background: #fff6f5; color: #6e1518; }
.notice-warning { border-color: #f3dfa2; background: #fffbeb; color: var(--warning); }
.flash ul, .notice ul { margin: 6px 0 0; padding-left: 18px; }
.flash p:last-child, .notice p:last-child { margin-bottom: 0; }

/* ---------- таблицы ---------- */
table { margin-bottom: var(--gap); font-size: var(--fs-body); --pico-background-color: transparent; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--rule); background: transparent; line-height: 20px; vertical-align: middle; }
thead th, thead td { padding-top: 8px; padding-bottom: 8px; color: var(--muted); font-size: var(--fs-small); font-weight: 400; line-height: 16px;
  border-bottom: 1px solid var(--border); white-space: nowrap; }
thead th.num { text-align: right; }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
tbody th { font-weight: 500; }
table.striped tbody tr:nth-child(odd) td, table.striped tbody tr:nth-child(odd) th { background: transparent; }
tbody tr:hover td { background: var(--raised); }
td small, th small { display: inline; color: var(--muted); }
td small.block, td .sub { display: block; color: var(--muted); font-size: var(--fs-small); line-height: 16px; margin-top: 2px; }
td a { text-decoration: none; }
td a:hover { text-decoration: underline; }
/* Таблица на белой карточке: отступы совпадают с краем карточки. */
.panel table, article table { margin: 0; }
.panel table td:first-child, .panel table th:first-child { padding-left: 0; }
.panel table td:last-child, .panel table th:last-child { padding-right: 0; }
.panel tbody tr:hover td { background: transparent; }
/* Таблица прямо на фоне — кладём её на белый лист. */
.table-wrap, .sheet { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-card); margin-bottom: var(--gap); }
.table-wrap > table, .sheet > table { margin: 0; }
.table-wrap td:first-child, .table-wrap th:first-child { padding-left: var(--card-pad); }
.table-wrap td:last-child, .table-wrap th:last-child { padding-right: var(--card-pad); }
.panel .table-wrap { border: 0; border-radius: 0; margin: 0; }
.panel .table-wrap td:first-child, .panel .table-wrap th:first-child { padding-left: 0; }
.panel .table-wrap td:last-child, .panel .table-wrap th:last-child { padding-right: 0; }
.table-wrap + p, .table-wrap + .note { margin-top: -4px; }
.note, p.muted > small:only-child { color: var(--muted); font-size: var(--fs-small); line-height: 16px; }
main article table { display: block; overflow-x: auto; }
main article .table-wrap table, main .kpis table { display: table; }
.table-total td { font-weight: 600; border-top: 1px solid var(--border); }

/* Пустое состояние: рамка остаётся, одна фраза. */
.empty { padding: 14px 16px; border: 1px dashed var(--control); border-radius: var(--radius-card); color: var(--muted); background: transparent; }
.empty a { color: var(--text); }

/* ---------- формы ---------- */
label { font-size: var(--fs-body); font-weight: 500; margin-bottom: 6px; }
label:has(input[type=checkbox]), label:has(input[type=radio]) { font-weight: 400; }
input:not([type=checkbox], [type=radio], [type=range], [type=file]), select, textarea {
  font-size: var(--fs-body); line-height: 20px; height: auto; min-height: var(--control-height); margin-bottom: 0; }
select { padding-right: 32px; }
textarea { min-height: 76px; }
input[type=file] { font-size: var(--fs-body); }
form > div, .form-grid > div { margin-bottom: 14px; }
form small, .helptext { display: block; margin-top: 4px; color: var(--muted); font-size: var(--fs-small); line-height: 16px; }
.errorlist { margin: 4px 0 0; padding: 0; list-style: none; color: var(--negative); font-size: var(--fs-small); }
.errorlist li { list-style: none; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 16px; }
.form-card { max-width: 1040px; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.form-actions button, .form-actions a { width: auto; margin: 0; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--negative); }
input[type=search] { border-radius: var(--radius-control); }
[role=search] { border-radius: var(--radius-control); }

/* Фильтры: одна строка контролов одной высоты. */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 auto var(--gap); }
.canvas .filters > * { width: auto; margin: 0; flex: 0 1 auto; }
.canvas .filters input[type=search] { flex: 1 1 260px; min-width: 200px; }
.canvas .filters select { flex: 0 1 240px; }
.canvas .filters button, .canvas .filters [role=button] { flex: none; }
.filters .spacer { flex: 1; }
.filters .count { color: var(--muted); }

details summary { font-size: var(--fs-body); }
details[open] > summary { margin-bottom: 8px; }
dl { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 8px 16px; margin: 0; }
dt { color: var(--muted); font-weight: 400; }
dd { margin: 0; }

/* Пагинация */
.pagination ul { display: flex; gap: 12px; align-items: center; justify-content: flex-start; margin: 0; padding: 0; }
.pagination li { list-style: none; padding: 0; }

/* ---------- Касса ---------- */
.free-panel { padding: 24px; }
.free-top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 24px; }
.free-figure { font-size: var(--fs-kpi); line-height: 36px; font-weight: 700; letter-spacing: -0.02em; color: var(--accent); white-space: nowrap; }
.free-figure.neg { color: var(--negative); }
.free-title { margin: 0; color: var(--muted); font-size: var(--fs-body); font-weight: 400; letter-spacing: 0; }
.free-caption { margin: 0; color: var(--muted); max-width: 46ch; }
.free-caption strong { color: var(--text); font-weight: 500; }
/* Фирменный элемент: деньги на счетах одной полосой — что занято и что свободно. */
.money-bar { display: flex; gap: 2px; height: 14px; margin: 20px 0 16px; border-radius: 3px; overflow: hidden; background: var(--rule); }
.money-bar span { min-width: 0; }
.money-bar .s-free { background: var(--accent); }
.money-bar .s-1 { background: var(--seg-1); } .money-bar .s-2 { background: var(--seg-2); }
.money-bar .s-3 { background: var(--seg-3); } .money-bar .s-4 { background: var(--seg-4); }
.money-legend { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; margin: 0; padding: 0; list-style: none; }
.money-legend li { list-style: none; padding: 0 16px; margin: 0; border-left: 1px solid var(--border); min-width: 0; }
.money-legend li:first-child { padding-left: 0; border-left: 0; }
.money-legend .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 1px; }
.money-legend .lbl { color: var(--muted); font-size: 13px; line-height: 18px; }
.money-legend .val { display: block; margin-top: 2px; font-size: 16px; line-height: 22px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.money-legend li.is-free .val { color: var(--accent); }
.kv { width: 100%; }
.kv td { padding: 7px 0; border-bottom: 1px solid var(--rule); }
.kv tr.head td { padding-top: 4px; font-weight: 600; }
.kv tr.head td.num { font-weight: 600; }
.kv tr.gap td { padding-top: 16px; }
.kv td.lbl { padding-left: 0; }
.kv td.sub-row { padding-left: 12px; color: var(--muted); }

/* ---------- Разноска ---------- */
.tx-table td { vertical-align: top; }
.tx-table .tx-date { white-space: nowrap; }
.tx-table .purpose { max-width: 28rem; color: var(--muted); }
.tx-table .cp { font-weight: 500; }
.tx-table tbody.done td { opacity: .6; }
.tx-table .form-row td { background: var(--raised); }
.tx-table tbody:hover td { background: var(--raised); }
.tx-table .tx-actions { white-space: nowrap; text-align: right; }
.tx-table .tx-actions > * { margin: 0 0 0 6px; vertical-align: middle; }
.suggestion strong { font-weight: 500; }
.suggestion small { display: block; }
.alloc-line { display: grid; grid-template-columns: 2fr 1.6fr 1.4fr 8rem 1.4fr auto; gap: 8px; align-items: start; margin-bottom: 8px; }
.alloc-line > * { margin-bottom: 0; }
.alloc-line .line-error { grid-column: 1 / -1; color: var(--negative); font-size: var(--fs-small); }
.alloc-actions { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-top: 12px; }
.alloc-actions > * { margin-bottom: 0; width: auto; }
.alloc-actions label { display: inline-flex; gap: 6px; align-items: center; margin: 0; font-weight: 400; }
.alloc-actions label small { display: inline; margin: 0; }
.alloc-actions .spacer { flex: 1; }
.alloc-errors { color: var(--negative); margin: 8px 0; }
.alloc-rest { font-weight: 500; }

/* ---------- Cash Flow ---------- */
.cashflow { font-size: 13px; }
.cashflow th, .cashflow td { padding: 8px 10px; }
.cashflow th:first-child, .cashflow td:first-child {
  position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 15rem; white-space: nowrap; }
.cashflow tbody tr:hover td { background: var(--raised); }
.cashflow tr.section th { padding-top: 18px; font-size: var(--fs-small); color: var(--muted); font-weight: 400; background: var(--surface); }
.cashflow tr.group td:first-child { padding-left: 32px; color: var(--muted); }
.cashflow tr.total td { font-weight: 600; border-top: 1px solid var(--border); }
.cashflow tr.balance td { font-weight: 600; background: var(--raised); }
.cashflow td a { text-decoration: none; }
.cashflow td a:hover { text-decoration: underline; }
.cashflow .now { background: var(--accent-soft) !important; }
.cashflow thead th.now { color: var(--accent); font-weight: 600; }
.cashflow .dot0 { color: #c3c8cf; }

/* ---------- вход ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; margin: 0; padding: 28px; }
.login-card .brand { margin-bottom: 24px; }
.login-card h1 { font-size: 20px; margin-bottom: 16px; }
.otp-qr svg { display: block; width: 200px; height: auto; margin: 8px 0; background: #fff; }
.login-card button { width: 100%; margin-top: 8px; }
.login-card p { margin-bottom: 14px; }

/* ---------- ничто не растягивает страницу вбок ---------- */
.canvas { overflow-wrap: break-word; }
main article { min-width: 0; }

/* ---------- планшет и телефон: меню складывается в шапку ---------- */
@media (max-width: 1024px) {
  .app { display: block; }
  .phonebar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 12px;
    background: var(--ground); border-bottom: 1px solid var(--border); }
  .phonebar-title { flex: 1; font-size: 16px; font-weight: 600; }
  .phonebar .mark { width: 24px; height: 24px; }
  .sidebar { display: none; }
  body.nav-open { overflow: hidden; }
  body.nav-open .sidebar { display: flex; position: fixed; inset: 0; z-index: 30; width: 100%; height: 100%; padding: 12px 16px 16px;
    border: 0; background: var(--ground); }
  body.nav-open .sidebar-close { display: inline-flex; }
  body.nav-open .nav-item { height: 44px; font-size: 16px; }
  body.nav-open .nav-group { margin-top: 18px; }
  .canvas { padding: 20px 20px 48px; }
}
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .money-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 14px; }
  .money-legend li { border-left: 0; padding-left: 0; }
  .money-legend li.is-free { grid-column: 1 / -1; order: -1; }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-strip > div { border-left: 0; border-top: 1px solid var(--border); }
  .kpi-strip > div:nth-child(-n+2) { border-top: 0; }
  .kpi-strip > div:nth-child(2n) { border-left: 1px solid var(--border); }
  .kpi-strip > div:last-child:nth-child(odd) { grid-column: 1 / -1; border-left: 0; }
  .alloc-line { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  :root { --pico-font-size: 15px; --card-pad: 16px; }
  body { font-size: 15px; }
  .canvas { padding: 16px 16px 40px; }
  h1, .page-head h1, .page-head h2, .title-row h1 { --pico-font-size: 22px; font-size: 22px; }
  input:not([type=checkbox], [type=radio], [type=range], [type=file]), select, textarea { font-size: 16px; min-height: 44px; }
  button, [role=button] { min-height: 40px; }
  .canvas .filters > * { flex: 1 1 0; min-width: 0; }
  .canvas .filters input[type=search] { flex: 1 1 100%; }
  .canvas .filters button, .canvas .filters [role=button] { flex: 0 0 auto; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis > article { border-left: 0; border-top: 1px solid var(--border); }
  .kpis > article:nth-child(-n+2) { border-top: 0; }
  .kpis > article:nth-child(2n) { border-left: 1px solid var(--border); }
  .kpis > article:last-child:nth-child(odd), .kpis .kpi-wide { grid-column: 1 / -1; border-left: 0; }
  .free-panel { padding: 16px; }
  .money-legend .val { font-size: 15px; }
  .segmented a { padding: 6px 10px; }
  dl { grid-template-columns: 1fr; gap: 2px; }
  dd { margin-bottom: 10px; }

  /* Разноска на телефоне: каждая операция — карточка из двух строк, действия снизу. */
  .tx-table, .tx-table tbody, .tx-table tr, .tx-table td { display: block; }
  .tx-table thead { display: none; }
  .tx-table tbody { border-bottom: 1px solid var(--rule); padding: 12px var(--card-pad); }
  .tx-table tbody:last-child { border-bottom: 0; }
  .tx-table tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
  .tx-table td { padding: 0 !important; border: 0; }
  .tx-table td.tx-date { grid-column: 1; grid-row: 2; color: var(--muted); font-size: 13px; }
  .tx-table td.tx-date small { display: none; }
  .tx-table td.num { grid-column: 2; grid-row: 1; font-weight: 600; }
  .tx-table td.tx-cp { grid-column: 1; grid-row: 1; }
  .tx-table td.purpose { grid-column: 1 / -1; grid-row: 3; margin-top: 4px; font-size: 13px; }
  .tx-table td.suggestion { grid-column: 1 / -1; grid-row: 4; margin-top: 6px; }
  .tx-table td.suggestion:has(> .muted:only-child) { display: none; }
  .tx-table td.tx-actions { grid-column: 1 / -1; grid-row: 5; margin-top: 10px; text-align: left; white-space: normal; }
  .tx-table td.tx-actions > * { margin: 0 6px 0 0; }
  .tx-table .form-row { display: block; }
  .tx-table .form-row td { margin-top: 12px; background: transparent; }
  .alloc-line { grid-template-columns: 1fr; }
}
.kv td.date-col { width: 4.5rem; color: var(--muted); }

/* Списки справочников */
td form { margin: 0; display: inline; }
td form button { width: auto; margin: 0; }
tr.inactive td { opacity: .55; }
td.actions, .actions-col { white-space: nowrap; text-align: right; }
tr.group-row td { padding-top: 18px; font-weight: 600; border-bottom: 1px solid var(--border); }
.tx-table .acc { max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-table .cp { font-weight: 500; text-decoration: none; }
.tx-table .cp:hover { text-decoration: underline; }
.tx-table td.num { font-weight: 500; }
.inline-title { margin: 0; font-size: var(--fs-section); }
.page-head hgroup { margin: 0; }
.page-head hgroup p { margin: 4px 0 0; color: var(--muted); font-size: var(--fs-body); }
.form-card .form-actions { padding-top: 4px; }
input.compact { min-height: 32px; padding: 4px 8px; margin: 0 0 6px; width: auto; }
/* Кнопка отправки формы — по ширине текста, а не во всю строку (Pico растягивает её). */
.canvas button[type=submit] { width: auto; }
.title-row form.filters { flex: 0 0 auto; flex-wrap: nowrap; margin: 0; }
.canvas .title-row .filters select { flex: none; width: auto; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.object-title { margin: 0 0 4px; font-size: 20px; }
.alloc-line .remove-line { justify-self: end; width: auto; }
/* История членства в карточке: на телефоне итог переносится под заголовок. */
.member-history .panel-head { flex-wrap: wrap; row-gap: 4px; }

/* Окно «Принять подсказку»: что будет записано. */
.accept-dialog article { max-width: 520px; width: 100%; }
.accept-dialog header p { margin: 4px 0 0; }
.accept-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 var(--gap); }
.accept-facts dt { color: var(--muted); font-weight: 400; }
.accept-facts dd { margin: 0; }
.accept-facts dd.num { text-align: left; }
.accept-dialog footer { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.accept-dialog footer button { width: auto; margin: 0; }
@media (max-width: 520px) {
  .accept-dialog footer button { flex: 1 1 0; padding-inline: 8px; }
}

/* Все операции: фильтр по датам и массовая смена статьи */
.filters .date-filter { display: inline-flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); white-space: nowrap; }
.filters .date-filter input { width: auto; margin: 0; }
.bulk-bar { position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  margin: 0 0 var(--gap); padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); }
.bulk-bar .bulk-all { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.bulk-bar .bulk-all input { margin: 0; }
.bulk-bar .bulk-target { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-left: auto; }
.bulk-bar select { width: auto; max-width: 18rem; margin: 0; }
.bulk-bar button { width: auto; margin: 0; }
.tx-table .check { width: 2.25rem; }
.tx-table.all-table tbody:hover td { background: none; }
.tx-table.all-table tr:hover { background: var(--raised); }
.tx-table .check input { margin: 0; }
@media (max-width: 640px) {
  .filters .date-filter { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .filters .date-filter input { flex: 1 1 auto; min-width: 0; }
  .tx-table.all-table tbody { padding: 0; border: 0; }
  .tx-table.all-table tr { grid-template-columns: auto 1fr auto; gap: 2px 0; padding: 12px var(--card-pad); border-bottom: 1px solid var(--rule); }
  .tx-table.all-table tr:last-child { border-bottom: 0; }
  .tx-table.all-table td.check { grid-column: 1; grid-row: 1 / span 2; margin-right: 12px; align-self: center; width: auto; }
  .tx-table.all-table td.tx-cp { grid-column: 2; grid-row: 1; font-weight: 500; }
  .tx-table.all-table td.num { grid-column: 3; grid-row: 1; margin-left: 12px; }
  .tx-table.all-table td.tx-date { grid-column: 2; grid-row: 2; }
  .tx-table.all-table td.tx-acc { grid-column: 3; grid-row: 2; margin-left: 12px; color: var(--muted); font-size: 13px; text-align: right; }
  .tx-table.all-table td.purpose { grid-column: 2 / -1; grid-row: 3; }
  .tx-table.all-table td.tx-alloc { grid-column: 2 / -1; grid-row: 4; margin-top: 4px; font-size: 13px; }
  .bulk-bar .bulk-target { margin-left: 0; width: 100%; }
  .bulk-bar select { flex: 1 1 100%; max-width: none; }
  .bulk-bar button { flex: 1 1 100%; }
}

/* Касса за период */
.period-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 16px; margin-bottom: 12px; }
.period-head h2 { margin: 0; }
.period-label { margin: 2px 0 0; font-size: 18px; font-weight: 600; color: var(--text); }
.period-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.period-arrows { display: inline-flex; align-items: center; gap: 6px; }
.period-arrows [role=button] { width: auto; margin: 0; min-width: 40px; }
.period-custom { margin: 0 0 16px; }
.period-custom summary { color: var(--muted); font-size: 14px; cursor: pointer; }
.period-custom form { margin: 8px 0 0; }
.period-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 32px; }
.period-balances td.num { white-space: nowrap; padding-left: 12px; }
@media (max-width: 760px) {
  .period-grid { grid-template-columns: 1fr; }
  .period-nav { width: 100%; justify-content: space-between; }
  .period-balances td { font-size: 14px; }
}

/* Список проектов: сортировка, действия в строке, карточки на телефоне */
.project-tabs { margin-bottom: 12px; }
.project-tabs .muted { margin-left: 4px; font-size: var(--fs-small); }
th a.sort { color: inherit; text-decoration: none; white-space: nowrap; }
th a.sort:hover { color: var(--text); }
th a.sort.asc::after { content: " ↑"; }
th a.sort.desc::after { content: " ↓"; }
.row-action { display: inline; width: auto; min-height: 0 !important; margin: 0 0 0 12px; padding: 0; border: 0; background: none;
  color: var(--muted); font-size: 13px; text-decoration: none; cursor: pointer; }
.row-action:hover { color: var(--text); text-decoration: underline; background: none; }
.row-action.danger:hover { color: var(--negative); }
.project-table .p-label { display: none; }
.project-table .p-date { white-space: nowrap; }
.project-table th, .project-table td { padding-left: 10px; padding-right: 10px; }
.project-table .p-actions > * { display: block; margin: 0; text-align: right; }
.project-table .p-actions .row-action { display: block; margin: 2px 0 2px auto; text-align: right; }
.page-head .actions .inline-form { margin: 0; }
.page-head .actions .inline-form button { margin: 0; }
.project-empty p { margin: 0 0 8px; }
.project-empty p:last-child { margin: 0; }
@media (max-width: 640px) {
  .project-tabs { display: flex; }
  .project-tabs li { flex: 1 1 0; text-align: center; }
  .project-table, .project-table tbody, .project-table tr, .project-table td { display: block; }
  .project-table thead { display: none; }
  .project-table tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px var(--card-pad); border-bottom: 1px solid var(--rule); }
  .project-table tr:last-child { border-bottom: 0; }
  .project-table td { padding: 0 !important; border: 0; text-align: left; }
  .project-table .p-name { grid-column: 1; grid-row: 1; font-weight: 500; }
  .project-table .p-result { grid-column: 2; grid-row: 1; text-align: right; font-weight: 600; }
  .project-table .p-code { grid-column: 1; grid-row: 2; font-size: 13px; }
  .project-table .p-status { grid-column: 2; grid-row: 2; text-align: right; }
  .project-table .p-kind { grid-column: 1; grid-row: 3; font-size: 13px; color: var(--muted); }
  .project-table .p-kind small.block { display: inline; margin-left: 4px; }
  .project-table .p-date { grid-column: 2; grid-row: 3; font-size: 13px; color: var(--muted); text-align: right; }
  .project-table .p-income, .project-table .p-expense { font-size: 13px; color: var(--muted); }
  .project-table .p-income { grid-column: 1; grid-row: 4; }
  .project-table .p-expense { grid-column: 2; grid-row: 4; text-align: right; }
  .project-table .p-label { display: inline; }
  .project-table .p-result .p-label { display: none; }
  .project-table .p-actions { grid-column: 1 / -1; grid-row: 5; width: auto; margin-top: 8px; white-space: normal; text-align: left; }
  .project-table .p-actions > *, .project-table .p-actions .row-action { display: inline; }
  .project-table .p-code, .project-table .p-date { white-space: normal; }
  .project-table .p-actions .row-action { margin: 0 16px 0 0; font-size: 14px; padding: 6px 0; }
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.panel-head h2 .meta { margin-left: 6px; font-weight: 400; }
.period-planned { margin-top: 8px; }
