/* ============================================================
   SpineNet · vista inventario
   Clases prefijadas v-inventario-…  ·  solo var(--token), nunca hex
   ============================================================ */

/* ---------- SpineNet: filtros, custodia y montos por moneda ---------- */
.v-inv-barra { gap: 12px; align-items: center; }
.v-inv-chk { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-13); color: var(--text-secondary); cursor: pointer; }
.v-inv-montos { font-size: var(--fs-20); white-space: nowrap; }

/* ---------- Por familia: una tarjeta por familia de producto ---------- */
.v-fam-barra { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.v-fam-barra .searchbox { flex: 1 1 280px; max-width: 420px; }
.v-fam-barra__acc { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-left: auto; }
.v-fam-rejilla { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); }
.v-fam-rejilla > .empty { grid-column: 1 / -1; }

.v-fam {
  display: flex; flex-direction: column; gap: var(--s-3);
  padding: var(--s-5); border-radius: var(--r-lg);
  background: var(--bg-surface); border: 1px solid var(--border);
  transition: border-color var(--t);
}
.v-fam:hover { border-color: var(--border-strong); }

.v-fam__head { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.v-fam__pieza {
  flex: 0 0 auto; width: 52px; height: 52px; display: grid; place-items: center;
  border-radius: var(--r); background: var(--brand-soft); color: var(--brand);
}
.v-fam__pieza svg { width: 40px; height: 40px; }
.v-fam--sin .v-fam__pieza { background: var(--bg-inset); color: var(--text-muted); }
.v-fam__nombre { min-width: 0; }
.v-fam__nombre h3 { font-size: var(--fs-15); font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; text-wrap: balance; }
.v-fam__nombre p { margin-top: 2px; font-size: var(--fs-12); color: var(--text-muted); }

.v-fam__cifra { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; }
.v-fam__cifra > b { font-size: 34px; font-weight: 600; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.v-fam__cifra > span { font-size: var(--fs-13); color: var(--text-secondary); }
.v-fam__cifra .badge { margin-left: auto; align-self: center; }
.v-fam--sin .v-fam__cifra > b { color: var(--text-muted); }

/* Contra el mínimo: por tramos (medidas cubiertas, por reponer y bajo el
   mínimo) o, con una sola medida, las existencias con una raya en el mínimo */
.v-fam__barra { position: relative; display: flex; gap: 2px; height: 8px; border-radius: var(--r-full); background: var(--bar-muted); }
.v-fam__tramo { min-width: 6px; border-radius: var(--r-full); }
.v-fam__tramo--ok { background: var(--brand); }
.v-fam__tramo--bajo { background: var(--warn); }
.v-fam__tramo--critico { background: var(--danger); }
.v-fam__minimo { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--text-primary); opacity: .55; }
.v-fam__nota { margin-top: -6px; font-size: var(--fs-12); color: var(--text-muted); }

.v-fam__vence { display: flex; align-items: flex-start; gap: 6px; font-size: var(--fs-12); color: var(--text-secondary); line-height: 1.4; }
.v-fam__vence svg { flex: 0 0 auto; width: 14px; height: 14px; margin-top: 1px; color: var(--text-muted); }
.v-fam__vence b { font-weight: 600; color: var(--text-primary); }
.v-fam__vence.is-pronto, .v-fam__vence.is-pronto b, .v-fam__vence.is-pronto svg { color: var(--warn-ink); }
.v-fam__vence.is-vencido, .v-fam__vence.is-vencido svg { color: var(--danger-ink); }

/* Cada medida con su cantidad: se toca para ver sus lotes */
.v-fam__medidas { display: flex; flex-wrap: wrap; gap: 6px; }
.v-fam__medida {
  display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 3px 4px 3px 10px;
  border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--bg-surface);
  font-size: var(--fs-12); font-weight: 500; color: var(--text-primary); cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), transform var(--t-fast);
}
.v-fam__medida b {
  min-width: 22px; padding: 1px 6px; border-radius: 5px; text-align: center;
  background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; font-variant-numeric: tabular-nums;
}
@media (hover: hover) { .v-fam__medida:hover { border-color: var(--brand); } }
.v-fam__medida:active { transform: scale(0.96); }
.v-fam__medida:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.v-fam__medida.is-cero { color: var(--text-muted); background: var(--bg-muted); }
.v-fam__medida.is-cero b { background: transparent; color: var(--text-muted); }
.v-fam__medida.is-critico { border-color: var(--danger-soft); background: var(--danger-soft); color: var(--danger-ink); }
.v-fam__medida.is-critico b { background: var(--danger-ink); color: var(--bg-surface); }
.v-fam__medida.is-bajo { border-color: var(--warn-soft); background: var(--warn-soft); color: var(--warn-ink); }
.v-fam__medida.is-bajo b { background: var(--bg-surface); color: var(--warn-ink); }

.v-fam__pie { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: auto; padding-top: var(--s-1); }

@media (max-width: 640px) {
  .v-fam { padding: var(--s-4); }
  .v-fam-barra .searchbox { max-width: none; }
  .v-fam-barra__acc { margin-left: 0; }
  .v-fam__medida { min-height: 36px; }
}

/* ---------- Registrar ingreso: elegir cómo ---------- */
.v-inv-opciones { display: grid; gap: var(--s-3); }
.v-inv-opcion {
  display: flex; align-items: flex-start; gap: var(--s-3); width: 100%;
  padding: var(--s-4); text-align: left; cursor: pointer;
  background: var(--bg-surface); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: var(--r);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.v-inv-opcion:hover { border-color: var(--brand); background: var(--brand-soft); }
.v-inv-opcion:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.v-inv-opcion > svg { width: 22px; height: 22px; flex: 0 0 auto; color: var(--brand); margin-top: 1px; }
.v-inv-opcion b { display: block; font-size: var(--fs-15); }
.v-inv-opcion small { display: block; margin-top: 2px; font-size: var(--fs-12); color: var(--text-secondary); line-height: 1.45; }

/* ---------- Escanear etiquetas ---------- */
.v-esc__visor {
  position: relative; overflow: hidden; margin-bottom: var(--s-3);
  aspect-ratio: 4 / 3; max-height: 46vh; max-height: 46dvh; width: 100%;
  background: var(--mt-navy-900); border-radius: var(--r);
  touch-action: manipulation;
}
.v-esc__visor[hidden] { display: none; }
.v-esc__visor video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* En el iPhone la imagen se copia a un lienzo encima del video (ver lector.js) */
.v-esc__visor canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* Marco del centro: ahí mira el lector */
.v-esc__marco {
  position: absolute; left: 50%; top: 50%; width: 58%; aspect-ratio: 1; max-height: 78%;
  transform: translate(-50%, -50%); border-radius: 10px; pointer-events: none;
  box-shadow: 0 0 0 999px rgba(5, 12, 24, 0.38);
  border: 2px solid rgba(255, 255, 255, 0.9);
}
.v-esc__estado {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 12px;
  font-size: var(--fs-12); font-weight: 700; text-align: center; color: var(--mt-navy-050);
  background: linear-gradient(transparent, rgba(5, 12, 24, 0.7));
}
.v-esc__leido {
  position: absolute; left: 10px; right: 10px; bottom: 10px; display: grid; gap: 10px;
  padding: 12px; border-radius: var(--r); background: var(--bg-elevated); box-shadow: var(--sh-3);
  border-left: 3px solid var(--ok);
}
.v-esc__leido.is-warn { border-left-color: var(--warn); }
.v-esc__leido[hidden] { display: none; }
.v-esc__leido-txt { font-size: var(--fs-13); font-weight: 700; line-height: 1.4; }

.v-esc__botones { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.v-esc__botones .btn { flex: 1 1 180px; }
.v-esc__subir { position: relative; overflow: hidden; cursor: pointer; }
/* El selector de archivo va invisible dentro del botón (iPhone no abre uno oculto con display:none) */
.v-esc__archivo { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 0; }
.v-esc__subir:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }

.v-esc__aviso { min-height: 0; margin: var(--s-2) 0 0; font-size: var(--fs-12); color: var(--text-secondary); }
.v-esc__aviso:empty { display: none; }
.v-esc__aviso.is-warn { color: var(--warn-ink); }
.v-esc__aviso.is-ok { color: var(--ok-ink); }

.v-esc__titulo { display: flex; align-items: baseline; justify-content: space-between; margin: var(--s-4) 0 var(--s-2); font-size: var(--fs-13); }
.v-esc__titulo span { color: var(--text-muted); font-size: var(--fs-12); }
.v-esc__vacio {
  margin-top: var(--s-4); padding: var(--s-4); text-align: center;
  font-size: var(--fs-12); color: var(--text-muted);
  border: 1px dashed var(--border-strong); border-radius: var(--r);
}
.v-esc__fila {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: start; gap: var(--s-3);
  padding: var(--s-3) 0; border-top: 1px solid var(--border);
}
.v-esc__fila.is-falta .v-esc__info > b { color: var(--warn-ink); }
.v-esc__info { display: grid; gap: 4px; min-width: 0; }
.v-esc__info > b { font-size: var(--fs-13); line-height: 1.35; }
.v-esc__datos { font-size: var(--fs-12); color: var(--text-muted); overflow-wrap: anywhere; }
.v-esc__nota { font-size: var(--fs-11); color: var(--warn-ink); font-weight: 700; }
.v-esc__nota--info { color: var(--text-secondary); font-weight: 600; }
.v-esc__campo { display: grid; gap: 3px; margin-top: 4px; font-size: var(--fs-11); font-weight: 700; color: var(--text-secondary); }
.v-esc__info .select { margin-top: 4px; }
.v-esc__cant { display: flex; align-items: center; gap: 2px; }
.v-esc__cant .input { width: 52px; height: 34px; padding: 0 4px; text-align: center; font-variant-numeric: tabular-nums; }
.v-esc__cant > b { min-width: 34px; text-align: center; font-size: var(--fs-15); font-variant-numeric: tabular-nums; }
.v-esc__cant .iconbtn { width: 34px; height: 34px; }
.v-esc__quitar { width: 34px; height: 34px; color: var(--text-muted); }

@media (max-width: 640px) {
  .v-esc__fila { grid-template-columns: minmax(0, 1fr) auto; }
  .v-esc__cant { grid-column: 1; grid-row: 2; }
  .v-esc__quitar { grid-column: 2; grid-row: 1; }
}
