/* Вкладка «Товары» сделки у закупщика (Семён 2026-10-06), модуль deal-goods.js.
   Цвета — только переменные палитры :root (style.css): тёмная и светлая темы. */

.gd-root .gd-title { margin-top: 0; font-size: 1.2rem; }
.gd-sub { margin: 0 0 var(--space-4); }

/* три цифры сверху: всего · с образцом · готовы к передаче */
.gd-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3); margin-bottom: var(--space-4); }
.gd-stat { display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border: 1px solid var(--surface-2);
  border-radius: 12px; }
.gd-stat-icon { display: inline-flex; align-items: center; justify-content: center;
  flex: none; width: 42px; height: 42px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); }
.gd-stat-icon .gd-glyph { width: 22px; height: 22px; }
.gd-stat--ok .gd-stat-icon { color: var(--ok);
  background: color-mix(in srgb, var(--ok) 16%, transparent); }
.gd-stat--accent .gd-stat-icon { color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent); }
.gd-stat-text { display: flex; flex-direction: column; min-width: 0; }
.gd-stat-num { font-size: 1.45rem; line-height: 1.1; }
.gd-stat-label { color: var(--muted); font-size: .85rem; }

/* поиск, фильтры и «+ Добавить товар» одной строкой */
.gd-toolbar { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center;
  margin-bottom: var(--space-4); }
.gd-toolbar input.gd-search { flex: 1 1 220px; width: auto; margin: 0; padding: 8px 12px;
  font-size: .92rem; }
.gd-toolbar select.gd-select { flex: 0 0 auto; width: auto; margin: 0; padding: 8px 10px;
  font-size: .92rem; }
.gd-toolbar .gd-add { margin-left: auto; white-space: nowrap; padding: 9px 16px; }

.gd-hint { display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3); border: 1px dashed var(--border); border-radius: 10px;
  font-size: .9rem; color: var(--muted); }
.gd-empty { padding: var(--space-5) var(--space-3); text-align: center; }
.gd-empty p { margin: 0 0 var(--space-2); }
.gd-foot { margin: var(--space-3) 0 0; }

/* карточка — как строка расчёта в окне виджета (Семён 2026-10-08): фото · название и
   состояние · действия, под названием — тиражи во всю ширину, ниже — файлы товара. На
   широком экране тиражи встают в строку с названием, как в виджете: шесть колонок с
   себестоимостью рядом с названием влезают только от ~1150 px. */
.gd-list { display: flex; flex-direction: column; gap: var(--space-3);
  container-type: inline-size; }
.gd-card { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto;
  grid-template-areas: "photo main actions" "photo tiers tiers" "files files files";
  gap: var(--space-2) var(--space-3); align-items: start; padding: var(--space-3);
  border: 1px solid var(--surface-2); border-radius: 12px; }
@container (min-width: 1150px) {
  .gd-card { grid-template-columns: 120px minmax(240px, 360px) minmax(0, 1fr) auto;
    grid-template-areas: "photo main tiers actions" "photo files files files"; }
}
.gd-card--kit { border-color: color-mix(in srgb, var(--accent) 45%, var(--surface-2));
  background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }

button.gd-photo { grid-area: photo; position: relative; display: flex; align-items: center;
  justify-content: center; width: 120px; height: 100px; padding: 0; border: 0;
  border-radius: 10px; background: var(--surface-2); overflow: hidden; cursor: pointer; }
button.gd-photo:hover { filter: none; outline: 2px solid var(--accent); outline-offset: 1px; }
.gd-photo img, .gd-panel-photo img, .gd-part-photo img, .gd-strip-item img {
  width: 100%; height: 100%; object-fit: contain; display: block; }
.gd-photo-count { position: absolute; left: 6px; bottom: 6px; padding: 1px 6px;
  border-radius: 6px; background: color-mix(in srgb, var(--surface) 85%, transparent);
  color: var(--text); font-size: .72rem; }
.gd-nophoto { display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; color: var(--muted); font-size: .8rem; }
.gd-nophoto-icon { width: 44px; height: 44px; }

.gd-main { grid-area: main; min-width: 0; }
.gd-name { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.gd-name .gd-glyph { width: 20px; height: 20px; color: var(--accent); }
button.gd-name-btn { padding: 0; border: 0; border-radius: 0; background: none; color: var(--text);
  font-size: 1rem; font-weight: 650; line-height: 1.3; text-align: left; overflow: hidden;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
button.gd-name-btn:hover { filter: none; color: var(--accent); }
.gd-pill { padding: 1px 8px; border-radius: 999px; font-size: .76rem; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent); }
.gd-badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.gd-badges:empty { display: none; }
.gd-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px;
  border-radius: 999px; font-size: .78rem; font-weight: 600; }
.gd-badge .gd-glyph { width: 14px; height: 14px; }
.gd-badge--ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 15%, transparent); }
.gd-badge--info { color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent); }
.gd-desc { margin: 4px 0; font-size: .88rem; overflow-wrap: break-word; }
.gd-fact { white-space: nowrap; }
.gd-part-facts { margin: 0; }
.gd-origin { margin: 0 0 var(--space-1); }
/* «В заказе: 3 000 шт по 120,00 ₽» — что менеджер продал */
.gd-order { display: inline-flex; align-items: center; gap: 4px; margin: 0; padding: 2px 9px;
  border-radius: 999px; color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent);
  font-size: .8rem; font-weight: 600; }
.gd-order .gd-glyph { flex: none; width: 14px; height: 14px; }

/* тиражи: таблица, как в окне расчёта виджета; тираж из заказа подсвечен */
.gd-tiers { grid-area: tiers; min-width: 0; }
.gd-tier-wrap { overflow-x: auto; }
.gd-tier-table { width: 100%; border: 1px solid var(--surface-2); border-radius: 8px;
  border-collapse: separate; border-spacing: 0; font-size: .84rem;
  font-variant-numeric: tabular-nums; }
.gd-tier-table th { padding: 6px 10px; border-bottom: 1px solid var(--surface-2);
  color: var(--muted); font-size: .76rem; font-weight: 400; text-align: left; white-space: nowrap; }
.gd-tier-table td { padding: 6px 10px; border-top: 1px solid var(--surface-2); white-space: nowrap; }
.gd-tier-table tbody tr:first-child td { border-top: 0; }
.gd-tier--ordered td { background: color-mix(in srgb, var(--ok) 8%, transparent); }
.gd-tier-profit { color: var(--ok); font-weight: 600; }
.gd-tier-profit.loss { color: var(--error); }
.gd-tier-none { color: var(--muted); }
.gd-tier-note { margin-left: 6px; padding: 0 5px; border-radius: 4px; background: var(--surface-2);
  color: var(--muted); font-size: .7rem; }
.gd-tier-note--order { color: var(--ok); background: color-mix(in srgb, var(--ok) 15%, transparent); }
.gd-tiers-none { margin: 0; padding: var(--space-2) var(--space-3); border: 1px dashed var(--border);
  border-radius: 8px; color: var(--muted); font-size: .85rem; }

.gd-actions { grid-area: actions; display: flex; align-items: center; gap: var(--space-2); }
button.gd-open { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
button.gd-open .gd-glyph { width: 16px; height: 16px; }
.gd-more { position: relative; }
button.gd-more-btn { padding: 6px 14px; letter-spacing: .1em; }
.gd-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 240px;
  padding: 6px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); box-shadow: 0 10px 24px rgba(0, 0, 0, .25); }
.gd-menu button { width: 100%; text-align: left; background: transparent; color: var(--text);
  font-weight: 400; border-radius: 8px; padding: 8px 10px; }
.gd-menu button:hover:not(:disabled) { filter: none; background: var(--surface-2); }

/* файлы товара: миниатюра слева открывает файл, справа — «Скачать» */
.gd-files { grid-area: files; display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.gd-file { display: flex; align-items: center; gap: var(--space-2); flex: 0 1 400px; min-width: 0;
  max-width: 100%; padding: 4px; border: 1px solid var(--surface-2); border-radius: 10px; }
.gd-file--draft { border-style: dashed; }
button.gd-file-thumb { flex: none; display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0; border: 0; border-radius: 7px;
  background: var(--surface-2); overflow: hidden; }
button.gd-file-thumb:hover { filter: none; outline: 2px solid var(--accent); }
.gd-file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gd-file-ext { color: var(--muted); font-size: .66rem; font-weight: 700; letter-spacing: .02em; }
.gd-file-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.gd-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; }
/* вид файла и откуда он — до двух строк: «Исходник макета для производства · Заявка
   на образцы №5» не должен обрываться на полуслове */
.gd-file-meta { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; }
button.gd-file-dl { flex: none; display: inline-flex; padding: 6px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); }
button.gd-file-dl:hover { filter: none; color: var(--accent); background: var(--surface-2); }
.gd-file-dl .gd-glyph { width: 18px; height: 18px; }
.gd-files--all { flex-direction: column; align-items: stretch; }
.gd-files--all .gd-file { flex: none; }
.gd-files-more { margin-left: 0; }

/* состав комплекта — раскрывается под карточкой */
.gd-kit { grid-column: 1 / -1; border-top: 1px solid var(--surface-2);
  padding-top: var(--space-2); }
.gd-kit summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .9rem; }
.gd-part { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) 0;
  border-bottom: 1px solid var(--surface-2); }
.gd-part:last-child { border-bottom: 0; }
.gd-part-photo { flex: none; width: 64px; height: 56px; border-radius: 8px; overflow: hidden;
  background: var(--surface-2); display: flex; align-items: center; justify-content: center; }
.gd-part-photo .gd-nophoto-icon { width: 26px; height: 26px; }
.gd-part-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.gd-part-name { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

/* правая карточка товара: фото и выбор главного, параметры, тиражи, файлы. Шире панели
   она не растёт: таблица тиражей прокручивается внутри */
.gd-panel, .gd-panel-block { min-width: 0; max-width: 100%; }
.gd-panel-photo { height: 240px; border-radius: 12px; background: var(--surface-2);
  overflow: hidden; display: flex; align-items: center; justify-content: center; }
.gd-gallery { margin-top: var(--space-2); }
.gd-strip { display: flex; gap: 6px; overflow-x: auto; padding: 2px; }
.gd-strip:empty { display: none; }
button.gd-strip-item { flex: none; width: 56px; height: 56px; padding: 0; border: 0;
  border-radius: 8px; background: var(--surface-2); overflow: hidden; }
button.gd-strip-item:hover { filter: none; outline: 2px solid var(--accent); }
button.gd-strip-item--main { outline: 2px solid var(--ok); }
button.gd-strip-item--on { outline: 2px solid var(--accent); }
/* под фото: «Загрузить фото», «Сделать главным», «Убрать» — одной строкой */
.gd-photo-acts { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.gd-photo-acts button.mini { margin-left: 0; }
.gd-panel-name { margin: var(--space-3) 0 0; font-size: 1.1rem; }
.gd-panel .gd-order { margin-top: var(--space-1); }
.gd-panel-block h4 { margin: var(--space-3) 0 4px; font-size: .92rem; }
.gd-pairs { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 4px var(--space-3);
  margin: 0; font-size: .9rem; }
.gd-pairs dt { color: var(--muted); }
.gd-pairs dd { margin: 0; overflow-wrap: anywhere; }
/* в панели шесть колонок тиражей — плотнее, заголовки в две строки */
.gd-panel .gd-tier-table { font-size: .8rem; }
.gd-panel .gd-tier-table th { white-space: normal; vertical-align: bottom; }
.gd-panel .gd-tier-table th, .gd-panel .gd-tier-table td { padding: 5px 6px; }
.gd-panel-uploads { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.gd-panel-uploads button.mini { margin-left: 0; }
.gd-panel .gd-panel-actions { flex-wrap: wrap; margin-top: var(--space-4);
  border-top: 1px solid var(--surface-2); padding-top: var(--space-3); }

/* «Открыть расчёты»: расчёт одного товара */
.gd-calc-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--space-2); margin-bottom: var(--space-2); }
.gd-calc-item { margin: var(--space-4) 0 var(--space-1); font-size: .98rem; }
.gd-table-wrap { overflow-x: auto; }
.gd-table td { white-space: nowrap; }
.gd-factory { display: flex; flex-direction: column; gap: 2px; white-space: normal;
  min-width: 160px; }

/* «+ Добавить товар»: товары расчётов других сделок клиента */
.gd-pick-group h3 { margin: var(--space-4) 0 var(--space-1); font-size: .95rem; }
label.gd-pick { display: flex; align-items: flex-start; gap: var(--space-2); margin: 0;
  padding: var(--space-2) 0; border-bottom: 1px solid var(--surface-2); color: var(--text);
  cursor: pointer; }
label.gd-pick input { margin-top: 3px; }
.gd-pick--off { opacity: .55; cursor: default; }
.gd-pick-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

@container (max-width: 700px) {
  .gd-card { grid-template-columns: 96px minmax(0, 1fr) auto;
    grid-template-areas: "photo main actions" "tiers tiers tiers" "files files files"; }
  button.gd-photo { width: 96px; height: 80px; }
}
@container (max-width: 520px) {
  .gd-card { grid-template-columns: 72px minmax(0, 1fr);
    grid-template-areas: "photo main" "tiers tiers" "files files" "actions actions"; }
  button.gd-photo { width: 72px; height: 64px; }
  .gd-file { max-width: 100%; }
}
@media (max-width: 640px) {
  .gd-stats { grid-template-columns: 1fr; }
  .gd-toolbar .gd-add { margin-left: 0; }
}

/* «Назначить на фабрику» в себестоимости товара — во вкладке «Производство» */
.gd-pick { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center;
  margin-top: var(--space-3); }
.gd-pick button.mini { margin-left: 0; }
