* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Manrope, system-ui, sans-serif; background: var(--marino); color: #fff;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
button, input, select { font: inherit; }
[hidden] { display: none !important; }

.pantalla { min-height: 100dvh; display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }

/* Entrar */
.entrar { padding: calc(env(safe-area-inset-top) + 40px) 20px 32px; max-width: 440px; margin: 0 auto; }
.entrar .logo { width: 130px; margin-bottom: 28px; }
.entrar h1 { font-family: Newsreader, Georgia, serif; font-weight: 500; font-size: 32px; margin: 0 0 24px; }
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 16px; }
label input, label select {
  display: block; width: 100%; margin-top: 6px; padding: 14px; border-radius: 12px; border: 1.5px solid var(--arena);
  font-size: 17px; background: #fff; color: var(--tinta);
}
.error { color: #FFB4AB; min-height: 1.2em; font-weight: 600; }

.primario, .secundario, .peligro {
  border: 0; border-radius: 999px; padding: 14px 20px; font-weight: 700; font-size: 16px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
}
.primario { background: #fff; color: var(--marino); width: 100%; }
.secundario { background: rgba(255,255,255,.12); color: #fff; }
.peligro { background: var(--rojo-fondo); color: var(--rojo); }
.ancho { width: 100%; margin-top: 10px; }

/* Escanear */
.barra { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; gap: 12px; }
.barra .evento { margin: 0; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70vw; }
.barra .conteo { margin: 2px 0 0; color: var(--arena); font-size: 14px; }
.barra .conteo strong { color: #fff; font-size: 18px; }
.icono { background: rgba(255,255,255,.12); border: 0; color: #fff; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; }

.camara { position: relative; flex: 1; margin: 0 16px; border-radius: 24px; overflow: hidden; background: #000; min-height: 0; }
.camara video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.marco {
  position: absolute; left: 50%; top: 50%; width: min(64vw, 300px); aspect-ratio: 1; transform: translate(-50%, -50%);
  border-radius: 24px; box-shadow: 0 0 0 100vmax rgba(6, 39, 82, .45); outline: 3px solid rgba(255,255,255,.9);
}
.camara-aviso { position: absolute; inset: auto 16px 16px; margin: 0; background: rgba(0,0,0,.7); padding: 12px; border-radius: 12px; font-size: 14px; text-align: center; }

.estado-red { text-align: center; font-size: 13px; color: var(--arena); padding: 10px 16px 0; min-height: 28px; }
.estado-red.sin-red { color: #FFD48A; font-weight: 700; }

.acciones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px 16px calc(16px + env(safe-area-inset-bottom)); }

/* Resultado: ocupa toda la pantalla y se lee de lejos */
.resultado { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; background: rgba(0,0,0,.35); }
.resultado .tarjeta {
  width: 100%; background: #fff; color: var(--tinta); border-radius: 28px 28px 0 0; border-top: 14px solid var(--verde);
  padding: 24px 20px calc(20px + env(safe-area-inset-bottom)); max-height: 92dvh; overflow: auto;
}
.resultado.ok .tarjeta { border-top-color: var(--verde); }
.resultado.alerta .tarjeta { border-top-color: var(--ambar); }
.resultado.mal .tarjeta { border-top-color: var(--rojo); }
.resultado-titulo { font-size: 13px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; margin: 0 0 6px; }
.resultado.ok .resultado-titulo { color: var(--verde); }
.resultado.alerta .resultado-titulo { color: var(--ambar); }
.resultado.mal .resultado-titulo { color: var(--rojo); }
.resultado h2 { font-family: Newsreader, Georgia, serif; font-weight: 500; font-size: 34px; line-height: 1.1; margin: 0; color: var(--marino); }
.detalle { color: var(--gris); margin: 8px 0 0; font-size: 16px; }
.grupo { list-style: none; padding: 0; margin: 16px 0 0; }
.grupo li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--arena-clara); }
.grupo .ya { color: var(--verde); font-weight: 700; font-size: 14px; }
.grupo button { border: 1.5px solid var(--marino); background: #fff; color: var(--marino); border-radius: 999px; padding: 8px 14px; font-weight: 700; }
.botones { display: flex; gap: 10px; margin-top: 20px; }
.botones .primario { background: var(--marino); color: #fff; }
.botones .secundario { background: var(--arena-clara); color: var(--tinta); flex: 1; }

/* Hojas (buscar, sin registro, menú) */
.hoja { position: fixed; inset: 0; z-index: 10; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; }
.hoja-cuerpo {
  width: 100%; background: #fff; color: var(--tinta); border-radius: 24px 24px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  max-height: 92dvh; overflow: auto;
}
.hoja header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.hoja h2 { font-family: Newsreader, Georgia, serif; font-weight: 500; font-size: 24px; margin: 0; color: var(--marino); }
.cerrar { border: 0; background: var(--arena-clara); width: 40px; height: 40px; border-radius: 50%; font-size: 24px; line-height: 1; color: var(--tinta); }
.hoja input[type=search] { width: 100%; padding: 14px; border-radius: 12px; border: 1.5px solid var(--arena); font-size: 17px; }
.hoja label { color: var(--tinta); }
.hoja .primario { background: var(--marino); color: #fff; margin-top: 4px; }
.hoja .secundario { background: var(--arena-clara); color: var(--tinta); }
.info { color: var(--gris); font-size: 14px; line-height: 1.5; }
.lista { list-style: none; padding: 0; margin: 8px 0 0; }
.lista li { padding: 12px 4px; border-bottom: 1px solid var(--arena-clara); display: flex; justify-content: space-between; gap: 12px; align-items: center; cursor: pointer; }
.lista .nombre { font-weight: 700; }
.lista .sub { color: var(--gris); font-size: 13px; }
.lista .marca-ok { color: var(--verde); font-weight: 700; font-size: 13px; white-space: nowrap; }
.lista .marca-baja { color: var(--cobre); font-weight: 700; font-size: 13px; white-space: nowrap; }

.aviso {
  position: fixed; left: 16px; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 30;
  background: var(--tinta); color: #fff; border-radius: 14px; padding: 14px 16px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
