:root {
  --bg: #faf7f2;
  --paper: #fffdf8;
  --card: #ffffff;
  --text: #2c1f14;
  --muted: #7b6856;
  --line: #eadfd0;
  --accent: #b85f2a;
  --accent-dark: #84431e;
  --green: #27723a;
  --red: #b83232;
  --shadow: 0 14px 34px rgba(94, 53, 23, 0.11);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.topbar {
  background: var(--accent);
  color: white;
  padding: 7px 24px;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.topbar a { color: white; text-decoration: none; font-weight: 700; }

.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 253, 248, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 24px;
  display: grid;
  grid-template-columns: 240px 1fr auto;
  gap: 18px;
  align-items: center;
}
.brand { font-weight: 900; letter-spacing: .2px; font-size: 22px; }
.brand span { display: block; color: var(--muted); font-size: 12px; font-weight: 600; margin-top: 2px; }
.search { width: 100%; border: 1px solid var(--line); background: white; border-radius: 6px; padding: 11px 12px; }
.nav-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn, .primary, .secondary, .danger {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--text);
  min-height: 38px;
  padding: 8px 12px;
  font-weight: 750;
}
.primary { background: var(--accent); color: white; border-color: var(--accent); }
.secondary { background: #f6efe7; }
.danger { color: white; background: var(--red); border-color: var(--red); }

.hero {
  background: linear-gradient(120deg, rgba(184,95,42,.94), rgba(54,110,55,.88)), url("https://happygarden.com.ua/published/publicdata/SAD/attachments/SC/products_pictures/amish-paste_thm.jpg");
  background-size: cover;
  background-position: center;
  color: white;
}
.hero-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 64px 24px 72px;
}
.hero h1 { max-width: 760px; font-size: clamp(36px, 6vw, 68px); line-height: .96; margin: 0 0 16px; letter-spacing: 0; }
.hero p { max-width: 660px; font-size: 18px; line-height: 1.6; margin: 0 0 24px; }

.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 24px 60px;
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 24px;
  align-items: start;
}
.sidebar {
  position: sticky;
  top: 88px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.sidebar h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; color: var(--muted); letter-spacing: .08em; }
.cat-btn {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 9px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 650;
}
.cat-btn.active { background: #efe1d1; color: var(--accent-dark); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.product-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(94,53,23,.06);
  display: grid;
  grid-template-rows: 170px 1fr;
}
.product-card img { width: 100%; height: 100%; object-fit: cover; background: #f4eadf; }
.product-body { padding: 13px; display: grid; gap: 8px; }
.product-title { font-weight: 850; line-height: 1.25; min-height: 42px; }
.product-desc { color: var(--muted); font-size: 13px; line-height: 1.45; min-height: 54px; }
.product-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 4px; }
.price { color: var(--accent-dark); font-weight: 900; font-size: 18px; white-space: nowrap; }

.drawer, .modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(31, 23, 15, .45);
  display: none;
}
.drawer.open, .modal.open { display: block; }
.drawer-panel, .modal-panel {
  background: white;
  height: 100%;
  width: min(460px, 100vw);
  margin-left: auto;
  padding: 20px;
  overflow: auto;
}
.modal-panel { width: min(760px, calc(100vw - 30px)); height: auto; max-height: calc(100vh - 30px); margin: 15px auto; border-radius: 8px; }
.product-modal-layout { display: grid; grid-template-columns: minmax(220px, .8fr) 1fr; gap: 20px; margin-top: 14px; }
.product-gallery { min-width: 0; }
.product-gallery-main-button { width: 100%; display: block; padding: 0; border: 0; background: transparent; cursor: zoom-in; }
.product-gallery-main { display: block; width: 100%; max-height: 420px; object-fit: contain; background: #f4eadf; border: 1px solid var(--line); border-radius: 8px; }
.product-gallery-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; margin-top: 10px; }
.product-gallery-thumb { aspect-ratio: 1; padding: 2px; border: 2px solid transparent; background: white; border-radius: 6px; overflow: hidden; }
.product-gallery-thumb.active { border-color: var(--accent); }
.product-gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-lightbox { position: fixed; inset: 0; z-index: 70; display: none; place-items: center; padding: 24px; background: rgba(20, 16, 12, .88); cursor: zoom-out; }
.image-lightbox.open { display: grid; }
.image-lightbox img { max-width: min(1400px, 94vw); max-height: 92vh; object-fit: contain; cursor: default; }
.image-lightbox-close { position: fixed; top: 16px; right: 18px; width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.65); border-radius: 6px; background: rgba(0,0,0,.35); color: white; font-size: 30px; line-height: 1; }

.cart-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; border-bottom: 1px solid var(--line); padding: 12px 0; }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button { width: 30px; height: 30px; border: 1px solid var(--line); background: white; border-radius: 5px; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.admin-side { background: #1f2a22; color: white; padding: 20px 14px; }
.admin-side h1 { font-size: 20px; margin: 0 0 20px; }
.admin-tab { width: 100%; border: none; background: transparent; color: #d9eadc; text-align: left; padding: 10px 12px; border-radius: 6px; font-weight: 750; }
.admin-tab.active { background: rgba(255,255,255,.12); color: white; }
.admin-main { padding: 24px; overflow: auto; }
.panel { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.panel h2 { margin: 0 0 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.stat strong { display: block; font-size: 28px; color: var(--accent-dark); }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; background: white; }
th, td { padding: 10px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 14px; }
th { background: #f6efe7; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.field { display: grid; gap: 5px; }
.field label { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.field input, .field textarea, .field select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: white;
  min-width: 0;
}
.field textarea { min-height: 130px; resize: vertical; grid-column: 1 / -1; }
.full { grid-column: 1 / -1; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .panel { width: min(420px, 100%); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

@media (max-width: 820px) {
  .nav-inner, .layout, .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .admin-side { position: sticky; top: 0; z-index: 30; }
  .form-grid { grid-template-columns: 1fr; }
  .product-modal-layout { grid-template-columns: 1fr; }
}
