header {
  padding: 24px 32px;
  justify-content: space-between;
  flex-wrap: wrap;
}
header h1 { font-size: 28px; font-weight: 700; margin: 0; }
header p  { margin-top: 6px; opacity: 0.85; font-size: 15px; margin-bottom: 0; }

.header-title { text-align: left; }
.header-title-center { text-align: center; flex: 1; }
.header-btns {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end;
}
.btn-auto-toggle.off { background: rgba(255,255,255,0.08); opacity: 0.7; }

.container { max-width: 920px; margin: 0 auto; padding: 32px 16px; }

/* ── Поиск ── */
.search-card {
  background: white; border-radius: 16px; padding: 28px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.search-card h2 { font-size: 17px; color: #333; margin-bottom: 16px; }
.search-row { display: flex; gap: 10px; }
.search-row input {
  flex: 1; padding: 12px 16px; border: 1.5px solid #dde3f0;
  border-radius: 10px; font-size: 14px; outline: none; transition: border-color .2s;
}
.search-row input:focus { border-color: #005bff; }
.search-row button {
  padding: 12px 24px; background: #005bff; color: white; border: none;
  border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: background .2s;
}
.search-row button:hover { background: #0041c4; }

/* ── Заголовок секции ── */
.section-title { font-size: 16px; font-weight: 600; color: #444; margin: 32px 0 14px; }

/* ── Сетка плиток категорий ── */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 10px;
  margin-bottom: 28px;
}
.cat-tile {
  background: white; border-radius: 12px; padding: 14px 16px;
  cursor: pointer; box-shadow: 0 1px 6px rgba(0,0,0,0.07);
  border: 1.5px solid transparent; transition: box-shadow .2s, transform .15s, border-color .2s;
}
.cat-tile:hover { box-shadow: 0 4px 16px rgba(0,91,255,0.13); transform: translateY(-2px); border-color: #d6e4ff; }
.cat-tile.active { background: #e8f0ff; border-color: #99bbff; box-shadow: 0 4px 16px rgba(0,91,255,0.15); }
.cat-tile .cat-name { font-size: 14px; font-weight: 600; color: #222; display: block; }
.cat-tile .cat-count { font-size: 12px; color: #888; margin-top: 4px; display: block; }
.cat-tile-fav .cat-name { color: #c07000; }

/* ── Раскрывающиеся секции ── */
.cat-section {
  display: none;
  background: white; border-radius: 14px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.07);
  margin-bottom: 10px; overflow: hidden;
  border: 1.5px solid transparent; transition: border-color .2s, box-shadow .2s;
}
.cat-section.visible { display: block; scroll-margin-top: 16px; }
.cat-section[open] { border-color: #cddeff; box-shadow: 0 4px 18px rgba(0,91,255,0.11); }

.cat-section > summary {
  padding: 15px 20px; cursor: pointer; list-style: none; user-select: none;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 15px; font-weight: 600; color: #222;
}
.cat-section > summary::-webkit-details-marker { display: none; }
.cat-section > summary .cat-meta { display: flex; align-items: center; gap: 10px; }
.cat-section > summary .cnt { font-size: 13px; font-weight: 400; color: #888; }
.cat-section > summary .arrow { font-size: 10px; color: #bbb; transition: transform .2s; }
.cat-section[open] > summary .arrow { transform: rotate(90deg); }

/* ── Список товаров внутри секции ── */
.cat-body { padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 8px; }

.product-wrap { position: relative; }
.product-wrap .btn-del,
.product-wrap .btn-ref,
.product-wrap .btn-fav {
  position: absolute; top: 50%;
  transform: translateY(-50%) translateX(8px);
  width: 26px; height: 26px; border-radius: 50%;
  border: none; font-size: 14px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 1; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.product-wrap .btn-del { right: 10px; background: #ffe8e8; color: #c00; font-size: 15px; }
.product-wrap .btn-ref { right: 40px; background: #e8eeff; color: #005bff; }
.product-wrap .btn-fav { right: 68px; background: #fff8e1; color: #bbb; font-size: 15px; }
.product-wrap:hover .btn-del,
.product-wrap:hover .btn-ref,
.product-wrap:hover .btn-fav {
  opacity: 1; pointer-events: auto;
  transform: translateY(-50%) translateX(0);
}
.product-wrap .btn-fav.active { color: #f5a623; opacity: 1; pointer-events: auto; transform: translateY(-50%) translateX(0); }
.product-wrap .btn-ref.spinning { opacity: 1; pointer-events: auto; transform: translateY(-50%) translateX(0); }
.product-wrap .btn-ref.spinning .ref-icon { animation: spin .6s linear infinite; }
.product-wrap .btn-ref:disabled { opacity: 0.6; cursor: default; }

/* ── Плашка «Избранные товары» ── */
.cat-section.favorites > summary { color: #c07000; }
.cat-section.favorites > summary .cat-name-fav::before { content: "★ "; }

/* ── Кнопка «наверх» ── */
.scroll-top {
  position: fixed; bottom: 28px; right: 24px; z-index: 200;
  width: 42px; height: 42px; border-radius: 50%;
  background: #005bff; color: white; border: none;
  font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(0,91,255,0.35);
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s;
  transform: translateY(8px);
}
.scroll-top.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.scroll-top:hover { background: #0041c4; }

.product-item {
  background: #f6f8ff; border-radius: 10px; padding: 13px 16px;
  display: flex; justify-content: space-between; align-items: center;
  text-decoration: none; color: inherit; transition: background .15s, padding-right .2s;
}
.product-item:hover { background: #edf1ff; }

.product-item .name {
  font-size: 14px; font-weight: 500; color: #222;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 500px;
}
.product-item .price-block {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px; white-space: nowrap;
  transition: transform .2s;
}
/* На ховере цена уезжает влево — освобождает место для кнопок */
.product-wrap:hover .price-block { transform: translateX(-84px); }
/* Избранный товар (без ховера): звезда справа от цены, цена чуть сдвигается */
.product-wrap:not(:hover) .btn-fav.active { opacity: 1; pointer-events: auto; transform: translateY(-50%) translateX(0); right: 10px; transition: right .2s, opacity .2s, transform .2s; }
.product-wrap:has(.btn-fav.active):not(:hover) .price-block { transform: translateX(-40px); }
/* Активный спиннер: кнопка видна без ховера — цена тоже отодвигается */
.product-wrap:has(.btn-ref.spinning) .price-block { transform: translateX(-84px); }
.product-item .price { font-size: 15px; font-weight: 700; color: #005bff; }
.delta { font-size: 12px; font-weight: 600; }
.delta.up   { color: #e03535; }
.delta.down { color: #00a850; }
.delta.flat { color: #aaa; }

.empty { text-align: center; color: #999; font-size: 14px; padding: 32px 0; }

/* ── Мобильная адаптация ── */
@media (max-width: 480px) {
  header { padding: 14px 16px; gap: 10px; }
  header h1 { font-size: 20px; }
  header p { font-size: 13px; }
  .btn-hdr { padding: 6px 10px; font-size: 12px; }
  .container { padding: 20px 12px; }
  .search-card { padding: 18px 16px; }
  .search-row { flex-direction: column; }
  .cat-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
  /* На мобильном: название на всю ширину, цена под ним, кнопки справа */
  .product-item { padding: 8px 88px 8px 12px; flex-wrap: wrap; align-items: center; justify-content: flex-start; }
  .product-item .name { flex: 1 1 100%; max-width: none; font-size: 13px; margin-bottom: 2px; }
  .product-item .price-block { flex: 1 1 100%; align-items: flex-start; gap: 1px; }
  .product-item .price { font-size: 13px; }
  .delta { font-size: 11px; }
  /* Кнопки всегда видны, цена не сдвигается */
  .product-wrap .btn-del,
  .product-wrap .btn-ref,
  .product-wrap .btn-fav { opacity: 1; pointer-events: auto; transform: translateY(-50%) translateX(0); width: 26px; height: 26px; }
  .product-wrap .btn-del { right: 6px; }
  .product-wrap .btn-ref { right: 36px; }
  .product-wrap .btn-fav { right: 66px; }
  .product-wrap:hover .price-block,
  .product-wrap:has(.btn-fav.active):not(:hover) .price-block,
  .product-wrap:has(.btn-ref.spinning) .price-block { transform: none; }
  .product-wrap:not(:hover) .btn-fav.active { right: 66px !important; }
  .toast-error { left: 12px; right: 12px; max-width: none; top: 12px; }
  .scroll-top { bottom: 16px; right: 14px; width: 38px; height: 38px; font-size: 16px; }
  .upd-text { font-size: 12px; }
}

/* ── Прогресс-бар фонового обновления ── */
.update-banner {
  display: none; background: #005bff; color: white;
  padding: 10px 20px; font-size: 13px; font-weight: 600;
  align-items: center; gap: 14px;
}
.update-banner.active { display: flex; }
.update-banner .upd-spinner {
  width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0;
}
.upd-bar-wrap {
  flex: 1; background: rgba(255,255,255,0.25); border-radius: 4px; height: 6px; overflow: hidden;
}
.upd-bar { height: 100%; background: white; border-radius: 4px; transition: width .4s; width: 0%; }
.upd-text { white-space: nowrap; }
.upd-stop {
  background: rgba(255,255,255,0.2); border: none; color: white;
  width: 22px; height: 22px; border-radius: 50%; cursor: pointer;
  font-size: 13px; line-height: 1; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.upd-stop:hover { background: rgba(255,255,255,0.4); }
