/* ============================================================
   CRM 3D Кузня — дизайн-система «кузница»
   Чугун/сажа · раскалённый металл (ember) · латунь (brass)
   Oswald (дисплей, промышленный) + Manrope (текст)
   ============================================================ */

:root {
  /* Тёмная сторона — сажа и чугун (сайдбар, логин) */
  --soot:        #15120e;
  --iron:        #1d1915;
  --iron-2:      #262019;
  --cast:        #322a21;
  --cast-line:   #3d3328;

  /* Раскалённый металл и латунь — акценты */
  --ember:       #ff5a1f;
  --ember-glow:  #ff7a3d;
  --ember-deep:  #d8410f;
  --brass:       #c9a24b;
  --brass-soft:  #e2c98a;

  /* Светлая сторона — тёплая «бумага» цеха (контент) */
  --paper:       #f4f0e8;
  --paper-2:     #fbf8f2;
  --panel:       #ffffff;
  --line:        #e3dccf;
  --line-strong: #d2c8b6;

  /* Текст */
  --ink:         #1c1813;
  --ink-2:       #4b4338;
  --ink-3:       #847a68;
  --on-dark:     #efe9df;
  --on-dark-dim: #a99e8b;

  /* Статусные */
  --ok:    #2f9e54;
  --warn:  #d97a0b;
  --bad:   #d23b2c;
  --bad-wash: #fdeee9;

  --r:    10px;
  --r-sm: 7px;
  --shadow: 0 1px 2px rgba(28,24,19,.06), 0 4px 16px rgba(28,24,19,.06);
  --shadow-lg: 0 12px 40px rgba(20,18,14,.18);

  --sidebar-w: 232px;
  --font-display: "Oswald", "Manrope", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

/* Атрибут hidden должен прятать элемент даже если у класса задан display */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: .01em;
  margin: 0;
  color: var(--ink);
}

/* ====================== Каркас приложения ====================== */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, var(--iron) 0%, var(--soot) 100%);
  color: var(--on-dark);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid #000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--cast);
}
.brand__mark {
  width: 34px; height: 34px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: radial-gradient(120% 120% at 30% 20%, var(--ember-glow), var(--ember-deep));
  box-shadow: 0 0 0 1px rgba(255,122,61,.3), 0 4px 14px rgba(216,65,15,.45);
  font-size: 18px;
}
/* Реальный логотип 3D Кузни вместо иконки */
.brand__mark--logo {
  width: 40px; height: 40px; background: none; box-shadow: none;
  border-radius: 9px; overflow: hidden;
}
.brand__mark--logo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #fff;
  line-height: 1;
}
.brand__sub {
  font-size: 10px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--brass);
}

.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav__label {
  font-size: 10px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--on-dark-dim); padding: 14px 12px 6px;
}
.nav__item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; border-radius: var(--r-sm);
  color: var(--on-dark-dim);
  font-weight: 600; font-size: 15px;
  transition: background .15s, color .15s;
}
.nav__item:hover { background: var(--iron-2); color: var(--on-dark); }
.nav__item.is-active {
  background: linear-gradient(90deg, rgba(255,90,31,.18), rgba(255,90,31,.02));
  color: #fff;
  box-shadow: inset 3px 0 0 var(--ember);
}
.nav__item .ic { width: 20px; height: 20px; display: grid; place-items: center; opacity: .92; flex: 0 0 20px; }
.nav__item .ic svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.nav__item.is-active .ic { color: var(--ember-glow); opacity: 1; }

.sidebar__foot {
  padding: 12px; border-top: 1px solid var(--cast);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--cast); color: var(--brass-soft);
  display: grid; place-items: center; font-weight: 700;
  font-family: var(--font-display); flex: 0 0 32px;
}
.sidebar__foot small { color: var(--on-dark-dim); display: block; font-size: 11px; }
.sidebar__foot b { color: var(--on-dark); font-weight: 600; font-size: 13px; }
.logout { margin-left: auto; color: var(--on-dark-dim); font-size: 16px; }
.logout:hover { color: var(--ember-glow); }

/* ====================== Основная область ====================== */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px; flex: 0 0 60px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 18px;
  padding: 0 26px;
  position: sticky; top: 0; z-index: 20;
}
.topbar__title { font-size: 22px; text-transform: uppercase; letter-spacing: .03em; }
.topbar__title small {
  font-family: var(--font-body); text-transform: none; letter-spacing: 0;
  color: var(--ink-3); font-weight: 600; font-size: 12px; margin-left: 10px;
}
.topbar__spacer { flex: 1; }
/* Кнопка «Инструкция» — в конце топбара, тонко отделена от основных кнопок */
.btn--help {
  margin-left: 10px; border-color: var(--line); color: var(--ink-3);
  position: relative;
}
.btn--help::before {
  content: ""; position: absolute; left: -7px; top: 20%; bottom: 20%;
  width: 1px; background: var(--line-strong);
}
.btn--help:hover { border-color: var(--ink-3); color: var(--ink-2); }
.btn--help.is-active { background: linear-gradient(180deg, var(--ember-glow), var(--ember)); color: #fff; border-color: var(--ember-deep); }

.content { padding: 22px 26px; flex: 1; }

/* ====================== Кнопки ====================== */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 17px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line-strong);
  background: var(--panel); color: var(--ink);
  font-family: var(--font-body); font-weight: 700; font-size: 14.5px;
  cursor: pointer; transition: all .14s; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(28,24,19,.05);
}
.btn:hover { border-color: var(--ink-3); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn--primary {
  background: linear-gradient(180deg, var(--ember-glow), var(--ember));
  border-color: var(--ember-deep); color: #fff;
  box-shadow: 0 3px 12px rgba(216,65,15,.34);
}
.btn--primary:hover { filter: brightness(1.06); border-color: var(--ember-deep); box-shadow: 0 5px 18px rgba(216,65,15,.4); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-2); box-shadow: none; }
.btn--ghost:hover { background: var(--paper); box-shadow: none; }
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--danger { background: var(--panel); border-color: #e6b3aa; color: var(--bad); }
.btn--danger:hover { background: #fdf2f0; border-color: var(--bad); }

.req { color: var(--bad); }
.repeat-row { margin-bottom: 6px; }

/* Приоритет (1 макс … 11 мин) */
.prio { display: inline-flex; align-items: center; gap: 5px; font-weight: 800; font-size: 12px; }
.prio::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--p, #8a8170); }

/* Срок: обратный отсчёт; ≤2 дней — красный */
.due { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.due--hot { color: #fff; background: var(--bad); padding: 1px 8px; border-radius: 20px; }
.due--soon { color: var(--warn); }

/* Переключатель видов (столбцами / списком) */
.viewswitch { display: inline-flex; border: 1.5px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; }
.vbtn { padding: 9px 14px; font-weight: 700; font-size: 14px; color: var(--ink-2); background: var(--panel); }
.vbtn + .vbtn { border-left: 1.5px solid var(--line-strong); }
.vbtn:hover { background: var(--paper); }
.vbtn.is-active { background: var(--ink); color: #fff; }
.btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ====================== Доска Kanban ====================== */
.board {
  display: flex; gap: 14px; align-items: flex-start;
  overflow-x: auto; padding-bottom: 20px;
  min-height: calc(100vh - 142px);
}
.col {
  flex: 0 0 290px; width: 290px;
  background: linear-gradient(180deg, var(--paper-2), var(--paper));
  border: 1px solid var(--line);
  border-radius: var(--r);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 122px);
}
.col__head {
  display: flex; align-items: center; gap: 9px;
  padding: 12px 14px 11px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0;
}
.col__dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.col__name {
  font-family: var(--font-display); font-weight: 600; font-size: 15px;
  text-transform: uppercase; letter-spacing: .04em; flex: 1;
}
.col__count {
  background: var(--paper); border: 1px solid var(--line-strong);
  color: var(--ink-2); font-weight: 700; font-size: 11px;
  padding: 1px 8px; border-radius: 20px;
}
.col__body {
  padding: 10px; display: flex; flex-direction: column; gap: 9px;
  overflow-y: auto; flex: 1; min-height: 60px;
}
.col__body.drag-over { background: rgba(255,90,31,.05); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--stage, var(--ink-3));
  border-radius: var(--r-sm);
  padding: 11px 12px;
  box-shadow: var(--shadow);
  cursor: grab;
  transition: box-shadow .15s, transform .05s;
}
.card:hover { box-shadow: var(--shadow-lg); }
.card.sortable-ghost { opacity: .4; }
.card.sortable-chosen { cursor: grabbing; }
.card__top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.card__id { font-family: var(--font-display); color: var(--ink-3); font-size: 12px; font-weight: 600; }
.card__amount { font-weight: 800; font-size: 13px; color: var(--ember-deep); }
.card__title { font-weight: 700; font-size: 15px; line-height: 1.35; margin-bottom: 7px; }
.card__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 11px; font-weight: 600; color: var(--ink-2);
  background: var(--paper); border: 1px solid var(--line);
  padding: 2px 7px; border-radius: 5px;
  display: inline-flex; align-items: center; gap: 3px;
  vertical-align: middle; white-space: nowrap;
}
.chip--user { background: #f3ede0; color: #6b5b3a; border-color: #e4d8bd; }
.chip--kit { background: #fff3e8; color: var(--ember-deep); border-color: #f2cda8; font-weight: 700; }

/* Этап-пилюля как кликабельный select (список заказов) — метрики как у .badge */
.stage-sel {
  display: inline-flex; align-items: center; width: auto; max-width: 100%;
  min-height: 22px; padding: 0 11px;
  background: var(--bg, var(--ink-3)); color: #fff; border: none;
  border-radius: 999px;
  font-family: var(--font-body); font-weight: 700; font-size: 11.5px;
  letter-spacing: .02em; line-height: 1; cursor: pointer;
  text-shadow: 0 1px 1px rgba(0,0,0,.18);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.22), 0 1px 3px rgba(28,24,19,.14);
  -webkit-appearance: none; appearance: none;
}
.form-error { color: var(--bad); }
/* Горизонтальный скролл широких таблиц на узких экранах (overflow на обёртке,
   не на .panel — иначе режутся всплывающие подсказки) */
.table-wrap { overflow-x: auto; }
.stage-sel:hover { filter: brightness(1.07); }
.stage-sel:focus { outline: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.2), 0 0 0 3px rgba(255,90,31,.25); }
.stage-sel option { background: #fff; color: var(--ink); font-weight: 600; }

/* ====================== Таблицы ====================== */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
  /* overflow видимый — иначе всплывающие подсказки (data-hint) обрезаются. */
  overflow: visible;
}
/* Скругляем углы таблицы внутри панели точечно, без обрезки контента.
   Поддерживаем два варианта: .panel > .table и .panel > .table-wrap > .table */
.panel > .table thead tr:first-child th:first-child,
.panel > .table-wrap > .table thead tr:first-child th:first-child { border-top-left-radius: var(--r); }

.panel > .table thead tr:first-child th:last-child,
.panel > .table-wrap > .table thead tr:first-child th:last-child { border-top-right-radius: var(--r); }

.panel > .table tbody tr:last-child td:first-child,
.panel > .table-wrap > .table tbody tr:last-child td:first-child { border-bottom-left-radius: var(--r); }

.panel > .table tbody tr:last-child td:last-child,
.panel > .table-wrap > .table tbody tr:last-child td:last-child { border-bottom-right-radius: var(--r); }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700; padding: 11px 14px;
  border-bottom: 1px solid var(--line); background: var(--paper-2);
  white-space: nowrap;  /* заголовки не переносятся по умолчанию — сетка не ломается */
}
/* Многострочный заголовок колонки допускается явно через .th-wrap */
.table th.th-wrap { white-space: normal; line-height: 1.3; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 14.5px; vertical-align: middle; }
.table th.center, .table td.center { text-align: center; }
.table th.right, .table td.right { text-align: right; }
/* Моноширинные цифры для числовых колонок — ровные столбцы. */
.table td.center, .table td.right, .table th.right, .table th.center {
  font-variant-numeric: tabular-nums;
}
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--paper-2); }
.table a.row-link { font-weight: 700; }
.table tr.clickable-row { cursor: pointer; }
.table tr.clickable-row:hover { background: var(--paper-2); }

/* Фиксированные минимальные ширины числовых колонок склада */
.table th.col-num { min-width: 80px; }
.table th.col-num-lg { min-width: 110px; }
.table th.col-rate { min-width: 120px; }

/* ====================== Статус-пилюли ====================== */
/* Овальные пилюли единой высоты: заливка цветом + контрастный текст.
   Базовый класс задаёт форму и ритм; модификаторы — семантику цвета.
   Цвет управляется тремя переменными, чтобы варианты были единообразны:
     --pill-bg   — заливка
     --pill-ink  — цвет текста
     --pill-edge — тонкая внутренняя обводка/контур (глубина)            */
.badge {
  --pill-bg:   var(--paper-2);
  --pill-ink:  var(--ink-2);
  --pill-edge: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  min-height: 22px;            /* единая высота всех пилюль */
  padding: 0 11px;
  font-family: var(--font-body);
  font-size: 11.5px; font-weight: 700; line-height: 1;
  letter-spacing: .02em; white-space: nowrap;
  border-radius: 999px;        /* овал */
  background: var(--pill-bg);
  color: var(--pill-ink);
  box-shadow:
    inset 0 0 0 1px var(--pill-edge),                  /* контур-обводка */
    inset 0 1px 0 rgba(255,255,255,.18),               /* верхняя подсветка */
    0 1px 1px rgba(28,24,19,.06);                       /* лёгкая тень-посадка */
  vertical-align: middle;
}
/* Точка-индикатор (необязательная). По умолчанию выключена;
   включается на нейтральных «светлых» пилюлях через .badge--dot. */
.badge--dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: .9; flex: 0 0 6px;
}

/* — Насыщенные (тёмная заливка → белый текст) — */
.badge--hot {            /* «в работе» / печатается — раскалённый металл */
  --pill-bg: linear-gradient(180deg, var(--ember-glow), var(--ember-deep));
  --pill-ink: #fff;
  --pill-edge: rgba(216,65,15,.55);
  box-shadow:
    inset 0 0 0 1px var(--pill-edge),
    inset 0 1px 0 rgba(255,255,255,.28),
    0 1px 6px rgba(216,65,15,.28);
}
.badge--done {           /* «готово» / «норма» — зелёный */
  --pill-bg: var(--ok); --pill-ink: #fff; --pill-edge: rgba(0,0,0,.18);
}
.badge--warn {           /* «на исходе» / предупреждение — янтарный */
  --pill-bg: var(--warn); --pill-ink: #fff; --pill-edge: rgba(0,0,0,.18);
}
.badge--bad {            /* «мало» / критично — красный */
  --pill-bg: var(--bad); --pill-ink: #fff; --pill-edge: rgba(0,0,0,.18);
}
/* — Нейтральная (светлая, для «Новый» и пр.) — */
.badge--new {
  --pill-bg: var(--paper-2); --pill-ink: var(--ink-2); --pill-edge: var(--line-strong);
  box-shadow:
    inset 0 0 0 1px var(--pill-edge),
    0 1px 1px rgba(28,24,19,.05);
}

/* — Этап воронки: заливка из stage.color через --bg, текст белый —
   Цвет приходит из БД (HEX). Тёмная внутренняя обводка добавляет
   «литую» глубину, верхняя подсветка — объём.                       */
.badge--stage {
  --pill-bg: var(--bg, var(--ink-3));
  --pill-ink: #fff;
  --pill-edge: rgba(0,0,0,.22);
  background: var(--pill-bg);
  text-shadow: 0 1px 1px rgba(0,0,0,.18);   /* читаемость на любом HEX */
  box-shadow:
    inset 0 0 0 1px var(--pill-edge),
    inset 0 1px 0 rgba(255,255,255,.22),
    0 1px 3px rgba(28,24,19,.14);
}

/* ====================== Тулбар/фильтры ====================== */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.field, .input, select.input {
  font-family: var(--font-body); font-size: 13px;
  padding: 7px 11px; border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); background: var(--panel); color: var(--ink);
}
.input:focus, select.input:focus, textarea.input:focus {
  outline: none; border-color: var(--ember); box-shadow: 0 0 0 3px rgba(255,90,31,.12);
}

/* ====================== Карточка заказа ====================== */
.detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }

.section { padding: 18px 20px; }
.section + .section { border-top: 1px solid var(--line); }
.section__title {
  font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700; margin: 0 0 12px;
}
/* Первый .section__title в области контента — без отступа сверху */
.content > .section__title:first-child { margin-top: 0; }

/* Предупреждение об остатках материала: горизонтальный ленточный блок */
.stock-warn {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--bad-wash); border: 1px solid #f3c9bb;
  border-left: 4px solid var(--bad);
  border-radius: var(--r-sm); padding: 10px 14px;
  margin-bottom: 18px; font-size: 13px; color: var(--bad);
}
.stock-warn__icon { font-size: 15px; flex: 0 0 auto; line-height: 1.4; }
.stock-warn__body { flex: 1; min-width: 0; }
.stock-warn__label { font-weight: 800; margin-bottom: 4px; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }
.stock-warn__items { display: flex; flex-wrap: wrap; gap: 5px; }
.stock-warn__item {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fff; border: 1px solid #f0c2bc; border-radius: 5px;
  padding: 2px 8px; font-size: 12.5px; font-weight: 700; color: var(--bad);
  white-space: nowrap;
}
.stock-warn__item small { font-weight: 400; color: var(--ink-3); }

/* ====================== Мобильная версия ====================== */
.navburger { display: none; background: none; border: none; color: var(--ink); cursor: pointer; padding: 6px; margin: 0 2px 0 -4px; border-radius: 8px; }
.navburger:active { background: var(--paper); }
.nav-backdrop { display: none; }

@media (max-width: 820px) {
  /* Сайдбар → выезжающее меню по бургеру */
  .navburger { display: inline-flex; align-items: center; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 250px;
    transform: translateX(-100%); transition: transform .22s ease; z-index: 200;
  }
  .app.nav-open .sidebar { transform: translateX(0); box-shadow: 10px 0 50px rgba(0,0,0,.45); }
  .nav-backdrop { position: fixed; inset: 0; background: rgba(20,16,12,.5); z-index: 199; }
  .app.nav-open .nav-backdrop { display: block; }

  .main { width: 100%; }
  .topbar { height: auto; min-height: 54px; flex: none; padding: 8px 12px; gap: 10px; flex-wrap: wrap; }
  .topbar__title { font-size: 18px; }
  .content { padding: 14px 12px; }

  /* Широкие таблицы — горизонтальный скролл */
  .panel { overflow-x: auto; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .board { min-height: auto; }

  /* Поменьше отступов в таблицах, чтобы влезало больше */
  .table th, .table td { padding: 9px 10px; font-size: 13px; }

  /* cost-plate и stock-warn на мобильном — вертикально */
  .cost-plate { flex-direction: column; gap: 14px; }
  .stock-warn { flex-direction: column; gap: 6px; }

  /* — Тач-таргеты ≥44px: палец/перчатка в цеху — */
  .btn { min-height: 44px; padding: 11px 18px; }
  .btn--sm { min-height: 40px; padding: 9px 15px; font-size: 13.5px; }
  .nav__item { min-height: 46px; }
  .vbtn, .ctype, .tab, .copy-btn { min-height: 42px; }

  /* — Инпуты 16px: iOS Safari не зумит страницу при фокусе; цифры читаемее — */
  .input, select.input, textarea.input, .field,
  input[type="text"], input[type="number"], input[type="password"],
  input[type="search"], input[type="tel"], input[type="email"], input[type="date"],
  select, textarea { font-size: 16px; }

  /* — Статус-пилюли и select-этапы: крупнее и эмодзи (⚪ 🟢 🟡) НЕ обрезаются.
       Причина бага на телефоне: min-height 22px + line-height 1 резали эмодзи. — */
  .badge { min-height: 28px; font-size: 12.5px; padding: 4px 13px; line-height: 1.25; }
  .stage-sel { min-height: 34px; font-size: 14px; padding: 5px 14px; line-height: 1.3; }
  .chip { font-size: 12px; padding: 3px 9px; }
  .tag-status { font-size: 13px; }

  /* — safe-area iPhone (чёлка/индикатор) — */
  .content { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .sidebar { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; }
.kv dt { color: var(--ink-3); font-weight: 600; font-size: 12.5px; }
.kv dd { margin: 0; font-weight: 600; }

/* Лента событий */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 7px; top: 4px; bottom: 4px;
  width: 2px; background: var(--line);
}
.tl { position: relative; padding: 0 0 16px 28px; }
.tl::before {
  content: ""; position: absolute; left: 2px; top: 3px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--panel); border: 2px solid var(--ink-3);
}
.tl--stage::before { border-color: var(--ember); background: var(--ember); }
.tl--created::before { border-color: var(--brass); background: var(--brass); }
.tl__time { font-size: 11px; color: var(--ink-3); font-weight: 600; }
.tl__text { font-weight: 600; }
.tl__text b { font-weight: 800; }

/* ====================== Чат заказа ====================== */
.chat { display: flex; flex-direction: column; gap: 9px; max-height: 360px; overflow-y: auto; margin-bottom: 14px; padding-right: 4px; }
.chatmsg { border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: var(--paper-2); }
.chatmsg__head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.chatmsg__tag { font-weight: 700; font-size: 12px; }
.chatmsg__who { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.chatmsg__time { font-size: 11px; color: var(--ink-3); margin-left: auto; }
.chatmsg__text { font-size: 14px; line-height: 1.45; }
.chatmsg--comment { background: #fff; }
.chatmsg--note { background: #fdf8ed; border-color: #ece0c0; }
.chatmsg--reminder { background: #eef4ff; border-color: #cdddf7; }
.chatmsg--reminder .chatmsg__tag { color: #2563eb; }
.chatmsg--important { background: #fdeee9; border-color: #f3c9bb; box-shadow: inset 3px 0 0 var(--ember); }
.chatmsg--important .chatmsg__tag { color: var(--ember-deep); }

.composer { border-top: 1px solid var(--line); padding-top: 12px; }
.composer__types { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 9px; }
.ctype {
  font-family: var(--font-body); font-size: 12.5px; font-weight: 700;
  padding: 6px 11px; border-radius: 7px; cursor: pointer;
  border: 1.5px solid var(--line-strong); background: var(--panel); color: var(--ink-2);
  transition: all .12s;
}
.ctype:hover { border-color: var(--ink-3); }
.ctype.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.composer__remind { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.composer__remind label { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }

/* Вложения */
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.thumb {
  width: 84px; height: 84px; border-radius: var(--r-sm); overflow: hidden;
  border: 1px solid var(--line); background: var(--paper-2);
  display: grid; place-items: center; position: relative;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb__file { font-size: 10px; color: var(--ink-2); text-align: center; padding: 6px; font-weight: 700; }
.thumb__ext { font-family: var(--font-display); font-size: 16px; color: var(--ember-deep); }

/* Смена статуса модели */
.status-changer { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.status-changer select { min-width: 190px; }
.status-changer #status-reason { flex: 1; min-width: 160px; }

/* Список ссылок с копированием */
.linklist { display: flex; flex-direction: column; gap: 7px; }
.linkrow { display: flex; align-items: center; gap: 8px; }
.linkrow__url { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #2563eb; font-weight: 600; font-size: 13.5px; }
.copy-btn { flex: 0 0 auto; }

/* Список файлов с подписями (модель) */
.filelist { display: flex; flex-direction: column; gap: 9px; }
.fitem { display: flex; align-items: center; gap: 11px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 10px; background: var(--paper-2); }
.fitem__prev { width: 52px; height: 52px; flex: 0 0 52px; border-radius: 6px; overflow: hidden; background: var(--panel); border: 1px solid var(--line); display: grid; place-items: center; }
.fitem__prev img { width: 100%; height: 100%; object-fit: cover; }
.fitem__prev .thumb__ext { font-family: var(--font-display); font-size: 14px; color: var(--ember-deep); }
.fitem__body { flex: 1; min-width: 0; }
.fitem__name { display: block; font-weight: 700; font-size: 13.5px; margin-bottom: 5px; }
.fitem__cap { display: flex; gap: 6px; }
.fitem__cap input { flex: 1; padding: 5px 9px; font-size: 13px; border: 1px solid var(--line-strong); border-radius: 6px; }
.upload-row { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.upload-row input[type=file] { flex: 1; min-width: 160px; }

/* ====================== Формы ====================== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row.col-2 { grid-column: 1 / -1; }
.form-row label { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.form-row input, .form-row select, .form-row textarea {
  font-family: var(--font-body); font-size: 13.5px; padding: 8px 11px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--panel); color: var(--ink); width: 100%;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none; border-color: var(--ember); box-shadow: 0 0 0 3px rgba(255,90,31,.12);
}
.errorlist { color: var(--bad); font-size: 12px; margin: 2px 0 0; padding-left: 16px; }

/* ====================== Сообщения ====================== */
.messages { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg {
  padding: 10px 14px; border-radius: var(--r-sm); font-weight: 600; font-size: 13px;
  border: 1px solid; background: var(--panel);
}
.msg.success { color: var(--ok); border-color: #b6e0c4; background: #f0f9f3; }
.msg.error { color: var(--bad); border-color: #f0c2bc; background: #fdf2f0; }

/* ====================== Пустые состояния ====================== */
.empty { text-align: center; padding: 48px 24px; color: var(--ink-3); font-weight: 600; font-size: 14px; }
.empty__mark { font-size: 32px; margin-bottom: 10px; opacity: .45; display: block; }
.empty a { color: var(--ember-deep); font-weight: 700; }
.empty a:hover { text-decoration: underline; }

/* ====================== Логин ====================== */
.login-page {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(60% 50% at 70% 10%, rgba(255,90,31,.16), transparent 60%),
    radial-gradient(50% 60% at 20% 90%, rgba(201,162,75,.10), transparent 60%),
    linear-gradient(160deg, var(--iron), var(--soot));
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: rgba(38,32,25,.72);
  backdrop-filter: blur(8px);
  border: 1px solid var(--cast-line);
  border-radius: 16px; padding: 34px 30px;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
  color: var(--on-dark);
}
.login-card .brand { border: 0; padding: 0 0 22px; justify-content: center; }
.login-card h1 {
  color: #fff; font-size: 22px; text-transform: uppercase; letter-spacing: .05em;
  text-align: center; margin-bottom: 4px;
}
.login-card p.muted { text-align: center; color: var(--on-dark-dim); margin: 0 0 22px; font-size: 13px; }
.login-card label { color: var(--on-dark-dim); font-size: 12px; font-weight: 700; }
.login-card input {
  width: 100%; padding: 10px 13px; margin-top: 5px; margin-bottom: 14px;
  background: var(--soot); border: 1px solid var(--cast-line); border-radius: var(--r-sm);
  color: #fff; font-family: var(--font-body); font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--ember); box-shadow: 0 0 0 3px rgba(255,90,31,.18); }
.login-card .btn--primary { width: 100%; justify-content: center; padding: 11px; margin-top: 6px; }
.login-error { color: #ff9b7a; font-size: 12.5px; margin-bottom: 12px; font-weight: 600; text-align: center; }

/* Карточка модели на доске тестирования */
.tcard { display: flex; gap: 10px; align-items: center; }
.tcard__thumb { width: 46px; height: 46px; border-radius: 6px; overflow: hidden; flex: 0 0 46px; background: var(--paper-2); border: 1px solid var(--line); }
.tcard__thumb img { width: 100%; height: 100%; object-fit: cover; }
.tcard__body { min-width: 0; flex: 1; }
.tcard .card__title { margin-bottom: 4px; }

/* Плашка себестоимости */
.cost-plate {
  background: linear-gradient(135deg, var(--iron), var(--soot));
  color: var(--on-dark); border-radius: var(--r); padding: 18px 22px;
  display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap;
  box-shadow: 0 0 0 1px rgba(255,122,61,.12), 0 4px 18px rgba(20,16,12,.18);
  margin-bottom: 20px;
}
.cost-plate__label { font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase; color: var(--on-dark-dim); margin-bottom: 3px; }
.cost-plate__value { font-family: var(--font-display); font-size: 34px; font-weight: 600; color: var(--ember-glow); line-height: 1.1; }
.cost-plate__sub { font-size: 12px; color: var(--on-dark-dim); margin-top: 4px; }
/* Разбивка: аккуратные чипы на тёмном фоне */
.cost-plate__break {
  display: flex; flex-wrap: wrap; gap: 7px;
  align-items: flex-start; align-content: flex-start;
  padding-top: 2px;
}
.cost-plate__break span {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px; padding: 4px 9px;
  font-size: 12px; color: var(--on-dark-dim);
  white-space: nowrap;
}
.cost-plate__break b {
  color: var(--brass-soft); font-family: var(--font-display);
  font-size: 13px; font-weight: 600;
}

/* Карточки парка принтеров */
.fleet { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 11px; }
.pcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px; box-shadow: var(--shadow); }
.pcard.is-test { background: var(--paper-2); opacity: .8; }
.pcard__sku { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.pcard__model { font-size: 11.5px; color: var(--ink-3); }
.pcard__row { display: flex; justify-content: space-between; font-size: 11.5px; margin-top: 7px; }
.pdot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* Метрики готовой продукции */
.metric { display: inline-flex; flex-direction: column; align-items: center; min-width: 56px; }
.metric b { font-family: var(--font-display); font-size: 18px; }
.metric small { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.progress {
  height: 6px; border-radius: 4px; background: var(--line); overflow: hidden;
  min-width: 80px;
}
.progress > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--ember-deep), var(--ok));
  border-radius: 4px; transition: width .3s ease;
}

/* Инлайн-форма действия (брак/доделка) */
.inline-act { display: flex; gap: 5px; align-items: center; }
.inline-act input { width: 58px; padding: 4px 6px; border: 1px solid var(--line-strong); border-radius: 5px; font-size: 12px; }

/* Виджеты форм в таблице позиций */
#items-table input, #items-table select, #items-table textarea {
  font-family: var(--font-body); font-size: 13px; padding: 6px 8px;
  border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--panel); color: var(--ink); width: 100%;
}
#items-table input:focus, #items-table select:focus {
  outline: none; border-color: var(--ember); box-shadow: 0 0 0 3px rgba(255,90,31,.12);
}

/* ====================== Подсказки (Инструкция) ====================== */

[data-hint] { position: relative; }
/* Поднимаем сам триггер в отдельный слой — иначе соседние поля ввода
   (native-контролы в Safari) рисуются поверх подсказки. */
[data-hint]:hover { z-index: 200; }
[data-hint]:hover::after {
  content: attr(data-hint);
  position: absolute; top: calc(100% + 8px); right: 0;
  width: max-content; max-width: 260px;
  background: var(--soot); color: var(--on-dark);
  font-size: 12.5px; font-weight: 600; line-height: 1.4;
  padding: 8px 11px; border-radius: 8px; z-index: 9999;
  box-shadow: var(--shadow-lg); border: 1px solid var(--cast-line);
  white-space: normal; text-align: left; pointer-events: none;
}
[data-hint]:hover::before {
  content: ""; position: absolute; top: calc(100% + 2px); right: 14px;
  border: 6px solid transparent; border-bottom-color: var(--soot); z-index: 9999;
}
/* На тач-устройствах :hover «залипает» при тапе и тёмная плашка-подсказка
   обрезается контейнером таблицы (видно «чёрное поле»). Отключаем hover-подсказки
   на тач — обучающие тексты остаются в drawer «Инструкция». */
@media (hover: none), (pointer: coarse) {
  [data-hint]:hover::after, [data-hint]:hover::before { display: none !important; }
}
/* Внутри прокручиваемых таблиц (.table-wrap) кастомная тёмная плашка-подсказка
   обрезается контейнером (overflow) и прячется за кнопкой — там используем родной
   браузерный title (см. шаблоны), а кастомную подсказку глушим. */
.table-wrap [data-hint]:hover::after, .table-wrap [data-hint]:hover::before { display: none !important; }
/* Панель-помощник (drawer) */
.help-overlay { position: fixed; inset: 0; background: rgba(20,18,14,.45); z-index: 90; }
.helpdrawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 92vw;
  background: var(--paper-2); z-index: 91; display: flex; flex-direction: column;
  box-shadow: -16px 0 50px rgba(20,18,14,.3); border-left: 1px solid var(--line);
  animation: help-slide .22s ease;
}
@keyframes help-slide { from { transform: translateX(100%); } to { transform: translateX(0); } }
.helpdrawer__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  font-family: var(--font-display); font-size: 17px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .03em; background: var(--panel);
}
.helpdrawer__close { border: 0; background: transparent; font-size: 18px; cursor: pointer; color: var(--ink-3); }
.helpdrawer__close:hover { color: var(--ember-deep); }
.helpdrawer__body { padding: 20px; overflow-y: auto; }
.helpdrawer__title { font-size: 19px; margin-bottom: 6px; }
.helpdrawer__intro { color: var(--ink-2); font-size: 14.5px; margin: 0 0 16px; }
.helpdrawer__sub { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 700; margin: 16px 0 8px; }
.helpsteps, .helptips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.helpsteps li { font-size: 14px; line-height: 1.5; padding-left: 14px; position: relative; }
.helpsteps li::before { content: ""; position: absolute; left: 0; top: 9px; width: 6px; height: 6px; border-radius: 50%; background: var(--ember); }
.helpsteps li b { color: var(--ink); }
.helptips li { font-size: 13.5px; color: var(--ink-2); line-height: 1.45; }

.editable-title { cursor: pointer; border-bottom: 2px dotted var(--line-strong); padding-bottom: 1px; }
.editable-title:hover { border-bottom-color: var(--ember); }

/* Полное руководство */
.guide { display: flex; flex-direction: column; gap: 16px; max-width: 820px; }
.guide p { font-size: 15px; line-height: 1.6; }
.guide-flow { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 11px; }
.guide-flow li { font-size: 15px; line-height: 1.55; }
.guide-block { padding: 14px 0; border-top: 1px solid var(--line); }
.guide-block:first-of-type { border-top: 0; padding-top: 0; }
.guide-block h3 { font-size: 16px; margin-bottom: 4px; }

/* Вкладки-фильтры */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; font-weight: 700; font-size: 14px; color: var(--ink-3);
  border-bottom: 2.5px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); border-bottom-color: var(--ember); }
.tab__n { font-size: 11.5px; background: var(--paper); border: 1px solid var(--line-strong); color: var(--ink-2); padding: 0 7px; border-radius: 20px; }
.tab.is-active .tab__n { background: var(--ember); color: #fff; border-color: var(--ember-deep); }

/* Утилиты */
.muted { color: var(--ink-3); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.tag-status { font-family: var(--font-display); font-weight: 600; }

/* ============================================================
   Уведомления, @упоминания, индикатор чата (v38)
   ============================================================ */

/* Индикатор общения на карточке/в списке заказа */
.chip--chat { background: #eef4ff; color: #2d5bb8; border-color: #cdddf7; font-weight: 700; }

/* Бейдж-счётчик уведомлений в боковом меню */
.nav__item--notif { position: relative; }
.nav__badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; line-height: 1; color: #fff;
  background: var(--ember); border-radius: 999px;
  box-shadow: 0 0 0 2px rgba(214,90,30,.18);
}

/* Список уведомлений */
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif { border-bottom: 1px solid var(--line); }
.notif:last-child { border-bottom: 0; }
.notif--unread { background: #fff8f1; }
.notif__link {
  display: flex; align-items: flex-start; gap: 12px; padding: 13px 14px;
  color: inherit; text-decoration: none;
}
.notif__link:hover { background: var(--paper); }
.notif__icon {
  flex: 0 0 34px; width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 800;
  background: #eef4ff; color: #2d5bb8;
}
.notif__icon--reminder { background: #fff1e6; color: var(--ember-deep); }
.notif__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.notif__top { font-size: 14px; }
.notif__text { font-size: 13px; color: var(--ink-2); }
.notif__time { font-size: 11px; color: var(--ink-3); }
.notif__dot {
  flex: 0 0 9px; width: 9px; height: 9px; margin-top: 6px;
  border-radius: 50%; background: var(--ember);
}

/* Подсветка @упоминания в чате */
.mention {
  font-weight: 700; color: #2d5bb8; background: #eef4ff;
  border-radius: 4px; padding: 0 3px;
}

/* Composer: чипы отмеченных + выпадашка автодополнения */
.composer__mentions { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.mchip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 700; color: #2d5bb8;
  background: #eef4ff; border: 1px solid #cdddf7;
  border-radius: 999px; padding: 2px 4px 2px 9px;
}
.mchip button {
  border: 0; background: #cdddf7; color: #1c3c7a; cursor: pointer;
  width: 16px; height: 16px; border-radius: 50%; line-height: 1; font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center;
}
.composer__field { position: relative; }
.mention-pop {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 30;
  list-style: none; margin: 4px 0 0; padding: 4px;
  background: var(--panel); border: 1.5px solid var(--line-strong);
  border-radius: var(--r-sm); box-shadow: var(--shadow-lg); max-height: 220px; overflow: auto;
}
.mention-pop li {
  padding: 8px 10px; border-radius: 7px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--ink);
}
.mention-pop li:hover { background: #eef4ff; color: #2d5bb8; }

/* Важные уведомления и отметки по роли (v39) */
.notif--important { background: #fff4f1; }
.notif--important.notif--unread { background: #ffece6; }
.notif__icon--important { background: #fde2da !important; color: var(--bad) !important; }
.notif__tag {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .02em;
  color: #fff; background: var(--bad); border-radius: 5px; padding: 1px 6px; margin-right: 4px;
}
.mchip--role { background: #f1ecff; border-color: #d8ccf7; color: #6d4bd0; }
.mchip--role button { background: #d8ccff; color: #4a2da0; }
.mention-pop li.is-role { color: #6d4bd0; font-weight: 700; }
.mention-pop li.is-role:hover { background: #f1ecff; }

/* Главное фото модели — компактно справа в «Параметрах» (v40) */
.param-row { display:flex; gap:16px; align-items:flex-start; }
.param-row__main { flex:1 1 auto; min-width:0; }
.param-row__photo { flex:0 0 168px; width:168px; }
.param-photo { display:block; border-radius:10px; overflow:hidden; background:#15110d; border:1px solid var(--line); }
.param-photo img { display:block; width:100%; height:168px; object-fit:cover; }
.param-photo__btn { width:100%; margin-top:6px; justify-content:center; }
.param-photo__empty { display:flex; justify-content:center; padding:10px; border:1px dashed var(--line-strong); border-radius:10px; }
@media (max-width:560px){
  .param-row { flex-direction:column-reverse; }
  .param-row__photo { width:100%; max-width:220px; }
}
