/* =============================================================================
   FM · Components — всё, из чего собираются экраны.
   Правило: новый экран не вводит новых стилей, он комбинирует эти классы.
   Живой каталог: /ui-kit.html

   Материал интерфейса. Поверхность не лежит на фоне плоско: у неё есть
   кромка (внутренний блик сверху) и тень, тонированная петролем. Кликабельное
   поднимается при наведении и проседает при нажатии — как настоящая клавиша.
   ========================================================================== */

/* --- 1. Карточка ------------------------------------------------------------ */

.card {
  background: var(--fm-surface);
  border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius-lg);
  box-shadow: var(--fm-shadow-sm), var(--fm-inset-top);
}
.card__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 14px 17px; border-bottom: 1px solid var(--fm-border-soft);
}
.card__title {
  font-family: var(--fm-font-display); font-weight: 700; font-size: var(--fm-fs-h3);
  letter-spacing: var(--fm-tr-title);
}
.card__sub   { font-size: var(--fm-fs-xs); color: var(--fm-text-3); margin-top: 2px; }
.card__body  { padding: 17px; }
.card__body--flush { padding: 0; }
.card__foot  {
  padding: 13px 17px; border-top: 1px solid var(--fm-border-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--fm-surface-subtle);
  border-radius: 0 0 var(--fm-radius-lg) var(--fm-radius-lg);
}

/* Двойная кромка: карточка не лежит на фоне, а сидит в лотке. Внутренний
   радиус на шаг меньше внешнего — кривые получаются концентрическими.
   Применяется к главным блокам экрана, не ко всем подряд. */
.card--shell {
  background: var(--fm-brand-tint-2);
  border-color: var(--fm-brand-line-2);
  border-radius: var(--fm-radius-xl);
  padding: 5px;
  box-shadow: var(--fm-shadow-md);
}
.card--shell > .card__head,
.card--shell > .card__body,
.card--shell > .card__foot {
  background: var(--fm-surface);
  border: 0;
}
.card--shell > .card__head { border-radius: 13px 13px 0 0; border-bottom: 1px solid var(--fm-border-soft); }
.card--shell > .card__body { border-radius: 13px; }
.card--shell > .card__head + .card__body { border-radius: 0 0 13px 13px; }
.card--shell > .card__foot { background: transparent; padding: 10px 13px 6px; }

.card--accent { border-color: var(--fm-accent-line); background: var(--fm-accent-tint); }
.card--brand  { border-color: var(--fm-brand-line); background: var(--fm-brand-tint); }
.card--danger { border-color: var(--fm-accent-line); background: var(--fm-accent-tint); }

/* Формы ж/д и авто. Тонируется только шапка: поля остаются на белом,
   но с одного взгляда видно, что это две разные формы, а не одна.
   Ж/д — петроль, авто — вермильон: тот же язык, что и во всех списках. */
.card--rail, .card--auto { overflow: hidden; }
.card--rail { border-color: var(--fm-brand-line); }
.card--rail .card__head {
  background: var(--fm-brand-tint); border-bottom-color: var(--fm-brand-line);
  box-shadow: inset 0 2px 0 var(--fm-brand);
}
.card--rail .card__title { color: var(--fm-brand); }
.card--auto { border-color: var(--fm-accent-line); }
.card--auto .card__head {
  background: var(--fm-accent-tint); border-bottom-color: var(--fm-accent-line);
  box-shadow: inset 0 2px 0 var(--fm-accent);
}
.card--auto .card__title { color: var(--fm-accent-deep); }

/* --- 2. Кнопки --------------------------------------------------------------
   Заливка главной кнопки — вермильон #C2470F: белый текст даёт 5.0:1.
   Яркий #F0703A на кнопках с текстом не используется — там контраст 2.9:1. */

.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--fm-radius);
  font-family: var(--fm-font-display); font-weight: 600; font-size: var(--fm-fs-sm);
  letter-spacing: -.005em;
  border: 1px solid transparent; white-space: nowrap;
  transition: background var(--fm-t-fast), border-color var(--fm-t-fast),
              color var(--fm-t-fast), box-shadow var(--fm-t-fast),
              transform 90ms var(--fm-ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px) scale(.985); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }

/* Главное действие экрана. Одна такая кнопка на экран. */
.btn--primary {
  background: var(--fm-accent); color: #fff;
  box-shadow: 0 1px 2px rgba(168, 65, 15, .3), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn--primary:hover {
  background: var(--fm-accent-deep); color: #fff;
  box-shadow: 0 4px 12px -4px rgba(168, 65, 15, .5), inset 0 1px 0 rgba(255, 255, 255, .18);
}

/* Действие «по системе»: сохранить фильтр, перейти в реестр, подтвердить. */
.btn--brand { background: var(--fm-brand); color: #fff; box-shadow: var(--fm-inset-top); }
.btn--brand:hover { background: var(--fm-brand-soft); color: #fff; }

.btn--secondary {
  background: var(--fm-surface); color: var(--fm-text-2);
  border-color: var(--fm-border); box-shadow: var(--fm-shadow-sm);
}
.btn--secondary:hover {
  border-color: var(--fm-brand-line); color: var(--fm-brand);
  background: var(--fm-brand-tint-2);
}

.btn--accent { background: var(--fm-accent); color: #fff; }
.btn--accent:hover { background: var(--fm-accent-deep); color: #fff; }

.btn--danger { background: var(--fm-accent); color: #fff; }
.btn--danger:hover { background: var(--fm-accent-deep); color: #fff; }

.btn--success { background: var(--fm-brand); color: #fff; }
.btn--success:hover { background: var(--fm-brand-soft); color: #fff; }

.btn--ghost { background: transparent; color: var(--fm-text-2); }
.btn--ghost:hover { background: var(--fm-brand-tint-2); color: var(--fm-brand); }

.btn--sm { padding: 6px 11px; font-size: var(--fm-fs-xs); border-radius: var(--fm-radius-sm); }
.btn--lg { padding: 14px 24px; font-size: var(--fm-fs-h3); border-radius: var(--fm-radius-lg); }
.btn--block { width: 100%; }
.btn--icon { padding: 0; width: 34px; height: 34px; flex: none; }

/* Стрелка не висит голой рядом с текстом — она сидит в своём кружке,
   прижатом к правому краю. При наведении кружок уезжает по диагонали. */
.btn__pip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; flex: none; margin: -3px -5px -3px 2px;
  border-radius: 50%; background: rgba(255, 255, 255, .18);
  transition: transform var(--fm-t-fast), background var(--fm-t-fast);
}
.btn:hover .btn__pip { transform: translate(2px, -1px) scale(1.06); background: rgba(255, 255, 255, .28); }
.btn--secondary .btn__pip, .btn--ghost .btn__pip { background: var(--fm-brand-tint); }
.btn--secondary:hover .btn__pip, .btn--ghost:hover .btn__pip { background: var(--fm-brand-line); }

.btn--loading { position: relative; color: transparent !important; pointer-events: none; }
.btn--loading::after {
  content: ''; position: absolute; width: 15px; height: 15px;
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
  color: #fff; animation: fm-spin .7s linear infinite;
}
.btn--secondary.btn--loading::after { color: var(--fm-text-2); }

.btn-group { display: inline-flex; gap: 7px; flex-wrap: wrap; }

/* --- 3. Бейдж статуса — единый компонент для списков и карточек --------------
   Четыре состояния различаются не только цветом, но и плотностью: заливка
   против подложки. Поэтому они читаются и в чёрно-белой распечатке. */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: var(--fm-radius-pill);
  font-weight: 600; font-size: var(--fm-fs-xs);
  border: 1px solid transparent; white-space: nowrap;
  letter-spacing: -.005em;
}

/* Закрыто, подтверждено, оплачено — петроль заливкой: решение принято */
.badge--ok { background: var(--fm-brand); color: #fff; border-color: var(--fm-brand); }

/* Справочное, в работе — петроль подложкой */
.badge--info { background: var(--fm-info-bg); color: var(--fm-info-fg); border-color: var(--fm-info-line); }

/* Ждёт действия, приближается срок — вермильон подложкой */
.badge--warn { background: var(--fm-warn-bg); color: var(--fm-warn-fg); border-color: var(--fm-warn-line); }

/* Брак, просрочка, перерасход — вермильон заливкой: требует реакции */
.badge--danger { background: var(--fm-accent); color: #fff; border-color: var(--fm-accent); }

.badge--neutral { background: var(--fm-neutral-bg); color: var(--fm-neutral-fg); border-color: var(--fm-neutral-line); }
.badge--rail    { background: var(--fm-brand-tint); color: var(--fm-brand); border-color: var(--fm-brand-line); }
.badge--auto    { background: var(--fm-accent-tint); color: var(--fm-accent-deep); border-color: var(--fm-accent-line); }
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

/* Ромб вместо точки — тот же знак, что в марке и перед заголовком */
.badge__pip { width: 6px; height: 6px; background: currentColor; border-radius: 1px; transform: rotate(45deg); flex: none; }

.counter {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 19px; height: 19px; padding: 0 6px;
  background: var(--fm-accent); color: #fff;
  border-radius: var(--fm-radius-pill);
  font-family: var(--fm-font-mono); font-weight: 600; font-size: 10.5px;
}
.counter--muted { background: var(--fm-text-4); }

/* --- 4. Таблица -------------------------------------------------------------
   Главный экран продукта. Зебра — петролем в четверть силы, просроченные
   строки — диагональной штриховкой и вермильоновой кромкой слева. */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--fm-radius-lg);
  -webkit-overflow-scrolling: touch;
}
.table { font-size: var(--fm-fs-body); min-width: 100%; }

.table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--fm-surface-subtle);
  padding: 10px 14px; text-align: left;
  font-family: var(--fm-font-mono); font-weight: 500; font-size: var(--fm-fs-label);
  letter-spacing: var(--fm-tr-label); text-transform: uppercase; color: var(--fm-text-3);
  border-bottom: 1px solid var(--fm-border);
  white-space: nowrap;
}
.table th.is-num, .table td.is-num { text-align: right; }
.table tbody td {
  padding: 11px 14px; border-top: 1px solid var(--fm-border-soft);
  color: var(--fm-text-2); vertical-align: top;
}
.table tbody tr:first-child td { border-top: none; }
.table tbody tr { transition: background var(--fm-t-fast); }
.table tbody tr:nth-child(even) td { background: rgba(214, 231, 234, .22); }
.table tbody tr:hover td { background: var(--fm-brand-tint-2); }
.table tbody tr[aria-selected="true"] td {
  background: var(--fm-brand-tint);
  box-shadow: inset 0 1px 0 var(--fm-brand-line-2), inset 0 -1px 0 var(--fm-brand-line-2);
}
.table tbody tr[aria-selected="true"] td:first-child { box-shadow: inset 3px 0 0 var(--fm-brand); }

/* Просрочка. Штриховка + кромка: видно даже боковым зрением. */
/* Строка, которую система не смогла разобрать: в предпросмотре выписки такую
   строку человек должен увидеть сразу, не читая колонку со статусом */
.table tbody tr.is-danger td { background: var(--fm-danger-bg); color: var(--fm-danger-fg); }
.table tbody tr.is-danger td:first-child { box-shadow: inset 3px 0 0 var(--fm-danger-line); }
.table tbody tr.is-danger:hover td { background-color: var(--fm-danger-bg); filter: brightness(0.98); }
.table tbody tr.is-late td { background: var(--fm-accent-tint-2); background-image: var(--fm-hatch); }
.table tbody tr.is-late td:first-child { box-shadow: inset 3px 0 0 var(--fm-accent); }
.table tbody tr.is-late:hover td { background-color: var(--fm-accent-tint); }

.table td strong, .table td .cell-strong { color: var(--fm-text); font-weight: 600; }

.table--dense tbody td { padding: 7px 14px; }
.table--clickable tbody tr { cursor: pointer; }

/* Фильтр в шапке каждого столбца — это Excel-замена */
.table__filter-row th { padding: 6px 8px; background: var(--fm-surface); top: 36px; }
.table__filter {
  width: 100%; min-width: 90px;
  border: 1px solid var(--fm-border-input); border-radius: var(--fm-radius-sm);
  background: var(--fm-surface-subtle); padding: 5px 8px;
  font-size: var(--fm-fs-xs); color: var(--fm-text-2);
  transition: border-color var(--fm-t-fast), box-shadow var(--fm-t-fast);
}
.table__filter:focus { outline: none; border-color: var(--fm-brand-soft); box-shadow: var(--fm-ring); }

.table__sort {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: 0; padding: 0; color: inherit; font: inherit;
  letter-spacing: inherit; text-transform: inherit;
  transition: color var(--fm-t-fast);
}
.table__sort:hover { color: var(--fm-brand); }
.table__sort::after { content: '↕'; opacity: .4; font-size: 10px; }
.table__sort[data-dir="asc"]::after  { content: '↑'; opacity: 1; color: var(--fm-accent); }
.table__sort[data-dir="desc"]::after { content: '↓'; opacity: 1; color: var(--fm-accent); }

.table__check { width: 34px; }
.table__check input { width: 15px; height: 15px; accent-color: var(--fm-brand); }

/* Мобильная карточная раскладка таблицы (от 640px и ниже).
   Работает автоматически: каждая ячейка получает data-label из заголовка. */
@media (max-width: 640px) {
  .table-wrap--cards .table,
  .table-wrap--cards .table thead,
  .table-wrap--cards .table tbody,
  .table-wrap--cards .table tr,
  .table-wrap--cards .table td { display: block; width: 100%; }
  .table-wrap--cards .table thead { display: none; }
  .table-wrap--cards .table tbody tr {
    border: 1px solid var(--fm-border); border-radius: var(--fm-radius);
    margin-bottom: 10px; background: var(--fm-surface); padding: 4px 0;
    box-shadow: var(--fm-shadow-sm);
  }
  .table-wrap--cards .table tbody tr td,
  .table-wrap--cards .table tbody tr:nth-child(even) td { background: transparent; }
  .table-wrap--cards .table tbody tr.is-late { border-color: var(--fm-accent-line); background-image: var(--fm-hatch); }
  .table-wrap--cards .table tbody td {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 14px;
    border-top: none; padding: 7px 13px; text-align: right;
  }
  .table-wrap--cards .table tbody td::before {
    content: attr(data-label);
    font-family: var(--fm-font-mono); font-size: var(--fm-fs-label);
    letter-spacing: var(--fm-tr-label); text-transform: uppercase; color: var(--fm-text-3);
    text-align: left; flex: none; max-width: 45%; padding-top: 2px;
  }
  .table-wrap--cards .table tbody td:empty { display: none; }
  /* Чекбокс строки в карточной раскладке — без подписи, прижат вправо */
  .table-wrap--cards .table tbody td.table__check { justify-content: flex-end; padding-bottom: 0; }
  .table-wrap--cards .table tbody td.table__check::before { content: none; }
}

/* --- 5. Формы --------------------------------------------------------------- */

.form { display: flex; flex-direction: column; gap: var(--fm-space-4); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid > .field--wide { grid-column: 1 / -1; }

.fieldset { border: 0; margin: 0; padding: 0; }
.fieldset__legend {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--fm-font-mono); font-weight: 500; font-size: var(--fm-fs-label);
  letter-spacing: var(--fm-tr-label); text-transform: uppercase; color: var(--fm-text-3);
  padding: 0 0 10px;
}
.fieldset__legend::before {
  content: ''; width: 6px; height: 6px; flex: none;
  background: var(--fm-accent-bright); border-radius: 1px; transform: rotate(45deg);
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field__label { font-weight: 600; font-size: var(--fm-fs-sm); color: var(--fm-text); }
.field__label .req { color: var(--fm-accent); margin-left: 2px; }
.field__hint  { font-size: var(--fm-fs-xs); color: var(--fm-text-3); line-height: 1.4; }
.field__error {
  display: flex; align-items: flex-start; gap: 5px;
  font-size: var(--fm-fs-xs); color: var(--fm-accent-deep); font-weight: 600;
}

.input, .select, .textarea {
  width: 100%; padding: 9px 12px;
  background: var(--fm-surface); color: var(--fm-text);
  border: 1px solid var(--fm-border-input); border-radius: var(--fm-radius);
  font-size: var(--fm-fs-body);
  transition: border-color var(--fm-t-fast), box-shadow var(--fm-t-fast), background var(--fm-t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--fm-text-4); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--fm-brand-line); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--fm-brand-soft); box-shadow: var(--fm-ring);
}
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--fm-surface-sunken); color: var(--fm-text-3); cursor: not-allowed;
}
.input[readonly] { background: var(--fm-surface-subtle); }
.textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.select {
  appearance: none; padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2346626C' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input--mono { font-family: var(--fm-font-mono); font-variant-numeric: tabular-nums; }

.field.is-invalid .input,
.field.is-invalid .select,
.field.is-invalid .textarea { border-color: var(--fm-accent); background: var(--fm-accent-tint-2); }
.field.is-invalid .input:focus,
.field.is-invalid .select:focus,
.field.is-invalid .textarea:focus { border-color: var(--fm-accent); box-shadow: var(--fm-ring-danger); }
.is-invalid { border-color: var(--fm-accent) !important; }

.input-group { display: flex; }
.input-group .input { border-radius: var(--fm-radius) 0 0 var(--fm-radius); }
.input-group__addon {
  display: flex; align-items: center; padding: 0 12px;
  background: var(--fm-surface-subtle); border: 1px solid var(--fm-border-input); border-left: 0;
  border-radius: 0 var(--fm-radius) var(--fm-radius) 0;
  font-family: var(--fm-font-mono); font-size: var(--fm-fs-sm); color: var(--fm-text-3);
}

.check {
  display: flex; align-items: flex-start; gap: 9px;
  font-size: var(--fm-fs-sm); color: var(--fm-text-2); cursor: pointer;
}
.check input { width: 16px; height: 16px; margin-top: 1px; accent-color: var(--fm-brand); flex: none; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch__track {
  width: 38px; height: 21px; border-radius: var(--fm-radius-pill);
  background: var(--fm-border-input); position: relative; flex: none;
  transition: background var(--fm-t-base);
}
.switch__track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 17px; height: 17px; border-radius: 50%; background: #fff;
  box-shadow: var(--fm-shadow-sm); transition: transform var(--fm-t-base);
}
.switch input:checked + .switch__track { background: var(--fm-brand); }
.switch input:checked + .switch__track::after { transform: translateX(17px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--fm-ring); }

/* Радио-плитки: тип перевозки, причина брака, тип документа */
.tiles { display: grid; gap: 9px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.tile {
  display: flex; align-items: flex-start; gap: 9px; cursor: pointer;
  border: 1px solid var(--fm-border); border-radius: var(--fm-radius);
  background: var(--fm-surface); padding: 11px 13px;
  transition: border-color var(--fm-t-fast), background var(--fm-t-fast),
              box-shadow var(--fm-t-fast), transform 90ms var(--fm-ease);
}
.tile:hover { border-color: var(--fm-brand-line); box-shadow: var(--fm-shadow-sm); }
.tile:active { transform: scale(.99); }
.tile input { margin-top: 2px; accent-color: var(--fm-brand); flex: none; }
.tile__title { font-weight: 600; font-size: var(--fm-fs-sm); color: var(--fm-text); }
.tile__note  { font-size: var(--fm-fs-xs); color: var(--fm-text-3); margin-top: 2px; line-height: 1.4; }
.tile:has(input:checked) {
  border-color: var(--fm-brand); background: var(--fm-brand-tint);
  box-shadow: inset 0 0 0 1px var(--fm-brand);
}

/* --- 6. Чипы и фильтры ------------------------------------------------------ */

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--fm-radius);
  font-family: var(--fm-font-display); font-weight: 600; font-size: var(--fm-fs-sm);
  border: 1px solid var(--fm-border); background: var(--fm-surface); color: var(--fm-text-2);
  transition: background var(--fm-t-fast), border-color var(--fm-t-fast),
              color var(--fm-t-fast), transform 90ms var(--fm-ease);
}
.chip:hover { border-color: var(--fm-brand-line); color: var(--fm-brand); background: var(--fm-brand-tint-2); }
.chip:active { transform: scale(.98); }
.chip[aria-pressed="true"] {
  background: var(--fm-brand); border-color: var(--fm-brand); color: #fff;
  box-shadow: var(--fm-inset-top);
}
.chip[aria-pressed="true"] .t-muted { color: #fff; opacity: .85; }
.chip__n { font-family: var(--fm-font-mono); font-size: var(--fm-fs-xs); opacity: .75; }

.filter-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 15px; background: var(--fm-surface);
  border: 1px solid var(--fm-border); border-radius: var(--fm-radius-lg);
  margin-bottom: var(--fm-space-4);
  box-shadow: var(--fm-shadow-sm), var(--fm-inset-top);
}
.filter-bar__spacer { margin-left: auto; }

/* Панель массовых действий — появляется при выборе строк */
.bulk-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 11px 15px; border-radius: var(--fm-radius-lg);
  background: var(--fm-brand-deep); color: #fff;
  margin-bottom: var(--fm-space-3);
  box-shadow: var(--fm-shadow-md);
  animation: fm-pop 260ms var(--fm-ease-out);
}
.bulk-bar__count { font-family: var(--fm-font-mono); font-weight: 600; color: var(--fm-brand-line); }
.bulk-bar .btn--secondary {
  background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .22);
  color: #fff; box-shadow: none;
}
.bulk-bar .btn--secondary:hover { background: rgba(255, 255, 255, .18); color: #fff; }

/* --- 7. Вкладки ------------------------------------------------------------- */

.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--fm-border);
  margin-bottom: var(--fm-space-4); overflow-x: auto;
}
.tab {
  position: relative;
  padding: 10px 15px; border: 0; background: none;
  font-family: var(--fm-font-display); font-weight: 600; font-size: var(--fm-fs-sm);
  color: var(--fm-text-3); border-bottom: 2px solid transparent;
  white-space: nowrap; transition: color var(--fm-t-fast), border-color var(--fm-t-base);
}
.tab:hover { color: var(--fm-text); }
.tab[aria-selected="true"] { color: var(--fm-brand); border-bottom-color: var(--fm-accent); }
.tab__n { font-family: var(--fm-font-mono); font-size: var(--fm-fs-xs); opacity: .7; margin-left: 5px; }

/* --- 8. KPI и показатели ----------------------------------------------------
   Число — главное на плитке, поэтому оно набрано моноширинным крупно.
   Подпись сверху капсом, комментарий снизу мелким. */

.kpi {
  position: relative; overflow: hidden;
  background: var(--fm-surface); border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius-lg); padding: 15px 17px;
  box-shadow: var(--fm-shadow-sm), var(--fm-inset-top);
}
/* Кликабельная плитка: она вход в свой список, а не просто цифра. */
.kpi--clickable { cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
.kpi--clickable:hover { border-color: var(--fm-accent); box-shadow: var(--fm-shadow-md); transform: translateY(-1px); }
.kpi--clickable:focus-visible { outline: 2px solid var(--fm-accent); outline-offset: 2px; }
.kpi--clickable::after {
  content: '→'; position: absolute; right: 14px; top: 13px;
  color: var(--fm-text-3); font-size: 13px; opacity: 0; transition: opacity .15s;
}
.kpi--clickable:hover::after { opacity: 1; }

.kpi__label {
  font-family: var(--fm-font-mono); font-weight: 500; font-size: var(--fm-fs-label);
  letter-spacing: var(--fm-tr-label); text-transform: uppercase; color: var(--fm-text-3);
}
.kpi__value {
  font-family: var(--fm-font-mono); font-weight: 600; font-size: 23px;
  color: var(--fm-text); margin-top: 6px; font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.kpi__note { font-size: var(--fm-fs-xs); color: var(--fm-text-3); margin-top: 4px; }
.kpi__delta { font-weight: 600; font-size: var(--fm-fs-xs); }
.kpi__delta--up   { color: var(--fm-brand); }
.kpi__delta--down { color: var(--fm-accent-deep); }
.kpi--ok     { background: var(--fm-brand-tint); border-color: var(--fm-brand-line); }
.kpi--warn   { background: var(--fm-accent-tint); border-color: var(--fm-accent-line); }
.kpi--danger { background: var(--fm-accent-tint); border-color: var(--fm-accent-line); background-image: var(--fm-hatch); }
.kpi--brand  { background: var(--fm-brand-tint-2); border-color: var(--fm-brand-line-2); }
/* На тонированной плитке вся типографика уходит в тот же цвет, что и фон:
   так плитка читается как одно целое, и подпись не проваливается по
   контрасту — серый --fm-text-3 на тёплой подложке даёт только 4.4:1. */
.kpi--danger .kpi__value, .kpi--danger .kpi__label, .kpi--danger .kpi__note,
.kpi--warn   .kpi__value, .kpi--warn   .kpi__label, .kpi--warn   .kpi__note { color: var(--fm-accent-deep); }
.kpi--ok     .kpi__value, .kpi--ok     .kpi__label, .kpi--ok     .kpi__note,
.kpi--brand  .kpi__value, .kpi--brand  .kpi__label, .kpi--brand  .kpi__note { color: var(--fm-brand); }

.meter { height: 7px; border-radius: var(--fm-radius-pill); background: var(--fm-surface-sunken); overflow: hidden; }
.meter__fill {
  height: 100%; border-radius: var(--fm-radius-pill); background: var(--fm-brand);
  transition: width var(--fm-t-slow);
}
.meter__fill--warn   { background: var(--fm-accent-bright); }
.meter__fill--danger { background: var(--fm-accent); }
.meter__fill--ok     { background: var(--fm-brand); }

/* Столбчатый график без библиотек — хватает для дашбордов.
   Ж/д петролем, авто ярким вермильоном: на столбцах текста нет,
   поэтому здесь #F0703A уместен и читается лучше всего. */
/* Базовая линия и две сетки: месяц без перевозок читается как ноль,
   а не как «данные не пришли». Без них график с одним столбцом
   выглядит сломанным. */
.bars {
  position: relative; display: flex; align-items: flex-end; gap: 8px; height: 150px;
  border-bottom: 1px solid var(--fm-border);
}
.bars::before {
  content: ''; position: absolute; left: 0; right: 0; top: 33%; height: 1px;
  background: var(--fm-border-soft); pointer-events: none;
}
.bars::after {
  content: ''; position: absolute; left: 0; right: 0; top: 66%; height: 1px;
  background: var(--fm-border-soft); pointer-events: none;
}
.bars__col { position: relative; }
.bars__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.bars__stack { width: 100%; display: flex; flex-direction: column; justify-content: flex-end; flex: 1; }
.bars__seg { width: 100%; transition: filter var(--fm-t-fast); }
.bars__col:hover .bars__seg { filter: saturate(1.15) brightness(1.04); }
.bars__seg--rail { background: var(--fm-brand); border-radius: 4px 4px 0 0; }
.bars__seg--auto { background: var(--fm-accent-bright); }
.bars__label { font-family: var(--fm-font-mono); font-size: 10px; color: var(--fm-text-3); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: var(--fm-fs-xs); color: var(--fm-text-2); }
.legend__item { display: flex; align-items: center; gap: 6px; }
.legend__swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* --- 9. Список «ключ — значение» -------------------------------------------- */

.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 9px 18px; font-size: var(--fm-fs-body); }
.kv__k { color: var(--fm-text-3); }
.kv__v { color: var(--fm-text); font-weight: 500; text-align: right; }
.kv--rows { display: flex; flex-direction: column; gap: 0; }
.kv--rows > div {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 9px 0; border-top: 1px solid var(--fm-border-soft);
}
.kv--rows > div:first-child { border-top: 0; }

/* --- 10. Таймлайн статусов ---------------------------------------------------
   Пройдено — петроль: спокойно, решение принято. Текущий шаг — петроль
   с ореолом. Просрочка — вермильон с ореолом: единственное красное пятно
   в цепочке, его невозможно не заметить. */

.timeline { display: flex; gap: 0; overflow-x: auto; padding-bottom: 4px; }
.timeline__step { flex: 1; min-width: 118px; position: relative; padding: 0 6px; }
.timeline__step::before {
  content: ''; position: absolute; top: 9px; left: 0; right: 0; height: 2px;
  background: var(--fm-border);
}
.timeline__step:first-child::before { left: 50%; }
.timeline__step:last-child::before  { right: 50%; }
.timeline__dot {
  position: relative; z-index: 1; width: 20px; height: 20px; margin-inline: auto;
  border-radius: 50%; background: var(--fm-surface);
  border: 2px solid var(--fm-border);
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--fm-text-3);
  transition: box-shadow var(--fm-t-base), background var(--fm-t-base);
}
.timeline__label {
  text-align: center; margin-top: 8px;
  font-size: var(--fm-fs-xs); color: var(--fm-text-3); line-height: 1.3;
}
.timeline__date { text-align: center; font-family: var(--fm-font-mono); font-size: 10px; color: var(--fm-text-3); margin-top: 3px; }
.timeline__step.is-done::before { background: var(--fm-brand-line); }
.timeline__step.is-done .timeline__dot { background: var(--fm-brand); border-color: var(--fm-brand); color: #fff; }
.timeline__step.is-done .timeline__label { color: var(--fm-text-2); }
.timeline__step.is-current .timeline__dot {
  background: var(--fm-brand); border-color: var(--fm-brand); color: #fff;
  box-shadow: 0 0 0 4px var(--fm-brand-tint);
}
.timeline__step.is-current .timeline__label { color: var(--fm-brand); font-weight: 700; }
.timeline__step.is-late .timeline__dot {
  background: var(--fm-accent); border-color: var(--fm-accent); color: #fff;
  box-shadow: 0 0 0 4px var(--fm-accent-tint);
}
.timeline__step.is-late .timeline__label { color: var(--fm-accent-deep); font-weight: 700; }
.timeline__step.is-skipped .timeline__dot { border-style: dashed; }

/* Вертикальная лента истории / аудита */
.feed { display: flex; flex-direction: column; }
.feed__item {
  display: flex; gap: 12px; padding: 12px 0;
  border-top: 1px solid var(--fm-border-soft);
}
.feed__item:first-child { border-top: 0; }
.feed__dot { width: 8px; height: 8px; border-radius: 2px; transform: rotate(45deg); background: var(--fm-text-4); margin-top: 6px; flex: none; }
.feed__dot--ok { background: var(--fm-brand); }
.feed__dot--danger { background: var(--fm-accent); }
.feed__dot--warn { background: var(--fm-accent-bright); }
.feed__text { font-size: var(--fm-fs-body); color: var(--fm-text); }
.feed__meta { font-size: var(--fm-fs-xs); color: var(--fm-text-3); margin-top: 3px; }

/* --- 11. Баннеры и алерты ---------------------------------------------------- */

.alert {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 15px; border-radius: var(--fm-radius-lg);
  border: 1px solid var(--fm-neutral-line); background: var(--fm-neutral-bg);
  font-size: var(--fm-fs-body); color: var(--fm-text-2);
}
.alert__icon { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.alert__title { font-weight: 700; color: var(--fm-text); margin-bottom: 3px; }
.alert__body { min-width: 0; }
.alert__actions { margin-top: 10px; display: flex; gap: 7px; flex-wrap: wrap; }
.alert--info   { background: var(--fm-info-bg);   border-color: var(--fm-info-line);   color: var(--fm-brand); }
.alert--warn   { background: var(--fm-warn-bg);   border-color: var(--fm-warn-line);   color: var(--fm-warn-fg); }
.alert--danger {
  background: var(--fm-accent-tint); border-color: var(--fm-accent);
  color: var(--fm-accent-deep); box-shadow: inset 3px 0 0 var(--fm-accent);
}
.alert--ok     { background: var(--fm-brand-tint); border-color: var(--fm-brand-line); color: var(--fm-brand-deep); }
.alert--info .alert__title, .alert--warn .alert__title,
.alert--danger .alert__title, .alert--ok .alert__title { color: inherit; }

/* Подпись бизнес-правила рядом с полем/формой */
.rule-note {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: var(--fm-fs-xs); color: var(--fm-text-3); line-height: 1.45;
  border-left: 2px solid var(--fm-accent-bright); padding-left: 10px;
}
.rule-note b { color: var(--fm-accent-deep); font-weight: 700; }

/* --- 12. Модальное окно ------------------------------------------------------ */

.modal-scrim {
  position: fixed; inset: 0; z-index: var(--fm-z-modal);
  background: rgba(12, 44, 54, .5);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; overflow-y: auto;
  animation: fm-fade-in 180ms var(--fm-ease);
}
.modal {
  width: 100%; max-width: 560px; margin: auto;
  background: var(--fm-surface); border-radius: var(--fm-radius-xl);
  box-shadow: var(--fm-shadow-lg); overflow: hidden;
  animation: fm-pop 300ms var(--fm-ease-out);
}
.modal--sm { max-width: 420px; }
.modal--lg { max-width: 860px; }
.modal__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 18px 20px; border-bottom: 1px solid var(--fm-border-soft);
}
.modal__title {
  font-family: var(--fm-font-display); font-weight: 700; font-size: var(--fm-fs-h2);
  letter-spacing: var(--fm-tr-title);
}
.modal__sub { font-size: var(--fm-fs-sm); color: var(--fm-text-3); margin-top: 4px; }
.modal__close {
  width: 30px; height: 30px; flex: none; border-radius: var(--fm-radius-sm);
  border: 1px solid var(--fm-border); background: var(--fm-surface);
  color: var(--fm-text-3); display: flex; align-items: center; justify-content: center;
  transition: background var(--fm-t-fast), color var(--fm-t-fast), border-color var(--fm-t-fast);
}
.modal__close:hover { background: var(--fm-accent-tint); color: var(--fm-accent-deep); border-color: var(--fm-accent-line); }
.modal__body { padding: 20px; max-height: 66vh; overflow-y: auto; }
.modal__foot {
  padding: 15px 20px; border-top: 1px solid var(--fm-border-soft);
  background: var(--fm-surface-subtle);
  display: flex; justify-content: flex-end; gap: 9px; flex-wrap: wrap;
}

/* --- 13. Тосты --------------------------------------------------------------- */

.toast-stack {
  position: fixed; right: 20px; bottom: 20px; z-index: var(--fm-z-toast);
  display: flex; flex-direction: column-reverse; gap: 10px;
  max-width: min(380px, calc(100vw - 40px));
}
.toast {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 15px; border-radius: var(--fm-radius-lg);
  background: var(--fm-surface); border: 1px solid var(--fm-border);
  box-shadow: var(--fm-shadow-lg), var(--fm-inset-top);
  animation: fm-slide-in 320ms var(--fm-ease-out);
}
.toast__stripe { width: 3px; align-self: stretch; border-radius: 3px; background: var(--fm-text-4); flex: none; }
.toast--ok     .toast__stripe { background: var(--fm-brand); }
.toast--danger .toast__stripe { background: var(--fm-accent); }
.toast--warn   .toast__stripe { background: var(--fm-accent-bright); }
.toast--info   .toast__stripe { background: var(--fm-brand-line); }
.toast__title { font-weight: 700; font-size: var(--fm-fs-sm); color: var(--fm-text); }
.toast__text  { font-size: var(--fm-fs-xs); color: var(--fm-text-2); margin-top: 3px; line-height: 1.45; }
.toast__close { border: 0; background: none; color: var(--fm-text-3); font-size: 16px; line-height: 1; padding: 0 2px; }
.toast__close:hover { color: var(--fm-accent); }
.toast.is-leaving { opacity: 0; transform: translateX(22px); transition: all 220ms var(--fm-ease-in); }

/* --- 14. Скелетон, пусто, загрузка -------------------------------------------
   Скелетон повторяет форму того, что грузится, — не крутящееся колесо. */

.skeleton {
  background: linear-gradient(90deg,
    var(--fm-surface-sunken) 25%, var(--fm-brand-tint-2) 37%, var(--fm-surface-sunken) 63%);
  background-size: 420px 100%;
  animation: fm-shimmer 1.4s linear infinite;
  border-radius: var(--fm-radius-xs);
  height: 12px;
}
.skeleton--text  { height: 12px; margin: 6px 0; }
.skeleton--title { height: 18px; width: 40%; }
.skeleton--row   { height: 38px; margin-bottom: 1px; border-radius: 0; }
.skeleton--kpi   { height: 84px; border-radius: var(--fm-radius-lg); }
.skeleton--block { height: 200px; border-radius: var(--fm-radius-lg); }

.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 10px; padding: 54px 24px;
}
.empty__art {
  width: 54px; height: 54px; border-radius: var(--fm-radius-lg);
  border: 2px dashed var(--fm-brand-line); background: var(--fm-brand-tint-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--fm-brand);
}
.empty__title {
  font-family: var(--fm-font-display); font-weight: 700; font-size: var(--fm-fs-h3);
  color: var(--fm-text); letter-spacing: var(--fm-tr-title);
}
.empty__text  { font-size: var(--fm-fs-sm); color: var(--fm-text-3); max-width: 380px; line-height: 1.5; }
.empty--sm { padding: 28px 18px; }

.spinner {
  width: 18px; height: 18px; border: 2px solid var(--fm-brand-tint);
  border-top-color: var(--fm-accent); border-radius: 50%;
  animation: fm-spin .7s linear infinite;
}

/* --- 15. Пагинация ----------------------------------------------------------- */

.pager { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.pager__btn {
  min-width: 32px; height: 32px; padding: 0 9px;
  border: 1px solid var(--fm-border); background: var(--fm-surface);
  border-radius: var(--fm-radius-sm);
  font-family: var(--fm-font-mono); font-size: var(--fm-fs-xs); color: var(--fm-text-2);
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color var(--fm-t-fast), color var(--fm-t-fast),
              background var(--fm-t-fast), transform 90ms var(--fm-ease);
}
.pager__btn:hover { border-color: var(--fm-brand-line); color: var(--fm-brand); background: var(--fm-brand-tint-2); }
.pager__btn:active { transform: scale(.95); }
.pager__btn[aria-current="page"] { background: var(--fm-brand); border-color: var(--fm-brand); color: #fff; }
.pager__btn:disabled { opacity: .4; pointer-events: none; }
.pager__info { font-size: var(--fm-fs-xs); color: var(--fm-text-3); margin-left: auto; }

/* --- 16. Выпадающие панели (язык, уведомления, профиль) ---------------------- */

.dropdown { position: relative; }
.dropdown__panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: var(--fm-z-dropdown);
  min-width: 220px; background: var(--fm-surface);
  border: 1px solid var(--fm-border); border-radius: var(--fm-radius-lg);
  box-shadow: var(--fm-shadow-lg), var(--fm-inset-top); padding: 6px; overflow: hidden;
  animation: fm-pop 220ms var(--fm-ease-out);
}
.dropdown__panel--wide { min-width: 340px; padding: 0; }
.dropdown__item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 11px; border: 0; background: none; border-radius: var(--fm-radius-sm);
  font-size: var(--fm-fs-sm); color: var(--fm-text-2); text-align: left;
  transition: background var(--fm-t-fast), color var(--fm-t-fast);
}
.dropdown__item:hover { background: var(--fm-brand-tint-2); color: var(--fm-brand); text-decoration: none; }
.dropdown__item[aria-current="true"] { background: var(--fm-brand-tint); color: var(--fm-brand); font-weight: 600; }
.dropdown__sep { height: 1px; background: var(--fm-border-soft); margin: 5px 0; }
.dropdown__hint {
  padding: 7px 11px 8px; font-size: var(--fm-fs-xs); line-height: 1.4;
  color: var(--fm-text-3); border-bottom: 1px solid var(--fm-border-soft); margin-bottom: 4px;
}

/* Переключатель рабочих пространств: какая из пяти фирм сейчас открыта. */
.ws-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 11px; border-radius: var(--fm-radius-sm);
  background: var(--fm-surface); border: 1px solid var(--fm-border);
  color: var(--fm-text-1); font-size: var(--fm-fs-sm); font-weight: 500;
  cursor: pointer; white-space: nowrap; transition: border-color .15s, background .15s;
}
.ws-btn:hover { border-color: var(--fm-accent); }
.ws-btn:focus-visible { outline: 2px solid var(--fm-accent); outline-offset: 2px; }
.ws-btn__text { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.ws-btn__crown { font-size: 13px; line-height: 1; }
@media (max-width: 900px) { .ws-btn__text { display: none; } }
.dropdown__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--fm-border-soft);
  font-family: var(--fm-font-display); font-weight: 700; font-size: var(--fm-fs-sm);
}
.dropdown__foot { padding: 10px 14px; border-top: 1px solid var(--fm-border-soft); background: var(--fm-surface-subtle); }

.lang-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 11px; border-radius: var(--fm-radius);
  border: 1px solid var(--fm-border); background: var(--fm-surface);
  font-family: var(--fm-font-mono); font-weight: 600; font-size: var(--fm-fs-xs);
  letter-spacing: .05em; text-transform: uppercase; color: var(--fm-text-2);
  transition: border-color var(--fm-t-fast), color var(--fm-t-fast), background var(--fm-t-fast);
}
.lang-btn:hover { border-color: var(--fm-brand-line); color: var(--fm-brand); background: var(--fm-brand-tint-2); }

.icon-btn {
  position: relative; width: 34px; height: 34px; flex: none;
  border: 1px solid var(--fm-border); background: var(--fm-surface);
  border-radius: var(--fm-radius); color: var(--fm-text-2);
  display: inline-flex; align-items: center; justify-content: center;
  transition: border-color var(--fm-t-fast), color var(--fm-t-fast),
              background var(--fm-t-fast), transform 90ms var(--fm-ease);
}
.icon-btn:hover { border-color: var(--fm-brand-line); color: var(--fm-brand); background: var(--fm-brand-tint-2); }
.icon-btn:active { transform: scale(.94); }
.icon-btn__badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--fm-accent); color: #fff; border: 2px solid var(--fm-bg);
  border-radius: var(--fm-radius-pill);
  font-family: var(--fm-font-mono); font-weight: 600; font-size: 9.5px;
  display: flex; align-items: center; justify-content: center;
}

/* Аватар — скруглённый квадрат, не круг: круги в этом интерфейсе заняты
   точками статуса, и повторять форму не нужно. */
.avatar {
  width: 31px; height: 31px; border-radius: 9px; flex: none;
  background: var(--fm-brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--fm-font-mono); font-weight: 600; font-size: 11px;
  box-shadow: var(--fm-inset-top);
}
.avatar--lg { width: 48px; height: 48px; font-size: 15px; border-radius: 13px; }
.avatar--muted { background: var(--fm-surface-sunken); color: var(--fm-text-2); }

/* --- 17. Экран входа и заявка на доступ --------------------------------------
   Слева — «диспетчерская»: глубокий петроль, маршрут и три тезиса о системе.
   Справа — светлая панель с карточкой формы. Языки — в шапке правой панели.
   Оба экрана (вход и заявка) собраны из одного каркаса .auth. */

.auth {
  min-height: 100dvh; display: grid; grid-template-columns: minmax(420px, 46%) 1fr;
  background: var(--fm-bg);
}

.auth__aside {
  position: relative; overflow: hidden;
  background: var(--fm-nav-bg);
  background-image:
    radial-gradient(55% 40% at 12% 0%, rgba(240, 112, 58, .2), transparent 70%),
    radial-gradient(60% 45% at 100% 100%, rgba(30, 98, 115, .55), transparent 72%);
  color: #fff; padding: 44px 46px;
  display: flex; flex-direction: column; gap: 40px;
}
/* Ромбовая штриховка — фирменный знак, растиражированный в паттерн */
.auth__aside::before {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .45;
  background-image: var(--fm-hatch);
}
.auth__aside > * { position: relative; }

.auth__brand { display: flex; align-items: center; gap: 12px; }
.auth__mark {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--fm-brand-soft); position: relative; flex: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 6px 18px -6px rgba(240, 112, 58, .6);
}
.auth__mark::after {
  content: ''; position: absolute; left: 13px; top: 13px;
  width: 18px; height: 18px;
  border: 2.5px solid var(--fm-accent-bright); border-radius: 5px;
  transform: rotate(45deg);
}
.auth__brand-name {
  font-family: var(--fm-font-display); font-weight: 800; font-size: 19px;
  letter-spacing: var(--fm-tr-title);
}
.auth__brand-sub {
  font-family: var(--fm-font-mono); font-size: 10.5px; letter-spacing: .07em;
  text-transform: uppercase; color: var(--fm-nav-text-mute);
}

.auth__hero { max-width: 26ch; }
.auth__hero h2 {
  font-family: var(--fm-font-display); font-weight: 800; font-size: 34px;
  line-height: 1.12; letter-spacing: var(--fm-tr-display); color: #fff;
}
.auth__hero p { margin-top: 12px; font-size: 14.5px; line-height: 1.6; color: var(--fm-nav-text); }

/* Маршрут: пунктирная линия с ромбами-станциями. Текущий «перегон» подсвечен. */
.auth__route { margin: 6px 0 2px; }
.auth__route svg { width: 100%; max-width: 380px; height: auto; display: block; }

.auth__pillars { display: flex; flex-direction: column; gap: 18px; }
.auth__pillar { display: flex; gap: 13px; align-items: flex-start; }
.auth__pillar-pip {
  width: 30px; height: 30px; flex: none; border-radius: 8px;
  background: rgba(159, 203, 211, .1); border: 1px solid var(--fm-nav-border);
  display: flex; align-items: center; justify-content: center;
}
.auth__pillar-pip::after {
  content: ''; width: 9px; height: 9px; background: var(--fm-accent-bright);
  border-radius: 2px; transform: rotate(45deg);
}
.auth__fact-v {
  font-family: var(--fm-font-display); font-weight: 700; font-size: 15.5px; color: #fff;
  letter-spacing: var(--fm-tr-title);
}
.auth__fact-l { font-size: var(--fm-fs-sm); color: var(--fm-nav-text); margin-top: 2px; line-height: 1.45; }

.auth__meta {
  margin-top: auto; display: flex; justify-content: space-between;
  font-family: var(--fm-font-mono); font-size: 10.5px; color: var(--fm-nav-text-mute);
}

/* --- правая панель ----------------------------------------------------------- */

.auth__main { display: flex; flex-direction: column; min-width: 0; }

/* Шапка панели: языки справа. На телефоне (aside скрыт) слева появляется марка. */
.auth__head {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  padding: 18px 26px;
}
.auth__head-brand { display: none; margin-right: auto; }

.auth__form-side {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 12px 24px 48px;
}

/* Карточка формы в лотке — та же двойная кромка, что у главных блоков системы */
.auth__card {
  width: 100%; max-width: 460px;
  background: var(--fm-surface);
  border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius-xl);
  box-shadow: var(--fm-shadow-lg), var(--fm-inset-top);
  padding: 34px 36px 30px;
  animation: fm-rise 420ms var(--fm-ease-out);
}
.auth__eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--fm-font-mono); font-weight: 500; font-size: var(--fm-fs-label);
  letter-spacing: var(--fm-tr-label); text-transform: uppercase; color: var(--fm-text-3);
}
.auth__eyebrow::before {
  content: ''; width: 7px; height: 7px; background: var(--fm-accent-bright);
  border-radius: 2px; transform: rotate(45deg);
}
.auth__title {
  font-family: var(--fm-font-display); font-weight: 800; font-size: 27px;
  letter-spacing: var(--fm-tr-display); margin-top: 10px;
}
.auth__lead { color: var(--fm-text-2); margin-top: 8px; font-size: var(--fm-fs-body); line-height: 1.55; }

/* Поле пароля с «глазом»: кнопка привязана к самому полю, а не к блоку —
   подсказка под полем её не сдвигает */
.auth__pass-box { position: relative; }
.auth__pass .input { padding-right: 44px; }
.auth__eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: 0; background: none; border-radius: var(--fm-radius-sm);
  color: var(--fm-text-3); display: flex; align-items: center; justify-content: center;
  transition: color var(--fm-t-fast), background var(--fm-t-fast);
}
.auth__eye:hover { color: var(--fm-brand); background: var(--fm-brand-tint-2); }

/* Разделитель «нет доступа?» */
.auth__divider {
  display: flex; align-items: center; gap: 12px; margin: 22px 0 14px;
  font-size: var(--fm-fs-xs); color: var(--fm-text-3);
}
.auth__divider::before, .auth__divider::after {
  content: ''; flex: 1; height: 1px; background: var(--fm-border-soft);
}

/* Успешная заявка */
.auth__done { text-align: center; padding: 10px 0 4px; animation: fm-pop 320ms var(--fm-ease-out); }
.auth__done-mark {
  width: 58px; height: 58px; margin: 0 auto 16px; border-radius: 16px;
  background: var(--fm-brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--fm-inset-top), 0 14px 30px -14px rgba(12, 44, 54, .55);
}
.auth__steps { text-align: left; margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.auth__step { display: flex; gap: 10px; align-items: flex-start; font-size: var(--fm-fs-sm); color: var(--fm-text-2); }
.auth__step b { color: var(--fm-text); }
.auth__step-n {
  width: 22px; height: 22px; flex: none; border-radius: 7px;
  background: var(--fm-brand-tint); color: var(--fm-brand);
  font-family: var(--fm-font-mono); font-weight: 600; font-size: 11px;
  display: flex; align-items: center; justify-content: center;
}

@media (max-width: 940px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth__aside { display: none; }
  .auth__head { justify-content: space-between; }
  .auth__head-brand { display: flex; }
  .auth__card { padding: 26px 22px 24px; box-shadow: var(--fm-shadow-md); }
}

.status-page {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 40px 20px; text-align: center;
}
.status-page__inner { max-width: 480px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.status-page__code {
  font-family: var(--fm-font-mono); font-weight: 600; font-size: 60px;
  color: var(--fm-brand); letter-spacing: -.04em; line-height: 1;
}
.status-page__code--danger { color: var(--fm-accent); }
/* Глубокий, а не яркий: знак крупный, но #F0703A даёт на белом 2.7:1
   и не дотягивает даже до порога для крупного текста (3:1). */
.status-page__code--warn   { color: var(--fm-accent-deep); }
.status-page__title {
  font-family: var(--fm-font-display); font-weight: 700; font-size: 22px;
  letter-spacing: var(--fm-tr-title);
}
.status-page__text  { color: var(--fm-text-2); line-height: 1.55; }
.status-page__hint  { font-family: var(--fm-font-mono); font-size: var(--fm-fs-xs); color: var(--fm-text-3); }

/* Макет push-уведомления директору (раздел 8.3) */
.push-mock {
  display: flex; gap: 11px; align-items: flex-start;
  background: rgba(255, 255, 255, .94); backdrop-filter: blur(8px);
  border: 1px solid var(--fm-border); border-radius: 16px;
  padding: 12px 14px; box-shadow: var(--fm-shadow-lg); max-width: 380px;
}
.push-mock__app { width: 30px; height: 30px; border-radius: 8px; background: var(--fm-brand); flex: none; position: relative; }
.push-mock__app::after {
  content: ''; position: absolute; left: 8px; top: 8px; width: 13px; height: 13px;
  border: 2px solid var(--fm-accent-bright); border-radius: 3px; transform: rotate(45deg);
}
.push-mock__title { font-weight: 700; font-size: var(--fm-fs-sm); }
.push-mock__text  { font-size: var(--fm-fs-xs); color: var(--fm-text-2); margin-top: 2px; }
.push-mock__time  { font-family: var(--fm-font-mono); font-size: 10px; color: var(--fm-text-3); margin-left: auto; flex: none; }

@media (max-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth__aside { display: none; }
}
@media (max-width: 640px) {
  .form-grid, .form-grid--3 { grid-template-columns: minmax(0, 1fr); }
  .modal__body { max-height: none; }
  .toast-stack { right: 12px; left: 12px; bottom: 12px; max-width: none; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv__v { text-align: left; margin-bottom: 8px; }
}

/* --- 18. Каталог экранов (служебная страница /screens.html) ------------------
   Открывается без входа, поэтому у неё своя шапка вместо общего каркаса. */

.catalog { min-height: 100dvh; background: var(--fm-bg); }

.catalog__head {
  position: relative; overflow: hidden;
  background: var(--fm-nav-bg);
  background-image:
    radial-gradient(50% 100% at 8% 0%, rgba(240, 112, 58, .2), transparent 65%),
    radial-gradient(45% 100% at 92% 100%, rgba(30, 98, 115, .5), transparent 70%);
  padding: 22px var(--fm-page-x) 26px;
  border-bottom: 1px solid var(--fm-nav-edge);
}
.catalog__head > * { position: relative; }
.catalog__title {
  font-family: var(--fm-font-display); font-weight: 800; font-size: var(--fm-fs-display);
  color: #fff; letter-spacing: var(--fm-tr-display); margin-top: 22px;
}
.catalog__lead { color: var(--fm-nav-text); font-size: var(--fm-fs-body); line-height: 1.55; max-width: 640px; margin-top: 7px; }

.chip--dark { background: transparent; border-color: var(--fm-nav-border); color: var(--fm-nav-text-mute); }
.chip--dark:hover { border-color: var(--fm-brand-soft); color: var(--fm-nav-text); background: rgba(255, 255, 255, .05); }
.chip--dark[aria-pressed="true"] { background: var(--fm-accent); border-color: var(--fm-accent); color: #fff; }

.catalog__body { padding: 22px var(--fm-page-x) 60px; }

.catalog__section { margin-bottom: var(--fm-space-7); }
.catalog__section-title {
  font-family: var(--fm-font-display); font-weight: 700; font-size: var(--fm-fs-h2);
  margin-bottom: var(--fm-space-4);
  display: flex; align-items: baseline; gap: 9px;
  letter-spacing: var(--fm-tr-title);
}
.catalog__group { margin-bottom: var(--fm-space-5); }
.catalog__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 12px; }

.catalog__card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 7px;
  background: var(--fm-surface); border: 1px solid var(--fm-border);
  border-radius: var(--fm-radius-lg); padding: 14px 15px;
  text-decoration: none; color: inherit;
  box-shadow: var(--fm-shadow-sm), var(--fm-inset-top);
  transition: border-color var(--fm-t-fast), box-shadow var(--fm-t-base),
              transform var(--fm-t-base);
}
/* Кромка вермильона выезжает слева при наведении — карточка «включается» */
.catalog__card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--fm-accent-bright);
  transform: translateX(-3px); transition: transform var(--fm-t-base);
}
.catalog__card:hover {
  text-decoration: none; border-color: var(--fm-brand-line);
  box-shadow: var(--fm-shadow-hover); transform: translateY(-2px);
}
.catalog__card:hover::before { transform: none; }
.catalog__card:active { transform: translateY(0) scale(.995); }
.catalog__card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.catalog__no {
  font-family: var(--fm-font-mono); font-weight: 600; font-size: var(--fm-fs-xs);
  color: var(--fm-brand); background: var(--fm-brand-tint);
  border-radius: var(--fm-radius-xs); padding: 2px 7px;
}
.catalog__card-title {
  font-family: var(--fm-font-display); font-weight: 700; font-size: var(--fm-fs-h3);
  color: var(--fm-text); line-height: 1.25; letter-spacing: var(--fm-tr-title);
}
.catalog__card-purpose {
  font-size: var(--fm-fs-xs); color: var(--fm-text-3); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.catalog__card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: auto; padding-top: 9px; border-top: 1px solid var(--fm-border-soft);
}
.catalog__card-foot b { color: var(--fm-accent-deep); }

@media (max-width: 640px) {
  .catalog__grid { grid-template-columns: minmax(0, 1fr); }
  .catalog__head { padding-bottom: 20px; }
}

/* --- 19. Приглушённый текст на тонированной подложке -------------------------
   Серый --fm-text-3 рассчитан на белое и на фон страницы. На подложках
   #D6E7EA и #FDEAE0 он проваливается до 4.0:1. Поэтому внутри тонированных
   контейнеров он переопределяется на глубокий цвет своей же семьи —
   одно правило вместо десятка точечных, и вся вложенная типографика
   (.card__sub, .tile__note, .eyebrow, .t-muted, .kpi__note) подхватывает
   его сама, потому что берёт цвет из той же переменной. */

.card--brand,
.card--rail .card__head,
.kpi--ok, .kpi--brand,
.alert--ok, .alert--info,
.tile:has(input:checked) {
  --fm-text-3: var(--fm-brand);
  --fm-text-4: var(--fm-brand-soft);
}

.card--accent, .card--danger,
.card--auto .card__head,
.kpi--warn, .kpi--danger,
.alert--warn, .alert--danger {
  --fm-text-3: var(--fm-accent-deep);
  --fm-text-4: var(--fm-accent);
}


/* =============================================================================
   Бухгалтерия по шаблону 1С: отчёты-деревья, редактируемые табличные части,
   панель периода, поля выбора с поиском, окно «Дт/Кт»
   ========================================================================== */
.acc-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; }
.acc-toolbar .field { min-width: 150px; margin: 0; }
.acc-toolbar .field--wide { min-width: 260px; }
.acc-toolbar__spacer { flex: 1; }
.acc-status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fm-fs-sm); color: var(--fm-text-2); }
.acc-status__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--fm-border); }
.acc-status--posted .acc-status__dot { background: var(--fm-brand); }
.acc-status--draft .acc-status__dot { background: var(--fm-accent); }

/* Дерево отчёта: строки с уровнем и раскрытием */
.tree-row td:first-child { white-space: nowrap; }
.tree-row[data-level="1"] td:first-child { padding-left: 28px; }
.tree-row[data-level="2"] td:first-child { padding-left: 46px; }
.tree-row[data-level="3"] td:first-child { padding-left: 64px; }
.tree-row--group td { font-weight: 600; background: color-mix(in srgb, var(--fm-brand) 5%, transparent); }
.tree-row--total td { font-weight: 700; background: color-mix(in srgb, var(--fm-brand) 9%, transparent); border-top: 2px solid var(--fm-border); }
.tree-toggle { display: inline-flex; width: 18px; height: 18px; align-items: center; justify-content: center;
  border: 1px solid var(--fm-border); border-radius: 4px; background: var(--fm-surface); cursor: pointer; margin-right: 6px; font-size: 11px; line-height: 1; color: var(--fm-text-2); }
.tree-toggle[aria-expanded="true"] { transform: none; }
.tree-row[hidden] { display: none; }
.acc-link { color: var(--fm-brand); text-decoration: none; border-bottom: 1px dotted currentColor; cursor: pointer; }
.acc-link:hover { color: var(--fm-accent); }
.table .is-cur { color: var(--fm-text-2); font-size: var(--fm-fs-xs); display: block; }

/* Табличная часть документа: ячейки-инпуты без рамок */
.lines-table td { padding: 4px 6px; vertical-align: middle; }
.lines-table .input, .lines-table .select { height: 30px; padding: 3px 8px; font-size: var(--fm-fs-sm); }
.lines-table td.is-num .input { text-align: right; }
.lines-table__remove { color: var(--fm-text-2); }
.lines-table__remove:hover { color: var(--fm-danger, #C2470F); }
.lines-table tfoot td { font-weight: 600; }

/* Поле выбора с поиском (контрагент, номенклатура, счёт) */
.lookup { position: relative; }
.lookup__list { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); max-height: 260px; overflow-y: auto;
  background: var(--fm-surface); border: 1px solid var(--fm-border); border-radius: 10px; box-shadow: var(--fm-shadow-md, 0 8px 24px rgba(0,0,0,.12)); padding: 4px; }
.lookup__item { display: flex; justify-content: space-between; gap: 10px; width: 100%; padding: 7px 10px; border: 0; background: none; text-align: left;
  border-radius: 7px; cursor: pointer; font-size: var(--fm-fs-sm); color: var(--fm-text); }
.lookup__item:hover, .lookup__item[aria-selected="true"] { background: color-mix(in srgb, var(--fm-brand) 8%, transparent); }
.lookup__hint { color: var(--fm-text-2); font-size: var(--fm-fs-xs); white-space: nowrap; }
.lookup__clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--fm-text-2); cursor: pointer; font-size: 16px; line-height: 1; }
.lookup--modal .lookup__list { position: fixed; }

/* Панель проводок Дт/Кт */
.entries-table td { padding: 6px 10px; }
.entries-table .sub { display: block; font-size: var(--fm-fs-xs); color: var(--fm-text-2); }

/* Секции формы 1С: две колонки шапки */
.doc-head { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 24px; }
.doc-head .field { margin: 0; }
.doc-head .field--wide { grid-column: 1 / -1; }
.doc-totals { display: flex; justify-content: flex-end; gap: 28px; padding: 10px 14px; background: color-mix(in srgb, var(--fm-brand) 6%, transparent); border-radius: 10px; font-size: var(--fm-fs-sm); }
.doc-totals b { font-family: var(--fm-font-mono); font-size: var(--fm-fs-body); }
.doc-messages { border-top: 3px solid var(--fm-brand); margin-top: 16px; padding-top: 8px; }
.doc-messages__item { background: #FFF6D6; color: #6B4B00; padding: 8px 12px; border-radius: 6px; font-size: var(--fm-fs-sm); margin-top: 6px; }
@media (max-width: 720px) { .doc-head { grid-template-columns: minmax(0, 1fr); } }

/* Монитор показателей и дашборды руководителя */
.kpi-list { display: flex; flex-direction: column; gap: 6px; }
.kpi-list__row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--fm-border-soft); }
.kpi-list__row--sub { padding-left: 16px; color: var(--fm-text-2); border-bottom: 0; }
.kpi-list__value { font-family: var(--fm-font-mono); font-weight: 600; white-space: nowrap; }
.month-close { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.month-close__col { background: color-mix(in srgb, var(--fm-brand) 4%, transparent); border-radius: 12px; padding: 12px; min-height: 120px; }
.month-close__step { display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-size: var(--fm-fs-sm); }
.month-close__step--done { color: var(--fm-brand); }
.month-close__step--error { color: var(--fm-danger, #C2470F); }
@media (max-width: 900px) { .month-close { grid-template-columns: minmax(0, 1fr); } }
.print-only { display: none; }
@media print { .sidebar, .topbar, .page-head__actions, .acc-toolbar, .filter-bar, .btn { display: none !important; } .print-only { display: block; } .app__main { margin: 0; } }

/* Только что сохранённый заказ.
   Менеджер приходит в список сразу после «Сохранить» и должен найти свою
   строку глазами за секунду — поэтому она подсвечивается и гаснет сама
   (ТЗ v6.5, раздел 2.3). */
tr.is-new > td { background: var(--fm-ok-bg); animation: fm-new-row 4s ease-out forwards; }
tr.is-new > td:first-child { box-shadow: inset 3px 0 0 var(--fm-ok-fg); }
@keyframes fm-new-row { 0%, 55% { background: var(--fm-ok-bg); } 100% { background: transparent; } }
@media (prefers-reduced-motion: reduce) { tr.is-new > td { animation: none; } }
