:root {
  --bg: #fff8f3;
  --surface: #ffffff;
  --sunken: #f5f0e8;
  --ink: #1f1a17;
  --muted: #6b625c;
  --red: #b3170f;
  --red-bright: #d6372a;
  --btn-red: #b3170f;
  --brown: #7a5200;
  --teal-bg: #dcebe8;
  --teal-ink: #2d5a54;
  --line: #ece4da;
  --wa: #128c4a;
  --mp: #0a7fc2;
  --radius: 14px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
:root { color-scheme: light; }
:root[data-tema="oscuro"] {
  color-scheme: dark;
    --bg: #1c1613; --surface: #272019; --sunken: #332a22; --ink: #f6ede4;
    --muted: #b9ada3; --red: #ff6b5c; --btn-red: #c9302a; --line: #3a3027;
    --teal-bg: #26413d; --teal-ink: #a9d6cf; --wa: #1a9d56; --mp: #1590d6;
}
@media (prefers-color-scheme: dark) {
  :root[data-tema="auto"] {
    color-scheme: dark;
    --bg: #1c1613; --surface: #272019; --sunken: #332a22; --ink: #f6ede4;
    --muted: #b9ada3; --red: #ff6b5c; --btn-red: #c9302a; --line: #3a3027;
    --teal-bg: #26413d; --teal-ink: #a9d6cf; --wa: #1a9d56; --mp: #1590d6;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.4;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ico-red { color: var(--red); }

/* ===== Encabezado (incluye la navegación que antes estaba abajo) ===== */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1100px; margin: 0 auto; padding: 8px 16px 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; }
.brand { display: flex; align-items: center; gap: 8px; padding-bottom: 6px; }
.brand-logo { font-size: 26px; }
.brand-name { display: flex; flex-direction: column; font-weight: 800; font-size: 18px; color: var(--red); line-height: 1; text-transform: uppercase; }
.brand-name small { font-size: 10px; font-weight: 700; color: var(--ink); letter-spacing: .06em; margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; padding-bottom: 6px; margin-left: auto; order: 2; }
.icon-btn { position: relative; background: none; border: 0; padding: 6px; display: grid; place-items: center; border-radius: 8px; }
.cart-btn { position: relative; display: inline-flex; align-items: center; gap: 6px; background: var(--btn-red); color: #fff; border: 0; border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: 13px; }
.cart-label { display: none; }
.badge { position: absolute; top: -6px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--ink); color: var(--bg); font-size: 11px; font-weight: 700; display: grid; place-items: center; }

.mainnav { order: 3; width: 100%; display: flex; justify-content: space-around; }
.mainnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 14px 7px; border-bottom: 3px solid transparent; }
.mainnav a.is-active { color: var(--red); font-weight: 700; border-bottom-color: var(--red); }
.mainnav a:hover { color: var(--red); }
@media (min-width: 720px) {
  .topbar-in { flex-wrap: nowrap; padding-top: 6px; }
  .brand, .topbar-actions { padding-bottom: 6px; }
  .mainnav { order: 0; width: auto; flex: 1; justify-content: center; gap: 6px; }
  .mainnav a { flex-direction: row; gap: 7px; font-size: 14px; padding: 14px 16px 12px; margin-bottom: -7px; }
  .topbar-actions { order: 0; margin-left: 0; }
  .cart-label { display: inline; }
}

/* ===== Contenedor ===== */
.page { max-width: 1100px; margin: 0 auto; padding: 16px 16px 40px; display: flex; flex-direction: column; gap: 22px; }

/* Buscador y chips */
.search { display: flex; align-items: center; gap: 10px; background: var(--sunken); border-radius: 999px; padding: 6px 8px 6px 16px; }
.search input { flex: 1; min-width: 0; border: 0; background: none; padding: 8px 0; }
.search input:focus { outline: none; }
.search:focus-within { box-shadow: 0 0 0 2px var(--red); }
.search-go { border: 0; background: var(--btn-red); color: #fff; font-weight: 700; font-size: 13px; padding: 8px 16px; border-radius: 999px; }
.search-inline { max-width: 340px; width: 100%; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: 13px; }
.chip.is-active { background: var(--btn-red); border-color: var(--btn-red); color: #fff; }

/* Banner */
.hero { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 20px; border-radius: 12px; color: #fff; background: linear-gradient(100deg, #c42a1f 0%, #d6372a 45%, var(--brown) 100%); }
.hero-text { max-width: 480px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.hero-tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; background: rgba(255,255,255,.18); font-size: 11px; font-weight: 700; }
.hero-tag .ico { width: 12px; height: 12px; }
.hero h1 { font-size: clamp(20px, 3.4vw, 28px); line-height: 1.15; font-weight: 800; }
.hero p { font-size: 13px; opacity: .92; }
.btn-light { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; background: #fff; color: #1f1a17; font-weight: 700; font-size: 14px; padding: 10px 18px; border-radius: 10px; }
.btn-light .ico { width: 16px; height: 16px; }
.hero-img { font-size: clamp(56px, 12vw, 110px); line-height: 1; padding-right: 8px; flex: none; }

/* Secciones */
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
h2 { font-size: 19px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.cat-titulo { font-size: clamp(20px, 3vw, 26px); font-weight: 800; }
.cat-head { margin-bottom: 0; align-items: center; }
.sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.link-red { color: var(--red); font-size: 13px; font-weight: 600; background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.muted-label { font-size: 12px; font-weight: 700; color: var(--muted); }
.muted { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; grid-column: 1 / -1; }

/* Categorías */
.cats { display: flex; gap: 18px; overflow-x: auto; padding: 4px 2px; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cats a { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; min-width: 62px; }
.cat-circle { width: 56px; height: 56px; border-radius: 50%; background: var(--surface); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); display: grid; place-items: center; font-size: 26px; }

/* ===== Filtros ===== */
.filtros { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px 14px 12px; }
.filtros summary { list-style: none; display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 10px 0; cursor: pointer; }
.filtros summary::-webkit-details-marker { display: none; }
.filtros summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
.filtros[open] summary::after { content: "▴"; }
.filtros-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 12px; margin-bottom: 8px; }

/* Formularios generales */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label, .field legend { font-size: 12px; font-weight: 700; color: var(--muted); padding: 0; }
.field input:not([type=checkbox]):not([type=radio]), .field select {
  width: 100%; min-height: 42px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.field input[type=file] { font-size: 13px; }
fieldset.field { border: 0; margin: 0; padding: 0; }
.radios { display: flex; flex-direction: row; flex-wrap: wrap; gap: 6px 18px; }
.radios legend { width: 100%; margin-bottom: 4px; }
.radios label { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; color: var(--ink); }
.form-error { color: var(--red); font-size: 13px; font-weight: 600; min-height: 0; }
.form-error:empty { display: none; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ===== Productos ===== */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 14px; } }
@media (min-width: 980px) { .grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 380px) { .grid { grid-template-columns: 1fr; } }

.card { background: var(--surface); border-radius: 12px; padding: 10px; box-shadow: 0 1px 3px rgba(60,30,10,.08); display: flex; flex-direction: column; min-width: 0; }
.card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; min-height: 22px; }
.tag { font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 6px; background: var(--sunken); color: var(--muted); }
.tag-size { background: var(--teal-bg); color: var(--teal-ink); margin-left: auto; }
.card-img { position: relative; display: grid; place-items: center; height: 110px; border-radius: 8px; background: var(--sunken); font-size: 46px; overflow: hidden; margin-bottom: 10px; }
.card-img img { width: 100%; height: 100%; object-fit: contain; }
.card-brand { font-size: 11px; font-weight: 700; color: var(--red); text-transform: uppercase; letter-spacing: .03em; }
.card h3 { font-size: 14px; font-weight: 700; margin-top: 1px; overflow-wrap: anywhere; }
.card .desc { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-foot { display: flex; align-items: baseline; flex-wrap: wrap; margin-top: auto; padding-top: 12px; }
.price { font-size: 18px; font-weight: 800; color: var(--red); }
.price-old { font-size: 12px; color: var(--muted); text-decoration: line-through; margin-left: 6px; }
.discount { position: absolute; top: 8px; left: 8px; background: var(--btn-red); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; z-index: 1; }
.fav { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; background: var(--surface); border: 0; display: grid; place-items: center; z-index: 1; }
.fav .ico { width: 15px; height: 15px; }
.fav[aria-pressed="true"] .ico { fill: var(--red); stroke: var(--red); }
.card-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; padding: 9px 14px; border-radius: 10px; border: 1.5px solid transparent; font-weight: 800; font-size: 12px; letter-spacing: .03em; text-transform: uppercase; text-align: center; line-height: 1.15; transition: transform .12s, filter .12s; }
.btn:active { transform: scale(.97); }
.btn .ico { width: 17px; height: 17px; }
.btn-buy { background: var(--btn-red); color: #fff; }
.btn-buy:hover { filter: brightness(1.08); }
.btn-cart { background: transparent; color: var(--red); border-color: var(--red); }
.btn-cart:hover { background: color-mix(in srgb, var(--red) 8%, transparent); }
.btn-wa { background: var(--wa); color: #fff; }
.btn-mp { background: var(--mp); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-danger { background: var(--btn-red); color: #fff; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 11px; }

.timer { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; color: var(--red); background: color-mix(in srgb, var(--red) 10%, var(--bg)); padding: 4px 10px; border-radius: 999px; }
.timer .ico { width: 14px; height: 14px; }

/* ===== Carrito (cajón lateral) ===== */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%); background: var(--bg); z-index: 60; display: flex; flex-direction: column; transform: translateX(100%); transition: transform .25s ease, visibility 0s linear .25s; visibility: hidden; }
.drawer.is-open { transform: none; visibility: visible; transition: transform .25s ease, visibility 0s; box-shadow: -8px 0 30px rgba(0,0,0,.2); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer-body { flex: 1; overflow-y: auto; padding: 8px 16px; }
.drawer-foot { padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; background: var(--surface); }
.cart-empty { text-align: center; padding: 40px 10px; display: flex; flex-direction: column; gap: 12px; align-items: center; color: var(--muted); }
.cart-empty span { font-size: 48px; }
.cl { display: grid; grid-template-columns: 58px 1fr auto; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.cl-img { width: 58px; height: 58px; border-radius: 8px; background: var(--sunken); display: grid; place-items: center; font-size: 28px; overflow: hidden; }
.cl-img img { width: 100%; height: 100%; object-fit: contain; }
.cl-name { font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.cl-meta { font-size: 12px; color: var(--muted); }
.cl-side { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; font-size: 14px; }
.qty { display: inline-flex; align-items: center; gap: 2px; margin-top: 6px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.qty button { width: 32px; height: 32px; border: 0; background: none; font-size: 18px; font-weight: 700; border-radius: 50%; }
.qty span { min-width: 22px; text-align: center; font-weight: 700; }
.link-del { background: none; border: 0; color: var(--muted); font-size: 12px; text-decoration: underline; padding: 4px; }
.link-del.center { align-self: center; }
.cart-total { display: flex; justify-content: space-between; align-items: baseline; font-size: 16px; }
.cart-total strong { font-size: 22px; font-weight: 800; color: var(--red); }

/* ===== Ventanas (dialog) ===== */
.dlg { border: 0; border-radius: 16px; padding: 18px; width: min(460px, calc(100% - 24px)); max-height: calc(100% - 24px); background: var(--bg); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.dlg-wide { width: min(720px, calc(100% - 24px)); }
.dlg::backdrop { background: rgba(0,0,0,.5); }
.dlg form { display: flex; flex-direction: column; gap: 12px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.dlg-actions .btn { flex: 1 1 140px; }
.co-resumen { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.co-resumen li { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.co-aviso { font-size: 12px; color: var(--muted); }

/* Aviso */
.toast { position: fixed; left: 50%; top: 92px; transform: translate(-50%, -16px); opacity: 0; pointer-events: none; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 600; transition: opacity .2s, transform .2s; z-index: 100; max-width: 90vw; }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* Pie y resultado de pago */
.footer { border-top: 1px solid var(--line); background: var(--sunken); }
.footer-in { max-width: 1100px; margin: 0 auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.footer a { text-decoration: underline; text-underline-offset: 2px; }
.result { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 40px 10px; }
.result-emoji { font-size: 64px; }
.result h1 { font-size: 24px; font-weight: 800; }
.result p { color: var(--muted); max-width: 440px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px; }

/* ===== Administración ===== */
.admin-page { gap: 16px; }
.demo-banner { background: color-mix(in srgb, var(--brown) 14%, var(--bg)); border: 1px solid color-mix(in srgb, var(--brown) 40%, var(--bg)); border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.demo-banner code { background: var(--sunken); padding: 1px 6px; border-radius: 4px; }
.login-card { width: min(400px, 100%); margin: 24px auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 22px; font-weight: 800; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab { background: none; border: 0; padding: 10px 16px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab.is-active { color: var(--red); border-bottom-color: var(--red); }
.admin-bar { display: grid; grid-template-columns: 1fr; gap: 10px; align-items: end; margin-bottom: 8px; }
@media (min-width: 720px) { .admin-bar { grid-template-columns: 1.5fr 1fr 1fr auto; } }
.table-wrap { margin-top: 8px; overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 12px; overflow: hidden; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); padding: 10px 12px; background: var(--sunken); }
.tbl td { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.td-acc { white-space: nowrap; text-align: right; }
.td-acc .btn + .btn { margin-left: 6px; }
.btn-del { color: var(--red); }
.thumb { width: 48px; height: 48px; border-radius: 8px; background: var(--sunken); display: grid; place-items: center; font-size: 24px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.pill { display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--sunken); color: var(--muted); margin-left: 4px; }
.pill-ok { background: var(--teal-bg); color: var(--teal-ink); margin-left: 0; }
.pill-off { background: color-mix(in srgb, var(--red) 14%, var(--bg)); color: var(--red); margin-left: 0; }
@media (max-width: 719px) {
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; }
  .tbl tr { border-top: 1px solid var(--line); padding: 10px 12px; display: grid; grid-template-columns: 56px 1fr; gap: 2px 10px; }
  .tbl td { border: 0; padding: 2px 0; }
  .tbl td.td-foto { grid-row: 1 / span 5; }
  .tbl td[data-label]::before { content: attr(data-label) ": "; font-size: 11px; color: var(--muted); font-weight: 700; }
  .tbl td.td-foto::before { content: none; }
  .td-acc { grid-column: 2; text-align: left; padding-top: 6px; }
}
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 12px; max-height: 62vh; overflow-y: auto; padding: 2px; }
.span2 { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.checks { justify-content: center; gap: 8px; }
.checks label { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--ink); }
.img-row { display: flex; gap: 12px; align-items: center; }
.img-prev { width: 72px; height: 72px; border-radius: 10px; background: var(--sunken); display: grid; place-items: center; font-size: 34px; overflow: hidden; flex: none; }
.img-prev img { width: 100%; height: 100%; object-fit: contain; }
.order { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.order-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.order select { min-height: 38px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.order ul { padding-left: 4px; display: flex; flex-direction: column; gap: 2px; }

/* Pantallas grandes */
@media (min-width: 900px) {
  .page { gap: 30px; padding-top: 22px; }
  .card-img { height: 150px; font-size: 56px; }
  .hero { padding: 36px 40px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

.badge-inline { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--btn-red); color: #fff; font-size: 11px; font-weight: 800; }

.brand-logo-img { height: 38px; width: auto; max-width: 120px; object-fit: contain; display: block; }
.hero-photo { width: clamp(110px, 30vw, 260px); aspect-ratio: 1; object-fit: cover; border-radius: 16px; display: block; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
