:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --secondary: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* ── Nav ─────────────────────────────────────────────────── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.nav-logo {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
}
.nav-logo span { color: var(--secondary); }
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-links a {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: .9rem;
  color: var(--text-muted);
  transition: all .15s;
}
.nav-links a:hover, .nav-links a.active { background: #eff6ff; color: var(--primary); }
.nav-actions { display: flex; align-items: center; gap: 8px; }

#nav-login, #nav-user { display: flex; align-items: center; gap: 8px; }
#nav-user { display: none; }

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: .875rem;
  cursor: pointer;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all .15s;
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

.cart-btn {
  position: relative;
  background: var(--primary);
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  color: #fff;
  font-size: .875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background .15s;
}
.cart-btn:hover { background: var(--primary-dark); }
#cart-badge {
  position: absolute;
  top: -6px; right: -6px;
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  min-width: 18px; height: 18px;
  font-size: .7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: #d97706; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-full { width: 100%; }

/* BUG-014 [P4]: у кнопки "Очистить корзину" нет стиля hover */
.btn-clear-cart {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
}

/* ── Layout ──────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.page-header { padding: 32px 0 24px; }
.page-header h1 { font-size: 1.75rem; font-weight: 700; }
.page-header p { color: var(--text-muted); margin-top: 4px; }

/* ── Hero ────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #06b6d4 100%);
  color: #fff;
  padding: 60px 20px;
  text-align: center;
}
.hero h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: 12px; }
.hero p { font-size: 1.1rem; opacity: .9; margin-bottom: 28px; }
.hero-search {
  display: flex;
  max-width: 540px;
  margin: 0 auto;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.hero-search input {
  flex: 1;
  padding: 14px 20px;
  border: none;
  outline: none;
  font-size: 1rem;
  color: var(--text);
}
.hero-search button {
  background: var(--secondary);
  border: none;
  padding: 14px 24px;
  color: #fff;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
}
#search-label {
  margin-top: 10px;
  font-size: .85rem;
  opacity: .8;
  min-height: 20px;
}

/* ── Filters ─────────────────────────────────────────────── */
.filters {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}
.filters-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.cat-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-size: .85rem;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.cat-btn:hover, .cat-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.sort-select {
  margin-left: auto;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .85rem;
  background: #fff;
  cursor: pointer;
  outline: none;
}

/* ── Product Grid ────────────────────────────────────────── */
.products-section { padding: 28px 0; }
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all .2s;
  box-shadow: var(--shadow);
}
.product-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.product-img {
  font-size: 5rem;
  text-align: center;
  padding: 28px 0 16px;
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
}
.product-body { padding: 16px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.product-name { font-size: .95rem; font-weight: 600; }
.product-rating { font-size: .85rem; color: var(--text-muted); }
.product-rating .stars { color: var(--secondary); }
.product-price { margin-top: auto; }
.price-current { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.price-old { font-size: .85rem; color: var(--text-muted); text-decoration: line-through; margin-left: 6px; }
.badge-sale {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  font-size: .75rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: 6px;
}
.product-footer { padding: 0 16px 16px; }
.btn-add {
  width: 100%;
  padding: 9px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-add:hover { background: var(--primary-dark); }
.btn-add.added { background: var(--success); }

/* ── Cart ────────────────────────────────────────────────── */
.cart-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
  padding: 28px 0;
}
@media (max-width: 768px) { .cart-layout { grid-template-columns: 1fr; } }
.cart-table { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; box-shadow: var(--shadow); }
.cart-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.cart-header h2 { font-size: 1rem; font-weight: 600; }
.cart-item { display: grid; grid-template-columns: 60px 1fr auto auto; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.cart-item:last-child { border-bottom: none; }
.cart-item-emoji { font-size: 2rem; text-align: center; }
.cart-item-name { font-weight: 500; font-size: .9rem; }
.cart-item-price { font-size: .85rem; color: var(--text-muted); }
.qty-control { display: flex; align-items: center; gap: 8px; }
.qty-btn {
  width: 28px; height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.qty-btn:hover { border-color: var(--primary); color: var(--primary); }
.qty-val { min-width: 24px; text-align: center; font-weight: 600; }
.item-total { font-weight: 600; min-width: 80px; text-align: right; }
.cart-empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.cart-empty .empty-icon { font-size: 3rem; margin-bottom: 12px; }

.cart-sidebar { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h3 { font-size: .95rem; font-weight: 600; margin-bottom: 14px; }
.promo-row { display: flex; gap: 8px; }
.promo-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .875rem;
  outline: none;
  transition: border .15s;
}
.promo-input:focus { border-color: var(--primary); }
.promo-msg { margin-top: 8px; font-size: .8rem; }
.promo-ok { color: var(--success); }
.promo-err { color: var(--danger); }

.summary-row { display: flex; justify-content: space-between; font-size: .9rem; margin-bottom: 8px; }
.summary-row.total { font-size: 1.1rem; font-weight: 700; border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; }
.summary-row .discount { color: var(--success); }

/* ── Forms ───────────────────────────────────────────────── */
.form-page {
  min-height: calc(100vh - 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}
.form-card h2 { font-size: 1.4rem; font-weight: 700; margin-bottom: 6px; }
.form-card .subtitle { color: var(--text-muted); font-size: .9rem; margin-bottom: 28px; }
.tabs { display: flex; gap: 0; margin-bottom: 24px; background: var(--bg); border-radius: 8px; padding: 4px; }
.tab-btn {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  transition: all .15s;
}
.tab-btn.active { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  outline: none;
  transition: border .15s;
  background: var(--surface);
  color: var(--text);
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--primary); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-error { color: var(--danger); font-size: .8rem; margin-top: 4px; }
.alert { padding: 12px 16px; border-radius: 8px; font-size: .875rem; margin-bottom: 16px; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #14532d; border: 1px solid #bbf7d0; }

/* ── Checkout ────────────────────────────────────────────── */
.checkout-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 28px;
  padding: 28px 0;
  align-items: start;
}
@media (max-width: 768px) { .checkout-layout { grid-template-columns: 1fr; } }
.checkout-form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}
.section-title { font-size: 1rem; font-weight: 600; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* ── Order summary (checkout) ───────────────────────────── */
.order-summary { position: sticky; top: 80px; }
.order-items { margin-bottom: 16px; }
.order-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: .875rem; }
.order-item:last-child { border: none; }
.order-item-name { color: var(--text); }
.order-item-qty { color: var(--text-muted); font-size: .8rem; }

/* ── Admin ───────────────────────────────────────────────── */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; padding: 28px 0; }
.admin-sidebar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; height: fit-content; box-shadow: var(--shadow); }
.admin-nav-link { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 7px; font-size: .875rem; color: var(--text-muted); transition: all .15s; cursor: pointer; }
.admin-nav-link:hover, .admin-nav-link.active { background: #eff6ff; color: var(--primary); }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: .85rem; color: var(--text-muted); margin-top: 4px; }
.orders-table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.orders-table table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.orders-table th { background: var(--bg); padding: 12px 16px; text-align: left; font-weight: 600; border-bottom: 1px solid var(--border); }
.orders-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.orders-table tr:last-child td { border: none; }
.status-badge { padding: 3px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.status-new { background: #eff6ff; color: #1d4ed8; }
.status-done { background: #f0fdf4; color: #15803d; }

/* ── Footer ──────────────────────────────────────────────── */
footer {
  background: #1e293b;
  color: #94a3b8;
  padding: 48px 0 24px;
  margin-top: 60px;
}
.footer-grid {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}
@media (max-width: 768px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
.footer-brand h3 { color: #f1f5f9; font-size: 1.2rem; margin-bottom: 8px; }
.footer-brand p { font-size: .875rem; line-height: 1.6; }
.footer-col h4 { color: #f1f5f9; font-size: .875rem; font-weight: 600; margin-bottom: 12px; }
.footer-col ul { list-style: none; display: flex; flex-direction: column; gap: 8px; }
/* BUG-012 [P4]: ссылки в футере открываются в новой вкладке, хотя ведут на # */
.footer-col a { font-size: .85rem; color: #94a3b8; transition: color .15s; }
.footer-col a:hover { color: #f1f5f9; }
.footer-bottom {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 20px 0;
  border-top: 1px solid #334155;
  display: flex;
  justify-content: space-between;
  font-size: .8rem;
}

/* ── Toast ───────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 9999; }
.toast { background: #1e293b; color: #fff; padding: 12px 18px; border-radius: 10px; font-size: .875rem; opacity: 0; transform: translateY(8px); transition: all .3s; max-width: 300px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.show { opacity: 1; transform: none; }
.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid var(--primary); }

/* ── Misc ────────────────────────────────────────────────── */
.no-results { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.no-results .icon { font-size: 3rem; margin-bottom: 12px; }
