/**
 * =============================================================================
 * DESIGN SYSTEM — UI для учёта бизнеса (SaaS-уровень)
 * =============================================================================
 *
 * КОМПОНЕНТЫ И ИСПОЛЬЗОВАНИЕ
 * --------------------------
 *
 * 1) AppLayout
 *    Основной layout: .app-layout > .app-sidebar + .app-content.
 *    Sidebar: глубокий slate + лёгкая глубина, ширина --ds-sidebar-width; кнопка в шапке сворачивает в «icon rail»
 *    (html.app-sidebar--collapsed). Состояние в localStorage + ранний скрипт в layout (без FOUC).
 *    Новые страницы наследуют layout — получают AppLayout автоматически.
 *
 * 2) PageHeader
 *    Шапка страницы формы: заголовок слева, кнопки справа (например Отмена).
 *    Шаблон: {% include 'components/page_header.html' with title="..." back_url=... back_label="Отмена" %}
 *    Стили: .page-header, .page-header__title, .page-header__actions.
 *
 * 3) FormPageLayout
 *    Страница с формой: белый блок по центру (max-width 900px), фон страницы #F9FAFB.
 *    Наследование: {% extends 'components/form_page_layout.html' %}, блоки: page_header, form_content.
 *    Стили: .form-page-background, .form-page-layout.
 *
 * 4) FormSection
 *    Секция формы с заголовком. Классы: .form-section, .form-section__title.
 *    Горизонтальная сетка ERP: .form-grid-horizontal или .form-grid-2 — лейбл и поле в одной строке
 *    (grid 150px 1fr 150px 1fr, gap 2px). Поле на всю ширину: .form-field--full. Кнопки: .form-actions (справа).
 *    Современный SaaS-режим (по умолчанию на FormPageLayout): .form-page-background--modern,
 *    карточки .ui-card, поля .ui-field + .ui-form-grid, липкая панель .ui-form-sticky.
 *
 * 5) DataTable
 *    Таблица списка: обёртка .data-table-wrap, таблица .data-table.
 *    Заголовок: фон #F9FAFB, высота строк 44px, sticky header.
 *    Числовые колонки: класс .text-right на th/td. Действия: .data-table__actions.
 *    Панель над таблицей: .data-table-toolbar; пагинация: .data-table-pagination.
 *
 * 6) ListPageHeader
 *    Шапка страницы со списком: только заголовок слева и основная кнопка «Добавить» справа.
 *    Поиск и фильтры размещаются в ListToolbar под шапкой.
 *    Шаблон: {% include 'components/list_page_header.html' with title="Сотрудники" add_url=... add_label="Добавить сотрудника" %}
 *    Стили: .list-page-header, .list-page-header__actions.
 * 6b) ListToolbar
 *     Под шапкой: поиск, фильтры, кнопки Найти/Сбросить/Экспорт. Класс .list-toolbar (gap 12px), поля .ds-input (height 40px).
 * 6c) Компактная панель фильтров (одна строка, лейблы и поля на одном уровне, мелкий шрифт):
 *     .list-toolbar.list-toolbar--compact или form.report-toolbar.report-toolbar--compact.
 *     Группа «лейбл + поле»: .list-toolbar__filter-group (или .report-toolbar__group).
 *
 * 6d) ListPageLayout + ListSurface — списки на всю ширину (пилот: отгрузки).
 *     {% extends 'components/list_page_layout.html' %}, блок list_content.
 *     Одна панель .list-surface: __head, __scroll + .data-table, __foot. Не form_page_layout.
 *
 * 7) EmptyState
 *    Пустое состояние: иконка, заголовок, описание, основная кнопка.
 *    Шаблон: {% include 'components/empty_state.html' with title="Нет расходов"
 *              description="Добавьте первый расход." action_url=... action_label="Добавить расход" %}
 *    Стили: .empty-state, .empty-state__icon, .empty-state__title, .empty-state__description, .empty-state__action.
 *
 * ФОРМЫ
 * -----
 * Поля: .form-field, .form-field__label, .ds-input, .ds-select, .ds-textarea, .ds-file.
 * Обязательное поле: добавить класс .is-required к .form-field__label (показывает « * »).
 * Подсказка под полем: .form-help. Валидация: .input-error (красная рамка), .input-success (зелёная).
 *
 * КНОПКИ И УТИЛИТЫ
 * ----------------
 * .btn-primary, .btn-secondary. Выравнивание: .text-right, .text-center.
 *
 * ЗАГРУЗКА И ИКОНКИ
 * -----------------
 * Состояние загрузки: на обёртку таблицы добавить .table-loading; на форму — .form-loading (skeleton).
 * Иконки (опционально): {% include 'components/icons/icon_date.html' %} и т.д. в label; класс .ds-icon.
 *
 * ДОКУМЕНТЫ (DocumentPageLayout, DocumentHeaderSection, DocumentItemsTable, DocumentTotals)
 * ----------------------------------------------------------------------------------------
 * 8) DocumentPageLayout — страница документа с шапкой и карточкой. Наследование:
 *    {% extends 'components/document_page_layout.html' %}. Блоки: page_header, document_content.
 *    Карточка: .document-card (white, padding 24px, border-radius 12px, box-shadow).
 *
* 9) DocumentHeaderSection — шапка документа, компактная ERP-сетка. Классы: .document-header-section
*    (фон, рамка, padding), .document-header-grid (4 колонки: 150px 1fr 150px 1fr — label и поле в одной строке),
*    .document-field (display: contents), .document-field--full (на всю ширину). Поля: .ds-input, .ds-select.
 *
 * 10) DocumentItemsTable — таблица строк документа. Обёртка: .document-items-section.
 *     Кнопка «Добавить строку»: .document-items-table__toolbar + .btn-secondary.document-items-table__add.
 *     Таблица: .document-items-table (row height 44px, header #F9FAFB, border #E5E7EB).
 *     Удалить строку: .btn-delete-line (маленькая красная кнопка).
 *
 * 11) DocumentTotals — итоги под таблицей. Класс .document-totals (text-align right),
 *     .document-totals__label, .document-totals__value (font-size 16px, font-weight 600).
 *     Можно использовать в <tfoot> или в отдельном блоке под таблицей.
 *
 * ВКЛАДКИ (PageTabs)
 * ------------------
 * 12) PageTabs — навигация вкладками. Классы: .tabs (обёртка, нижняя граница),
 *     .tabs__list (flex), .tabs__item (padding 0 16px, font 14px), .tabs__item--active (color #111827,
 *     нижняя полоса var(--ds-tab-underline) solid #6366F1, font-weight 600). Неактивная вкладка: color #6B7280.
 *     Шаблон: {% include 'components/page_tabs.html' with tabs=tab_list active_tab=request.resolver_match.url_name %}
 *     tabs — список { url, label, id }. Либо вывести разметку вручную с этими классами.
 *
 * ОТЧЁТЫ (Reports)
 * -----------------
 * 13) ReportLayout — страницы отчётов наследуют reports/reports_layout.html. Контент в .report-content.
 * 14) report-toolbar — панель фильтров отчёта (как .list-toolbar): даты, селекты, кнопки. Поля .ds-input, .ds-select.
 * 15) report-kpi — сетка KPI-карточек над таблицей. .report-kpi__card — одна карточка (заголовок + значение).
 * 16) report-chart — обёртка для графика (canvas), отступы снизу.
 */

/* ========== TOKENS ========== */
:root {
  --ds-sidebar-width: 184px;
  --ds-sidebar-width-collapsed: 80px;
  /* Мягче navy: меньше «бетона», читаемый контраст */
  --ds-sidebar-bg: #1e293b;
  --ds-sidebar-bg-deep: #0f172a;
  --ds-sidebar-text: #e2e8f0;
  --ds-sidebar-text-muted: rgba(226, 232, 240, 0.72);
  /* Активный пункт: «капсула», не заливка на всю ширину */
  --ds-sidebar-active-bg: rgba(99, 102, 241, 0.22);
  --ds-sidebar-active-border: rgba(165, 180, 252, 0.45);
  --ds-sidebar-active-glow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 1px 14px rgba(99, 102, 241, 0.28);
  --ds-tab-underline: 3px;
  --ds-page-bg: #F9FAFB;
  --ds-surface: #ffffff;
  --ds-border: #E5E7EB;
  --ds-border-focus: #6366F1;
  --ds-primary: #6366F1;
  --ds-primary-hover: #4F46E5;
  --ds-secondary-border: #D1D5DB;
  --ds-text: #111827;
  --ds-text-muted: #6B7280;
  --ds-error: #DC2626;
  --ds-success: #15803d;
  --ds-radius: 8px;
  --ds-radius-lg: 12px;
  --ds-input-height: 40px;
  --ds-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --ds-shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.08);
}

html {
  scrollbar-gutter: stable;
}

/* ========== APP LAYOUT ========== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  display: flex;
  flex-direction: column;
  width: var(--ds-sidebar-width);
  min-width: var(--ds-sidebar-width);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 18%),
    linear-gradient(180deg, var(--ds-sidebar-bg) 0%, var(--ds-sidebar-bg-deep) 100%);
  color: var(--ds-sidebar-text);
  padding: 1.5rem 0 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: hidden;
  box-sizing: border-box;
  transition: width 0.2s ease, min-width 0.2s ease;
  border-right: 1px solid rgba(15, 23, 42, 0.75);
  box-shadow:
    inset -1px 0 0 rgba(255, 255, 255, 0.05),
    4px 0 24px rgba(15, 23, 42, 0.06);
}

.app-sidebar nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

.app-sidebar__footer {
  flex-shrink: 0;
  margin-top: auto;
  padding: 0.75rem 0.85rem 1rem;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: rgba(226, 232, 240, 0.38);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

html.app-sidebar--collapsed .app-sidebar__footer {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .app-sidebar {
    transition: none;
  }
  .app-sidebar nav a {
    transition: none;
  }
  .tabs__item a {
    transition: none;
  }
}

/* Свёрнутое меню: icon rail — иконка + короткая подпись, без вертикальной прокрутки */
html.app-sidebar--collapsed .app-sidebar {
  width: var(--ds-sidebar-width-collapsed);
  min-width: var(--ds-sidebar-width-collapsed);
  padding-top: 0.5rem;
}

html.app-sidebar--collapsed .app-sidebar nav {
  overflow-y: hidden;
  scrollbar-width: none;
}

html.app-sidebar--collapsed .app-sidebar nav::-webkit-scrollbar {
  display: none;
}

html.app-sidebar--collapsed .app-sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.35rem 0.35rem;
  margin-bottom: 0.05rem;
  min-height: auto;
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

html.app-sidebar--collapsed .app-sidebar__brand-text {
  display: block;
  max-width: 100%;
  padding: 0 0.1rem;
  font-size: 0.5rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: rgba(248, 250, 252, 0.55);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html.app-sidebar--collapsed .app-sidebar nav a {
  position: relative;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  margin: 0.06rem 0.3rem;
  padding: 0.28rem 0.15rem 0.3rem;
  min-height: 0;
  border-radius: 10px;
  text-align: center;
}

html.app-sidebar--collapsed .app-sidebar nav a .ds-icon {
  width: 20px;
  height: 20px;
  margin: 0;
}

html.app-sidebar--collapsed .app-sidebar nav a.active::before {
  display: none;
}

html.app-sidebar--collapsed .app-sidebar nav a.active::after {
  content: "";
  position: absolute;
  bottom: 0.15rem;
  left: 50%;
  transform: translateX(-50%);
  width: 1rem;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, #c7d2fe 0%, #818cf8 100%);
  box-shadow: 0 0 6px rgba(129, 140, 248, 0.55);
}

@media (prefers-reduced-motion: no-preference) {
  html.app-sidebar--collapsed .app-sidebar nav a:hover {
    transform: translateY(-1px);
  }

  html.app-sidebar--collapsed .app-sidebar nav a:active {
    transform: translateY(0);
  }
}

/* Подписи: полный текст в развёрнутом виде, короткий — в свёрнутом */
.app-sidebar__label {
  min-width: 0;
  line-height: 1.25;
}

.app-sidebar__label-compact {
  display: none;
}

html.app-sidebar--collapsed .app-sidebar__label {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 4.25rem;
}

html.app-sidebar--collapsed .app-sidebar__label-text {
  display: none;
}

html.app-sidebar--collapsed .app-sidebar__label-compact {
  display: block;
  font-size: 0.5625rem;
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: 0;
  color: var(--ds-sidebar-text-muted);
  word-break: break-word;
  hyphens: auto;
}

html.app-sidebar--collapsed .app-sidebar nav a.active .app-sidebar__label-compact {
  color: #e0e7ff;
  font-weight: 600;
}

.app-sidebar__brand {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  padding: 0 0.85rem 0.85rem;
  margin-bottom: 0.45rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #f8fafc;
}

.app-sidebar nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.app-sidebar nav li {
  margin: 0;
}

.app-sidebar nav li.sidebar-section {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ds-sidebar-text-muted);
  padding: 1rem 0.85rem 0.35rem;
  margin-top: 0.5rem;
}

.app-sidebar nav li.sidebar-section:first-child {
  margin-top: 0;
}

.app-sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.1rem 0.45rem;
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  border: 1px solid transparent;
  color: var(--ds-sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition:
    background 0.14s ease,
    color 0.14s ease,
    box-shadow 0.14s ease,
    border-color 0.14s ease,
    transform 0.14s ease;
}

.app-sidebar nav a:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.06);
}

.app-sidebar nav a.active {
  background: var(--ds-sidebar-active-bg);
  border: 1px solid var(--ds-sidebar-active-border);
  box-shadow: var(--ds-sidebar-active-glow);
  color: #fff;
  font-weight: 600;
  position: relative;
}

.app-sidebar nav a.active::before {
  content: "";
  position: absolute;
  left: -0.35rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 58%;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #a5b4fc 0%, #6366f1 100%);
  box-shadow: 0 0 8px rgba(99, 102, 241, 0.45);
}

.app-sidebar nav a.active .ds-icon {
  opacity: 1;
}

.app-sidebar nav a:not(.active) .ds-icon {
  opacity: 0.88;
}

.app-content {
  flex: 1;
  min-width: 0;
  background: var(--ds-page-bg);
  padding: 0 2rem 2rem;
  box-sizing: border-box;
}

/* Верхняя панель с информацией о пользователе / контексте */
.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  margin: 0 -2rem 1.25rem;
  padding: 0 2rem;
  background: #ffffff;
  box-shadow: 0 1px 0 rgba(209, 213, 219, 0.8);
  position: sticky;
  top: 0;
  z-index: 5;
}
.app-topbar__left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8125rem;
  color: var(--ds-text-muted);
}

.app-topbar__date {
  white-space: nowrap;
}

.app-topbar__pos {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 0.85rem;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1;
  white-space: nowrap;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.app-topbar__pos:hover,
.app-topbar__pos.is-active {
  border-color: #4f46e5;
  background: #4f46e5;
  color: #fff;
  transform: translateY(-1px);
}

/* Кнопка сворачивания меню */
.app-sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  margin: 0;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  background: #fff;
  color: var(--ds-text);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.app-sidebar-toggle:hover {
  background: var(--ds-page-bg);
  border-color: #cbd5e1;
  color: var(--ds-primary);
}

.app-sidebar-toggle:focus-visible {
  outline: 2px solid var(--ds-border-focus);
  outline-offset: 2px;
}

.app-sidebar-toggle__icon--when-collapsed {
  display: none;
}

html.app-sidebar--collapsed .app-sidebar-toggle__icon--when-expanded {
  display: none;
}

html.app-sidebar--collapsed .app-sidebar-toggle__icon--when-collapsed {
  display: block;
}
.app-topbar__right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--ds-text);
}

.app-topbar__support {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 36px;
  padding: 0 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #fff;
  color: var(--ds-text);
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.app-topbar__support .ds-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--ds-primary);
}
.app-topbar__support:hover {
  background: var(--ds-page-bg);
  border-color: #cbd5e1;
  color: var(--ds-primary);
}
.app-topbar__support.is-active {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: var(--ds-primary);
}
.app-topbar__support--inbox {
  padding: 0 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ds-text-muted);
}
.app-topbar__support-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #f59e0b;
  color: #1e293b;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 0 0 2px #fff;
}

@media (max-width: 900px) {
  .app-topbar__support-label {
    display: none;
  }
  .app-topbar__support {
    width: 40px;
    padding: 0;
    justify-content: center;
  }
  .app-topbar__support--inbox {
    width: auto;
    padding: 0 0.5rem;
  }
}
.app-topbar__user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.app-topbar__user-name {
  white-space: nowrap;
}
.app-topbar__user-role {
  font-size: 0.75rem;
  color: var(--ds-text-muted);
}
.app-topbar__avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--ds-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

@media print {
  .app-sidebar { display: none !important; }
  .app-content { padding: 0 !important; }
  .page-header__actions { display: none !important; }
}

/* ========== PAGE HEADER ========== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header__title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ds-text);
  margin: 0;
}

.page-header__title--mb {
  margin-bottom: 1rem;
}

.page-header__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ========== FORM PAGE LAYOUT ========== */
.form-page-background {
  background: var(--ds-page-bg);
  min-height: 100%;
}

.form-page-layout {
  max-width: 900px;
  background: var(--ds-surface);
  padding: 32px;
  border-radius: var(--ds-radius-lg);
  box-shadow: var(--ds-shadow-lg);
  margin: 0 auto;
}

/* Расширенный контейнер для форм с широкой таблицей/фильтрами */
.form-page-layout--wide {
  max-width: 1280px;
}

/* Узкая центрованная форма для экрана логина */
.auth-login-page .form-page-layout {
  max-width: 420px;
}
.auth-login-page .form-section {
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}
.auth-login-page .form-section__title {
  text-align: center;
}
.auth-login-page .form-grid-2 {
  grid-template-columns: 120px minmax(0, 1fr);
}
.auth-login-page .form-actions {
  display: flex;
  justify-content: center;
}

/* === DASHBOARD KPI CARDS === */
.dashboard-kpi-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.dashboard-kpi-card {
  flex: 1 1 calc(33.333% - 8px);
  max-width: 260px;
  background: #ffffff;
  border-radius: 10px;
  border: 1px solid #E5E7EB;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  padding: 10px 12px;
}

.dashboard-kpi-card--tone-neutral {
  background: #ffffff;
  border-color: #e5e7eb;
}

.dashboard-kpi-card--tone-success {
  background: linear-gradient(180deg, #fafffb 0%, #f0fdf4 100%);
  border-color: #bbf7d0;
}

.dashboard-kpi-card--tone-danger {
  background: linear-gradient(180deg, #fffbfa 0%, #fef2f2 100%);
  border-color: #fecaca;
}

.dashboard-kpi-card--tone-warn {
  background: linear-gradient(180deg, #fffdfa 0%, #fff7ed 100%);
  border-color: #fed7aa;
}
.dashboard-kpi-title {
  font-size: 12px;
  color: #6B7280;
  margin-bottom: 4px;
  white-space: nowrap;
}
.dashboard-kpi-value {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
}
/* Семантика сумм на главной / дашбордах (согласовано с «Финансы → Обзор») */
.dashboard-kpi-value--income {
  color: #16a34a;
}
.dashboard-kpi-value--expense {
  color: #dc2626;
}
.dashboard-kpi-value--debt {
  color: #c2410c;
}
.dashboard-kpi-value--profit-positive {
  color: #16a34a;
}
.dashboard-kpi-value--profit-negative {
  color: #dc2626;
}

.dashboard-kpi-row--secondary {
  margin-bottom: 14px;
}

.dashboard-kpi-row--secondary .dashboard-kpi-card {
  flex: 1 1 160px;
  max-width: none;
}

.dashboard-kpi-hint {
  font-size: 11px;
  color: #6b7280;
  margin-top: 4px;
  line-height: 1.35;
}

/* --- Главная: срочность + hero KPI + операционный блок --- */
.dashboard-alerts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.dashboard-alert {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.dashboard-alert--danger {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fecaca;
}

.dashboard-alert--danger:hover {
  background: #fee2e2;
}

.dashboard-alert--warn {
  color: #9a3412;
  background: #fff7ed;
  border-color: #fed7aa;
}

.dashboard-alert--warn:hover {
  background: #ffedd5;
}

.dashboard-hero {
  position: relative;
  margin-bottom: 12px;
  padding: 18px 22px 18px 24px;
  border-radius: 12px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.05),
    0 6px 20px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}

.dashboard-hero::before {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, #64748b 0%, #334155 100%);
}

.dashboard-hero--risk {
  background: linear-gradient(135deg, #fffdf8 0%, #ffffff 55%);
  border-color: #d6d3d1;
}

.dashboard-hero--risk::before {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
}

.dashboard-hero:not(.dashboard-hero--risk)::before {
  background: linear-gradient(180deg, #6366f1 0%, #4338ca 100%);
}

.dashboard-hero__eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #475569;
}

.dashboard-hero__label {
  font-size: 15px;
  color: #334155;
  margin-top: 6px;
  font-weight: 600;
}

.dashboard-hero__value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #0f172a;
  margin-top: 6px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.dashboard-hero__value--pos {
  color: #15803d;
}

.dashboard-hero__value--neg {
  color: #b91c1c;
}

.dashboard-hero__value--balance-neg {
  color: #92400e;
}

.dashboard-hero__caption {
  margin-top: 10px;
  font-size: 13px;
  color: #334155;
  font-weight: 500;
}

.dashboard-hero__caption--muted {
  font-size: 12px;
  color: #64748b;
}

.dashboard-hero__trend {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
}

.dashboard-hero__trend--up {
  color: #15803d;
}

.dashboard-hero__trend--down {
  color: #b91c1c;
}

.dashboard-ops {
  margin-bottom: 16px;
}

.dashboard-ops__head {
  margin-bottom: 8px;
}

.dashboard-ops__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
}

.dashboard-ops__subtitle {
  font-size: 12px;
  color: #64748b;
}

.dashboard-ops__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 1100px) {
  .dashboard-ops__grid {
    grid-template-columns: 1fr;
  }
}

.dashboard-ops-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 140px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.dashboard-ops-panel--queue:hover {
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.dashboard-ops-panel--urgent {
  border-color: #fecaca;
  box-shadow: 0 1px 3px rgba(220, 38, 38, 0.06);
}

.dashboard-ops-panel__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

.dashboard-ops-panel__name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
}

.dashboard-ops-panel__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}

.dashboard-ops-panel__count--warn {
  color: #b91c1c;
  background: #fef2f2;
  border-color: #fecaca;
}

.dashboard-ops-panel__link {
  font-size: 12px;
  font-weight: 600;
  color: #2563eb;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.12s ease;
}

.dashboard-ops-panel__link:hover {
  color: #1d4ed8;
  text-decoration: none;
}

.dashboard-ops-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dashboard-ops-list li + li {
  border-top: 1px solid #f1f5f9;
}

.dashboard-ops-list__item--urgent {
  background: linear-gradient(90deg, rgba(254, 242, 242, 0.55) 0%, transparent 100%);
}

.dashboard-ops-list__a {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-rows: auto auto;
  gap: 0 10px;
  padding: 8px 10px;
  margin: 0 -10px;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  align-items: center;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}

.dashboard-ops-list__a::after {
  content: "›";
  grid-column: 3;
  grid-row: 1 / span 2;
  font-size: 16px;
  line-height: 1;
  color: #94a3b8;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.12s ease, transform 0.12s ease, color 0.12s ease;
}

.dashboard-ops-list__a:hover {
  background: #f8fafc;
  box-shadow: inset 0 0 0 1px #e2e8f0;
}

.dashboard-ops-list__a:hover::after {
  opacity: 1;
  transform: translateX(0);
  color: #2563eb;
}

.dashboard-ops-list__a:hover .dashboard-ops-list__main {
  color: #1d4ed8;
}

.dashboard-ops-list__main {
  grid-column: 1;
  grid-row: 1;
  font-size: 13px;
  font-weight: 500;
  color: #0f172a;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-ops-list__meta {
  grid-column: 1;
  grid-row: 2;
  font-size: 11px;
  color: #64748b;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-ops-list__amt {
  grid-column: 2;
  grid-row: 1 / span 2;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.dashboard-ops-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 4px;
  background: #fef2f2;
  color: #b91c1c;
  vertical-align: middle;
}

.dashboard-ops-list__amt--crit {
  color: #b91c1c;
}

.dashboard-ops-empty {
  margin: 12px 0 0;
  font-size: 12px;
  color: #94a3b8;
}

.dashboard-charts-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 0;
}

.dashboard-chart-card {
  flex: 1 1 320px;
  min-width: 280px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.dashboard-chart-card__title {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  letter-spacing: -0.01em;
}

.dashboard-chart-card__canvas {
  position: relative;
  height: 252px;
}

/* === Финансы → Обзор (без form-page-layout — одна плоскость контента) === */
.fin-dash-page {
  padding: 0 1.25rem 2rem;
  max-width: 1280px;
}

.fin-dash-page .tabs {
  margin-bottom: 0.75rem;
}

.hr-dash-page,
.reports-dash-page {
  max-width: 1280px;
}

.fin-dash-card__footnote {
  margin: 0;
  padding: 0.65rem 1rem;
  font-size: 0.8125rem;
  color: var(--ds-text-muted, #64748b);
  border-top: 1px solid var(--ds-border, #e5e7eb);
}

.hr-dash-quick {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.hr-dash-quick__item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 1rem 1.1rem;
  text-decoration: none;
  color: inherit;
  background: #fff;
  border: 1px solid var(--ds-border, #e5e7eb);
  border-radius: 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.hr-dash-quick__item:hover {
  border-color: #93c5fd;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}

.hr-dash-quick__label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ds-text-muted, #64748b);
}

.hr-dash-quick__value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ds-text, #0f172a);
}

.hr-dash-quick__hint {
  font-size: 0.8125rem;
  color: var(--ds-text-muted, #64748b);
}

.hr-dash-links {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
  line-height: 1.6;
}

.hr-dash-links a {
  color: #2563eb;
  text-decoration: none;
}

.hr-dash-links a:hover {
  text-decoration: underline;
}

@media (max-width: 900px) {
  .hr-dash-quick {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .hr-dash-quick {
    grid-template-columns: 1fr;
  }
}

.fin-dash-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0 1.25rem;
}

.fin-dash-head__meta {
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
  color: #64748b;
}

.fin-dash-period {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 3px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  gap: 2px;
}

.fin-dash-period__btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}

.fin-dash-period__btn:hover {
  color: #334155;
  background: #f8fafc;
}

.fin-dash-period__btn.is-active {
  background: #eef2ff;
  color: #4338ca;
  font-weight: 600;
}

.fin-dash-charts {
  margin-bottom: 1rem;
}

.fin-dash-chart-card--wide {
  flex: 1 1 100%;
  min-width: 0;
}

.fin-dash-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 960px) {
  .fin-dash-grid {
    grid-template-columns: 1fr;
  }
}

.fin-dash-card .fs-card__body--flush {
  padding: 0;
}

.fin-dash-card .data-table {
  border: 0;
  border-radius: 0;
}

.fin-dash-card__head--link {
  justify-content: space-between;
}

.fin-dash-card__link {
  font-size: 12px;
  font-weight: 600;
  color: #4f46e5;
  text-decoration: none;
  text-transform: none;
  letter-spacing: 0;
}

.fin-dash-card__link:hover {
  color: #4338ca;
  text-decoration: underline;
}

.fin-dash-empty {
  padding: 1.25rem 1rem !important;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
}

.fin-dash-row--overdue {
  background: #fef2f2;
}

.fin-dash-due-hint {
  font-size: 11px;
  color: #16a34a;
  margin-left: 4px;
}

/* === Финансы → Курсы валют (форма над list-surface) === */
.fx-rate-form {
  display: block;
  margin-bottom: 1rem;
  max-width: 100%;
}

.fx-rate-form__card {
  overflow: hidden;
}

.fx-rate-form__head {
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.fx-rate-form__meta {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ds-text-muted);
  text-transform: none;
  letter-spacing: 0;
}

.fx-rate-form__grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
}

.fx-rate-form__field {
  display: grid;
  grid-template-rows: 2.25rem 44px;
  gap: 0.35rem;
  min-width: 0;
}

.fx-rate-form__field--date {
  flex: 0 1 9.75rem;
}

.fx-rate-form__field--currency {
  flex: 1 1 11rem;
  min-width: 10rem;
}

.fx-rate-form__field--rate {
  flex: 0 1 7rem;
}

.fx-rate-form__field--source {
  flex: 0 1 10rem;
}

.fx-rate-form__field--note {
  flex: 1 1 12rem;
  min-width: 9rem;
}

.fx-rate-form__field--action {
  flex: 0 0 auto;
}

.fx-rate-form__label {
  align-self: end;
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.25;
  color: var(--ds-text-muted);
  min-width: 0;
}

.fx-rate-form__label--ghost {
  visibility: hidden;
  pointer-events: none;
}

.fx-rate-form__cell {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.fx-rate-form__cell .ds-input,
.fx-rate-form__cell .ds-select,
.fx-rate-form__cell input:not([type="checkbox"]):not([type="radio"]),
.fx-rate-form__cell select {
  width: 100%;
  max-width: 100%;
  height: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0 12px;
  box-sizing: border-box;
  border: 1px solid var(--ds-border);
  border-radius: 10px;
  font-size: 0.875rem;
  color: var(--ds-text);
  background: #fff;
}

.fx-rate-form__cell input[type="date"] {
  line-height: 44px;
  padding-top: 0;
  padding-bottom: 0;
}

.fx-rate-form__cell input[type="date"]::-webkit-calendar-picker-indicator {
  margin-left: 2px;
}

.fx-rate-form__cell .ds-input:focus,
.fx-rate-form__cell .ds-select:focus,
.fx-rate-form__cell input:focus,
.fx-rate-form__cell select:focus {
  outline: none;
  border-color: var(--ds-border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.fx-rate-form__field--action .btn-primary {
  width: 100%;
  height: 44px;
  min-height: 44px;
  padding: 0 1.25rem;
  white-space: nowrap;
}

.fx-rate-form__errors {
  margin: 0.25rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.75rem;
  color: var(--ds-error);
}

.fx-rate-form__readonly {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  color: var(--ds-text-muted);
  background: #f8fafc;
  border: 1px solid var(--ds-border);
  border-radius: 10px;
}

@media (max-width: 900px) {
  .fx-rate-form__field--date,
  .fx-rate-form__field--currency,
  .fx-rate-form__field--rate,
  .fx-rate-form__field--source,
  .fx-rate-form__field--note {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 9rem;
  }

  .fx-rate-form__field--action {
    flex: 1 1 100%;
  }

  .fx-rate-form__field--action .btn-primary {
    width: auto;
    min-width: 10rem;
  }
}

/* === Финансы → Операции по счетам (перевод / обмен / поступление / кредит) === */
.fin-op-panel[hidden] {
  display: none !important;
}

.fin-op-form {
  display: block;
  margin-bottom: 0;
  max-width: 100%;
}

.fin-op-form__card {
  overflow: hidden;
}

.fin-op-form__body {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.fin-op-form__actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--ds-border, #e5e7eb);
}

.fin-op-form__submit.btn-primary {
  min-width: 9.5rem;
  height: 44px;
  min-height: 44px;
  padding: 0 1.5rem;
  white-space: nowrap;
}

.fin-op-form__head {
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.fin-op-form__mode {
  flex-shrink: 0;
  flex-wrap: wrap;
  max-width: 100%;
}

.fin-op-amt--in {
  color: #16a34a;
  font-weight: 600;
}

.fin-op-amt--out {
  color: #dc2626;
  font-weight: 600;
}

@media (max-width: 720px) {
  .fin-op-form__head {
    flex-direction: column;
    align-items: stretch;
  }

  .fin-op-form__mode {
    width: 100%;
    justify-content: stretch;
  }

  .fin-op-form__mode-btn {
    flex: 1 1 auto;
    text-align: center;
    font-size: 12px;
    padding: 6px 8px;
  }
}

.fin-op-form__mode-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.fin-op-form__grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
}

.fin-op-form__field {
  display: grid;
  grid-template-rows: 2.25rem 44px;
  gap: 0.35rem;
  min-width: 0;
}

/* Единые ширины полей во всех режимах (перевод / обмен / поступление / кредит) */
.fin-op-form__field--date { flex: 0 0 9.5rem; width: 9.5rem; max-width: 9.5rem; }
.fin-op-form__field--src,
.fin-op-form__field--dst,
.fin-op-form__field--account,
.fin-op-form__field--category,
.fin-op-form__field--supplier {
  flex: 0 0 10.25rem;
  width: 10.25rem;
  max-width: 10.25rem;
}
.fin-op-form__field--due { flex: 0 0 9.5rem; width: 9.5rem; max-width: 9.5rem; }
.fin-op-form__field--amount { flex: 0 0 7.25rem; width: 7.25rem; max-width: 7.25rem; }
.fin-op-form__field--amount-to { flex: 0 0 7.75rem; width: 7.75rem; max-width: 7.75rem; }
.fin-op-form__field--comment {
  flex: 1 1 9rem;
  min-width: 8.5rem;
  max-width: 100%;
}

.fin-op-form__label {
  align-self: end;
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.25;
  color: var(--ds-text-muted);
}

.fin-op-form__label--ghost {
  visibility: hidden;
}

.fin-op-form__cell .ds-input,
.fin-op-form__cell .ds-select,
.fin-op-form__cell input,
.fin-op-form__cell select {
  width: 100%;
  height: 44px;
  min-height: 44px;
  margin: 0;
  box-sizing: border-box;
}

.fin-op-form__hint {
  margin: 0.85rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--ds-text-muted);
}

.fin-op-form__preview {
  color: #4338ca;
  font-weight: 500;
}

@media (max-width: 900px) {
  .fin-op-form__field--date,
  .fin-op-form__field--src,
  .fin-op-form__field--dst,
  .fin-op-form__field--account,
  .fin-op-form__field--category,
  .fin-op-form__field--supplier,
  .fin-op-form__field--due,
  .fin-op-form__field--amount,
  .fin-op-form__field--amount-to,
  .fin-op-form__field--comment {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 9rem;
  }

}

@media (max-width: 520px) {
  .fx-rate-form__grid,
  .fin-op-form__grid {
    flex-direction: column;
    align-items: stretch;
  }

  .fx-rate-form__field,
  .fin-op-form__field {
    flex: 1 1 auto;
    width: 100%;
  }

  .fx-rate-form__label--ghost,
  .fin-op-form__label--ghost {
    display: none;
  }

  .fx-rate-form__field--action {
    grid-template-rows: 44px;
  }

  .fx-rate-form__field--action .btn-primary {
    width: 100%;
  }

  .fin-op-form__actions {
    justify-content: stretch;
  }

  .fin-op-form__submit.btn-primary {
    width: 100%;
  }
}

/* Секция формы — те же отступы, что у .document-header-section */
.form-section {
  margin-bottom: 0.75rem;
  background: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  padding: 8px 12px;
}

.form-section:last-child {
  margin-bottom: 0;
}

.form-section__title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ds-text);
  margin: 0 0 0.5rem 0;
}

.form-section.form-section--compact-y {
  padding-top: 8px;
  padding-bottom: 8px;
}

.form-section .form-actions {
  margin-top: 10px;
  padding-top: 8px;
}

/* ERP-сетка: [label] [field] [label] [field] — как .document-header-grid */
.form-grid-horizontal,
.form-grid-2 {
  display: grid;
  grid-template-columns: 150px 1fr 150px 1fr;
  gap: 2px 10px;
  align-items: center;
}

/* Каждое поле — пара label|control (2 колонки родителя), без display:contents */
.form-grid-horizontal > .form-field,
.form-grid-horizontal > .form-group,
.form-grid-2 > .form-field,
.form-grid-2 > .form-group {
  display: grid;
  grid-column: span 2;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 2px 10px;
  align-items: center;
  min-width: 0;
}

.form-grid-horizontal br,
.form-grid-2 br {
  display: none;
}

.form-grid-horizontal > .form-field--full,
.form-grid-horizontal > .form-group.form-field--full,
.form-grid-2 > .form-field--full,
.form-grid-2 > .form-group.form-field--full {
  grid-column: 1 / -1;
}

.form-grid-horizontal > .form-actions,
.form-grid-2 > .form-actions {
  grid-column: 1 / -1;
}

/* Подсказки, ошибки, скрытые поля — не ломают строку label|input */
.form-grid-horizontal > .form-field input[type="hidden"],
.form-grid-horizontal > .form-group input[type="hidden"],
.form-grid-2 > .form-field input[type="hidden"],
.form-grid-2 > .form-group input[type="hidden"] {
  display: none;
}

.form-grid-horizontal > .form-field > p,
.form-grid-horizontal > .form-group > p,
.form-grid-horizontal > .form-field > .text-muted,
.form-grid-horizontal > .form-group > .text-muted,
.form-grid-horizontal > .form-field > .form-errors,
.form-grid-horizontal > .form-group > .form-errors,
.form-grid-horizontal > .form-field > .form-help,
.form-grid-horizontal > .form-group > .form-help,
.form-grid-2 > .form-field > p,
.form-grid-2 > .form-group > p,
.form-grid-2 > .form-field > .text-muted,
.form-grid-2 > .form-group > .text-muted,
.form-grid-2 > .form-field > .form-errors,
.form-grid-2 > .form-group > .form-errors,
.form-grid-2 > .form-field > .form-help,
.form-grid-2 > .form-group > .form-help {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 11px;
  line-height: 1.25;
}

.form-grid-horizontal > .form-group:has(> label:only-child) > label,
.form-grid-2 > .form-group:has(> label:only-child) > label,
.form-grid-horizontal > .form-field:has(> label:only-child) > label,
.form-grid-2 > .form-field:has(> label:only-child) > label {
  grid-column: 1 / -1;
}

/* Плоская разметка: <label> и <input> сразу в .form-grid-2 (например, счета) */
.form-grid-horizontal > label,
.form-grid-2 > label {
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.2;
  color: #374151;
  margin: 0;
  padding: 2px 0;
}

.form-grid-horizontal > .form-field label,
.form-grid-horizontal > .form-field .form-field__label,
.form-grid-horizontal > .form-group label,
.form-grid-2 > .form-field label,
.form-grid-2 > .form-field .form-field__label,
.form-grid-2 > .form-group label,
.form-grid-2 > .form-group .form-field__label {
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.2;
  color: #374151;
  margin: 0;
  padding: 2px 0;
}

.form-grid-horizontal > .form-field .form-field__controls,
.form-grid-2 > .form-field .form-field__controls {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.form-grid-horizontal > .form-field .form-field__controls .ds-input,
.form-grid-horizontal > .form-field .form-field__controls .ds-select,
.form-grid-2 > .form-field .form-field__controls .ds-input,
.form-grid-2 > .form-field .form-field__controls .ds-select {
  width: 100%;
}

.form-grid-horizontal > .form-field input:not([type="hidden"]),
.form-grid-horizontal > .form-field select,
.form-grid-horizontal > .form-field textarea,
.form-grid-horizontal > .form-group input:not([type="hidden"]),
.form-grid-horizontal > .form-group select,
.form-grid-horizontal > .form-group textarea,
.form-grid-horizontal > .form-group .form-control,
.form-grid-2 > .form-field input:not([type="hidden"]),
.form-grid-2 > .form-field select,
.form-grid-2 > .form-field textarea,
.form-grid-2 > .form-group input:not([type="hidden"]),
.form-grid-2 > .form-group select,
.form-grid-2 > .form-group textarea,
.form-grid-2 > .form-group .form-control,
.form-grid-horizontal > label + input.form-control,
.form-grid-horizontal > label + select.form-control,
.form-grid-2 > label + input.form-control,
.form-grid-2 > label + select.form-control {
  height: 32px;
  min-height: 32px;
  padding-top: 4px;
  padding-bottom: 4px;
  font-size: 0.875rem;
  box-sizing: border-box;
}

.form-grid-horizontal > .form-field textarea,
.form-grid-horizontal > .form-group textarea,
.form-grid-horizontal > .form-group .form-control[rows],
.form-grid-2 > .form-field textarea,
.form-grid-2 > .form-group textarea,
.form-grid-2 > .form-group .form-control[rows] {
  height: auto;
  min-height: 56px;
}

@media (max-width: 900px) {
  .form-grid-horizontal,
  .form-grid-2 {
    grid-template-columns: 150px 1fr;
  }
}

/* Orders/create: строки заказа -> карточки на телефонах/планшетах */
@media (max-width: 768px) {
  #order-items-table thead {
    display: none;
  }

  #order-items-table tbody tr {
    display: block;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface);
    padding: 12px;
    margin-bottom: 12px;
  }

  #order-items-table tbody td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 0 !important;
    padding: 8px 0 !important;
    background: transparent !important;
  }

  #order-items-table tbody td::before {
    color: var(--ds-text-muted);
    font-size: 12px;
    font-weight: 500;
    flex: 0 0 120px;
  }

  #order-items-table tbody td:nth-child(1)::before {
    content: "Товар";
  }
  #order-items-table tbody td:nth-child(2)::before {
    content: "Название";
  }
  #order-items-table tbody td:nth-child(3)::before {
    content: "Артикул";
  }
  #order-items-table tbody td:nth-child(4)::before {
    content: "Кол-во";
  }
  #order-items-table tbody td:nth-child(5)::before {
    content: "Цена";
  }
  #order-items-table tbody td:nth-child(6)::before {
    content: "Сумма";
  }
  #order-items-table tbody td:nth-child(7)::before {
    content: "";
    flex: 0 0 auto;
  }

  #order-items-table tbody td:nth-child(7) {
    justify-content: flex-end;
  }

  #order-items-table tbody td:nth-child(7) .btn-delete-line {
    width: 44px !important;
    height: 44px !important;
    font-size: 20px !important;
  }

  #order-items-table .ds-input,
  #order-items-table .ds-select {
    height: 36px;
    font-size: 13px;
  }
}

@media (max-width: 640px) {
  .form-grid-horizontal,
  .form-grid-2 {
    grid-template-columns: 1fr;
  }

  .form-grid-horizontal > .form-field,
  .form-grid-horizontal > .form-group,
  .form-grid-2 > .form-field,
  .form-grid-2 > .form-group {
    grid-column: 1 / -1;
    grid-template-columns: 1fr;
  }
}

/* ========== FORM FIELDS (InputField, SelectField, DateField, FileUpload) ========== */
.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-field__label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ds-text);
}

.form-field__label.is-required::after {
  content: " *";
  color: var(--ds-error);
}

.form-help {
  font-size: 0.8125rem;
  color: var(--ds-text-muted);
  margin-top: 0.25rem;
}

.ds-input,
.ds-select,
.ds-textarea,
.ds-file {
  width: 100%;
  height: var(--ds-input-height);
  padding: 0 12px;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  font-size: 14px;
  color: var(--ds-text);
  background: var(--ds-surface);
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ds-input:focus,
.ds-select:focus,
.ds-textarea:focus {
  outline: none;
  border-color: var(--ds-border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Поле с кнопкой внутри (справа), например автогенерация артикула. Одна рамка — у input. */
.ds-input-wrap {
  position: relative;
  display: flex;
  width: 100%;
  min-width: 0;
}
.ds-input-wrap .ds-input {
  width: 100%;
  min-width: 0;
  padding-right: 42px;
}
.ds-input-wrap .ds-input-wrap__btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  min-height: 28px;
  border-radius: 4px;
  flex-shrink: 0;
  border: none;
  background: var(--ds-page-bg);
  color: var(--ds-text);
  box-shadow: 0 0 0 1px var(--ds-border) inset;
}
.ds-input-wrap .ds-input-wrap__btn:hover {
  background: #E5E7EB;
}
.ds-input-wrap .ds-input-wrap__btn .btn-icon__svg {
  width: 14px;
  height: 14px;
}

.ds-input::placeholder,
.ds-textarea::placeholder {
  color: var(--ds-text-muted);
}

.ds-textarea {
  height: auto;
  min-height: 88px;
  padding: 10px 12px;
  resize: vertical;
}

.ds-file {
  padding: 8px 12px;
  font-size: 0.875rem;
  cursor: pointer;
}

.ds-file::-webkit-file-upload-button {
  margin-right: 0.75rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--ds-border);
  border-radius: 6px;
  background: var(--ds-page-bg);
  cursor: pointer;
  font-size: 0.8125rem;
}

/* Django form-group: apply design system to form-group inputs when inside form-page-layout */
.form-page-layout .form-group,
.form-page-layout .form-field {
  margin-bottom: 1rem;
}
/* No margin when inside horizontal grid (display: contents removes the box) */
.form-grid-horizontal .form-group,
.form-grid-horizontal .form-field,
.form-grid-2 .form-group,
.form-grid-2 .form-field {
  margin-bottom: 0;
}
.form-page-layout .form-group label:not([class]),
.form-page-layout .form-group .form-field__label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ds-text);
  margin-bottom: 0.35rem;
}
.form-page-layout .form-group input[type="text"],
.form-page-layout .form-group input[type="number"],
.form-page-layout .form-group input[type="date"],
.form-page-layout .form-group input[type="email"],
.form-page-layout .form-group select,
.form-page-layout .form-group textarea,
.form-page-layout .form-group .form-control {
  width: 100%;
  height: var(--ds-input-height);
  padding: 0 12px;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  font-size: 14px;
  color: var(--ds-text);
  background: var(--ds-surface);
  box-sizing: border-box;
}
.form-page-layout .form-group textarea,
.form-page-layout .form-group .form-control[rows] {
  height: auto;
  min-height: 88px;
  padding: 10px 12px;
}
.form-page-layout .form-group input:focus,
.form-page-layout .form-group select:focus,
.form-page-layout .form-group textarea:focus {
  outline: none;
  border-color: var(--ds-border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Invalid / error state */
.ds-input.is-invalid,
.ds-select.is-invalid,
.ds-textarea.is-invalid,
.ds-input.input-error,
.ds-select.input-error,
.ds-textarea.input-error {
  border-color: var(--ds-error);
}

.ds-input.input-error:focus,
.ds-select.input-error:focus,
.ds-textarea.input-error:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

/* Success state */
.ds-input.input-success,
.ds-select.input-success,
.ds-textarea.input-success {
  border-color: #10B981;
}

.ds-input.input-success:focus,
.ds-select.input-success:focus,
.ds-textarea.input-success:focus {
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.form-field__hint {
  font-size: 0.8125rem;
  color: var(--ds-text-muted);
}

.form-field__link {
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.form-errors {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--ds-radius);
  padding: 0.75rem 1rem;
}

.form-errors li {
  font-size: 0.875rem;
  color: var(--ds-error);
}

/* ========== BUTTONS (PrimaryButton, SecondaryButton) ========== */
.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--ds-input-height);
  padding: 0 20px;
  border-radius: var(--ds-radius);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  box-sizing: border-box;
}

.btn-primary {
  background: var(--ds-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--ds-primary-hover);
  color: #fff;
}

.btn-secondary {
  background: transparent;
  color: var(--ds-text);
  border: 1px solid var(--ds-secondary-border);
}

.btn-secondary:hover {
  background: var(--ds-page-bg);
  border-color: #9CA3AF;
  color: var(--ds-text);
}

.page-header__actions .btn-primary,
.page-header__actions .btn-secondary {
  margin: 0;
}

/* ========== LIST PAGE HEADER ========== */
.list-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.list-page-header__title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ds-text);
  margin: 0;
}

.list-page-header__toolbar,
.list-page-header__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ========== LIST PAGE LAYOUT + LIST SURFACE (списки на всю ширину) ========== */
.list-page-background {
  background: var(--ds-page-bg);
  padding-bottom: 1.5rem;
}

.list-page-layout {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}

.list-page-layout .page-header {
  margin-bottom: 0.75rem;
}

.list-page-layout .page-header__title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.list-page-layout .tabs {
  margin-bottom: 1rem;
}

/* Одна панель: шапка таблицы + scroll + пагинация */
.list-surface {
  background: var(--ds-surface);
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 12px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 4px 16px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}

.list-surface__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--ds-border);
  background: linear-gradient(180deg, #fafbfc 0%, #ffffff 100%);
}

.list-surface__head-text {
  min-width: 0;
}

.list-surface__title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ds-text);
  letter-spacing: -0.01em;
}

.list-surface__desc {
  margin: 0.2rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--ds-text-muted);
}

.list-surface__head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.list-surface__scroll {
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

.list-surface .data-table {
  width: 100%;
  min-width: 36rem;
}

.list-surface .data-table th {
  height: 38px;
  padding-top: 0;
  padding-bottom: 0;
  background: #f8fafc;
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
}

.list-surface .data-table td {
  height: 40px;
  padding-top: 0;
  padding-bottom: 0;
  font-size: 0.8125rem;
}

.list-surface .data-table th:first-child,
.list-surface .data-table td:first-child {
  padding-left: 1.25rem;
}

.list-surface .data-table th:last-child,
.list-surface .data-table td:last-child {
  padding-right: 1.25rem;
}

.list-surface .data-table tbody tr:nth-child(even) td {
  background: #fafbfc;
}

.list-surface .data-table tbody tr:hover td {
  background: #f3f4f6 !important;
}

.list-surface .data-table tbody tr:last-child td {
  border-bottom: none;
}

.list-surface__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.65rem 1.25rem;
  border-top: 1px solid var(--ds-border);
  background: #f8fafc;
  font-size: 0.8125rem;
  color: var(--ds-text-muted);
}

.list-surface__foot .pagination {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.list-surface__foot .pagination a {
  font-size: 0.8125rem;
  color: var(--ds-primary);
  text-decoration: none;
}

.list-surface__foot .pagination a:hover {
  text-decoration: underline;
}

.list-surface__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
}

.list-surface__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 0.65rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--ds-secondary-border);
  background: #ffffff;
  color: var(--ds-text);
  transition: background 0.12s ease, border-color 0.12s ease;
}

.list-surface__btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
  color: var(--ds-text);
}

.list-surface__btn--danger {
  border-color: #fecaca;
  color: #b91c1c;
  background: #fff;
}

.list-surface__btn--danger:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

.list-surface__toolbar {
  margin: 0;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--ds-border);
  background: #ffffff;
}

.list-surface__cell-list {
  margin: 0;
  padding-left: 1rem;
  list-style: disc;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.list-surface__cell-sub {
  margin-top: 0.25rem;
  font-size: 0.6875rem;
  line-height: 1.35;
  color: var(--ds-text-muted);
}

.list-surface__cell-note {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  line-height: 1.35;
}

.list-surface__cell-note--danger {
  color: #b91c1c;
}

.list-surface__inline-form {
  display: inline;
  margin: 0;
}

.list-surface tbody tr.sale-row {
  cursor: pointer;
}

.list-surface .col-actions {
  width: 1%;
  white-space: nowrap;
}

.list-surface .empty-state {
  padding: 2.5rem 1.25rem;
  margin: 0 auto;
  max-width: 24rem;
}

.list-surface .empty-state__title {
  font-size: 1rem;
}

.ds-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
}

.ds-badge--neutral {
  background: #f3f4f6;
  color: #4b5563;
}

.ds-badge--success {
  background: #ecfdf5;
  color: #047857;
}

.ds-badge--danger {
  background: #fef2f2;
  color: #b91c1c;
}

/* ========== DOCUMENT PAGE PILOT (реализация — document-card--pilot) ========== */
.document-page-background {
  width: 100%;
  padding-bottom: 1.5rem;
}

.document-page-background .page-header {
  margin-bottom: 0.75rem;
}

.document-page-background .tabs {
  margin-bottom: 1rem;
}

/* Одна поверхность документа — без «карточки в карточке» */
.document-card.document-card--pilot {
  max-width: none;
  width: 100%;
  margin: 0 0 1.25rem;
  padding: 1.25rem 1.5rem 1.5rem;
  background: #ffffff;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 12px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 8px 24px rgba(15, 23, 42, 0.06);
}

.document-card--pilot .document-inline-banner {
  margin-bottom: 1rem;
  padding: 0.65rem 1rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #1e40af;
}

/* Шапка: единая панель (Документ | Клиент | Финансы + примечание) */
.document-card--pilot .document-header-section--grouped {
  margin-bottom: 1.25rem;
  border: 1px solid var(--ds-border);
  border-radius: 10px;
  overflow: hidden;
  background: #ffffff;
}

.document-card--pilot .document-header-groups {
  gap: 0;
  margin: 0;
  background: linear-gradient(180deg, #fafbfc 0%, #ffffff 100%);
  border: none;
  border-radius: 0;
}

.document-card--pilot .doc-header-group {
  background: transparent;
  border: none;
  border-radius: 0;
  border-right: 1px solid var(--ds-border);
  padding: 14px 16px;
  box-shadow: none;
}

.document-card--pilot .doc-header-group:last-child {
  border-right: none;
}

.document-card--pilot .doc-header-group--client {
  background: rgba(99, 102, 241, 0.04);
  box-shadow: none;
}

.document-card--pilot .doc-header-group__title {
  margin-bottom: 8px;
  color: #64748b;
}

.document-card--pilot .doc-header-field {
  margin-bottom: 8px;
}

.document-card--pilot .doc-header-field__control .ds-input,
.document-card--pilot .doc-header-field__control .ds-select,
.document-card--pilot .doc-header-field__control input,
.document-card--pilot .doc-header-field__control select {
  height: 32px;
  min-height: 32px;
  font-size: 0.8125rem;
}

.document-card--pilot .document-header-note {
  margin-top: 0;
  padding: 10px 16px;
  background: #f8fafc;
  border: none;
  border-top: 1px solid var(--ds-border);
  border-radius: 0;
}

.document-card--pilot .document-header-note .doc-header-field__label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}

/* Табличная часть — как list-surface */
.document-card--pilot .document-lines-surface {
  margin-bottom: 1rem;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
}

.document-card--pilot .document-lines-surface .document-items-meta {
  margin-bottom: 0;
  padding: 0.75rem 1.25rem;
  background: linear-gradient(180deg, #fafbfc 0%, #ffffff 100%);
  border-bottom: 1px solid var(--ds-border);
}

.document-card--pilot .document-lines-surface .document-items-scroll {
  max-height: min(56vh, 560px);
  border: none;
  border-radius: 0;
  background: #ffffff;
}

.document-card--pilot .document-lines-surface .document-items-table {
  border: 0 !important;
  border-radius: 0 !important;
  margin-bottom: 0 !important;
}

.document-card--pilot .document-lines-surface .document-items-table thead th {
  height: 38px !important;
  padding: 0 12px !important;
  font-size: 0.6875rem !important;
  letter-spacing: 0.04em !important;
  background: #f8fafc !important;
  color: #64748b !important;
  text-transform: uppercase !important;
}

.document-card--pilot .document-lines-surface .document-items-table td {
  padding: 8px 12px !important;
  vertical-align: middle !important;
}

.document-card--pilot .document-lines-surface .document-items-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.document-card--pilot .document-lines-surface .document-items-table tbody tr:nth-child(even) td {
  background: #fafbfc !important;
}

.document-card--pilot .document-lines-surface .document-items-table tbody tr:hover td {
  background: #f1f5f9 !important;
}

.document-card--pilot .document-lines-surface .document-items-table tbody tr:focus-within td {
  background: #eef2ff !important;
}

.document-card--pilot .document-lines-surface .document-items-table .table-input,
.document-card--pilot .document-lines-surface .document-items-table .ds-input,
.document-card--pilot .document-lines-surface .document-items-table .ds-select,
.document-card--pilot .document-lines-surface .document-items-table select {
  height: 32px !important;
  min-height: 32px !important;
  font-size: 0.8125rem !important;
  border-radius: 6px !important;
}

.document-card--pilot .document-lines-surface .document-items-meta__total strong {
  color: #4338ca;
  font-variant-numeric: tabular-nums;
}

.document-card--pilot .document-lines-surface .line-sum {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: #0f172a;
}

.document-card--pilot #rz-table .col-line-type {
  width: 108px;
  min-width: 96px;
}

.document-card--pilot #rz-table .col-position {
  min-width: 12rem;
  width: 38%;
}

.document-card--pilot #rz-table .col-qty {
  width: 88px;
  min-width: 72px;
}

.document-card--pilot #rz-table .col-price {
  width: 104px;
  min-width: 88px;
}

.document-card--pilot #rz-table .col-sum {
  width: 108px;
  min-width: 88px;
}

.document-card--pilot #rz-table .col-del {
  width: 44px;
  min-width: 44px;
}

.document-card--pilot .document-lines-surface .document-items-table tfoot tr:first-child td {
  background: #f8fafc !important;
  border-top: 2px solid var(--ds-border) !important;
  padding: 12px !important;
}

.document-card--pilot .document-lines-surface .document-items-table tfoot .document-totals__value {
  font-size: 1.25rem !important;
  color: #4338ca !important;
}

.document-card--pilot .document-lines-surface .document-items-table tfoot tr.document-items-toolbar-row td {
  background: #ffffff !important;
  border-top: 1px solid var(--ds-border) !important;
}

/* Оплаты — без form-section + data-table-wrap */
.document-card--pilot .document-payments-surface {
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
  margin-bottom: 1rem;
}

.document-card--pilot .document-payments-surface__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 1rem;
  padding: 0.75rem 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--ds-border);
}

.document-card--pilot .document-payments-surface__title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ds-text);
  margin-right: auto;
}

.document-card--pilot .document-payments-surface__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  font-size: 0.8125rem;
  color: var(--ds-text-muted);
}

.document-card--pilot .document-payments-surface__summary strong {
  color: var(--ds-text);
  font-variant-numeric: tabular-nums;
}

.document-card--pilot .document-payments-surface__sep {
  color: #cbd5e1;
}

.document-card--pilot .document-payments-surface__hint {
  flex: 1 1 100%;
  margin: 0;
  font-size: 0.6875rem;
  color: #9ca3af;
  line-height: 1.35;
}

.document-card--pilot .document-payments-surface__scroll {
  overflow-x: auto;
}

.document-card--pilot .document-payments-surface .data-table {
  width: 100%;
  min-width: 36rem;
  font-size: 0.8125rem;
}

.document-card--pilot .document-payments-surface .data-table th {
  height: 36px;
  padding: 0 12px;
  background: #f8fafc;
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.document-card--pilot .document-payments-surface .data-table td {
  height: 38px;
  padding: 0 12px;
}

.document-card--pilot .document-payments-surface__empty {
  padding: 1.25rem !important;
  color: var(--ds-text-muted);
}

.document-card--pilot .document-payments-surface .data-table tbody tr:nth-child(even) td {
  background: #fafbfc;
}

.document-card--pilot .document-payments-surface .data-table tbody tr:hover td {
  background: #f1f5f9 !important;
}

.document-card--pilot .document-footer {
  margin-top: 0;
  padding: 0.875rem 1.25rem;
  background: #f8fafc;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 10px;
  box-shadow: none;
}

.document-card--pilot .document-footer--actions .btn-primary {
  box-shadow: 0 1px 2px rgba(67, 56, 202, 0.2);
}

.document-card--pilot #rz-accept-payment:not(:disabled) {
  border-color: rgba(99, 102, 241, 0.45);
  color: #4338ca;
  background: #eef2ff;
}

.document-card--pilot #rz-accept-payment:not(:disabled):hover {
  background: #e0e7ff;
  border-color: #6366f1;
}

/* Шапка документа — действия под полями (отгрузка edit) */
.document-card--pilot .document-header-form__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0 0 0.25rem;
}

/* Добавление строки / оплаты — компактная панель */
.document-card--pilot .document-add-line-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--ds-border);
  background: #fafbfc;
}

.document-card--pilot .document-lines-surface .document-add-line-bar {
  margin: 0;
}

.document-card--pilot .document-add-line-bar__fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem 1rem;
  flex: 1;
  min-width: 12rem;
}

.document-card--pilot .document-add-line-bar__field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 6rem;
}

.document-card--pilot .document-add-line-bar__field--grow {
  flex: 1;
  min-width: 10rem;
}

.document-card--pilot .document-add-line-bar .ds-input,
.document-card--pilot .document-add-line-bar .ds-select,
.document-card--pilot .document-add-line-bar select {
  height: 32px;
  min-height: 32px;
  font-size: 0.8125rem;
}

.document-card--pilot .document-payments-surface__form {
  border-bottom: 1px solid var(--ds-border);
}

.document-card--pilot .document-add-line-bar--payments {
  background: #ffffff;
}

.document-card--pilot .document-return-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem 1.25rem;
  padding: 0 0 0.75rem;
  margin-bottom: 0.5rem;
}

.document-card--pilot .document-return-options__hint {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--ds-text-muted);
  grid-column: 1 / -1;
}

@media (max-width: 1100px) {
  .document-card--pilot .document-header-groups {
    grid-template-columns: 1fr;
  }

  .document-card--pilot .doc-header-group {
    border-right: none;
    border-bottom: 1px solid var(--ds-border);
  }

  .document-card--pilot .doc-header-group:last-child {
    border-bottom: none;
  }
}

/* ListToolbar: поиск, фильтры, вторичные кнопки — под шапкой списка */
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 1rem;
}

.list-toolbar .ds-input {
  width: 220px;
  min-width: 180px;
  height: 40px;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  padding: 0 12px;
  font-size: 0.9375rem;
}

.list-toolbar .ds-input::placeholder {
  color: var(--ds-text-muted);
}

.list-toolbar .ds-input:focus {
  outline: none;
  border-color: var(--ds-border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.list-toolbar form {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Компактные фильтры: одна линия (с переносом на узких экранах), лейбл и контрол вровень */
.list-toolbar.list-toolbar--compact {
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: nowrap;
  gap: 8px;
}

.list-toolbar.list-toolbar--compact form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.list-toolbar__filter-group,
.report-toolbar__group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Compact report toolbar: labels above fields, all bottoms aligned */
form.report-toolbar.report-toolbar--compact .report-toolbar__group {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

form.report-toolbar.report-toolbar--compact .report-toolbar__group > label {
  line-height: 1.2;
}

form.report-toolbar.report-toolbar--compact .report-toolbar__actions {
  align-self: flex-end;
}

.list-toolbar.list-toolbar--compact .list-toolbar__filter-group > label,
form.report-toolbar.report-toolbar--compact label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ds-text-muted);
  margin: 0;
  white-space: nowrap;
  line-height: 1;
}

.list-toolbar.list-toolbar--compact .ds-input,
.list-toolbar.list-toolbar--compact .ds-select,
.list-toolbar.list-toolbar--compact input[type="date"],
.list-toolbar.list-toolbar--compact input[type="text"],
.list-toolbar.list-toolbar--compact select:not([multiple]),
form.report-toolbar.report-toolbar--compact .ds-input,
form.report-toolbar.report-toolbar--compact .ds-select,
form.report-toolbar.report-toolbar--compact input[type="date"],
form.report-toolbar.report-toolbar--compact input[type="text"],
form.report-toolbar.report-toolbar--compact input[type="number"],
form.report-toolbar.report-toolbar--compact select:not([multiple]) {
  height: 32px;
  min-height: 32px;
  font-size: 12px;
  padding: 0 8px;
  margin: 0;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  box-sizing: border-box;
}

/* Chrome/WebKit date input baseline fix in compact toolbars */
form.report-toolbar.report-toolbar--compact input[type="date"] {
  line-height: 32px;
  padding-top: 0;
  padding-bottom: 0;
}

form.report-toolbar.report-toolbar--compact input[type="date"]::-webkit-datetime-edit,
form.report-toolbar.report-toolbar--compact input[type="date"]::-webkit-datetime-edit-fields-wrapper {
  padding: 0;
}

.list-toolbar.list-toolbar--compact input[type="date"],
form.report-toolbar.report-toolbar--compact input[type="date"] {
  min-width: 128px;
  max-width: 140px;
}

.list-toolbar.list-toolbar--compact .ds-select,
.list-toolbar.list-toolbar--compact select:not([multiple]),
form.report-toolbar.report-toolbar--compact .ds-select,
form.report-toolbar.report-toolbar--compact select:not([multiple]) {
  min-width: 100px;
  max-width: 200px;
}

.list-toolbar.list-toolbar--compact .list-toolbar__actions,
form.report-toolbar.report-toolbar--compact .report-toolbar__actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: auto;
}

.list-toolbar.list-toolbar--compact .btn-primary,
.list-toolbar.list-toolbar--compact .btn-secondary,
form.report-toolbar.report-toolbar--compact .btn-primary,
form.report-toolbar.report-toolbar--compact .btn-secondary {
  padding: 6px 12px;
  font-size: 12px;
  min-height: 32px;
  line-height: 1.2;
}

@media (max-width: 1200px) {
  .list-toolbar.list-toolbar--compact {
    flex-wrap: wrap;
  }

  .list-toolbar.list-toolbar--compact .list-toolbar__actions,
  form.report-toolbar.report-toolbar--compact .report-toolbar__actions {
    margin-left: 0;
  }
}

/* Форма сама является toolbar (справочники: поиск в одной строке) */
form.list-toolbar.list-toolbar--compact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  width: 100%;
  box-sizing: border-box;
}

form.list-toolbar.list-toolbar--compact .ds-input,
form.list-toolbar.list-toolbar--compact .ds-select,
form.list-toolbar.list-toolbar--compact input[type="date"],
form.list-toolbar.list-toolbar--compact input[type="text"],
form.list-toolbar.list-toolbar--compact select:not([multiple]) {
  height: 32px;
  min-height: 32px;
  font-size: 12px;
  padding: 0 8px;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  box-sizing: border-box;
}

form.list-toolbar.list-toolbar--compact .btn-primary,
form.list-toolbar.list-toolbar--compact .btn-secondary {
  padding: 6px 12px;
  font-size: 12px;
  min-height: 32px;
  line-height: 1.2;
}

form.report-toolbar.report-toolbar--compact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

/* SaaS filter card: period + account + type + category + reset */
.filter-card {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.filter-card.filter-card--txn {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-bottom: 14px;
  overflow: hidden;
}

.filter-card__row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.filter-card__row--top {
  justify-content: space-between;
  flex-wrap: nowrap;
}

.filter-card__row--middle {
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.filter-card__search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 360px;
  flex: 1 1 auto;
}

.filter-card__search .ds-input {
  width: 100%;
}

.filter-card__period-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  border: none;
  border-radius: 0;
  padding: 0;
  background: transparent;
}

.filter-card__quick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-card__controls {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  align-items: stretch;
  gap: 8px;
  flex-wrap: nowrap;
  margin-left: auto;
}

.filter-card__cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.filter-card__cell--period {
  min-width: 232px;
}

.filter-card__cell:not(.filter-card__cell--period):not(.filter-card__cell--actions) {
  min-width: 118px;
}

.filter-card__cell > label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ds-text-muted);
  margin: 0;
  white-space: nowrap;
  line-height: 1;
}

.filter-card__prefix {
  font-size: 12px;
  color: var(--ds-text-muted);
  line-height: 1;
}

.filter-card__cell .ds-input,
.filter-card__cell .ds-select {
  height: 40px;
  min-height: 40px;
  font-size: 13px;
  padding: 0 6px;
}

.filter-card__search .ds-input,
.filter-card__controls .ds-select,
.filter-card__period-pill .ds-input {
  height: 40px;
  min-height: 40px;
  font-size: 13px;
}

.filter-card__controls .ds-select {
  min-width: 150px;
}

.filter-card__controls .ds-select,
.filter-card__controls .btn-primary,
.filter-card__controls .btn-secondary {
  height: 40px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  line-height: 1;
  box-sizing: border-box;
  margin: 0;
  align-self: stretch;
  vertical-align: middle;
}

/* exact one-line baseline for controls */
.filter-card__controls > * {
  align-self: stretch;
}

.filter-card__date-range {
  display: flex;
  align-items: center;
  gap: 4px;
}

.filter-card__date-range .ds-input {
  min-width: 124px;
  width: 124px;
}

.filter-card__date-sep {
  color: var(--ds-text-muted);
  font-size: 11px;
}

.filter-card__cell--actions {
  margin-left: auto;
  min-width: max-content;
}

.btn-filter-reset {
  min-height: 40px;
  height: 40px;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  padding: 0 12px;
  width: 40px;
}

.txn-type-badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.txn-type-badge--income {
  background: #dcfce7;
  color: #166534;
}

.txn-type-badge--expense {
  background: #fee2e2;
  color: #991b1b;
}

.txn-type-badge--transfer {
  background: #dbeafe;
  color: #1e40af;
}

#txn-results.txn-results--busy {
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

@media (max-width: 1180px) {
  .filter-card__search {
    min-width: 280px;
  }
  .filter-card__controls .ds-select {
    min-width: 130px;
  }
}

/* В one-line режиме перенос не используем.
   На узком экране просто прокрутка фильтра по X внутри карточки. */

/* ========== REPORTS (report-toolbar, report-kpi, report-chart) ========== */
.report-content {
  max-width: 1200px;
  margin: 0 auto;
}

.report-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 1.5rem;
}

.report-toolbar .ds-input,
.report-toolbar .ds-select {
  width: auto;
  max-width: 160px;
  height: 40px;
  min-width: 120px;
  flex-shrink: 0;
}

.report-toolbar label {
  font-size: 0.875rem;
  color: var(--ds-text-muted);
  margin: 0;
}

.report-kpi {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.report-kpi__card {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--ds-shadow);
}

.report-kpi__card h4 {
  margin: 0 0 0.35rem 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ds-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.report-kpi__card p {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ds-text);
}

.report-kpi__card small {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--ds-text-muted);
}

a.report-kpi__card {
  text-decoration: none;
  color: inherit;
  display: block;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

a.report-kpi__card:hover {
  border-color: var(--ds-border-focus);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.report-chart {
  margin-bottom: 1.5rem;
}

.report-chart h4 {
  margin: 0 0 0.75rem 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ds-text);
}

.form-actions {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 1.25rem;
  border-top: 1px solid var(--ds-border);
}

/* Legacy: откат к классическому виду одной страницы */
.form-page-background--legacy {
  background: var(--ds-page-bg);
  padding-bottom: 0;
}

.form-page-layout--legacy {
  max-width: 900px;
  padding: 32px;
  background: var(--ds-surface);
  border-radius: var(--ds-radius-lg);
  box-shadow: var(--ds-shadow-lg);
}

.form-page-layout--legacy .form-section {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: none;
  padding: 8px 12px;
}

.form-page-layout--legacy .form-actions {
  justify-content: flex-end;
}

/* ========== DATA TABLE ========== */
.data-table-wrap {
  background: var(--ds-surface);
  border-radius: var(--ds-radius-lg);
  box-shadow: var(--ds-shadow);
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th,
.data-table td {
  padding: 0 1rem;
  height: 44px;
  border-bottom: 1px solid var(--ds-border);
  vertical-align: middle;
  box-sizing: border-box;
}

/* 1. Sticky Header — шапка таблицы всегда видна при прокрутке */
.data-table th {
  background: #F9FAFB;
  font-weight: 600;
  color: var(--ds-text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
  border-bottom: 1px solid var(--ds-border);
  box-shadow: 0 1px 0 0 var(--ds-border);
}

.data-table td {
  background: var(--ds-surface);
  color: var(--ds-text);
}

/* 2. Zebra rows — чередование фона для читаемости */
.data-table tbody tr:nth-child(even) td {
  background: #FAFAFA;
}

/* 3. Hover строки */
.data-table tbody tr:hover td {
  background: #F3F4F6 !important;
}

/* 4. Активная строка (фокус в поле ввода) */
.data-table tbody tr:focus-within td {
  background: #EEF2FF !important;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table th.text-right,
.data-table td.text-right,
.data-table th.numeric,
.data-table td.numeric {
  text-align: right;
}

.data-table th.text-center,
.data-table td.text-center {
  text-align: center;
}

/* 6. Ширина колонок — стабильная сетка таблицы */
.col-product { width: 35%; min-width: 120px; }
.col-name { width: 35%; min-width: 120px; }
.col-qty { width: 90px; min-width: 70px; }
.col-price { width: 120px; min-width: 90px; }
.col-sum { width: 140px; min-width: 100px; }
.col-actions { width: 100px; min-width: 80px; }

.data-table__actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Суммы в списках закупок: оплачено / остаток к оплате */
.text-money--paid {
  color: var(--ds-success);
  font-weight: 600;
}

.text-money--due {
  color: var(--ds-error);
  font-weight: 600;
}

.text-money--settled {
  color: var(--ds-text-muted);
  font-weight: 500;
}

.data-table .text-money--paid,
.data-table .text-money--due,
.data-table .text-money--settled {
  font-variant-numeric: tabular-nums;
}

/* Table action icon buttons (edit / delete) */
.btn-icon,
button.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid #E5E7EB;
  background: white;
  color: var(--ds-text);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  box-sizing: border-box;
  font: inherit;
}

.btn-icon__svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-icon-edit:hover,
a.btn-icon.btn-icon-edit:hover {
  background: #F9FAFB;
  border-color: #E5E7EB;
  color: var(--ds-text);
}

.btn-icon-delete {
  border-color: #FEE2E2;
  color: var(--ds-error);
}

.btn-icon-delete:hover {
  background: #FEE2E2;
  border-color: #FEE2E2;
  color: #B91C1C;
}

/* 5. Колонки чисел — выравнивание вправо (бухгалтерский стандарт) */
.numeric,
.text-right {
  text-align: right !important;
}

.text-center {
  text-align: center !important;
}

/* ========== PAGE TABS ========== */
.tabs {
  border-bottom: 1px solid rgba(148, 163, 184, 0.55);
  margin-bottom: 1.5rem;
}

.tabs__list {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 0;
  min-height: 46px;
  align-items: stretch;
}

.tabs__item {
  display: flex;
  align-items: stretch;
}

.tabs__item a {
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 14px;
  color: var(--ds-text-muted);
  text-decoration: none;
  cursor: pointer;
  border-bottom: var(--ds-tab-underline) solid transparent;
  margin-bottom: -1px;
  transition:
    color 0.14s ease,
    border-color 0.14s ease,
    font-weight 0.1s ease;
}

.tabs__item a:hover {
  color: var(--ds-text);
  border-bottom-color: rgba(99, 102, 241, 0.35);
}

.tabs__item--active a,
.tabs__item.tabs__item--active a {
  color: var(--ds-text);
  font-weight: 600;
  border-bottom-color: var(--ds-primary);
}

/* Справочники: стабильные вкладки (единый вес шрифта); без полос прокрутки */
.directory-top.directory-top--spravochnik-nav {
  margin-bottom: 1.25rem;
}

.tabs.tabs--directory-nav .tabs__list {
  flex-wrap: wrap;
  overflow: visible;
}

.tabs.tabs--directory-nav .tabs__item {
  flex: 0 0 auto;
}

.tabs.tabs--directory-nav .tabs__item a {
  font-weight: 500;
  white-space: nowrap;
}

.tabs.tabs--directory-nav .tabs__item:not(.tabs__item--active) a {
  color: var(--ds-text-muted);
  font-weight: 500;
}

.tabs.tabs--directory-nav .tabs__item--active a,
.tabs.tabs--directory-nav .tabs__item.tabs__item--active a {
  color: var(--ds-text);
  font-weight: 600;
}

/* Второй уровень вкладок (например «Структура» → подразделения / должности / смены) */
.tabs.tabs--nested {
  margin-top: 0.25rem;
  margin-bottom: 1.25rem;
}

.tabs.tabs--nested .tabs__list {
  min-height: 40px;
}

.tabs.tabs--nested .tabs__item a {
  font-size: 13px;
  padding: 0 14px;
}

/*
 * Второй ряд вкладок (центр группы): справочник (продукция, прайс), закупки ОС/инвентарь, зарплата.
 * По центру только ряд названий (ul сжат по ширине контента); контент страницы — на всю ширину.
 */
.tabs.tabs--subnav-center {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.tabs.tabs--subnav-center .tabs__list {
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* Закупки / продажи: основные вкладки слева, вспомогательные справа */
.tabs.tabs--purchases,
.tabs.tabs--sales {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  column-gap: 1.5rem;
  row-gap: 0.35rem;
}

.tabs.tabs--purchases .tabs__list,
.tabs.tabs--sales .tabs__list {
  margin-bottom: 0;
  min-height: 48px;
}

.tabs.tabs--purchases .tabs__list--purchases-tools,
.tabs.tabs--sales .tabs__list--sales-tools {
  margin-left: auto;
}

.tabs.tabs--purchases .tabs__item--purchases-tool:not(.tabs__item--active) a,
.tabs.tabs--sales .tabs__item--sales-tool:not(.tabs__item--active) a {
  color: #64748b;
}

.tabs.tabs--purchases .tabs__item--purchases-tool:not(.tabs__item--active) a:hover,
.tabs.tabs--sales .tabs__item--sales-tool:not(.tabs__item--active) a:hover {
  color: #475569;
}

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  background: var(--ds-surface);
  border-radius: var(--ds-radius-lg);
  border: 1px dashed var(--ds-border);
}

.empty-state__icon {
  color: var(--ds-text-muted);
  margin-bottom: 1rem;
}

.empty-state__svg {
  width: 48px;
  height: 48px;
  margin: 0 auto;
  display: block;
}

.empty-state__title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--ds-text);
  margin: 0 0 0.5rem 0;
}

.empty-state__description {
  font-size: 0.9375rem;
  color: var(--ds-text-muted);
  margin: 0 0 1.25rem 0;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

.empty-state__action {
  margin-top: 0.5rem;
}

/* ========== LOADING STATES (skeleton) ========== */
:root {
  --ds-skeleton: linear-gradient(90deg, #F3F4F6 25%, #E5E7EB 50%, #F3F4F6 75%);
  --ds-skeleton-bg: #F3F4F6;
}

.table-loading {
  pointer-events: none;
}

.table-loading .data-table tbody tr td {
  background: var(--ds-skeleton-bg);
  color: transparent;
}

.table-loading .data-table tbody tr td a,
.table-loading .data-table tbody tr td button {
  visibility: hidden;
}

.table-loading .data-table tbody tr td::after {
  content: "";
  display: block;
  height: 16px;
  border-radius: 4px;
  background: var(--ds-skeleton);
  background-size: 200% 100%;
  animation: ds-skeleton 1.2s ease-in-out infinite;
}

.table-loading .data-table tbody tr:hover td {
  background: var(--ds-skeleton-bg);
}

.form-loading .form-page-layout {
  position: relative;
}

.form-loading .form-page-layout::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--ds-radius-lg);
  pointer-events: none;
}

.form-loading .ds-input,
.form-loading .ds-select,
.form-loading .ds-textarea,
.form-loading .btn-primary {
  background: var(--ds-skeleton-bg) !important;
  color: transparent !important;
  border-color: var(--ds-border) !important;
}

.form-loading .ds-input::placeholder,
.form-loading .ds-textarea::placeholder {
  color: transparent;
}

@keyframes ds-skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Search, filter, pagination bar above table */
.data-table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 1rem 1.25rem;
  background: var(--ds-surface);
  border-bottom: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg) var(--ds-radius-lg) 0 0;
}

.data-table-toolbar .ds-input {
  height: 36px;
  min-height: 36px;
}

.data-table-toolbar .ds-select {
  height: 36px;
  min-height: 36px;
}

.data-table-toolbar .btn-primary,
.data-table-toolbar .btn-secondary {
  height: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  padding: 0 12px;
}

.data-table-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 12px;
  color: var(--ds-text-muted);
}

/* Унифицированная группа фильтра: label + control */
.filter-inline-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.filter-inline-group > label {
  margin: 0;
  font-size: 12px;
  color: var(--ds-text-muted);
}

.data-table-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--ds-surface);
  border-top: 1px solid var(--ds-border);
  border-radius: 0 0 var(--ds-radius-lg) var(--ds-radius-lg);
}

/* ========== DOCUMENT PAGE LAYOUT ========== */
.document-card {
  background: var(--ds-surface);
  border-radius: var(--ds-radius-lg);
  padding: 24px;
  box-shadow: var(--ds-shadow-lg);
  margin-bottom: 1.5rem;
}

/* ========== DOCUMENT HEADER SECTION (compact ERP horizontal layout) ========== */
.document-header-section {
  background: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 0.75rem;
}

/* 4-column grid: [label] [field] [label] [field] — label and field on same row */
.document-header-grid {
  display: grid;
  grid-template-columns: 150px 1fr 150px 1fr;
  gap: 2px 10px;
  align-items: center;
}

.document-field {
  display: contents;
}

.document-header-grid .document-field label,
.document-header-grid .document-field .form-field__label {
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.2;
  color: #374151;
  margin: 0;
  padding: 2px 0;
}

.document-header-grid .document-field .ds-input,
.document-header-grid .document-field .ds-select,
.document-header-grid .document-field input[type="text"],
.document-header-grid .document-field input[type="date"],
.document-header-grid .document-field input[type="number"],
.document-header-grid .document-field select {
  width: 100%;
  height: 32px;
  min-height: 32px;
  padding-top: 4px;
  padding-bottom: 4px;
  font-size: 0.875rem;
  box-sizing: border-box;
}

.document-header-grid .document-field .typeahead-wrapper {
  width: 100%;
}

.document-header-grid .document-field .typeahead-wrapper .ds-input,
.document-header-grid .document-field .typeahead-wrapper .typeahead-input {
  height: 32px;
  min-height: 32px;
}

.document-header-grid .document-field .text-muted {
  font-size: 11px;
  line-height: 1.2;
  margin: 0;
}

/* Full-width field (e.g. comment): label and control span all columns and stack */
.document-header-grid .document-field--full label,
.document-header-grid .document-field--full .form-field__label {
  grid-column: 1 / -1;
  margin-bottom: 0;
  padding-bottom: 0;
}

.document-header-grid .document-field--full .ds-input,
.document-header-grid .document-field--full .ds-select,
.document-header-grid .document-field--full input,
.document-header-grid .document-field--full .typeahead-wrapper {
  grid-column: 1 / -1;
}

.document-header-grid .document-field--full .form-help {
  grid-column: 1 / -1;
  margin-top: 0.25rem;
}

/* Responsive: 2 columns on medium screens */
@media (max-width: 900px) {
  .document-header-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Responsive: 1 column on small screens */
@media (max-width: 640px) {
  .document-header-grid {
    grid-template-columns: 1fr;
  }
}

/* ========== DOCUMENT ITEMS TABLE ========== */
.document-items-section {
  margin-bottom: 1rem;
}

.document-items-table__toolbar,
.document-items-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 12px !important;
}

.document-items-table__add {
  /* secondary button style is .btn-secondary */
}

.document-items-table {
  width: 100% !important;
  border-collapse: collapse !important;
  font-size: 0.875rem !important;
  border: 1px solid var(--ds-border) !important;
  border-radius: var(--ds-radius) !important;
  overflow: hidden !important;
  box-shadow: none !important;
  margin-bottom: 0 !important;
}

.document-items-table th,
.document-items-table td {
  box-sizing: border-box;
  background: var(--ds-surface);
}

/* Sticky header для таблиц документов при длинном списке строк */
.document-items-table thead th {
  background: #F3F4F6 !important;
  color: #374151 !important;
  font-weight: 600 !important;
  font-size: 13px !important;
  text-transform: uppercase !important;
  letter-spacing: 0.02em !important;
  border-bottom: 1px solid #E5E7EB !important;
  padding: 10px 12px !important;
  vertical-align: middle !important;
  text-align: left !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 10 !important;
  box-shadow: 0 1px 0 0 #E5E7EB !important;
}

.document-items-table td {
  padding: 10px 12px !important;
  vertical-align: middle !important;
  border-bottom: 1px solid #F1F5F9 !important;
}

/* Zebra + Hover + focus-within для таблиц документов */
.document-items-table tbody tr:nth-child(even) td {
  background: #FAFAFA !important;
}

.document-items-table tbody tr:hover td {
  background: #F3F4F6 !important;
}

.document-items-table tbody tr:focus-within td {
  background: #EEF2FF !important;
}

.document-items-table tbody tr:last-child td {
  border-bottom: none !important;
}

.document-items-table th.text-right,
.document-items-table td.text-right {
  text-align: right !important;
}

/* Компактные поля внутри таблицы документов — перебиваем style.css */
.table-input,
.document-items-table .table-input,
.document-items-table .ds-input,
.document-items-table input[type="number"],
.document-items-table input[type="text"],
.document-items-table select {
  height: 34px !important;
  min-height: 34px !important;
  border: 1px solid #E5E7EB !important;
  border-radius: 6px !important;
  padding: 0 8px !important;
  font-size: 14px !important;
  min-width: 0 !important;
  width: 100% !important;
  box-sizing: border-box !important;
  margin-bottom: 0 !important;
}

.document-items-table td input,
.document-items-table td select {
  width: 100% !important;
  box-sizing: border-box !important;
}

/* Сумма по строке — визуальный акцент */
.line-sum {
  font-weight: 600 !important;
  color: #111827 !important;
}

.btn-delete-line {
  width: 28px !important;
  height: 28px !important;
  border-radius: 6px !important;
  border: 1px solid #FCA5A5 !important;
  background: white !important;
  color: #DC2626 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  cursor: pointer !important;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease !important;
}

.btn-delete-line:hover {
  background: #FEE2E2 !important;
  border-color: #FEE2E2 !important;
  color: #B91C1C !important;
}

.btn-delete-line:focus {
  outline: none !important;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.3) !important;
}

/* ========== DOCUMENT TOTALS ========== */
/* 9. Sticky итог — блок итогов закреплён внизу при прокрутке */
.document-totals {
  text-align: right !important;
  margin-top: 1rem !important;
  padding: 1rem 0 !important;
  background: #F9FAFB !important;
  border-top: 2px solid #E5E7EB !important;
  font-size: 16px !important;
  position: sticky !important;
  bottom: 0 !important;
  z-index: 5 !important;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06) !important;
}

.document-items-table tfoot tr {
  background: #F9FAFB !important;
  border-top: 2px solid #E5E7EB !important;
}

.document-items-table tfoot td {
  padding: 12px !important;
  font-size: 16px !important;
  border-bottom: none !important;
  background: #F9FAFB !important;
}

/* Кнопка «Добавить строку» в футере таблицы */
.document-items-table tfoot tr.document-items-toolbar-row td {
  background: #fff !important;
  border-top: 1px solid #E5E7EB !important;
  padding: 10px 12px !important;
  font-size: 0.875rem !important;
}

.document-items-toolbar-cell {
  vertical-align: middle !important;
}

.document-totals__label {
  font-size: 16px !important;
  font-weight: 600 !important;
  color: #111827 !important;
}

.document-totals__value {
  font-weight: 700 !important;
  font-size: 18px !important;
  color: #111827 !important;
}

/* ========== DOCUMENT FOOTER ========== */
.document-footer {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
}

.document-footer--actions {
  /* наследует стили .document-footer */
}

.document-footer--actions .btn-primary {
  min-height: 44px;
  padding: 0 22px;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: 10px;
}

.document-footer--actions .btn-secondary {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 10px;
}

.document-footer__hint {
  margin-right: auto;
  font-size: 0.8125rem;
  color: var(--ds-text-muted);
}

/* ========== DOCUMENT HEADER GROUPS (реализация и др.) ========== */
.document-header-section--grouped {
  background: transparent;
  border: 0;
  padding: 0;
  margin-bottom: 1rem;
}

.document-header-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.doc-header-group {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px 14px;
}

.doc-header-group--client {
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.08);
}

.doc-header-group--finance {
  border-color: #e5e7eb;
}

.doc-header-group__title {
  margin: 0 0 10px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7280;
}

.doc-header-field {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  margin-bottom: 10px;
}

.doc-header-field:last-child {
  margin-bottom: 0;
}

.doc-header-field__label {
  font-size: 0.75rem;
  font-weight: 500;
  color: #6b7280;
  line-height: 1.2;
}

.doc-header-field__control .ds-input,
.doc-header-field__control .ds-select,
.doc-header-field__control input,
.doc-header-field__control select {
  width: 100%;
  height: 34px;
  min-height: 34px;
  font-size: 0.875rem;
}

.doc-header-field--highlight .doc-header-field__label {
  color: #4338ca;
  font-weight: 600;
}

.doc-header-field--highlight .ds-input,
.doc-header-field--highlight .typeahead-input {
  border-color: rgba(99, 102, 241, 0.45);
  background: #fafaff;
}

.doc-header-field--money .doc-header-field__control input {
  font-weight: 600;
  color: #111827;
}

.doc-header-field--full {
  grid-column: 1 / -1;
}

.document-header-note {
  margin-top: 10px;
}

.document-header-note .ds-input {
  width: 100%;
  height: 34px;
}

.doc-status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
}

.doc-status-pill--due {
  background: #fef3c7;
  color: #92400e;
}

.doc-status-pill--partial {
  background: #dbeafe;
  color: #1e40af;
}

.doc-status-pill--paid {
  background: #dcfce7;
  color: #166534;
}

.doc-status-pill--muted {
  background: #f3f4f6;
  color: #6b7280;
}

.doc-payment-hint {
  margin: 6px 0 0;
  font-size: 0.6875rem;
  line-height: 1.35;
  color: #9ca3af;
}

/* Панель над таблицей документа */
.document-items-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 0 2px;
}

.document-items-meta__title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #374151;
}

.document-items-meta__total {
  font-size: 0.875rem;
  color: #6b7280;
}

.document-items-meta__total strong {
  font-size: 1.125rem;
  font-weight: 700;
  color: #111827;
  margin-left: 6px;
}

/* Прокрутка табличной части + sticky header */
.document-items-scroll {
  max-height: min(52vh, 520px);
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
}

.document-card .document-items-table {
  border: 0 !important;
  border-radius: 0 !important;
}

.document-card .document-items-table tbody tr {
  transition: background 0.12s ease;
}

.document-card .document-items-table .table-input:focus,
.document-card .document-items-table .ds-input:focus,
.document-card .document-items-table select:focus {
  border-color: var(--ds-border-focus) !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12) !important;
  outline: none !important;
}

.document-card .document-items-table tfoot tr:first-child td {
  background: #f8fafc !important;
  border-top: 2px solid #e5e7eb !important;
  padding: 14px 12px !important;
}

.document-card .document-totals__value {
  font-size: 1.375rem !important;
  color: #4338ca !important;
}

.document-card .document-totals__label {
  font-size: 0.9375rem !important;
}

@media (max-width: 1100px) {
  .document-header-groups {
    grid-template-columns: 1fr;
  }
}

/* Прокрутка табличной части на form-page (без document_page_layout) */
.form-page-layout--modern .document-items-section:not(:has(.document-items-scroll)),
.form-page-layout--modern .data-table-wrap:has(.document-items-table) {
  max-height: min(52vh, 520px);
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  margin-bottom: 0.75rem;
}

.form-page-layout--modern .document-items-section:not(:has(.document-items-scroll)) .document-items-table,
.form-page-layout--modern .data-table-wrap:has(.document-items-table) .document-items-table {
  border: 0 !important;
  border-radius: 0 !important;
}

.form-page-layout--modern .document-footer .btn-primary,
.document-card .document-footer .btn-primary {
  min-height: 44px;
  padding: 0 22px;
  font-size: 0.9375rem;
  font-weight: 600;
  border-radius: 10px;
}

.form-page-layout--modern .document-footer .btn-secondary,
.document-card .document-footer .btn-secondary {
  min-height: 40px;
  padding: 0 16px;
  border-radius: 10px;
}

/* Legacy compatibility: .btn without modifier stays usable */
.app-content .btn {
  box-shadow: none;
  transform: none;
}

.app-content .btn:hover {
  transform: none;
}

.app-content .btn.btn-primary { background: var(--ds-primary); color: #fff; }
.app-content .btn.btn-secondary { background: transparent; border: 1px solid var(--ds-secondary-border); color: var(--ds-text); }

/* Global: tables in app-content use design system when not already .data-table */
.app-content table:not(.data-table) {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.875rem;
  border-radius: var(--ds-radius-lg);
  overflow: hidden;
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow);
}
.app-content table:not(.data-table) th,
.app-content table:not(.data-table) td {
  padding: 0 1rem;
  height: 44px;
  border-bottom: 1px solid var(--ds-border);
  vertical-align: middle;
}
.app-content table:not(.data-table) th {
  background: #F9FAFB;
  font-weight: 600;
  color: var(--ds-text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}
.app-content table:not(.data-table) tbody tr:hover td {
  background: #F9FAFB;
}
.app-content .pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}
.app-content > .pagination a,
.app-content .pagination .btn {
  padding: 0.35rem 0.75rem;
  border-radius: var(--ds-radius);
}
.app-content h1,
.app-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ds-text);
  margin: 0 0 1rem 0;
}
.app-content .top-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.app-content .top-menu .btn {
  margin: 0;
}
.app-content form.get-form,
.app-content form[method="get"]:not(.list-toolbar):not(.report-toolbar):not(.filter-card) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.app-content form.get-form input[type="text"],
.app-content form[method="get"]:not(.list-toolbar):not(.report-toolbar):not(.filter-card) input[type="text"],
.app-content form.get-form input[type="date"],
.app-content form[method="get"]:not(.list-toolbar):not(.report-toolbar):not(.filter-card) input[type="date"],
.app-content form.get-form select,
.app-content form[method="get"]:not(.list-toolbar):not(.report-toolbar):not(.filter-card) select {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  font-size: 14px;
}
.app-content .alert,
.app-content .form-errors {
  margin-bottom: 1rem;
}

/* ========== ICON SYSTEM (subtle, optional) ========== */
.ds-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  vertical-align: middle;
  margin-right: 0.35rem;
  opacity: 0.7;
  flex-shrink: 0;
}

.ds-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
}

.ds-icon--date svg { stroke-width: 1.8; }
.ds-icon--money svg { stroke-width: 1.8; }
.ds-icon--supplier svg { stroke-width: 1.8; }
.ds-icon--employee svg { stroke-width: 1.8; }
.ds-icon--upload svg { stroke-width: 1.8; }

/* =============================================================================
 * DS Modal (универсальное модальное окно)
 * ============================================================================= */
.ds-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.ds-modal.is-open {
  display: flex;
}
.ds-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
}
.ds-modal__panel {
  position: relative;
  width: min(560px, calc(100vw - 32px));
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.ds-modal__body .form-grid-2 {
  gap: 10px 14px;
}
.ds-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ds-border);
  background: #F9FAFB;
}
.ds-modal__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ds-text);
}
.ds-modal__close {
  border: 1px solid var(--ds-secondary-border);
  background: #fff;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  line-height: 30px;
  cursor: pointer;
}
.ds-modal__body {
  padding: 16px;
}
.ds-modal__footer {
  padding: 12px 16px;
  border-top: 1px solid var(--ds-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #fff;
}

/* Modal form grid: compact 2-column layout */
.ds-modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
  align-items: start;
}
.ds-modal-grid .form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ds-modal-grid .form-field--full {
  grid-column: 1 / -1;
}
@media (max-width: 640px) {
  .ds-modal-grid {
    grid-template-columns: 1fr;
  }
}

/* ========== MOBILE/TABLET: TABLE -> CARDS (progressive enhancement) ========== */
@media (max-width: 900px) {
  .app-content {
    padding: 0 12px 1rem;
  }

  .mobile-data-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 12px;
  }

  .mobile-data-card {
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    box-shadow: var(--ds-shadow);
    padding: 12px;
  }

  .mobile-data-row {
    display: grid;
    grid-template-columns: 42% 58%;
    gap: 8px;
    padding: 6px 0;
  }

  .mobile-data-row__label {
    color: var(--ds-text-muted);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
  }

  .mobile-data-row__value {
    color: var(--ds-text);
    font-size: 13px;
    line-height: 1.3;
    word-break: break-word;
  }

  .mobile-data-row__value.is-right {
    text-align: right;
  }

  /* Документы с интерактивными таблицами (реализация/создание и т.п.) */
  .document-items-table {
    font-size: 0.82rem !important;
  }

  .document-items-table th,
  .document-items-table td {
    padding: 8px 10px !important;
  }

  .document-items-table input.ds-input,
  .document-items-table select.ds-select,
  .document-items-table textarea.ds-textarea {
    height: 36px;
    padding: 0 10px;
    font-size: 13px;
  }
}

/* ========== MODERN FORM UI (SaaS pilot — form-page-layout--modern) ========== */
.form-page-background--modern {
  background: #f4f5f7;
  padding-bottom: 1.5rem;
}

.form-page-layout--modern {
  max-width: 760px;
  margin: 0 auto;
  padding: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

.form-page-layout--modern .page-header {
  margin-bottom: 1.25rem;
}

.form-page-layout--modern .page-header__title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Старые секции на страницах форм — как ui-card */
.form-page-layout--modern .form-section {
  background: var(--ds-surface);
  border: 1px solid rgba(17, 24, 39, 0.06);
  border-radius: 16px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 8px 24px rgba(15, 23, 42, 0.06);
  padding: 24px 28px;
  margin-bottom: 16px;
}

.form-page-layout--modern .form-section__title {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 0.75rem;
}

.form-page-layout--modern .form-actions {
  flex-direction: row-reverse;
  justify-content: center;
  margin: 16px auto 0;
  padding: 14px 24px;
  max-width: 760px;
  width: min(100%, 760px);
  box-sizing: border-box;
  background: var(--ds-surface);
  border: 1px solid rgba(17, 24, 39, 0.06);
  border-radius: 16px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 8px 24px rgba(15, 23, 42, 0.06);
  border-top: 1px solid rgba(17, 24, 39, 0.06);
}

.form-page-layout--modern .form-actions .btn-primary,
.form-page-layout--modern .form-actions .btn-secondary {
  min-height: 44px;
  padding: 0 20px;
  border-radius: 12px;
  font-size: 0.9375rem;
}

.form-page-layout--modern .form-actions .btn-primary {
  font-weight: 600;
}

/* Широкие формы (таблицы строк) */
.form-page-layout--modern.form-page-layout--wide {
  max-width: 1280px;
}


.ui-card {
  background: var(--ds-surface);
  border: 1px solid rgba(17, 24, 39, 0.06);
  border-radius: 16px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 8px 24px rgba(15, 23, 42, 0.06);
  padding: 24px 28px;
  margin-bottom: 16px;
}

.ui-card:last-of-type {
  margin-bottom: 0;
}

.ui-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.ui-card__title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ds-text);
}

.ui-card__desc {
  margin: 4px 0 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--ds-text-muted);
}

.ui-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 20px;
}

.ui-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.ui-field--full {
  grid-column: 1 / -1;
}

.ui-field__label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #374151;
  line-height: 1.2;
}

.ui-field__label.is-required::after {
  content: " *";
  color: var(--ds-error);
}

.ui-field__hint {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--ds-text-muted);
}

.ui-field--checkbox {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}

.ui-field--checkbox label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ds-text);
  cursor: pointer;
}

.ui-field--checkbox input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--ds-primary);
}

/* Современные контролы внутри ui-field */
.form-page-layout--modern .ui-field .ds-input,
.form-page-layout--modern .ui-field .ds-select,
.form-page-layout--modern .ui-field .ds-textarea,
.form-page-layout--modern .ui-field .ds-file,
.form-page-layout--modern .ui-field .form-control,
.form-page-layout--modern .ui-field input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.form-page-layout--modern .ui-field select,
.form-page-layout--modern .ui-field textarea {
  width: 100%;
  min-height: 44px;
  height: 44px;
  padding: 0 14px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  font-size: 0.9375rem;
  color: var(--ds-text);
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-page-layout--modern .ui-field textarea,
.form-page-layout--modern .ui-field .ds-textarea {
  height: auto;
  min-height: 96px;
  padding-top: 10px;
  padding-bottom: 10px;
  resize: vertical;
}

.form-page-layout--modern .ui-field .ds-input:hover,
.form-page-layout--modern .ui-field .ds-select:hover,
.form-page-layout--modern .ui-field input:not([type="checkbox"]):not([type="radio"]):hover,
.form-page-layout--modern .ui-field select:hover {
  border-color: #d1d5db;
}

.form-page-layout--modern .ui-field .ds-input:focus,
.form-page-layout--modern .ui-field .ds-select:focus,
.form-page-layout--modern .ui-field input:not([type="checkbox"]):not([type="radio"]):focus,
.form-page-layout--modern .ui-field select:focus,
.form-page-layout--modern .ui-field textarea:focus {
  outline: none;
  border-color: var(--ds-border-focus);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.form-page-layout--modern .ui-field .ds-input::placeholder,
.form-page-layout--modern .ui-field textarea::placeholder {
  color: #9ca3af;
}

.ui-disclosure {
  margin-top: 4px;
  border-top: 1px solid #f3f4f6;
  padding-top: 12px;
}

.ui-disclosure > summary {
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ds-text-muted);
  list-style: none;
}

.ui-disclosure > summary::-webkit-details-marker {
  display: none;
}

.ui-disclosure[open] > summary {
  margin-bottom: 12px;
  color: var(--ds-text);
}

/* В конце формы, в потоке документа (без sticky/fixed) */
.ui-form-sticky {
  position: static;
  margin-top: 16px;
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.ui-form-sticky__inner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 14px 24px;
  background: var(--ds-surface);
  border: 1px solid rgba(17, 24, 39, 0.06);
  border-radius: 16px;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 8px 24px rgba(15, 23, 42, 0.1);
}

.form-page-layout--modern.form-page-layout--wide .ui-form-sticky__inner {
  max-width: none;
}

.form-page-layout--modern .ui-form-sticky .btn-primary {
  min-height: 44px;
  padding: 0 22px;
  border-radius: 12px;
  font-size: 0.9375rem;
  font-weight: 600;
}

.form-page-layout--modern .ui-form-sticky .btn-secondary {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  font-size: 0.9375rem;
}

@media (max-width: 900px) {
  .ui-form-grid {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 640px) {
  .ui-card {
    padding: 18px 16px;
    border-radius: 14px;
  }
}

/* =============================================================================
 * FORM SURFACE v2 — пилот: компактный двухколоночный layout карточек
 * Использование: {% extends 'components/form_surface_layout.html' %}
 * Блоки: page_header, form_surface_content
 * Колонки: .fs-wrap > .fs-col (основная) + .fs-col (сайдбар 320px)
 * ============================================================================= */

/* Фон страницы */
.fs-bg {
  background: var(--ds-page-bg);
  min-height: 100%;
  padding-bottom: 4.5rem; /* место под sticky-footer */
}

/* Двухколоночная сетка: основная + правый сайдбар */
.fs-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 0;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1rem;
  align-items: start;
}

/* Вертикальный стек карточек внутри колонки */
.fs-col {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

/* Карточка-секция */
.fs-card {
  background: #fff;
  border: 1px solid var(--ds-border);
  border-radius: 10px;
  box-shadow:
    0 1px 3px rgba(15, 23, 42, 0.05),
    0 0 0 0.5px rgba(15, 23, 42, 0.03);
  overflow: hidden;
}

/* Заголовок карточки */
.fs-card__head {
  padding: 0.625rem 1.125rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafafa;
}

.fs-card__title {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.065em;
  text-transform: uppercase;
  color: var(--ds-text-muted);
}

/* Тело карточки */
.fs-card__body {
  padding: 1rem 1.125rem;
}

/* Сетки полей */
.fs-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1rem;
}

.fs-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem 1rem;
}

/* Одно поле (лейбл + инпут) */
.fs-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.fs-field label,
.fs-field__label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ds-text-muted);
  line-height: 1.2;
}

/* Поле на всю ширину внутри fs-grid */
.fs-field--full {
  grid-column: 1 / -1;
}

/* Мета-строки (key: value) в сайдбаре */
.fs-meta {
  font-size: 0.8125rem;
  color: var(--ds-text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.fs-meta__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.fs-meta__row strong {
  font-weight: 600;
  color: var(--ds-text);
}

.fs-meta__row--total {
  padding-top: 0.5rem;
  border-top: 1px solid rgba(15, 23, 42, 0.07);
  font-weight: 600;
  color: var(--ds-text);
}

/* Разделитель внутри карточки */
.fs-divider {
  border: none;
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  margin: 0.875rem 0;
}

/* Sticky-footer с кнопками */
.fs-footer {
  padding: 1rem 1.5rem 1.5rem;
  border-top: 1px solid var(--ds-border);
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}

.fs-status-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.35rem 0;
}

.fs-status-row__btn {
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
  min-height: auto;
  height: auto;
}

/* ── Input Group: поле + прикреплённая кнопка (используется для артикула с генерацией) ── */
.input-group {
  display: flex;
  align-items: stretch;
  width: 100%;
}
.input-group .ds-input {
  flex: 1;
  min-width: 0;
  border-radius: var(--ds-radius) 0 0 var(--ds-radius);
  border-right: none;
}
.input-group .ds-input:focus {
  position: relative;
  z-index: 1;
  border-right: none;
}
.input-group__btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0 0.75rem;
  background: var(--ds-surface-1);
  border: 1px solid var(--ds-border);
  border-left: none;
  border-radius: 0 var(--ds-radius) var(--ds-radius) 0;
  cursor: pointer;
  color: var(--ds-text-2);
  font-size: 0.8125rem;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  height: 36px;
}
.input-group__btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.input-group__btn:hover {
  background: var(--ds-surface-2);
  color: var(--ds-text-1);
}
.input-group__btn:active {
  background: #e5e7eb;
}

/* Help-карточка в правой колонке формы */
.fs-card--help {
  background: #f0f9ff;
  border-color: #bae6fd;
}
.fs-card--help .fs-card__head {
  background: #e0f2fe;
  border-bottom-color: #bae6fd;
}
.fs-card--help .fs-card__title {
  color: #0369a1;
  font-size: 0.8125rem;
}
.fs-help-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.fs-help-list li {
  font-size: 0.8125rem;
  color: #0c4a6e;
  line-height: 1.5;
  padding-left: 0.9rem;
  position: relative;
}
.fs-help-list li::before {
  content: "·";
  position: absolute;
  left: 0;
  color: #38bdf8;
  font-weight: 700;
}

/* Компактные инпуты внутри fs-card */
.fs-card .ds-input,
.fs-card .ds-select,
.fs-card .form-control,
.fs-card input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.fs-card select {
  height: 36px;
  min-height: 36px;
  padding: 0 10px;
  font-size: 0.875rem;
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  width: 100%;
  box-sizing: border-box;
  background: #fff;
  color: var(--ds-text);
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.03);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  line-height: 1;
}

.fs-card .ds-textarea,
.fs-card textarea {
  min-height: 84px;
  height: auto;
  padding: 8px 10px;
  font-size: 0.875rem;
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  width: 100%;
  box-sizing: border-box;
  background: #fff;
  color: var(--ds-text);
  resize: vertical;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.03);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.fs-card input:not([type="checkbox"]):not([type="radio"]):focus,
.fs-card select:focus,
.fs-card textarea:focus {
  outline: none;
  border-color: var(--ds-border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.fs-card input::placeholder,
.fs-card textarea::placeholder {
  color: #9ca3af;
}

/* Errors */
.fs-card .form-errors {
  margin: 0 0 0.875rem;
  padding: 0.625rem 1rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 7px;
  list-style: none;
  font-size: 0.8125rem;
  color: var(--ds-error);
}

/* Адаптив: стек на узких экранах */
@media (max-width: 860px) {
  .fs-wrap {
    grid-template-columns: 1fr;
  }

  .fs-grid-3 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 540px) {
  .fs-grid-2,
  .fs-grid-3 {
    grid-template-columns: 1fr;
  }

  .fs-wrap {
    padding: 1rem;
  }
}

/* ========================================================================
   LIST SURFACE v2 — ls-toolbar, ls-seg-btn, ls-filter-bar
   Compact unified toolbar: segment view-switcher + actions + collapsible filter
   ======================================================================== */

/* Toolbar row ------------------------------------------------------------ */
.ls-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 1.25rem;
  border-bottom: 1px solid var(--ds-border, #e5e7eb);
  background: #fff;
  flex-wrap: wrap;
  min-height: 52px;
}

.ls-toolbar__left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.ls-toolbar__right {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-shrink: 0;
  margin-left: auto;
}

/* Segment / view-switcher buttons --------------------------------------- */
.ls-seg {
  display: inline-flex;
  align-items: stretch;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #d1d5db;
}

.ls-seg__btn {
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
  height: 32px;
  font-size: 0.8rem;
  font-weight: 500;
  color: #4b5563;
  background: #f9fafb;
  border: none;
  border-right: 1px solid #d1d5db;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
  line-height: 1;
}

.ls-seg__btn:last-child {
  border-right: none;
}

.ls-seg__btn:hover {
  background: #f3f4f6;
  color: #111827;
}

.ls-seg__btn--active {
  background: var(--ds-primary, #6366f1);
  color: #fff;
  font-weight: 600;
  border-right-color: transparent;
}

.ls-seg__btn--active:hover {
  background: var(--ds-primary-dark, #4f46e5);
  color: #fff;
}

.ls-seg__btn--active + .ls-seg__btn {
  border-left: 1px solid var(--ds-primary, #6366f1);
}

/* Compact secondary/icon buttons in toolbar */
.ls-toolbar .btn-secondary,
.ls-toolbar .btn-primary {
  height: 32px;
  font-size: 0.8rem;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.ls-toolbar .btn-primary {
  font-weight: 600;
}

/* Filter toggle: active = filled */
.ls-filter-btn.is-active {
  background: var(--ds-primary, #6366f1);
  color: #fff;
  border-color: var(--ds-primary, #6366f1);
}
.ls-filter-btn.is-active:hover {
  background: var(--ds-primary-dark, #4f46e5);
}

/* Collapsible filter bar ------------------------------------------------ */
.ls-filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.25rem;
  border-bottom: 1px solid var(--ds-border, #e5e7eb);
  background: #f8fafc;
  flex-wrap: wrap;
}

.ls-filter-bar[hidden] { display: none !important; }

.ls-filter-bar .ds-input,
.ls-filter-bar .ds-select {
  height: 32px;
  min-height: 32px;
  font-size: 0.8rem;
  padding: 0 9px;
}

.ls-filter-bar .ds-input { min-width: 190px; max-width: 250px; }
.ls-filter-bar .ds-select { min-width: 130px; }

.ls-filter-bar .btn-secondary {
  height: 32px;
  font-size: 0.8rem;
  padding: 0 12px;
}

/* Table refinements inside list-surface --------------------------------- */
.list-surface .data-table th {
  height: 34px !important;
  background: #f1f3f5 !important;
  font-size: 0.675rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.07em !important;
  color: #6b7280 !important;
  text-transform: uppercase !important;
  border-bottom: 2px solid #e5e7eb !important;
}

.list-surface .data-table td {
  height: 38px !important;
  font-size: 0.8125rem !important;
  color: #111827;
}

.list-surface .data-table tbody tr:nth-child(even) td {
  background: #fafbfc !important;
}

.list-surface .data-table tbody tr:hover td {
  background: #eff6ff !important;
}

/* Count/meta badge in toolbar */
.ls-count {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  color: var(--ds-text-muted, #6b7280);
  white-space: nowrap;
}

/* Pagination footer (List Surface) */
.ls-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  width: 100%;
}

.ls-pagination__meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.ls-pagination__count {
  font-size: 0.8125rem;
  color: var(--ds-text-muted, #6b7280);
  white-space: nowrap;
}

.ls-pagination__per-page {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
}

.ls-pagination__per-page-label {
  font-size: 0.8125rem;
  color: var(--ds-text-muted, #6b7280);
  margin: 0;
  white-space: nowrap;
}

.ls-pagination__per-page-select {
  min-width: 4.5rem;
  height: 32px;
  padding: 0 0.5rem;
  font-size: 0.8125rem;
}

.ls-pagination__nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.ls-pagination__btn {
  min-width: 32px;
  height: 32px;
  padding: 0 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
}

.ls-pagination__btn.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.ls-pagination__current {
  min-width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ds-primary, #2563eb);
  background: #eff6ff;
  border-radius: 6px;
}

.list-surface__foot .ls-pagination {
  padding: 0;
  border: none;
  background: transparent;
}

@media (max-width: 640px) {
  .ls-toolbar {
    padding: 0.5rem 0.75rem;
  }
  .ls-seg__btn {
    padding: 0 9px;
    font-size: 0.75rem;
  }
  .ls-filter-bar {
    padding: 0.5rem 0.75rem;
  }
  .ls-pagination {
    flex-direction: column;
    align-items: stretch;
  }
  .ls-pagination__nav {
    justify-content: center;
  }
}

/* ========== Production master-detail (Состав / Маршрут) ========== */
.prod-md__desc {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  color: var(--ds-text-muted, #6b7280);
}

.prod-md__grid {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 1rem;
  align-items: start;
}

.prod-md__aside.list-surface {
  min-height: 420px;
}

.prod-md__aside .list-surface__scroll {
  max-height: 52vh;
  overflow: auto;
}

.prod-md__aside .data-table td a {
  font-weight: 600;
  color: var(--ds-primary, #2563eb);
  text-decoration: none;
}

.prod-md__aside .data-table tr.is-selected td {
  background: #eff6ff !important;
}

.prod-md__status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}

.prod-md__status-dot--empty {
  background: #d1d5db;
}

.prod-md__main {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}

.prod-md__panel {
  background: var(--ds-surface, #fff);
  border: 1px solid var(--ds-border, #e5e7eb);
  border-radius: var(--ds-radius-lg, 10px);
  overflow: hidden;
}

.prod-md__panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--ds-border, #e5e7eb);
  background: #f8fafc;
}

.prod-md__panel-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.prod-md__panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.prod-md__copy-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0;
}

.prod-md__copy-form .ds-select {
  min-width: 200px;
  max-width: 280px;
}

.prod-md__form-table-wrap {
  overflow-x: auto;
}

.prod-md__form-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.prod-md__form-table th {
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ds-text-muted, #6b7280);
  background: #f1f3f5;
  border-bottom: 1px solid var(--ds-border, #e5e7eb);
  white-space: nowrap;
}

.prod-md__form-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #f1f3f5;
  vertical-align: middle;
}

.prod-md__form-table td input[type="text"],
.prod-md__form-table td input[type="number"],
.prod-md__form-table td select {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 0.5rem;
  font-size: 0.8125rem;
  border: 1px solid var(--ds-border, #e5e7eb);
  border-radius: 6px;
}

.prod-md__form-table tr.row-warn td {
  background: #fffbeb;
}

.prod-md__form-table tr.row-error td {
  background: #fef2f2;
}

.prod-md__form-table tfoot td {
  background: #f8fafc;
  font-weight: 600;
}

.prod-md__form-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--ds-border, #e5e7eb);
  background: #fafbfc;
}

.prod-md__empty {
  padding: 2rem 1.5rem;
  text-align: center;
  color: var(--ds-text-muted);
  font-size: 0.875rem;
}

/* Callout / справка */
.ds-callout {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
}

.ds-callout--info {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.ds-callout__title {
  margin: 0 0 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #1e40af;
}

.ds-callout__text {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  color: #1e3a8a;
  line-height: 1.45;
}

.ds-callout__links {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.8125rem;
  color: #1e3a8a;
}

.ds-callout__links a {
  color: var(--ds-primary, #2563eb);
  font-weight: 500;
}

@media (max-width: 900px) {
  .prod-md__grid {
    grid-template-columns: 1fr;
  }
  .prod-md__aside .list-surface__scroll {
    max-height: 240px;
  }
}

/* Таблица норм/операций внутри Form Surface (Состав, Маршрут) */
.prod-doc-table-wrap {
  overflow-x: auto;
}

.prod-doc-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

/* Первая колонка — выбор материала / операции (шире) */
.prod-doc-table th:first-child,
.prod-doc-table td:first-child {
  width: 46%;
  min-width: 200px;
}

.prod-doc-table__col-sm {
  width: 82px;
}

.prod-doc-table__col-act {
  width: 44px;
}

.prod-doc-table th {
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ds-text-muted, #6b7280);
  background: #f1f3f5;
  border-bottom: 1px solid var(--ds-border, #e5e7eb);
  white-space: nowrap;
}

.prod-doc-table td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #f1f3f5;
  vertical-align: middle;
}

.prod-doc-table td input[type="text"],
.prod-doc-table td input[type="number"],
.prod-doc-table td select {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 0.5rem;
  font-size: 0.8125rem;
  border: 1px solid var(--ds-border, #e5e7eb);
  border-radius: 6px;
}

.prod-doc-table tr.row-warn td {
  background: #fffbeb;
}

.prod-doc-table tr.row-error td {
  background: #fef2f2;
}

.prod-doc-table tfoot td {
  background: #f8fafc;
  font-weight: 600;
}

.prod-doc-table__meta {
  font-size: 0.7rem;
  color: var(--ds-text-muted);
  margin-top: 2px;
}

.prod-doc-table__del {
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}

.prod-doc-table__del span {
  display: none;
}

#prod-picker-select {
  max-width: 100%;
}
