:root {
  --azul: #12355b;
  --azul-claro: #e8eef5;
  --verde: #14894e;
  --verde-oscuro: #0f6e3e;
  --texto: #1c2430;
  --suave: #5d6b7a;
  --borde: #dde3ea;
  --fondo: #f4f6f9;
  --blanco: #fff;
  --rojo: #b42318;
  --radio: 12px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--texto);
  background: var(--fondo);
  padding-bottom: 96px;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Encabezado */
.encabezado {
  position: sticky; top: 0; z-index: 10;
  background: var(--azul); color: var(--blanco);
  padding: 10px 16px 0;
  padding-top: max(10px, env(safe-area-inset-top));
}
.encabezado__fila { display: flex; align-items: center; gap: 12px; min-height: 32px; }
.encabezado__logo { height: 28px; width: auto; }
.encabezado__titulo { font-weight: 600; font-size: 15px; opacity: .9; }
.buscador { padding: 10px 0 8px; }
.buscador input {
  width: 100%; padding: 11px 14px; border: 0; border-radius: 10px;
  background: var(--blanco); color: var(--texto); font-size: 16px;
}
.marcas {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px;
  scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px;
}
.marcas::-webkit-scrollbar { display: none; }
.marcas button {
  flex: none; border: 1px solid rgba(255,255,255,.35); background: transparent; color: var(--blanco);
  border-radius: 999px; padding: 6px 13px; font-size: 14px; white-space: nowrap; cursor: pointer;
}
.marcas button[aria-pressed="true"] { background: var(--blanco); color: var(--azul); border-color: var(--blanco); font-weight: 600; }

/* Lista */
main { max-width: 760px; margin: 0 auto; padding: 12px 16px; }
.aviso {
  background: var(--azul-claro); border-radius: var(--radio); padding: 10px 14px; font-size: 14px; margin-bottom: 8px;
}
.aviso span { display: block; color: var(--suave); }
.aviso__volumen { margin: 6px 0; padding: 8px 10px; background: #e3f4ea; border-radius: 8px; color: var(--verde-oscuro); }
.marca { scroll-margin-top: 150px; }
.marca__titulo { font-size: 20px; margin: 22px 0 2px; color: var(--azul); }
.seccion__titulo { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--suave); margin: 4px 0 8px; font-weight: 600; }

.producto {
  display: grid; grid-template-columns: 84px 1fr; gap: 12px; align-items: center;
  background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 10px; margin-bottom: 8px;
}
.producto--elegido { border-color: var(--verde); box-shadow: 0 0 0 1px var(--verde) inset; }
.producto__foto {
  width: 84px; height: 84px; border: 0; padding: 0; border-radius: 8px; background: var(--fondo);
  overflow: hidden; cursor: zoom-in;
}
.producto__foto img { width: 100%; height: 100%; object-fit: contain; display: block; }
.producto__nombre { font-size: 14px; font-weight: 600; margin: 0; line-height: 1.25; }
.producto__sku { font-size: 12px; color: var(--suave); margin: 2px 0 6px; }
.producto__pie { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.producto__precio { font-weight: 700; }
.producto__precio small { font-weight: 400; color: var(--suave); }
.producto__precio s { font-weight: 400; color: var(--suave); font-size: 13px; }
.producto__precio .volumen { display: block; font-size: 12px; font-weight: 600; color: var(--verde); }

.cantidad { display: flex; align-items: center; border: 1px solid var(--borde); border-radius: 10px; overflow: hidden; }
.cantidad button {
  width: 40px; height: 40px; border: 0; background: var(--fondo); font-size: 20px; cursor: pointer; color: var(--azul);
}
.cantidad button:active { background: var(--borde); }
.cantidad input {
  width: 52px; height: 40px; border: 0; text-align: center; font-weight: 600; -moz-appearance: textfield;
}
.cantidad input::-webkit-outer-spin-button, .cantidad input::-webkit-inner-spin-button { -webkit-appearance: none; }

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

/* Barra inferior */
.barra {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--blanco); border-top: 1px solid var(--borde);
  padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(0,0,0,.06);
  flex-wrap: wrap;
}
.barra__nivel {
  flex-basis: 100%; margin: -4px 0 0; font-size: 13px; font-weight: 600; color: var(--azul);
  background: var(--azul-claro); border-radius: 8px; padding: 6px 10px; text-align: center;
}
.barra__nivel--ok { color: var(--verde-oscuro); background: #e3f4ea; }
.barra__info { display: flex; flex-direction: column; font-size: 14px; color: var(--suave); }
.barra__info strong { font-size: 19px; color: var(--texto); }

.boton {
  display: inline-block; text-align: center; text-decoration: none;
  background: var(--verde); color: var(--blanco); border: 0; border-radius: 10px;
  padding: 12px 18px; font-weight: 600; cursor: pointer;
}
.boton:hover { background: var(--verde-oscuro); }
.boton:disabled { background: #b8c2cc; cursor: not-allowed; }
.boton--grande { width: 100%; padding: 15px; font-size: 17px; margin-top: 8px; }
.enlace { background: none; border: 0; color: var(--azul); font-weight: 600; padding: 8px 0; cursor: pointer; }

/* Hojas (pedido / listo) */
.hoja { position: fixed; inset: 0; z-index: 30; background: var(--fondo); overflow-y: auto; }
.hoja__barra {
  position: sticky; top: 0; background: var(--blanco); border-bottom: 1px solid var(--borde);
  padding: 6px 16px; padding-top: max(6px, env(safe-area-inset-top)); z-index: 1;
}
.hoja__contenido { max-width: 640px; margin: 0 auto; padding: 16px 16px 40px; }
.hoja h1 { font-size: 22px; margin: 4px 0 12px; color: var(--azul); }
.hoja h2 { font-size: 17px; margin: 24px 0 8px; color: var(--azul); }

.resumen { list-style: none; margin: 0; padding: 0; background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio); }
.resumen li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 14px; border-bottom: 1px solid var(--borde); font-size: 14px; }
.resumen li:last-child { border-bottom: 0; }
.resumen .detalle { color: var(--suave); font-size: 13px; }
.resumen .importe { font-weight: 600; text-align: right; }

.desglose { margin: 12px 0 0; background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio); padding: 10px 14px; }
.desglose div { display: flex; justify-content: space-between; padding: 3px 0; font-size: 15px; }
.desglose dt { color: var(--suave); }
.desglose dd { margin: 0; }
.desglose .total { border-top: 1px solid var(--borde); margin-top: 6px; padding-top: 8px; font-size: 18px; font-weight: 700; }
.desglose .total dt { color: var(--texto); }
.desglose .gratis { color: var(--verde); font-weight: 600; }

.nota { font-size: 13px; color: var(--suave); margin: 8px 0; }

form label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 12px; }
form input:not([type=checkbox]), form select {
  display: block; width: 100%; margin-top: 4px; padding: 11px 12px; font-size: 16px; font-weight: 400;
  border: 1px solid var(--borde); border-radius: 10px; background: var(--blanco);
}
form input:focus, form select:focus { outline: 2px solid var(--azul); outline-offset: 0; border-color: var(--azul); }
form .invalido { border-color: var(--rojo) !important; }
.dos { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; }
.check { display: flex !important; align-items: center; gap: 10px; font-weight: 600; margin-top: 8px; }
.check input { width: 20px; height: 20px; }
.error { color: var(--rojo); background: #fdecea; border-radius: 10px; padding: 10px 12px; font-size: 14px; }

.listo { text-align: center; padding-top: 60px; }
.listo__icono {
  width: 72px; height: 72px; border-radius: 50%; background: var(--verde); color: var(--blanco);
  font-size: 40px; line-height: 72px; margin: 0 auto 12px;
}

/* Visor de fotos */
.visor { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; }
.visor::backdrop { background: rgba(0,0,0,.8); }
.visor img { max-width: min(92vw, 700px); max-height: 85vh; display: block; border-radius: 10px; background: var(--blanco); }
.visor__cerrar {
  position: fixed; top: 16px; right: 16px; width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: var(--blanco); font-size: 20px; cursor: pointer;
}

@media (min-width: 700px) {
  .producto { grid-template-columns: 100px 1fr; }
  .producto__foto { width: 100px; height: 100px; }
}
