:root {
  --primary-color: #00a651;
  --bg-color: #f4f6f8;
  --card-bg: #ffffff;
  --text-color: #1a1a1a;
  --text-muted: #70757a;
  --border-color: #e2e8f0;
  --shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.08);
  --radius-lg: 18px;
  --radius-md: 12px;
}

/* 🌙 Тёмная тема */
body.dark-theme {
  --bg-color: #0f172a;
  --card-bg: #1e293b;
  --text-color: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  padding-bottom: 90px;
  transition: background-color 0.3s, color 0.3s;
}

/* 📲 Плашка установки PWA сверху */
.pwa-banner {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--card-bg);
  color: var(--text-color);
  border-bottom: 1px solid var(--border-color);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.pwa-banner-info {
  display: flex;
  flex-direction: column;
}

.pwa-banner-info strong {
  font-size: 0.88rem;
}

.pwa-banner-info span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pwa-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
}

.pwa-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
}

/* Главный контейнер */
.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px;
}

/* 🔝 Шапка: строго центрированное название */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--card-bg);
  backdrop-filter: blur(12px);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.header-logo-box {
  width: 44px;
  flex-shrink: 0;
}

.header-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  object-fit: contain;
}

.header-title-box {
  flex: 1;
  text-align: center;
  padding: 0 8px;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.header-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-right-placeholder {
  width: 44px;
  flex-shrink: 0;
}

/* Кнопки навигации */
.top-nav-buttons {
  display: flex;
  gap: 8px;
  padding: 12px 0 4px 0;
}

.top-nav-btn {
  flex: 1;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-color);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.top-nav-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.top-nav-btn.theme-btn {
  flex: 0 0 48px;
  font-size: 1.1rem;
}

/* 🔍 Поиск и категории */
.controls-bar {
  padding: 8px 0 14px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  outline: none;
  background: var(--card-bg);
  color: var(--text-color);
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--primary-color);
}

.categories-scroll {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 4px;
  user-select: none;
}

.cat-btn {
  padding: 7px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-color);
  white-space: nowrap;
  font-size: 0.84rem;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

.cat-btn.active {
  background: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
  font-weight: 600;
}

.cat-toggle-btn {
  background: var(--bg-color);
  font-weight: 600;
  border-style: dashed;
}

/* 📦 Сетка товаров */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  padding: 0;
}

@media (max-width: 992px) {
  .catalog-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 768px) {
  .catalog-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 580px) {
  .app-container { padding: 0 10px; }
  .catalog-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .product-img { height: 120px; padding: 6px; }
  .product-info { padding: 8px; }
  .product-title { font-size: 0.78rem; min-height: 2.4em; }
  .product-price { font-size: 0.95rem; }
  .add-btn { padding: 8px; font-size: 0.8rem; }
}

.product-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.product-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 35px -5px rgba(0, 0, 0, 0.12);
}

.product-img {
  width: 100%;
  height: 135px;
  object-fit: contain;
  background-color: #ffffff;
  padding: 6px;
}

.product-info {
  padding: 10px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.product-meta {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.product-badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.badge-in-stock { background: #dcfce7; color: #166534; }
.badge-on-order { background: #e0f2fe; color: #0369a1; }

.product-title {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.25;
  min-height: 2.5em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-color);
}

.product-brand {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.price-block {
  margin-top: auto;
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 8px;
}

.product-price {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-color);
}

.product-old-price {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-decoration: line-through;
}

.add-btn {
  width: 100%;
  padding: 8px;
  background: var(--primary-color);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}

.add-btn:active {
  transform: scale(0.98);
}

/* 🛒 Аккуратная плавающая корзина (Прямоугольная плашка аккуратного размера) */
.floating-cart-btn {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 380px;
  background: var(--primary-color);
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  cursor: pointer;
  z-index: 200;
  font-size: 0.88rem;
  transition: transform 0.2s ease;
}

.floating-cart-btn:hover {
  transform: translateX(-50%) translateY(-2px);
}

.cart-pill-badge {
  background: rgba(255, 255, 255, 0.22);
  padding: 4px 8px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.8rem;
  white-space: nowrap;
}

.cart-pill-title {
  font-weight: 600;
  text-align: center;
  flex: 1;
  padding: 0 8px;
}

.cart-pill-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  white-space: nowrap;
}

.cart-close-icon {
  font-size: 1rem;
  padding: 2px 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.cart-close-icon:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* 🪟 Центрированные Модальные окна */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  justify-content: center;
  align-items: center;
  padding: 20px;
  z-index: 300;
}

.modal-content {
  background: var(--card-bg);
  color: var(--text-color);
  width: 100%;
  max-width: 500px;
  border-radius: 24px;
  padding: 24px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-color);
  animation: modalCenterPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  margin: auto;
}

@keyframes modalCenterPop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.close-modal-btn {
  border: none;
  background: var(--bg-color);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.close-modal-btn:hover {
  background: var(--border-color);
}

.about-info-box {
  background: var(--bg-color);
  padding: 14px;
  border-radius: var(--radius-md);
  color: var(--text-color);
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.cart-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-color);
  color: var(--text-color);
  font-weight: bold;
  font-size: 1rem;
  cursor: pointer;
}

.qty-input {
  width: 44px;
  text-align: center;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px;
  font-weight: bold;
  background: var(--card-bg);
  color: var(--text-color);
}