/* app.css — единый стиль платформы (zero-build, без внешних запросов) */
/* Атрибут hidden всегда побеждает CSS-дисплеи (иначе модалы/подсказки с
   display:flex/block видны, даже когда скрыты) */
[hidden] { display: none !important; }

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #e2e5ea;
  --text: #1f2329;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --gray: #6b7280;
  --blue: #2563eb;
  --dark: #111827;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Шапка ---------- */
.topbar {
  background: #08182B;  /* фирменный darkNavy ONNEX (на месте var(--dark)) */
  color: #fff;
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  max-width: 1440px; margin: 0 auto; padding: 10px 14px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; text-decoration: none; line-height: 0; }
/* Логотип ONNEX на белой подложке (решение Стаса, 31.08): фирменный горизонтальный
   логотип, белая плашка отделяет его от тёмной шапки. Высота 34px, пропорции 3.4:1. */
.brand-logo {
  display: block; height: 34px; width: auto;
  background: #fff; padding: 4px 10px; border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.main-nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav-link { color: #cbd5e1; text-decoration: none; padding: 6px 10px; border-radius: 6px; }
.nav-link:hover { background: rgba(25,161,229,.22); color: #fff; }

.nav-admin { position: relative; }
.nav-admin-label { color: #fbbf24; padding: 6px 10px; cursor: default; }
.nav-admin-menu {
  display: none; position: absolute; right: 0; top: 100%; background: #fff; color: var(--text);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15); min-width: 200px; overflow: hidden;
}
.nav-admin:hover .nav-admin-menu { display: block; }
.nav-admin-menu a { display: block; padding: 9px 14px; color: var(--text); text-decoration: none; }
.nav-admin-menu a:hover { background: #f0f2f5; }

.topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; }

/* Колокольчик */
.bell { position: relative; }
.bell-btn {
  position: relative; display: inline-block; background: none; border: none;
  font-size: 20px; cursor: pointer; padding: 4px; text-decoration: none; color: #fff;
  line-height: 1;
}
.bell-icon { filter: grayscale(1) brightness(2); }
.bell-badge {
  position: absolute; top: -2px; right: -6px; background: var(--red); color: #fff;
  border-radius: 10px; font-size: 11px; padding: 1px 5px; line-height: 1.2;
}
.bell-panel {
  position: absolute; right: 0; top: 34px; width: 300px; max-width: 90vw;
  background: #fff; color: var(--text); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  z-index: 100; overflow: hidden;
}
.bell-title { padding: 10px 12px; font-weight: 600; border-bottom: 1px solid var(--border); }
.bell-item { padding: 8px 12px; border-bottom: 1px solid #f0f2f5; }
.bell-item-title { font-weight: 600; }
.bell-item-body { color: var(--muted); font-size: 13px; }
.bell-item-date { color: var(--muted); font-size: 11px; }
.bell-empty { padding: 16px; color: var(--muted); text-align: center; }
.bell-more { text-align: center; }
.bell-more a { color: var(--primary); text-decoration: none; font-weight: 600; font-size: 13px; }

.user-chip { text-align: right; line-height: 1.2; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { display: block; color: #9ca3af; font-size: 11px; }

.logout-form { margin: 0; }

/* ---------- Контейнер ---------- */
/* ТЗ 30.08 (F3): контейнер расширен до 1440px (решение заказчика, вопрос 2,
   вариант 1) — список заявок с 10 колонками помещается без среза. */
.container { max-width: 1440px; margin: 0 auto; padding: 18px 14px 60px; }
/* M10 (ТЗ admin_dashboards, 30.08): админ-разделы desktop-first до ~1600px.
   Блок container_class в base.html добавляет этот класс админ-шаблонам. */
.container-wide { max-width: 1600px; }
.footer {
  max-width: 1440px; margin: 0 auto; padding: 12px 14px; color: var(--muted); font-size: 12px;
  border-top: 1px solid var(--border);
}
.footer-links { float: right; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--primary); text-decoration: underline; }
.footer-sep { margin: 0 6px; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-block; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--border);
  background: #fff; color: var(--text); text-decoration: none; cursor: pointer; font-size: 14px;
  line-height: 1.3;
}
.btn:hover { background: #f0f2f5; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
/* TASK status_paid_done 02.09: жёлтая кнопка «Оплачено» (бухгалтер подтверждает
   факт оплаты на заявке «В оплате»). Тон — янтарный в стиле бейджа paid_done. */
.btn-amber { background: #f59e0b; border-color: #f59e0b; color: #fff; }
.btn-amber:hover { background: #d97706; border-color: #d97706; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f0f2f5; color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-xs { padding: 2px 8px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 14px; }
.btn-lg { padding: 10px 20px; font-size: 15px; }
/* ТЗ ui_fixes 01.09 (в.4.1): главные действия карточки «Одобрить»/«Отклонить» —
   крупные яркие кнопки, без иконок. Классы ставятся ТОЛЬКО на эти две кнопки
   (остальные кнопки action-bar остаются обычными). */
.btn-approve,
.btn-reject {
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 1px 3px rgba(16, 24, 40, .06);
}
.btn-approve { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn-approve:hover { background: #15803d; border-color: #15803d; }
/* «Вернуть в Доработку» — фиолетовый (решение Стаса 11.09; был красный #dc2626) */
.btn-reject { background: #6d28d9; border-color: #6d28d9; color: #fff; }
.btn-reject:hover { background: #5b21b6; border-color: #5b21b6; }
/* «А почему так?» — цвет Тиффани #0ABAB5 (ТЗ clarify_flow 18.09.2026, M2; правка
   заказчика 18.09.2026: «поменяй на цвет Тиффани»). Кнопка ГД: отправка заявки
   на уточнение ответственному. Ховер — на 8% темнее того же тона. */
.btn-clarify {
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 1px 3px rgba(16, 24, 40, .06);
  background: #0ABAB5;
  border-color: #0ABAB5;
  color: #fff;
}
.btn-clarify:hover { background: #09A19C; border-color: #09A19C; }

/* ---------- Карточки ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
}
.card-title { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }

/* ---------- Таблицы (редизайн 27.08; table_ux_v2 03.09 — 12.5px/компакт) ---------- */
.table-wrap {
  overflow-x: auto; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(16,24,40,.03), 0 1px 3px rgba(16,24,40,.04);
}
.table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 640px; }
/* ТЗ 30.08 (F3): широкие списки (заявки 10 колонок, секции главной) — минимум
   ширины под колонки, узкие окна получают нативный скролл внутри .table-wrap.
   table-layout: fixed — таблица всегда = ширине контейнера, длинный текст
   обрезается многоточием (text-overflow), колонки не «выталкивают» ширину.
   ТЗ table_ux_v2 03.09 (M0): шрифт 12.5px + компактные отступы позволяют
   уменьшить минимум ширины 1200px → ~1040px (ландшафт ноутбуков почти без скролла). */
/* ТЗ table_ux_v3 04.09: auto-layout давал «резиновость», НО px-ширины из админки
   (table_global_cols) при auto игнорируются на сжатие (колонка не уже контента) —
   жалоба заказчика 04.09 «колонки не изменяются». Вернули fixed: заданные ширины
   (CSS-дефолты + админ px из <style>) соблюдаются жёстко; колонки без ширины делят
   остаток (резиновость при скрытии сохраняется); контент сверх ширины — ellipsis. */
.table-wide { min-width: 0; table-layout: fixed; }
.table-wide td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Ширины колонок заявок по data-col (ТЗ table_ux_v2 03.09): селекторы по атрибуту
   вместо nth-child — при скрытии колонки шестерёнкой nth-child «съезжает» на соседа,
   атрибутный селектор устойчив. Фикс-минимум: короткие колонки — px, «Статья» —
   фикс 160px с переносом (название видно полностью, решение 4-1: wrap, без ellipsis),
   длинные текстовые (Контрагент/Отдел/Инициатор/Согласовал/Ступень) делят остаток. */
.table-wide th[data-col="number"] { width: 108px; }
.table-wide th[data-col="status"] { width: 126px; }
.table-wide th[data-col="amount"] { width: 112px; }
.table-wide th[data-col="pay_method"] { width: 44px; }
.table-wide th[data-col="payment_type"] { width: 160px; }
.table-wide th[data-col="due_date"] { width: 92px; }
.table-wide th[data-col="created"] { width: 140px; }
/* v3 (04.09): значение «Статьи» НЕ переносится (nowrap как у остальных);
   при нехватке места — ellipsis; ширина колонки — желаемая 160px (auto-layout
   расширит под контент, если таблица позволяет). */
/* Смайл типа оплаты (TASK payment_icons 01.09; express_ux 02.09, решение 2):
   узкая центрированная колонка «Оплата» ~36–44px (было 64px), смайл по центру,
   title-подсказка на ячейке сохраняется. Отдельный класс — без nth-child,
   чтобы не задеть колонки all_payments-полотна. */
.pay-icon-col { width: 44px; text-align: center; }
/* Центрирование смайла: .table td{text-align:left} специфичнее — усиливаем селектор
   (TASK express_ux 02.09, вердикт критика attempt1). */
table.table td.pay-icon-col { text-align: center; }
.table th.pay-icon-col,
.table td.pay-icon-col { padding-left: 2px; padding-right: 2px; }
.table th.pay-icon-col {
  font-size: 10px; letter-spacing: 0; white-space: normal;
  line-height: 1.15; overflow-wrap: anywhere; vertical-align: middle;
}
/* ⚡-маркер экспресс-платежа (статья «ЭКСПРЕСС», express_ux 02.09, решение 1):
   в начале строки, в ячейке № перед номером; у не-экспресс пусто — inline не
   сдвигает колонки (таблицы .table-wide с table-layout: fixed). */
.express-mark {
  display: inline-block; margin-right: 5px;
  font-size: 14px; line-height: 1; vertical-align: -1px;
}
.table th {
  background: #f8fafc; font-weight: 600; font-size: 10.5px; letter-spacing: .03em;
  color: var(--muted); white-space: normal; line-height: 1.25;
  padding: 7px 10px; border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  overflow-wrap: anywhere;
}
/* ТЗ 30.08 (F4): заголовки-сортировка. Значки ▲/▼/🔍 скрыты по умолчанию и
   появляются ТОЛЬКО при наведении на th (решение заказчика 30.08); на тач —
   по фокусу/первому тапу (:focus-within). Активная колонка подсвечена. */
/* Заголовок колонки — ОДНОЙ строкой (решение Стаса 04.09): при нехватке ширины —
   многоточие, без переноса. Кнопки сортировки/фильтра (▲▼🔍) — строкой ПОД названием,
   чтобы не теснить/не переносить заголовок. */
.th-inner { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.th-label { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; max-width: 100%; line-height: 1.25; }
.th-icons { display: inline-flex; align-items: center; gap: 2px; opacity: 0; transition: opacity .15s; }
.sortable:hover .th-icons,
.th-icons:focus-within { opacity: 1; }
.sortable.sort-on .th-icons { opacity: .65; }
.sortable.sort-on .th-label { color: var(--primary); }
.sortable.sort-on:hover .th-icons { opacity: 1; }
.th-sort {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; font-size: 10px; line-height: 1; text-decoration: none;
  color: var(--muted); border-radius: 3px; cursor: pointer;
}
.th-sort:hover { background: #e2e8f0; color: var(--text); }
.sortable.sort-on .th-sort { color: var(--primary); }
.th-filter-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; font-size: 10px; line-height: 1; border: none; background: none;
  color: var(--muted); border-radius: 3px; cursor: pointer; padding: 0;
}
.th-filter-btn:hover { background: #e2e8f0; color: var(--text); }
.th-filter { margin-top: 5px; }
.th-filter input {
  width: 100%; min-width: 90px; padding: 3px 6px; font-size: 12px;
  border: 1px solid var(--border); border-radius: 4px;
  text-transform: none; letter-spacing: normal; font-weight: 400; color: var(--text);
}
.th-filter input:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
.table th:first-child { border-radius: calc(var(--radius) - 1px) 0 0 0; }
.table th:last-child { border-radius: 0 calc(var(--radius) - 1px) 0 0; }
.table td { padding: 7px 10px; border-bottom: 1px solid #f0f2f5; text-align: left; vertical-align: middle; font-size: 12px; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: #f2f6ff; }
.clickable { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.total-row td { font-weight: 700; border-top: 2px solid var(--border); }

/* Массовые действия супер-админа (ТЗ admin_management, 31.08):
   чекбоксы в первой колонке списка /payments + липкая панель снизу. */
.bulk-col { width: 42px; text-align: center; }
.bulk-check {
  width: 24px; height: 24px; margin: 0; cursor: pointer;
  vertical-align: middle; accent-color: var(--primary);
}
.bulk-panel {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border: 1px solid var(--primary);
  border-radius: var(--radius);
  box-shadow: 0 -2px 10px rgba(16, 24, 40, .08);
  padding: 10px 14px; margin: 0 0 16px;
}
.bulk-count { font-weight: 600; font-size: 13.5px; }
.bulk-actions { display: flex; gap: 8px; }
.inline-form { display: inline-block; margin-right: 6px; }
.inline-form .btn { margin: 0; }

/* Секции главной: заголовок + счётчик + ссылка «Все» */
.home-section { margin-bottom: 8px; }
.home-section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin: 18px 0 8px; padding-bottom: 6px; border-bottom: 2px solid #eef1f5;
}
.home-section-head .section-title { margin: 0; font-size: 16px; font-weight: 700; color: var(--text); }
.home-section-meta { display: flex; align-items: center; gap: 8px; }
.badge-count {
  background: var(--primary); color: #fff; font-size: 11px; font-weight: 700;
  padding: 1px 8px; border-radius: 999px; min-width: 20px; text-align: center;
}
.section-more { font-size: 12.5px; color: var(--primary); text-decoration: none; font-weight: 600; }
.section-more:hover { text-decoration: underline; }

/* Карточки вместо таблиц на мобильных (без горизонтального скролла) */
@media (max-width: 640px) {
  .table-wrap { overflow: visible; background: transparent; border: none; box-shadow: none; }
  .table { min-width: 0; display: block; }
  .table-wide { min-width: 0; table-layout: auto; }
  .table-wide td { white-space: normal; overflow: visible; text-overflow: clip; max-width: none; }
  .table thead { display: none; }
  .table tbody { display: block; }
  .table tr { display: block; border: 1px solid var(--border); border-radius: 8px; background: var(--card); margin-bottom: 10px; padding: 8px 10px; }
  .table td { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid #f0f2f5; text-align: right; }
  .table td::before { content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left; }
  .table td.num { text-align: right; }
  /* .pay-icon-col на мобильных карточках: фикс-ширина 44px ломает flex-строку
     (эмодзи вылезает) — сбрасываем на auto (TASK express_ux 02.09, attempt1). */
  .table td.pay-icon-col { width: auto; }
  /* чекбокс массовых действий в «карточке»: отдельной строкой сверху */
  .table td.bulk-col { display: block; border: none; padding: 0 0 6px; text-align: left; }
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
}

/* ТЗ table_ux_v2 03.09 (M1, решение 2-1): ландшафт iPhone / iPad портрет
   (641–900px) — широкие таблицы ЗАЯВОК (.table-wide) переходят в карточный режим
   (заголовки столбцов видны как подписи карточек через data-label). Узкие .table
   (справочники/админка/справка) остаются таблицами до 640px, как раньше. */
/* v3 (04.09, правка Стаса): на iPhone landscape (641–900px) — ТАБЛИЦА, а не карточки
   (резиновый auto-layout + перенос заголовков + скролл контейнера). Карточки — только ≤640px. */

/* ---------- Бейджи ---------- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: #e5e7eb; color: #4b5563; }
.badge-dark { background: #1f2937; color: #fff; }
.badge-amber { background: #fef3c7; color: #b45309; }
/* «Закрывающие документы» — фиолетовый (решение Стаса, 31.08: отличать от «Согласовано»). */
.badge-violet { background: #ede9fe; color: #6d28d9; }
/* «Уточнение» — цвет Тиффани (ТЗ clarify_flow 18.09.2026, M2; правка 18.09:
   бейдж в той же гамме, что кнопка: светлая подложка + насыщенный текст). */
.badge-teal { background: #d9f6f4; color: #0a8f8b; }

/* ---------- Формы ---------- */
.form { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-weight: 600; margin-bottom: 4px; }
.req { color: var(--red); }
input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px;
  font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--primary); }
.readonly { background: #f3f4f6; color: var(--muted); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--red); }
.field-error { color: var(--red); font-size: 12px; margin-top: 3px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 3px; }
.form-actions { margin-top: 16px; display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form { display: inline; }

/* ---------- Разрешения ролей (role_permissions, 30.08) ---------- */
.perm-details { border: 1px solid var(--border); border-radius: 8px; background: var(--card); margin-bottom: 10px; }
.perm-details summary {
  cursor: pointer; padding: 10px 12px; font-weight: 600; font-size: 14px;
  list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.perm-details summary::-webkit-details-marker { display: none; }
.perm-details summary::after { content: '▾'; color: var(--muted); }
.perm-details[open] summary::after { content: '▴'; }
.perm-form { padding: 0 12px 12px; }
.perm-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 8px 0; border-top: 1px solid #f0f2f5;
}
.perm-name { font-weight: 600; font-size: 13px; min-width: 150px; }
.perm-check { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; }
.perm-check input { width: auto; }
.perm-select { width: auto; min-width: 150px; font-size: 13px; }
/* M9 (ТЗ admin_dashboards, 30.08): чекбоксы скоупа разрешения (отделы/типы)
   вместо <select multiple> — сплошная сетка галочек на десктопе */
.perm-scope { flex: 1 1 220px; min-width: 200px; }
.perm-scope-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 4px;
}
.perm-scope-title {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .4px; color: var(--muted);
}
.perm-toggle { display: inline-flex; gap: 4px; }
.perm-checkboxes {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 2px 10px;
}
.perm-checkbox {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; line-height: 1.4; padding: 1px 2px;
}
.perm-checkbox input { width: auto; margin: 0; }
@media (max-width: 640px) {
  .perm-row { flex-direction: column; align-items: stretch; }
  .perm-select { width: 100%; }
  .perm-checkboxes { grid-template-columns: 1fr 1fr; }
}
.flashes { margin-bottom: 14px; }
.flash {
  position: relative; padding: 10px 32px 10px 12px; border-radius: 6px; margin-bottom: 8px;
  transition: opacity .4s;
}
.flash-hide { opacity: 0; }
.flash-close {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  border: 0; background: none; font-size: 16px; line-height: 1; cursor: pointer;
  opacity: .55; color: inherit; padding: 2px 4px;
}
.flash-close:hover { opacity: 1; }
.flash-success { background: #dcfce7; color: #15803d; }
.flash-error { background: #fee2e2; color: #b91c1c; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---------- Дашборд ---------- */
.page-title { font-size: 22px; margin: 0 0 14px; }
.section-title { font-size: 16px; margin: 20px 0 8px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card {
  display: block; position: relative; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-decoration: none; color: var(--text);
  box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  transition: box-shadow .15s ease, border-color .15s ease;
}
.stat-card:hover { border-color: var(--primary); box-shadow: 0 2px 6px rgba(37,99,235,.12); }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }
.stat-new {
  position: absolute; top: 8px; right: 8px;
  background: #dc2626; color: #fff; border-radius: 999px;
  font-size: 11px; font-weight: 700; line-height: 1; padding: 3px 7px;
}
@media (max-width: 640px) {
  .stat-new { top: 6px; right: 6px; font-size: 10px; padding: 3px 6px; }
}
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
/* Правая группа тулбара («+ Новая заявка», ТЗ table_ux_v2 03.09) */
.toolbar-actions { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- Блоки главной (ТЗ dashboard_blocks, 01.09) ---------- */
.admin-blocks-table { min-width: 0; }
.admin-blocks-table td { white-space: nowrap; }
.admin-blocks-table .col-pos { width: 80px; }
.admin-blocks-table .col-enabled { width: 110px; text-align: center; }
.admin-blocks-table .col-move { width: 130px; }
.block-label { font-weight: 600; margin-right: 8px; }
.block-key { font-size: 12px; }
.admin-blocks-arrows { display: inline-flex; gap: 6px; }
.admin-blocks-arrows form { display: inline; margin: 0; }
.admin-blocks-arrows .btn { padding: 4px 10px; min-width: 34px; }

/* Админка «Колонки таблиц» (ТЗ table_global_cols, 04.09, M2) */
.admin-table-cols-table { min-width: 0; }
.admin-table-cols-table td { white-space: nowrap; }
.admin-table-cols-table .col-visible { width: 120px; text-align: center; }
.admin-table-cols-table .col-px { width: 210px; }
.admin-table-cols-table .col-px input { width: 120px; font-size: 13px; }
.col-label { font-weight: 600; margin-right: 8px; }

/* ---------- Фильтры ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select, .filters input { width: auto; max-width: 100%; }

/* ---------- Деталь ---------- */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.detail-status { margin-top: 6px; }
.action-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: flex-start; }
.reject-form { display: block; width: 100%; }
.reject-form textarea { width: 100%; }
.kv td { padding: 5px 8px; vertical-align: top; }
.kv td:first-child { color: var(--muted); width: 40%; }
.big { font-size: 20px; font-weight: 700; }
.attach-list { margin: 0; padding-left: 18px; }

/* ---------- Таймлайн ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.tl-item { position: relative; padding: 0 0 16px 26px; }
.tl-item::before {
  content: ''; position: absolute; left: 8px; top: 4px; bottom: 0; width: 2px; background: var(--border);
}
.tl-item:last-child::before { display: none; }
.tl-item::after {
  content: ''; position: absolute; left: 4px; top: 6px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--gray);
}
.tl-approved::after { background: var(--green); }
.tl-rejected::after { background: var(--red); }
.tl-skipped::after { background: var(--gray); }
.tl-current::after { background: var(--blue); }
.tl-docs::after { background: var(--green); }
.tl-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tl-role { font-weight: 600; }
.tl-comment { color: var(--muted); margin-top: 4px; }

/* ---------- Админ-конструктор ---------- */
.pos-cell { text-align: center; font-variant-numeric: tabular-nums; }
.pos { font-weight: 600; }
.rule-card { position: relative; }
.rule-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.rule-name { font-weight: 700; font-size: 16px; }
.step-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.step-row select { max-width: 260px; }
.step-row input { flex: 1; }
.steps-title { font-weight: 600; margin: 10px 0 8px; }

/* ---------- Вход ---------- */
.login-body { background: linear-gradient(160deg, #0f172a, #1e293b); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-wrap { width: 100%; padding: 20px; }
.login-card { max-width: 420px; margin: 0 auto; background: #fff; border-radius: 12px; padding: 26px; box-shadow: 0 12px 40px rgba(0,0,0,.3); }
/* Служебный знак «*» в правом нижнем углу страницы входа — ведёт на /login/dev
   (админский dev-вход под мастер-ключом; решение Стаса, 01.09). */
.login-dev-link {
  position: fixed; right: 14px; bottom: 10px;
  color: rgba(255,255,255,.28); text-decoration: none;
  font-size: 16px; line-height: 1; padding: 4px 8px; border-radius: 4px;
  z-index: 10;
}
.login-dev-link:hover { color: rgba(255,255,255,.75); background: rgba(255,255,255,.1); }
.login-brand { font-size: 26px; font-weight: 700; color: var(--dark); }
.login-brand span { color: var(--primary); }
.login-sub { color: var(--muted); margin: 4px 0 18px; }
.user-option {
  display: flex; align-items: center; gap: 10px; border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer;
}
.user-option:hover { border-color: var(--primary); }
.user-option-name { font-weight: 600; }
.user-option-meta { margin-left: auto; color: var(--muted); font-size: 13px; }

/* ---------- Ошибки ---------- */
.err-wrap { display: flex; justify-content: center; padding-top: 60px; }
.err-card { max-width: 480px; text-align: center; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 40px; }
.err-code { font-size: 56px; font-weight: 800; color: var(--muted); }
.err-message { font-size: 18px; margin: 8px 0 12px; }

/* ---------- Разбивка/вложения ---------- */
.budget-lines { margin-bottom: 8px; }
.budget-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.budget-row select { max-width: 320px; }
.budget-row input { flex: 1; }
.attachments-list { margin-top: 8px; }
.attach-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: #f8fafc; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 6px; }
.attach-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Зона drag-and-drop вложений (ТЗ dnd 09.09, M0/M1) ---------- */
/* Форма заявки: блок «Вложения» — dropzone (клик = выбор файла, дроп — загрузка). */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  background: #fafbfc;
}
.dropzone #attach-input { display: none; }
.dropzone .dz-title { display: block; font-weight: 600; font-size: 13px; }
.dropzone .dz-hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
/* Карточка заявки: блок «Вложения» — зона прикрепления (M1). */
.dropzone-card {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
}
.dropzone.dz-over, .dropzone-card.dz-over {
  background: #eef4ff;
  border-color: var(--blue);
}
.attach-add { cursor: pointer; font-weight: 600; color: var(--text); }
.attach-add input[type="file"] { display: none; }

/* ---------- График «Затраты по месяцам» ---------- */
.costs-card { margin-top: 18px; }
.costs-chart { margin-top: 10px; overflow-x: auto; }
.costs-chart svg { display: block; max-width: 100%; height: auto; }

/* ---------- Автокомплит справочников (контрагент/проект) ---------- */
.autocomplete-group { position: relative; }
.autocomplete-suggestions {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 60;
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,.12); max-height: 220px; overflow-y: auto;
  margin-top: 2px;
}
.autocomplete-option {
  padding: 8px 10px; cursor: pointer; border-bottom: 1px solid #f0f2f5;
  font-size: 13px;
}
.autocomplete-option:last-child { border-bottom: none; }
.autocomplete-option:hover { background: #f0f2f5; }
.autocomplete-recent-title {
  padding: 6px 10px; font-size: 11px; font-weight: 600;
  color: #8a94a6; text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 1px solid #f0f2f5; background: #fafbfc;
}

/* Блок «Новый контрагент/проект» */
.new-entity {
  margin-top: 8px; padding: 10px 12px; background: #f8fafc;
  border: 1px dashed var(--border); border-radius: 6px;
}
.new-entity-title { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.new-entity-input { margin-bottom: 6px; max-width: 420px; }
.new-entity-btn { margin-top: 2px; }
.new-entity-error { margin-top: 4px; }

/* Мобильная вёрстка: подсказки не разваливаются, инпуты на всю ширину */
@media (max-width: 640px) {
  .autocomplete-suggestions { max-height: 180px; }
  .new-entity-input { max-width: none; }
}

/* ---------- TASK_FIX8: центр уведомлений, дашборды (светлая тема Stripe/Linear) ---------- */

/* Центр уведомлений */
.notif-unread { background: #f0f6ff; }
.notif-title { font-weight: 600; }
.notif-body { color: var(--muted); font-size: 13px; margin-top: 2px; }
.pagination {
  display: flex; align-items: center; gap: 10px; margin: 14px 0;
  color: var(--muted); font-size: 13px;
}
.pagination a {
  display: inline-block; padding: 4px 10px; border: 1px solid var(--border);
  border-radius: 6px; text-decoration: none; color: var(--text); background: #fff;
}
.pagination a:hover { border-color: var(--primary); color: var(--primary); }

/* Дашборд: сетка графиков (Chart.js), карточки */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.chart-card { margin-bottom: 0; }
.chart-box { position: relative; height: 240px; margin-top: 10px; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

/* Аналитика (M8): итоги одобренных — сетка компактных плиток */
.totals-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.total-box {
  border: 1px solid var(--border); border-radius: 8px;
  background: #f8fafc; padding: 12px 14px;
}
.total-value { font-size: 20px; font-weight: 700; }
.total-label { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* Блок «Траты отдела» (Блок B) в форме заявки */
.dept-costs-total {
  padding: 8px 0 0; text-align: right; color: var(--text);
  border-top: 2px solid var(--border); margin-top: 4px; font-size: 14px;
}
#dept-costs-table .clickable { cursor: pointer; }
#dept-costs-table tr:hover { background: #f8fafc; }

/* ---------- TASK_FIX8: фильтры дашборда, таблица затрат, предпросмотр ---------- */

/* Мультиселект-фильтры дашборда — стиль Power BI (слайсеры-чипы) */
.dash-filters {
  margin: 0 0 16px; padding: 10px 14px;
  background: var(--card); border: 1px solid var(--border); border-radius: 4px;
}
.dash-filters-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.dash-filters-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted);
}
.dash-filters-reset { font-size: 12px; color: var(--muted); text-decoration: none; }
.dash-filters-reset:hover { color: var(--primary); text-decoration: underline; }
.dash-filters-grid {
  display: flex; flex-wrap: wrap; gap: 12px 22px;
}
.filter-field { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.filter-label {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .4px; color: var(--muted);
}
.chip-list { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--border); border-radius: 3px;
  padding: 2px 8px; font-size: 12px; line-height: 1.5;
  cursor: pointer; background: #fff; user-select: none;
  transition: border-color .12s, background .12s, color .12s;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:hover { border-color: var(--primary); }
.chip-on { background: #1b4b7b; border-color: #1b4b7b; color: #fff; }
.chip-on:hover { background: #16395e; }
.dash-filters-active {
  margin-top: 8px; padding: 5px 8px; background: #eff6ff;
  border: 1px solid #bfdbfe; border-radius: 3px; color: #1d4ed8; font-size: 12px;
}

/* Сликеры-списки фильтров дашборда: аккуратные формы, мелкий текст, скругление */
.dash-filters-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.filter-field { display: block; }
.filter-label {
  display: block; font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .4px; color: var(--muted); margin-bottom: 3px;
}
.filter-select {
  width: 100%; min-height: 76px; font-size: 12px; line-height: 1.4;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 4px 6px; background: #fff; color: var(--text);
}
.filter-select:focus { outline: none; border-color: var(--primary); }
.filter-select option { font-size: 12px; padding: 1px 3px; }

/* Индикатор «не сданы закрывающие документы» (п.5) */
.stat-warn { background: #fffbeb; border-color: #fde68a; }
.stat-warn .stat-value { color: #b45309; }

/* Поле «Платёжное поручение» в форме mark-paid (п.6) */
.file-inline {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted);
}
.file-inline input[type=file] { max-width: 240px; }

/* Таблица затрат над заявкой — информационная панель (компактная) */
.cost-panel {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 14px 10px; margin: 12px 0 14px; background: #fbfcfe;
}
.cost-panel-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted); margin-bottom: 6px;
}
.cost-summary {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
}
@media (max-width: 900px) { .cost-summary { grid-template-columns: 1fr; } }
.cost-col { border-right: 1px solid var(--border); padding-right: 14px; }
.cost-col:last-child { border-right: none; padding-right: 0; }
@media (max-width: 900px) { .cost-col { border-right: none; padding-right: 0; } }
.cost-col-title { margin: 0 0 4px; font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.cost-name { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.cost-summary .kv td { font-size: 12px; padding: 1px 0; }
.cost-recent-title { font-size: 11px; font-weight: 600; color: var(--muted); margin: 8px 0 3px; }
.cost-recent { margin: 0; padding-left: 16px; font-size: 12px; }
.cost-recent li { margin-bottom: 2px; }
.cost-recent a { color: var(--primary); text-decoration: none; }
.cost-recent a:hover { text-decoration: underline; }

/* Модальное окно предпросмотра вложений (п.3) */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center; z-index: 200;
  padding: 20px;
}
.modal {
  background: #fff; border-radius: 10px; width: 92vw; max-width: 860px;
  max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body {
  padding: 16px; overflow: auto; display: flex; align-items: center;
  justify-content: center; flex: 1; background: #f8fafc;
}
.preview-img { max-width: 100%; max-height: 70vh; display: block; }
.preview-unavailable { color: var(--muted); padding: 40px; text-align: center; }

/* Предпросмотр вложений (ТЗ preview_files, 28.08): PDF.js canvas, SheetJS,
   txt/csv. Модальное тело по умолчанию центрирует flex-контейнер; для
   таблиц/canvas/текста — блок-раскладка, скролл внутри. */
.preview-body-block { display: block; align-items: initial; justify-content: initial; }
.preview-unavailable .preview-dl { margin-top: 12px; display: inline-block; }
.preview-open-new { margin-top: 12px; display: inline-block; }

.modal-nav { display: flex; align-items: center; gap: 8px; margin: 0 8px 0 auto; }
.modal-nav .btn-xs { white-space: nowrap; }
.preview-pdf-counter { font-size: 13px; color: var(--muted); white-space: nowrap; }

.preview-pdf { width: 100%; }
.preview-pdf canvas { display: block; margin: 0 auto; box-shadow: 0 1px 4px rgba(15, 23, 42, .18); background: #fff; }

.preview-xlsx { width: 100%; }
.preview-sheets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.preview-sheet-btn {
  min-height: 36px; padding: 4px 12px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; color: var(--text); cursor: pointer; font-size: 13px;
}
.preview-sheet-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.preview-xlsx-scroll { overflow-x: auto; max-width: 100%; background: #fff; }
.preview-xlsx table { border-collapse: collapse; font-size: 13px; }
.preview-xlsx td, .preview-xlsx th { border: 1px solid #dbe1e8; padding: 4px 8px; white-space: nowrap; }
.preview-xlsx th { background: #f1f5f9; font-weight: 600; }

.preview-text { width: 100%; }
.preview-text pre {
  margin: 0; padding: 12px; background: #fff; border: 1px solid var(--border);
  border-radius: 6px; overflow: auto; max-height: 60vh; font-size: 13px; white-space: pre-wrap; word-break: break-word;
}
.preview-csv { border-collapse: collapse; font-size: 13px; background: #fff; }
.preview-csv td, .preview-csv th { border: 1px solid #dbe1e8; padding: 4px 8px; }
.preview-csv th { background: #f1f5f9; font-weight: 600; }
.preview-more { margin-top: 8px; font-size: 13px; }

/* Окно при сохранении черновика (ТЗ v4, F3) */
.modal-sm { max-width: 440px; }
.modal-body-draft { display: block; text-align: left; align-items: flex-start; }
.draft-modal-note { margin: 0 0 10px; font-size: 14px; }
.draft-modal-list { margin: 0 0 0 18px; padding: 0; font-size: 14px; }
.draft-modal-list li { margin-bottom: 4px; }
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 12px 16px; border-top: 1px solid var(--border);
}

/* Окна соглашений (ТЗ settings_admin, 30.08, M6): текст по левому краю,
   скролл внутри модалки */
.doc-modal { max-width: 560px; }
.doc-modal-body { display: block; align-items: initial; justify-content: initial; background: #fff; }
.doc-text { white-space: pre-wrap; word-break: break-word; font-size: 13px; line-height: 1.55; }

/* Окно проверки файла при отправке (TASK express_ux 02.09, M1): блокирующая
   модалка «Файл не приложен» + анимация зелёной галочки перед отправкой. */
#submit-no-file-modal .modal-sm { max-width: 400px; }
.submit-check-overlay {
  position: fixed; inset: 0; z-index: 400; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
  background: rgba(244, 245, 247, .35);
}
.submit-check-circle {
  display: flex; align-items: center; justify-content: center;
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--green); color: #fff;
  box-shadow: 0 10px 30px rgba(22, 163, 74, .4);
  animation: submit-check-pop .35s ease-out;
}
.submit-check-mark { font-size: 38px; line-height: 1; font-weight: 700; }
@keyframes submit-check-pop {
  from { transform: scale(.45); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
@media (max-width: 640px) {
  .modal-sm { max-width: 96vw; }
  .modal-overlay { padding: 8px; }
  .modal-body-draft { max-height: 55vh; overflow-y: auto; }
  .submit-check-overlay { background: rgba(244, 245, 247, .45); }
}

/* Контрагент с ИНН: клик копирует в буфер (требование 19.08) */
.cp-copy {
  cursor: pointer;
  border-bottom: 1px dashed var(--border);
  transition: border-color .12s, color .12s;
}
.cp-copy:hover { border-color: var(--primary); color: var(--primary); }
.cp-inn { color: var(--muted); font-size: 12px; white-space: nowrap; }

/* Тост «Скопировано» */
#copy-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(16px);
  background: #1f2329; color: #fff; font-size: 13px; padding: 8px 14px;
  border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.25);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  z-index: 300; max-width: 86vw; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
#copy-toast.copy-toast-on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Неактивные сотрудники (выключены админом) — «серые» (27.08) */
tr.user-inactive td { color: #9ca3af; }
tr.user-inactive td .badge { opacity: .6; }

/* Выдача логинов/паролей (ТЗ settings_admin, 30.08, M4): блок под строкой
   пользователя, только для супер-админа */
tr.creds-row td { background: #f8fafc; padding: 6px 10px; }
.creds-block { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.creds-form .input-sm { width: 150px; }
.creds-row .checkbox-inline { margin-right: 6px; }
.checkbox-inline { display: inline-flex; align-items: center; gap: 6px; margin-right: 12px; }

/* ---------- F2: хаб «Справочники» таблицей (ТЗ 30.08) ---------- */
.catalog-icon { font-size: 18px; line-height: 1.2; margin-right: 6px; }
.catalog-label { font-weight: 600; font-size: 14px; color: var(--text); }
.catalog-hint { font-size: 12px; color: var(--muted); }

/* Дерево в списке справочника (accounting_items): отступы по уровню */
.tree-item { display: inline-block; }
.tree-connector { color: var(--muted); opacity: .55; }

/* ---------- Справка пользователя (ТЗ help v1, 31.08) ---------- */

/* Кнопка «?» в шапке (.topbar-right, рядом с колокольчиком): круглая, контраст
   на тёмном topbar, тач-зона ≥ 32×32px (требование Блока 1). */
.help-link {
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.12); color: #fff;
  font-size: 17px; font-weight: 700; line-height: 1; text-decoration: none;
  transition: background .15s, color .15s;
}
.help-link:hover { background: #19A1E5; color: #fff; }  /* фирменный акцент ONNEX */
.help-link:focus-visible { outline: 2px solid #19A1E5; outline-offset: 1px; }

/* Страница справки: оглавление-якоря + секции-карточки. */
.help-toc {
  display: flex; flex-wrap: wrap; gap: 6px 8px;
  margin: 0 0 18px; padding: 10px 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
}
.help-toc a {
  color: var(--primary); text-decoration: none; font-size: 13px;
  padding: 4px 8px; border-radius: 6px;
}
.help-toc a:hover { background: #f0f2f5; text-decoration: underline; }
.help-section {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 18px 16px; margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
}
.help-section-title { margin: 0 0 6px; font-size: 18px; font-weight: 700; }
.help-section-lead { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.help-section h3 { margin: 14px 0 6px; font-size: 15px; font-weight: 600; }
.help-section h3:first-of-type { margin-top: 10px; }
.help-section p { margin: 6px 0; line-height: 1.55; }
.help-section ul, .help-section ol { margin: 6px 0; padding-left: 22px; line-height: 1.55; }
.help-section li { margin-bottom: 4px; }
.help-note {
  background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8;
  border-radius: 6px; padding: 8px 12px; margin: 8px 0; font-size: 13px; line-height: 1.5;
}
/* Таблица статусов (секция E): адаптивна на 390px — узкие экраны получают
   карточки (общий мобильный стиль .table в media-блоке выше). */
.help-table { min-width: 480px; }
@media (max-width: 640px) { .help-table { min-width: 0; } }

/* ---------- Карточка заявки, вариант 2 (01.09): перебаланс колонок ----------
   Слева «Деньги и условия» с крупной суммой, справа «Кому и по чему» + разбивка,
   вложения — полосой чипов на всю ширину (ТЗ макета detail_layouts, в.2). */
.detail-amount { font-size: 26px; font-weight: 800; letter-spacing: -.3px; margin: 0 0 10px; }
.attach-card { margin-top: 16px; }
.attach-bar { display: flex; gap: 10px; flex-wrap: wrap; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: 8px; background: #fafbfc;
  padding: 6px 12px; font-size: 13px;
}
.attach-name { font-weight: 600; }
.attach-chip .btn-xs { padding: 3px 9px; font-size: 11.5px; }
@media (max-width: 640px) {
  .attach-chip { width: 100%; }
}

/* ---------- Аналитика расходов v2 (ТЗ analytics_costs, 09.09) ---------- */

/* Справочный блок K «В работе» (вне расходов) */
.cost-in-work {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 0 0 14px; padding: 8px 12px; font-size: 13px;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 8px;
}
.cost-in-work-icon { font-size: 15px; }
.cost-in-work .hint { margin-left: 4px; flex: 1; }

/* Фильтры расходов (одиночные select, компактные) */
.cost-filters { margin: 0 0 16px; padding: 10px 14px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; }
.cost-filters-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cost-filters-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.cost-filters-reset { font-size: 12px; color: var(--muted); text-decoration: none; }
.cost-filters-reset:hover { color: var(--primary); text-decoration: underline; }
.cost-filters-grid { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.cost-filters .filter-field select { min-height: auto; height: 34px; }
.cost-filters .filter-input { height: 34px; border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; font-size: 12px; }
.cost-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; padding: 8px 0; }
.cost-check input { width: 16px; height: 16px; accent-color: #2563eb; }
.cost-filters-active { margin-top: 8px; padding: 5px 8px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 3px; color: #1d4ed8; font-size: 12px; }

/* KPI-полоса */
.cost-kpi .stat-card { padding: 10px 12px; }
.cost-kpi .stat-value { font-size: 18px; }
.cost-kpi .stat-value.up { color: #16a34a; }
.cost-kpi .stat-value.down { color: #dc2626; }

/* Переключатель разреза динамики (B) */
.cost-cut-switch { display: inline-flex; align-items: center; gap: 6px; margin: 6px 0 2px; flex-wrap: wrap; }
.cost-cut-label { font-size: 12px; color: var(--muted); }
.cost-cut-btn {
  display: inline-block; padding: 3px 10px; font-size: 12px; text-decoration: none;
  border: 1px solid var(--border); border-radius: 12px; color: var(--muted); background: #fff;
}
.cost-cut-btn:hover { border-color: var(--primary); color: var(--primary); }
.cost-cut-active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Таблицы расходов: обёртка со скроллом (мобильная — карточки через .table) */
.cost-table-scroll { overflow-x: auto; }
.cost-rest td { color: var(--muted); font-style: italic; }
.cost-empty { text-align: center; color: var(--muted); padding: 18px; }

/* Drill-down «статьи внутри подразделения» */
.cost-details { margin-top: 4px; }
.cost-details summary { font-size: 11.5px; color: var(--muted); cursor: pointer; }
.cost-details-list { margin: 2px 0 0 6px; padding-left: 12px; font-size: 12px; }
.cost-details-list li { display: flex; justify-content: space-between; gap: 8px; }
.cost-details-total { color: var(--muted); font-weight: 600; }
.cost-new-cps { margin-top: 12px; padding: 8px 12px; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; }
.cost-new-cps-title { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.cost-new-cps ul { margin: 2px 0 0; padding-left: 16px; }

/* Матрицы: скролл + закреплённая первая колонка */
.cost-matrix-scroll { overflow-x: auto; }
.cost-matrix { border-collapse: separate; border-spacing: 0; min-width: 720px; font-size: 12px; }
.cost-matrix th { position: sticky; top: 0; background: var(--card); padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border); z-index: 1; font-weight: 600; color: var(--muted); }
.cost-mx-first { position: sticky; left: 0; background: var(--card); z-index: 2; font-weight: 600; }
.cost-matrix .cost-mx-total { font-weight: 700; color: var(--text); }
.cost-matrix td { padding: 6px 9px; border-bottom: 1px solid #f0f2f5; }
.cost-matrix td.num { text-align: right; }
.cost-matrix tbody tr:hover { background: #f2f6ff; }
.cost-matrix tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.cost-matrix td a { color: var(--primary); text-decoration: none; }
@media (max-width: 640px) {
  .cost-matrix { min-width: 0; width: 100%; }
  .cost-matrix th, .cost-matrix td { white-space: nowrap; }
}

/* ---------- Аналитика расходов v3 (ТЗ analytics_v3, 18.09) ---------- */
/* Строка периода справа от фильтров (вместо отдельного блока «К прошлому»). */
.cost-filters-period { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }

/* Сегменты-разрезы основной таблицы (ТЗ п.3 M2.4): pay-style переключатель. */
.cost-seg-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 14px; padding: 8px 12px;
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
}
.cost-seg-bar .spacer { margin-left: auto; }
.cost-seg-label { font-size: 12px; color: var(--muted); }
.cost-seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: #eef1f5; border-radius: 8px; }
.cost-seg-item {
  display: inline-block; padding: 5px 11px; border-radius: 6px;
  font-size: 12.5px; color: #4b5563; text-decoration: none; white-space: nowrap;
}
.cost-seg-item:hover { color: var(--primary); background: rgba(255, 255, 255, .6); }
.cost-seg-active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

/* Полоска доли в таблице (маленький трек + заполнение). */
.cost-bar.track { height: 4px; margin-top: 4px; background: #eef1f5; border-radius: 3px; overflow: hidden; }
.cost-bar-fill { height: 100%; background: var(--primary); border-radius: 3px; }

/* Сортировка: подсказка ▲▼ в заголовке, активная колонка подсвечена. */
.cost-sort-icons { font-size: 9px; color: var(--muted); opacity: .45; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover .cost-sort-icons, th.sortable[data-dir] .cost-sort-icons { opacity: 1; }
th.sortable[data-dir] .th-label { color: var(--primary); }

/* Раскрытие строки: подтаблица разбивки разреза. */
.cost-sub { margin-top: 4px; }
.cost-sub summary { font-size: 11.5px; color: var(--muted); cursor: pointer; }
.cost-sub-list { margin: 2px 0 0 6px; padding-left: 12px; font-size: 12px; list-style: none; }
.cost-sub-list li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.cost-sub-total { color: var(--muted); font-weight: 600; white-space: nowrap; }

/* Динамика по дням/неделям: столбики без внешней библиотеки (zero-build). */
.cost-day-chart { position: relative; display: flex; align-items: flex-end; gap: 3px; overflow-x: auto; padding: 6px 0 0; }
.cost-day-col { flex: 1 1 0; min-width: 22px; display: flex; flex-direction: column; align-items: center; }
/* Столбики динамики (правка 18.09.2026): заполнение позиционируется абсолютно —
   процентная высота внутри flex-контейнера схлопывается в Safari (iPhone), из-за
   чего блок выглядел пустым. Нулевые дни получают тонкую серую базу, чтобы
   календарь дней читался как непрерывная шкала. */
.cost-day-col .track { position: relative; display: flex; flex-direction: column-reverse; justify-content: flex-start; width: 100%; height: 96px; background: #f4f6f9; border-radius: 3px; overflow: hidden; }
.cost-day-col .cost-bar-fill { position: absolute; left: 0; right: 0; bottom: 0; min-height: 3px; border-radius: 2px 2px 0 0; }
.cost-day-col .cost-bar-fill.zero { height: 2px !important; background: #dfe4ea; }

/* Сегменты столбца: каждый отдел своим цветом (правка заказчика 18.09.2026). */
.cost-day-seg { width: 100%; min-height: 1px; }
.cost-day-seg + .cost-day-seg { box-shadow: 0 -1px 0 rgba(255, 255, 255, .6); }
.cost-day-seg.is-active { filter: brightness(.82); }

/* Легенда отделов под диаграммой: цвет, название, сумма; клик — фильтр по отделу. */
.cost-day-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 12px; }
.cost-legend-chip { display: inline-flex; align-items: center; gap: 6px; color: var(--text); text-decoration: none; }
.cost-legend-chip .dot { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 auto; }
.cost-legend-chip b { font-weight: 600; }
.cost-legend-chip:hover { color: var(--primary-dark); }
.cost-legend-chip.is-active { color: var(--primary-dark); }
.cost-legend-chip.is-active .dot { outline: 2px solid rgba(37, 99, 235, .35); }

/* Подсказка при наведении на сегмент: «отдел · сумма · день». */
.cost-tip { position: absolute; z-index: 6; pointer-events: none; background: #111827; color: #fff;
  font-size: 12px; line-height: 1.3; padding: 4px 8px; border-radius: 5px; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(15, 23, 42, .25); }
.cost-day-label { font-size: 9.5px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.cost-scroll-hint { display: none; font-size: 11px; color: var(--muted); margin-top: 6px; }

/* «Справочно»: три плитки в ряд, узкие таблицы без минимальной ширины. */
.cost-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.cost-tiles > * { min-width: 0; }
.cost-mini { min-width: 0; }
.cost-mini td, .cost-mini th { font-size: 12px; }
.cost-tiles .card-title .sub { font-weight: 400; color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  .cost-tiles { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .cost-filters-period { margin-left: 0; }
  .cost-seg-item { padding: 9px 12px; display: inline-flex; align-items: center; min-height: 42px; }
  .cost-seg-bar .btn { min-height: 42px; }
  /* ТЗ п.3 п.3: поля ввода на телефоне — 16px (без авто-zoom iOS) и тап ≥ 40px */
  .cost-filters .filter-field select,
  .cost-filters .filter-input { font-size: 16px; height: auto; min-height: 42px; }
  .cost-filters .filter-label { font-size: 11px; }
  .cost-check { min-height: 42px; font-size: 14px; }
  .cost-day-col { min-width: 8px; }
  .cost-day-label { display: none; }
  .cost-day-legend { font-size: 11px; gap: 2px 10px; }
  .cost-legend-chip { min-height: 32px; }
  .cost-day-col:nth-child(5n + 1) .cost-day-label { display: block; }
  .cost-scroll-hint { display: block; }
  /* Карточный режим .table (td::before + flex) сжимает раскрытие разбивки до
     ширины ссылки — на телефоне первая ячейка идёт блоком на всю ширину. */
  .cost-table td:first-child { display: block; text-align: left; }
  .cost-table td:first-child::before { display: block; margin-bottom: 2px; }
  .cost-sub { display: block; width: 100%; }
  .cost-sub-list li { flex-wrap: wrap; }
  .cost-sub summary { min-height: 30px; display: inline-flex; align-items: center; }
}
