* { box-sizing: border-box; }

/* .panel y .fondo declaran display, que de lo contrario gana sobre [hidden]. */
[hidden] { display: none !important; }

:root {
  --tinta: #14161a;
  --suave: #6b7280;
  --linea: #e4e7ec;
  --fondo: #f6f7f9;
  --azul: #1d4ed8;
  --verde: #067647;
}

body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: var(--tinta);
  background: var(--fondo);
}

/* ---------------------------------------------------------- encabezado */

.top {
  position: sticky; top: 0; z-index: 20;
  background: #fff;
  border-bottom: 1px solid var(--linea);
}

.top-in {
  max-width: 1240px; margin: 0 auto;
  padding: 12px 20px;
  display: flex; align-items: center; gap: 16px;
}

.marca strong { display: block; font-size: 16px; letter-spacing: .06em; }
.marca span { font-size: 11px; color: var(--suave); letter-spacing: .04em; text-transform: uppercase; }

.buscar {
  flex: 1; min-width: 0;
  padding: 9px 13px;
  border: 1px solid var(--linea); border-radius: 8px;
  font-size: 14px; background: var(--fondo);
}
.buscar:focus { outline: 2px solid var(--azul); outline-offset: -1px; background: #fff; }

.carrito-btn {
  padding: 9px 15px; border: 1px solid var(--tinta); border-radius: 8px;
  background: var(--tinta); color: #fff;
  font-size: 14px; font-weight: 550; cursor: pointer;
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
}
.pill {
  background: rgba(255,255,255,.25); border-radius: 20px;
  padding: 1px 8px; font-size: 12px; font-variant-numeric: tabular-nums;
}

.filtros { padding-top: 0; padding-bottom: 10px; }

.cats { display: flex; gap: 7px; flex-wrap: wrap; flex: 1; }
.cat {
  padding: 5px 12px; border: 1px solid var(--linea); border-radius: 20px;
  background: #fff; font-size: 13px; cursor: pointer; color: var(--suave);
}
.cat:hover { border-color: #c7cbd3; color: var(--tinta); }
.cat[aria-pressed="true"] { background: var(--tinta); border-color: var(--tinta); color: #fff; }

.derecha { display: flex; align-items: center; gap: 14px; }
.lista { font-size: 12px; color: var(--suave); display: flex; align-items: center; gap: 6px; }
.lista select {
  border: 1px solid var(--linea); border-radius: 6px; padding: 4px 7px;
  font-size: 13px; background: #fff; color: var(--tinta);
}
.estado { font-size: 12px; color: var(--suave); white-space: nowrap; }

/* ---------------------------------------------------------- vitrina */

main { max-width: 1240px; margin: 0 auto; padding: 20px; }

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

.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
}

.card {
  background: #fff; border: 1px solid var(--linea); border-radius: 11px;
  overflow: hidden; display: flex; flex-direction: column;
}
.card:hover { border-color: #c7cbd3; }

.card img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  display: block; background: #eceef1; cursor: pointer;
}
.card .nombre { cursor: pointer; }
.card .nombre:hover { text-decoration: underline; }

.card-body { padding: 12px; display: flex; flex-direction: column; flex: 1; gap: 2px; }

.nombre {
  font-size: 13px; font-weight: 550; line-height: 1.35; margin: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 35px;
}
.meta { font-size: 11px; color: var(--suave); margin: 0 0 7px; }

.precio-paca { font-size: 19px; font-weight: 680; margin: 0; letter-spacing: -.01em; }
.por-paca { font-size: 11px; color: var(--suave); margin: 0 0 1px; }
.unitario { font-size: 12px; color: var(--suave); margin: 0 0 9px; }

.stock { font-size: 12px; color: var(--verde); margin: 0 0 10px; }
.stock.poco { color: #b54708; }
.pares { color: var(--suave); }

.agregar {
  margin-top: auto; width: 100%;
  padding: 8px; border: 1px solid var(--tinta); border-radius: 7px;
  background: #fff; color: var(--tinta);
  font-size: 13px; font-weight: 550; cursor: pointer;
}
.agregar:hover { background: var(--tinta); color: #fff; }
.agregar.puesto { background: var(--verde); border-color: var(--verde); color: #fff; }

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

/* ---------------------------------------------------------- detalle */

.detalle {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(15,17,21,.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 34px 20px; overflow-y: auto;
}

.det-caja {
  position: relative; width: 100%; max-width: 880px;
  background: #fff; border-radius: 14px; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.det-x {
  position: absolute; top: 11px; right: 13px; z-index: 2;
  width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: rgba(255,255,255,.92); color: var(--tinta);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.det-x:hover { background: #fff; }

.det-top { display: grid; grid-template-columns: 1fr 1fr; }

/* contain, no cover: en el detalle se ve la foto completa sin recortar. */
.det-img {
  width: 100%; aspect-ratio: 1;
  object-fit: contain; background: #f1f2f4;
  display: block; padding: 10px;
}

.det-info { padding: 26px; }
.det-info h2 { font-size: 21px; margin: 0 0 5px; line-height: 1.25; letter-spacing: -.01em; }
.det-meta { font-size: 13px; color: var(--suave); margin: 0 0 18px; }

.det-precio { border-top: 1px solid var(--linea); padding-top: 15px; }
.det-monto { font-size: 30px; font-weight: 700; margin: 1px 0 2px; letter-spacing: -.02em; }

.det-cant { display: flex; align-items: center; gap: 9px; margin: 17px 0 13px; }
.det-cant button {
  width: 33px; height: 33px; border: 1px solid var(--linea); border-radius: 7px;
  background: #fff; cursor: pointer; font-size: 17px; color: var(--tinta);
}
.det-cant button:hover { border-color: var(--tinta); }
.det-cant button:disabled { opacity: .35; cursor: not-allowed; }
#det-n { font-size: 16px; min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; }
.det-cant-txt { font-size: 13px; color: var(--suave); }

.det-agregar {
  width: 100%; padding: 12px; border: 0; border-radius: 8px;
  background: var(--tinta); color: #fff;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.det-agregar:hover { background: #000; }
.det-agregar.puesto { background: var(--verde); }

.det-ficha {
  margin: 20px 0 0; padding-top: 15px; border-top: 1px solid var(--linea);
  display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13px;
}
.det-ficha dt { color: var(--suave); }
.det-ficha dd { margin: 0; }

.sug { border-top: 1px solid var(--linea); padding: 20px 26px 26px; background: var(--fondo); }
.sug h3 { font-size: 14px; margin: 0 0 13px; }

.sug-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 11px; }

.sug-item { cursor: pointer; background: #fff; border: 1px solid var(--linea); border-radius: 9px; overflow: hidden; }
.sug-item:hover { border-color: var(--tinta); }
.sug-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #eceef1; }
.sug-txt { padding: 8px; }
.sug-nom {
  font-size: 11.5px; margin: 0 0 3px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; min-height: 30px;
}
.sug-precio { font-size: 13px; font-weight: 650; margin: 0; }

@media (max-width: 720px) {
  .detalle { padding: 0; }
  .det-caja { border-radius: 0; min-height: 100%; }
  .det-top { grid-template-columns: 1fr; }
  .det-img { max-height: 300px; }
  .det-info { padding: 18px; }
}

/* ---------------------------------------------------------- panel pedido */

.fondo { position: fixed; inset: 0; background: rgba(15,17,21,.4); z-index: 30; }

.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 92vw;
  background: #fff; z-index: 31; display: flex; flex-direction: column;
  box-shadow: -8px 0 28px rgba(0,0,0,.13);
}

.panel-top {
  padding: 15px 18px; border-bottom: 1px solid var(--linea);
  display: flex; justify-content: space-between; align-items: center;
}
.x { border: 0; background: none; font-size: 25px; line-height: 1; cursor: pointer; color: var(--suave); }

.lineas { flex: 1; overflow-y: auto; padding: 6px 18px; }

.linea { display: flex; gap: 11px; padding: 13px 0; border-bottom: 1px solid var(--linea); }
.linea img { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; background: #eceef1; flex-shrink: 0; }
.linea-info { flex: 1; min-width: 0; }
.linea-nom { font-size: 12.5px; font-weight: 550; margin: 0 0 2px; line-height: 1.3; }
.linea-sub { font-size: 11px; color: var(--suave); margin: 0; }
.linea-tot { font-size: 13px; font-weight: 620; margin: 5px 0 0; }

.cant { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.cant button {
  width: 25px; height: 25px; border: 1px solid var(--linea); border-radius: 6px;
  background: #fff; cursor: pointer; font-size: 15px; line-height: 1; color: var(--tinta);
}
.cant button:hover { border-color: var(--tinta); }
.cant span { font-size: 13px; min-width: 46px; text-align: center; font-variant-numeric: tabular-nums; }

.panel-pie { border-top: 1px solid var(--linea); padding: 16px 18px; }
.tot { display: flex; justify-content: space-between; align-items: baseline; }
.tot strong { font-size: 22px; letter-spacing: -.01em; }
.tot-detalle { font-size: 12px; color: var(--suave); margin: 3px 0 13px; }

.enviar {
  width: 100%; padding: 11px; border: 0; border-radius: 8px;
  background: var(--verde); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
.enviar:disabled { background: #cbd0d8; cursor: not-allowed; }

.datos-cliente { display: grid; gap: 8px; margin-bottom: 11px; }
.datos-cliente input {
  padding: 9px 12px; border: 1px solid var(--linea); border-radius: 8px;
  font-size: 14px; background: var(--fondo); width: 100%;
}
.datos-cliente input:focus { outline: 2px solid var(--azul); outline-offset: -1px; background: #fff; }
.datos-cliente input.falta { border-color: #d92d20; }

.pedido-error {
  font-size: 12.5px; color: #d92d20; background: #fef3f2;
  border: 1px solid #fecdca; border-radius: 8px;
  padding: 9px 12px; margin: 0 0 11px; white-space: pre-line;
}

.pedido-ok {
  position: absolute; inset: 0; z-index: 2;
  background: #fff; padding: 40px 26px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 4px;
}
.ok-icono {
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--verde); color: #fff;
  font-size: 30px; line-height: 54px; margin-bottom: 10px;
}
.pedido-ok h3 { margin: 0; font-size: 20px; }
.pedido-ok p { margin: 4px 0; color: var(--suave); font-size: 14px; }
.pedido-numero { font-size: 24px; font-weight: 700; color: var(--tinta) !important; letter-spacing: .02em; }
.ok-nota { max-width: 260px; }
.pedido-ok .enviar { margin-top: 18px; max-width: 240px; }

.vacio-panel { text-align: center; color: var(--suave); padding: 45px 20px; font-size: 14px; }

@media (max-width: 640px) {
  .top-in { flex-wrap: wrap; gap: 10px; padding: 11px 14px; }
  .buscar { order: 3; width: 100%; flex-basis: 100%; }
  main { padding: 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 11px; }
}
