:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #16233b;
  --ink-soft: #5a6b86;
  --line: #e3e8f1;
  --line-soft: #eef2f8;
  --accent: #1b2b46;
  --accent-ink: #ffffff;
  --ozon: #005bff;
  --wb: #cb11ab;
  --ya: #fc3f1d;
  --avito: #965eeb;
  --ok: #12805c;
  --warn: #b45309;
  --err: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 "Segoe UI", Roboto, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------------------------------------------------------------- top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand__mark {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: linear-gradient(135deg, #1b2b46, #34507a);
  color: #fff;
  font-weight: 700;
  letter-spacing: .5px;
  font-size: 14px;
}

.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.brand__text strong { font-size: 17px; letter-spacing: .2px; }
.brand__text small { color: var(--ink-soft); font-size: 12.5px; }

/* метки площадок в шапке */
.topbar__sites { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.site-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  background: #f4f6fa;
  border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}
.site-tag::before {
  content: '';
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
}
.site-tag--ozon { color: var(--ozon); background: #eef3ff; border-color: #d9e4ff; }
.site-tag--wb { color: var(--wb); background: #fdeef9; border-color: #f8d9f0; }
.site-tag--ya { color: var(--ya); background: #fff0ec; border-color: #ffdcd3; }
.site-tag--avito { color: var(--avito); background: #f5efff; border-color: #e5d8ff; }

/* ------------------------------------------------------------------- page */
.page { width: 100%; max-width: 1900px; margin: 0 auto; padding: 22px 24px 28px; flex: 1; }

/* ---------------------------------------------------------------- поиск */
.search {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.search__form { display: flex; gap: 12px; }

.search__field { position: relative; flex: 1; display: flex; align-items: center; }

.search__icon {
  position: absolute; left: 14px; width: 20px; height: 20px;
  color: #8a97ab; pointer-events: none;
}

.search__field input {
  width: 100%;
  padding: 13px 44px 13px 44px;
  font-size: 15.5px;
  color: var(--ink);
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.search__field input::placeholder { color: #9aa7ba; }
/* убираем встроенные крестики Edge/Chrome — у нас свой */
.search__field input::-webkit-search-cancel-button,
.search__field input::-webkit-search-decoration,
.search__field input::-ms-clear,
.search__field input::-ms-reveal { -webkit-appearance: none; display: none; width: 0; height: 0; }
.search__field input:focus {
  border-color: #9ab0d4;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(27, 43, 70, .08);
}

.search__clear {
  position: absolute; right: 8px; width: 28px; height: 28px;
  border: 0; border-radius: 8px; background: transparent;
  color: #8a97ab; font-size: 20px; line-height: 1; cursor: pointer;
}
.search__clear:hover { background: #eef2f8; color: var(--ink); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-width: 132px; padding: 0 22px;
  border: 0; border-radius: 11px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease, box-shadow .15s ease;
}
.btn:hover { background: #24395c; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .75; cursor: progress; }

.btn__spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* фильтры под строкой поиска */
.filters {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 13px;
  border-top: 1px dashed var(--line);
}

.filters__group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filters__label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.filters__dash { color: #a2adbd; }

.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check__box {
  width: 17px; height: 17px; border-radius: 5px;
  border: 1.5px solid #c3ccda; background: #fff;
  display: grid; place-items: center;
  transition: background .14s ease, border-color .14s ease;
}
.check__box::after {
  content: '';
  width: 9px; height: 5px;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
  opacity: 0;
  transition: opacity .12s ease;
}
.check input:checked + .check__box { background: var(--accent); border-color: var(--accent); }
.check input:checked + .check__box::after { opacity: 1; }
.check input:focus-visible + .check__box { outline: 2px solid #9ab0d4; outline-offset: 2px; }
.check__text { font-size: 13.5px; font-weight: 500; }
.check input:not(:checked) ~ .check__text { color: #8a97ab; }
.check--ozon input:checked + .check__box { background: var(--ozon); border-color: var(--ozon); }
.check--wb input:checked + .check__box { background: var(--wb); border-color: var(--wb); }
.check--ya input:checked + .check__box { background: var(--ya); border-color: var(--ya); }
.check--avito input:checked + .check__box { background: var(--avito); border-color: var(--avito); }
.check--own { padding-left: 6px; margin-left: 2px; border-left: 1px solid var(--line); }
.check--own input:checked + .check__box { background: var(--ink); border-color: var(--ink); }
.check--disabled { opacity: .45; cursor: not-allowed; }
.check--disabled input { cursor: not-allowed; }

.filters__group--price { margin-left: auto; }
.price-input {
  width: 96px; padding: 8px 10px;
  font-size: 13.5px; color: var(--ink);
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
  -moz-appearance: textfield;
}
.price-input::-webkit-outer-spin-button,
.price-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.price-input:focus { border-color: #9ab0d4; background: #fff; box-shadow: 0 0 0 3px rgba(27, 43, 70, .08); }
.price-input::placeholder { color: #9aa7ba; }

.filters__reset {
  border: 0; background: transparent; padding: 6px 8px;
  font-size: 12.5px; color: var(--ink-soft);
  border-radius: 8px; cursor: pointer;
}
.filters__reset:hover { background: #eef2f8; color: var(--ink); }

.search__meta { display: flex; align-items: center; gap: 14px; margin-top: 12px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  background: #eef2f8; color: var(--ink-soft);
  border: 1px solid transparent;
}
.chip__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8; }
.chip--ok { background: #e8f6f0; color: var(--ok); }
.chip--warn { background: #fdf3e3; color: var(--warn); }
.chip--err { background: #fdeceb; color: var(--err); }

.search__hint { color: var(--ink-soft); font-size: 13px; }

/* --------------------------------------------------------------- колонки */
.columns { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; align-items: start; }

.panel {
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 0;
}
.panel[hidden] { display: none; }

.panel__head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

.panel__logo {
  width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 13px;
}
.panel__logo--ozon { background: var(--ozon); }
.panel__logo--wb { background: var(--wb); }
.panel__logo--ya { background: var(--ya); }
.panel__logo--avito { background: var(--avito); }

.panel__title { margin: 0; font-size: 16px; font-weight: 650; }
.panel__count { margin-left: auto; font-size: 12.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.panel__notice {
  margin: 12px 14px 0;
  padding: 9px 12px;
  border-radius: 10px;
  background: #fdf3e3;
  border: 1px solid #f2dfbc;
  color: #7a5310;
  font-size: 13px;
}
.panel__notice--err { background: #fdeceb; border-color: #f4cdc9; color: var(--err); }

.panel__table-wrap { padding: 6px 6px 10px; }

/* ---------------------------------------------------------------- таблица */
.grid { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }

.grid thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--panel);
  padding: 9px 8px;
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: #8492a6; text-align: left;
  border-bottom: 1px solid var(--line-soft);
}

.grid__num { width: 38px; text-align: center; }
.grid__img { width: 46px; }
.grid__price { width: 108px; text-align: right; }
.grid thead th.grid__price { text-align: right; }
.grid thead th.grid__num { text-align: center; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* миниатюра в строке */
.cell-img { padding: 6px 2px 6px 4px !important; }

.thumb {
  display: block;
  width: 34px; height: 44px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #f4f6fa center / 60% no-repeat;
  object-fit: cover;
  cursor: zoom-in;
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}

.thumb:hover { transform: scale(1.06); border-color: #c8d4e6; }

/* заглушка, если картинки нет или она не загрузилась */
.thumb--empty {
  cursor: default;
  border-style: dashed;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b7c1d1' stroke-width='1.6'%3E%3Crect x='3' y='4' width='18' height='16' rx='3'/%3E%3Ccircle cx='9' cy='10' r='1.6'/%3E%3Cpath d='M4 18l5-5 4 4 3-2 4 3'/%3E%3C/svg%3E");
}
.thumb--empty:hover { transform: none; box-shadow: none; border-color: var(--line); }


/* увеличенный предпросмотр при наведении на миниатюру */
.zoom {
  position: fixed;
  z-index: 60;
  width: 280px; height: 360px;
  padding: 10px;
  display: grid; place-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 22px 50px rgba(16, 24, 40, .24);
  pointer-events: none;
  animation: zoom-in .12s ease-out;
}
.zoom[hidden] { display: none; }
.zoom img {
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  opacity: 0;
  transition: opacity .12s ease;
}
.zoom.is-ready img { opacity: 1; }
.zoom:not(.is-ready)::after {
  content: '';
  position: absolute;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid #dbe3ef;
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}

@keyframes zoom-in {
  from { opacity: 0; transform: translateY(4px) scale(.97); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 980px) {
  .zoom { display: none; }
}

.grid tbody td {
  padding: 8px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  font-size: 13.5px;
  height: 42px;
}
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover td { background: #f7f9fd; }

.cell-num { color: #a2adbd; text-align: center; font-variant-numeric: tabular-nums; }
.cell-price { text-align: right; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cell-price--empty { color: #c4ccd9; font-weight: 400; }

.cell-title a {
  color: var(--ink);
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
  max-height: 2.6em;
}
.cell-title a:hover { color: #1a4fd6; text-decoration: underline; }

.cell-seller {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: #8a97ab;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row--empty .cell-title { color: #c4ccd9; }

/* строка «показать ещё» */
.grid__more-row td { padding: 8px !important; border-bottom: 0 !important; }
.grid__more-row:hover td { background: transparent !important; }

.more-wrap { display: flex; flex-direction: column; gap: 6px; }

.more {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 8px 12px;
  border: 1px dashed #cfd8e6; border-radius: 10px;
  background: #fafcff; color: var(--ink-soft);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.more:hover { background: #eef3fb; border-color: #a9bcd8; color: var(--ink); }
.more__arrow { font-size: 11px; line-height: 1; transform: translateY(-1px); }

.more--hide {
  padding: 6px 12px;
  font-size: 12.5px;
  color: #8a97ab;
  border-style: solid;
  border-color: #e2e8f1;
  background: #fff;
}
.more--hide:hover { background: #f4f7fc; border-color: #c3ccda; }

.panel--loading .grid tbody { opacity: .55; transition: opacity .2s ease; }

/* ---------------------------------------------------------------- подвал */
.foot {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 24px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-soft);
  font-size: 12.5px;
}
.foot__dot { opacity: .5; }
#footStatus { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ адаптив */
@media (max-width: 1400px) {
  .columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1120px) {
  .topbar__sites { display: none; }
  .filters__group--price { margin-left: 0; }
}

@media (max-width: 980px) {
  .columns { grid-template-columns: 1fr; }
  .page { padding: 16px 14px 22px; }
  .topbar { padding: 12px 14px; }
  .search__form { flex-direction: column; }
  .btn { width: 100%; min-height: 44px; }
  .grid__price { width: 92px; }
  .filters { gap: 12px; }
  .price-input { width: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
