:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --text: #0b1020;
  --muted: #5a6675;
  --border: #e4e8ee;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef0fe;
  --teal: #14b8a6;
  --teal-ink: #0f766e;
  --teal-soft: #e6faf7;
  --danger: #b91c1c;
  --warn: #b45309;
  --ink: #0b1020;
  /* 44px — минимальная зона нажатия пальцем (WCAG 2.5.5). */
  --control-height: 44px;
  --control-pad-x: 16px;
  --control-radius: 10px;
}
* { box-sizing: border-box; }
/* overflow-x у body всплывает на вьюпорт, если у html он visible — тогда сам body
   ничего не обрезает и страница едет вбок (всплывающие подсказки уводили её на 50px).
   Дублируем правило на html, чтобы обрезал именно body. */
html { overflow-x: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", "Segoe UI", Tahoma, sans-serif;
  overflow-x: hidden;
}
a { color: var(--primary-dark); }
:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 2px;
}
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}
h1, h2, h3 { margin-top: 0; }
nav {
  background: var(--card);
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -.01em;
  color: var(--ink);
  text-decoration: none;
}
.nav-brand:hover { text-decoration: none; }
.nav-brand svg { display: block; }
.nav-brand .tech {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--muted);
}
nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: nowrap;
}
nav .nav-left,
nav .nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
nav .nav-left {
  flex-wrap: nowrap;
}
nav .nav-right {
  margin-left: auto;
  white-space: nowrap;
}
nav a { color: var(--text); text-decoration: none; margin-right: 0; white-space: nowrap; }
nav a:hover { text-decoration: underline; }
nav .nav-right span { color: var(--muted); font-size: 13px; }
.nav-dropdown {
  position: relative;
}
.nav-dropdown summary {
  list-style: none;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.nav-dropdown summary::-webkit-details-marker {
  display: none;
}
.nav-dropdown summary:hover {
  text-decoration: underline;
}
.nav-dropdown summary.is-active {
  text-decoration: underline;
}
.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 200px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
  z-index: 20;
}
.nav-dropdown-menu a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: #0f172a;
  text-decoration: none;
}
.nav-dropdown-menu a:hover {
  background: #f1f5f9;
  text-decoration: none;
}
.nav-dropdown-group {
  padding: 8px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.nav-dropdown-group + a {
  margin-top: 0;
}
form.inline { display: inline; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.products-filter-row {
  /* Только поля отбора. Кнопки живут ниже своей строкой: в сетке они были
     лишними элементами и последняя уезжала на отдельную строку одна. */
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: end;
}
@media (min-width: 1100px) {
  .products-filter-row {
    grid-template-columns: minmax(190px, 1.5fr) repeat(5, minmax(140px, 1fr));
  }
}
.filter-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.filter-actions-row button { width: auto; max-width: none; }
label { display: block; margin-bottom: 6px; font-weight: 600; }
input, select, textarea, button {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-width: 16px;
  height: 16px;
  margin: 0 8px 0 0;
  vertical-align: middle;
}
.check-label {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  margin-bottom: 0;
}
/* Сам квадратик флажка — 16px, это меньше минимальной зоны нажатия. Кликабельна
   вся метка, поэтому поднимаем её высоту, а не размер квадратика. */
label:has(> input[type="checkbox"]),
label:has(> input[type="radio"]) {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  cursor: pointer;
}
.multi-check-dropdown {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  background: #fff;
}
.multi-check-summary {
  list-style: none;
  cursor: pointer;
  min-height: var(--control-height);
  padding: 9px 36px 9px 10px;
  position: relative;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
}
.multi-check-summary::-webkit-details-marker {
  display: none;
}
.multi-check-summary::after {
  content: "▾";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 12px;
}
.multi-check-dropdown[open] .multi-check-summary::after {
  content: "▴";
}
.multi-check-list {
  border-top: 1px solid var(--border);
  max-height: 220px;
  overflow-y: auto;
  padding: 6px 8px;
}
.multi-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 4px;
  font-weight: 400;
  /* Кликабельна вся строка, а не квадратик 16px — держим её выше 24px (WCAG 2.5.8). */
  min-height: 28px;
  cursor: pointer;
}
.multi-check-item input[type="checkbox"] {
  margin-right: 0;
}
textarea { min-height: 90px; }
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  border: none;
  cursor: pointer;
  max-width: 200px;
  font-family: inherit;
  font-weight: 600;
  letter-spacing: .01em;
  border-radius: var(--control-radius);
  padding: 0 var(--control-pad-x);
  height: var(--control-height);
  line-height: 1;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(79, 70, 229, 0.25);
}
button.primary {
  background: var(--primary);
}
button.secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
button.secondary:hover { background: #f1f5f9; box-shadow: none; }
button.danger { background: #fff; color: var(--text); border: 1px solid var(--border); }
button.warn { background: var(--warn); }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--control-radius);
  padding: 0 var(--control-pad-x);
  height: var(--control-height);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .01em;
  text-decoration: none;
  line-height: 1;
  border: 1px solid var(--border);
  background: #fff;
  color: #0f172a;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12);
}
.btn.primary {
  background: var(--primary);
  color: #fff;
  border: none;
}
.btn.secondary {
  background: #fff;
  color: var(--teal-ink);
  border: 1px solid var(--teal);
}
.btn.secondary:hover { background: var(--teal-soft); box-shadow: none; }
.btn.warn {
  background: var(--warn);
  color: #fff;
  border: none;
}
.btn.danger {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn.ghost {
  background: #fff;
  color: #0f172a;
  border: 1px solid var(--border);
}
.actions a,
.modal-actions a,
.hero-actions a,
.card-header-row a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  padding: 0 var(--control-pad-x);
  height: var(--control-height);
  line-height: 1;
  text-decoration: none;
  color: #0f172a;
  background: #fff;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .01em;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.actions a:hover,
.modal-actions a:hover,
.hero-actions a:hover,
.card-header-row a:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12);
  background: #f1f5f9;
}
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--control-radius);
  padding: 0 var(--control-pad-x);
  height: var(--control-height);
  line-height: 1;
  text-decoration: none;
  color: #0f172a;
  background: #fff;
  font-weight: 600;
  font-size: 14px;
}
.ghost:hover {
  background: #f1f5f9;
}
.actions button,
.modal-actions button,
.hero-actions button,
.hero-actions .ghost,
.card-header-row .ghost,
form.inline button {
  width: auto;
  max-width: none;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.page-header h1 { margin-bottom: 0; }
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}
.empty-state-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.empty-state .actions {
  justify-content: center;
  margin-top: 14px;
}
td.empty-state {
  padding: 28px 20px;
}
/* Удаление строки повторяется в каждой строке таблицы — сплошной красный
   превращается в стену и перетягивает внимание с самих данных. Смысл
   действия несут цвет текста и рамка, заливку оставляем диалогам. */
td button.danger,
td .btn.danger {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
td button.danger:hover,
td .btn.danger:hover {
  background: #f1f5f9;
  box-shadow: none;
}
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}
th, td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 8px;
  vertical-align: top;
}
.trial-bar { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; background: #fdf7ec; border: 1px solid #e7cfa3; font-size: 14px; }
.trial-bar-over { background: #fdf1f1; border-color: #e9b4b4; }
.flash { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.flash.info { background: var(--primary-soft); }
.flash.success { background: #def7ec; }
.flash.error { background: #fee2e2; }
.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 14px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid #cfd7e3;
  border-radius: 16px;
  box-shadow: inset 0 1px 0 #f3f6fa;
  color: #64748b;
  font-size: 13px;
}
.breadcrumbs a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 600;
}
.breadcrumbs a:hover {
  background: #f7fafc;
  border-color: #dfe7f2;
}
.breadcrumbs .sep {
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
}
.audit-list {
  display: grid;
  gap: 10px;
}
.audit-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fbfcfd;
  overflow: hidden;
}
.audit-item summary {
  list-style: none;
}
.audit-item summary::-webkit-details-marker {
  display: none;
}
.audit-summary-row {
  cursor: pointer;
  padding: 14px 16px;
}
.audit-summary {
  font-weight: 700;
  color: var(--ink);
}
.audit-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}
.audit-body {
  padding: 0 16px 16px;
}
.audit-change-table {
  min-width: 100%;
}
.filter-actions {
  display: flex;
  align-items: end;
}
.breadcrumbs .current {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid #d7e1ee;
  background: #f5f8fc;
  color: #0a2247;
  font-weight: 700;
}
.muted { color: var(--muted); }
.badge { border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; }
.badge.draft { background: #e2e8f0; color: #1f2937; }
.badge.proto { background: #dbeafe; color: #1e3a8a; }
.badge.salesman_sample { background: #e0e7ff; color: #312e81; }
.badge.pp_sample { background: #ede9fe; color: #4c1d95; }
.badge.production { background: #fef3c7; color: #92400e; }
.badge.active { background: #dcfce7; color: #065f46; }
.badge.archived { background: #fee2e2; color: #991b1b; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.small { font-size: 12px; }
.product-top-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(300px, 1fr);
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}
.product-side-stack {
  display: grid;
  gap: 16px;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.hero-actions .ghost,
.card-header-row .ghost {
  border-radius: var(--control-radius);
}
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.qr-card .qr-row { display: flex; gap: 14px; align-items: flex-start; }
.qr-card .qr-text { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.qr-card .qr-preview { width: 104px; height: 104px; flex: 0 0 auto; }
.qr-hero {
  width: 180px;
  height: 180px;
  border-radius: 12px;
  border: 1px solid #99e6dc;
  background: #fff;
}
.spec-card {
  border: 1px solid #e5e7eb;
}
.spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}
.spec-chip {
  border-radius: 12px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}
.spec-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: #64748b;
}
.spec-value {
  margin-top: 6px;
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
}
.attribute-group-block {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}
.attribute-group-block:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.attribute-group-block h4 {
  margin: 0 0 10px;
}
.comment-list,
.notification-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}
.comment-card,
.notification-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fbfcfd;
  padding: 14px 16px;
}
.notification-item.is-unread {
  border-color: #b9bcf7;
  background: var(--primary-soft);
}
.comment-meta,
.notification-item-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}
.comment-body {
  margin-top: 10px;
  white-space: pre-wrap;
}
.comment-edit,
.comment-history {
  margin-top: 12px;
}
.comment-edit summary,
.comment-history summary {
  cursor: pointer;
  color: var(--primary-dark);
  font-weight: 600;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.product-card-link {
  text-decoration: none;
  color: inherit;
}
.product-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
  transition: transform .15s ease, box-shadow .15s ease;
  /* Растягиваем на всю ячейку грида, чтобы карточки в ряду были одной высоты. */
  height: 100%;
  display: flex;
  flex-direction: column;
}
.product-card-link {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.product-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}
.product-cover {
  width: 100%;
  height: 156px;
  object-fit: cover;
  object-position: top center;
  display: block;
  background: #f1f5f9;
}
.product-card-body {
  padding: 10px 12px 12px;
}
.product-line-1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
/* Длинные статусы («Предпроизводственный образец») ломали артикул на две
   строки — фиксируем артикул, а бейдж ужимаем. */
.product-line-1 strong {
  white-space: nowrap;
  flex: 0 0 auto;
}
.product-line-1 .badge {
  min-width: 0;
  text-align: right;
  line-height: 1.25;
}
.product-name {
  margin-top: 6px;
  font-weight: 600;
  line-height: 1.3;
}
.product-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.label-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  user-select: none;
}
.tooltip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  transform: none;
  width: max-content;
  max-width: 280px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: #f8fafc;
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
  z-index: 20;
}
.tooltip:hover::after {
  opacity: 1;
}

.dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.dashboard-kpi {
  display: grid;
  gap: 6px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.dashboard-kpi:has(.dashboard-kpi-link):hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}
.dashboard-kpi-link {
  display: grid;
  gap: 6px;
  text-decoration: none;
  color: inherit;
}
.dashboard-kpi-label {
  color: var(--muted);
  font-size: 13px;
}
.dashboard-kpi-value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
}
.dashboard-kpi-value.is-alert { color: var(--danger); }
.dashboard-kpi-value.is-warn { color: var(--warn); }

.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
dialog.modal {
  border: 0;
  border-radius: 16px;
  padding: 0;
  width: min(680px, 92vw);
  max-height: 88vh;
  overflow: visible;
}
dialog.modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}
.modal-body {
  padding: 0;
  max-height: 88vh;
  overflow-y: auto;
  overflow-x: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
/* «Закрыть» — вспомогательное действие, оно не должно перевешивать
   основную кнопку формы. */
.modal-header form[method="dialog"] button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 500;
}
.modal-header form[method="dialog"] button:hover {
  background: #f1f5f9;
  color: var(--text);
  box-shadow: none;
  transform: none;
}
.user-edit-sections {
  display: grid;
  gap: 12px;
}
.user-profile-grid {
  grid-template-columns: repeat(3, minmax(220px, 1fr));
}
.user-profile-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-start;
}
.user-role-form {
  border-top: 1px solid #e2e8f0;
  padding-top: 10px;
}
.user-role-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.user-role-actions,
.user-danger-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.user-danger-actions {
  border-top: 1px solid #e2e8f0;
  padding-top: 10px;
}
.user-danger-actions form {
  margin: 0;
}
.login-card {
  max-width: 420px;
  margin: 50px auto;
}
.login-brand {
  font-size: 20px;
  margin: 0 0 18px;
}
.login-card h1 {
  font-size: 22px;
}
.qr-preview {
  width: 170px;
  height: 170px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
@media (max-width: 920px) {
  nav .container {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 10px;
  }
  nav .nav-left {
    flex-wrap: wrap;
  }
  /* nowrap уводил правую группу («Выход») за край экрана, а overflow-x:hidden
     на body её обрезал — на телефоне выйти из системы было невозможно. */
  nav .nav-right {
    margin-left: 0;
    flex-wrap: wrap;
    white-space: normal;
  }
  .nav-dropdown-menu {
    position: static;
    margin-top: 8px;
    width: 100%;
  }
  .product-top-layout {
    grid-template-columns: 1fr;
  }
  .products-filter-row {
    grid-template-columns: 1fr;
  }
  .hero-header {
    grid-template-columns: 1fr;
  }
  .hero-meta {
    order: 2;
  }
  .user-profile-grid {
    grid-template-columns: 1fr;
  }
  .user-role-grid {
    grid-template-columns: 1fr;
  }
  /* Подсказка шириной 280px не влезает рядом с иконкой на узком экране. */
  .tooltip::after {
    max-width: 220px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  /* Подъём карточек и кнопок при наведении — тоже движение. */
  .btn:hover, button:hover, .product-card:hover,
  .actions a:hover, .modal-actions a:hover,
  .hero-actions a:hover, .card-header-row a:hover {
    transform: none;
  }
}

/* ---------- Карточка изделия ---------- */
.product-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
  margin: 4px 0 16px;
}
.product-sku {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.product-title {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
  letter-spacing: -.02em;
}
.product-head .hero-actions { margin-top: 0; }
h2.section-title {
  margin: 0 0 2px;
  font-size: 17px;
  line-height: 1.3;
  letter-spacing: -.01em;
}
/* Пустая метка-распорка у кнопки в форме загрузки не должна читаться вслух. */
.overview-card label:empty { display: none; }

/* Этапы: непрерывная линия, по которой идёт изделие */
.lifecycle-card { margin-bottom: 16px; }
.stepper {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 0;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}
.step {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
  text-align: center;
}
/* Линия рисуется между соседними точками, поэтому не у первого шага. */
.step::before {
  content: "";
  position: absolute;
  top: 7px;
  right: 50%;
  left: -50%;
  height: 2px;
  background: var(--border);
}
.step:first-child::before { display: none; }
.step.is-done::before,
.step.is-current::before { background: var(--teal); }
.step-dot {
  position: relative;
  z-index: 1;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--card);
}
.step.is-done .step-dot { border-color: var(--teal); background: var(--teal); }
.step.is-current .step-dot {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.step-label { font-size: 13px; line-height: 1.3; color: var(--muted); }
.step.is-done .step-label { color: var(--text); }
.step.is-current .step-label { color: var(--primary-dark); font-weight: 700; }
.stepper-note { margin: 18px 0 0; }

/* Разделы карточки */
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.tab {
  flex: 0 0 auto;
  padding: 0 14px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active {
  color: var(--primary-dark);
  border-bottom-color: var(--primary);
}
/* Панели скрываются только когда вкладки ожили: без скриптов виден весь текст. */
.js-tabs .tab-panel[hidden] { display: none; }
.tab-panel:focus { outline: none; }

/* Основные данные: обложка и список полей */
.overview-card .card-header-row { margin-bottom: 14px; }
.overview-layout {
  display: grid;
  grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.overview-cover {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  display: block;
}
.data-list { margin: 0; display: grid; gap: 2px; }
.data-row {
  display: grid;
  grid-template-columns: minmax(120px, 200px) minmax(0, 1fr);
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.data-row:last-child { border-bottom: 0; }
.data-list dt {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.data-list dd { margin: 0; overflow-wrap: anywhere; }
/* Должность под именем: над плашкой уже написана проектная роль,
   и та же строка в скобках читалась как противоречие. */
.spec-sub {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

/* ---------- Состав коллекции ---------- */
.collection-total {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}
.collection-composition { margin-bottom: 16px; }

/* ---------- Загруженность поставщика ---------- */
.load-count {
  font-size: 14px;
  font-weight: 700;
  color: var(--teal-ink);
  white-space: nowrap;
}
.load-count.is-over { color: var(--warn); }
.load-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
  margin: 12px 0 10px;
}
.load-bar-fill {
  display: block;
  height: 100%;
  background: var(--teal);
}
.load-bar-fill.is-over { background: var(--warn); }

/* Кто ведёт модель — в карточке списка изделий */
.product-owner {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

/* ---------- Компактные кнопки-иконки для повторяющихся действий строки ---------- */
/* Текстовые «Редактировать/Деактивировать/Удалить» в каждой строке таблицы
   атрибутов давали три полноразмерные (44px) кнопки на строку — стена кнопок
   тяжелее самих данных. Иконка 32px + title/aria-label несёт то же действие
   компактнее; фон/обводка держат смысл (индиго/янтарь/красный), без заливки
   на каждую строку. button.icon-btn — специфичность тега+класса, чтобы
   перебить .modal-actions button/.actions button из общих правил. */
.row-actions { gap: 6px; align-items: center; }
button.icon-btn {
  padding: 0;
  max-width: none;
  flex-shrink: 0;
  border-radius: var(--control-radius);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  width: 32px;
  height: 32px;
}
/* form.inline button (0,1,2) задаёт width:auto и перебивает голый
   button.icon-btn (0,1,1) — без этой строки одиночная .icon-btn-кнопка внутри
   <form class="inline"> (без обёртки .row-actions) схлопывалась по ширине до
   иконки, а высота оставалась от базового button (44px) — получался высокий
   узкий прямоугольник вместо квадрата 32×32. */
form.inline button.icon-btn { width: 32px; }
.row-actions .icon-btn { width: 32px; height: 32px; }
button.icon-btn svg { width: 16px; height: 16px; }
button.icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
}
/* Единственный цветной значок — удаление. Остальные одинаково серые. */



button.icon-btn.tone-danger { color: var(--danger); border-color: #eab8b8; background: #fff; }
button.icon-btn.tone-danger:hover { background: #fef2f2; }
/* Для положительных/включающих действий (активировать, разблокировать) —
   тот же бирюзовый акцент, что и у вторичных кнопок по сайту. */
button.icon-btn.tone-teal { color: var(--teal-ink); border-color: var(--teal); background: var(--teal-soft); }
button.icon-btn.tone-teal:hover { background: #d3f3ee; }

/* ---------- Этапы жизненного цикла в настройках ---------- */
.stage-order-cell { width: 96px; }
.stage-order-cell input { width: 100%; }
.stage-code {
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
}

/* ---------- Диапазон "от/до" в полном поиске по атрибутам ---------- */
.filter-range { display: flex; gap: 6px; }
.filter-range input { min-width: 0; }

/* ---------- Галерея изображений и лайтбокс в файлах карточки ---------- */
.file-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.file-gallery-item { position: relative; }
.file-gallery-item form { display: none; }
.file-gallery-link {
  display: block;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.file-gallery-link img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-gallery-caption {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
.file-lightbox-body {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.file-lightbox-body img { max-width: 100%; max-height: 60vh; object-fit: contain; border-radius: 8px; }
/* Вне .row-actions у .icon-btn нет заданной ширины/высоты (там их даёт
   .row-actions .icon-btn) — без явного размера кнопка растягивалась под
   высоту строки (var(--control-height)) при почти нулевой видимой стрелке. */
.file-lightbox-nav.icon-btn { width: 40px; height: 40px; flex-shrink: 0; }

/* ---------- таблица измерений ---------- */
/* Колонки задаются явно: при авторазметке пустая ячейка допуска схлопывалась,
   и шапка переставала совпадать со своей колонкой. */
.measurement-grid { table-layout: fixed; min-width: 0; width: auto; }
.measurement-grid th,
.measurement-grid td { padding: 6px 8px; vertical-align: middle; }
.measurement-grid .m-name { width: 190px; }
.measurement-grid th.m-size { width: 74px; white-space: nowrap; text-align: center; }
.measurement-grid td:has(.m-cell) { text-align: center; }
.measurement-grid .m-cell { width: 62px; text-align: center; padding: 6px 4px; }
.measurement-grid .m-unit { width: 52px; padding: 6px 4px; }
.measurement-grid .row-actions { justify-content: flex-end; }
/* Размер и кнопка удаления — в столбик: вплотную к числу крестик читался
   как знак умножения между соседними размерами («42 × 44 × 46»). */
.measurement-grid th.m-size {
  text-align: center;
  padding-top: 4px;
  padding-bottom: 4px;
}
.measurement-grid .m-size-label { display: block; }
.measurement-grid .m-size-del {
  width: 20px; height: 20px; margin: 2px auto 0; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 6px; background: none;
  color: #c7cedb; cursor: pointer;
}
.measurement-grid .m-size-del svg { width: 12px; height: 12px; }
.measurement-grid .m-size-del:hover { background: #fee2e2; color: var(--danger); }

/* ---------- модульные карточки блоков ----------
   Блоки PLM-контура подаются самостоятельными карточками в сетке, а не
   стопкой таблиц через разделители: состояние блока (сколько строк, есть
   ли просрочка) видно до того, как пользователь в него вошёл. */
.block-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.block-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.block-card.is-wide { grid-column: 1 / -1; }
.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.block-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.block-title svg { width: 20px; height: 20px; flex: 0 0 auto; color: var(--primary); }
.block-note { font-size: 12px; color: var(--muted); margin-top: -4px; }
.block-count {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg);
  color: var(--muted);
  white-space: nowrap;
}
.block-count.tone-sum { background: var(--teal-soft); color: var(--teal-ink); }
.block-count.tone-warn { background: #fef3c7; color: var(--warn); }

.block-list { display: flex; flex-direction: column; }
.block-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid #f1f3f7;
  font-size: 14px;
}
.block-row:last-child { border-bottom: 0; }
.block-row .grow { flex-grow: 1; min-width: 0; }
.block-row .sub { font-size: 12px; color: var(--muted); }
.block-row .val { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* Образец материала: цвет и фактура узнаются быстрее названия. */
.swatch {
  display: inline-block; vertical-align: middle;
  width: 34px; height: 34px; border-radius: 8px; flex: 0 0 auto;
  border: 1px solid var(--border); background: var(--bg);
  object-fit: cover;
}
.dot { display: inline-block; vertical-align: middle; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--border); }
.dot.is-done { background: #15803d; }
.dot.is-late { background: var(--warn); }

/* Добавление — пунктирная зона в конце карточки, а не кнопка в шапке:
   так действие не конкурирует с названием блока. */
.block-add {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 12px; width: 100%;
  border: 1px dashed #c7cedb; border-radius: var(--control-radius);
  background: none; color: var(--muted);
  font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.block-add:hover { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-soft); }
.block-empty { font-size: 13px; color: var(--muted); padding: 2px 0 4px; }
/* Оттенок образца — по категории материала (реальное поле), а не произвольный. */
.swatch.cat-shell { background: #d8cfc0; }
.swatch.cat-lining { background: #c8d3e0; }
.swatch.cat-insulation { background: #e3dccf; }
.swatch.cat-trims { background: #b9c0cc; }
.swatch.cat-packaging { background: #ddd0b8; }
.swatch.cat-other { background: #e8ebef; }

/* ---------- всплывающие окна ----------
   Шапка и подвал занимают всю ширину окна, поля живут между ними.
   Подвал собирается из последней ячейки формы (там лежит кнопка отправки),
   поэтому разметка всех двух десятков окон остаётся прежней. */
.modal-header {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 16px 20px;
  background: var(--card);
  border-bottom: 1px solid #f1f3f7;
  border-radius: 16px 16px 0 0;
}
.modal-header h3 { font-size: 17px; letter-spacing: -.01em; }
.modal-body > form,
.modal-body > p { padding: 16px 20px; margin: 0; }
.modal-body > p + form { padding-top: 0; }

.modal-body form.grid > div:last-child:has(> button[type="submit"]) {
  grid-column: 1 / -1;
  margin: 4px -20px -16px;
  padding: 14px 20px;
  background: var(--bg);
  border-top: 1px solid #f1f3f7;
  border-radius: 0 0 16px 16px;
  display: flex;
  justify-content: flex-end;
}
.modal-body form.grid > div:last-child:has(> button[type="submit"]) button {
  width: auto;
  min-width: 160px;
}

}

/* ---------- лента этапов ----------
   Прямая установка этапа — исключение, а не основной путь: она не должна
   спорить по весу с кнопкой «Следующий этап». Базовое правило даёт полям
   width:100%, из-за чего select и кнопка разъезжались на две строки. */
.lifecycle-card .actions { flex-wrap: wrap; gap: 8px; align-items: center; }
.stage-set { display: flex; align-items: center; gap: 6px; }
.stage-set select {
  width: auto;
  min-width: 190px;
  height: var(--control-height);
  color: var(--muted);
  font-size: 14px;
}
.stage-set button { width: auto; white-space: nowrap; }
.lifecycle-card .stage-days { margin-top: 2px; }
@media (max-width: 760px) {
  .stage-set { width: 100%; }
  .stage-set select { flex-grow: 1; min-width: 0; }
}

/* ---------- общая подача таблиц ----------
   Все таблицы в карточках выглядят одинаково: числа вправо, вторая строка
   ячейки приглушена, действия иконками у правого края. */
table .sub { font-size: 12px; color: var(--muted); }
table td.num, table th.num { text-align: right; white-space: nowrap; }
table td.col-actions, table th.col-actions { width: 1%; white-space: nowrap; }
table td.col-actions .row-actions { justify-content: flex-end; flex-wrap: nowrap; }
table td.col-swatch, table th.col-swatch { width: 1%; padding-right: 0; }
table td.col-swatch .swatch { width: 28px; height: 28px; }

/* ---------- два вида кнопок ----------
   Со словами: акцентная (primary) либо дополнительная серая.
   Со значками: одинаковые серые квадраты, красный только у удаления. */
.ghost, .btn.ghost, a.btn:not(.btn-primary) {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.ghost:hover, .btn.ghost:hover { background: #f1f5f9; }

/* Значок-ссылка выглядит так же, как значок-кнопка. */
a.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: var(--control-radius);
  background: #fff; color: var(--muted); text-decoration: none;
}
a.icon-btn svg { width: 16px; height: 16px; }
a.icon-btn:hover { background: #f1f5f9; transform: translateY(-1px); box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12); }
button.icon-btn:hover { background: #f1f5f9; }
button.icon-btn.tone-danger:hover, a.icon-btn.tone-danger:hover { background: #fef2f2; }
a.icon-btn.tone-danger { color: var(--danger); border-color: #eab8b8; }

/* Добавление в карточке — та же дополнительная кнопка, только во всю ширину. */
.block-add {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
}
.block-add:hover { background: #f1f5f9; border-color: var(--border); color: var(--text); }

/* Удаление размера — обычный значок, чтобы не заводить третий размер кнопок. */
.measurement-grid .m-size-del {
  width: 32px; height: 32px; margin: 4px auto 0; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid #eab8b8; border-radius: var(--control-radius);
  background: #fff; color: var(--danger); cursor: pointer;
}
.measurement-grid .m-size-del svg { width: 16px; height: 16px; }
.measurement-grid .m-size-del:hover { background: #fef2f2; }

/* ---------- вертикальный ритм ----------
   Между соседними блоками страницы — ровно 16px. Отдельно стоящая карточка
   несёт отступ сама; внутри сетки отступ задаёт сетка, и у детей его нет —
   иначе карточка в ряду становится выше соседней на эти 16px. */
.block-card { margin-bottom: 16px; }
.block-grid > .block-card,
.block-grid > .card,
.product-top-layout > .block-card,
.product-top-layout > .card { margin-bottom: 0; }

/* Пять красных значков подряд в шапке забивали таблицу. На устройствах
   с мышью значок проявляется при наведении на колонку или фокусе с
   клавиатуры; на сенсорных экранах наведения нет — там он виден всегда. */
@media (hover: hover) {
  .measurement-grid th.m-size .m-size-del { opacity: 0; transition: opacity .15s ease; }
  .measurement-grid th.m-size:hover .m-size-del,
  .measurement-grid .m-size-del:focus-visible { opacity: 1; }
}
/* Значки действий в строке не переносятся нигде: перенос ставил их
   столбиком и раздувал высоту каждой строки таблицы. */
.row-actions { flex-wrap: nowrap; }
