:root {
  --green: #1f6f4a; --green-600: #185c3d; --green-50: #eef5f1; --green-100: #d7eadf;
  --ink: #16201b; --ink-2: #4b5a52; --muted: #7b8a82; --line: #e3e8e5;
  --bg: #f6f7f5; --card: #ffffff; --warn: #b54708; --danger: #c0362c;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,20,.06), 0 4px 16px rgba(16,24,20,.06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.45; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* ---------- Encabezado ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 12px 16px; display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; }
.brand { display: flex; gap: 10px; align-items: center; text-decoration: none; color: var(--ink); min-width: 0; }
.brand-mark { color: var(--green); font-size: 26px; line-height: 1; }
.brand strong { display: block; font-size: 17px; white-space: nowrap; }
.brand small { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; fill: var(--muted); pointer-events: none; z-index: 1; }
.topbar .search input[type=search] { width: 100%; height: 44px; border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 0 40px 0 38px; outline: none; font-size: 15px; }
.topbar .search input[type=search]:focus { border-color: var(--green); background: #fff; box-shadow: 0 0 0 3px var(--green-100); }
.search input::-webkit-search-cancel-button { display: none; }
.search .clear { position: absolute; right: 8px; border: 0; background: var(--line); width: 26px; height: 26px; border-radius: 50%; font-size: 16px; line-height: 1; }
.cart-btn { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--green); color: #fff; font-weight: 600; position: relative; }
.cart-btn svg { width: 20px; fill: currentColor; }
.badge { background: #fff; color: var(--green); border-radius: 999px; min-width: 22px; height: 22px; padding: 0 6px; font-size: 12px; display: inline-grid; place-items: center; font-weight: 700; }
.chips { max-width: 1180px; margin: 0 auto; padding: 0 16px 12px; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 14px; font-size: 14px; color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- Grilla ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 16px 16px 120px; }
.result-bar { font-size: 14px; color: var(--muted); margin: 0 0 12px; }
.result-bar:empty, .result-bar:has(span:empty) { display: none; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.thumb { aspect-ratio: 4/3; background: var(--green-50); display: grid; place-items: center; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .ph { font-size: 34px; font-weight: 700; letter-spacing: .5px; opacity: .55; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-cat { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.card-name { font-size: 15px; font-weight: 600; margin: 0; }
.card-desc { font-size: 13px; color: var(--ink-2); margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { margin-top: auto; padding-top: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.price { font-size: 18px; font-weight: 700; }
.price small { font-size: 12px; font-weight: 400; color: var(--muted); }
.add { border: 0; background: var(--green); color: #fff; border-radius: 10px; height: 38px; padding: 0 14px; font-weight: 600; }
.add:hover { background: var(--green-600); }
.stock-note { font-size: 12px; color: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 48px 0; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.stepper button { width: 36px; height: 36px; border: 0; background: var(--green-50); font-size: 18px; color: var(--green); }
.stepper .qty { width: 48px; height: 36px; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); border-radius: 0; padding: 0 2px;
  text-align: center; font-weight: 600; font-size: 16px; background: #fff; -moz-appearance: textfield; appearance: textfield; }
.stepper .qty::-webkit-outer-spin-button, .stepper .qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .qty:focus { outline: none; box-shadow: inset 0 0 0 2px var(--green); }
.stock { font-size: 12px; font-weight: 600; }
.stock.ok { color: var(--green); } .stock.low { color: var(--warn); } .stock.out { color: var(--danger); }

/* ---------- Carrito ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10,20,15,.45); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100%); background: #fff; z-index: 50; display: flex; flex-direction: column; transform: translateX(100%); transition: transform .25s ease; }
.drawer.open { transform: none; }
.drawer-head, .modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); gap: 8px; }
.drawer-head h2, .modal-head h2 { margin: 0; font-size: 18px; flex: 1; }
.icon-btn { border: 0; background: var(--bg); width: 36px; height: 36px; border-radius: 50%; font-size: 22px; line-height: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 8px 16px; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.cart-line .n { font-weight: 600; font-size: 14px; }
.cart-line .u { font-size: 12px; color: var(--muted); }
.cart-line .lt { font-weight: 700; text-align: right; }
.cart-line .rm { border: 0; background: none; color: var(--danger); font-size: 12px; padding: 0; justify-self: end; }
.drawer-foot { border-top: 1px solid var(--line); padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; font-size: 14px; margin-bottom: 12px; }
.totals .grand { font-size: 18px; font-weight: 700; padding-top: 6px; border-top: 1px dashed var(--line); margin-top: 4px; }
.hint { font-size: 12px; color: var(--green); background: var(--green-50); padding: 6px 10px; border-radius: 8px; margin-bottom: 10px; }
.cart-empty { text-align: center; color: var(--muted); padding: 48px 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 20px; border-radius: 12px; border: 1px solid transparent; font-weight: 600; text-decoration: none; font-size: 15px; }
.btn.primary { background: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-600); }
.btn.primary:disabled { opacity: .6; cursor: progress; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.block { width: 100%; }

.mobile-cartbar { display: none; }

/* ---------- Checkout ---------- */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(10,20,15,.5); display: grid; place-items: center; padding: 16px; }
.modal-card { background: #fff; width: min(640px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); border-radius: 18px; display: flex; flex-direction: column; overflow: hidden; }
.steps { list-style: none; margin: 0; padding: 12px 16px; display: flex; gap: 8px; counter-reset: s; border-bottom: 1px solid var(--line); }
.steps li { flex: 1; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; counter-increment: s; }
.steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--bg); font-weight: 700; font-size: 12px; flex: none; }
.steps li.on { color: var(--ink); font-weight: 600; }
.steps li.on::before { background: var(--green); color: #fff; }
.steps li.done::before { content: "✓"; background: var(--green-100); color: var(--green); }
#coForm { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.step { padding: 16px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label small { font-weight: 400; color: var(--muted); }
input:not([type=checkbox]):not([type=file]), textarea, select { border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; font-size: 16px; font-weight: 400; color: var(--ink); background: #fff; width: 100%; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-100); }
input.invalid { border-color: var(--danger); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pay-box { background: var(--green-50); border-radius: 12px; padding: 14px 16px; }
.pay-total { margin: 0 0 10px; display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }
.pay-total b { font-size: 24px; color: var(--green); }
.bank { margin: 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.bank-row { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; align-items: center; }
.bank dt { color: var(--ink-2); }
.bank dd { margin: 0; font-weight: 600; word-break: break-all; }
.copy { border: 1px solid var(--green-100); background: #fff; color: var(--green); border-radius: 8px; font-size: 12px; padding: 4px 8px; }
.file-drop { border: 2px dashed var(--green-100); border-radius: 12px; padding: 18px; text-align: center; cursor: pointer; position: relative; background: #fff; }
.file-drop:hover, .file-drop.drag { border-color: var(--green); background: var(--green-50); }
.file-drop.invalid { border-color: var(--danger); }
.file-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-cta { display: flex; flex-direction: column; gap: 4px; color: var(--ink); }
.file-preview { display: flex; align-items: center; gap: 12px; text-align: left; margin-top: 12px; font-weight: 400; }
.file-preview img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.file-preview .pdf { width: 64px; height: 64px; border-radius: 8px; background: #fde8e7; color: var(--danger); display: grid; place-items: center; font-weight: 700; }

#review { display: flex; flex-direction: column; gap: 12px; }
.review-sec { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.review-sec h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; justify-content: space-between; }
.review-sec h3 button { border: 0; background: none; color: var(--green); font-size: 12px; text-transform: none; letter-spacing: 0; font-weight: 600; }
.review-sec p { margin: 0; font-size: 14px; }
.rtable { width: 100%; border-collapse: collapse; font-size: 14px; }
.rtable td, .rtable th { padding: 6px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.rtable th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: left; }
.rtable .r { text-align: right; white-space: nowrap; }
.rtable .c { text-align: center; }
.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 500; color: var(--ink); }
.check input { width: 20px; height: 20px; accent-color: var(--green); flex: none; margin-top: 1px; }

.form-error { margin: 0 16px; background: #fdecea; color: var(--danger); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.modal-foot { display: flex; gap: 12px; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.modal-foot .btn { flex: 1; }

.success { padding: 32px 20px; text-align: center; }
.success-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--green); color: #fff; font-size: 34px; display: grid; place-items: center; margin: 0 auto 8px; }
.success h2 { margin: 8px 0; }
.success-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 80; box-shadow: var(--shadow); }

/* ---------- Móvil ---------- */
@media (max-width: 720px) {
  .topbar-inner { grid-template-columns: 1fr auto; gap: 10px; padding: 10px 16px; }
  .search { grid-column: 1 / -1; grid-row: 2; }
  .brand small { display: none; }
  .cart-label { display: none; }
  .cart-btn { padding: 0 12px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .card-body { padding: 10px; }
  .card-name { font-size: 14px; }
  .card-desc { display: none; }
  .card-foot { flex-direction: column; align-items: stretch; }
  .add { width: 100%; }
  .stepper { justify-content: space-between; }
  .card .stepper .qty { flex: 1; width: auto; min-width: 0; }
  .price { font-size: 16px; }
  .row2 { grid-template-columns: 1fr; }
  .modal { padding: 0; place-items: end stretch; }
  .modal-card { width: 100%; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .steps li { font-size: 12px; }
  .mobile-cartbar { display: flex; position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 30; justify-content: space-between; align-items: center; background: var(--green); color: #fff; border: 0; border-radius: 14px; padding: 14px 18px; font-size: 15px; box-shadow: 0 6px 20px rgba(31,111,74,.35); }
  .bank-row { grid-template-columns: 76px 1fr auto; }
  .toast { top: 16px; bottom: auto; }
}

/* Envío del recibo por el cliente */
.receipt-actions { display: flex; flex-direction: column; gap: 10px; max-width: 360px; margin: 20px auto 0; }
.send-hint { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); background: var(--green-50); border-radius: 10px; padding: 10px 12px; text-align: left; }
.link-btn { background: none; border: 0; color: var(--green); margin-top: 12px; height: 40px; }
.btn.wa { background: #25d366; color: #0b3d20; }
.btn.wa:hover { background: #1ebe5b; }

/* Formas de pago */
.opts { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.opts legend { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; padding: 0; }
.opt { position: relative; cursor: pointer; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt span { display: flex; flex-direction: column; gap: 2px; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; height: 100%; }
.opt b { font-size: 15px; color: var(--ink); }
.opt small { font-weight: 400; color: var(--muted); font-size: 12px; }
.opt input:checked + span { border-color: var(--green); background: var(--green-50); box-shadow: 0 0 0 1px var(--green); }
.opt input:focus-visible + span { box-shadow: 0 0 0 3px var(--green-100); }
.pay-box label { margin-top: 8px; }
.pay-total.big { margin: 0; display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; }
.pay-total.big b { font-size: 26px; color: var(--green); }
.small { font-size: 13px; margin: 0; }
.later-badge { display: inline-block; background: #fff4e5; color: #9a4a06; border-radius: 8px; padding: 2px 8px; font-size: 13px; font-weight: 600; }
.pay-box .pay-total { margin-bottom: 4px; }
.pay-note { background: var(--green-50); border-radius: 12px; padding: 12px 14px; font-size: 14px; max-width: 420px; margin: 12px auto; line-height: 1.6; }

/* Cartel de pedidos fuera de horario */
.late-banner { background: #fff4d6; color: #6b4a00; border-bottom: 1px solid #f1dca0; text-align: center; font-weight: 600; font-size: 14px; padding: 10px 16px; line-height: 1.4; }
.late-banner::before { content: "🕒 "; }
.co-late { background: #fff4d6; color: #6b4a00; border-radius: 10px; padding: 10px 12px; font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.co-late::before { content: "🕒 "; }
/* Advertencia al confirmar la compra */
.co-warning { border: 1px solid #f3c3be; background: #fdf1ef; color: #7a1f14; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.co-warning b::before { content: "⚠ "; }
.co-warning p { margin: 4px 0 0; white-space: pre-line; }
