/* @updated 2026-06-15-v9 */
:root {
  color-scheme: dark;
  font-family: Inter, system-ui, -apple-system, sans-serif;

  --tbl-bg:        rgb(2, 6, 23);
  --tbl-bg-head:   rgb(15, 23, 42);
}

/* ── Critical: hidden before Tailwind loads ─────────────────────── */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.overflow-hidden { overflow: hidden; }
.w-full { width: 100%; }
.h-full { height: 100%; }

/* ── catalog-panel: full-screen panel inside modal-overlay ──────── */
/* Tailwind CDN не генерирует классы для скрытых при загрузке элементов.
   Все критические стили catalog-panel дублируем явно. */
.catalog-panel {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: rgb(2, 6, 23);
  overflow: hidden;
}

body {
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

/* ── Modal overlay ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal-panel {
  transform: translateY(16px) scale(0.97);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-overlay.open .modal-panel { transform: translateY(0) scale(1); }

.modal-overlay .modal-panel { max-height: 92vh; }

.module-hub-modal {
  width: min(97vw, 1380px) !important;
  max-width: none !important;
  max-height: 94vh !important;
}

@media (max-width: 640px) {
  .module-hub-modal {
    width: min(99vw, 1380px) !important;
    margin-left: 0.35rem !important;
    margin-right: 0.35rem !important;
    padding: 0.9rem !important;
  }
}

/* ── Card / modal body scroll ───────────────────────────────────── */
.catalog-panel > .flex-1.overflow-auto,
.catalog-panel > .flex-1.overflow-y-auto { min-height: 0; }
.modal-panel.flex.flex-col > .flex-1 { min-height: 0; overflow-y: auto; }

/* ── Toast ──────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.toast.out { animation: toast-out 0.25s ease forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

/* ── Drop zone ──────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed rgba(100, 116, 139, 0.4);
  transition: border-color 0.2s, background 0.2s;
}
.drop-zone.drag-over {
  border-color: rgb(34, 211, 238);
  background: rgba(34, 211, 238, 0.05);
}

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,0.35); }

/* ── Color swatch ───────────────────────────────────────────────── */
.color-swatch {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  flex-shrink: 0;
}

/* ── Focus ring ─────────────────────────────────────────────────── */
button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 2px solid rgb(34, 211, 238);
  outline-offset: 2px;
}

/* ── Predictive filters ────────────────────────────────────────── */
.predictive-filter {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 44px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 0.9rem;
  background: rgba(255,255,255,0.05);
  overflow: hidden;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.predictive-filter:focus-within {
  border-color: rgba(34,211,238,0.5);
  background: rgba(255,255,255,0.07);
}

.predictive-filter__icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 0.8rem;
  color: rgb(148, 163, 184);
}

.predictive-filter__input {
  width: 100%;
  min-height: 44px;
  border: 0 !important;
  background: transparent !important;
  color: rgb(248, 250, 252) !important;
  padding: 0.6rem 2.5rem 0.6rem 2.2rem !important;
  font-size: 0.875rem;
  outline: none !important;
  box-shadow: none !important;
}

.predictive-filter__input::placeholder {
  color: rgb(100, 116, 139);
}

.predictive-filter__clear {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 0.75rem;
  background: transparent;
  color: rgb(148, 163, 184);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, opacity 0.18s ease;
}

.predictive-filter__clear:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.predictive-filter__clear[data-empty="true"] {
  opacity: 0.35;
  pointer-events: none;
}

/* ── Native select dropdown readability ────────────────────────── */
select {
  color-scheme: dark;
}

select option,
select optgroup {
  background: rgb(15, 23, 42);
  color: rgb(248, 250, 252);
}

/* ── Line clamp ─────────────────────────────────────────────────── */
.line-clamp-2 {
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.line-clamp-3 {
  display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
}

/* ── Main action button ─────────────────────────────────────────── */
.main-action-btn:hover { box-shadow: 0 0 24px rgba(34, 211, 238, 0.2); }

/* ── Menu tiles ─────────────────────────────────────────────────── */
.menu-tile { position: relative; min-height: 120px; }
.menu-tile:hover {
  box-shadow: 0 0 0 1px rgba(34,211,238,0.15), 0 4px 24px rgba(0,0,0,0.3);
}
@keyframes soon-pulse { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
.menu-tile .soon-badge { animation: soon-pulse 2.5s ease-in-out infinite; }

/* ── Table row hover ────────────────────────────────────────────── */
table tbody tr { transition: background 0.15s ease; }

/* ── Touch-friendly action buttons ─────────────────────────────── */
@media (hover: none), (max-width: 640px) {
  table tbody tr .flex { opacity: 1 !important; }
}

/* ── Resizable column handles ───────────────────────────────────── */
.col-resize-handle { touch-action: none; }
body.col-resizing * {
  user-select: none !important;
  -webkit-user-select: none !important;
}

/* ══════════════════════════════════════════════════════════════════
   SCROLL-КОНТЕЙНЕРЫ ДЛЯ ТАБЛИЦ
   ══════════════════════════════════════════════════════════════════
   Каждый контейнер таблицы должен иметь overflow:auto по обеим осям
   и ограниченную высоту — тогда sticky thead/tfoot работают корректно.
   Все sticky-ячейки получают непрозрачный фон через JS (frozen-table.js)
   или через CSS-правила ниже.
*/

/* Универсальный класс для обёртки таблицы */
.tbl-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 62vh;
  border-radius: 0.75rem;
  border: 1px solid rgba(255,255,255,0.1);
  scrollbar-gutter: stable;
}

/* ── Контейнеры конкретных таблиц ──────────────────────────────── */

/* Каталог */
#catalogTableWrap > div {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 62vh;
  scrollbar-gutter: stable;
}

/* Контракты — таблица позиций */
#contractItemsWrap > div {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 55vh;
  scrollbar-gutter: stable;
}

/* Заявки — таблица позиций */
#orderItemsWrap > div {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 55vh;
  scrollbar-gutter: stable;
}

#orderItemsWrap2 {
  overflow-x: scroll !important;
  overflow-y: auto;
  max-height: 68vh;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6rem;
}

#orderItemsWrap2::-webkit-scrollbar {
  width: 8px;
  height: 10px;
}

#orderItemsWrap2::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
}

#orderItemsWrap2::-webkit-scrollbar-thumb {
  background: rgba(148,163,184,0.35);
  border-radius: 6px;
}

#orderItemsWrap2::-webkit-scrollbar-thumb:hover {
  background: rgba(148,163,184,0.55);
}

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

.segmented-btn {
  min-height: 46px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 0.9rem;
  background: rgba(255,255,255,0.04);
  color: rgb(203, 213, 225);
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.segmented-btn:hover {
  background: rgba(255,255,255,0.08);
  color: white;
}

.segmented-btn.active {
  background: rgba(34, 211, 238, 0.13);
  border-color: rgba(34, 211, 238, 0.45);
  color: rgb(165, 243, 252);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.12);
}

.order-delivery-card {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 1rem;
  background: rgba(255,255,255,0.04);
  padding: 0.9rem;
}

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

@media (max-width: 760px) {
  .segmented-toggle,
  .order-delivery-grid {
    grid-template-columns: 1fr;
  }
}

/* Склад */
#warehouseStockWrap > div.overflow-x-auto,
#whItemsSection > div.overflow-x-auto {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 60vh;
  scrollbar-gutter: stable;
}

/* Таблица отгрузки (разнарядка) */
#shipmentTableWrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 62vh;
  scrollbar-gutter: stable;
}

#shipmentTableWrap table thead th {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgb(15, 23, 42);
}

#shipmentTableWrap table tbody tr {
  background: rgb(2, 6, 23);
}

/* Матрица потребностей — занимает весь экран под шапкой и фильтрами */
#needsMatrixWrap {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

/* needs-table-area — flex-контейнер для scroll-обёртки таблицы */
#needsMatrixWrap .needs-table-area {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Единый scroll-контейнер матрицы: горизонтальный скроллбар ВСЕГДА виден (прикреплён снизу) */
#needsMatrixWrap .needs-table-area > div {
  flex: 1 1 0;
  min-height: 0;
  overflow-x: scroll !important;   /* всегда показывать горизонтальный скроллбар */
  overflow-y: auto;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

/* Webkit: горизонтальный скроллбар чуть толще для удобства */
#needsMatrixWrap .needs-table-area > div::-webkit-scrollbar {
  width: 6px;
  height: 10px;
}
#needsMatrixWrap .needs-table-area > div::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.04);
  border-radius: 5px;
}
#needsMatrixWrap .needs-table-area > div::-webkit-scrollbar-thumb {
  background: rgba(148,163,184,0.35);
  border-radius: 5px;
}
#needsMatrixWrap .needs-table-area > div::-webkit-scrollbar-thumb:hover {
  background: rgba(148,163,184,0.55);
}
#needsMatrixWrap .needs-table-area > div::-webkit-scrollbar-corner {
  background: transparent;
}

#needsMatrixWrap > div.overflow-auto {
  overflow-x: scroll;
  overflow-y: auto;
  flex: 1 1 0;
  min-height: 0;
  max-height: calc(100vh - 200px);
  scrollbar-gutter: stable;
}
/* Группированный режим: каждая секция */
#needsMatrixWrap > .space-y-6 {
  overflow-y: auto;
  flex: 1 1 0;
  min-height: 0;
  max-height: calc(100vh - 200px);
}

/* ── Needs Matrix: sticky thead rows ───────────────────────────── */
/*
   Sticky управляется из JS (needs-matrix-view.js):
   — thead: position:sticky; top:0; z-index:18
   — row1 th (rowspan=4): z-index:22, sticky left
   — row2 tr: top:36px, z-index:17; td bg: rgb(11,17,34)
   — row3 tr: top:60px, z-index:17; td bg: rgb(9,14,28)
   — row4 tr: top:84px, z-index:17; td bg: rgb(15,23,42)
   CSS задаёт только фон строк tbody и опорные фоны th row1.
*/
#needsMatrixWrap table thead tr:nth-child(1) th {
  background: rgb(15, 23, 42);
}
/* Row 4 — строка итогов: нижняя граница */
#needsMatrixWrap table thead tr:nth-child(4) td {
  border-bottom: 2px solid rgba(255,255,255,0.2);
}

/* Таблица потребностей в карточке получателя */
#needsTableWrap {
  overflow-x: scroll !important;
  overflow-y: auto;
  max-height: 55vh;
  scrollbar-gutter: stable;
  /* Всегда показывать горизонтальный скроллбар */
  scrollbar-width: auto;
}
/* Webkit: принудительно показываем горизонтальный скроллбар */
#needsTableWrap::-webkit-scrollbar {
  width: 6px;
  height: 8px;  /* чуть толще для горизонтального */
}
#needsTableWrap::-webkit-scrollbar-track { background: rgba(255,255,255,0.04); border-radius: 4px; }
#needsTableWrap::-webkit-scrollbar-thumb { background: rgba(148,163,184,0.3); border-radius: 4px; }
#needsTableWrap::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,0.5); }
#needsTableWrap::-webkit-scrollbar-corner { background: transparent; }

/* ── Sticky thead — работает только внутри overflow-контейнера ─── */
/*
   ВАЖНО: background на th должен быть непрозрачным.
   Tailwind-класс bg-slate-900 = rgb(15,23,42) — используем его.
   Также задаём через inline-style в frozen-table.js для динамических таблиц.
*/

#catalogTableWrap table thead th,
#contractItemsWrap table thead th,
#orderItemsWrap table thead th,
#warehouseStockWrap table thead th,
#needsTableWrap table thead th,
#needsTableWrap thead th,
#whItemsSection table thead th,
.tbl-scroll table thead th,
.sticky-thead thead th {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgb(15, 23, 42);   /* slate-900 — непрозрачный! */
}
/* needsMatrixWrap: sticky управляется через nth-child выше */

/* ── Sticky tfoot (итоги) ───────────────────────────────────────── */
#contractItemsWrap table tfoot td,
#orderItemsWrap table tfoot td,
.tbl-scroll table tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 15;
  background: rgb(15, 23, 42);
}

/* ── Фон строк tbody — нужен чтобы sticky-ячейки не просвечивали ─ */
#catalogTableWrap table tbody tr,
#contractItemsWrap table tbody tr,
#orderItemsWrap table tbody tr,
#warehouseStockWrap table tbody tr,
#needsMatrixWrap table tbody tr,
#needsTableWrap table tbody tr,
#needsTableWrap tbody tr,
.tbl-scroll table tbody tr {
  background: var(--tbl-bg);
}

/* ── Resizable table (#itemsTable в контрактах) ─────────────────── */
/* overflow:visible на th нужен для resize-handle */
#itemsTable thead th { overflow: visible !important; }
#itemsTable td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#itemsTable td.name-cell { overflow: visible !important; }

/* ── Подсказка о правом клике ───────────────────────────────────── */
/* Показываем tooltip при наведении на th таблиц с frozen-manager */
[data-frozen-key] thead th:first-child::after {
  content: '';
}
[data-frozen-key] thead th {
  cursor: context-menu;
}

/* ══════════════════════════════════════════════════════════════════
   PADDING-BOTTOM ДЛЯ СКРОЛЛА ТАБЛИЦ
   ══════════════════════════════════════════════════════════════════
   Чтобы последняя строка не перекрывалась индикатором синхронизации
   (position:fixed bottom:1.25rem) и другими fixed-элементами,
   добавляем padding-bottom к scroll-контейнерам таблиц.
   Используем псевдо-элемент ::after на tbody — работает в overflow-контейнерах.
*/

/* Универсальный отступ снизу для всех scroll-таблиц */
.tbl-scroll,
#catalogTableWrap > div,
#contractItemsWrap > div,
#orderItemsWrap > div,
#warehouseStockWrap > div.overflow-x-auto,
#whItemsSection > div.overflow-x-auto,
#shipmentTableWrap,
#needsMatrixWrap > div.overflow-auto,
#needsTableWrap,
#rptScrollBox {
  padding-bottom: 3rem;
}

/* Отчёты — единый scroll-контейнер с синхронным горизонтальным скроллом */
#rptScrollBox {
  overflow-x: auto;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

/* thead sticky задаётся inline из JS (точный top для 2-й строки) */
#rptScrollBox table thead th,
#rptScrollBox table thead td {
  position: sticky;
  top: 0;
  z-index: 20;
}

#rptScrollBox table tbody tr {
  background: rgb(2, 6, 23);
}

/* ── Receiving / inspection schedule layout fixes ───────────────── */
.receiving-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
}

.receiving-schedule-wrap {
  min-width: 0;
}

.receiving-schedule-table td,
.receiving-schedule-table th {
  vertical-align: top;
}

.receiving-schedule-table td > div,
.receiving-schedule-table td > span,
.receiving-schedule-table td button,
.receiving-schedule-table td textarea,
.receiving-schedule-table td input,
.receiving-schedule-table td select {
  max-width: 100%;
}

.receiving-schedule-table textarea {
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .receiving-modal-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .receiving-modal-actions > button {
    width: 100%;
    justify-content: center;
  }
}

/* ── Receiving / inspection / act-form fallback layout ─────────── */
.receiving-main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.receiving-main-card {
  width: 100%;
  min-height: 150px;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  border-radius: 1rem;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  padding: 1.4rem;
  color: rgb(248,250,252);
  text-align: left;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
  box-sizing: border-box;
}

.receiving-main-card:hover {
  background: rgba(255,255,255,0.09);
  border-color: rgba(34,211,238,0.3);
}

.receiving-main-card:active {
  transform: scale(0.98);
}

.receiving-main-card__icon {
  font-size: 2.15rem;
  line-height: 1;
  flex: 0 0 auto;
  margin-top: 0.125rem;
}

.receiving-main-card__body {
  flex: 1 1 auto;
  min-width: 0;
}

.receiving-main-card__title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.receiving-main-card__title {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.35;
  font-weight: 700;
  color: rgb(255,255,255);
}

.receiving-main-card__text {
  margin: 0.35rem 0 0;
  font-size: 0.84rem;
  line-height: 1.45;
  color: rgb(148,163,184);
}

.receiving-main-card__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  border-radius: 0.7rem;
  background: rgba(34,211,238,0.15);
  padding: 0.15rem 0.5rem;
  font-size: 0.68rem;
  line-height: 1;
  font-weight: 700;
  color: rgb(34,211,238);
}

.receiving-main-card__arrow {
  flex: 0 0 auto;
  margin-top: 0.2rem;
  color: rgb(100,116,139);
  transition: color 0.18s ease;
}

.receiving-main-card:hover .receiving-main-card__arrow {
  color: rgb(34,211,238);
}

/* ── Global collapsible sections ──────────────────────────────── */
.app-collapsible {
  position: relative;
}

.app-collapsible-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.025);
  flex: 0 0 auto;
}

.catalog-panel > .app-collapsible-toolbar {
  padding-left: 1rem;
  padding-right: 1rem;
}

.app-collapsible-toolbar__btn {
  min-height: 38px;
  padding: 0.55rem 0.9rem;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 0.85rem;
  background: rgba(255,255,255,0.04);
  color: rgb(203, 213, 225);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.app-collapsible-toolbar__btn:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(34,211,238,0.3);
  color: rgb(165, 243, 252);
}

.app-collapsible-toolbar__btn:active {
  transform: scale(0.97);
}

.app-collapsible__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.app-collapsible[data-collapsed="true"] .app-collapsible__header {
  margin-bottom: 0;
}

.app-collapsible__header > h1,
.app-collapsible__header > h2,
.app-collapsible__header > h3,
.app-collapsible__header > h4,
.app-collapsible__header > h5,
.app-collapsible__header > h6,
.app-collapsible__header > [data-collapsible-heading] {
  margin: 0 !important;
  min-width: 0;
  flex: 1 1 auto;
}

.app-collapsible__toggle {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0.45rem 0.75rem;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 0.85rem;
  background: rgba(255,255,255,0.04);
  color: rgb(148, 163, 184);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.app-collapsible__toggle:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(34,211,238,0.3);
  color: rgb(165, 243, 252);
}

.app-collapsible__toggle:active {
  transform: scale(0.97);
}

.app-collapsible__icon {
  font-size: 0.9rem;
  line-height: 1;
}

.app-collapsible__body[hidden] {
  display: none !important;
}

@media (max-width: 640px) {
  .app-collapsible__header {
    align-items: flex-start;
    flex-direction: column;
  }

  .app-collapsible__toggle {
    width: 100%;
    justify-content: center;
  }
}

.inspection-schedule-filters-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.inspection-schedule-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#actBasicFieldsWrap .act-basic-grid,
#actSupplierNoticeWrap .act-supplier-notice-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

#actBasicFieldsWrap .sm\:col-span-2 {
  grid-column: 1 / -1;
}

#actMediaWrap .act-media-photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

#actMediaWrap .act-media-video-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .receiving-main-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #actBasicFieldsWrap .act-basic-grid,
  #actSupplierNoticeWrap .act-supplier-notice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #actMediaWrap .act-media-photo-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #actMediaWrap .act-media-video-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 768px) {
  .inspection-schedule-filters-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .receiving-main-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1280px) {
  .inspection-schedule-filters-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* ── Разбор ТХ: isolated reports ─────────────────────────────── */
.th-analysis-panel { background: rgb(2, 6, 23); }
.th-summary-card { display:flex; align-items:center; gap:.7rem; }
.th-summary-icon { font-size:1.55rem; }
.th-summary-card strong { display:block; color:#f8fafc; font-size:.9rem; }
.th-summary-card span:last-child { display:block; color:rgb(100,116,139); font-size:.7rem; margin-top:.15rem; }
.th-status { color:rgb(148,163,184); }
.th-status.success { color:rgb(74,222,128); }
.th-status.error { color:rgb(251,146,60); }
.th-report-list { display:flex; flex-direction:column; gap:1rem; max-width:1100px; margin:0 auto; }
.th-report-section { overflow:hidden; border:1px solid rgba(255,255,255,.09); border-radius:1rem; background:rgba(255,255,255,.035); }
.th-section-heading { display:flex; align-items:center; justify-content:space-between; gap:1rem; padding:1rem 1.1rem; border-bottom:1px solid rgba(255,255,255,.08); background:rgba(245,158,11,.045); }
.th-section-kicker { display:block; color:rgb(245,158,11); font-size:.65rem; font-weight:700; letter-spacing:.12em; text-transform:uppercase; }
.th-section-heading h3 { margin:.18rem 0 0; color:#f8fafc; font-size:.92rem; line-height:1.35; }
.th-total-badge { flex:0 0 auto; border:1px solid rgba(245,158,11,.2); border-radius:.7rem; background:rgba(245,158,11,.1); padding:.35rem .65rem; color:rgb(253,230,138); font-size:.7rem; font-weight:700; white-space:nowrap; }
.th-table-wrap { overflow-x:auto; }
.th-table-wrap table { width:100%; min-width:560px; border-collapse:collapse; font-size:.78rem; }
.th-table-wrap th { padding:.65rem .8rem; color:rgb(148,163,184); background:rgb(15,23,42); border-bottom:1px solid rgba(255,255,255,.1); text-align:left; font-size:.66rem; font-weight:700; text-transform:uppercase; letter-spacing:.06em; }
.th-table-wrap td { padding:.62rem .8rem; color:rgb(226,232,240); border-bottom:1px solid rgba(255,255,255,.055); vertical-align:top; }
.th-table-wrap tr:last-child td { border-bottom:0; }
.th-table-wrap tbody tr:hover td { background:rgba(245,158,11,.045); }
.th-table-wrap th:first-child, .th-table-wrap td:first-child { width:3rem; color:rgb(100,116,139); }
.th-number { width:8rem; color:rgb(253,230,138) !important; font-weight:700; text-align:right; }
.th-empty-state { display:flex; align-items:center; flex-direction:column; gap:.5rem; padding:5rem 1rem; text-align:center; color:rgb(148,163,184); }
.th-empty-state span { font-size:2.5rem; }
.th-empty-state strong { color:#f8fafc; font-size:.95rem; }
.th-empty-state p { margin:0; color:rgb(100,116,139); font-size:.78rem; }
@media (max-width:640px) {
  .th-section-heading { align-items:flex-start; flex-direction:column; }
  .th-total-badge { align-self:flex-start; }
  .th-report-panel input { min-width:0; width:100%; }
}

/* ── Разбор ТХ: экранная таблица помещений/товаров ───────────── */
.th-print-title { display:none; }
.th-room-line {
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:.75rem;
  margin:.15rem 0;
}
.th-room-line span { min-width:0; }
.th-room-line strong { flex:0 0 auto; color:rgb(253,230,138); white-space:nowrap; }
.th-products-section .th-table-wrap table { min-width:760px; }
.th-products-section .th-table-wrap td:last-child { min-width:320px; }

/* Браузерная печать: в диалоге печати пользователь выбирает «Сохранить в PDF». */
@media print {
  body.th-print-mode {
    background:#fff !important;
    color:#111 !important;
  }
  body.th-print-mode > *:not(#appRoot) { display:none !important; }
  body.th-print-mode #appRoot > *:not(#thAnalysisModal) { display:none !important; }
  body.th-print-mode #thAnalysisModal {
    position:static !important;
    display:block !important;
    inset:auto !important;
    opacity:1 !important;
    pointer-events:auto !important;
    background:#fff !important;
  }
  body.th-print-mode #thAnalysisModal > .th-analysis-panel {
    display:flex !important;
    position:static !important;
    width:100% !important;
    height:auto !important;
    min-height:0 !important;
    overflow:visible !important;
    background:#fff !important;
    color:#111 !important;
  }
  body.th-print-mode #thAnalysisHeader,
  body.th-print-mode #thReportToolbar,
  body.th-print-mode #thReportTabsBar,
  body.th-print-mode #thInputPanel { display:none !important; }
  body.th-print-mode #thReportPanel {
    display:block !important;
    overflow:visible !important;
    min-height:0 !important;
    background:#fff !important;
  }
  body.th-print-mode #thPrintTitle {
    display:block !important;
    padding:0 0 12pt;
    color:#111 !important;
    font-family:Arial,sans-serif;
    font-size:16pt;
    font-weight:700;
    text-align:center;
  }
  body.th-print-mode #thReportWrap {
    display:block !important;
    overflow:visible !important;
    padding:0 !important;
    color:#111 !important;
  }
  body.th-print-mode .th-report-list {
    display:block !important;
    max-width:none !important;
    margin:0 !important;
  }
  body.th-print-mode .th-report-section {
    overflow:visible !important;
    border:1px solid #333 !important;
    border-radius:0 !important;
    background:#fff !important;
    color:#111 !important;
    break-inside:avoid;
  }
  body.th-print-mode .th-rooms-report .th-report-section {
    break-after:page;
    page-break-after:always;
    min-height:245mm;
  }
  body.th-print-mode .th-rooms-report .th-report-section:last-child {
    break-after:auto;
    page-break-after:auto;
  }
  body.th-print-mode .th-section-heading {
    padding:8pt 10pt;
    border-bottom:1px solid #333 !important;
    background:#f2f2f2 !important;
  }
  body.th-print-mode .th-section-kicker,
  body.th-print-mode .th-section-heading h3,
  body.th-print-mode .th-total-badge,
  body.th-print-mode .th-table-wrap th,
  body.th-print-mode .th-table-wrap td,
  body.th-print-mode .th-number,
  body.th-print-mode .th-room-line strong {
    color:#111 !important;
  }
  body.th-print-mode .th-total-badge {
    border:0 !important;
    background:transparent !important;
    padding:0 !important;
  }
  body.th-print-mode .th-table-wrap { overflow:visible !important; }
  body.th-print-mode .th-table-wrap table,
  body.th-print-mode .th-products-section .th-table-wrap table {
    width:100% !important;
    min-width:0 !important;
    border-collapse:collapse;
    font-family:Arial,sans-serif;
    font-size:9pt;
  }
  body.th-print-mode .th-table-wrap thead { display:table-header-group; }
  body.th-print-mode .th-table-wrap th,
  body.th-print-mode .th-table-wrap td {
    padding:5pt 6pt;
    border:1px solid #777 !important;
    background:#fff !important;
    vertical-align:top;
    text-align:left;
  }
  body.th-print-mode .th-table-wrap th {
    background:#e8e8e8 !important;
    font-size:8pt;
    text-transform:none;
    letter-spacing:0;
  }
  body.th-print-mode .th-table-wrap th:first-child,
  body.th-print-mode .th-table-wrap td:first-child { width:8mm; }
  body.th-print-mode .th-table-wrap .th-number { width:25mm; text-align:right; }
  /* Печатный отчёт «По товарам»: основной размер — 14 pt. */
  body.th-print-mode .th-products-report,
  body.th-print-mode .th-products-report .th-section-kicker,
  body.th-print-mode .th-products-report .th-section-heading h3,
  body.th-print-mode .th-products-report .th-total-badge,
  body.th-print-mode .th-products-report .th-table-wrap table,
  body.th-print-mode .th-products-report .th-table-wrap th,
  body.th-print-mode .th-products-report .th-table-wrap td,
  body.th-print-mode .th-products-report .th-room-line,
  body.th-print-mode .th-products-report .th-room-line strong {
    font-size: 14pt !important;
  }

  /* Правый столбец занимает всё оставшееся место до края страницы. */
  body.th-print-mode .th-products-section .th-table-wrap table {
    width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed !important;
    margin-right: 0 !important;
  }
  body.th-print-mode .th-products-section .th-table-wrap th:nth-child(1),
  body.th-print-mode .th-products-section .th-table-wrap td:nth-child(1) { width: 8mm; }
  body.th-print-mode .th-products-section .th-table-wrap th:nth-child(2),
  body.th-print-mode .th-products-section .th-table-wrap td:nth-child(2) { width: 65mm; }
  body.th-print-mode .th-products-section .th-table-wrap th:nth-child(3),
  body.th-print-mode .th-products-section .th-table-wrap td:nth-child(3) { width: 18mm; }
  body.th-print-mode .th-products-section .th-table-wrap th:nth-child(4),
  body.th-print-mode .th-products-section .th-table-wrap td:nth-child(4) { width: 25mm; }
  body.th-print-mode .th-products-section .th-table-wrap th:nth-child(5),
  body.th-print-mode .th-products-section .th-table-wrap td:nth-child(5) {
    width: auto !important;
    min-width: 0 !important;
  }

  body.th-print-mode .th-room-line { margin:0; }
  body.th-print-mode .th-empty-state { color:#111 !important; }
  @page { size:A4 portrait; margin:12mm; }
}

/* ── Разбор ТХ: восстановленные по аналогии данные ─────────────── */
.th-recovered-room {
  border-color: rgba(245, 158, 11, 0.58) !important;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.12), 0 8px 24px rgba(245, 158, 11, 0.08);
}

.th-recovery-note {
  margin-top: 0.45rem;
  color: rgb(253, 230, 138);
  font-size: 0.72rem;
  line-height: 1.4;
  font-weight: 700;
}

.th-recovered-row > td {
  background: rgba(245, 158, 11, 0.12) !important;
  color: rgb(254, 243, 199) !important;
}

.th-recovered-line {
  margin: 0.12rem -0.3rem;
  border-radius: 0.45rem;
  background: rgba(245, 158, 11, 0.13);
  padding: 0.14rem 0.3rem;
}

@media print {
  .th-recovered-room {
    border-color: #b77900 !important;
    box-shadow: none !important;
  }

  .th-recovery-note {
    color: #7a4b00 !important;
  }

  body.th-print-mode .th-recovered-row > td,
  body.th-print-mode .th-recovered-line {
    background: #fff3cd !important;
    color: #111 !important;
  }

  /* В печатном отчёте «По помещениям» основной текст — 18 pt. */
  body.th-print-mode .th-rooms-report,
  body.th-print-mode .th-rooms-report .th-section-kicker,
  body.th-print-mode .th-rooms-report .th-section-heading h3,
  body.th-print-mode .th-rooms-report .th-total-badge,
  body.th-print-mode .th-rooms-report .th-recovery-note,
  body.th-print-mode .th-rooms-report .th-table-wrap table,
  body.th-print-mode .th-rooms-report .th-table-wrap th,
  body.th-print-mode .th-rooms-report .th-table-wrap td,
  body.th-print-mode .th-rooms-report .th-number {
    font-size: 18pt !important;
  }

  /* Номер помещения в печатной версии — крупный заголовок 40 pt. */
  body.th-print-mode .th-rooms-report .th-section-kicker {
    font-size: 40pt !important;
    line-height: 1.05 !important;
  }
}
