:root {
  --accent: #2e5c8a;
  --bg: #f7f8fa;
  --border: #e0e3e8;
  --text: #000000;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  position: sticky;
  top: 0;
}

.header__inner { display: flex; align-items: center; gap: 24px; }

.logo { font-weight: 700; font-size: 20px; color: var(--accent); text-decoration: none; }

.search { display: flex; gap: 8px; flex: 1; }
.search input {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 15px;
}
.search input#articleInput { flex: 2; }
.search input#brandInput { flex: 1; }
.search button {
  background: #c0392b; color: #fff; border: none; border-radius: 6px;
  padding: 10px 20px; cursor: pointer; font-size: 15px;
}
.search button:hover { background: #962d22; }

.cart-link { text-decoration: none; color: var(--text); font-weight: 500; white-space: nowrap; }
.cart-link--primary {
  color: #fff; background: #c0392b;
  padding: 8px 16px; border-radius: 6px; font-weight: 700;
}
.cart-link--primary:hover { background: #962d22; color: #fff; }

.cart-link--messages {
  color: #1f2937 !important; background: #eab308;
  padding: 6px 14px; border-radius: 6px; font-weight: 700;
}
.cart-link--messages:hover { background: #ca8a04; color: #1f2937 !important; }

.auth-area { display: flex; gap: 16px; align-items: center; margin-left: auto; }
.auth-area a { text-decoration: none; color: var(--text); font-weight: 500; white-space: nowrap; }
.auth-area a:hover { color: var(--accent); }
.account-id { color: var(--accent); font-weight: 700; }

.unread-badge {
  display: inline-block; background: #c0392b; color: #fff; font-weight: 700;
  font-size: 11px; line-height: 1; padding: 3px 6px; border-radius: 10px; margin-left: 4px;
}

.delivery-qty-wrap { margin-left: 8px; white-space: nowrap; }
.delivery-qty-input { width: 56px; margin: 0 4px; }

.search-bar-wrap { background: var(--bg); padding: 14px 0; }
.search-bar-wrap .search { width: 100%; max-width: 640px; margin: 0 auto; }
.search--loud {
  border: 2px solid var(--accent);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.message {
  margin: 20px 0; padding: 12px 16px; background: #fff3cd; border: 1px solid #ffe08a; border-radius: 6px;
}

.results { margin: 24px 0; }

.offer-card {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 16px;
}

.offer-card__info h3 { margin: 0 0 4px; font-size: 16px; }
.offer-card__meta { color: #6b7280; font-size: 14px; }

.offer-card__buy { text-align: right; white-space: nowrap; }
.offer-card__price { font-size: 20px; font-weight: 700; color: var(--accent); }
.offer-card__stock { font-size: 13px; color: #16a34a; margin: 4px 0; }
.offer-card__buy button {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 8px 16px; cursor: pointer;
}

.cart-item {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 16px; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center;
}

.cart-total { text-align: right; font-size: 18px; font-weight: 700; margin: 16px 0; }

.test-result { margin-left: 12px; font-size: 13px; }

.cart-actions { display: flex; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.cart-actions button.secondary,
button.secondary {
  background: #fff; color: var(--text); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 16px; cursor: pointer; font-size: 14px;
}
.cart-actions button.secondary:hover,
button.secondary:hover { background: #f3f4f6; }

.cart-file-btn {
  background: #16a34a; color: #fff; border: none; border-radius: 6px;
  padding: 8px 16px; cursor: pointer; font-size: 14px;
}
.cart-file-btn:hover { background: #15803d; }

.cart-table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.cart-table-wrap table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cart-table-wrap th, .cart-table-wrap td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.cart-table-wrap td.wrap-cell { white-space: normal; }
.cart-table-wrap .qty-input {
  width: 70px; padding: 6px; border: 2px solid var(--accent); border-radius: 4px;
  font-weight: 700; font-size: 15px; text-align: center;
}
.cart-table-wrap .qty-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.cart-table-wrap button[data-remove] {
  background: none; border: 1px solid var(--border); border-radius: 4px; color: #dc2626;
  cursor: pointer; padding: 4px 10px;
}
/* Строка позиции, которой не хватило при оформлении заказа (см. checkout.js highlightUnavailableCartRow) */
.cart-row--unavailable { background: #fef2f2 !important; }
.cart-row--unavailable td { box-shadow: inset 0 0 0 9999px rgba(220,38,38,0.04); }
.cart-table-wrap button[data-remove]:hover { background: #fee2e2; }

.checkout-form {
  background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 20px; max-width: 480px;
}
.checkout-form label { display: block; margin-bottom: 12px; font-size: 14px; }
.checkout-form input, .checkout-form textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; margin-top: 4px; font-size: 14px;
}
.checkout-form fieldset { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 16px; }
.checkout-form button {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 12px 24px; font-size: 15px; cursor: pointer; width: 100%;
}

.sbp-payment {
  background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 24px;
  max-width: 480px; text-align: center;
}
.sbp-qr { margin: 16px auto; max-width: 260px; }
.sbp-qr svg { width: 100%; height: auto; }
.sbp-status { font-size: 15px; font-weight: 600; color: #6b7280; }

.free-payment-widget {
  background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 24px;
  max-width: 480px; margin-top: 24px;
}
.free-payment-widget h2 { margin-top: 0; font-size: 18px; }
.free-payment-widget__hint { font-size: 13px; color: #6b7280; margin-bottom: 16px; }
.free-payment-widget__form label { display: block; margin-bottom: 12px; font-size: 14px; }
.free-payment-widget__form input, .free-payment-widget__form select {
  width: 100%; padding: 8px 10px; border: 2px solid var(--accent); border-radius: 6px; margin-top: 4px; font-size: 14px;
  box-sizing: border-box; background: #f0f9ff;
}
.free-payment-widget__form input:focus, .free-payment-widget__form select:focus {
  outline: none; border-color: #16a34a; background: #fff;
}
.free-payment-widget__form button {
  background: #16a34a; color: #fff; border: none; border-radius: 6px;
  padding: 12px 24px; font-size: 15px; font-weight: 600; cursor: pointer; width: 100%;
}
.free-payment-widget__form button:hover { background: #15803d; }
.free-payment-widget__error { color: #dc2626; font-size: 14px; margin-top: 12px; }
.free-payment-widget__result { text-align: center; }
.free-payment-widget__result #freePaymentQr { margin: 16px auto; max-width: 260px; }
.free-payment-widget__result #freePaymentQr svg { width: 100%; height: auto; }
.free-payment-widget__result #freePaymentStatus { font-size: 15px; font-weight: 600; color: #6b7280; }

.site-footer {
  margin-top: 48px; padding: 24px 0; border-top: 1px solid var(--border);
  background: #fff; font-size: 13px; color: #6b7280;
}
.site-footer__row { margin-bottom: 6px; display: flex; gap: 20px; flex-wrap: wrap; }
.site-footer a { color: #6b7280; }
.site-footer a:hover { color: var(--accent); }

.site-nav { background: #f3f4f6; border-bottom: 1px solid var(--border); }
.site-nav__list { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; flex-wrap: wrap; }
.site-nav__item { position: relative; }
.site-nav__item > a {
  display: block; padding: 10px 14px; color: var(--text); text-decoration: none; font-size: 14px;
}
.site-nav__item > a:hover { color: var(--accent); background: #e5e7eb; }
.site-nav__submenu {
  display: none; position: absolute; top: 100%; left: 0; background: #fff;
  border: 1px solid var(--border); border-radius: 0 0 6px 6px; list-style: none;
  margin: 0; padding: 4px 0; min-width: 200px; box-shadow: 0 4px 10px rgba(0,0,0,0.08); z-index: 20;
}
.site-nav__item.has-children:hover .site-nav__submenu { display: block; }
.site-nav__submenu a { display: block; padding: 8px 14px; color: var(--text); text-decoration: none; font-size: 14px; }
.site-nav__submenu a:hover { background: #f3f4f6; color: var(--accent); }

.results-summary { color: #6b7280; font-size: 14px; margin: 16px 0 8px; }
.offers-table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.offers-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 900px; }
.offers-table th {
  background: #f9fafb; text-align: left; padding: 10px 12px; font-weight: 600;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.offers-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.offers-table tr:last-child td { border-bottom: none; }
.offers-table tr:hover { background: #f9fafb; }
.offer-price { font-weight: 700; color: var(--accent); white-space: nowrap; }
.stock-ok { color: #16a34a; white-space: nowrap; }
.stock-out { color: #9ca3af; white-space: nowrap; }
.reliability { color: #f59e0b; font-size: 11px; }
.reliability-gauge-wrap {
  position: relative; display: inline-block; cursor: default; vertical-align: middle;
  width: 15px; height: 15px; border-radius: 50%;
}
.reliability-gauge-wrap::after {
  content: attr(data-tooltip);
  position: absolute; bottom: 130%; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: 4px 8px; border-radius: 4px;
  font-size: 12px; white-space: nowrap; opacity: 0; visibility: hidden;
  transition: opacity 0.15s; pointer-events: none; z-index: 10;
}
.reliability-gauge-wrap:hover::after { opacity: 1; visibility: visible; }

.sortable-col { cursor: pointer; user-select: none; }
.sortable-col:hover { color: var(--accent); }
.sortable-col--active { color: var(--accent); }
.offers-table button {
  background: var(--accent); color: #fff; border: none; border-radius: 6px;
  padding: 6px 14px; cursor: pointer; white-space: nowrap;
}
.offers-table button:disabled { background: #d1d5db; cursor: not-allowed; }

/* Ячейка заказа (как в личном кабинете Автопитера): маленькое поле с
   предустановленным количеством слева от кнопки-иконки корзины. */
.order-cell { display: flex; align-items: center; gap: 4px; }
.qty-preset-input {
  width: 40px; padding: 4px 2px; text-align: center; font-weight: 700; font-size: 14px;
  border: 1px solid var(--border); border-radius: 4px; color: var(--text);
}
.qty-preset-input:disabled { background: #f3f4f6; color: #9ca3af; }
.offers-table .cart-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; flex-shrink: 0;
  background: #dc2626; border: none; border-radius: 6px; cursor: pointer;
  transition: background-color 0.15s;
}
.offers-table .cart-icon-btn:hover:not(:disabled) { background: #b91c1c; }
.offers-table .cart-icon-btn:disabled { background: #d1d5db; cursor: not-allowed; }
.offers-table .cart-icon-btn.cart-icon-btn--added { background: #16a34a; }

/* Текстовый блок под таблицей результатов поиска — на всю ширину, вкл/выкл
   и текст задаются в админке (Настройки → "Блок под таблицей поиска"). */
.search-note {
  width: 100%; margin: 16px 0; padding: 14px 16px;
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; line-height: 1.5;
}

/* Рекламные окна — сетка настраивается в админке (1 ряд на 3 или 2 ряда на 2). */
.promo-grid { display: grid; gap: 16px; margin: 16px 0; }
.promo-grid--row3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.promo-grid--2x2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.promo-card {
  display: block; background: #fff; border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; color: var(--text); text-decoration: none; transition: box-shadow 0.15s;
}
a.promo-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.promo-card img { width: 100%; display: block; object-fit: cover; max-height: 160px; }
.promo-card p { margin: 0; padding: 10px 12px; font-size: 14px; line-height: 1.4; }

@media (max-width: 700px) {
  .promo-grid--row3, .promo-grid--2x2 { grid-template-columns: 1fr; }
}
