/* Вишлист — компактная таблица «как в Excel» */

.wl-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.wl-toolbar-left,
.wl-toolbar-right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.wl-search,
.wl-select {
  padding: 6px 10px;
  border: 1px solid var(--border-color, #33415580);
  border-radius: 8px;
  background: var(--input-bg, var(--card-bg, #fff));
  color: var(--text-color, inherit);
  font-size: 0.85rem;
}
.wl-search { min-width: 180px; }

.wl-tabs { display: inline-flex; gap: 4px; }
.wl-tab {
  padding: 6px 12px;
  border: 1px solid var(--border-color, #33415580);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted, inherit);
  font-size: 0.82rem;
  cursor: pointer;
}
.wl-tab.active {
  background: var(--accent-color, #2d5a8e);
  color: #fff;
  border-color: var(--accent-color, #2d5a8e);
}

.wl-status-note {
  min-height: 1.1em;
  margin: 0 0 8px;
  font-size: 0.8rem;
  color: var(--text-muted, #8892a4);
}

/* Таблица */
.wl-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-color, #33415540);
  border-radius: 10px;
  background: var(--card-bg, #fff);
}
.wl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 640px;
  table-layout: fixed; /* «Название» и «Магазин» гибкие (%), забирают освободившееся место при скрытии колонок */
}
.wl-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted, #8892a4);
  background: var(--card-bg, #fff);
  border-bottom: 2px solid var(--border-color, #33415540);
  white-space: nowrap;
}
.wl-sortable { cursor: pointer; user-select: none; }
.wl-sortable:hover { color: var(--text-color, inherit); }
.wl-sortable.wl-sort-asc::after { content: " ▲"; font-size: 0.7em; }
.wl-sortable.wl-sort-desc::after { content: " ▼"; font-size: 0.7em; }

.wl-table tbody td {
  padding: 3px 8px;
  border-bottom: 1px solid var(--border-color, #33415522);
  vertical-align: middle;
}
.wl-table tbody tr:hover { background: var(--hover-bg, #2d5a8e0d); }

/* Строка — цель достигнута (цена ниже/равна целевой) */
.wl-table tbody tr.wl-hit {
  background: var(--success-bg, #16a34a14);
}
.wl-table tbody tr.wl-hit:hover { background: var(--success-bg, #16a34a22); }

/* Инлайн-инпуты в ячейках — «эксель» */
.wl-cell-input,
.wl-cell-select {
  width: 100%;
  box-sizing: border-box;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-color, inherit);
  font-size: 0.82rem;
  font-family: inherit;
}
.wl-cell-input:hover,
.wl-cell-select:hover { border-color: var(--border-color, #33415540); }
.wl-cell-input:focus,
.wl-cell-select:focus {
  outline: none;
  border-color: var(--accent-color, #2d5a8e);
  background: var(--input-bg, var(--card-bg, #fff));
}
.wl-num, .wl-cell-num { text-align: right; font-variant-numeric: tabular-nums; }
input.wl-cell-num { text-align: right; }

/* Кастомная стрелка селектов (тема-нейтральный цвет), чтобы не торчала светлая нативная */
.wl-cell-select,
.wl-select,
.wl-field select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%238892a4' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}
/* Убираем нативные стрелки-спиннеры у числовых полей (были светлыми на тёмной теме) */
.wl-cell-num::-webkit-outer-spin-button,
.wl-cell-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.wl-cell-num { -moz-appearance: textfield; appearance: textfield; }

/* Мультицена: раскрытие продавцов */
.wl-title-cell { display: flex; align-items: center; gap: 4px; }
.wl-expand {
  border: none; background: transparent; cursor: pointer;
  color: var(--text-muted, #8892a4); font-size: 0.8rem;
  padding: 2px 4px; border-radius: 5px; line-height: 1;
  transition: transform 0.12s ease;
}
.wl-expand:hover { color: var(--text-color, inherit); background: var(--hover-bg, #2d5a8e14); }
.wl-expand.open { transform: rotate(90deg); color: var(--text-color, inherit); }

.wl-readonly { padding: 4px 6px; color: var(--text-color, inherit); font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wl-price-cell { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.wl-sellers-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--accent-color, #2d5a8e); color: #fff; font-size: 0.65rem; font-weight: 700;
}

.wl-offers-row > td { background: var(--hover-bg, #2d5a8e0d); padding: 0; }
.wl-offers { display: flex; flex-direction: column; gap: 6px; padding: 10px 10px 12px 42px; }
.wl-offers-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted, #8892a4); }
.wl-offer { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wl-offer input {
  padding: 5px 8px; border: 1px solid var(--border-color, #33415580); border-radius: 7px;
  background: var(--input-bg, var(--card-bg, #fff)); color: var(--text-color, inherit);
  font-size: 0.82rem; font-family: inherit;
}
.wl-offer .wl-o-seller { flex: 1 1 150px; min-width: 110px; }
.wl-offer .wl-o-url { flex: 2 1 200px; min-width: 130px; }
.wl-offer .wl-o-price { width: 110px; text-align: right; }
.wl-o-price::-webkit-outer-spin-button,
.wl-o-price::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.wl-o-price { -moz-appearance: textfield; appearance: textfield; }
.wl-o-spacer { width: 24px; }
.wl-offer-tag { font-size: 0.68rem; color: var(--text-muted, #8892a4); min-width: 56px; }
.wl-offer-cheapest .wl-offer-tag { color: var(--success-color, #16a34a); font-weight: 600; }
.wl-offer-cheapest .wl-o-price { border-color: var(--success-color, #16a34a); }
.wl-o-del { border: none; background: transparent; cursor: pointer; opacity: 0.7; font-size: 0.9rem; }
.wl-o-del:hover { opacity: 1; }
.wl-add-offer {
  align-self: flex-start; border: 1px dashed var(--border-color, #33415580);
  background: transparent; color: var(--text-color, inherit); border-radius: 8px;
  padding: 5px 12px; cursor: pointer; font-size: 0.8rem;
}
.wl-add-offer:hover { border-color: var(--accent-color, #2d5a8e); }

.wl-col-img { width: 44px; }
.wl-col-title { width: 40%; }   /* гибкая, приоритет по ширине */
.wl-col-store { width: 20%; }   /* гибкая */
.wl-col-cat { width: 120px; }
.wl-col-price { width: 90px; }
.wl-col-delta { width: 70px; }
.wl-col-prio { width: 92px; }
.wl-col-actions { width: 44px; text-align: center; }

/* Скрытие колонок (класс на таблице) */
.wl-table.wl-hide-store .wl-col-store,
.wl-table.wl-hide-cat .wl-col-cat,
.wl-table.wl-hide-current .wl-col-current,
.wl-table.wl-hide-target .wl-col-target,
.wl-table.wl-hide-delta .wl-col-delta,
.wl-table.wl-hide-prio .wl-col-prio { display: none; }

.wl-thumb {
  width: 30px; height: 30px;
  object-fit: cover;
  border-radius: 5px;
  display: block;
  background: var(--border-color, #33415522);
}
.wl-thumb-empty {
  width: 30px; height: 30px;
  border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  background: var(--border-color, #33415522);
  font-size: 0.9rem; opacity: 0.5;
}

.wl-delta { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wl-delta.down { color: var(--success-color, #16a34a); }
.wl-delta.up { color: var(--danger-color, #dc2626); }
.wl-delta.muted { color: var(--text-muted, #8892a4); font-weight: 400; }

.wl-row-actions { display: inline-flex; gap: 4px; }

/* Шеврон сворачивания карточки — только в мобильном виде (см. media ≤900px) */
.wl-mchevron { display: none; }

/* Цветной индикатор приоритета */
.wl-prio-dot {
  flex: 0 0 auto;
  width: 9px; height: 9px;
  border-radius: 50%;
  display: inline-block;
  background: var(--text-muted, #8892a4);
}
.wl-prio-3 { background: var(--danger-color, #dc2626); }   /* Must */
.wl-prio-2 { background: #eab308; }                         /* Средний */
.wl-prio-1 { background: var(--text-muted, #8892a4); }      /* Nice */

/* Компактный чип «vs цель» — по умолчанию скрыт (в таблице есть отдельная колонка) */
.wl-mini-delta { display: none; font-weight: 600; font-size: 0.78rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wl-mini-delta.down { color: var(--success-color, #16a34a); }
.wl-mini-delta.up { color: var(--danger-color, #dc2626); }

/* Счётчик на вкладке */
.wl-tab-count:not(:empty) {
  display: inline-block;
  min-width: 16px;
  padding: 0 5px;
  margin-left: 2px;
  border-radius: 9px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  background: var(--border-color, #33415560);
  color: var(--text-color, inherit);
}
.wl-tab.active .wl-tab-count:not(:empty) { background: rgba(255,255,255,0.28); color: #fff; }

/* Селектор сортировки — только в карточном виде */
.wl-sort-mobile { display: none; }

/* Значок чека + дата покупки в шапке карточки/строки */
.wl-receipt-btn { flex: 0 0 auto; font-size: 0.95rem; }
.wl-bought-date { flex: 0 0 auto; font-size: 0.72rem; color: var(--text-muted, #8892a4); margin-left: auto; white-space: nowrap; }

/* Превью чека в модалке */
.wl-receipt-preview { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.wl-receipt-preview img {
  max-width: 100%; max-height: 220px;
  border-radius: 10px; border: 1px solid var(--border-color, #33415540);
  object-fit: contain;
}

/* Лайтбокс просмотра чека */
.wl-lightbox {
  position: fixed; inset: 0; z-index: 60002;
  display: none; align-items: center; justify-content: center;
  background: rgba(3, 7, 18, 0.82); padding: 24px; cursor: zoom-out;
}
.wl-lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.wl-lightbox-close {
  position: fixed; top: 16px; right: 20px;
  border: none; background: rgba(255,255,255,0.15); color: #fff;
  width: 40px; height: 40px; border-radius: 50%; font-size: 1.2rem; cursor: pointer;
}
.wl-kebab {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 0.5;
  color: var(--text-color, inherit);
  opacity: 0.85;
}
.wl-kebab:hover { opacity: 1; }

/* Кнопка «Колонки» в тулбаре + чекбоксы в меню */
.wl-cols-btn { white-space: nowrap; }
.wl-row-menu label.wl-col-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 0.85rem;
  color: var(--text-color, inherit);
  cursor: pointer;
}
.wl-row-menu label.wl-col-toggle:hover { background: var(--hover-bg, #2d5a8e22); }
.wl-row-menu label.wl-col-toggle input { margin: 0; accent-color: var(--accent-color, #2d5a8e); }

/* Выпадающее меню действий строки (крепится к body, fixed) */
.wl-row-menu {
  position: fixed;
  z-index: 60001;
  min-width: 190px;
  background: var(--card-bg, #0f1729);
  border: 1px solid var(--border-color, #33415580);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.4);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wl-row-menu button,
.wl-row-menu a {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--text-color, inherit);
  font-size: 0.85rem;
  font-family: inherit;
  text-align: left;
  text-decoration: none;
  border-radius: 7px;
  cursor: pointer;
}
.wl-row-menu button:hover,
.wl-row-menu a:hover { background: var(--hover-bg, #2d5a8e22); }
.wl-row-menu .wl-menu-danger { color: var(--danger-color, #dc2626); }

.wl-icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 4px;
  border-radius: 6px;
  text-decoration: none;
  opacity: 0.75;
}
.wl-icon-btn:hover { opacity: 1; background: var(--hover-bg, #2d5a8e14); }

.wl-sumrow td {
  padding: 8px 10px;
  border-top: 2px solid var(--border-color, #33415540);
  font-weight: 700;
  font-size: 0.85rem;
}

.wl-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted, #8892a4);
  font-size: 0.9rem;
}

/* Модалка */
.wl-modal {
  position: fixed; inset: 0;
  z-index: 60000; /* выше .main-nav (10005) и user-menu (50000), вровень с .modal */
  background: rgba(3, 7, 18, 0.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 32px 16px;
  overflow-y: auto;
}
.wl-modal-card {
  width: 100%;
  max-width: 520px;
  background: var(--card-bg, #fff);
  color: var(--text-color, inherit);
  border-radius: 14px;
  border: 1px solid var(--border-color, #33415540);
  padding: 20px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}
.wl-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.wl-modal-head h2 { margin: 0; font-size: 1.1rem; }
.wl-modal-close { border: none; background: transparent; font-size: 1.1rem; cursor: pointer; color: var(--text-muted, inherit); }

.wl-form { display: flex; flex-direction: column; gap: 12px; }
.wl-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.82rem; }
.wl-field > span { color: var(--text-muted, #8892a4); }
.wl-field input,
.wl-field select,
.wl-field textarea {
  padding: 8px 10px;
  border: 1px solid var(--border-color, #33415580);
  border-radius: 8px;
  background: var(--input-bg, var(--card-bg, #fff));
  color: var(--text-color, inherit);
  font-size: 0.9rem;
  font-family: inherit;
}
.wl-field-row { display: flex; gap: 10px; }
.wl-field-row .wl-field { flex: 1; }
.wl-url-row { display: flex; gap: 8px; }
.wl-url-row input { flex: 1; }
.wl-modal-actions { display: flex; gap: 10px; margin-top: 6px; }

@media (max-width: 560px) {
  .wl-field-row { flex-direction: column; }
  .wl-url-row { flex-direction: column; }
}

/* ---------- Мобильный/планшетный вид: таблица → карточки ---------- */
@media (max-width: 900px) {
  /* Тулбар: элементы фильтров на всю ширину — удобнее тапать */
  .wl-toolbar { gap: 8px; }
  .wl-toolbar-left,
  .wl-toolbar-right { width: 100%; }
  .wl-search,
  .wl-toolbar-left .wl-select { flex: 1 1 100%; min-width: 0; }
  .wl-tabs { flex: 1 1 auto; }
  .wl-tab { flex: 1; text-align: center; }
  /* Сортировка доступна в карточном виде (заголовки-сортировка скрыты) */
  .wl-sort-mobile { display: block; flex: 1 1 100%; min-width: 0; }

  /* Контейнер таблицы — без горизонтального скролла и рамки-обёртки */
  .wl-table-wrap {
    overflow-x: visible;
    border: none;
    background: transparent;
    border-radius: 0;
  }
  .wl-table {
    display: block;
    width: 100%;
    min-width: 0;
  }
  .wl-table thead { display: none; }
  .wl-table tbody { display: block; }

  /* Каждая позиция — карточка */
  .wl-table tbody tr.wl-item-row {
    position: relative;
    display: block;
    padding: 12px 12px 8px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color, #33415540);
    border-radius: 12px;
    background: var(--card-bg, #fff);
  }
  .wl-table tbody tr.wl-item-row:hover { background: var(--card-bg, #fff); }
  .wl-table tbody tr.wl-item-row.wl-hit {
    border-color: var(--success-color, #16a34a);
    background: var(--success-bg, #16a34a10);
  }

  /* Средние поля (с data-label) — строка «метка: значение» */
  .wl-item-row > td[data-label] {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    border: none;
    width: auto;      /* сбрасываем десктопные % / px ширины колонок */
    min-height: 34px;
  }
  .wl-item-row > td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 92px;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted, #8892a4);
  }
  .wl-item-row > td[data-label] > * { flex: 1 1 auto; min-width: 0; }
  .wl-item-row > td.wl-col-price .wl-readonly.wl-price-cell { justify-content: flex-start; }
  .wl-item-row > td .wl-readonly { white-space: normal; }
  /* Числовой ввод цели — слева у метки, как остальные значения */
  .wl-item-row > td[data-label] input.wl-cell-num { text-align: left; }

  /* Миниатюра — в левом верхнем углу карточки */
  .wl-item-row > td.wl-col-img {
    position: absolute;
    top: 12px;
    left: 12px;
    display: block;
    padding: 0;
    border: none;
    width: auto;
  }

  /* Название — крупная «шапка» карточки, с отступом под миниатюру */
  .wl-item-row > td.wl-col-title {
    display: block;
    width: auto;      /* сбрасываем десктопную ширину 40% */
    padding: 0 40px 8px 42px;
    min-height: 34px;
    border: none;
    border-bottom: 1px solid var(--border-color, #33415522);
    margin-bottom: 4px;
  }
  .wl-item-row > td.wl-col-title .wl-title-cell { width: 100%; }
  .wl-item-row > td.wl-col-title .wl-cell-input {
    font-size: 0.95rem;
    font-weight: 600;
  }

  /* Шеврон сворачивания + меню действий (⋯) — правый верхний угол */
  .wl-item-row > td.wl-col-actions {
    position: absolute;
    top: 8px;
    right: 4px;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0;
    border: none;
    width: auto;
    text-align: right;
  }
  .wl-mchevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    font-size: 0.85rem;
    color: var(--text-muted, #8892a4);
    cursor: pointer;
    border-radius: 6px;
    user-select: none;
  }
  .wl-mchevron:hover { background: var(--hover-bg, #2d5a8e14); }

  /* --- Свёрнутая карточка: только название + цена + ⋯ --- */
  .wl-item-row.wl-mcollapsed { cursor: pointer; padding-bottom: 10px; }
  /* Прячем все поля кроме «Сейчас, ₽» */
  .wl-item-row.wl-mcollapsed > td[data-label]:not(.wl-col-current) { display: none; }
  /* Название без разделителя, компактнее */
  .wl-item-row.wl-mcollapsed > td.wl-col-title {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 4px;
  }
  /* В свёрнутом состоянии не даём тапу «проваливаться» в редактирование названия */
  .wl-item-row.wl-mcollapsed > td.wl-col-title .wl-cell-input { pointer-events: none; }
  /* Кнопка раскрытия продавцов (▸) скрыта, пока карточка свёрнута */
  .wl-item-row.wl-mcollapsed > td.wl-col-title .wl-expand { display: none; }
  /* Строка цены — компактная, значение жирнее */
  .wl-item-row.wl-mcollapsed > td.wl-col-current { min-height: 30px; padding-top: 0; }
  .wl-item-row.wl-mcollapsed > td.wl-col-current .wl-readonly { font-weight: 600; }
  /* Чип «vs цель» рядом с ценой в свёрнутой карточке */
  .wl-item-row.wl-mcollapsed > td.wl-col-current .wl-mini-delta { display: inline; margin-left: 6px; }
  .wl-item-row.wl-mcollapsed > td.wl-col-current .wl-price-cell { gap: 4px; }

  /* Подстрока «Продавцы и цены» — стек на всю ширину */
  .wl-offers-row { display: block; }
  .wl-offers-row > td { display: block; padding: 0; }
  .wl-offers { padding: 10px 12px; }
  .wl-offer .wl-o-seller,
  .wl-offer .wl-o-url,
  .wl-offer .wl-o-price {
    flex: 1 1 100%;
    width: auto;
    box-sizing: border-box;
  }

  /* Итоговая строка — компактная карточка */
  .wl-table tfoot { display: block; }
  .wl-table tfoot tr.wl-sumrow {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    align-items: baseline;
    padding: 12px;
    margin-top: 2px;
    border-top: none;
    border: 1px solid var(--border-color, #33415540);
    border-radius: 12px;
    background: var(--card-bg, #fff);
  }
  .wl-sumrow td { display: inline-block; padding: 0; border: none; }
  .wl-sumrow td[colspan="3"],
  .wl-sumrow td:empty { display: none; }
  #wlSumCurrent::before { content: "Сейчас: "; font-weight: 400; color: var(--text-muted, #8892a4); }
  #wlSumTarget::before { content: "Цель: "; font-weight: 400; color: var(--text-muted, #8892a4); }
}
