:root {
  /* Mismos tokens que EM (app/globals.css, "paleta derivada del logo Muebo") —
     misma personalidad de marca en los dos lados del ecosistema. */
  --azul: #4878b4;
  --azul-claro: #35619b;
  --azul-suave: #e8eef7;
  --rojo: #b3362e;
  --verde: #2e7d4f;
  --gris-fondo: #eaedf2;
  --gris-borde: #dde3ec;
  --texto: #232a33;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--gris-fondo);
  color: var(--texto);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

.oculto { display: none !important; }

/* Feedback táctil visual en todo botón, parejo con la vibración de app.js —
   sutil, para depósito: solo un pequeño achique al tocar, nada animado. */
button {
  transition: transform 0.08s ease, opacity 0.08s ease;
}
button:active {
  transform: scale(0.96);
  opacity: 0.85;
}

.version-info {
  position: fixed;
  right: 8px;
  bottom: 6px;
  font-size: 11px;
  color: rgba(35, 42, 51, 0.35);
  z-index: 1;
  pointer-events: none;
}

.pantalla {
  display: none;
  min-height: 100vh;
  padding: 16px 16px 100px;
}
.pantalla.activa { display: block; }

.logo-img {
  display: block;
  width: 100%;
  max-width: 200px;
  margin: 40px auto 0;
}
.logo-sub {
  text-align: center;
  color: var(--texto);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 6px;
  margin: 8px 0 60px;
}

.badge-pendientes {
  text-align: center;
  background: #fff3cd;
  color: #7a5a00;
  border: 1px solid #ffe08a;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  margin: 24px 8px 0;
}
/* Rechazo de EM: no se arregla solo, alguien tiene que hacer algo. */
.badge-pendientes.badge-rechazo {
  background: #fbe9e7;
  color: #8c2f26;
  border-color: #f0b4ad;
}

.botones-tipo {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 0 8px;
}

.btn-grande {
  font-size: 28px;
  font-weight: 700;
  padding: 40px 0;
  border: none;
  border-radius: 18px;
  color: white;
  letter-spacing: 1px;
}
.btn-salida { background: var(--rojo); }
.btn-entrada { background: var(--verde); }

.link-chico {
  display: block;
  margin: 40px auto 0;
  background: none;
  border: none;
  color: var(--azul-claro);
  font-size: 15px;
  text-align: center;
  width: 100%;
}

.barra-superior {
  position: sticky;
  top: 0;
  background: var(--gris-fondo);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 16px;
  font-size: 20px;
  font-weight: 600;
  z-index: 5;
}
.btn-volver {
  border: none;
  background: white;
  border-radius: 12px;
  width: 44px;
  height: 44px;
  font-size: 20px;
}

.bloque {
  background: var(--azul-suave);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--gris-borde);
}
.bloque h2 {
  margin: 0 0 12px;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666;
}

.grilla-destinos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.btn-destino {
  padding: 18px 8px;
  font-size: 16px;
  font-weight: 600;
  border: 2px solid var(--gris-borde);
  border-radius: 12px;
  background: white;
  color: var(--texto);
}
.btn-destino.seleccionado {
  border-color: var(--azul);
  background: var(--azul);
  color: white;
}

.input-texto {
  width: 100%;
  font-size: 18px;
  padding: 14px;
  border: 2px solid var(--gris-borde);
  border-radius: 12px;
  margin-top: 10px;
}
/* Dentro de la grilla de destinos el input es un ítem más del grid (cae a la
   derecha de "Otro"), no necesita el margen pensado para cuando iba debajo. */
#grilla-destinos .input-texto { margin-top: 0; align-self: center; min-width: 0; }

.fila-fotos {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.miniatura-foto {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--gris-borde);
}
.miniatura-foto img { width: 100%; height: 100%; object-fit: cover; }
.miniatura-foto .quitar-foto {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0,0,0,.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 13px;
  line-height: 1;
}

.btn-foto {
  display: inline-block;
  padding: 14px 20px;
  background: var(--azul);
  color: white;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
}

/* Encabezado + filas comparten las mismas columnas fijas, así la línea
   vertical y la cantidad quedan siempre en el mismo lugar sin importar
   cuán largo sea el código (antes, con flex + space-between de 3 ítems,
   la cantidad se corría hacia el medio si el código era corto). */
.lineas-encabezado {
  display: grid;
  grid-template-columns: 1fr 60px 72px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #888;
  margin-bottom: 4px;
}
.lineas-encabezado span:nth-child(2) { text-align: right; padding-left: 10px; }

.lista-lineas { margin-bottom: 12px; }
.linea-item {
  display: grid;
  grid-template-columns: 1fr 60px 72px;
  align-items: center;
  padding: 12px 10px;
  border-bottom: 1px solid var(--gris-borde);
}
.linea-item:last-child { border-bottom: none; }
.linea-info { display: flex; flex-direction: column; min-width: 0; }
.linea-codigo { font-weight: 700; font-size: 17px; }
.linea-nombre { font-size: 13px; color: #666; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linea-cantidad {
  font-size: 18px;
  font-weight: 700;
  text-align: right;
  padding-left: 10px;
  border-left: 1px solid rgba(35, 42, 51, 0.12);
}
.linea-acciones {
  display: flex;
  gap: 8px;
  justify-self: end;
}
.linea-editar, .linea-borrar {
  border: none;
  background: #eee;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 15px;
}

.btn-agregar {
  width: 100%;
  padding: 20px;
  font-size: 18px;
  font-weight: 700;
  background: var(--azul);
  color: white;
  border: none;
  border-radius: 14px;
}

.btn-flotante {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  padding: 18px;
  font-size: 17px;
  font-weight: 700;
  background: var(--verde);
  color: white;
  border: none;
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
/* Apagado mientras falta algo: sigue en pantalla (dice qué falta) pero se lee
   de un vistazo que todavía no es el paso a dar. */
.btn-flotante:disabled {
  background: #aab3c0;
  box-shadow: none;
}

.overlay {
  position: fixed;
  inset: 0;
  background: black;
  z-index: 50;
  display: flex;
  flex-direction: column;
}
.overlay-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  color: white;
  font-size: 16px;
}
.btn-cerrar {
  background: rgba(255,255,255,.15);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
}
#video-scan {
  width: 100%;
  flex: 1;
  object-fit: cover;
  background: #111;
}
.scan-aviso {
  color: #ffd873;
  text-align: center;
  padding: 10px 16px;
  font-size: 14px;
}
.scan-busqueda {
  background: white;
  padding: 14px;
  max-height: 45vh;
  overflow-y: auto;
}
.resultados-busqueda { margin-top: 8px; }
.resultado-item {
  padding: 14px 10px;
  border-bottom: 1px solid var(--gris-borde);
  font-size: 16px;
}
.resultado-item b { font-size: 17px; }

.modal-cantidad-caja {
  background: white;
  border-radius: 18px;
  padding: 24px;
  width: min(90vw, 380px);
}
#modal-cantidad, #modal-correccion { align-items: center; justify-content: center; background: rgba(0,0,0,.5); }
.modal-codigo { font-size: 20px; font-weight: 700; margin-bottom: 16px; text-align: center; }
.input-cantidad {
  width: 100%;
  font-size: 32px;
  text-align: center;
  padding: 16px;
  border: 2px solid var(--gris-borde);
  border-radius: 12px;
}
.modal-botones { display: flex; gap: 10px; margin-top: 20px; }
.btn-primario, .btn-secundario {
  flex: 1;
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: 12px;
}
.btn-primario { background: var(--azul); color: white; }
.btn-secundario { background: var(--gris-fondo); color: var(--texto); }

.resumen-encabezado {
  background: var(--azul);
  color: white;
  padding: 18px;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}
.resumen-encabezado-cols {
  display: flex;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #888;
  margin-bottom: 6px;
}
.resumen-lineas { background: white; border-radius: 14px; overflow: hidden; margin-bottom: 20px; }
.resumen-linea {
  display: flex;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--gris-borde);
  font-size: 16px;
}
.resumen-linea:last-child { border-bottom: none; }
.resumen-linea .cant { font-weight: 700; }
.btn-guardar { width: 100%; padding: 20px; font-size: 18px; background: var(--verde); }
.resumen-estado { text-align: center; margin-top: 14px; font-size: 15px; color: #555; }

.historial-vacio { text-align: center; color: #666; margin-top: 40px; }

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--gris-borde);
  border-top-color: var(--azul);
  border-radius: 50%;
  margin: 60px auto;
  animation: girar 0.7s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

.historial-separador-dia {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888;
  margin: 20px 4px 8px;
}
.historial-separador-dia:first-child { margin-top: 0; }

.historial-evento {
  background: var(--azul-suave);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
  border: 1px solid var(--gris-borde);
}
.historial-cabecera {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gris-borde);
}
.historial-tipo { font-weight: 700; font-size: 15px; }
.historial-entrada { color: var(--verde); }
.historial-salida { color: var(--rojo); }
.historial-meta { font-size: 13px; color: #666; margin-top: 2px; }
.historial-anular-evento { margin: 0; color: var(--rojo); }

.historial-linea {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 15px;
  gap: 8px;
}
.historial-linea.anulada .historial-linea-codigo,
.historial-linea.anulada .cant {
  text-decoration: line-through;
  color: #999;
}
.historial-linea-codigo { flex: 1; }
.historial-linea-acciones { display: flex; gap: 6px; flex-shrink: 0; }
.historial-btn {
  border: none;
  background: #eee;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 14px;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  top: 16px;
  background: var(--texto);
  color: white;
  padding: 14px 18px;
  border-radius: 12px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
#toast-texto { flex: 1; }
.toast-accion {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #9cc2f0;
  font-weight: 700;
  font-size: 15px;
}
