:root {
  --green: #16a34a;
  --green-dark: #15803d;
  --green-light: #dcfce7;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --white: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 8px 24px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

a { color: var(--green-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Header ---------- */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
}
.logo {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--ink);
}
.logo:hover { text-decoration: none; }
.nav {
  display: flex;
  align-items: center;
  gap: 16px;
}
.nav-link {
  color: var(--ink);
  font-weight: 500;
  position: relative;
}
.cart-link { display: inline-flex; align-items: center; gap: 6px; }
.badge {
  background: var(--green);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-user {
  color: var(--muted);
  font-size: 0.85rem;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inline { display: inline; margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
  font-family: inherit;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-outline { background: #fff; border-color: var(--green); color: var(--green-dark); }
.btn-outline:hover { background: var(--green-light); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 7px 12px; font-size: 0.85rem; border-radius: 8px; }
.btn-lg { padding: 13px 20px; font-size: 1.05rem; }
.btn-block { width: 100%; }

/* ---------- Main / footer ---------- */
.main-content { flex: 1; padding: 28px 20px 48px; }
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--white);
  color: var(--muted);
  font-size: 0.85rem;
  padding: 20px 0;
  text-align: center;
}

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, var(--green) 0%, #22c55e 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 36px 28px;
  margin-bottom: 24px;
}
.hero h1 { margin: 0 0 8px; font-size: 1.9rem; }
.hero p { margin: 0; opacity: 0.95; }

/* ---------- Category chips ---------- */
.catalog-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}
.chip {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
}
.chip:hover { border-color: var(--green); text-decoration: none; }
.chip-active { background: var(--green); color: #fff; border-color: var(--green); }

/* ---------- Product grid ---------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow .18s, transform .18s;
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-3px); }
.card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--bg);
}
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-cat {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(255,255,255,0.92);
  color: var(--green-dark);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}
.card-body { padding: 14px; display: flex; flex-direction: column; flex: 1; }
.card-title { margin: 0 0 4px; font-size: 1.05rem; }
.card-desc { margin: 0 0 14px; color: var(--muted); font-size: 0.85rem; flex: 1; }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.price { font-size: 1.15rem; font-weight: 800; }
.empty { color: var(--muted); }

/* ---------- Auth ---------- */
.auth-wrap { display: flex; justify-content: center; padding: 20px 0; }
.auth-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  width: 100%;
  max-width: 420px;
}
.auth-card h1 { margin: 0 0 20px; }
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.field input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 1rem;
  font-family: inherit;
}
.field input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-light); }
.password-wrap { position: relative; display: flex; }
.password-wrap input { flex: 1; width: 100%; padding-right: 46px; }
.toggle-pass {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  padding: 4px 6px;
  opacity: 0.65;
  border-radius: 6px;
}
.toggle-pass:hover { opacity: 1; }
.toggle-pass:focus-visible { outline: 2px solid var(--green); opacity: 1; }
.auth-alt { margin: 18px 0 0; text-align: center; color: var(--muted); font-size: 0.9rem; }
.alert { padding: 11px 14px; border-radius: 10px; font-size: 0.9rem; margin-bottom: 18px; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* ---------- Cart ---------- */
.page-title { margin: 0 0 20px; }
.cart-layout { display: grid; grid-template-columns: 1fr 320px; gap: 22px; align-items: start; }
.cart-items { display: flex; flex-direction: column; gap: 12px; }
.cart-item {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  grid-template-columns: 64px 1fr auto auto auto;
  align-items: center;
  gap: 14px;
}
.cart-item-img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; }
.cart-item-info h3 { margin: 0 0 2px; font-size: 1rem; }
.cart-item-price { color: var(--muted); font-size: 0.85rem; }
.qty-form { display: inline-flex; align-items: center; gap: 4px; margin: 0; }
.qty-btn {
  width: 30px; height: 30px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}
.qty-btn:hover { border-color: var(--green); color: var(--green-dark); }
.qty { min-width: 26px; text-align: center; font-weight: 600; }
.cart-item-sum { font-weight: 700; min-width: 70px; text-align: right; }
.remove-btn {
  border: none; background: transparent; color: var(--muted);
  font-size: 1rem; cursor: pointer; padding: 6px;
}
.remove-btn:hover { color: #b91c1c; }
.cart-summary {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 84px;
}
.cart-summary h2 { margin: 0 0 16px; font-size: 1.2rem; }
.summary-row { display: flex; justify-content: space-between; margin-bottom: 10px; color: var(--muted); }
.summary-total { color: var(--ink); font-weight: 800; font-size: 1.2rem; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.summary-total + form { margin-top: 16px; }
.empty-cart { text-align: center; padding: 48px 0; color: var(--muted); }
.empty-cart p { margin-bottom: 18px; }

/* ---------- Success / 404 ---------- */
.success-wrap { display: flex; justify-content: center; padding: 30px 0; }
.success-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 44px 36px;
  text-align: center;
  max-width: 460px;
}
.success-icon {
  width: 72px; height: 72px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--green-light);
  color: var(--green-dark);
  font-size: 2.2rem;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.success-card h1 { margin: 0 0 10px; }
.success-card p { color: var(--muted); margin: 4px 0; }
.success-total { margin: 14px 0 22px !important; color: var(--ink) !important; }

/* ---------- Toast (уведомления) ---------- */
#toast-container {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
  pointer-events: none;
  width: max-content;
  max-width: 92vw;
}
.toast {
  background: var(--green-dark);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .25s ease, transform .25s ease;
}
.toast-show { opacity: 1; transform: translateY(0); }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .cart-layout { grid-template-columns: 1fr; }
  .cart-summary { position: static; }
}
@media (max-width: 600px) {
  .hero { padding: 26px 20px; }
  .hero h1 { font-size: 1.5rem; }
  .nav-user { display: none; }
  .nav { gap: 12px; }
  .cart-item { grid-template-columns: 52px 1fr auto; grid-row-gap: 8px; }
  .cart-item-img { width: 52px; height: 52px; }
  .cart-item-sum { grid-column: 2 / 3; text-align: left; }
  .qty-form { grid-column: 3 / 4; grid-row: 1; }
}
