:root {
  --brand: #d90f1c;
  --brand-dark: #a80a15;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #ececef;
  --bg: #f6f6f7;
  --card: #ffffff;
  --ok: #128c4a;
  --wa: #1fa855;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 14px rgba(0,0,0,.05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: env(safe-area-inset-bottom);
}
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

/* Encabezado */
.top { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line); padding: 10px 16px 0; }
.top-row { display: flex; align-items: center; justify-content: space-between; max-width: 1200px; margin: 0 auto; }
.brand img { height: 34px; width: auto; }
.cart-btn { position: relative; border: 0; background: transparent; color: var(--ink); padding: 8px; border-radius: 50%; }
.cart-btn:hover { background: var(--bg); }
.badge { position: absolute; top: 0; right: -2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.search { display: flex; align-items: center; gap: 8px; max-width: 1200px; margin: 10px auto 0; background: var(--bg); border-radius: 12px; padding: 0 12px; color: var(--muted); }
.search input { flex: 1; border: 0; background: transparent; padding: 11px 0; font: inherit; color: var(--ink); outline: none; min-width: 0; }
.chips { display: flex; gap: 8px; overflow-x: auto; max-width: 1200px; margin: 0 auto; padding: 10px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 14px; white-space: nowrap; color: var(--ink); text-decoration: none; font-size: 14px; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

main { max-width: 1200px; margin: 0 auto; padding: 14px 16px 120px; outline: none; }
.loading, .empty { text-align: center; color: var(--muted); padding: 60px 16px; }
.notice { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; font-size: 13.5px; color: var(--muted); margin-bottom: 14px; text-align: center; }
.count { color: var(--muted); font-size: 13px; margin: 0 2px 10px; }

/* Cuadrícula de productos */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; text-decoration: none; position: relative; }
.card .ph { aspect-ratio: 1; background: #fafafa; }
.card .ph img { width: 100%; height: 100%; object-fit: cover; }
.card.out .ph img { filter: grayscale(.85); opacity: .6; }
.card .info { padding: 10px 11px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card .name { font-size: 14px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .hook { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prices { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 4px; }
.price { font-weight: 800; font-size: 16px; }
.price.promo { color: var(--brand); }
.was { color: var(--muted); text-decoration: line-through; font-size: 13px; }
.tag { position: absolute; top: 8px; left: 8px; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: var(--brand); color: #fff; }
.tag.out { background: #4a4a4f; }
.card .prices { padding-right: 40px; }
.card .add-btn { position: absolute; right: 8px; bottom: 10px; }
.add-btn { border: 0; background: var(--brand); color: #fff; width: 36px; height: 36px; border-radius: 50%; font-size: 22px; line-height: 1; display: grid; place-items: center; box-shadow: var(--shadow); }
.add-btn:active { transform: scale(.94); }

/* Ficha de producto */
.back { border: 0; background: transparent; color: var(--muted); padding: 4px 0 12px; font-size: 14px; }
.pdp { display: grid; gap: 20px; }
@media (min-width: 860px) { .pdp { grid-template-columns: 1fr 1fr; gap: 36px; align-items: start; } .pdp .gallery { position: sticky; top: 170px; } }
.gallery .slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; border-radius: var(--radius); background: #fff; scrollbar-width: none; }
.gallery .slides::-webkit-scrollbar { display: none; }
.gallery .slides img { flex: none; width: 100%; aspect-ratio: 1; object-fit: contain; scroll-snap-align: center; }
.thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; }
.thumbs button { flex: none; width: 58px; height: 58px; padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: #fff; }
.thumbs button.on { border-color: var(--brand); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; }
.pdp h1 { font-size: 22px; line-height: 1.25; margin: 0 0 4px; }
.pdp .sub { color: var(--muted); margin: 0 0 12px; }
.pdp .prices .price { font-size: 26px; }
.pdp .save { background: #fde8ea; color: var(--brand-dark); font-weight: 700; font-size: 12.5px; padding: 3px 8px; border-radius: 6px; }
.code { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.buy { display: flex; gap: 10px; margin: 18px 0; flex-wrap: wrap; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.qty button { border: 0; background: transparent; width: 40px; height: 44px; font-size: 20px; color: var(--ink); }
.qty span { min-width: 28px; text-align: center; font-weight: 700; }
.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; min-height: 46px; }
.btn.primary { background: var(--brand); color: #fff; flex: 1; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.wa { background: var(--wa); color: #fff; }
.btn.ghost { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.out-box { background: #f1f1f3; border-radius: 12px; padding: 12px 14px; margin: 16px 0; color: var(--muted); }
.desc { background: #fff; border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); white-space: normal; }
.desc h3 { font-size: 14px; letter-spacing: .02em; margin: 16px 0 6px; }
.desc h3:first-child { margin-top: 0; }
.desc p { margin: 0 0 8px; }

/* Carrito y pago */
.panel { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.panel h2 { font-size: 17px; margin: 0 0 12px; }
.line { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.line:first-of-type { border-top: 0; }
.line img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; background: #fafafa; }
.line .n { font-size: 14px; font-weight: 600; line-height: 1.3; }
.line .u { color: var(--muted); font-size: 13px; }
.line .qty button { width: 32px; height: 34px; font-size: 18px; }
.line .rm { border: 0; background: transparent; color: var(--muted); font-size: 12.5px; text-decoration: underline; padding: 4px 0; }
.line .lt { font-weight: 700; text-align: right; }
.totals { display: grid; gap: 6px; }
.totals div { display: flex; justify-content: space-between; }
.totals .big { font-size: 19px; font-weight: 800; border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px; }
.form { display: grid; gap: 12px; }
@media (min-width: 640px) { .form.two { grid-template-columns: 1fr 1fr; } .form .full { grid-column: 1 / -1; } }
label { display: grid; gap: 5px; font-size: 13.5px; font-weight: 600; }
label small { font-weight: 400; color: var(--muted); }
input, textarea, select { font: inherit; border: 1px solid #d9d9de; border-radius: 10px; padding: 11px 12px; background: #fff; color: var(--ink); width: 100%; }
input:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
.pay-opts { display: grid; gap: 10px; }
.pay-opt { display: flex; align-items: center; gap: 12px; text-align: left; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 14px; width: 100%; }
.pay-opt:hover { border-color: var(--brand); }
.pay-opt .ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 20px; background: var(--bg); flex: none; }
.pay-opt b { display: block; }
.pay-opt small { color: var(--muted); }
.pay-opt.wa .ic { background: #e3f6ea; }
.testmode { display: inline-block; background: #fff4cc; color: #7a5b00; font-size: 11.5px; font-weight: 700; border-radius: 6px; padding: 2px 6px; margin-left: 6px; }
.err { color: var(--brand-dark); background: #fde8ea; border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.bold-box { display: grid; gap: 10px; justify-items: center; padding: 10px 0; }

/* Estado del pedido */
.status { text-align: center; padding: 28px 16px; }
.status .big-ic { font-size: 54px; line-height: 1; }
.status h1 { font-size: 22px; margin: 10px 0 6px; }
.status p { color: var(--muted); margin: 0 auto 6px; max-width: 460px; }
.status .ref { font-family: ui-monospace, Consolas, monospace; background: var(--bg); padding: 2px 8px; border-radius: 6px; color: var(--ink); }

/* Barra fija del carrito en móvil */
.sticky-cart { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 30; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--ink); color: #fff; border: 0; border-radius: 14px; padding: 14px 18px; font-weight: 700; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 560px; margin: 0 auto; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 40; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.install { position: fixed; right: 16px; bottom: 84px; z-index: 25; border: 0; background: #fff; color: var(--ink); border-radius: 999px; padding: 10px 16px; font-weight: 700; box-shadow: var(--shadow), 0 0 0 1px var(--line); }
footer.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 16px 10px; }
