:root {
  --bg: #fffdfa;
  --surface: #ffffff;
  --surface-2: #f7f1ea;
  --text: #2a1f1a;
  --muted: #74675e;
  --border: #eee4d8;
  --primary: #c62832;
  --primary-ink: #ffffff;
  --primary-soft: #fdecec;
  --ok: #2e7d4f;
  --ok-soft: #e3f3e9;
  --warn: #a35f00;
  --warn-soft: #fdf0dc;
  --shadow: 0 1px 2px rgba(60, 30, 10, .06), 0 4px 16px rgba(60, 30, 10, .06);
  --radius: 14px;

  --c-hojaldres: #c0605f;
  --c-bombones: #8a4b3c;
  --c-especialidades: #3f86b8;
  --c-ibericos: #6e6862;
  --c-hogar: #3f8d43;
  --c-perfumes: #9a68ae;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* ------------------------------------------------------------ cabecera */
.hero {
  background:
    radial-gradient(circle at 92% 20%, rgba(198, 40, 50, .10) 0 90px, transparent 91px),
    radial-gradient(circle at 80% 85%, rgba(63, 141, 67, .10) 0 60px, transparent 61px),
    linear-gradient(180deg, #fff4ee, #fdf9f4);
  border-bottom: 1px solid var(--border);
  padding: 30px 0 26px;
}
.hero h1 { margin: 0 0 6px; font-size: clamp(1.7rem, 4.5vw, 2.5rem); letter-spacing: -.01em; color: var(--primary); }
.hero h1::before { content: "🎄 "; }
.hero p { margin: 0; font-size: 1.05rem; font-weight: 600; }
.hero .msg { margin-top: 8px; max-width: 720px; font-size: .95rem; font-weight: 400; color: var(--muted); }
.hero .deadline {
  display: inline-block; margin-top: 12px; padding: 4px 12px; border-radius: 999px;
  background: var(--primary); color: #fff; font-size: .85rem; font-weight: 600;
}

.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.hero-actions .deadline { margin-top: 0; }
.wa-btn {
  display: inline-flex; align-items: center; gap: 8px; border: 0; cursor: pointer;
  padding: 7px 14px; border-radius: 999px; background: #25d366; color: #fff;
  font-weight: 700; font-size: .9rem; box-shadow: 0 2px 8px rgba(37, 211, 102, .3);
}
.wa-btn:hover { background: #1ebe5b; }
.wa-btn svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.wa-icon {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none; padding: 0;
  border: 1px solid #c9eed6; border-radius: 10px; background: #effbf3; color: #1aa851; cursor: pointer;
}
.wa-icon svg { width: 18px; height: 18px; fill: currentColor; }
.foot-actions { display: inline-flex; align-items: center; gap: 6px; }

.banner {
  margin: 16px 0 0; padding: 12px 14px; border-radius: 10px;
  background: var(--warn-soft); color: var(--warn); font-weight: 600;
}

/* ------------------------------------------------------------ filtros */
.toolbar {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  padding: 12px 0 8px;
  border-bottom: 1px solid var(--border);
}
.search {
  width: 100%; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--border); background: var(--surface);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: .9rem; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ------------------------------------------------------------ catálogo */
.section-title {
  margin: 34px 0 16px; padding: 10px 16px; display: flex; align-items: center; gap: 12px;
  font-size: clamp(1.35rem, 3.5vw, 1.7rem); font-weight: 800; letter-spacing: -.01em;
  color: var(--cat, var(--primary));
  background: linear-gradient(90deg, color-mix(in srgb, var(--cat) 14%, #fff), transparent 85%);
  border-left: 6px solid var(--cat, var(--primary)); border-radius: 12px;
}
.section-title .icon {
  display: grid; place-items: center; width: 42px; height: 42px; flex: none;
  border-radius: 50%; background: #fff; font-size: 1.4rem; box-shadow: var(--shadow);
}
.section-title .n {
  margin-left: auto; font-size: .8rem; font-weight: 700; color: var(--muted);
  background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 14px; }

.search-row { display: flex; gap: 8px; align-items: center; }
.vista-btn {
  display: none; flex: none; width: 44px; height: 44px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.vista-btn svg { width: 20px; height: 20px; fill: currentColor; }

@media (max-width: 520px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .vista-btn { display: grid; place-items: center; }
  .una-columna .grid { grid-template-columns: 1fr; gap: 14px; }
  .una-columna .card h3 { font-size: 1.1rem; }
  .una-columna .price { font-size: 1.25rem; }
}

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.card .thumb {
  position: relative; aspect-ratio: 1; background: #fff; cursor: zoom-in;
  border: 0; border-bottom: 1px solid var(--border); padding: 6px; width: 100%; overflow: hidden;
}
.card .thumb img { width: 100%; height: 100%; object-fit: contain; }
.placeholder {
  width: 100%; height: 100%; display: grid; place-items: center; text-align: center;
  background: linear-gradient(135deg, var(--cat), color-mix(in srgb, var(--cat) 55%, #000));
  color: #fff; padding: 12px;
}
.placeholder b { display: block; font-size: 2.6rem; line-height: 1; }
.placeholder span { display: block; margin-top: 6px; font-size: .8rem; opacity: .85; }
.code-tag {
  position: absolute; top: 8px; left: 8px; background: var(--cat); color: #fff; opacity: .9;
  font-weight: 700; font-size: .78rem; padding: 2px 8px; border-radius: 6px;
}
.card .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card h3 { margin: 0; font-size: .98rem; line-height: 1.25; }
.card .details { color: var(--muted); font-size: .82rem; }
.card .foot { margin-top: auto; padding-top: 8px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.card .foot-actions { margin-left: auto; }
.price { font-weight: 800; font-size: 1.1rem; }

.btn {
  border: 0; border-radius: 10px; padding: 9px 14px; cursor: pointer; font-weight: 600;
  background: var(--primary); color: var(--primary-ink);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.small { padding: 6px 10px; font-size: .88rem; }
.btn.danger { background: transparent; color: var(--primary); border: 1px solid var(--primary); }

.qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.qty button { border: 0; background: var(--surface-2); width: 34px; height: 34px; cursor: pointer; font-size: 1.1rem; font-weight: 700; }
.qty span { min-width: 30px; text-align: center; font-weight: 700; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ------------------------------------------------------------ botón carrito */
.cart-fab {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-radius: 999px;
  border: 0; background: var(--primary); color: var(--primary-ink); font-weight: 700; font-size: 1rem;
  box-shadow: 0 8px 24px rgba(140, 20, 30, .35); cursor: pointer; max-width: calc(100% - 32px);
}
.cart-fab .count { background: #fff; color: var(--primary); border-radius: 999px; padding: 0 8px; min-width: 26px; }
.cart-fab[hidden] { display: none; }
footer { padding: 40px 0 110px; color: var(--muted); font-size: .85rem; text-align: center; }

/* ------------------------------------------------------------ diálogos */
dialog {
  border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--text);
  width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 24px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
dialog::backdrop { background: rgba(20, 10, 5, .55); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dlg-head h2 { margin: 0; font-size: 1.15rem; }
.dlg-body { padding: 16px 18px; }
.close { border: 0; background: var(--surface-2); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 1.1rem; }

.detail-img { width: 100%; max-height: 62dvh; object-fit: contain; border-radius: 12px; background: #fff; }
.detail-img.placeholder { aspect-ratio: 4/3; border-radius: 12px; }

.lines { list-style: none; margin: 0; padding: 0; }
.lines li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 0; border-bottom: 1px solid var(--border); align-items: center; }
.lines .name { font-weight: 600; font-size: .95rem; }
.lines .sub { color: var(--muted); font-size: .85rem; }
.total-row { display: flex; justify-content: space-between; font-size: 1.15rem; font-weight: 800; padding: 14px 0 4px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.field label, .field legend { font-weight: 600; font-size: .92rem; }
.field input[type=text], .field input[type=password], .field input[type=tel], .field input[type=date], .field textarea, .field select {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
}
.field textarea { resize: vertical; min-height: 64px; }
fieldset.field { border: 0; padding: 0; margin: 14px 0 0; }
.pay-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pay-options label {
  display: flex; align-items: center; gap: 8px; padding: 12px; border: 1px solid var(--border);
  border-radius: 12px; cursor: pointer; font-weight: 600;
}
.pay-options input:checked + span { color: var(--primary); }
.pay-options label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.error { color: var(--primary); font-weight: 600; margin-top: 10px; }
.note { color: var(--muted); font-size: .88rem; }

.success { text-align: center; padding: 8px 0; }
.success .big { font-size: 3rem; }
.paybox { margin: 16px 0; padding: 14px; border-radius: 12px; background: var(--surface-2); text-align: left; }
.paybox strong { font-size: 1.05rem; }

/* ------------------------------------------------------------ admin */
.admin-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; flex-wrap: wrap; }
.admin-top h1 { margin: 0; font-size: 1.3rem; }
.tabs { display: flex; gap: 6px; overflow-x: auto; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--primary); }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; }
.stat .k { color: var(--muted); font-size: .8rem; }
.stat .v { font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { background: var(--surface-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); position: sticky; top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.inactive td { opacity: .5; }
tr.cat-row td { background: var(--surface-2); font-weight: 700; }
tfoot td { font-weight: 800; background: var(--surface-2); }
.price-input { width: 84px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); text-align: right; }
.price-input.custom { border-color: var(--primary); }
.neg { color: var(--primary); font-weight: 700; }
.pos { color: var(--ok); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.row .grow { flex: 1; min-width: 180px; }
.bulk { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 14px; }
.bulk select, .bulk input { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.bulk input { width: 90px; }

.orders { display: grid; gap: 10px; }
.order { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.order-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.order-head .who { font-weight: 700; font-size: 1.02rem; }
.order-head .meta { color: var(--muted); font-size: .85rem; }
.order ul { margin: 8px 0; padding-left: 18px; font-size: .9rem; }
.order-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toggle { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border); cursor: pointer; font-size: .85rem; font-weight: 600; background: var(--surface-2); }
.toggle.on { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .78rem; font-weight: 700; background: var(--surface-2); }
.badge.bizum { background: #e1f1f5; color: #0b6f86; }

.login { max-width: 360px; margin: 12vh auto; background: var(--surface); padding: 24px; border-radius: 16px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.login h1 { margin: 0 0 4px; font-size: 1.3rem; }
.saved { color: var(--ok); font-size: .85rem; font-weight: 600; transition: opacity .4s; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 50; }
