:root {
  --green-900: #1b5e20;
  --green-700: #2e7d32;
  --green-600: #388e3c;
  --green-500: #4caf50;
  --green-400: #66bb6a;
  --green-100: #e8f5e9;
  --green-50: #f3faf3;
  --ink: #1c2321;
  --ink-soft: #5b6660;
  --white: #ffffff;
  --line: #e3ece3;
  --shadow: 0 4px 16px rgba(27, 94, 32, 0.08);
  --shadow-lg: 0 12px 32px rgba(27, 94, 32, 0.16);
  --radius: 14px;
  --header-h: 68px;
  --promo-h: 38px;
  font-size: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--ink);
  background: var(--green-50);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .brand__text strong {
  font-family: 'Poppins', 'Inter', sans-serif;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--green-700); color: #fff;
  padding: 10px 16px; z-index: 200; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%; border: none;
  background: transparent; color: var(--ink); cursor: pointer;
  transition: background .15s ease;
}
.icon-btn:hover { background: var(--green-100); }
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  height: var(--header-h);
}
.topbar__inner {
  max-width: 1400px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
}
.menu-toggle { display: none; }
.brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand__logo { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px var(--green-100); }
.brand__text { display: flex; flex-direction: column; line-height: 1.15; }
.brand__text strong { font-size: 1.05rem; color: var(--green-800, var(--green-700)); font-weight: 700; }
.brand__text small { font-size: .68rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }

.topbar__search {
  flex: 1; max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--green-50); border: 1px solid var(--line);
  border-radius: 999px; padding: 0 14px; height: 42px;
}
.topbar__search:focus-within { border-color: var(--green-400); box-shadow: 0 0 0 3px var(--green-100); }
.search-icon { width: 18px; height: 18px; color: var(--ink-soft); flex-shrink: 0; }
.topbar__search input {
  border: none; background: transparent; outline: none; width: 100%;
  font-size: .95rem; font-family: inherit; color: var(--ink);
}

.whatsapp-topbtn { color: var(--green-600); }
.whatsapp-topbtn svg { width: 26px; height: 26px; }

.promo-strip {
  background: var(--green-700); color: #fff; font-size: .8rem;
  text-align: center; padding: 8px 12px; height: var(--promo-h);
  display: flex; align-items: center; justify-content: center;
  overflow-x: auto; white-space: nowrap;
}

/* ---------- Layout ---------- */
.layout { max-width: 1400px; margin: 0 auto; display: flex; align-items: flex-start; }

.sidebar {
  width: 250px; flex-shrink: 0; position: sticky;
  top: calc(var(--header-h) + var(--promo-h)); align-self: flex-start;
  height: calc(100vh - var(--header-h) - var(--promo-h));
  overflow-y: auto; padding: 18px 14px 40px;
  border-right: 1px solid var(--line);
}
.sidebar__header { display: none; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sidebar__header h2 { margin: 0; font-size: 1.1rem; }

.category-list { display: flex; flex-direction: column; gap: 2px; }
.category-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; width: 100%; text-align: left; border: none; background: none;
  font: inherit; padding: 9px 12px; border-radius: 10px; cursor: pointer;
  color: var(--ink); font-size: .88rem;
}
.category-item:hover { background: var(--green-50); }
.category-item.is-active { background: var(--green-100); color: var(--green-800, var(--green-700)); font-weight: 600; }
.category-item .count { font-size: .74rem; color: var(--ink-soft); background: var(--white); border: 1px solid var(--line); border-radius: 999px; padding: 1px 7px; }
.category-item.is-active .count { background: var(--white); }

.sidebar-overlay { display: none; }

.content { flex: 1; min-width: 0; padding: 24px 20px 60px; }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, var(--green-600), var(--green-800, var(--green-700)));
  color: #fff; border-radius: 20px; padding: 32px 28px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px;
  margin-bottom: 26px; box-shadow: var(--shadow-lg);
}
.hero__text h1 { margin: 0 0 8px; font-size: clamp(1.3rem, 2.6vw, 1.8rem); }
.hero__text p { margin: 0; opacity: .92; max-width: 46ch; font-size: .95rem; }
.hero__cta {
  background: #fff; color: var(--green-700); font-weight: 700; padding: 13px 22px;
  border-radius: 999px; white-space: nowrap; box-shadow: 0 6px 16px rgba(0,0,0,.15);
  transition: transform .15s ease;
}
.hero__cta:hover { transform: translateY(-2px); }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 10px; margin-bottom: 16px;
}
.toolbar__info { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: .9rem; }
.active-chip {
  background: var(--green-100); color: var(--green-800, var(--green-700)); font-weight: 600;
  padding: 4px 12px; border-radius: 999px; font-size: .82rem;
}
.sort-control { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--ink-soft); }
.sort-control select {
  font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer;
}

/* ---------- Product grid ---------- */
.product-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.product-card {
  background: #fff; border-radius: var(--radius); border: 1px solid var(--line);
  overflow: hidden; display: flex; flex-direction: column; cursor: pointer;
  transition: box-shadow .2s ease, transform .2s ease;
}
.product-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); }
.product-card__img { aspect-ratio: 1 / 1; background: var(--green-50); overflow: hidden; }
.product-card__img img { width: 100%; height: 100%; object-fit: cover; }
.product-card__body { padding: 12px 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-card__cat { font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--green-600); font-weight: 700; }
.product-card__title {
  font-size: .86rem; line-height: 1.3; color: var(--ink); font-weight: 500;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.6em;
}
.product-card__footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.product-card__price { font-weight: 800; color: var(--green-700); font-size: 1.02rem; }
.product-card__buy {
  width: 34px; height: 34px; border-radius: 50%; background: var(--green-500); color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; border: none; cursor: pointer;
}
.product-card__buy svg { width: 18px; height: 18px; }
.product-card__buy:hover { background: var(--green-600); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-soft); }
.btn-outline {
  margin-top: 12px; padding: 10px 20px; border-radius: 999px; border: 1px solid var(--green-500);
  color: var(--green-700); background: #fff; font: inherit; cursor: pointer;
}
.btn-outline:hover { background: var(--green-50); }

/* ---------- Pagination ---------- */
.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 32px; flex-wrap: wrap; }
.pagination button {
  min-width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; font: inherit; cursor: pointer; color: var(--ink); padding: 0 10px;
}
.pagination button.is-active { background: var(--green-600); border-color: var(--green-600); color: #fff; font-weight: 700; }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagination button:hover:not(:disabled):not(.is-active) { background: var(--green-50); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 300; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(20, 30, 22, .55); backdrop-filter: blur(2px); }
.modal__card {
  position: relative; background: #fff; border-radius: 20px; max-width: 780px; width: 100%;
  max-height: 88vh; overflow-y: auto; display: flex; flex-wrap: wrap; box-shadow: var(--shadow-lg);
}
.modal__close { position: absolute; top: 12px; right: 12px; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.15); z-index: 2; }
.modal__img { flex: 1 1 320px; background: var(--green-50); display: flex; align-items: center; justify-content: center; min-height: 320px; }
.modal__img img { width: 100%; height: 100%; object-fit: contain; max-height: 460px; }
.modal__info { flex: 1 1 320px; padding: 28px 26px; display: flex; flex-direction: column; gap: 10px; }
.tag {
  align-self: flex-start; background: var(--green-100); color: var(--green-700); font-weight: 700;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; padding: 5px 12px; border-radius: 999px;
}
#modalTitle { margin: 4px 0 0; font-size: 1.3rem; line-height: 1.35; }
.modal__brand { margin: 0; color: var(--ink-soft); font-size: .9rem; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.chip-row span { background: var(--green-50); border: 1px solid var(--line); color: var(--green-700); font-size: .76rem; padding: 4px 10px; border-radius: 999px; }
.modal__price { font-size: 1.7rem; font-weight: 800; color: var(--green-700); margin: 6px 0 0; }
.modal__code { color: var(--ink-soft); font-size: .82rem; margin: -6px 0 6px; }
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--green-600); color: #fff; font-weight: 700; padding: 14px 20px;
  border-radius: 12px; margin-top: 6px; box-shadow: 0 6px 16px rgba(56,142,60,.3);
}
.btn-primary:hover { background: var(--green-700); }
.modal__note { font-size: .8rem; color: var(--ink-soft); margin: 6px 0 0; }

/* ---------- Floating buttons ---------- */
.whatsapp-fab {
  position: fixed; right: 20px; bottom: 20px; width: 58px; height: 58px; border-radius: 50%;
  background: #25D366; color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(0,0,0,.25); z-index: 150;
}
.whatsapp-fab svg { width: 30px; height: 30px; }
.whatsapp-fab:hover { transform: scale(1.06); }

.back-to-top {
  position: fixed; right: 20px; bottom: 88px; width: 42px; height: 42px; border-radius: 50%;
  background: #fff; border: 1px solid var(--line); color: var(--green-700); cursor: pointer;
  box-shadow: var(--shadow); z-index: 150; display: flex; align-items: center; justify-content: center;
}
.back-to-top[hidden] { display: none; }
.back-to-top svg { width: 20px; height: 20px; }

/* ---------- Footer ---------- */
.site-footer { background: var(--green-900); color: #dcecdc; margin-top: 40px; }
.site-footer__grid {
  max-width: 1400px; margin: 0 auto; padding: 40px 24px 20px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 28px;
}
.site-footer h3 { color: #fff; font-size: .95rem; margin: 0 0 10px; }
.site-footer p { margin: 0 0 6px; font-size: .86rem; line-height: 1.5; color: #cfe4cf; }
.footer__logo { width: 46px; height: 46px; border-radius: 50%; margin-bottom: 10px; }
.site-footer__bottom {
  text-align: center; font-size: .78rem; color: #9fc39f;
  padding: 16px; border-top: 1px solid rgba(255,255,255,.1);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; }
  .brand__text { display: none; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 250; width: 280px;
    background: #fff; transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: var(--shadow-lg); padding-top: 18px;
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar__header { display: flex; padding: 0 14px 12px; }
  .sidebar-overlay.is-open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 240; }
  .topbar__search { max-width: none; }
}
@media (max-width: 560px) {
  .content { padding: 18px 12px 50px; }
  .hero { padding: 24px 18px; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .modal__card { flex-direction: column; flex-wrap: nowrap; max-height: 92vh; }
  .modal__img {
    flex: 0 0 auto; align-self: center; width: auto; min-height: 0;
    height: min(48vh, 380px); aspect-ratio: 9 / 16;
  }
  .modal__img img { width: 100%; height: 100%; object-fit: contain; max-height: none; }
  .promo-strip { font-size: .72rem; }
  .drawer__panel { width: 100%; }
}

/* ---------- Cart button ---------- */
.cart-topbtn { position: relative; color: var(--green-700); }
.cart-badge {
  position: absolute; top: 2px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--green-600); color: #fff; font-size: .65rem; font-weight: 700;
  border-radius: 999px; display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
}
.cart-badge[hidden] { display: none; }

/* ---------- Quantity stepper (modal) ---------- */
.qty-stepper {
  display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--line);
  border-radius: 10px; overflow: hidden; width: fit-content; margin-top: 4px;
}
.qty-stepper button {
  width: 36px; height: 36px; border: none; background: var(--green-50); color: var(--green-700);
  font-size: 1.1rem; cursor: pointer; font-family: inherit;
}
.qty-stepper button:hover { background: var(--green-100); }
.qty-stepper input {
  width: 46px; height: 36px; border: none; border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  text-align: center; font: inherit; font-weight: 600; -moz-appearance: textfield;
}
.qty-stepper input::-webkit-outer-spin-button,
.qty-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.btn-link {
  display: block; text-align: center; margin-top: 8px; font-size: .82rem;
  color: var(--ink-soft); text-decoration: underline; text-underline-offset: 2px;
}
.btn-link:hover { color: var(--green-700); }

/* ---------- Cart / Checkout drawer ---------- */
.drawer { position: fixed; inset: 0; z-index: 350; }
.drawer[hidden] { display: none; }
.drawer__backdrop { position: absolute; inset: 0; background: rgba(20, 30, 22, .5); }
.drawer__panel {
  position: absolute; top: 0; right: 0; height: 100%; width: 420px; max-width: 92vw;
  background: #fff; box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: slideIn .22s ease;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.drawer__view { display: flex; flex-direction: column; height: 100%; }
.drawer__view[hidden] { display: none; }
.drawer__header {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.drawer__header h2 { margin: 0; font-size: 1.1rem; flex: 1; }

.cart-items { flex: 1; overflow-y: auto; padding: 10px 18px; }
.cart-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.cart-item__img { width: 64px; height: 64px; border-radius: 10px; overflow: hidden; background: var(--green-50); flex-shrink: 0; }
.cart-item__img img { width: 100%; height: 100%; object-fit: cover; }
.cart-item__info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.cart-item__title { font-size: .84rem; line-height: 1.3; font-weight: 500; }
.cart-item__price { font-size: .8rem; color: var(--ink-soft); }
.cart-item__row { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.cart-item__remove { border: none; background: none; color: #c62828; font-size: .78rem; cursor: pointer; padding: 0; text-decoration: underline; }
.cart-item .qty-stepper button { width: 28px; height: 28px; font-size: 1rem; }
.cart-item .qty-stepper input { width: 34px; height: 28px; font-size: .82rem; }
.cart-item__subtotal { font-weight: 700; color: var(--green-700); font-size: .86rem; }

.cart-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--ink-soft); text-align: center; padding: 0 20px; }
.cart-empty[hidden] { display: none; }

.drawer__footer { padding: 16px 18px; border-top: 1px solid var(--line); flex-shrink: 0; }
.cart-total-row { display: flex; align-items: center; justify-content: space-between; font-size: 1.05rem; margin-bottom: 12px; }
.cart-total-row strong { color: var(--green-700); font-size: 1.2rem; }

.checkout-form { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--ink); font-weight: 600; }
.field em { color: #c62828; font-style: normal; }
.field input[type="text"], .field input[type="email"], .field input[type="tel"] {
  font: inherit; font-weight: 400; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line);
  outline: none; background: var(--green-50);
}
.field input:focus { border-color: var(--green-400); box-shadow: 0 0 0 3px var(--green-100); }
.delivery-field { border: none; padding: 0; margin: 0; }
.delivery-field legend { padding: 0 0 6px; font-weight: 600; font-size: .85rem; }
.radio-row {
  display: flex; align-items: center; gap: 10px; font-weight: 400; font-size: .88rem;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer;
}
.radio-row:has(input:checked) { border-color: var(--green-500); background: var(--green-50); }
.radio-row input { accent-color: var(--green-600); width: 16px; height: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: .86rem; z-index: 400; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 8px;
}
.toast[hidden] { display: none; }
