:root {
  --rosa: #d6336c;
  --rosa-oscuro: #a61e4d;
  --rosa-suave: #fff0f6;
  --texto: #1f2328;
  --texto-2: #5c636a;
  --borde: #e3e5e8;
  --fondo: #f6f7f9;
  --blanco: #fff;
  --verde: #2b8a3e;
  --rojo: #c92a2a;
  --radio: 14px;
  --sombra: 0 2px 10px rgba(0, 0, 0, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  color: var(--texto);
  background: var(--fondo);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }

/* ---------- Estructura ---------- */
.barra {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px calc(12px);
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--rosa); color: #fff;
}
.barra h1 { margin: 0; font-size: 20px; flex: 1; letter-spacing: .2px; }
.barra .btn-barra { background: rgba(255,255,255,.18); border: 0; color: #fff; padding: 8px 12px; border-radius: 10px; font-size: 15px; cursor: pointer; }
.contenido { max-width: 720px; margin: 0 auto; padding: 16px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }

/* ---------- Botones y campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px;
  border: 0; border-radius: 12px; cursor: pointer;
  font-weight: 600; font-size: 17px;
  background: var(--rosa); color: #fff;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-claro { background: var(--blanco); color: var(--texto); border: 1px solid var(--borde); }
.btn-peligro { background: var(--blanco); color: var(--rojo); border: 1px solid #f5c2c2; }
.btn-grande { width: 100%; min-height: 64px; font-size: 21px; border-radius: 16px; box-shadow: 0 4px 14px rgba(214, 51, 108, .3); }
.btn-bloque { width: 100%; }

.campo { display: block; margin-bottom: 14px; }
.campo > span { display: block; font-size: 14px; font-weight: 600; color: var(--texto-2); margin-bottom: 6px; }
.entrada {
  width: 100%; min-height: 50px; padding: 10px 14px;
  border: 1.5px solid var(--borde); border-radius: 12px; background: var(--blanco);
  font-size: 17px; outline: none;
}
.entrada:focus { border-color: var(--rosa); box-shadow: 0 0 0 3px rgba(214, 51, 108, .15); }
.fila { display: flex; gap: 10px; }
.fila > * { flex: 1; }

.buscador { position: relative; margin: 14px 0 10px; }
.buscador .entrada { padding-left: 44px; min-height: 54px; font-size: 18px; }
.buscador::before { content: "🔍"; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); font-size: 18px; opacity: .6; }
.buscador .limpiar { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; font-size: 22px; padding: 8px 12px; color: var(--texto-2); cursor: pointer; }

/* ---------- Chips de categoría ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 9px 16px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--borde); background: var(--blanco); font-size: 15px; font-weight: 600; white-space: nowrap;
}
.chip.activo { background: var(--rosa); border-color: var(--rosa); color: #fff; }

/* ---------- Lista de productos ---------- */
.lista { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px; border: 0; border-radius: var(--radio); background: var(--blanco); box-shadow: var(--sombra); cursor: pointer;
}
.item img, .item .sin-foto { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; flex: none; background: var(--fondo); }
.sin-foto { display: flex; align-items: center; justify-content: center; font-size: 28px; }
.item-info { flex: 1; min-width: 0; }
.item-nombre { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item-extra { font-size: 13px; color: var(--texto-2); }
.item-precio { text-align: right; flex: none; }
.item-precio b { display: block; font-size: 20px; color: var(--rosa-oscuro); }
.item-precio small { color: var(--texto-2); font-size: 13px; }
.inactivo { opacity: .5; }

.vacio { text-align: center; color: var(--texto-2); padding: 32px 12px; }
.vacio .icono { font-size: 44px; display: block; margin-bottom: 6px; }
.aviso { padding: 12px 14px; border-radius: 12px; background: var(--rosa-suave); color: var(--rosa-oscuro); margin: 10px 0; font-size: 15px; }
.error-texto { color: var(--rojo); font-size: 15px; min-height: 22px; margin: 8px 0; }

/* ---------- Hoja de detalle ---------- */
.capa { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; animation: aparecer .15s ease-out; }
.hoja {
  width: 100%; max-width: 560px; max-height: 94vh; overflow-y: auto;
  background: var(--blanco); border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  animation: subir .2s ease-out;
}
@media (min-width: 700px) { .capa { align-items: center; } .hoja { border-radius: 22px; } }
.hoja-foto { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: var(--fondo); border-radius: 14px; }
.hoja-foto.sin-foto { font-size: 72px; }
.hoja h2 { margin: 14px 0 4px; font-size: 24px; line-height: 1.25; }
.hoja .meta { color: var(--texto-2); font-size: 15px; }
.precio-grande { margin: 14px 0 18px; padding: 16px; border-radius: 16px; background: var(--rosa-suave); text-align: center; }
.precio-grande b { font-size: 46px; color: var(--rosa-oscuro); line-height: 1.1; display: block; }
.precio-grande span { font-size: 18px; color: var(--texto-2); }
@keyframes aparecer { from { opacity: 0; } }
@keyframes subir { from { transform: translateY(40px); opacity: .6; } }

/* ---------- Escáner ---------- */
.escaner { position: fixed; inset: 0; z-index: 100; background: #000; display: flex; align-items: center; justify-content: center; }
.escaner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.escaner-marco { position: relative; width: min(82vw, 380px); height: min(46vw, 210px); border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.5); border: 3px solid rgba(255,255,255,.9); overflow: hidden; }
.escaner-linea { position: absolute; left: 6%; right: 6%; height: 2px; background: #ff4d8d; box-shadow: 0 0 10px #ff4d8d; animation: barrer 1.8s ease-in-out infinite alternate; }
@keyframes barrer { from { top: 12%; } to { top: 88%; } }
.escaner-ayuda { position: absolute; top: max(28px, env(safe-area-inset-top)); left: 16px; right: 16px; text-align: center; color: #fff; font-size: 18px; font-weight: 600; text-shadow: 0 1px 4px #000; }
.escaner-botones { position: absolute; bottom: calc(28px + env(safe-area-inset-bottom)); left: 16px; right: 16px; display: flex; gap: 10px; justify-content: center; }
.escaner-botones .btn { min-width: 130px; }

/* ---------- PIN ---------- */
.pantalla-pin { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(160deg, var(--rosa) 0%, var(--rosa-oscuro) 100%); }
.tarjeta-pin { width: 100%; max-width: 360px; background: var(--blanco); border-radius: 22px; padding: 26px 22px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.tarjeta-pin .logo { font-size: 46px; }
.tarjeta-pin h1 { margin: 4px 0 2px; font-size: 26px; }
.tarjeta-pin p { margin: 0 0 18px; color: var(--texto-2); }
.entrada-pin { text-align: center; font-size: 32px; letter-spacing: 12px; min-height: 64px; -webkit-text-security: disc; }

/* ---------- Admin ---------- */
.pestanas { display: flex; gap: 6px; background: var(--blanco); padding: 6px; border-radius: 14px; box-shadow: var(--sombra); margin-bottom: 14px; }
.pestana { flex: 1; border: 0; background: none; padding: 10px 6px; border-radius: 10px; font-weight: 600; font-size: 15px; cursor: pointer; color: var(--texto-2); }
.pestana.activo { background: var(--rosa); color: #fff; }
.tarjeta { background: var(--blanco); border-radius: var(--radio); box-shadow: var(--sombra); padding: 16px; margin-bottom: 14px; }
.tarjeta h3 { margin: 0 0 12px; font-size: 18px; }
.foto-editor { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.foto-editor img, .foto-editor .sin-foto { width: 110px; height: 110px; border-radius: 12px; object-fit: cover; background: var(--fondo); flex: none; }
.foto-editor .acciones { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.entrada-con-boton { display: flex; gap: 8px; }
.entrada-con-boton .entrada { flex: 1; }
.entrada-con-boton .btn { flex: none; padding: 0 14px; }
.interruptor { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-weight: 600; }
.interruptor input { width: 22px; height: 22px; accent-color: var(--rosa); }
.botones-form { display: flex; gap: 10px; margin-top: 6px; }
.botones-form .btn { flex: 1; }
.cat-fila { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--borde); }
.cat-fila:last-child { border-bottom: 0; }
.cat-fila .nombre { flex: 1; font-weight: 600; }
.cat-fila small { color: var(--texto-2); font-weight: 400; }
.cat-fila button { min-height: 38px; padding: 6px 12px; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 200; background: #222; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 90vw; }
.flotante { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 20; width: 60px; height: 60px; border-radius: 50%; font-size: 30px; padding: 0; box-shadow: 0 6px 18px rgba(214, 51, 108, .45); }
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
