/* Темы (11.11.2026): светлая — по умолчанию, тёмная — кнопкой в меню (html[data-theme], cookie mf.theme). Цвета только
   токенами: в правилах ниже нет «голых» цветов, иначе тёмная тема оставит светлые пятна. */
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --surface-2: #fafbfc;
  --section-bg: #eef2f7;
  --soft: #eef1f5;
  --input-bg: #ffffff;
  --text: #1d2430;
  --muted: #6b7380;
  --line: #dde1e7;
  --accent: #1f5fae;
  --accent-fill: #1f5fae;
  --accent-ink: #ffffff;
  --accent-soft: #eaf1fb;
  --accent-soft-ink: #1f5fae;
  --accent-soft-2: #f4f8fd;
  --side-bg: #fbfcfd;
  --side-hover: #eef2f7;
  --ok-bg: #e7f5ec;
  --ok-ink: #1d6b3a;
  --ok-line: #bfe3cb;
  --err-bg: #fdeceb;
  --err-ink: #9b2c22;
  --danger: #b3362b;
  --danger-line: #f0c9c5;
  --warn-bg: #fff3d6;
  --warn-ink: #8a5a00;
  --warn-line: #f0d9a8;
  --warn-panel: #fffaf0;
  --locked-bg: #e8e8f3;
  --locked-ink: #44476b;
  --row-opening: #fbe4e2;
  --row-cash: #fff7d6;
  --row-closing: #e7f5ec;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  --overlay: rgba(16, 24, 40, 0.35);
  --radius: 8px;
  --sidebar-w: 236px;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12151b;
  --panel: #1b1f27;
  --surface-2: #20252e;
  --section-bg: #232a35;
  --soft: #262c36;
  --input-bg: #12161d;
  --text: #e6e9ef;
  --muted: #9aa3b2;
  --line: #2e3440;
  --accent: #6aa6ee;
  --accent-fill: #2f6fc0;
  --accent-ink: #ffffff;
  --accent-soft: #1d2d45;
  --accent-soft-ink: #a9cbf5;
  --accent-soft-2: #18222f;
  --side-bg: #161a21;
  --side-hover: #222833;
  --ok-bg: #16301f;
  --ok-ink: #6fd394;
  --ok-line: #24543a;
  --err-bg: #3a1d1b;
  --err-ink: #f29b92;
  --danger: #f07070;
  --danger-line: #6b2d28;
  --warn-bg: #3a2f12;
  --warn-ink: #e3b65c;
  --warn-line: #5c4a1f;
  --warn-panel: #2a2416;
  --locked-bg: #2a2b40;
  --locked-ink: #b7b9e0;
  --row-opening: #3a2222;
  --row-cash: #352f17;
  --row-closing: #17301f;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  --overlay: rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.45; }
input, select, textarea { color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0.2rem 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.6rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.5rem; }
code { background: var(--soft); padding: 0 4px; border-radius: 4px; font-size: 0.9em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.inline { display: inline; }

/* Раскладка (11.11.2026, как в Zelta): меню слева блоками, справа рабочая колонка; до 900px меню выезжает по кнопке. */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 20;
  display: flex; flex-direction: column; gap: 0.7rem; padding: 1rem 0.75rem 0.8rem;
  background: var(--side-bg); border-right: 1px solid var(--line); overflow-y: auto; transition: transform 0.2s ease;
}
.sidebar__brand { padding: 0 0.45rem 0.7rem; border-bottom: 1px solid var(--line); }
.sidebar__logo { font-weight: 700; font-size: 1.2rem; color: var(--text); }
.sidebar__logo:hover { text-decoration: none; }
.sidebar__subtitle { margin-top: 2px; font-size: 0.7rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }
.sidebar__tenant {
  display: flex; flex-direction: column; padding: 0.45rem 0.6rem; color: var(--text);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.sidebar__tenant:hover { border-color: var(--accent); text-decoration: none; }
.sidebar__tenant-name { font-weight: 600; }
.sidebar__tenant-role { font-size: 0.78rem; color: var(--muted); }
.sidenav { display: flex; flex-direction: column; gap: 2px; }
.sidenav__group { margin: 0.75rem 0.6rem 0.2rem; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.sidenav__link { display: block; padding: 0.4rem 0.6rem; border-left: 3px solid transparent; border-radius: 6px; color: var(--text); font-size: 0.93rem; }
.sidenav__link:hover { background: var(--side-hover); text-decoration: none; }
.sidenav__link.active { background: var(--accent-soft); color: var(--accent-soft-ink); border-left-color: var(--accent); font-weight: 600; }
.sidebar__bottom { margin-top: auto; padding-top: 0.7rem; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 0.45rem; }
.sidebar__user { padding: 0 0.45rem; font-size: 0.9rem; font-weight: 600; }
.btn--block { display: block; width: 100%; text-align: center; }
.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.main > .container { flex: 1; width: 100%; }
.mobilebar { display: none; }
.sidebar-overlay { position: fixed; inset: 0; z-index: 15; background: var(--overlay); }
.sidebar-overlay[hidden] { display: none; }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.is-open { transform: none; box-shadow: var(--shadow); }
  .main { margin-left: 0; }
  .mobilebar {
    display: flex; align-items: center; gap: 0.8rem; position: sticky; top: 0; z-index: 10;
    padding: 0.5rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line);
  }
  .mobilebar__brand { font-weight: 700; color: var(--text); }
}

.container { max-width: 1180px; margin: 0 auto; padding: 1.2rem; }
.footer { text-align: center; padding: 1rem; font-size: 0.8rem; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.grid-3 .panel { margin-bottom: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.card__title { font-weight: 600; }

.list { margin: 0; padding-left: 1.1rem; }
.steps li { margin: 0.25rem 0; }
.steps li.done { color: var(--ok-ink); }
.tag { display: inline-block; font-size: 0.75rem; background: var(--accent-soft); color: var(--accent-soft-ink); padding: 0 6px; border-radius: 4px; }
.tag--muted { background: var(--soft); color: var(--muted); }

.table { width: 100%; border-collapse: collapse; background: var(--panel); margin-bottom: 1rem; }
.table th, .table td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.table--compact th, .table--compact td { padding: 0.3rem 0.5rem; }
.row--inactive td { color: var(--muted); }

.form { display: flex; flex-direction: column; gap: 0.8rem; }
.form--row { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
.form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.form label.check { flex-direction: row; align-items: center; gap: 0.35rem; }
.form input[type="text"], .form input[type="email"], .form input[type="password"], .form input:not([type]), .form select {
  padding: 0.45rem 0.6rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; min-width: 200px;
  background: var(--input-bg); color: var(--text);
}
.checks { border: 1px dashed var(--line); border-radius: 6px; padding: 0.3rem 0.6rem; display: flex; gap: 0.6rem; flex-wrap: wrap; }
.checks legend { padding: 0 4px; }

.btn { display: inline-block; padding: 0.45rem 0.9rem; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn--primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--danger { color: var(--danger); border-color: var(--danger-line); }
.btn--small { padding: 0.2rem 0.55rem; font-size: 0.85rem; }
.btn--link { background: none; border: none; color: var(--accent); padding: 0; }

.flash { padding: 0.6rem 0.9rem; border-radius: 6px; margin-bottom: 1rem; }
.flash--ok { background: var(--ok-bg); color: var(--ok-ink); }
.flash--error { background: var(--err-bg); color: var(--err-ink); }
.copy-field { width: 100%; margin-top: 0.4rem; padding: 0.4rem; font-family: monospace; border: 1px solid var(--line); border-radius: 4px; background: var(--input-bg); }
.toast { position: fixed; right: 1rem; bottom: 1rem; background: var(--err-bg); color: var(--err-ink); padding: 0.7rem 1rem; border-radius: 6px; box-shadow: var(--shadow); }
.toast--ok { background: var(--ok-bg); color: var(--ok-ink); }

body.public { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.6rem 2rem; width: min(420px, 94vw); }
.auth-card__brand { font-size: 1.2rem; color: var(--accent); margin-bottom: 1rem; }

/* Справочники (E1): таблица из форм-строк — каждая строка своя форма, поэтому display: table, а не <table>. */
.container--wide { max-width: none; }
.mt { margin-top: 1rem; }
.warn { color: var(--warn-ink); }
.err { color: var(--err-ink); }
.tag--warn { background: var(--warn-bg); color: var(--warn-ink); }
.panel--warn { border-color: var(--warn-line); background: var(--warn-panel); }
.card--link { color: var(--text); }
.card--link:hover { border-color: var(--accent); text-decoration: none; }
.ref-scroll { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.ref-table { display: table; border-collapse: collapse; width: 100%; font-size: 0.85rem; }
.ref-tr { display: table-row; }
.ref-td { display: table-cell; padding: 0.2rem 0.3rem; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.ref-th .ref-td { font-weight: 600; color: var(--muted); padding: 0.45rem 0.3rem; background: var(--surface-2); }
.ref-td input[type="text"], .ref-td input[type="number"], .ref-td select {
  font: inherit; color: inherit; padding: 0.2rem 0.3rem; border: 1px solid transparent; border-radius: 4px; background: transparent; max-width: 100%;
}
.ref-td input[type="text"]:hover, .ref-td select:hover, .ref-td input[type="number"]:hover { border-color: var(--line); }
.ref-td input:focus, .ref-td select:focus { border-color: var(--accent); background: var(--input-bg); outline: none; }
.ref-td input.w-l { width: 16rem; }
.ref-td input.w-m { width: 11rem; }
.ref-td input.w-s { width: 6.5rem; }
.ref-td input.w-xs, .form input.w-xs { width: 4.5rem; min-width: 0; }
.form input.w-s { width: 8rem; min-width: 0; }
.ref-td select { max-width: 13rem; }
.ref-td--lvl1 { padding-left: 1.4rem; }
.ref-td--lvl2 { padding-left: 2.6rem; }
.ref-td--lvl3 { padding-left: 3.8rem; }
.ref-actions { text-align: right; }
.ref-new .ref-td { background: var(--accent-soft-2); border-bottom: none; }
.ref-tr--deleted .ref-td { opacity: 0.55; text-decoration: line-through; }
.ref-tr--deleted .ref-actions { opacity: 1; text-decoration: none; }
.ref-tr--saved .ref-td { animation: ref-saved 1.2s ease-out; }
.ref-tr--failed .ref-td { background: var(--err-bg); }
@keyframes ref-saved { from { background: var(--ok-bg); } to { background: transparent; } }
.pl-row--l0 td { font-weight: 700; background: var(--surface-2); }
.pl-row--l1 td:nth-child(2) { font-weight: 600; }
.pl-row--l2 td:nth-child(2) { padding-left: 1.4rem; }
.row--error td { background: var(--err-bg); }
.table--import { table-layout: fixed; }
.table--import td:nth-child(1) { width: 2rem; }
.table--import td:nth-child(2) { width: 18rem; }
.table--import td:nth-child(3) { width: 7.5rem; }

/* Касса (E2) */
.num { text-align: right; font-variant-numeric: tabular-nums; }
input.num { text-align: right; }
.tag--draft { background: var(--soft); color: var(--muted); }
.tag--submitted { background: var(--warn-bg); color: var(--warn-ink); }
.tag--checked { background: var(--ok-bg); color: var(--ok-ink); }
.tag--locked { background: var(--locked-bg); color: var(--locked-ink); }
.cash-actions { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.cash-actions .reason { display: flex; gap: 0.4rem; align-items: center; font-size: 0.9rem; }
.cash-actions .reason input { padding: 0.35rem 0.5rem; border: 1px solid var(--warn-line); border-radius: 6px; min-width: 18rem; font: inherit; background: var(--input-bg); }
.cash-totals__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0.8rem 1.2rem; align-items: start; }
.cash-total { display: flex; flex-direction: column; gap: 0.2rem; }
.cash-total b { font-size: 1.1rem; }
.cash-total--main b { font-size: 1.3rem; color: var(--accent); }
.cash-total input { font: inherit; padding: 0.3rem 0.4rem; border: 1px solid var(--line); border-radius: 6px; max-width: 11rem; background: var(--input-bg); }
.cash-note { grid-column: 1 / -1; display: flex; gap: 0.5rem; align-items: center; }
.cash-note input { flex: 1; font: inherit; padding: 0.3rem 0.4rem; border: 1px solid var(--line); border-radius: 6px; background: var(--input-bg); }
.cash-table .ref-td input.unmatched { border-color: var(--warn-line); background: var(--warn-panel); }

/* Импорт кассовой книги (E3): та же таблица из форм-строк, что в справочниках. */
.imp-label { white-space: normal; min-width: 14rem; max-width: 24rem; }
.imp-note { white-space: normal; max-width: 22rem; margin-top: 0.15rem; }
.imp-tr--none .ref-td, .imp-tr--conflict .ref-td { background: var(--warn-panel); }
.imp-tr--suggested .ref-td input[type="text"] { color: var(--warn-ink); }
/* ДДС по дням (E4.3): первая колонка и шапка закреплены, цвета строк — как в кассовой книге */
.panel--ok { border-color: var(--ok-line); background: var(--ok-bg); }
.cf-scroll { overflow: auto; max-height: 78vh; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.cf-table { border-collapse: separate; border-spacing: 0; font-size: 0.8rem; }
.cf-table th, .cf-table td { padding: 0.2rem 0.45rem; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); }
.cf-table thead th { position: sticky; top: 0; z-index: 2; font-weight: 600; color: var(--muted); vertical-align: bottom; }
.cf-table .cf-label { position: sticky; left: 0; z-index: 1; min-width: 16rem; max-width: 24rem; white-space: normal; border-right: 1px solid var(--line); text-align: left; }
.cf-table thead th.cf-label { z-index: 3; }
.cf-wd { font-weight: 400; font-size: 0.7rem; }
.cf-noday { opacity: 0.5; }
.cf-table td.cf-l1 { padding-left: 1.1rem; }
.cf-table td.cf-l2 { padding-left: 2rem; }
.cf-table td.cf-l3 { padding-left: 2.9rem; }
.cf-table .cf-balance td, .cf-table .cf-section td { font-weight: 700; }
.cf-table .cf-section td { background: var(--section-bg); }
.cf-table .cf-row-opening td { background: var(--row-opening); }
.cf-table .cf-row-cash td { background: var(--row-cash); }
.cf-table .cf-row-closing td { background: var(--row-closing); }
.cf-table .cf-group td { font-weight: 600; }
.cf-table .cf-detail td { color: var(--muted); font-size: 0.75rem; }
.cf-table .cf-total { font-weight: 600; border-left: 1px solid var(--line); }
/* P&L месяца (E5.2): заголовки блоков, итоговые строки, проценты */
.cf-table .pl-head td { font-weight: 700; background: var(--section-bg); text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.02em; }
.cf-table .pl-sum td { font-weight: 700; }
.cf-table .pl-pct td { color: var(--muted); font-style: italic; }
.cf-table .btn--link { padding: 0; text-align: left; font-size: inherit; }

/* Дашборд и графики (E9.0, 20; skill dataviz): тонкие метки, волосяные сетки и оси, цвет только у меток — текст
   токенами текста; выручка — акцент, расходы — приглушённый серый, итоги — тёмный шаг того же тона, выбранный месяц —
   акцент на светлом шаге (пары проверены validate_palette.js на поверхности #ffffff). Тёмная тема (11.11, DASH-06) —
   свои шаги того же синего, не инверсия: на тёмном «итог» светлее акцента, «прочие месяцы» темнее; проверено
   validate_palette.js на #1b1f27: --ordinal «#1c5cab,#5598e7,#9ec5f4» — PASS; соседние пары с серым — ΔE ≥ 15;
   «прочие месяцы» 2,49:1 (ниже 3:1, как и в светлой) — под каждым графиком есть таблица. Тексты прибыли/убытка ≥ 5,7:1. */
:root {
  --viz-surface: #ffffff;
  --viz-accent: #2a78d6;
  --viz-context: #86b6ef;
  --viz-total: #184f95;
  --viz-muted: #898781;
  --viz-grid: #e1e0d9;
  --viz-axis: #c3c2b7;
  --viz-ink-2: #52514e;
  --viz-good: #006300;
  --viz-bad: #d03b3b;
  --viz-hover: rgba(11, 11, 11, 0.04);
}
:root[data-theme="dark"] {
  --viz-surface: #1b1f27;
  --viz-accent: #5598e7;
  --viz-context: #1c5cab;
  --viz-total: #9ec5f4;
  --viz-muted: #898781;
  --viz-grid: #2c323d;
  --viz-axis: #3a414d;
  --viz-ink-2: #c3c2b7;
  --viz-good: #3fb950;
  --viz-bad: #f07070;
  --viz-hover: rgba(255, 255, 255, 0.06);
}
.viz { display: block; width: 100%; height: auto; overflow: visible; }
.viz--spark { max-width: 150px; height: 34px; margin-top: auto; }
.viz-grid { stroke: var(--viz-grid); stroke-width: 1; }
.viz-axis, .viz-connector { stroke: var(--viz-axis); stroke-width: 1; }
.viz-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz-tick--strong { fill: var(--text); font-weight: 600; }
.viz-note { fill: var(--muted); font-size: 10px; }
.viz-label { fill: var(--text); font-size: 12px; }
.viz-label--strong { font-weight: 600; }
.viz-value { fill: var(--viz-ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.viz-value--strong { fill: var(--text); font-weight: 600; }
.viz-bar--accent { fill: var(--viz-accent); }
.viz-bar--context { fill: var(--viz-context); }
.viz-bar--total { fill: var(--viz-total); }
.viz-bar--muted { fill: var(--viz-muted); }
.viz-hit { fill: transparent; }
.viz-mark:hover .viz-hit { fill: var(--viz-hover); }
.viz-mark:hover .viz-bar { opacity: 0.85; }
.viz-spark { fill: none; stroke: var(--viz-muted); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-dot { fill: var(--viz-accent); stroke: var(--viz-surface); stroke-width: 2; }
.viz-table { margin-top: 0.6rem; }
.viz-table summary { cursor: pointer; color: var(--accent); font-size: 0.85rem; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.8rem; margin-bottom: 0.6rem; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 0.9rem; display: flex; flex-direction: column; gap: 0.2rem; }
.kpi__label { font-size: 0.85rem; font-weight: 600; color: var(--muted); margin: 0; }
.kpi__value { font-size: 1.5rem; font-weight: 600; line-height: 1.2; }
.kpi__sub, .kpi__target { font-size: 0.78rem; color: var(--muted); }
.kpi__delta { font-size: 0.8rem; }
.kpi__delta--good, .kpi__status--ok { color: var(--viz-good); }
.kpi__delta--bad, .kpi__status--bad { color: var(--viz-bad); }
.kpi__delta--flat, .kpi__status--info { color: var(--muted); }
.kpi__status { font-weight: 600; }
.kpi__range { white-space: nowrap; }
.dash-source { margin: 0 0 0.8rem; }
.dash-extra { margin: 0 0 1rem; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); gap: 1rem; align-items: start; }
.dash-grid .panel { margin-bottom: 0; }
