:root {
  --fondo: #f4f2ee;
  --papel: #ffffff;
  --tinta: #1d2126;
  --suave: #5d646d;
  --linea: #e2ded6;
  --acero: #2b3138;
  --naranja: #e8590c;
  --naranja-osc: #c2470a;
  --wsp: #1fa855;
  --radio: 14px;
  --sombra: 0 1px 2px rgba(20, 22, 26, .06), 0 6px 20px rgba(20, 22, 26, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fondo);
  color: var(--tinta);
  font: 16px/1.45 "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
.mono { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: .82em; letter-spacing: .02em; }

.aviso-demo {
  background: var(--acero);
  color: #d9dde2;
  font-size: 13px;
  text-align: center;
  padding: 7px 16px;
}
.aviso-demo b { color: #fff; }

/* Cabecera */
.cabecera {
  position: sticky; top: 0; z-index: 10;
  background: var(--papel);
  border-bottom: 1px solid var(--linea);
}
.cabecera__in {
  max-width: 1120px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
}
.logo { display: flex; flex-direction: column; text-decoration: none; color: var(--tinta); line-height: 1; }
.logo__marca { font-weight: 800; font-size: 22px; letter-spacing: .08em; }
.logo__marca::after { content: ""; display: block; height: 4px; width: 38px; background: var(--naranja); margin-top: 4px; }
.logo__sub { font-size: 11px; text-transform: uppercase; letter-spacing: .18em; color: var(--suave); margin-top: 4px; }
.btn-cotizacion {
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--linea); background: var(--papel);
  border-radius: 999px; padding: 9px 16px; font-weight: 600;
}
.btn-cotizacion svg { width: 20px; height: 20px; }
.btn-cotizacion:hover { border-color: var(--tinta); }
.contador {
  min-width: 22px; height: 22px; border-radius: 11px; padding: 0 6px;
  background: var(--naranja); color: #fff; font-size: 12px; font-weight: 700;
  display: inline-grid; place-items: center;
}
.contador[hidden], #limpiar[hidden] { display: none; }
.contador.salta { animation: salta .35s ease; }
@keyframes salta { 40% { transform: scale(1.3); } }

/* Buscador */
main { max-width: 1120px; margin: 0 auto; padding: 0 16px 40px; }
.buscador { padding: 28px 0 8px; }
.buscador h1 { font-size: clamp(26px, 5vw, 38px); line-height: 1.1; margin: 0 0 6px; letter-spacing: -.01em; }
.buscador__ayuda { margin: 0 0 16px; color: var(--suave); }
.caja-busqueda {
  display: flex; align-items: center; gap: 10px;
  background: var(--papel); border: 2px solid var(--tinta); border-radius: var(--radio);
  padding: 0 14px; box-shadow: var(--sombra);
}
.caja-busqueda:focus-within { border-color: var(--naranja); }
.caja-busqueda svg { width: 22px; height: 22px; flex: none; color: var(--suave); }
.caja-busqueda input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; padding: 15px 0; font-size: 17px; }
.caja-busqueda input::-webkit-search-cancel-button { display: none; }
#limpiar { border: 0; background: none; font-size: 26px; line-height: 1; color: var(--suave); padding: 4px; }
.ejemplos { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; }
.ejemplos > span { color: var(--suave); }
.ejemplos button {
  border: 1px dashed #b9b3a8; background: transparent; border-radius: 999px; padding: 5px 12px;
}
.ejemplos button small { color: var(--naranja-osc); font-size: 11px; margin-left: 2px; }
.ejemplos button:hover { border-style: solid; border-color: var(--tinta); }

/* Categorías */
.categorias {
  display: flex; gap: 8px; overflow-x: auto; padding: 18px 0 6px;
  scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px;
}
.categorias::-webkit-scrollbar { display: none; }
.categorias button {
  flex: none; border: 1px solid var(--linea); background: var(--papel);
  border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 500; white-space: nowrap;
}
.categorias button[aria-pressed="true"] { background: var(--tinta); color: #fff; border-color: var(--tinta); }
.categorias button span { color: var(--suave); margin-left: 4px; font-size: 12px; }
.categorias button[aria-pressed="true"] span { color: #c8ccd1; }

.resumen { color: var(--suave); font-size: 14px; padding: 10px 0 12px; min-height: 42px; }
.resumen b { color: var(--tinta); }

/* Grilla de productos */
.grilla { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 720px) { .grilla { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 1000px) { .grilla { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tarjeta {
  display: flex; flex-direction: column;
  background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio);
  overflow: hidden; transition: border-color .15s, transform .15s;
}
.tarjeta:hover { border-color: #c9c3b8; transform: translateY(-2px); }
.tarjeta__foto {
  border: 0; padding: 12px; background: #fff; aspect-ratio: 1; display: grid; place-items: center;
}
.tarjeta__foto img { width: 100%; height: 100%; object-fit: contain; }
.sin-foto {
  width: 100%; height: 100%; display: grid; place-items: center; text-align: center;
  background: repeating-linear-gradient(135deg, #f6f4f0 0 10px, #efece6 10px 20px);
  color: var(--suave); font-size: 12px; border-radius: 10px;
}
.tarjeta__cuerpo { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; border-top: 1px solid var(--linea); }
.tarjeta__meta { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--suave); }
.tarjeta__marca { font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--tinta); }
.tarjeta__nombre {
  border: 0; background: none; padding: 0; text-align: left; font-weight: 600; font-size: 14.5px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.tarjeta__nombre:hover { text-decoration: underline; }
.tarjeta__pie { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 8px; }
.precio { font-weight: 800; font-size: 17px; white-space: nowrap; }
.precio small { font-weight: 600; font-size: .7em; color: var(--suave); margin-right: 2px; }
.btn-agregar {
  border: 0; background: var(--naranja); color: #fff; border-radius: 10px;
  width: 38px; height: 38px; font-size: 22px; line-height: 1; display: grid; place-items: center; flex: none;
}
.btn-agregar:hover { background: var(--naranja-osc); }
.btn-agregar.listo { background: var(--tinta); font-size: 16px; }
mark { background: #ffe1cc; color: inherit; border-radius: 3px; padding: 0 1px; }

.vacio {
  grid-column: 1 / -1; background: var(--papel); border: 1px dashed #c9c3b8; border-radius: var(--radio);
  padding: 28px 20px; text-align: center; color: var(--suave);
}
.vacio b { color: var(--tinta); display: block; font-size: 17px; margin-bottom: 4px; }

/* Excel antes y después */
.excel { margin-top: 48px; }
.excel h2 { font-size: 24px; margin: 0 0 4px; }
.excel > p { margin: 0 0 16px; color: var(--suave); max-width: 640px; }
.excel__grid { display: grid; gap: 12px; }
@media (min-width: 860px) { .excel__grid { grid-template-columns: repeat(3, 1fr); } }
.par { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); overflow: hidden; }
.par__lado { padding: 12px 14px; }
.par__lado + .par__lado { border-top: 1px solid var(--linea); }
.par__etq { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; color: var(--suave); margin-bottom: 4px; }
.par__antes { background: #faf8f4; }
.par__antes .par__txt { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: 12.5px; color: #6b5f52; word-break: break-word; }
.par__despues .par__etq { color: var(--naranja-osc); }
.par__txt { font-size: 14px; }
.par__que { font-size: 13px; color: var(--suave); margin-top: 6px; }

.pie { text-align: center; color: var(--suave); font-size: 13px; padding: 24px 16px 40px; border-top: 1px solid var(--linea); }
.pie p { margin: 4px 0; }

/* Hojas (diálogos) */
dialog.hoja {
  border: 0; padding: 0; background: var(--papel); color: var(--tinta);
  width: min(560px, 100vw); max-width: 100vw; max-height: min(92vh, 900px);
  border-radius: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
dialog.hoja::backdrop { background: rgba(20, 22, 26, .45); }
dialog.hoja[open] { animation: sube .22s ease; }
@keyframes sube { from { transform: translateY(16px); opacity: 0; } }
@media (max-width: 600px) {
  dialog.hoja { margin: auto 0 0; width: 100vw; border-radius: 18px 18px 0 0; max-height: 92vh; }
}
dialog.hoja--lateral { width: min(440px, 100vw); }
@media (min-width: 601px) {
  dialog.hoja--lateral { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; border-radius: 0; }
  dialog.hoja--lateral[open] { animation: entra .22s ease; }
  @keyframes entra { from { transform: translateX(30px); opacity: 0; } }
}
.hoja__in { padding: 18px 18px 22px; }
.hoja__cab { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.hoja__cab h2 { margin: 0; font-size: 20px; }
.cerrar {
  border: 0; background: #f0ede7; width: 36px; height: 36px; border-radius: 50%;
  font-size: 22px; line-height: 1; display: grid; place-items: center; flex: none;
}
.cerrar:hover { background: #e4e0d8; }

/* Ficha */
.ficha__foto { background: #fff; border: 1px solid var(--linea); border-radius: var(--radio); aspect-ratio: 4 / 3; padding: 14px; display: grid; place-items: center; margin-bottom: 14px; }
.ficha__foto img { max-height: 100%; object-fit: contain; }
.ficha__meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; margin-bottom: 6px; }
.chip { background: #f0ede7; border-radius: 6px; padding: 3px 8px; }
.chip--marca { background: var(--tinta); color: #fff; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.ficha h3 { font-size: 21px; line-height: 1.25; margin: 4px 0 10px; }
.ficha__precio { font-size: 26px; font-weight: 800; margin-bottom: 14px; }
.ficha__precio small { font-size: 13px; font-weight: 500; color: var(--suave); margin-left: 6px; }
.ficha__datos { margin: 0 0 16px; padding: 12px 14px; background: #faf8f4; border-radius: 12px; font-size: 13.5px; list-style: none; max-height: 240px; overflow: auto; }
.ficha__datos li { padding: 3px 0; border-bottom: 1px dashed #e6e1d8; }
.ficha__datos li:last-child { border-bottom: 0; }
.ficha__datos .titulo { font-weight: 700; padding-top: 8px; }
.ficha__acciones { display: flex; gap: 10px; align-items: stretch; }
.cantidad { display: flex; align-items: center; border: 1px solid var(--linea); border-radius: 12px; overflow: hidden; }
.cantidad button { border: 0; background: none; width: 40px; height: 100%; min-height: 46px; font-size: 20px; }
.cantidad button:hover { background: #f4f2ee; }
.cantidad output, .cantidad span { min-width: 30px; text-align: center; font-weight: 700; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  border: 0; border-radius: 12px; padding: 14px 16px; font-weight: 700; text-decoration: none; text-align: center;
}
.btn svg { width: 22px; height: 22px; }
.btn--pri { background: var(--naranja); color: #fff; }
.btn--pri:hover { background: var(--naranja-osc); }
.btn--wsp { background: var(--wsp); color: #fff; }
.btn--wsp:hover { background: #178f47; }
.btn--sec { background: #f0ede7; color: var(--tinta); margin-top: 10px; }
.btn--sec:hover { background: #e4e0d8; }

/* Cotización */
.cot-item { display: grid; grid-template-columns: 56px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--linea); }
.cot-item__foto { width: 56px; height: 56px; background: #fff; border: 1px solid var(--linea); border-radius: 10px; padding: 4px; }
.cot-item__foto img { width: 100%; height: 100%; object-fit: contain; }
.cot-item__nombre { font-size: 14px; font-weight: 600; line-height: 1.3; }
.cot-item__cod { font-size: 12px; color: var(--suave); }
.cot-item__fila { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; gap: 8px; }
.cot-item .cantidad button { min-height: 32px; width: 32px; font-size: 17px; }
.quitar { border: 0; background: none; color: var(--suave); font-size: 12px; text-decoration: underline; padding: 0; margin-left: 8px; }
.cot-vacia { text-align: center; color: var(--suave); padding: 30px 10px; }
.cot-vacia b { display: block; color: var(--tinta); margin-bottom: 4px; }
.cot-form { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.cot-total { display: flex; justify-content: space-between; align-items: baseline; font-size: 18px; }
.cot-total b { font-size: 24px; }
.nota { font-size: 13px; color: var(--suave); margin: 0; }
.cot-form label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; font-weight: 600; }
.cot-form label small { font-weight: 400; color: var(--suave); }
.cot-form input, .cot-form select {
  border: 1px solid #d3cec5; border-radius: 10px; padding: 11px 12px; background: #fff; font-weight: 400;
}
.cot-form input:focus, .cot-form select:focus { outline: 2px solid var(--naranja); outline-offset: 0; border-color: transparent; }

/* Vista de WhatsApp */
.wsp { border-radius: 14px; overflow: hidden; border: 1px solid var(--linea); margin-bottom: 12px; }
.wsp__cab { display: flex; align-items: center; gap: 10px; background: #075e54; color: #fff; padding: 10px 12px; }
.wsp__cab small { display: block; font-size: 11px; opacity: .8; }
.wsp__avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--naranja); display: grid; place-items: center; font-weight: 800; }
.wsp__chat { background: #ece5dd; padding: 14px 12px; max-height: 46vh; overflow: auto; }
.wsp__burbuja {
  background: #dcf8c6; border-radius: 10px 0 10px 10px; padding: 9px 11px 18px; margin-left: 18px;
  font-size: 13.5px; white-space: pre-wrap; position: relative; box-shadow: 0 1px 1px rgba(0,0,0,.1);
}
.wsp__burbuja::after { content: "✓✓"; position: absolute; right: 8px; bottom: 3px; font-size: 10px; color: #34b7f1; letter-spacing: -2px; }

/* Proforma: solo al imprimir */
.proforma { display: none; }
@media print {
  @page { size: A4; margin: 16mm; }
  body > *:not(.proforma) { display: none !important; }
  body { background: #fff; }
  .proforma { display: block; color: #000; font-size: 11pt; }
  .pf-cab { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid var(--naranja); padding-bottom: 10px; margin-bottom: 14px; }
  .pf-cab h1 { font-size: 22pt; letter-spacing: .08em; margin: 0; }
  .pf-cab p { margin: 2px 0; }
  .pf-num { text-align: right; }
  .pf-num b { font-size: 14pt; display: block; }
  .pf-cliente { margin-bottom: 14px; }
  .pf-cliente p { margin: 2px 0; }
  .proforma table { width: 100%; border-collapse: collapse; }
  .proforma th { text-align: left; background: #f0ede7; padding: 6px; font-size: 9.5pt; text-transform: uppercase; letter-spacing: .05em; }
  .proforma td { padding: 6px; border-bottom: 1px solid #ddd; vertical-align: top; }
  .proforma td.n, .proforma th.n { text-align: right; white-space: nowrap; }
  .pf-total td { font-weight: 800; font-size: 13pt; border-bottom: 0; }
  .pf-nota { margin-top: 18px; font-size: 9.5pt; color: #444; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
