:root {
  --naranja: #F67D3A;
  --naranja-dark: #d9651e;
  --verde: #3A7D44;
  --verde-dark: #2d6235;
  --gris: #f4f4f4;
  --borde: #e0e0e0;
  --texto: #1a1a1a;
  --subtexto: #666;
  --sombra: 0 2px 10px rgba(0,0,0,.1);
  --radio: 14px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--gris); color: var(--texto); min-height: 100dvh; }

/* ── LOGIN ── */
#pantalla-login { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 24px; background: linear-gradient(160deg, #fff8f3 0%, #f0faf2 100%); }
.login-logo { font-size: 3rem; margin-bottom: 8px; }
.login-titulo { font-size: 1.5rem; font-weight: 800; color: var(--naranja); margin-bottom: 4px; }
.login-sub { font-size: .9rem; color: var(--subtexto); margin-bottom: 32px; }
.login-card { background: #fff; border-radius: 20px; box-shadow: 0 8px 32px rgba(0,0,0,.12); padding: 28px 24px; width: 100%; max-width: 380px; }
.login-card h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.login-card p { font-size: .85rem; color: var(--subtexto); margin-bottom: 20px; }
.login-input { width: 100%; padding: 14px 16px; border: 2px solid var(--borde); border-radius: 12px; font-size: 1rem; margin-bottom: 14px; transition: border-color .15s; -webkit-appearance: none; }
.login-input:focus { outline: none; border-color: var(--naranja); }

/* ── CABECERA ── */
header { background: var(--naranja); color: #fff; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.header-left { display: flex; align-items: center; gap: 8px; }
.header-titulo { font-size: 1rem; font-weight: 700; }
.header-titulo span { font-weight: 400; font-size: .8rem; display: block; opacity: .85; }
.btn-sesion { background: rgba(255,255,255,.2); border: 1.5px solid rgba(255,255,255,.4); color: #fff; border-radius: 20px; padding: 5px 12px; font-size: .78rem; font-weight: 600; cursor: pointer; white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }

/* ── PROGRESO ── */
.progreso-wrap { background: #fff; padding: 14px 16px 10px; border-bottom: 1px solid var(--borde); }
.progreso-pasos { display: flex; align-items: flex-start; }
.paso-item { display: flex; flex-direction: column; align-items: center; flex: 1; position: relative; }
.paso-circulo { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--borde); background: #fff; display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; color: #aaa; transition: all .3s; position: relative; z-index: 1; }
.paso-circulo.activo { border-color: var(--naranja); background: var(--naranja); color: #fff; }
.paso-circulo.hecho  { border-color: var(--verde); background: var(--verde); color: #fff; }
.paso-linea { position: absolute; top: 15px; left: 50%; width: 100%; height: 2px; background: var(--borde); z-index: 0; transition: background .3s; }
.paso-linea.hecha { background: var(--verde); }
.paso-item:last-child .paso-linea { display: none; }
.paso-label { font-size: .65rem; color: #aaa; margin-top: 4px; font-weight: 600; text-align: center; }
.paso-label.activo { color: var(--naranja); }
.paso-label.hecho  { color: var(--verde); }

/* ── MAIN ── */
main { max-width: 480px; margin: 0 auto; padding: 16px; padding-bottom: 90px; display: flex; flex-direction: column; gap: 14px; }
.pantalla { display: none; }
.pantalla.activa { display: flex; flex-direction: column; gap: 14px; }

/* ── TARJETA ── */
.card { background: #fff; border-radius: var(--radio); box-shadow: var(--sombra); padding: 18px; }
.card-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: #999; margin-bottom: 12px; }

/* ── ESCÁNER ── */
#reader-wrapper { border-radius: 10px; overflow: hidden; background: #000; }
#reader { width: 100%; }
#reader img                { display: none !important; }
#reader__dashboard         { display: none !important; }
#reader__scan_region > img { display: none !important; }
#reader video              { width: 100% !important; height: auto !important; display: block !important; }
.scan-badge { display: none; align-items: center; gap: 6px; background: #f0faf2; border: 1.5px solid var(--verde); border-radius: 8px; padding: 8px 12px; font-size: .85rem; color: var(--verde-dark); font-weight: 600; margin-top: 8px; }
.scan-badge.visible { display: flex; }
.ref-row { display: flex; gap: 6px; align-items: center; margin-top: 10px; }
.ref-row input { flex: 1; }

/* ── BOTÓN INSTALACIÓN ── */
.btn-instalacion { width: 100%; padding: 16px; background: #fff; border: 2px solid var(--naranja); border-radius: var(--radio); display: flex; align-items: center; gap: 14px; cursor: pointer; transition: all .15s; box-shadow: var(--sombra); }
.btn-instalacion:active { background: #fff8f3; }
.btn-instalacion .icon { font-size: 2rem; }
.btn-instalacion .textos { text-align: left; }
.btn-instalacion .textos strong { display: block; font-size: 1rem; font-weight: 800; color: var(--naranja-dark); }
.btn-instalacion .textos span  { font-size: .8rem; color: var(--subtexto); }

/* ── TIPO MOVIMIENTO ── */
.tipo-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.tipo-btn { border: 2px solid var(--borde); border-radius: 12px; background: #fff; padding: 14px 8px; font-size: .85rem; font-weight: 700; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px; transition: all .15s; }
.tipo-btn .icon { font-size: 1.6rem; }
.tipo-btn .desc { font-size: .65rem; font-weight: 400; color: #999; text-align: center; }
.tipo-btn.salida.active    { border-color: #e53e3e; background: #fff5f5; color: #c53030; }
.tipo-btn.entrada.active   { border-color: var(--verde); background: #f0faf2; color: var(--verde-dark); }
.tipo-btn.devolucion.active{ border-color: #805ad5; background: #faf5ff; color: #6b46c1; }

/* ── ALMACÉN ── */
.almacen-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.almacen-btn { border: 2px solid var(--borde); border-radius: 12px; background: #fff; padding: 14px 8px; font-size: .95rem; font-weight: 700; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: all .15s; }
.almacen-btn .icon { font-size: 1.5rem; }
.almacen-btn.active { border-color: var(--verde); background: #f0faf2; color: var(--verde-dark); }

/* ── CHIPS ── */
.chips-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 9px 14px; border-radius: 20px; border: 2px solid var(--borde); background: #fff; font-size: .85rem; font-weight: 600; cursor: pointer; transition: all .15s; white-space: nowrap; }
.chip.vehiculo.selected { border-color: #805ad5; background: #faf5ff; color: #6b46c1; }

/* ── INPUTS ── */
.field { display: flex; flex-direction: column; gap: 6px; }
label { font-size: .82rem; font-weight: 700; color: #444; }
.req { color: #e53e3e; }
input[type="text"], input[type="number"], textarea, select {
  width: 100%; padding: 13px 14px; border: 2px solid var(--borde); border-radius: 10px;
  font-size: 1rem; background: #fff; transition: border-color .15s; -webkit-appearance: none; appearance: none;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--naranja); }
input.escaneado { border-color: var(--verde); background: #f0faf2; }
.btn-clear { width: 46px; height: 46px; border: 2px solid var(--borde); border-radius: 10px; background: #fff; font-size: 1rem; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }

/* ── RESUMEN ── */
.resumen-item { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--borde); font-size: .9rem; }
.resumen-item:last-child { border-bottom: none; }
.resumen-item .lbl { color: var(--subtexto); font-weight: 500; }
.resumen-item .val { font-weight: 700; text-align: right; max-width: 65%; }
.badge-tipo { display: inline-block; padding: 3px 12px; border-radius: 12px; font-size: .82rem; font-weight: 700; }
.badge-Salida    { background: #fff5f5; color: #c53030; }
.badge-Entrada   { background: #f0faf2; color: var(--verde-dark); }
.badge-Devolución{ background: #faf5ff; color: #6b46c1; }

/* ── BOTONES NAVEGACIÓN ── */
.nav-btns { display: flex; gap: 10px; }
.btn-back { flex: 0 0 auto; padding: 15px 18px; border-radius: 12px; border: 2px solid var(--borde); background: #fff; font-size: .95rem; font-weight: 600; cursor: pointer; }
.btn-next { flex: 1; padding: 15px; background: var(--naranja); color: #fff; border: none; border-radius: 12px; font-size: 1rem; font-weight: 700; cursor: pointer; box-shadow: 0 4px 12px rgba(246,125,58,.3); transition: background .15s, transform .1s; }
.btn-next:hover { background: var(--naranja-dark); }
.btn-next:active { transform: scale(.98); }
.btn-next:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn-primary { width: 100%; padding: 15px; background: var(--naranja); color: #fff; border: none; border-radius: 12px; font-size: 1rem; font-weight: 700; cursor: pointer; transition: background .15s; }
.btn-primary:hover { background: var(--naranja-dark); }
.btn-guardar-final { flex: 1; padding: 15px; background: var(--verde); color: #fff; border: none; border-radius: 12px; font-size: 1rem; font-weight: 700; cursor: pointer; box-shadow: 0 4px 12px rgba(58,125,68,.3); transition: background .15s, transform .1s; }
.btn-guardar-final:hover { background: var(--verde-dark); }
.btn-guardar-final:active { transform: scale(.98); }
.btn-guardar-final:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

/* ── SPINNER ── */
.spinner { display: inline-block; width: 18px; height: 18px; border: 3px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ══ INSTALACIÓN — STOCK LIST ══ */
.inst-buscar { width: 100%; padding: 11px 14px; border: 2px solid var(--borde); border-radius: 10px; font-size: 1rem; -webkit-appearance: none; margin-bottom: 10px; }
.inst-buscar:focus { outline: none; border-color: var(--naranja); }
.stock-lista { display: flex; flex-direction: column; gap: 8px; }

/* Layout VERTICAL: texto arriba, picker abajo — sin solapamiento posible */
.stock-item { display: flex; flex-direction: column; padding: 12px 14px; border: 2px solid var(--borde); border-radius: 12px; background: #fff; transition: border-color .15s, background .15s; }
.stock-item.seleccionado { border-color: var(--naranja); background: #fff8f3; }
.stock-item-ref  { font-size: .7rem; color: #aaa; font-weight: 600; margin-bottom: 2px; }
.stock-item-nom  { font-size: .9rem; font-weight: 700; color: var(--texto); line-height: 1.4; }
.stock-item-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.stock-item-disp { font-size: .78rem; color: var(--subtexto); }

/* Picker compacto en la esquina inferior derecha */
.qty-picker { display: flex; align-items: center; gap: 8px; }
.qty-btn { width: 36px; height: 36px; border: 2px solid var(--borde); border-radius: 8px; background: #fff; font-size: 1.2rem; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .1s; line-height: 1; }
.qty-btn:active { background: var(--gris); }
.qty-btn.plus { border-color: var(--naranja); color: var(--naranja); }
.qty-display { min-width: 28px; text-align: center; font-size: 1.1rem; font-weight: 800; color: var(--texto); cursor: pointer; padding: 2px 6px; border-bottom: 2px dotted var(--borde); }

.stock-empty    { text-align: center; color: #aaa; font-size: .9rem; padding: 32px 0; }
.stock-cargando { text-align: center; color: #aaa; font-size: .9rem; padding: 32px 0; }

/* ── BARRA CARRITO ── */
.carrito-bar { position: fixed; bottom: 0; left: 0; right: 0; background: var(--naranja); color: #fff; padding: 14px 20px; padding-bottom: calc(14px + env(safe-area-inset-bottom,0px)); display: none; align-items: center; justify-content: space-between; gap: 12px; z-index: 200; box-shadow: 0 -4px 16px rgba(0,0,0,.15); }
.carrito-bar.visible { display: flex; }
.carrito-info { font-size: .95rem; font-weight: 700; }
.carrito-info span { font-weight: 400; font-size: .8rem; display: block; opacity: .85; }
.carrito-next { background: #fff; color: var(--naranja-dark); border: none; border-radius: 10px; padding: 10px 18px; font-size: .95rem; font-weight: 800; cursor: pointer; }

/* ── RESUMEN INSTALADO (paso B) ── */
.inst-resumen-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--borde); gap: 8px; }
.inst-resumen-item:last-child { border-bottom: none; }
.inst-resumen-nom { font-size: .88rem; font-weight: 700; flex: 1; }
.inst-resumen-ref { font-size: .72rem; color: #aaa; display: block; }
.inst-resumen-qty { font-size: 1rem; font-weight: 800; color: var(--naranja-dark); white-space: nowrap; }

/* ── TOAST ── */
#toast { position: fixed; bottom: calc(80px + env(safe-area-inset-bottom,0px)); left: 50%; transform: translateX(-50%) translateY(120px); background: #222; color: #fff; padding: 13px 22px; border-radius: 24px; font-size: .95rem; font-weight: 600; box-shadow: 0 4px 20px rgba(0,0,0,.3); transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .3s; opacity: 0; z-index: 999; max-width: 90vw; text-align: center; white-space: pre-line; }
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.ok  { background: var(--verde); }
#toast.err { background: #e53e3e; }

/* ── ÉXITO ── */
#pantalla-exito { display: none; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh; text-align: center; padding: 32px 24px; gap: 12px; }
#pantalla-exito.visible { display: flex; }
.exito-icono  { font-size: 4rem; }
.exito-titulo { font-size: 1.4rem; font-weight: 800; color: var(--verde); }
.exito-sub    { font-size: .9rem; color: var(--subtexto); line-height: 1.5; }
.btn-nuevo    { margin-top: 12px; padding: 14px 32px; background: var(--naranja); color: #fff; border: none; border-radius: 12px; font-size: 1rem; font-weight: 700; cursor: pointer; }
