:root {
  --accent: #0f766e;
  --accent-ink: #fff;
  --bg: #f6f7f9;
  --surface: #fff;
  --ink: #1d2330;
  --muted: #667085;
  --line: #e4e7ec;
  --wa: #25d366;
  --wa-dark: #128c4a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .06);
  --topbar-h: 64px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; display: flex; flex-direction: column; }
body > main { flex: 1; width: 100%; } /* el pie queda abajo aunque haya poco contenido */
img { max-width: 100%; display: block; }
img[data-src] { visibility: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.container { max-width: 1200px; margin: 0 auto; padding: 20px 16px 48px; }

/* ---------- Pie de página ---------- */
.footer { background: #1d2330; color: #d0d5dd; }
.footer:empty { display: none; }
.footer-inner { max-width: 1200px; margin: 0 auto; padding: 32px 16px 24px; }
.footer h2 { color: #fff; font-size: 1.05rem; margin: 0 0 14px; }
.contact-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px 24px; }
.contact-list a { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; padding: 4px 0; word-break: break-word; }
.contact-list a:hover { color: #fff; }
.contact-list a:hover span { text-decoration: underline; }
.contact-list svg { width: 20px; height: 20px; flex: none; fill: color-mix(in srgb, var(--accent) 55%, #fff); }
.copy { margin: 24px 0 0; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, .12); font-size: .82rem; color: #98a2b3; }
.loading, .empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* ---------- Topbar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1200px; margin: 0 auto; height: var(--topbar-h); padding: 0 16px; display: flex; align-items: center; gap: 16px; }
.brand { font-weight: 800; font-size: 1.15rem; text-decoration: none; color: var(--accent); max-width: 40%; display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-logo { height: 44px; width: auto; max-width: 160px; object-fit: contain; flex: none; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; height: 42px; min-width: 0; }
.search svg { width: 18px; height: 18px; fill: var(--muted); flex: none; }
.search input { border: 0; background: transparent; outline: none; width: 100%; height: 100%; min-width: 0; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.cart-btn { position: relative; display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.cart-btn svg { width: 20px; height: 20px; fill: currentColor; }
.badge { position: absolute; top: -6px; right: -6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: #e11d48; color: #fff; font-size: .75rem; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface); }
.badge[hidden] { display: none; }

/* ---------- Hero / títulos ---------- */
.hero { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 65%, #000)); color: #fff; border-radius: var(--radius); padding: 28px 24px; margin-bottom: 28px; }
.hero h1 { margin: 0 0 6px; font-size: clamp(1.4rem, 3vw, 2rem); }
.hero p { margin: 0; opacity: .9; }
.section-title { font-size: 1.15rem; margin: 0 0 14px; }
.crumbs { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: .9rem; margin-bottom: 10px; }
.crumbs a { color: var(--accent); text-decoration: none; }
.page-title { margin: 0 0 16px; font-size: clamp(1.3rem, 3vw, 1.7rem); }

/* ---------- Categorías ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.cat-card { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); text-decoration: none; display: flex; flex-direction: column; transition: transform .15s, box-shadow .15s; }
.cat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(16, 24, 40, .12); }
/* Recuadro fijo: la foto se recorta para llenarlo, sin importar su tamaño o proporción */
.cat-img { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: var(--line); }
.cat-img > img, .cat-img > .ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; }
.cat-info h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.cat-info { padding: 12px 14px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cat-info h3 { margin: 0; font-size: 1rem; }
.cat-info span { color: var(--muted); font-size: .85rem; white-space: nowrap; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 18px; scrollbar-width: thin; }
.chip { flex: none; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); text-decoration: none; font-size: .9rem; white-space: nowrap; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- Productos ---------- */
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.product { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.product-img { position: relative; aspect-ratio: 1 / 1; overflow: hidden; background: var(--line); }
.product-img > img, .product-img > .ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.product-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product h3 { margin: 0; font-size: 1rem; line-height: 1.3; }
.product .desc { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.35; }
.product .cat-tag { font-size: .78rem; color: var(--accent); font-weight: 600; text-decoration: none; }
.price { font-size: 1.2rem; font-weight: 800; margin-top: auto; padding-top: 4px; }
.in-cart { font-size: .8rem; color: var(--accent); font-weight: 600; min-height: 1.1em; }
.product-actions { display: flex; gap: 8px; align-items: center; }

/* Oferta */
.sale-badge { align-self: flex-start; display: inline-block; background: #e11d48; color: #fff; font-size: .75rem; font-weight: 800; letter-spacing: .03em; padding: 4px 9px; border-radius: 999px; box-shadow: 0 2px 6px rgba(225, 29, 72, .35); }
.product-img > .sale-badge { position: absolute; top: 10px; left: 10px; z-index: 1; }
.product.on-sale { outline: 2px solid #e11d48; outline-offset: -2px; }
.product.on-sale.no-img { border-top-color: #e11d48; }
.product.on-sale .price > span { color: #e11d48; }
.price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.old-price { font-size: .85rem; font-weight: 500; color: var(--muted); }
.unit-sale { color: #e11d48; font-weight: 600; }

/* Producto sin imagen: tarjeta compacta */
.product.no-img { border-top: 4px solid var(--accent); }
.product-head { display: flex; align-items: center; gap: 10px; }
.product-head .ph { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.prod-grid { align-items: start; }

.ph { display: grid; place-items: center; font-size: 2.4rem; font-weight: 800; color: #fff; background: linear-gradient(135deg, hsl(var(--h) 55% 55%), hsl(calc(var(--h) + 40) 55% 42%)); }
.ph.small { font-size: 1.1rem; }

.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); flex: none; }
.qty button { width: 34px; height: 38px; border: 0; background: transparent; font-size: 1.1rem; }
.qty button:hover { background: var(--bg); }
.qty input { width: 40px; height: 38px; border: 0; text-align: center; -moz-appearance: textfield; appearance: textfield; background: transparent; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty select { height: 38px; min-width: 76px; border: 0; background: transparent; text-align: center; text-align-last: center; font: inherit; font-weight: 600; cursor: pointer; }
.qty .qty-unit { font-size: .8rem; color: var(--muted); padding-right: 4px; }
.price .per-kg { font-size: .8rem; font-weight: 600; color: var(--muted); margin-left: -6px; }

.btn { border: 0; border-radius: 10px; height: 40px; padding: 0 14px; font-weight: 600; background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:hover { filter: brightness(1.08); }
.btn.block { width: 100%; }
.btn.add { flex: 1; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.wa { background: var(--wa); color: #fff; height: 48px; font-size: 1rem; }
.btn.wa:hover { background: var(--wa-dark); filter: none; }
.btn.wa svg { width: 22px; height: 22px; fill: currentColor; }
.link-btn { border: 0; background: none; color: var(--muted); text-decoration: underline; font-size: .85rem; padding: 4px; }

/* ---------- Carrito ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 40; }
.overlay[hidden] { display: none; }
.cart { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); background: var(--surface); z-index: 50; display: flex; flex-direction: column; transform: translateX(100%); transition: transform .25s ease; box-shadow: -8px 0 30px rgba(0, 0, 0, .15); }
.cart.open { transform: none; }
.cart-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.cart-head h2 { margin: 0; font-size: 1.2rem; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--bg); font-size: 1rem; }
.cart-body { flex: 1; overflow-y: auto; padding: 8px 18px; }
.cart-item { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: center; }
.cart-item:last-child { border-bottom: 0; }
.cart-thumb { width: 56px; height: 56px; border-radius: 10px; overflow: hidden; background: var(--line); }
.cart-thumb > img, .cart-thumb > .ph { width: 100%; height: 100%; object-fit: cover; }
.cart-item h4 { margin: 0 0 2px; font-size: .95rem; }
.cart-item .unit { color: var(--muted); font-size: .82rem; }
.cart-item .controls { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.cart-item .qty button { width: 30px; height: 32px; }
.cart-item .qty input { width: 36px; height: 32px; }
.cart-item .qty select { height: 32px; min-width: 70px; }
.cart-item .subtotal { font-weight: 700; text-align: right; white-space: nowrap; }
.remove { border: 0; background: none; color: #b42318; font-size: .82rem; padding: 4px; }
.cart-empty { text-align: center; color: var(--muted); padding: 48px 12px; }
.cart-empty .big { font-size: 3rem; margin-bottom: 8px; }
.cart-foot { border-top: 1px solid var(--line); padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.cart-foot:empty { display: none; }
.total-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.05rem; }
.total-row strong { font-size: 1.35rem; }
.price-notice { margin: -4px 0 4px; font-size: .78rem; color: var(--muted); line-height: 1.35; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); }
.field input, .field textarea { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--ink); background: var(--surface); resize: vertical; }
.field input:focus, .field textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.field input[aria-invalid="true"] { border-color: #d92d20; outline: 2px solid rgba(217, 45, 32, .2); }
.field-error { color: #d92d20; font-size: .8rem; }
.field-error[hidden] { display: none; }
.foot-actions { display: flex; justify-content: space-between; }

/* Barra inferior (solo celular) */
.cart-bar { display: none; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .92rem; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  :root { --topbar-h: auto; }
  .topbar-inner { flex-wrap: wrap; padding: 10px 12px; gap: 10px; }
  .brand { max-width: calc(100% - 70px); flex: 1; font-size: 1.05rem; gap: 8px; }
  .brand-logo { height: 38px; max-width: 120px; }
  .search { order: 3; flex-basis: 100%; height: 40px; }
  .cart-btn { padding: 0 12px; }
  .cart-btn-label { display: none; }
  .container { padding: 14px 12px 32px; }
  .footer-inner { padding: 24px 16px 100px; } /* espacio para la barra del carrito */
  .contact-list { grid-template-columns: 1fr; gap: 6px; }
  .contact-list a { padding: 8px 0; }
  .hero { padding: 20px 18px; margin-bottom: 20px; }
  .cat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cat-info { flex-direction: column; gap: 2px; padding: 10px 12px; }
  .prod-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .product-body { padding: 10px; }
  .product h3 { font-size: .92rem; }
  .product .desc { display: none; }
  .product.no-img .desc { display: block; font-size: .8rem; }
  .product-head { gap: 8px; }
  .product-head .ph { width: 32px; height: 32px; font-size: .95rem; border-radius: 8px; }
  .price { font-size: 1.05rem; }
  .product-actions { flex-direction: column; align-items: stretch; }
  .btn.add { flex: none; }
  .qty { justify-content: space-between; }
  .qty input, .qty select { flex: 1; }
  .cart-bar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 0; border-radius: 14px; padding: 14px 16px; background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 24px rgba(0, 0, 0, .25); font-size: .92rem; }
  .cart-bar[hidden] { display: none; }
  .toast { bottom: 90px; }
}
@media (max-width: 360px) {
  .prod-grid { grid-template-columns: 1fr; }
}
