/* Как в b2b-v24: table-layout auto + явные ширины колонок; «Наименование» тянется за счёт остальных */
.table-card {
  background: var(--card-bg); border: 1px solid var(--card-border);
  border-radius: 8px; box-shadow: var(--card-shadow); overflow: hidden;
  min-width: 0;
  max-width: 100%;
}
.table-scroll-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  min-width: 0;
  max-width: 100%;
}
@media (max-width: 600px) {
  .table-card { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 6px; }
  .table-card .data-table { min-width: 620px; width: 100%; }
  .right-col { min-width: 0; overflow-x: clip; }
  .main-grid { min-width: 0; }
}

/* sticky thead */
.data-table {
  width: 100%;
  max-width: 100%;
  table-layout: auto;
}
.data-table thead { position: sticky; top: 0; z-index: 5; }
.data-table thead th {
  padding: 12px 14px; text-align: left;
  font-size: 12px; font-weight: 500; color: var(--table-header);
  letter-spacing: 0.25px; border-bottom: 1px solid var(--table-border);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--card-bg);
}
.th-hash  {
  width: 44px;
  min-width: 44px;
  text-align: right !important;
  padding-left: 8px;
  padding-right: 10px;
}
.th-art   { min-width: 120px; width: 140px; }
/* Наименование: ограничиваем долю ширины таблицы + перенос в ячейках (см. td.col-name) */
.data-table thead th.th-name {
  padding-left: 8px;
  padding-right: 8px;
}
.th-name  {
  min-width: 120px;
  max-width: 52%;
  vertical-align: bottom;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
.th-vnd   { min-width: 90px; width: 110px; }
/* Без max-width колонка съедает свободную ширину таблицы (имя ограничено 52%), отсюда огромный зазор до «Действий» */
.th-dst,
.data-table tbody td.col-dist {
  width: 1%;
  min-width: 110px;
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.data-table tbody td.col-dist { color: var(--text-secondary); }
.th-qty   { min-width: 60px; width: 70px; text-align: right !important; white-space: nowrap; }
.th-prc   { min-width: 80px; width: 90px; text-align: right !important; white-space: nowrap; }
.th-rub   { min-width: 80px; width: 92px; text-align: right !important; white-space: nowrap; }
.th-trs   { min-width: 65px; width: 75px; text-align: right !important; white-space: nowrap; }
.th-wch   {
  width: 68px; min-width: 68px; max-width: 76px;
  padding: 0 6px !important;
  box-sizing: border-box;
  text-align: center;
  vertical-align: middle;
}
/* Как в строках: две «ячейки» по 22px (как кнопки watch/proj), иначе иконки в шапке визуально разъезжаются */
.th-wch-inner {
  display: grid;
  grid-template-columns: 22px 22px;
  gap: 3px;
  align-items: center;
  justify-items: center;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}
.th-wch-svg {
  width: 14px;
  height: 14px;
  display: block;
  flex-shrink: 0;
  color: var(--text-secondary);
}
[data-style="circle"] .th-hash { width: 52px; }
.col-hidden { display: none !important; }
.data-table tbody tr { border-bottom: 1px solid var(--table-border); transition: background 0.1s; }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--row-hover) !important; }
.data-table tbody tr:nth-child(odd)  { background: transparent; }
.data-table tbody tr:nth-child(even) { background: var(--row-alt); }
.data-table tbody td {
  padding: var(--row-pad-v, 11px) 14px; font-size: 13px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: padding 0.2s ease;
}
.data-table tbody td.copyable {
  cursor: pointer;
  user-select: none;
}
.data-table tbody td.col-name {
  max-width: 52%;
  min-width: 120px;
  padding-left: 8px;
  padding-right: 8px;
  white-space: normal !important;
  text-overflow: clip;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  line-height: 1.4;
  vertical-align: top;
  overflow: visible;
  hyphens: auto;
}
.data-table .col-name-ellipsis {
  display: block;
  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 100%;
}
.data-table tbody td.col-qty {
  text-align: right;
  color: var(--text-secondary);
}
.data-table tbody td.col-actions {
  white-space: nowrap;
  vertical-align: middle;
  padding: var(--row-pad-v, 11px) 6px;
}
.data-table .col-actions-inner {
  display: grid;
  grid-template-columns: 22px 22px;
  gap: 3px;
  align-items: center;
  justify-items: center;
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
  min-width: 0;
}
.data-table tbody td.col-hash {
  text-align: right;
  color: var(--text-secondary);
  font-size: 12px;
}
.data-table .col-actions-inner .watch-btn,
.data-table .col-actions-inner .proj-add-btn {
  flex: 0 0 auto;
}
/* density toggle buttons */
/* SORT PRICE BUTTON */
.sort-price-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--card-border);
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
  padding: 0;
  overflow: visible;
  box-sizing: border-box;
  line-height: 0;
}
.sort-price-btn:hover {
  background: var(--row-hover);
  color: var(--text);
}
.sort-price-btn:active { transform: scale(0.97); }
/* sort-price-btn always neutral, no active highlight — overflow:visible чтобы стрелка у края viewBox не обрезалась */
.sort-price-btn svg {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  overflow: visible;
  flex-shrink: 0;
  display: block;
  margin: 0;
  transform: translate(calc(-50% - 0.35px), -50%);
}
/* ASC state (default): показываем icon-asc, скрываем icon-desc */
.sort-price-btn .icon-asc  { display: block; }
.sort-price-btn .icon-desc { display: none; }
/* DESC state */
.sort-price-btn.desc .icon-asc  { display: none; }
.sort-price-btn.desc .icon-desc { display: block; }

.density-btns { display: flex; gap: 4px; flex-shrink: 0; }
.density-divider {
  width: 1px; height: 16px; background: var(--card-border);
  align-self: center; flex-shrink: 0; margin: 0 2px;
}
.col-vis-group { display: flex; align-items: center; gap: 6px; }
.col-vis-label {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 500; color: var(--text-secondary);
  cursor: pointer; user-select: none; white-space: nowrap;
  padding: 4px 2px;
}
.col-vis-label input[type="checkbox"] {
  display: block; width: 16px; height: 16px; border-radius: 4px;
  border: 1.5px solid var(--text-secondary); background: transparent;
  appearance: none; -webkit-appearance: none; cursor: pointer;
  position: relative; flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.col-vis-label input[type="checkbox"]:checked {
  background: #0078D4; border-color: #0078D4;
}
.col-vis-label input[type="checkbox"]:checked::after {
  content: ''; position: absolute;
  left: 50%; top: 50%;
  width: 9px; height: 5px;
  border-left: 1.5px solid #fff; border-bottom: 1.5px solid #fff;
  transform: translate(-50%, -60%) rotate(-45deg);
}
.density-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1px solid var(--card-border);
  background: transparent;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  padding: 0;
  margin: 0;
  line-height: 0;
  box-sizing: border-box;
  vertical-align: middle;
}
.density-btn.active { background: #0078D4; color: #fff; border-color: #0078D4; }
.density-btn:hover:not(.active) { background: var(--row-hover); color: var(--text); }
.density-btn:active { transform: scale(0.93); }
.density-btn svg {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  display: block;
  overflow: visible;
  flex-shrink: 0;
  margin: 0;
  transform: translate(calc(-50% - 0.35px), -50%);
}
/* Плотность в панели фильтра — как сортировка по цене: без рамки и заливки */
#main-density-btns .density-btn--toolbar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 7px;
  border: 1px solid var(--card-border) !important;
  background: transparent;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#main-density-btns .density-btn--toolbar:hover {
  background: var(--row-hover);
  color: var(--text);
}
#main-density-btns .density-btn--toolbar:active {
  transform: scale(0.93);
}
#main-density-btns .density-btn--toolbar .density-icon {
  width: 14px;
  height: 14px;
  display: none;
}
#main-density-btns .density-btn--toolbar[data-density="compact"] .density-icon--compact,
#main-density-btns .density-btn--toolbar[data-density="regular"] .density-icon--regular,
#main-density-btns .density-btn--toolbar[data-density="relaxed"] .density-icon--relaxed {
  display: block;
}
.filter-btn:active, .pd-period-btn:active, .pd-chart-btn:active,
.anomaly-limit-btn:active { transform: scale(0.97); }

/* COLUMN DRAG & DROP */
.data-table thead th[draggable] { cursor: grab; user-select: none; }
.data-table thead th[draggable]:active { cursor: grabbing; }
.data-table thead th.col-drag-over-left  { box-shadow: inset 3px 0 0 #0078D4; }
.data-table thead th.col-drag-over-right { box-shadow: inset -3px 0 0 #0078D4; }
.data-table thead th.col-dragging { opacity: 0.45; }
.td-hash { color: var(--text-secondary); font-size: 12px; }
.td-art  { font-family: 'SF Mono','Menlo','Monaco','Courier New',monospace; font-size: 12px; color: var(--text-secondary); }
.td-vnd, .td-dst { color: var(--text-secondary); }
.td-trs { text-align: right; color: var(--text-secondary); }
.td-qty  { text-align: right; color: var(--text-secondary); }
.td-prc  { text-align: right; font-weight: 600; }
.col-rub { text-align: right; font-weight: 600; }
.td-art.copyable, .td-prc.copyable, .wc-sku.copyable, .wc-price.copyable {
  cursor: pointer; user-select: none;
}
.wc-sku.copyable:hover, .wc-price.copyable:hover { opacity: 0.75; }

/* CHART MODAL */
