[hidden] { display: none !important; }
:root {
  --ink: #1c1a33; --indigo: #3a2784; --indigo-2: #2a1c63; --red: #e3201b; --yellow: #ffe000;
  --muted: #5f5c75; --line: #e4e2ec; --soft: #f5f4f9; --bg: #fbfbfd; --white: #fff;
  --ok: #157a3a; --ok-bg: #e6f4ea; --zero: #8a4d00; --zero-bg: #fff1d6; --neg: #b3201a; --neg-bg: #fde8e7;
  --wa: #128c4a; --r: 12px; --shadow: 0 1px 2px rgba(28,26,51,.06), 0 4px 14px rgba(28,26,51,.06);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--indigo); color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 50; }
.skip:focus { top: 8px; }
:focus-visible { outline: 3px solid #7b63e0; outline-offset: 2px; }

/* header */
.top { position: sticky; top: 0; z-index: 20; background: var(--white); border-bottom: 1px solid var(--line); box-shadow: 0 2px 10px rgba(28,26,51,.04); }
.top-in { display: flex; align-items: center; gap: 10px; padding: 10px 16px 6px; max-width: 1200px; margin: 0 auto; }
.logo { width: 74px; height: auto; flex: none; }
.top-t { flex: 1; min-width: 0; }
.top h1 { margin: 0; font-size: 17px; line-height: 1.15; color: var(--indigo); font-weight: 800; letter-spacing: -.2px; }
.top h1 span { display: block; font-weight: 600; color: var(--ink); font-size: 14px; }
.top-t p { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vend { display: flex; align-items: center; gap: 6px; min-height: 40px; max-width: 42vw; padding: 6px 12px 6px 9px; border: 1px solid var(--line);
  border-radius: 999px; background: var(--soft); font-size: 13px; font-weight: 600; color: var(--indigo); }
.vend svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.vend span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vend.falta { background: #fff4c2; border-color: #f0d36a; color: #6b4e00; }

.buscar { position: relative; max-width: 1200px; margin: 4px auto 0; padding: 0 16px; }
.buscar svg { position: absolute; left: 29px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); fill: var(--muted); pointer-events: none; }
.buscar input { width: 100%; height: 46px; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 44px 0 42px; background: var(--soft); font-size: 16px; }
.buscar input:focus { border-color: var(--indigo); background: #fff; outline: none; box-shadow: 0 0 0 3px rgba(58,39,132,.15); }
.buscar input::-webkit-search-cancel-button { display: none; }
.x { position: absolute; right: 22px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; font-size: 24px; color: var(--muted); }

.lineas { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px 4px; max-width: 1200px; margin: 0 auto; scrollbar-width: none; scroll-snap-type: x proximity; }
.lineas::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 38px; padding: 7px 13px; border: 1.5px solid var(--line); border-radius: 999px; background: #fff; font-size: 13.5px; font-weight: 600;
  color: var(--ink); white-space: nowrap; scroll-snap-align: start; }
.chip em { font-style: normal; color: var(--muted); font-weight: 500; margin-left: 4px; font-size: 12px; }
.chip[aria-pressed="true"] { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.chip[aria-pressed="true"] em { color: #d6d0f2; }

.filtros { display: flex; gap: 8px; align-items: center; padding: 6px 16px 10px; max-width: 1200px; margin: 0 auto; overflow-x: auto; scrollbar-width: none; }
.filtros::-webkit-scrollbar { display: none; }
.sel select { height: 38px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; padding: 0 30px 0 10px; font-size: 13.5px; max-width: 46vw;
  appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 16px, calc(100% - 10px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }
.tog { display: flex; align-items: center; gap: 7px; flex: none; min-height: 38px; padding: 0 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; font-size: 13.5px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.tog input { width: 18px; height: 18px; accent-color: var(--indigo); margin: 0; }

/* list */
main { max-width: 1200px; margin: 0 auto; padding: 12px 16px 24px; outline: none; }
.conteo { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } .logo { width: 96px; } .top h1 { font-size: 20px; } }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.card.en { border-color: var(--indigo); box-shadow: 0 0 0 2px rgba(58,39,132,.18), var(--shadow); }
.c-img { position: relative; aspect-ratio: 1 / 1; background: var(--soft); border: 0; padding: 10px; display: flex; align-items: center; justify-content: center; width: 100%; }
.c-img img { max-height: 100%; width: auto; object-fit: contain; mix-blend-mode: multiply; }
.c-img .sin { font-size: 12px; color: var(--muted); }
.c-img .marca { position: absolute; left: 7px; top: 7px; }
.c-img .cant { position: absolute; right: 7px; top: 7px; background: var(--indigo); color: #fff; font-weight: 800; font-size: 13px; min-width: 28px; height: 28px; border-radius: 14px; display: flex; align-items: center; justify-content: center; padding: 0 8px; }
.c-bd { padding: 9px 10px 10px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.ref { font-size: 11.5px; font-weight: 800; color: var(--indigo); letter-spacing: .3px; font-variant-numeric: tabular-nums; }
.c-n { margin: 0; font-size: 13.5px; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; min-height: 3.75em; }
.c-pr { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.precio { font-size: 18px; font-weight: 800; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.marca { display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; padding: 3px 7px; border-radius: 5px; line-height: 1.2; }
.m-mercury { background: #111; color: var(--yellow); } .m-titanium { background: #5b6472; color: #fff; } .m-thor { background: #d9480f; color: #fff; }
.m-knox { background: #0e4c97; color: #fff; } .m-valqua { background: #00707b; color: #fff; }
.st { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 3px 8px; white-space: nowrap; }
.st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st.ok { color: var(--ok); background: var(--ok-bg); } .st.zero { color: var(--zero); background: var(--zero-bg); } .st.neg { color: var(--neg); background: var(--neg-bg); }

.step { display: flex; align-items: center; border: 1.5px solid var(--indigo); border-radius: 10px; overflow: hidden; height: 42px; }
.step button { width: 44px; height: 100%; border: 0; background: #fff; color: var(--indigo); font-size: 22px; font-weight: 700; line-height: 1; flex: none; }
.step button:active { background: var(--soft); }
.step input { flex: 1; min-width: 0; width: 100%; height: 100%; border: 0; text-align: center; font-weight: 800; font-size: 16px; -moz-appearance: textfield; background: #fff; }
.step input::-webkit-inner-spin-button, .step input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.add { width: 100%; height: 42px; border: 0; border-radius: 10px; background: var(--indigo); color: #fff; font-weight: 700; font-size: 14px; }
.add:active { background: var(--indigo-2); }
.add.pp { background: #fff; color: var(--indigo); border: 1.5px solid var(--indigo); }
.add:disabled { background: var(--soft); color: var(--muted); border: 1.5px dashed var(--line); cursor: not-allowed; }

.vacio { text-align: center; padding: 40px 10px; color: var(--muted); }
.vacio p { margin: 4px 0; }
.vacio .btn { margin-top: 14px; }

/* bottom bar */
.barra { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px); border-top: 1px solid var(--line); box-shadow: 0 -4px 18px rgba(28,26,51,.08); }
.barra-in { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.barra-in div { display: flex; flex-direction: column; line-height: 1.2; }
.barra-in b { font-size: 13px; color: var(--muted); font-weight: 600; }
.barra-in span { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.barra .btn { min-width: 150px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 12px; border: 0; font-weight: 700; font-size: 15px; }
.btn.pri { background: var(--indigo); color: #fff; } .btn.pri:active { background: var(--indigo-2); }
.btn.sec { background: #fff; color: var(--indigo); border: 1.5px solid var(--indigo); }
.btn.txt { background: transparent; color: var(--neg); text-decoration: underline; text-underline-offset: 3px; }
.btn.wa { background: var(--wa); color: #fff; } .btn.wa svg { width: 22px; height: 22px; fill: #fff; }

/* dialogs */
dialog.hoja { border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 92vh; border-radius: 18px 18px 0 0; background: #fff; color: var(--ink);
  box-shadow: 0 -10px 40px rgba(0,0,0,.2); }
dialog.hoja.grande { max-width: 720px; }
@media (min-width: 720px) { dialog.hoja { margin: auto; border-radius: 18px; } }
dialog::backdrop { background: rgba(20,16,45,.55); }
.hoja-in { position: relative; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); overflow-y: auto; max-height: 92vh; }
.hoja h2 { margin: 0 44px 10px 0; font-size: 20px; line-height: 1.25; }
.hoja h3 { margin: 18px 0 10px; font-size: 15px; color: var(--indigo); }
.cerrar { position: absolute; right: 10px; top: 10px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--soft); font-size: 26px; line-height: 1; color: var(--ink); z-index: 2; }
.mut { color: var(--muted); font-size: 14px; }
.centro { text-align: center; }
.centro h2 { margin: 6px 0 8px; }
.ok-ico { width: 64px; height: 64px; margin: 6px auto 0; border-radius: 50%; background: var(--ok-bg); color: var(--ok); font-size: 34px; font-weight: 800; display: flex; align-items: center; justify-content: center; }

.f-img { background: var(--soft); border-radius: 14px; aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; padding: 16px; margin-top: 36px; }
.f-img img { max-height: 100%; width: auto; object-fit: contain; mix-blend-mode: multiply; }
.f-bd { padding-top: 14px; }
.f-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.f-bc { margin: 0 0 12px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; color: var(--muted); }
.f-pr { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.f-pr div { display: flex; flex-direction: column; }
.f-pr small { font-size: 12px; color: var(--muted); }
.f-pr b { font-size: 28px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.f-acc { margin-top: 14px; }
.f-acc .step { height: 50px; } .f-acc .step button { width: 56px; } .f-acc .add { height: 50px; }

.items { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.items li { display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.items .mini { width: 52px; height: 52px; background: var(--soft); border-radius: 8px; display: flex; align-items: center; justify-content: center; padding: 4px; }
.items .mini img { max-height: 100%; width: auto; mix-blend-mode: multiply; }
.items .in { min-width: 0; }
.items .in b { display: block; font-size: 13.5px; line-height: 1.25; font-weight: 600; }
.items .in small { color: var(--muted); font-size: 12px; }
.items .in .pp { color: var(--zero); font-weight: 700; }
.items .der { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.items .der .step { height: 36px; width: 118px; } .items .der .step button { width: 36px; font-size: 19px; }
.items .sub { font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; }
.tot { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 0 4px; }
.tot span { color: var(--muted); font-size: 14px; }
.tot b { font-size: 24px; font-variant-numeric: tabular-nums; }
.aviso { background: var(--zero-bg); color: var(--zero); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin: 8px 0 0; }

.campos { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 560px) { .campos { grid-template-columns: 1fr 1fr; } .campos .full { grid-column: 1 / -1; } }
.campos label, label.solo { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.campos em, label em { color: var(--red); font-style: normal; }
.campos input, .campos textarea, label.solo input { height: 46px; border: 1.5px solid var(--line); border-radius: 10px; padding: 0 12px; font-size: 16px; color: var(--ink); background: #fff; font-weight: 400; }
.campos textarea { height: auto; padding: 10px 12px; resize: vertical; }
.campos input:focus, .campos textarea:focus, label.solo input:focus { border-color: var(--indigo); outline: none; box-shadow: 0 0 0 3px rgba(58,39,132,.15); }
.campos input[aria-invalid="true"] { border-color: var(--neg); }
.err { color: var(--neg); font-weight: 600; font-size: 14px; margin: 10px 0 0; }
.acciones { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.acciones .wa { flex: 1 1 100%; }
.acciones.col { flex-direction: column; } .acciones.col .btn { width: 100%; }
#formVend .acciones .btn { width: 100%; }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600; z-index: 60; transition: .2s; max-width: calc(100% - 32px); }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
/* v2: solo el buscador y las líneas quedan fijos */
.top { position: static; box-shadow: none; border-bottom: 0; }
.pega { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line); box-shadow: 0 4px 12px rgba(28,26,51,.05); padding-top: 8px; }
.pega .buscar { margin-top: 0; }
.filtros { padding-top: 10px; padding-bottom: 0; }
.c-img { aspect-ratio: 5 / 4; padding: 8px; }
/* v3: correcciones de auditoría */
.btn.wa { background: #0f7a3e; }
.top-t p { white-space: normal; overflow: visible; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; font-size: 12px; }
.top-t p.alerta { color: var(--neg); font-weight: 700; }
.filtros { flex-wrap: wrap; overflow: visible; padding: 0 0 12px; }
.sel { flex: 1 1 150px; }
.sel select { width: 100%; max-width: none; font-size: 16px; height: 42px; background-position: calc(100% - 15px) 18px, calc(100% - 10px) 18px; }
.tog { min-height: 42px; font-size: 14px; }
.items .der .step { height: 42px; width: 132px; } .items .der .step button { width: 42px; }
.marca { font-size: 10.5px; } .ref { font-size: 12px; } .st { font-size: 12px; }
#eLargo { text-align: left; }
search { display: block; }
.c-img { overflow: hidden; min-height: 0; }
.c-img img { width: 100%; height: 100%; max-height: none; object-fit: contain; }
