/* ==========================================================================
   СнабКонтроль — слой оформления по макету Google Stitch «Smart Supply AI».
   Подключается ПОСЛЕ app.css и переводит существующую вёрстку в макет:
   плоские карточки со скруглением 2px, тонкие линии, синий primary #003EC7,
   светлое боковое меню, верхняя панель 64px с поиском, моно-шрифт для цифр.
   Значения перенесены из tailwind.config макета (px/hex), без внешних CDN.
   ========================================================================== */

/* ---------- база ---------- */
body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  background: var(--bg);
}

.app-shell {
  grid-template-columns: 280px minmax(0, 1fr);
  background: var(--bg);
}

/* ---------- боковое меню (280px, светлое в светлой теме) ---------- */
/* !important — перебиваем правило прошлой версии оформления в app.css */
.sidebar,
[data-theme="dark"] .sidebar {
  padding: 24px 0;
  color: var(--sidebar-text);
  background: var(--sidebar-bg) !important;
  border-inline-end: 1px solid var(--sidebar-line);
}

.sidebar .brand {
  padding: 0 32px;
  margin-bottom: 24px;
}

.sidebar .wordmark-name { color: var(--sidebar-text-strong); }
.sidebar .wordmark-suffix { color: var(--sidebar-muted); }

/* Кнопка-действие меню: «+ Новая поставка» */
.side-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 32px);
  min-height: 40px;
  margin: 0 16px 16px;
  padding: 10px 16px;
  font-family: var(--font-ui);
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

.side-cta:hover { background: var(--accent-hover); }

/* Заголовок группы пунктов (в макете — метка-капс) */
.nav-group {
  padding: 16px 32px 6px;
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
}

.nav { gap: 4px; padding: 0 16px; }

.nav button,
.nav-main,
.nav-bottom,
.theme-toggle,
.logout {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 400;
  color: var(--sidebar-text);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
}

.nav button:hover,
.nav-main:hover,
.nav-bottom:hover,
.theme-toggle:hover,
.logout:hover {
  color: var(--sidebar-text-strong);
  background: var(--sidebar-hover);
}

/* Активный пункт: синий текст, жирный, полоса СПРАВА 2px (как в макете) */
.nav button.active,
.nav .nav-main.active {
  color: var(--accent);
  font-weight: 700;
  background: transparent;
  border-inline-start: 0;
  border-inline-end: 2px solid var(--accent);
  padding-inline-start: 16px;
  border-start-start-radius: var(--radius);
  border-start-end-radius: 0;
  border-end-end-radius: 0;
  border-end-start-radius: var(--radius);
}

.nav button.active .msym { font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24; }

.nav .msym,
.nav-bottom .msym { font-size: 20px; color: inherit; }

.sidebar-bottom {
  padding: 0 16px;
  margin-top: auto;
  border-top: 1px solid var(--sidebar-line);
  padding-top: 16px;
}

/* Раскрывающийся блок «Ещё» — в стиле пунктов меню */
.nav-more summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  font-size: 14px;
  color: var(--sidebar-text);
  border-radius: var(--radius);
  cursor: pointer;
}

.nav-more summary:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); }
.nav-more button { padding-inline-start: 40px; }

/* ---------- верхняя панель 64px ---------- */
.topbar {
  height: 64px;
  min-height: 64px;
  padding: 0 32px;
  gap: 16px;
  color: var(--text);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar .wordmark-name { color: var(--text); }
.topbar .wordmark-suffix { color: var(--muted); }
.topbar .page-title {
  margin: 0;
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text);
  white-space: nowrap;
}

/* Разделы в верхней панели (ПК): иконка + подпись, активный — синяя плашка.
   Заголовок раздела при этом лишний — активная вкладка уже подписана. */
@media (min-width: 821px) {
  .topbar .page-title { display: none; }
}

.top-nav { display: flex; align-items: center; gap: 4px; margin-inline-start: 8px; flex: none; }

.top-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 8px 12px;
  white-space: nowrap;
  flex: none;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  color: var(--text-2);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

.top-nav-btn .msym { font-size: 20px; }
.top-nav-btn:hover { color: var(--text); background: var(--surface-3); }

.top-nav-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.top-nav-btn.active .msym { font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24; }

/* Поиск-лупа: поле органично раскрывается влево от кнопки */
.top-find { display: flex; align-items: center; }

.top-find input {
  width: 0;
  min-height: 36px;
  padding: 0;
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  opacity: 0;
  transition: width .22s ease, opacity .18s ease, margin .22s ease, padding .22s ease;
}

.top-find.open input {
  width: min(300px, 34vw);
  padding: 8px 14px;
  margin-right: 6px;
  border-color: var(--line);
  opacity: 1;
}

.top-find input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.top-find.open .icon-btn { color: var(--accent) !important; }

.topbar .spacer { flex: 1 1 auto; }

.topbar .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--text-2);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
}

/* !important — перебиваем «жёлтые круглые кнопки» прошлой версии оформления */
.topbar .icon-btn,
[data-theme="light"] .topbar .icon-btn,
[data-theme="dark"] .topbar .icon-btn {
  width: 36px !important;
  min-width: 36px !important;
  height: 36px !important;
  padding: 0 !important;
  color: var(--text-2) !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: var(--radius) !important;
}

.topbar .icon-btn:hover,
[data-theme="light"] .topbar .icon-btn:hover,
[data-theme="dark"] .topbar .icon-btn:hover {
  color: var(--text) !important;
  background: var(--surface-3) !important;
}

.topbar .icon-btn .msym { font-size: 22px; color: inherit; }
.topbar .icon-btn .theme-icon { display: none; }

/* Верхняя строка плитки: метка слева, иконка справа (как в макете) */
.stat-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.stat-top .msym { font-size: 22px; color: var(--line); }
.stat-card.danger .stat-top .msym { color: var(--danger); }

.notif-badge {
  min-width: 8px;
  height: 8px;
  padding: 0;
  font-size: 0;
  background: var(--danger);
  border: 0;
  border-radius: var(--radius-pill);
}

/* ---------- рабочая область ---------- */
.main {
  max-width: none;
  padding: 32px;
  background: var(--bg);
}

.topline { margin-bottom: 24px; }

.topline h1 {
  margin: 0 0 4px;
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.topline p {
  font-size: 14px;
  line-height: 20px;
  color: var(--text-2);
}

/* ---------- карточки ---------- */
.panel,
.card,
.form-panel,
.notice-card,
.instruction-card,
.object-card,
.supplier-card,
.user-card,
.digest-panel,
.readiness-panel,
.correction-panel,
.receive-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: none;
}

.panel { padding: 16px; }

.panel h2,
.card-head h2 {
  margin: 0 0 16px;
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text);
}

.grid { gap: 16px; }

/* ---------- плитки показателей (KPI макета) ---------- */
.stats-grid { gap: 16px; }

.stat-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  text-align: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: none;
}

.stat-card b {
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-2);
}

.stat-card strong {
  display: block;
  font-size: 36px;
  line-height: 44px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.stat-card span {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-2);
}

.stat-card:hover { background: var(--surface-3); }

/* «Тревожная» плитка — как ACTIVE ISSUES в макете */
.stat-card.danger {
  background: var(--danger-container);
  border-color: var(--danger);
}

.stat-card.danger b,
.stat-card.danger span { color: var(--on-danger-container); }
.stat-card.danger strong { color: var(--danger); }

.stat-card.warning {
  background: var(--warning-bg);
  border-color: var(--line);
}

.stat-card.warning b,
.stat-card.warning span { color: var(--on-secondary-container); }
.stat-card.warning strong { color: var(--text); }

/* ---------- таблицы ---------- */
.table-wrap,
.attention-scroll {
  background: transparent;
  border: 0;
  box-shadow: none;
}

table { font-size: 12px; line-height: 16px; }

thead {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

th {
  padding: 8px 16px;
  font-size: 11px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-2);
  border-bottom: 1px solid var(--line);
}

td {
  padding: 8px 16px;
  font-size: 12px;
  line-height: 16px;
  color: var(--text-2);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent);
  vertical-align: middle;
}

tbody tr:hover td { background: var(--surface-lowest); }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 30%, transparent); }
tbody tr:nth-child(even):hover td { background: var(--surface-lowest); }

/* Номера, коды и количества — моно-шрифтом, как в макете */
.ref-open,
.attention-num,
.copy-ref,
.qr-label,
.shipment-title,
td .mono,
.mono {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 16px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text);
}

/* ---------- статусные чипы (варианты макета) ---------- */
.status,
.delivery-chip,
.badge-new {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 16px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  border-radius: var(--radius);
  border: 1px solid transparent;
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--radius-pill);
  background: currentColor;
  flex: none;
}

/* «Ожидает» — нейтральный (Pending) */
.status.created,
.status.neutral {
  color: var(--text-2);
  background: var(--surface-variant);
  border-color: var(--line);
}

/* «В пути» — третичный (In Transit) */
.status.sent,
.status.in_transit {
  color: var(--info);
  background: var(--info-bg);
  border-color: var(--tertiary-soft-line);
}

/* «Принято» — основной синий (Delivered) */
.status.received {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-soft-line);
}

/* «Частично» — вторичный контейнер */
.status.partially_received {
  color: var(--on-secondary-container);
  background: var(--warning-bg);
  border-color: var(--line);
}

/* «Проблема» — ошибка */
.status.problem,
.status.damaged,
.status.missing {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: color-mix(in srgb, var(--danger) 20%, transparent);
}

/* «Просрочено» — сильная ошибка (Delayed) */
.status.overdue {
  color: var(--on-danger-container);
  background: var(--danger-container);
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 10px 16px;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.btn:hover { background: var(--surface-3); }

.btn.signal,
.btn-hero {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: none;
}

.btn.signal:hover,
.btn-hero:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

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

/* Дизайн-система: разрушительные действия — тонкие, красный текст и рамка */
.btn.danger {
  color: var(--danger);
  background: transparent;
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
  box-shadow: none;
}

.btn.danger:hover {
  color: var(--on-danger-container);
  background: var(--danger-bg);
  border-color: var(--danger);
}

.btn-sm { min-height: 32px; padding: 6px 12px; font-size: 12px; line-height: 16px; }

.btn .msym { font-size: 16px; }

/* Ссылка-действие «Смотреть все» (VIEW ALL в макете) */
.link-caps {
  padding: 0;
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent);
  background: none;
  border: 0;
  cursor: pointer;
}

.link-caps:hover { text-decoration: underline; }

/* ---------- поля ввода ---------- */
.field span,
.field label,
.field > span {
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-2);
}

/* Часть полей в разметке без атрибута type — селектор по типам их не ловил,
   из-за чего в одной форме соседние поля отличались шрифтом и скруглением. */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
select,
textarea {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  background: var(--surface-lowest);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
select {
  min-height: 40px;
  padding: 10px 12px;
}

textarea { padding: 10px 12px; }

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}

.filters {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

/* Кнопка отправки в формах справочников — своей строкой под полями,
   а не ячейкой сетки между ними (лежала вперемешку с полями). */
.form-grid > .btn:not(.full):not(.btn-hero) {
  grid-column: 1 / -1;
  justify-self: start;
  min-width: 200px;
  margin-top: 4px;
}

/* ---------- лента событий (Activity Stream макета) ---------- */
.timeline { display: grid; gap: 0; }

.event {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent);
  background: transparent;
}

.event:last-child { border-bottom: 0; }

.event-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-line);
  border-radius: var(--radius-pill);
}

.event-ic .msym { font-size: 18px; }
.event-ic.is-danger { color: var(--danger); background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 20%, transparent); }
.event-ic.is-neutral { color: var(--text-2); background: var(--surface-variant); border-color: var(--line); }
.event-ic.is-info { color: var(--info); background: var(--info-bg); border-color: var(--tertiary-soft-line); }

.event-body { min-width: 0; }
.event-body b { font-weight: 600; color: var(--text); }
.event-body p { margin: 0; font-size: 12px; line-height: 16px; color: var(--text-2); }
.event-time { margin-top: 2px; font-size: 12px; line-height: 16px; color: var(--muted); }

/* ---------- шкала статусов поставки (Tracking Timeline макета) ---------- */
.track-line { position: relative; display: grid; gap: 0; padding-inline-start: 28px; }

.track-line::before {
  content: "";
  position: absolute;
  inset-inline-start: 5px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--line);
}

.track-step { position: relative; padding: 12px 0; }

.track-step::before {
  content: "";
  position: absolute;
  inset-inline-start: -28px;
  top: 16px;
  width: 11px;
  height: 11px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius-pill);
}

.track-step.is-done::before { background: var(--accent); border-color: var(--accent); }
.track-step.is-current::before { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.track-step.is-current b { color: var(--accent); }
.track-step.is-future { opacity: .55; }
.track-step b { display: block; font-size: 14px; line-height: 20px; font-weight: 600; color: var(--text); }
.track-step p { margin: 2px 0 0; font-size: 12px; line-height: 16px; color: var(--text-2); }
.track-step time { font-family: var(--font-mono); font-size: 13px; line-height: 16px; font-weight: 500; color: var(--text-2); }

/* ---------- прочее ---------- */
.empty {
  padding: 24px 16px;
  font-size: 14px;
  color: var(--text-2);
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}

.muted { color: var(--text-2); }

.toast-item,
.notice-card {
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}

.mini-bar { background: var(--surface-variant); border-radius: var(--radius); }
.mini-bar-fill { background: var(--accent); border-radius: var(--radius); }

.qr-grid img,
.receive-card img { border-radius: var(--radius); }

/* Переключатель сервисов из старой версии не используется */
.topbar .tabs,
.proj-dd,
.proj-switch { display: none !important; }

/* ---------- экран входа по макету (двухпанельная карточка) ---------- */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  width: 100%;
  max-width: 960px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.login-art {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  padding: 32px;
  background: var(--surface-2);
  border-inline-end: 1px solid var(--line);
}

.login-art .wordmark { position: relative; z-index: 1; }

/* Фоновая сетка-«карта» — как в макете, средствами CSS */
.login-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, color-mix(in srgb, var(--line) 45%, transparent) 1px, transparent 1px),
    linear-gradient(to bottom, color-mix(in srgb, var(--line) 45%, transparent) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 72%);
  -webkit-mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 72%);
  pointer-events: none;
}

.login-status {
  position: relative;
  z-index: 1;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.login-status h2 {
  margin: 0 0 8px;
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-2);
}

.login-status strong {
  font-family: var(--font-mono);
  font-size: 36px;
  line-height: 44px;
  font-weight: 500;
  color: var(--accent);
}

.login-status span { font-size: 12px; line-height: 16px; color: var(--text-2); }

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: 32px;
  background: var(--surface);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.login-panel h1 {
  margin: 0;
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.login-panel p {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  color: var(--text-2);
}

.login-foot {
  margin-top: 8px;
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  text-align: center;
  color: var(--muted);
}

.login-art .yard-map,
.login-art .route-rails,
.login-art .status-track { display: none; }

/* ==========================================================================
   ТЕЛЕФОН — по мобильным экранам макета (03/06/09):
   нижняя панель разделов, кнопка «+», плитки листаются вбок,
   реестры — карточками, всё под палец.
   ========================================================================== */

/* Нижняя панель разделов (на десктопе не нужна) */
.tabbar { display: none; }
.topbar .topbar-brand { display: none; }
.fab { display: none; }

@media (max-width: 820px) {
  /* Меню выезжает поверх содержимого — колонка под него в сетке не нужна.
     Из-за неё рабочая область получала 280px вместо всей ширины экрана. */
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
  }

  /* --- верхняя панель: бургер, словомарк, колокольчик, тема --- */
  .topbar {
    padding: env(safe-area-inset-top, 0px) 12px 0;
    height: calc(64px + env(safe-area-inset-top, 0px));
    min-height: calc(64px + env(safe-area-inset-top, 0px));
    gap: 4px;
  }

  .topbar .page-title { display: none; }

  .topbar .topbar-brand {
    display: inline-grid;
    min-width: 0;
    margin-inline-start: 2px;
  }

  .topbar-brand .wordmark-name { font-size: 17px; line-height: 24px; }

  /* Полоски бургера были кремовыми (под старую тёмную панель) — на светлой не видны.
     В макете кнопка меню синяя (primary). */
  .topbar .menu-toggle span { background: var(--accent) !important; }
  .topbar .menu-toggle { border-radius: var(--radius); }

  /* Кнопка «скопировать номер» была 14x16px внутри кликабельной строки */
  .copy-ref {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    margin: -12px 0 -12px 2px;
    padding: 0;
    font-size: 16px;
  }

  .top-nav { display: none; }
  .top-find { display: none; }

  .topbar .icon-btn[data-nav="journal"],
  .topbar .icon-btn[data-nav="instructions"] { display: none; }

  /* Под палец: 44px */
  .topbar .icon-btn,
  [data-theme="light"] .topbar .icon-btn,
  [data-theme="dark"] .topbar .icon-btn {
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
  }

  .topbar .icon-btn .theme-toggle-label { display: none !important; }

  /* --- рабочая область: место под закреплённые панели сверху и снизу --- */
  .main {
    padding: calc(64px + env(safe-area-inset-top, 0px) + 16px) 16px
             calc(64px + env(safe-area-inset-bottom, 0px) + 16px);
  }

  .topline { margin-bottom: 16px; }
  .topline h1 { font-size: 22px; line-height: 28px; }

  /* --- выдвижное меню --- */
  /* Меню не прокручивалось: 16 пунктов не влезают в экран телефона,
     нижние («Настройки», «Инструкция») были физически недоступны. */
  .sidebar,
  [data-theme="dark"] .sidebar {
    width: 288px;
    max-width: 86vw;
    height: 100dvh;
    min-height: 0;
    padding-top: calc(64px + env(safe-area-inset-top, 0px) + 12px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar .nav,
  .sidebar .sidebar-bottom { flex: 0 0 auto; }

  /* Фон под открытым меню не должен прокручиваться (html с overflow-x: clip
     забирает прокрутку на себя, и body.menu-lock один не срабатывает) */
  html:has(body.menu-lock) { overflow: hidden; }
  .app-shell.menu-open .menu-backdrop { touch-action: none; overscroll-behavior: contain; }

  .sidebar .brand { display: none; }

  .nav button,
  .nav-main,
  .nav-bottom { min-height: 44px; }

  .side-cta { min-height: 44px; }

  /* --- нижняя панель разделов (как в макете) --- */
  .tabbar {
    position: fixed;
    z-index: 45;
    inset-inline-end: 0;
    bottom: 0;
    inset-inline-start: 0;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    align-items: stretch;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--surface-3);
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, .05);
  }

  .tabbar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    padding: 6px 2px;
    color: var(--text-2);
    background: transparent;
    border: 0;
    cursor: pointer;
  }

  .tabbar-ic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 26px;
    border-radius: var(--radius-pill);
  }

  .tabbar-tx {
    font-size: 11px;
    line-height: 14px;
    font-weight: 600;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Активный раздел: синяя плашка с белой иконкой и синяя подпись */
  .tabbar-btn.active { color: var(--accent); }
  .tabbar-btn.active .tabbar-ic { color: var(--accent-ink); background: var(--accent); }
  .tabbar-btn.active .msym { font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24; }

  /* --- кнопка «+» над нижней панелью --- */
  .fab {
    position: fixed;
    z-index: 46;
    inset-inline-end: 16px;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 16px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    color: var(--accent-ink);
    background: var(--accent);
    border: 0;
    border-radius: var(--radius-xl);
    box-shadow: 0 6px 16px rgba(0, 62, 199, .32);
    cursor: pointer;
  }

  .fab .msym { font-size: 28px; }
  .app-shell.menu-open .fab { display: none; }

  /* --- плитки показателей: лента с прокруткой вбок, как в макете --- */
  .stats-grid {
    display: flex;
    gap: 12px;
    margin: 0 -16px;
    padding: 0 16px 4px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .stats-grid::-webkit-scrollbar { display: none; }

  .stats-grid .stat-card {
    flex: 0 0 200px;
    min-height: 116px;
    gap: 12px;
    scroll-snap-align: start;
  }

  .stat-card strong { font-size: 30px; line-height: 38px; }

  /* --- реестры: карточки вместо таблиц, без внутренней прокрутки ---
     Вложенные области прокрутки на телефоне перехватывали жест пальца. */
  .attention-scroll,
  .table-wrap {
    overflow: visible !important;
    border: 0;
    background: transparent;
  }

  .attention-scroll .attention-table,
  .attention-scroll .report-table,
  .table-wrap .data-table,
  .data-table {
    table-layout: auto !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  .data-table tr {
    margin-bottom: 8px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: none;
  }

  .data-table td {
    grid-template-columns: minmax(104px, 40%) minmax(0, 1fr);
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 45%, transparent);
    background: transparent !important;
  }

  /* Чип статуса в карточке не должен растягиваться на всю ячейку */
  .data-table td > .status,
  .data-table td > .delivery-chip { justify-self: start; }

  .data-table td::before {
    font-size: 11px;
    line-height: 14px;
    font-weight: 700;
    letter-spacing: .02em;
    color: var(--text-2);
    hyphens: auto;
  }

  .data-table .ref-open,
  .data-table .attention-num { white-space: normal; }

  /* --- формы и фильтры --- */
  .panel { padding: 14px; }
  .filters { padding: 14px; }
  .grid.two,
  .dash-grid.grid.two { grid-template-columns: minmax(0, 1fr); }

  /* Safari на iPhone зумит страницу, если шрифт поля меньше 16px.
     Отрицания вместо перечисления типов: у части полей атрибута type нет. */
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
  select,
  textarea,
  .filters .field input,
  .filters .field select {
    font-size: 16px;
    min-height: 44px;
  }

  textarea { min-height: 88px; }

  .btn,
  .ai-chip { min-height: 44px; }

  .btn-sm { min-height: 40px; }

  /* Кнопки в карточке поставки — в столбик во всю ширину, чтобы не выезжали */
  .detail-head,
  .card-actions { display: grid; gap: 8px; }
  .detail-head .btn,
  .card-actions .btn { width: 100%; }

  /* --- экран входа --- */
  .login-screen { min-height: 100dvh; padding: 16px; }
  .login-shell { grid-template-columns: minmax(0, 1fr); max-width: 460px; }
  .login-art { display: none; }
  .login-panel { padding: 24px 20px; }

  /* --- экран ИИ --- */
  .ai-hero { padding: 24px 8px 16px; }
  .ai-chips { flex-direction: column; align-items: stretch; }
  .ai-chip { justify-content: flex-start; }
  .ai-cards { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 420px) {
  .tabbar-tx { font-size: 10px; }
  .stats-grid .stat-card { flex-basis: 170px; }
  .main { padding-inline-start: 12px; padding-inline-end: 12px; }
  /* Лента плиток «до краёв»: вылет должен совпадать с отступом страницы,
     иначе появляется горизонтальная прокрутка всей страницы. */
  .stats-grid { margin: 0 -12px; padding: 0 12px 4px; }
}


/* Текст только для скринридеров */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- экран «ИИ-снабженец» (по макету AI Assistant) ---------- */
.ai-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 24px 32px;
  text-align: center;
}

.ai-hero-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: 8px;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: var(--radius-xl);
}

.ai-hero-ic .msym { font-size: 26px; }

.ai-hero h2 {
  margin: 0;
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.ai-hero p {
  margin: 0;
  max-width: 560px;
  font-size: 14px;
  line-height: 20px;
  color: var(--text-2);
}

.ai-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 12px;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.ai-chip:hover { background: var(--surface-3); }
.ai-chip .msym { font-size: 16px; color: var(--accent); }

.ai-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.ai-card {
  padding: 16px;
  text-align: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.ai-card b {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  color: var(--text);
}

.ai-card b .msym { font-size: 18px; color: var(--accent); }
.ai-card p { margin: 0; font-size: 12px; line-height: 16px; color: var(--text-2); }
.ai-note { margin-top: 24px; }

/* ---------- сворачиваемый блок фильтров ---------- */
.fold { border: 0; }
.fold > .fold-sum { display: none; }

/* Быстрые фильтры: ряд кнопок */
.chips-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chips-label { flex: none; }

@media (max-width: 820px) {
  /* Фильтры спрятаны за кнопкой — как в мобильном макете */
  .fold > .fold-sum {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 20px;
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    list-style: none;
  }

  .fold > .fold-sum::-webkit-details-marker { display: none; }
  .fold > .fold-sum .msym { color: var(--accent); }
  .fold[open] > .fold-sum { margin-bottom: 12px; }

  .fold > .filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 0;
    background: transparent;
    border: 0;
  }

  /* Быстрые фильтры листаются вбок, а не занимают пол-экрана */
  .chips-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 8px -12px 0 !important;
    padding: 0 12px 4px;
    background: transparent;
    border: 0;
  }

  .chips-row::-webkit-scrollbar { display: none; }
  .chips-row .btn { flex: none; }
}

@media (max-width: 820px) {
  /* В свёрнутом виде подпись даёт сама кнопка — свой заголовок и пояснение прячем */
  .fold-create > h2,
  .fold-create > p { display: none; }
  .form-panel { padding: 14px; }
}

/* Основной чип раздела ИИ — ведёт в чат */
.ai-chip--primary {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: none;
  text-decoration: none;
}

.ai-chip--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.ai-chip--primary .msym { color: var(--accent-ink); }

/* ==========================================================================
   ЧАТ ИИ-СНАБЖЕНЦА — по экранам макета Stitch 07 (светлый), 08 (тёмный),
   09 (мобильный). Значения перенесены из макета: пузырь пользователя #003EC7
   со срезанным правым нижним углом, ответ ассистента с плашкой smart_toy и
   срезанным левым нижним углом, поле ввода 768px по центру.
   ========================================================================== */

.chat-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 0;
  /* от нижней кромки верхней панели до низа окна — без «хвоста» снизу */
  height: calc(100vh - 64px);
  height: calc(100dvh - 64px);
  min-height: 480px;
  margin: -32px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

/* ---------- панель диалогов (левая колонка макета) ---------- */
.chat-threads {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px;
  background: var(--surface-2);
  border-inline-end: 1px solid var(--line);
}

.chat-new {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  margin-bottom: 16px;
  padding: 10px 16px;
  font-family: var(--font-ui);
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

.chat-new:hover { background: var(--accent-hover); }

.chat-threads-title {
  margin-bottom: 8px;
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}

.chat-threads-list {
  display: grid;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chat-thread {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 8px 12px;
  text-align: start;
  color: var(--text-2);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
}

.chat-thread:hover { background: var(--surface-variant); color: var(--text); }

.chat-thread.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-soft-line);
}

.chat-thread-title {
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-thread-meta {
  font-size: 12px;
  line-height: 16px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- полотно переписки ---------- */
.chat-main {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  background: var(--bg);
}

.chat-canvas {
  min-height: 0;
  padding: 24px 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.chat-canvas > * { max-width: 768px; margin-inline: auto; }

/* ---------- пустое состояние (макет 07:232-263) ---------- */
.chat-empty {
  width: 100%;
  max-width: 768px;
  margin: 24px auto;
  text-align: center;
}

.chat-hero-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: 8px;
  color: var(--accent-fixed);
  background: var(--accent-hover);
  border-radius: var(--radius-pill);
}

.chat-hero-ic .msym { font-size: 24px; }

.chat-empty h2 {
  margin: 0;
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}

.chat-empty > p {
  max-width: 560px;
  margin: 4px auto 0;
  font-size: 14px;
  line-height: 20px;
  color: var(--text-2);
}

.chat-quick {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.chat-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 12px;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.chat-chip:hover { background: var(--surface-3); }
.chat-chip .msym { color: var(--accent); }

.chat-suggest {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 24px;
  text-align: start;
}

.chat-suggest-card {
  padding: 12px 14px;
  text-align: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.chat-suggest-card:hover { border-color: var(--accent); }

.chat-suggest-card b {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  color: var(--text);
}

.chat-suggest-card span {
  font-size: 12px;
  line-height: 16px;
  color: var(--text-2);
}

/* ---------- пузыри (макет 07:267-323) ---------- */
.chat-row { display: flex; gap: 8px; margin-bottom: 16px; }
.chat-row--user { justify-content: flex-end; }
.chat-row--bot { justify-content: flex-start; }

.chat-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  margin-top: 4px;
  color: var(--accent);
  background: var(--surface-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
}

.chat-bubble--user {
  max-width: 80%;
  padding: 8px 16px;
  font-size: 14px;
  line-height: 20px;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  border-start-end-radius: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-bubble--bot {
  max-width: 85%;
  padding: 16px;
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  border-start-start-radius: 0;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .05);
  overflow-wrap: anywhere;
}

[data-theme="dark"] .chat-bubble--user {
  color: var(--text);
  background: var(--surface-4);
  border-color: var(--line);
}

.chat-bubble--bot > *:first-child { margin-top: 0; }
.chat-bubble--bot > *:last-child { margin-bottom: 0; }
.chat-bubble--bot p { margin: 0 0 16px; }
.chat-bubble--bot h3 { margin: 16px 0 8px; font-size: 16px; line-height: 24px; font-weight: 600; }
.chat-bubble--bot ul,
.chat-bubble--bot ol { margin: 0 0 16px; padding-inline-start: 20px; }
.chat-bubble--bot li { margin-bottom: 4px; }
.chat-bubble--bot a { color: var(--accent); }
.chat-bubble--bot code {
  padding: 1px 4px;
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.chat-bubble--bot pre {
  margin: 0 0 16px;
  padding: 12px;
  overflow-x: auto;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.chat-bubble--bot pre code { padding: 0; border: 0; background: none; }

/* Таблица в ответе — как в макете 07:280-317 */
.chat-table-wrap { margin: 0 0 16px; overflow-x: auto; overscroll-behavior-inline: contain; }

.chat-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  line-height: 16px;
}

.chat-table thead { background: var(--surface-2); border-bottom: 1px solid var(--line); }

.chat-table th {
  padding: 8px 12px;
  font-size: 11px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-2);
  text-align: start;
  white-space: nowrap;
}

.chat-table td {
  padding: 8px 12px;
  color: var(--text-2);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent);
  vertical-align: top;
}

.chat-table tbody tr:last-child td { border-bottom: 0; }
.chat-table td:first-child { font-family: var(--font-mono); font-size: 13px; color: var(--accent); }

/* «Печатает…» */
.chat-typing { display: inline-flex; gap: 4px; align-items: center; padding: 16px; }
.chat-typing span {
  width: 6px;
  height: 6px;
  background: var(--muted);
  border-radius: var(--radius-pill);
  animation: chat-dot 1.2s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes chat-dot {
  0%, 60%, 100% { opacity: .28; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
  .chat-typing span { animation: none; opacity: .5; }
}

/* ---------- поле ввода (макет 07:327-339) ---------- */
.chat-dock {
  padding: 8px 16px 16px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  max-width: 768px;
  margin: 0 auto;
  padding: 6px;
  background: var(--surface-lowest);
  border: 1px solid var(--line);
  border-radius: 26px; /* капсула: одна строка — овал, при росте — скруглённые бока */
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, .05);
}

.chat-composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.chat-composer textarea {
  flex: 1 1 auto;
  min-width: 0;
  height: 40px;
  min-height: 40px !important;
  max-height: 140px;
  padding: 10px 6px !important;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  background: transparent !important;
  border: 0 !important;
  border-radius: 0;
  resize: none;
  overflow-y: auto;
}

.chat-composer textarea:focus { outline: none; box-shadow: none; border: 0; }

.chat-attach,
.chat-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.chat-attach { color: var(--muted); background: transparent; }
.chat-attach:hover { color: var(--text); background: var(--surface-3); }

.chat-send { color: var(--accent-ink); background: var(--accent); }
.chat-send:hover { background: var(--accent-hover); }
.chat-send:disabled { opacity: .55; cursor: default; }

.chat-hint {
  max-width: 768px;
  margin: 8px auto 0;
  font-size: 12px;
  line-height: 16px;
  text-align: center;
  color: var(--muted);
}

/* ---------- телефон (макет 09) ---------- */
@media (max-width: 820px) {
  /* Чат занимает всё окно между верхней и нижней панелями, поле ввода
     закреплено внизу — раньше оно «улетало» вверх из-за расчёта высоты. */
  .chat-shell {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    border-top: 0;
    background: transparent;
  }

  .chat-main {
    display: block;
    background: transparent;
  }

  .chat-canvas {
    padding: 16px 12px calc(96px + env(safe-area-inset-bottom, 0px));
    overflow: visible;
  }

  .chat-dock {
    position: fixed;
    z-index: 44;
    inset-inline-end: 0;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    inset-inline-start: 0;
    padding: 8px 12px;
    background: var(--surface);
    border-top: 1px solid var(--line);
  }

  .chat-hint { display: none; }

  /* Панели диалогов в мобильном макете нет — список открывается кнопкой */
  .chat-threads { display: none; }

  .chat-bubble--user,
  .chat-bubble--bot { max-width: 90%; }
  .chat-bubble--bot { padding: 12px; }
  .chat-dock { padding: 8px 12px calc(12px + env(safe-area-inset-bottom, 0px)); }
  /* Подсказка в поле занимает две строки — даём под неё высоту, иначе текст обрезался */
  .chat-composer textarea { font-size: 16px; min-height: 48px; }

  /* Кнопка «+» (новая поставка) в чате не нужна и перекрывала поле ввода */
  .app-shell:has(.chat-shell) .fab { display: none; }
  .chat-quick { flex-direction: column; align-items: stretch; }
  .chat-chip { justify-content: flex-start; min-height: 44px; }
  .chat-suggest { grid-template-columns: minmax(0, 1fr); }
  .chat-attach,
  .chat-send { width: 44px; height: 44px; }
}

/* ==========================================================================
   Новый макет ИИ (stitch-v2, ai_workspace_*): подписи ролей над пузырями,
   сетка быстрых действий, круглый аватар. Пузыри скруглены целиком, срезан
   только верхний угол со стороны говорящего.
   ========================================================================== */

.chat-turn { max-width: 768px; margin: 0 auto 16px; }
.chat-turn--user { text-align: end; }

.chat-role {
  display: inline-block;
  margin-bottom: 4px;
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}

.chat-turn-body { min-width: 0; text-align: start; }
.chat-turn .chat-row { margin-bottom: 0; }

/* Пометка «отвечает ИИ» рядом с подписью ассистента (статья 50 AI Act ЕС).
   Тише самой подписи, но всегда видна и не обрезается на телефоне. */
.chat-ai-note {
  margin-inline-start: 8px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  opacity: .75;
}

/* Сетка быстрых действий — как 2x2 в мобильном макете */
.chat-quick {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.chat-quick-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 12px 14px;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 20px;
  font-weight: 600;
  text-align: start;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.chat-quick-card:hover { border-color: var(--accent); background: var(--surface-3); }
.chat-quick-card .msym { color: var(--accent); }

/* Кнопки внутри ответа ИИ (в макете «Export CSV», «Deep Dive Compare») */
.chat-bubble--bot .chat-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

@media (max-width: 820px) {
  .chat-turn { margin-bottom: 16px; }
  .chat-quick { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .chat-quick-card { min-height: 60px; padding: 10px 12px; font-size: 13px; }
}

/* ==========================================================================
   Диалоги ИИ в боковом меню (макет ai_workspace_unified_navigation):
   кнопка «Новый диалог», поиск, «Закреплённые», «Недавние», карточка
   пользователя внизу меню.
   ========================================================================== */

.side-chats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 120px;
  padding: 16px 16px 0;
  margin-top: 8px;
  border-top: 1px solid var(--sidebar-line);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.side-cta--chat { width: 100%; margin: 0; }

.side-search {
  position: relative;
  display: block;
}

.side-search .msym {
  position: absolute;
  inset-inline-start: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--sidebar-muted);
  pointer-events: none;
}

.side-search input {
  width: 100%;
  min-height: 34px !important;
  padding-top: 6px !important;
  padding-inline-end: 10px !important;
  padding-bottom: 6px !important;
  padding-inline-start: 34px !important;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 16px;
  color: var(--sidebar-text-strong);
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.side-search input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }

.nav-group--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px 2px;
}

.nav-group--row .msym { font-size: 14px; color: var(--sidebar-muted); }

.side-chats .nav-group { padding: 8px 4px 2px; }

/* Элемент списка диалогов */
.side-chat {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius);
}

.side-chat:hover { background: var(--sidebar-hover); }

.side-chat-open {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 32px;
  padding: 6px 8px;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 16px;
  text-align: start;
  color: var(--sidebar-text);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

.side-chat-open span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-chat-open .msym { font-size: 14px; color: var(--accent); flex: none; }
.side-chat:hover .side-chat-open { color: var(--accent); }

.side-chat.active { background: var(--surface-4); }
.side-chat.active .side-chat-open { color: var(--accent); font-weight: 600; }

/* Три точки — видимая ручка действий у каждого диалога */
.side-chat-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: none;
  padding: 0;
  color: var(--sidebar-muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  opacity: .55;
  cursor: pointer;
}

.side-chat:hover .side-chat-more { opacity: 1; }
.side-chat-more:hover { background: var(--surface-variant); color: var(--accent); opacity: 1; }
.side-chat-more .msym { font-size: 18px; }

/* Всплывающее меню действий */
.chat-menu-pop {
  position: fixed;
  z-index: 80;
  min-width: 200px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
}

.chat-menu-pop button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  text-align: start;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

.chat-menu-pop button:hover { background: var(--surface-3); }
.chat-menu-pop button .msym { color: var(--text-2); }
.chat-menu-pop button:hover .msym { color: var(--accent); }
.chat-menu-pop button.danger { color: var(--danger); }
.chat-menu-pop button.danger .msym { color: var(--danger); }
.chat-menu-pop button.danger:hover { background: var(--danger-bg); }

/* Поле переименования по месту */
.side-chat-edit {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 32px !important;
  padding: 6px 8px !important;
  font-size: 12px !important;
  border-radius: var(--radius) !important;
}

.side-chats-empty {
  margin: 4px;
  font-size: 12px;
  line-height: 16px;
  color: var(--sidebar-muted);
}

/* Карточка пользователя внизу меню */
.side-user {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  text-align: start;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

.side-user:hover { background: var(--sidebar-hover); }

.side-user-ava {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex: none;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  background: var(--surface-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
}

.side-user-body { display: grid; min-width: 0; }

.side-user-body b {
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--sidebar-text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-user-body span {
  font-size: 11px;
  line-height: 16px;
  color: var(--sidebar-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Чат теперь в одну колонку — панель диалогов живёт в меню */
.chat-shell { grid-template-columns: minmax(0, 1fr); }
.chat-threads { display: none; }

/* Карточка поставки внутри ответа ИИ (мобильный макет ai_workspace_mobile) */
.chat-ship {
  margin-top: 12px;
  padding: 12px;
  background: var(--surface-lowest);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.chat-ship--alarm { border-inline-start: 3px solid var(--danger); }

.chat-ship-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.chat-ship-num {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 16px;
  font-weight: 500;
  color: var(--accent);
}

/* Пары «метка над значением» в колонках — как Vessel/Status в макете */
.chat-ship-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: auto auto;
  grid-auto-columns: minmax(0, 1fr);
  gap: 2px 12px;
  margin-bottom: 10px;
}

.chat-ship-label {
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-2);
  align-self: end;
}

.chat-ship-value {
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  overflow-wrap: anywhere;
}

.chat-ship-open {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 36px;
  padding: 8px 12px;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  cursor: pointer;
}

.chat-ship-open:hover { background: var(--surface-variant); }

@media (max-width: 820px) {
  /* На телефоне пары складываются в столбик — три колонки не влезают */
  .chat-ship-grid { grid-auto-flow: row; grid-template-rows: none; grid-template-columns: minmax(0, 1fr); }
}

/* Пилюля-разделитель с датой между днями переписки */
.chat-day {
  display: flex;
  justify-content: center;
  max-width: 768px;
  margin: 0 auto 16px;
}

.chat-day span {
  padding: 4px 12px;
  font-size: 12px;
  line-height: 16px;
  color: var(--text-2);
  background: var(--surface-variant);
  border-radius: var(--radius-pill);
}

/* Микрофон в поле ввода: активная диктовка подсвечивается */
.chat-mic--on { color: var(--danger) !important; background: var(--danger-bg) !important; }

/* ---------- аналитика в «Отчётах» (макет analytics) ---------- */
.an-row { margin-top: 16px; }

.an-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.an-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-2);
}

.an-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-inline-start: 10px;
  border-radius: var(--radius-sm);
}

.an-legend .an-dot:first-child { margin-inline-start: 0; }
.an-dot--done { background: var(--accent); }
.an-dot--total { background: var(--surface-variant); border: 1px solid var(--line); }
.an-dot--part { background: var(--secondary-container); border: 1px solid var(--line); }
.an-dot--bad { background: var(--danger); }

.an-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 200px;
  padding-top: 8px;
}

.an-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
}

.an-stack {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.an-bar { width: 70%; border-radius: 6px 6px 0 0; }

.an-bar--total {
  position: absolute;
  bottom: 0;
  background: var(--surface-variant);
  border: 1px solid var(--line);
  border-bottom: 0;
}

.an-bar--done { position: relative; z-index: 1; width: 46%; background: var(--accent); }

.an-x {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 16px;
  color: var(--muted);
  white-space: nowrap;
}

/* Панель «Доставка вовремя» */
.an-perf { display: grid; gap: 16px; }

.an-perf-big {
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 24px;
  background: var(--surface-2);
  border-radius: var(--radius-lg);
}

.an-perf-big strong {
  font-size: 36px;
  line-height: 44px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.an-perf-big span {
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-2);
}

.an-perf-legend { display: grid; gap: 8px; }

.an-perf-legend > div {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
}

.an-perf-legend .an-dot { margin-inline-start: 0; }
.an-perf-legend b { margin-inline-start: auto; font-weight: 600; }

@media (max-width: 820px) {
  .an-chart { height: 150px; gap: 6px; }
  .an-x { font-size: 9px; }
}

/* ---------- настройки профиля (макет profile_settings) ---------- */
.panel h2 .msym { color: var(--accent); vertical-align: -3px; margin-inline-end: 4px; }

.prof-card { display: flex; gap: 16px; align-items: flex-start; }

.prof-ava {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  flex: none;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  background: var(--surface-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
}

.prof-fields { display: grid; gap: 12px; flex: 1 1 auto; min-width: 0; }
.prof-fields input:disabled { color: var(--text-2); background: var(--surface-2); }
.prof-fields .mono { font-family: var(--font-mono); }

/* Строка предпочтения с тумблером — как Notifications в макете */
.pref-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.pref-row b { display: block; font-size: 14px; line-height: 20px; font-weight: 600; color: var(--text); }
.pref-row span { font-size: 12px; line-height: 16px; color: var(--text-2); }

/* Тумблер из макета: 44x24, круглая ручка */
.switch {
  position: relative;
  /* мобильное правило «все кнопки минимум 44px» раздувало тумблер в круг */
  width: 44px !important;
  min-width: 44px !important;
  height: 24px !important;
  min-height: 24px !important;
  flex: none;
  padding: 0 !important;
  background: var(--surface-variant);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background .15s ease;
}

.switch i {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--surface-lowest);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  transition: left .15s ease;
}

.switch.on { background: var(--accent); border-color: var(--accent); }
.switch.on i { left: 22px; border-color: var(--accent); }

/* Кнопки действий под ответом ИИ (в макете Export CSV / Deep Dive Compare) */
.chat-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.chat-act {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 10px;
  font-family: var(--font-ui);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-lowest);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.chat-act:hover { border-color: var(--accent); color: var(--accent); }
.chat-act .msym { font-size: 16px; }

/* ---------- логика бокового меню ----------
   Разделы переехали в верхнюю панель (ПК) и нижнюю (телефон), поэтому:
   - в разделе ИИ меню показывает ТОЛЬКО диалоги (+ низ: настройки, профиль);
   - в остальных разделах — только «Справочники» (+ низ). Дублей нет. */
.nav:empty { display: none; }

.side-chats { border-top: 0; margin-top: 0; }

@media (max-width: 820px) {
  /* На телефоне меню-шторка открывается бургером: в ИИ — только диалоги */
  .sidebar .brand { display: none; }
  .sidebar { padding-top: calc(64px + env(safe-area-inset-top, 0px) + 4px); }
}

/* Группа «Разделы» в бургере — только на телефоне (на ПК разделы в верхней панели).
   Без неё «Отчёты» на телефоне были недоступны: в нижней панели только 4 пункта. */
.nav-primary-mobile { display: none; }

@media (max-width: 820px) {
  .nav-primary-mobile { display: block; }
}

/* ==========================================================================
   Деньги в поставках: панель бюджета в отчётах + форма бюджета объекта
   ========================================================================== */
.money-table td:not(:first-child) { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13px; white-space: nowrap; }
.money-table tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.money-use { display: inline-flex; align-items: center; gap: 8px; }
.money-bar { width: 110px; height: 8px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; display: inline-block; flex: none; }
.money-bar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.money-bar i.over { background: var(--danger); }
.money-over { color: var(--danger); font-weight: 700; }
.object-budget { display: flex; gap: 10px; align-items: flex-end; margin: 10px 0 4px; }
.object-budget .field { flex: 1; margin: 0; }
.object-budget .btn { flex: none; }

/* --- Резиновая таблица денег (Отчёты → «Деньги по объектам», Деньги → «Бюджеты объектов») ---
   Суммы не переносятся (так и задумано), поэтому места таблице нужно много: при крупных
   номиналах (AED, AMD, KZT) шесть колонок не помещаются в панель на средних ширинах окна.
   Раньше таблица в Отчётах стояла без .table-wrap, на общей жёсткой сетке равных колонок
   (table-layout: fixed), и суммы наезжали на соседний столбец. Теперь три ступени:
   1) таблица по содержимому: колонка суммы ровно по ширине суммы, название объекта забирает
      остаток и переносится по словам; поля ячеек уже, полоса расхода резиновая;
   2) панель узкая - строки превращаются в карточки-сводки (ниже);
   3) не влезло и так (очень длинные суммы) - прокрутка внутри .table-wrap, как у реестров. */
.money-panel { container: money-panel / inline-size; }
.money-bar { width: clamp(56px, 12cqi - 50px, 110px); }
.money-table .object-budget { max-width: 320px; }
.money-table .object-budget input { flex: 1 1 auto; min-width: 0; width: 100%; }
@media (min-width: 821px) {
  .table-wrap .money-table { width: 100%; }
  .money-table th, .money-table td { padding-inline: 10px; }
  .money-table th:first-child, .money-table td:first-child { min-width: 168px; overflow-wrap: break-word; }

  /* Ступень 2. Порог 860px - ширина, в которую таблица ещё помещается с самыми длинными
     суммами демо-наборов (KZT: «2 400 000 000 KZT»); с боковым меню это окно примерно до
     1240px. Считаем от ширины панели, а не окна: место отнимает меню, а не экран.
     На телефоне (до 820px) карточки рисует общий мобильный блок .data-table. */
  @container money-panel (max-width: 860px) {
    .money-panel .table-wrap { overflow: visible; }
    .table-wrap .money-table,
    .money-table tbody,
    .money-table tfoot { display: block; width: 100%; min-width: 0; }
    .money-table thead { display: none; }
    .money-table tr {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px 16px;
      margin-bottom: 8px;
      padding: 12px 14px;
      background: var(--surface);
      border: 1px solid var(--line);
      border-radius: var(--radius);
    }
    .money-table tr:last-child { margin-bottom: 0; }
    .money-table tfoot tr { margin-top: 8px; border-width: 2px; }
    /* Сумма длиннее своей клетки (такого в данных пока нет) пусть лучше перенесётся,
       чем снова наедет на соседнюю. */
    .money-table td,
    .money-table td .money-nb { white-space: normal; overflow-wrap: anywhere; }
    .money-table td { display: block; min-width: 0; padding: 0; border: 0; background: transparent !important; }
    .money-table td:first-child,
    .money-table td[data-col="usage"] { grid-column: 1 / -1; }
    .money-table td:first-child { min-width: 0; font-size: 13px; line-height: 18px; color: var(--text); }
    .money-table td:empty { display: none; }
    .money-table td[data-label]::before {
      content: attr(data-label);
      display: block;
      margin-bottom: 2px;
      font-family: var(--font-ui);
      font-size: 11px;
      line-height: 14px;
      font-weight: 700;
      letter-spacing: .02em;
      text-transform: uppercase;
      color: var(--text-2);
    }
    .money-table td:first-child::before { content: none; }
    .money-table tfoot td { border: 0; }
    .money-use { display: flex; }
    .money-bar { flex: 1 1 auto; width: auto; min-width: 40px; max-width: 240px; }
  }
  /* Четыре суммы в ряд - когда каждой хватает места (самая длинная в демо - 133px). */
  @container money-panel (min-width: 700px) and (max-width: 860px) {
    .money-table tr { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  }
}
/* Телефон: строка «Итого» (tfoot) не попадала в общий мобильный блок .data-table - оставалась
   узкой таблицей без подписей. Делаем её такой же карточкой, как строки объектов. */
@media (max-width: 820px) {
  .money-table tfoot { display: block; width: 100%; }
  .money-table tfoot td { border-top: 0; }
  .money-table tfoot td:first-child { display: block; color: var(--text); }
  .money-table tfoot td:first-child::before { content: none; }
  .money-table tfoot td:nth-last-child(2) { border-bottom: 0; } /* последняя ячейка (полоса расхода) в итоге пустая и скрыта */
  .money-table td:empty { display: none; }
  .money-table td::before { font-family: var(--font-ui); }
}

/* Заявки с объекта */
.cargo-row input[name="reqQty"] { width: 92px; flex: none; }
.cargo-row select[name="reqUnit"] { width: 108px; flex: none; }
.cargo-row input[name="reqUnitOther"] { width: 108px; flex: none; }
.request-card { margin-bottom: 12px; }
.request-items { margin: 10px 0 4px; padding-inline-start: 20px; }
.request-items li { margin: 2px 0; }
.request-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; }
.request-convert { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.request-convert select, .request-convert input { min-height: 40px; }
@media (max-width: 820px) {
  .request-convert { width: 100%; }
  .request-convert select { flex: 1; min-width: 150px; }
}

/* ==========================================================================
   Мессенджер: список чатов, аватары, бейджи, шапка переписки
   ========================================================================== */
.chat-new-btn { width: 100%; margin: 0 0 10px; }
.side-chat-list { display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.chat-ava { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; flex: none; }
.chat-ava--group { background: var(--secondary-container, var(--accent-soft)); color: var(--on-secondary-container, var(--accent)); }
.chat-item { display: flex; gap: 10px; align-items: center; }
.chat-item-tx { flex: 1; min-width: 0; display: block; text-align: start; }
.chat-item-tx b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-tx small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-unread { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex: none; }
[data-theme="dark"] .chat-unread { color: var(--accent-ink, #001452); }
.chat-head { display: flex; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); flex: none; }
.chat-head-tx { min-width: 0; }
.chat-head-tx b { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head-tx small { color: var(--muted); font-size: 12px; }
.top-nav-btn { position: relative; }
.tabbar-ic { position: relative; }
.chat-badge { position: absolute; top: -6px; inset-inline-end: -10px; }
.top-nav-btn .chat-badge { top: 2px; inset-inline-end: 2px; }
.chat-empty-side { padding: 4px 6px; font-size: 13px; }

.chat-avatar--person { font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.chat-bubble--user .chat-ship { color: var(--text); }

/* ==========================================================================
   ФИКСЫ КОНСИЛИУМА (01.08.2026): переносы по буквам, сжатые кнопки, мелочи
   ========================================================================== */
/* Кнопки никогда не рвутся по буквам и не сжимаются в столбик */
.btn, .top-nav-btn, .tabbar-btn, .chat-act { white-space: nowrap; }
.pref-row .btn { flex: none; }
/* Места груза в карточке поставки: тексту — простор, никаких колонок в 5 символов */
.part-card, .parts-grid > * { min-width: 0; }
.part-card b, .part-card .muted, .part-name { overflow-wrap: normal; word-break: keep-all; }
/* Места груза: текст занимает всю ширину, кнопки — строкой ниже, не столбиком */
.part-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.part-row > div:first-child { flex: 1 1 260px; min-width: 220px; overflow-wrap: normal; word-break: keep-all; }
.part-row .btn { flex: none; }

/* Пузырь сообщения: короткие слова не рвутся */
.chat-bubble--user, .chat-bubble--bot { min-width: 48px; word-break: normal; }
/* Кнопка выхода остаётся красной и в тёмной теме */
[data-theme="dark"] .btn.danger { color: var(--danger); border-color: var(--danger); }
/* Мобильный чат-мессенджер: композер прижат к низу над таббаром, как в ИИ */
@media (max-width: 820px) {
  /* Композер зафиксирован над нижней панелью: не уезжает при прокрутке,
     а с открытой клавиатурой браузер сам держит его над ней. */
  .main .chat-shell { display: flex; flex-direction: column; }
  .main .chat-shell .chat-canvas { flex: 1 1 auto; padding-bottom: 96px; }
  .main .chat-shell .chat-form,
  .main .chat-form {
    position: fixed;
    inset-inline-start: 0;
    inset-inline-end: 0;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    z-index: 40;
    padding: 8px 12px;
    background: var(--bg);
    border-top: 1px solid var(--line);
    margin: 0;
  }
}

/* Поиск доступен и на мобильном: лупа в шапке, поле раскрывается поверх */
@media (max-width: 820px) {
  .top-find { display: flex; }
  .top-find.open { position: fixed; top: 8px; inset-inline-start: 12px; inset-inline-end: 12px; z-index: 60; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px 4px; box-shadow: 0 6px 20px rgba(0, 0, 0, .18); }
  .top-find.open input { width: 100%; font-size: 16px; }
}

/* Таблицы на ПК: ответственный не съедает соседей, статус всегда виден */
.data-table td, .data-table th { overflow-wrap: anywhere; }
.data-table td[data-label="Ответственный"], .data-table td[data-col="responsible"] { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* data-label: убрать после этапа 4 */
.data-table td[data-label="Статус"], .data-table td[data-col="status"], .data-table td[data-label="Срок"], .data-table td[data-col="due"] { white-space: nowrap; } /* data-label: убрать после этапа 4 */
/* Шапка чата на мобильном: стрелка назад к списку */
.chat-back { display: none; }
@media (max-width: 820px) {
  .chat-back { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 0; background: none; color: var(--accent); cursor: pointer; flex: none; }
}

/* Время у сообщений чата */
.chat-stamp { font-size: 11px; color: var(--muted); margin-top: 4px; }
.chat-stamp--user { text-align: end; }
/* Горизонтальный скролл таблиц: всегда видимый тонкий скроллбар */
.table-wrap, .data-table-wrap, .attention-scroll, .chat-table-wrap { overflow-x: auto; scrollbar-width: thin; }
.table-wrap::-webkit-scrollbar, .data-table-wrap::-webkit-scrollbar { height: 8px; }
.table-wrap::-webkit-scrollbar-thumb, .data-table-wrap::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }

/* Панель участников группового чата */
.chat-members-panel { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.chat-member-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; font-size: 12.5px; background: var(--accent-soft); color: var(--accent); border-radius: 999px; font-weight: 600; }
.chat-member-chip button { border: 0; background: none; color: var(--danger); font-size: 13px; cursor: pointer; padding: 0 2px; }
.chat-add-member { display: inline-flex; gap: 8px; align-items: center; }
.chat-add-member select { min-height: 36px; border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px; font-family: inherit; font-size: 13px; background: var(--surface); color: var(--text); max-width: 190px; }

/* Обрезанная таблица подсказывает, что справа есть ещё (градиент-индикатор) */
@media (max-width: 820px) {
  .chat-table-wrap { position: relative; }
  .chat-table-wrap::after { content: ""; position: absolute; top: 0; inset-inline-end: 0; bottom: 8px; width: 28px; pointer-events: none; background: linear-gradient(to left, var(--surface), transparent); }
}

/* Главный экран чатов: список карточками */
.chat-list-main { display: flex; flex-direction: column; gap: 10px; max-width: 760px; }
.chat-card { width: 100%; padding: 14px 16px; border: 1px solid var(--line); cursor: pointer; text-align: start; }
.chat-card:hover { border-color: var(--accent); }

/* Голосовые сообщения: свой плеер (кнопка + полоса + время), без системного */
.chat-voice { display: inline-flex; align-items: center; gap: 10px; min-width: 210px; max-width: 100%; }
.vplay { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: none; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .22); color: inherit; cursor: pointer; }
.chat-bubble--bot .vplay { background: var(--accent); color: #fff; }
[data-theme="dark"] .chat-bubble--bot .vplay { color: var(--accent-ink, #001452); }
.vbar { flex: 1 1 90px; min-width: 70px; height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .3); overflow: hidden; cursor: pointer; }
.chat-bubble--bot .vbar { background: var(--accent-soft); }
.vbar i { display: block; width: 0%; height: 100%; border-radius: 999px; background: currentColor; transition: width .2s linear; }
.chat-bubble--bot .vbar i { background: var(--accent); }
.vtime { font-size: 12px; font-weight: 700; white-space: nowrap; opacity: .9; }
.voice-text-btn { border: 1px solid currentColor; background: none; color: inherit; font-size: 12px; font-weight: 800; border-radius: 8px; padding: 3px 8px; cursor: pointer; opacity: .85; }
.voice-transcript { margin-top: 8px; padding-top: 8px; border-top: 1px dashed currentColor; font-size: 13.5px; line-height: 19px; opacity: .95; white-space: pre-wrap; }
.chat-voice-btn.rec { background: var(--danger) !important; color: #fff !important; border-radius: 999px; animation: voicepulse 1.2s ease-in-out infinite; min-width: 52px; }
.voice-timer { font-size: 12px; font-weight: 800; font-family: "JetBrains Mono", monospace; }
@keyframes voicepulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(186, 26, 26, .4); } 50% { box-shadow: 0 0 0 8px rgba(186, 26, 26, 0); } }

/* Карточка поставки в чате: номер не ломается по строкам */
.chat-ship-head { flex-wrap: wrap; gap: 6px 10px; }
.chat-ship-num { white-space: nowrap; }
/* Голосовой пузырь без лишних пустот */
.chat-bubble--user .chat-voice, .chat-bubble--bot .chat-voice { margin: 2px 0; }

/* Плеер ГС в тёмной теме: акцентная кнопка и заметная полоса */
.vplay svg { display: block; }
[data-theme="dark"] .chat-bubble--user .vplay { background: var(--accent); color: var(--accent-ink, #001452); }
[data-theme="dark"] .chat-bubble--user .vbar { background: rgba(255, 255, 255, .22); }
[data-theme="dark"] .chat-bubble--user .vbar i { background: var(--accent); }
[data-theme="dark"] .chat-bubble--user .vtime { color: var(--text-2); }

/* ==========================================================================
   ГС как в Телеграме: волна, длительность и время — внутри пузыря
   ========================================================================== */
.msg-time { display: block; float: none; margin: 4px 0 0; font-size: 10.5px; line-height: 1; opacity: .65; white-space: nowrap; text-align: end; }
.chat-bubble--bot > .msg-time { display: block; margin: 6px 0 0; text-align: end; }
.chat-bubble--user .msg-time { color: inherit; }

/* Пузыри мессенджера обёрнуты в .chat-turn-body (ужимается по содержимому):
   max-width в процентах у пузыря считался от этой обёртки, а не от строки, -
   каждое сообщение срезалось на 15-20% и короткие слова ломались по буквам.
   Ограничиваем ширину самой обёртки от полной строки, пузырю - 100%. */
.chat-row--user .chat-turn-body { max-width: min(80%, 640px); }
.chat-row--bot .chat-turn-body { max-width: min(85%, 680px); }
.chat-turn-body .chat-bubble--user,
.chat-turn-body .chat-bubble--bot { max-width: 100%; }
.chat-row--user .chat-turn-body .chat-bubble--user { margin-inline-start: auto; width: fit-content; }
.chat-voice { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.chat-voice-body { display: inline-flex; flex-direction: column; gap: 4px; min-width: 150px; }
.vwave { position: relative; display: block; height: 26px; width: 168px; max-width: 46vw; cursor: pointer; }
.vwave-base, .vwave-fill-in { display: flex; align-items: center; gap: 2px; height: 100%; width: 168px; }
.vwave-base i, .vwave-fill-in i { flex: none; width: 3px; border-radius: 2px; background: rgba(255, 255, 255, .45); }
.vwave-fill { position: absolute; inset: 0 auto 0 0; overflow: hidden; width: 0%; transition: width .2s linear; }
.vwave-fill-in i { background: #fff; }
.vmeta { display: flex; align-items: center; gap: 8px; }
.vmeta .vtime { font-size: 11px; font-weight: 700; opacity: .85; }
.vmeta .msg-time { display: inline; margin-top: 0; margin-inline-end: 0; margin-bottom: 0; margin-inline-start: auto; text-align: end; }
.voice-text-btn { padding: 2px 7px; font-size: 11px; }
/* Входящие и ИИ (светлый пузырь): волна в акценте */
.chat-bubble--bot .vwave-base i { background: var(--accent-soft); }
.chat-bubble--bot .vwave-fill-in i { background: var(--accent); }
/* Тёмная тема, исходящее: перивинкл на графитовом */
[data-theme="dark"] .chat-bubble--user .vwave-base i { background: rgba(255, 255, 255, .28); }
[data-theme="dark"] .chat-bubble--user .vwave-fill-in i { background: var(--accent); }
[data-theme="dark"] .chat-bubble--bot .vwave-base i { background: rgba(183, 196, 255, .25); }

/* Подсказка под полем ИНН в форме поставщика (подтягивание из ЕГРЮЛ) */
.inn-hint { grid-column: 1 / -1; margin: -4px 0 0; padding: 8px 12px; border-radius: 10px; font-size: 13px; line-height: 18px; color: var(--text-2); background: rgba(0, 62, 199, .06); }
.inn-hint[hidden] { display: none; }
.inn-hint.ok { color: #0B6B3A; background: rgba(11, 107, 58, .09); }
.inn-hint.warn { color: #8A3B00; background: rgba(186, 26, 26, .09); }
.inn-hint.wait { opacity: .8; }
[data-theme="dark"] .inn-hint { background: rgba(183, 196, 255, .08); }
[data-theme="dark"] .inn-hint.ok { color: #7CF7A8; background: rgba(124, 247, 168, .1); }
[data-theme="dark"] .inn-hint.warn { color: #FFB4AB; background: rgba(255, 180, 171, .1); }

/* ---------- счета и оплаты ---------- */
.invoice-table td { vertical-align: top; }
.invoice-table .inv-sum { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13px; white-space: nowrap; font-weight: 700; }
.inv-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.inv-row.inv-hold td { background: var(--danger-bg); }
.inv-row.inv-hold td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.inv-group-title { margin: 18px 0 8px; font-size: 15px; }
.inv-stats .stat-card strong { font-size: 22px; }
.ship-invoices { margin-top: 16px; }
.ship-invoices .btn { margin-top: 10px; }
@media (max-width: 720px) {
  .invoice-table .inv-actions { justify-content: flex-start; }
  /* Реестр счетов в виде карточек: у кнопки «Оплатить без приёмки» и подобных
     длинных подписей нет места по ширине карточки — были шире своего блока
     (nowrap от .btn). Внутри действий счёта разрешаем перенос подписи. */
  .invoice-table .inv-actions .btn { white-space: normal; text-align: center; }
}

/* ==========================================================================
   Аудит UX/UI 23.08: мессенджер как мессенджер + общие правки
   ========================================================================== */
/* Переписка: шапка и композер по краям, лента тянется (иначе три равные полосы) */
.main .chat-shell { display: flex; flex-direction: column; }
.main .chat-shell > .chat-main { flex: 1 1 auto; min-height: 0; }
.main .chat-shell > .chat-canvas { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.main .chat-shell > .chat-head,
.main .chat-shell > .chat-members-panel { flex: 0 0 auto; }
.main .chat-shell > .chat-form { flex: 0 0 auto; border-top: 1px solid var(--line); background: var(--surface); }
.chat-head-tx { min-width: 0; }
.chat-head-tx b, .chat-head-tx small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Пузыри мессенджера: хвост снизу, одинаковые отступы, время в углу */
.chat-canvas--im .chat-bubble--user { border-radius: var(--radius-lg); border-end-end-radius: 4px; padding: 8px 12px; }
.chat-canvas--im .chat-bubble--bot { border-radius: var(--radius-lg); border-start-start-radius: 4px; padding: 8px 12px; box-shadow: none; border-color: transparent; background: var(--surface-2); }
.chat-canvas--im .msg-time { float: inline-end; margin-top: 6px; margin-inline-end: 0; margin-bottom: 0; margin-inline-start: 10px; }
.chat-canvas--im .chat-turn { margin-bottom: 12px; }
.chat-canvas--im .chat-turn--cont { margin-top: -8px; }
.chat-role--person { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; color: var(--accent); }
/* Свой пузырь в тёмной теме - акцентный, а не серый как чужой */
[data-theme="dark"] .chat-canvas--im .chat-bubble--user { color: #EAF0FF; background: color-mix(in srgb, var(--accent) 42%, #10141F); border-color: transparent; }
/* Пустая переписка - пилюля по центру, а не пунктирная рамка */
.chat-empty-pill { width: max-content; max-width: 80%; margin: 24px auto; padding: 8px 14px; font-size: 13px; color: var(--text-2); background: var(--surface-2); border-radius: var(--radius-pill); text-align: center; }

/* Строки списка чатов: не нативные кнопки, время и непрочитанные справа */
.side-chat { width: 100%; padding: 8px; background: transparent; border: 0; text-align: start; }
.side-chat:hover { background: var(--surface-2); }
.side-chat.active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.chat-item-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; margin-inline-start: auto; flex: none; }
.chat-item-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.chat-item--unread .chat-item-tx b { font-weight: 700; }
.chat-item--unread .chat-item-tx small { color: var(--text); }
.chat-card.side-chat { padding: 14px; }

/* Пустые состояния занимают всю ширину сетки, а не одну ячейку */
.cards-grid > .empty, .grid > .empty, .split > .empty { grid-column: 1 / -1; }

/* Кнопка выбора файла по-русски (нативный «Choose File» скрыт).
   Имя файла и надпись на кнопке - обычным текстом: правило «.field span» делало
   их капсом в 11px («ВЫБРАТЬ ФАЙЛ / ФАЙЛ НЕ ВЫБРАН»), а без min-width:0 длинное
   имя файла вылезало за край карточки. */
.file-field { display: flex; align-items: center; gap: 10px; min-width: 0; }
.file-field input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.file-field .btn { flex: none; }
.field .file-field .btn,
.file-field .btn { text-transform: none; letter-spacing: 0; }
.field .file-field .file-name,
.file-field .file-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 500;
}

/* Закрытый details никогда не остаётся без кнопки-раскрывашки */
@media (min-width: 821px) {
  .fold:not([open]) > .fold-sum { display: inline-flex; }
}

/* Кнопки в строке счёта не режутся краем таблицы */
.invoice-table th:last-child, .invoice-table td:last-child { width: 230px; }

/* ==========================================================================
   Правки многоязычной вёрстки (сентябрь 2026)
   ========================================================================== */

/* --- Сумма не рвётся посреди числа ---------------------------------------
   «US$ 3,915,000» в плитке переносился как «US$ 3,915,00» и «0» на второй строке:
   у денег нет места для переноса, разорванное число читается как другая сумма.
   Поэтому строка не переносится, а КЕГЛЬ уменьшается по её длине: разметка кладёт
   число знаков в --figure-chars (app.js: statFigure), --figure-free говорит, сколько
   знаков помещается без уменьшения. Считать ширину в JS нельзя: плитка меняет ширину
   при повороте экрана, а CSS пересчитывает сам. */
.stat-card strong { white-space: nowrap; }

.stat-card strong.stat-figure {
  --figure-base: 36px;
  --figure-step: 2.4px;
  --figure-min: 17px;
  --figure-free: 9;
  /* Высоту строки НЕ трогаем: плитки в ряду обязаны остаться одной высоты. */
  font-size: max(
    var(--figure-min),
    min(var(--figure-base), calc(var(--figure-base) - (var(--figure-chars, 9) - var(--figure-free)) * var(--figure-step)))
  );
}

/* Плитки денег (счета и платёжный календарь) по макету мельче остальных - 22px. Значения
   ниже подобраны так, чтобы РУССКАЯ сумма («3 915 000 ₽», 11 знаков) осталась ровно
   прежнего кегля, а уменьшались только те строки, которые раньше рвались переносом. */
.inv-stats .stat-card strong.stat-figure {
  --figure-base: 22px;
  --figure-step: 1.6px;
  --figure-min: 13px;
  --figure-free: 13;
}

@media (max-width: 720px) {
  /* На телефоне плитка вдвое уже, поэтому запас знаков меньше, а шаг крупнее. */
  .inv-stats .stat-card strong.stat-figure {
    --figure-step: 2.2px;
    --figure-free: 11;
  }
}

/* Суммы в обычном тексте (подпись плитки, итог группы, ячейка таблицы) тоже целые.
   Разметка заворачивает их в <bdi> (app.js: nbMoney) — правила вида «.stat-card span»
   и «.meta span» превратили бы вложенный span в блок со своим кеглем. */
.money-nb { white-space: nowrap; }
.stat-multi-currency { white-space: nowrap; }

/* --- Карточка счёта: текст не заезжает под красную полосу ------------------
   На ПК полоса у просроченного счёта — внутренняя тень первой ячейки, и отступа ячейки
   (12px) ей хватает. На телефоне строка таблицы превращается в карточку, у ячеек отступа
   слева нет вовсе, и под трёхпиксельную тень уезжали первые буквы: «ECHNUNG» вместо
   «RECHNUNG», «om 7.9.2026» вместо «vom 7.9.2026». Поэтому в режиме карточек полосу
   рисуем НАСТОЯЩЕЙ рамкой по краю всей карточки: рамка занимает место, все подписи
   остаются на одной линии, а логическое свойство само переносит её вправо в языках,
   которые пишут справа налево. */
@media (max-width: 720px) {
  .inv-row.inv-hold td:first-child { box-shadow: none; }
  .inv-row.inv-hold { border-inline-start: 4px solid var(--danger); }
}

/* В языках справа налево полоса на ПК тоже должна быть со стороны начала строки. */
[dir="rtl"] .inv-row.inv-hold td:first-child { box-shadow: inset -3px 0 0 var(--danger); }

/* --- Ответственный: столбец не шире 180 пикселей, но ничего не теряет ---------
   Раньше длинное имя или должность обрезались многоточием («Снабженец компании»,
   «Beschaffung des Unternehmens») — на телефоне, где строка таблицы становится
   карточкой, это особенно заметно. Ширину ограничиваем по-прежнему, а лишнее
   переносим на вторую строку. */
.data-table td[data-label="Ответственный"],
.data-table td[data-col="responsible"] {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

@media (max-width: 720px) {
  /* В режиме карточек ширину столбца задаёт сетка ячейки, а не max-width. */
  .data-table td[data-label="Ответственный"],
  .data-table td[data-col="responsible"] { max-width: none; }
}

/* --- Кнопка выбора файла: подпись уходит на свою строку, а не под многоточие ---
   «Keine Datei ausgewählt» / «Ningún archivo elegido» длиннее русского «Файл не
   выбран» и не помещались рядом с кнопкой — оставалось «Keine Datei ausge…».
   Разрешаем перенос: у подписи flex-basis остаётся auto (её собственная ширина), поэтому
   короткая русская подпись как стояла рядом с кнопкой, так и стоит, а длинная переезжает
   на свою строку и видна целиком. */
.file-field { flex-wrap: wrap; row-gap: 4px; }
