:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f8f9f6;
  --border: #e3e5df;
  --border-strong: #cfd3ca;
  --text: #1c211e;
  --muted: #6b726c;
  --accent: #126b5a;
  --accent-hover: #0e594a;
  --accent-soft: #e3f0ec;
  --pos: #1b7f4c;
  --pos-soft: #e5f3ea;
  --neg: #c2412d;
  --neg-soft: #fbebe7;
  --trf: #4a5f8a;
  --warn: #9a6a00;
  --warn-soft: #fdf4dc;
  --bar-in: #2f9e66;
  --bar-out: #e07a5f;
  --grid: #eceee8;
  --side: #17201c;
  --side-text: #c9d1cb;
  --side-muted: #8a958e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 1px 1px rgba(20, 30, 25, .03);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121614;
    --surface: #1a201d;
    --surface-2: #1f2622;
    --border: #2b332e;
    --border-strong: #3a443e;
    --text: #e6ebe7;
    --muted: #8f9a93;
    --accent: #3fb394;
    --accent-hover: #55c6a7;
    --accent-soft: #1d3a32;
    --pos: #4cc285;
    --pos-soft: #18301f;
    --neg: #ef7d68;
    --neg-soft: #3a211c;
    --trf: #8da3d6;
    --warn: #e6b84a;
    --warn-soft: #3a3016;
    --bar-in: #3fb37a;
    --bar-out: #e88a70;
    --grid: #262d29;
    --side: #0d110f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font-size: 12.5px; }
small, .hint { color: var(--muted); font-size: 12.5px; }
.hint { margin: 10px 2px; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* ---------- Каркас ---------- */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; background: linear-gradient(to right, var(--side) 224px, transparent 224px); }
.side {
  background: var(--side);
  color: var(--side-text);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; padding: 2px 6px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: #126b5a; color: #fff; font-weight: 700; flex: none;
}
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--side-text);
}
.side nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.side nav a.active { background: rgba(63, 179, 148, .16); color: #fff; }
.side nav svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.side-add { width: 100%; }
.side-foot { margin-top: auto; padding: 0 10px; }
.link-btn { background: none; border: 0; color: var(--side-muted); cursor: pointer; padding: 0; font: inherit; }
.link-btn:hover { color: #fff; }
.main { padding: 24px 28px 48px; min-width: 0; max-width: 1480px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 40%, transparent); }
.btn-danger:hover { background: var(--neg-soft); border-color: var(--neg); }
.btn-in { color: var(--pos); }
.btn-out { color: var(--neg); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.push-right { margin-left: auto; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 10px; height: 36px; min-width: 0;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
input[type=checkbox] { height: auto; width: 16px; height: 16px; accent-color: var(--accent); }
input[type=file] { height: auto; padding: 8px; border: 0; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
label > input, label > select, label > textarea { color: var(--text); font-size: 14px; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.input-amount { font-size: 18px !important; font-weight: 600; height: 42px; }

.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-lg { display: flex; flex-direction: column; gap: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Карточки ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.table-card { padding: 0; overflow: hidden; }
.table-card > .card-head { padding: 14px 18px 0; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.card .empty { padding: 12px 0; text-align: left; }
.table-card .empty { padding: 28px; text-align: center; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; background: var(--pos-soft); color: var(--pos); border: 1px solid color-mix(in srgb, var(--pos) 25%, transparent); }
.flash-err { background: var(--neg-soft); color: var(--neg); border-color: color-mix(in srgb, var(--neg) 25%, transparent); }
.notice { display: block; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; background: var(--warn-soft); color: var(--warn); }
.tag { display: inline-block; font-size: 11.5px; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.tag-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table thead th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot th { background: var(--surface-2); border-top: 1px solid var(--border-strong); border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; }
.table tr[data-href] { cursor: pointer; }
.table tbody tr:hover td { background: var(--surface-2); }
.table.compact th, .table.compact td { padding: 7px 10px; }
.card > .table.compact { margin: -6px 0; }
.col-check { width: 34px; padding-right: 0 !important; }
.desc { max-width: 340px; color: var(--muted); }
.desc a { color: inherit; }
.is-archived td { opacity: .55; }
.is-editing td { background: var(--accent-soft) !important; }
.indent { padding-left: 30px !important; }
.group-row th { background: var(--surface-2); font-size: 12px; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; }
tr.warn td, tr.warn th { background: var(--warn-soft); }
.amt { font-weight: 600; }
.amt.trf { color: var(--trf); }

/* ---------- Фильтры ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; padding: 12px; }
.filters select, .filters input[type=search] { max-width: 220px; }
.filters input[type=search] { flex: 1 1 200px; max-width: 320px; }
.period { display: flex; gap: 6px; align-items: center; }
.period input[type=date] { width: 145px; }
.link-muted { color: var(--muted); font-size: 13px; }

.totals { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.totals > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; display: flex; flex-direction: column; min-width: 150px; }
.totals b { font-size: 17px; }
.totals .muted { font-size: 12px; }

.bulk-bar { display: flex; gap: 8px; align-items: center; padding: 10px 12px; background: var(--accent-soft); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.bulk-bar[hidden] { display: none; }
.bulk-bar select { height: 30px; }

.pager { display: flex; gap: 4px; margin-top: 14px; flex-wrap: wrap; }
.pager a { min-width: 32px; height: 32px; display: grid; place-items: center; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); }
.pager a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Форма операции ---------- */
.op-form { max-width: 760px; display: flex; flex-direction: column; gap: 18px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; align-self: flex-start; }
.seg label { flex-direction: row; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { padding: 7px 16px; border-radius: 7px; color: var(--muted); font-weight: 500; font-size: 14px; }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg-income input:checked + span { color: var(--pos); }
.seg-expense input:checked + span { color: var(--neg); }
.seg-transfer input:checked + span { color: var(--trf); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
[data-show][hidden] { display: none; }

/* ---------- Справочники ---------- */
.refs-layout { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.ref-form { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 16px; }
.danger-zone { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.merge { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; width: 100%; font-size: 13px; }
.merge select { flex: 1; height: 30px; }

/* ---------- Сводка ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); }
.kpi-main { background: #126b5a; border-color: #126b5a; color: #fff; }
.kpi-main .kpi-label { color: rgba(255, 255, 255, .78); }
.kpi-label { font-size: 12.5px; color: var(--muted); }
.kpi-value { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
.kpi-main .kpi-value { color: #fff; }
.kpi-value small { font-size: 13px; font-weight: 500; opacity: .75; color: inherit; }
.kpi-sub { font-size: 12.5px; color: var(--muted); }
.delta { font-weight: 600; margin-left: 4px; }
.delta.good { color: var(--pos); }
.delta.bad { color: var(--neg); }

.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.dash-grid > *, .kpis > *, .refs-layout > *, .import-grid > * { min-width: 0; }
.span-2 { grid-column: span 2; }
.dash-grid > .card:nth-child(2) { grid-row: span 1; }

.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .bar-in { fill: var(--bar-in); }
.chart .bar-out { fill: var(--bar-out); }
.chart g:hover rect { opacity: .85; }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.lg { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-left: 8px; }
.lg-in { background: var(--bar-in); }
.lg-out { background: var(--bar-out); }

.list-rows { list-style: none; margin: 0; padding: 0; }
.list-rows li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list-rows li:last-child { border-bottom: 0; }
.list-rows a { color: var(--text); }
.list-rows .total { font-weight: 600; border-top: 1px solid var(--border-strong); }

.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.hbars a { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; color: var(--text); }
.hbars a:hover { text-decoration: none; }
.hbars a:hover .hb-fill { background: var(--neg); }
.hb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-val { font-weight: 600; }
.hb-track { grid-column: 1 / -1; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.hb-fill { display: block; height: 100%; background: var(--bar-out); border-radius: 99px; }

/* ---------- ДДС ---------- */
.dds th, .dds td { padding: 7px 10px; font-size: 13.5px; }
.dds .sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 220px; font-weight: 500; text-align: left; }
.dds thead .sticky { background: var(--surface-2); }
.dds tbody tr:hover .sticky { background: var(--surface-2); }
.dds td a { color: var(--text); }
.dds td a:hover { color: var(--accent); }
.dds .zero { color: var(--border-strong); }
.dds .lvl-1 .sticky { padding-left: 28px; font-weight: 400; color: var(--muted); }
.dds .lvl-1 td { color: var(--muted); }
.dds .lvl-1 td a { color: var(--muted); }
.dds .sec-row th, .dds .sec-row td { font-weight: 700; border-top: 1px solid var(--border-strong); }
.dds .sec-income th, .dds .sec-income td { background: var(--pos-soft); color: var(--pos); }
.dds .sec-expense th, .dds .sec-expense td { background: var(--neg-soft); color: var(--neg); }
.dds .net-row th, .dds .net-row td { font-weight: 700; border-top: 2px solid var(--border-strong); }
.dds .bal-row th, .dds .bal-row td { background: var(--surface-2); font-weight: 600; }
.dds tr.warn .sticky { background: var(--warn-soft); }

/* ---------- Импорт ---------- */
.import-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.drop { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 22px; align-items: center; text-align: center; background: var(--surface-2); }
.bullets { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; color: var(--muted); }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px 16px; margin-bottom: 14px; }
.checks-row { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; align-items: start; }

/* ---------- Вход ---------- */
body.bare { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.auth-box { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: 0 10px 30px rgba(0, 0, 0, .06); display: flex; flex-direction: column; gap: 14px; }
.auth-box h1 { font-size: 20px; }
.brand-lg { color: var(--text); font-size: 17px; padding: 0; }
.checks { list-style: none; margin: 0; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; font-size: 13px; }
.checks .ok { color: var(--pos); }
.checks .bad { color: var(--neg); font-weight: 600; }

/* ---------- Адаптив ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .refs-layout { grid-template-columns: 1fr; }
  .ref-form { position: static; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: none; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; gap: 8px; }
  .side nav { flex-direction: row; overflow-x: auto; width: 100%; order: 3; }
  .side nav a span { display: none; }
  .side nav a { padding: 8px 12px; }
  .side-add { width: auto; margin-left: auto; height: 32px; }
  .side-foot { display: none; }
  .main { padding: 16px 16px 40px; }
  .kpis, .dash-grid, .grid-2, .import-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .filters select, .filters input { max-width: none; flex: 1 1 140px; }
  .period { flex-wrap: wrap; width: 100%; }
  .period input[type=date] { flex: 1; width: auto; }
}

/* ---------- Правила ---------- */
.apply-card { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.apply-card > div { flex: 1 1 320px; }

/* ---------- Вывод ---------- */
.payout-calc { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.payout-calc > div { background: var(--surface-2); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.payout-calc span { font-size: 12px; color: var(--muted); }
.payout-calc b { font-size: 16px; }
.payout-calc .payout-net { background: var(--accent-soft); }
.payout-calc .payout-net b { color: var(--accent); font-size: 18px; }
.seg-withdrawal input:checked + span { color: var(--accent); }
.tag-payout { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.dds .payout-row th, .dds .payout-row td { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.kpi-payout .kpi-value { color: var(--accent); }
@media (max-width: 760px) {
  .payout-calc { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .seg { flex-wrap: wrap; }
}
.btn-payout { color: var(--accent); }
.list-payout { margin-top: 14px; padding-top: 6px; border-top: 1px dashed var(--border-strong); }
b.accent { color: var(--accent); }
.dash-grid > .card > .kpi-sub { margin: 12px 0 0; }
.span-all { grid-column: 1 / -1; }
.accent { color: var(--accent); }

/* ---------- Регулярные платежи ---------- */
.chip { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; font-weight: 500; }
.chip-paid { background: var(--pos-soft); color: var(--pos); border-color: transparent; }
.chip-overdue { background: var(--neg-soft); color: var(--neg); border-color: transparent; }
.chip-today { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip-soon { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.small { font-size: 12.5px; }
.strong-link { font-weight: 600; color: var(--text); }
.due-table td { vertical-align: middle; }
.due-table .actions { text-align: right; white-space: nowrap; }
.due-table tr.is-overdue td { background: color-mix(in srgb, var(--neg-soft) 55%, transparent); }
.due-card { margin-bottom: 16px; }
.inline-form { display: inline-flex; gap: 6px; margin: 0; align-items: center; }
.link-plain { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.empty-state { display: flex; flex-direction: column; gap: 10px; max-width: 720px; }
.kpi-sub-inv { color: rgba(255, 255, 255, .75); }
.seg-sm { padding: 2px; }
.seg-sm a { padding: 4px 10px; border-radius: 6px; color: var(--muted); font-size: 13px; }
.seg-sm a:hover { text-decoration: none; color: var(--text); }
.seg-sm a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.rec-cal .sticky { min-width: 240px; }
.rec-cal .sticky a { color: var(--text); }
.rec-meta { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; }
.rec-cal th.is-current { color: var(--accent); }
.rec-cal td.cell-paid, .rec-cal td.cell-paid a { color: var(--pos); }
.rec-cal td.cell-overdue { color: var(--neg); font-weight: 600; background: color-mix(in srgb, var(--neg-soft) 60%, transparent); }
.rec-cal td.cell-skipped, .rec-cal td.cell-paused, .rec-cal td.cell-before { color: var(--muted); }
.rec-edit { display: grid; grid-template-columns: minmax(0, 760px) minmax(0, 1fr); gap: 16px; align-items: start; }
.rec-summary { align-self: start; margin-top: 21px; display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); min-height: 58px; }
.rec-summary:empty { visibility: hidden; }
.rec-summary b { color: var(--accent); }
.rec-summary span { color: var(--muted); font-size: 12.5px; }
.rec-banner { padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); font-size: 13.5px; }
.repeat-box { border: 1px dashed var(--border-strong); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.repeat-fields { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.repeat-fields .check { padding-bottom: 8px; }
.due-mini { list-style: none; margin: 14px 0 0; padding: 12px 0 0; border-top: 1px dashed var(--border-strong); display: flex; flex-direction: column; gap: 8px; }
.due-mini li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; font-size: 13.5px; }
.due-mini a { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1100px) {
  .rec-edit { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .repeat-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .due-table .actions { white-space: normal; }
}

/* ---------- Состояние системы ---------- */
.section-title { font-size: 17px; margin: 28px 0 14px; }
.status { margin: 0; padding: 9px 12px; border-radius: 8px; font-size: 13.5px; }
.status-ok { background: var(--pos-soft); color: var(--pos); }
.status-warn { background: var(--warn-soft); color: var(--warn); }
.status-bad { background: var(--neg-soft); color: var(--neg); }
.card-alert { border-color: var(--neg); box-shadow: 0 0 0 3px var(--neg-soft); }
.log-tail { margin: 0; padding: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; font-size: 11.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-all; max-height: 260px; overflow: auto; }
.backup-list li { font-size: 13px; padding: 5px 0; }
details summary { cursor: pointer; color: var(--accent); font-size: 13.5px; }

/* ---------- Роли счетов, план ---------- */
.tag-role-business { background: var(--surface-2); }
.tag-role-transit { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag-role-owner { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag-plan { background: var(--warn-soft); color: var(--warn); border-color: transparent; font-weight: 600; }
tr.is-plan td { background: color-mix(in srgb, var(--warn-soft) 45%, transparent); }
tr.is-plan .amt { opacity: .75; font-style: italic; }
.btn-confirm { height: 26px; padding: 0 9px; font-size: 12.5px; color: var(--pos); border-color: color-mix(in srgb, var(--pos) 45%, transparent); }
.btn-confirm:hover { background: var(--pos-soft); border-color: var(--pos); }
.grp-toggle { background: none; border: 0; padding: 0 4px 0 0; cursor: pointer; color: var(--muted); font: inherit; }
.grp-toggle[aria-expanded="true"] .grp-arrow { display: inline-block; transform: rotate(90deg); }
.grp-arrow { display: inline-block; transition: transform .15s; }
tr.grp-child td { background: var(--surface-2); font-size: 13px; border-bottom-style: dashed; }
tr.grp-child td.desc, tr.grp-child td { color: var(--muted); }
.amt-sub { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; }
.status-switch { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); }
.status-switch.is-plan { background: var(--warn-soft); border-color: transparent; }
.status-switch .check { font-weight: 600; }
.owner-flow td, .owner-flow th { white-space: nowrap; }
.owner-flow .col-net { background: var(--accent-soft); font-weight: 700; color: var(--accent); }
.kpi-row-mini { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi-row-mini b { color: var(--text); font-weight: 600; }
.totals-plan { background: var(--warn-soft) !important; border-color: transparent !important; }
.totals-plan b { font-size: 15px !important; display: flex; gap: 10px; }
.plan-sub { color: var(--warn) !important; font-weight: 500; }
.kpi-main .plan-sub { color: #ffe7a8 !important; }
.plan-list li { grid-template-columns: minmax(0, 1fr) auto auto auto; }
.plan-list .btn-confirm { height: 24px; padding: 0 7px; }
.totals-accent { background: var(--accent-soft) !important; border-color: transparent !important; }
.owner-flow thead th { white-space: normal; min-width: 92px; vertical-align: bottom; line-height: 1.3; }
.owner-flow thead th:first-child { min-width: 120px; }
