:root {
  --azul: #02112f;
  --azul2: #0b2a5b;
  --acento: #3fa9f5;
  --fondo: #f3f5f9;
  --texto: #1b2333;
  --suave: #6b7487;
  --borde: #dfe3ea;
  --verde: #23a55a;
  --rojo: #e03b3b;
  --naranja: #f08c1a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--texto); background: var(--fondo); }
a { color: var(--azul2); }
header.barra { display: flex; align-items: center; gap: 18px; height: 56px; padding: 0 18px; background: var(--azul); color: #fff; }
header.barra img { width: 34px; height: 34px; border-radius: 8px; }
header.barra .marca { font-weight: 700; letter-spacing: .3px; }
header.barra .marca small { display: block; font-weight: 400; font-size: 12px; opacity: .7; }
header.barra nav { display: flex; gap: 4px; margin-left: 12px; }
header.barra nav a { color: #cfe3ff; text-decoration: none; padding: 7px 12px; border-radius: 7px; font-size: 14px; }
header.barra nav a.activo, header.barra nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
header.barra .usuario { margin-left: auto; font-size: 13px; opacity: .85; }
header.barra .usuario a { color: #fff; margin-left: 10px; }
header.barra .usuario .version { font-size: 11px; opacity: .55; margin-right: 12px; }
.manual-entrar { text-align: center; margin: 6px 0 0; }
.version-entrar { text-align: center; opacity: .6; margin-top: 4px; }
main.pagina { max-width: 1000px; margin: 24px auto; padding: 0 16px; }
.tarjeta { background: #fff; border: 1px solid var(--borde); border-radius: 12px; padding: 20px; margin-bottom: 18px; }
h1 { font-size: 22px; margin: 0 0 14px; }
h2 { font-size: 17px; margin: 0 0 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--borde); }
th { color: var(--suave); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
input[type=text], input[type=email], input[type=password], input[type=date] { padding: 9px 11px; border: 1px solid var(--borde); border-radius: 8px; font-size: 15px; }
button, .boton { display: inline-block; padding: 9px 16px; border: 0; border-radius: 8px; background: var(--azul2); color: #fff; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; }
button.secundario, .boton.secundario { background: #e8ecf3; color: var(--texto); }
.formulario-linea { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.etiqueta { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.etiqueta.verde { background: #e3f6ea; color: #17733e; }
.etiqueta.gris { background: #eceff4; color: var(--suave); }
.etiqueta.rojo { background: #fde8e8; color: #b42323; }
.etiqueta.naranja { background: #fff1df; color: #a75b00; }
.error { background: #fde8e8; color: #9d1d1d; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.suave { color: var(--suave); font-size: 13px; }
.exito { background: #e3f6ea; color: #17733e; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
button.peligro { background: var(--rojo); }
input[type=number], select { padding: 9px 11px; border: 1px solid var(--borde); border-radius: 8px; font-size: 15px; }
.cifras { display: flex; gap: 14px; flex-wrap: wrap; }
.cifras div { background: var(--fondo); border-radius: 10px; padding: 10px 16px; }
.cifras b { display: block; font-size: 24px; }
.enlace { font-family: ui-monospace, Menlo, monospace; font-size: 13px; word-break: break-all; background: var(--fondo); padding: 8px; border-radius: 6px; }
td form { display: inline; }
td button { padding: 5px 10px; font-size: 12px; }

/* Entrada */
.entrar { min-height: 100%; display: grid; place-items: center; background: linear-gradient(160deg, var(--azul), var(--azul2)); padding: 16px; }
.entrar .caja { width: 100%; max-width: 360px; background: #fff; border-radius: 16px; padding: 28px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.entrar .caja img { width: 64px; height: 64px; border-radius: 14px; display: block; margin: 0 auto 10px; }
.entrar .caja h1 { text-align: center; margin-bottom: 4px; }
.entrar .caja p.suave { text-align: center; margin: 0 0 18px; }
.entrar label { display: block; font-size: 13px; color: var(--suave); margin: 10px 0 4px; }
.entrar input { width: 100%; }
.entrar button { width: 100%; margin-top: 18px; padding: 11px; }

/* Mapa en vivo */
.vivo { display: flex; height: calc(100% - 56px); }
.vivo aside { width: 320px; background: #fff; border-right: 1px solid var(--borde); overflow-y: auto; display: flex; flex-direction: column; }
.vivo aside h2 { padding: 14px 16px 6px; margin: 0; font-size: 13px; color: var(--suave); text-transform: uppercase; letter-spacing: .4px; }
.vivo #mapa { flex: 1; }
.vehiculo-fila { padding: 11px 16px; border-bottom: 1px solid var(--borde); cursor: pointer; display: grid; grid-template-columns: 12px 1fr auto; gap: 4px 10px; align-items: center; }
.vehiculo-fila:hover { background: #f6f8fb; }
.vehiculo-fila .punto { width: 10px; height: 10px; border-radius: 50%; background: #b9c0cc; }
.vehiculo-fila .punto.movimiento { background: var(--verde); }
.vehiculo-fila .punto.detenido { background: var(--acento); }
.vehiculo-fila .nombre { font-weight: 600; font-size: 14px; }
.vehiculo-fila .vel { font-weight: 700; font-variant-numeric: tabular-nums; }
.vehiculo-fila .vel.exceso { color: var(--rojo); }
.vehiculo-fila .detalle { grid-column: 2 / 4; font-size: 12px; color: var(--suave); }
.vehiculo-fila .bateria { color: #b26a00; font-weight: 600; }
.vehiculo-fila .bateria.baja { color: var(--rojo); }
.vehiculo-fila:has(+ .vehiculo-acordeon) { background: #eef3fb; border-bottom: none; }
.vehiculo-acordeon { background: #f6f8fb; border-bottom: 1px solid var(--borde); max-height: 420px; overflow-y: auto; }
.vehiculo-acordeon .vehiculo-estado { padding: 6px 16px 10px 38px; font-size: 13px; display: grid; gap: 2px; }
.vehiculo-acordeon .vehiculo-estado .suave { font-size: 12px; }
.vehiculo-acordeon .evento-fila { padding-left: 38px; cursor: pointer; background: #fff; }
.vehiculo-acordeon .evento-fila:hover { background: var(--fondo); }
.vehiculo-acordeon .evento-fila.alerta { background: #fdecec; }
.vehiculo-acordeon > p.suave { padding: 4px 16px 12px 38px; margin: 0; font-size: 13px; }
.marcador.elegido { outline: 3px solid #1d2433; outline-offset: 1px; }
#eventos-vivo { border-top: 1px solid var(--borde); margin-top: auto; }
.evento-fila { padding: 9px 16px; font-size: 13px; border-bottom: 1px solid var(--borde); }
.evento-fila b { display: block; }
.evento-fila.golpe, .evento-fila.alerta { background: #fdecec; }
.evento-fila.alerta b { color: var(--rojo); }
.marcador { width: max-content; background: var(--azul2); color: #fff; padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; white-space: nowrap; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.marcador.movimiento { background: var(--verde); }
.marcador.sin-conexion { background: #8a93a3; }
.qr { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; }
.qr svg { width: 260px; height: 260px; background: #fff; }
.codigo { font-family: ui-monospace, Menlo, monospace; font-size: 30px; letter-spacing: 4px; font-weight: 700; }
#recorrido { height: 420px; border-radius: 10px; }
@media (max-width: 700px) {
  .vivo { flex-direction: column-reverse; }
  .vivo aside { width: 100%; height: 45%; }
  header.barra .usuario span { display: none; }
}

/* Llamadas */
.vehiculo-fila button.hablar { grid-column: 2 / 4; justify-self: start; padding: 4px 10px; font-size: 12px; background: #e8ecf3; color: var(--azul2); }
.emergencia { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 2000; background: #fff; border: 3px solid var(--rojo);
  border-radius: 14px; padding: 18px 22px; min-width: 300px; box-shadow: 0 16px 50px rgba(0,0,0,.4); animation: latido 1s infinite; }
.emergencia h2 { color: var(--rojo); margin: 0 0 6px; font-size: 22px; text-transform: none; letter-spacing: 0; padding: 0; }
.emergencia button.contestar { background: var(--verde); font-size: 16px; padding: 11px 20px; }
@keyframes latido { 50% { box-shadow: 0 0 0 10px rgba(224,59,59,.25), 0 16px 50px rgba(0,0,0,.4); } }
#panel-llamada { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 2000; background: var(--azul); color: #fff;
  padding: 12px 16px; border-radius: 12px; display: none; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
#panel-llamada b { display: block; }
#panel-llamada span { display: block; font-size: 12px; opacity: .8; margin: 2px 0 8px; }
#panel-llamada button { background: var(--rojo); }

/* Logo de la empresa y configuración */
header.barra img.logo-empresa { width: auto; height: 36px; max-width: 160px; object-fit: contain; border-radius: 6px; background: #fff; padding: 3px 6px; }
.muestra-logo { min-width: 120px; min-height: 56px; display: grid; place-items: center; background: var(--fondo); border-radius: 8px; padding: 8px 12px; }
.muestra-logo img { max-height: 56px; max-width: 220px; }

/* Protocolos en el mapa */
.evento-fila button.llamar { margin-top: 6px; padding: 5px 10px; font-size: 12px; background: var(--rojo); }
dialog.protocolo { border: 0; border-radius: 14px; padding: 20px; width: min(520px, 92vw); }
dialog.protocolo::backdrop { background: rgba(2, 17, 47, .45); }
.pestanas { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.pestanas button { padding: 6px 10px; font-size: 12px; }
.pestanas button.activo { background: var(--azul2); color: #fff; }
.contacto { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--borde); font-size: 14px; }
.contacto > div { flex: 1; }
.contacto .numero { width: 26px; height: 26px; border-radius: 50%; background: var(--fondo); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.formulario-columna { display: flex; flex-direction: column; gap: 8px; }
.formulario-columna textarea, .formulario-columna input[type=text], .formulario-columna select { width: 100%; }
textarea { padding: 9px 11px; border: 1px solid var(--borde); border-radius: 8px; font-size: 15px; font-family: inherit; resize: vertical; }
input.titulo-situacion { font-size: 18px; font-weight: 700; }
.casillas { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; }
.protocolo-texto { white-space: pre-line; background: var(--fondo); border-radius: 8px; padding: 10px 12px; font-size: 14px; margin-bottom: 8px; }
.vehiculo-evento { font-size: 18px; font-weight: 700; background: #fff1df; color: #7a4300; border-radius: 8px; padding: 8px 12px; margin: 6px 0 10px; }
.contacto .boton { padding: 7px 12px; font-size: 13px; white-space: nowrap; }
.acciones-mapa { padding: 12px 16px 0; }
.acciones-mapa button { width: 100%; }
.abierto-fila { padding: 8px 16px; font-size: 13px; border-bottom: 1px solid var(--borde); background: #fdecec; cursor: pointer; }
.abierto-fila b { display: block; }
.bitacora-mini { font-size: 12px; max-height: 160px; overflow-y: auto; margin: 6px 0; }
.bitacora-mini div { padding: 4px 0; border-bottom: 1px dashed var(--borde); }
tr.fila-enlace { cursor: pointer; }
tr.fila-enlace:hover { background: var(--fondo); }

dialog.dashcam { width: min(760px, 94vw); }
.dashcam-pantalla { position: relative; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 16 / 9; }
.dashcam-pantalla video { width: 100%; height: 100%; object-fit: contain; display: block; }
#dashcam-estado { position: absolute; inset: auto 0 0 0; margin: 0; padding: 10px 14px; color: #fff; background: rgba(0, 0, 0, .55); font-size: 14px; }
.dashcam-opciones { margin-bottom: 10px; }
.segmento { display: inline-flex; border-radius: 8px; overflow: hidden; border: 1px solid var(--borde); }
.segmento button { border-radius: 0; background: #fff; color: var(--azul2); padding: 6px 14px; }
.segmento button.elegido { background: var(--azul2); color: #fff; }
#dashcam-nitida { margin-bottom: 10px; }
.dashcam-pantalla.nitida { outline: 3px solid var(--rojo); }
#dashcam-nitida[hidden] { display: none; }

/* Cercas virtuales */
.cerca-form { padding: 4px 16px 14px; border-bottom: 1px solid var(--borde); }
.cerca-form h2 { padding: 10px 0 0 !important; }
.cerca-form input[type=number] { width: 100%; }
.casilla { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.cerca-vehiculos { display: flex; flex-direction: column; gap: 4px; max-height: 160px; overflow-y: auto; padding-left: 4px; }
.color { width: 26px; height: 26px; border-radius: 50%; background: var(--c); cursor: pointer; position: relative; }
.color input { position: absolute; opacity: 0; }
.color:has(input:checked) { outline: 3px solid var(--azul2); outline-offset: 2px; }
.cerca-fila { padding: 11px 16px; border-bottom: 1px solid var(--borde); cursor: pointer; display: grid; grid-template-columns: 12px 1fr; gap: 2px 10px; align-items: center; }
.cerca-fila:hover { background: var(--fondo); }
.cerca-fila .punto { width: 12px; height: 12px; border-radius: 3px; }
.cerca-fila .detalle { grid-column: 2; font-size: 12px; color: var(--suave); }
.cerca-fila.inactiva { opacity: .5; }
.leaflet-container.dibujando { cursor: crosshair; }
.eventos-dia .evento-fila { cursor: pointer; }
.eventos-dia .evento-fila:hover { background: var(--fondo); }
.eventos-dia .evento-fila.elegida { background: #fdecec; }
.eventos-dia .evento-fila.pasada td:nth-child(2) { font-weight: 700; }
.reproductor { margin-top: 10px; align-items: center; }
.reproductor #rep-barra { flex: 1; min-width: 140px; }
.reproductor #rep-info { min-width: 120px; font-variant-numeric: tabular-nums; }
#eventos-ayuda button { margin-left: 8px; padding: 5px 10px; font-size: 13px; }
.acordeon { border-bottom: 1px solid var(--borde); }
.acordeon > summary { padding: 10px 16px; cursor: pointer; font-weight: 600; font-size: 14px; user-select: none; }
.acordeon > summary:hover { background: var(--fondo); }

/* Dentro de la app YoyoADAS Central: el menú lo pone la app (pestañas de abajo) */
body.en-app header.barra { height: 48px; gap: 12px; padding: 0 14px; }
body.en-app header.barra nav, body.en-app header.barra .usuario { display: none; }

/* Configuración: nivel de cada tipo de evento */
.niveles { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px 28px; }
.niveles-grupo h2 { margin: 12px 0 4px; font-size: 15px; }
.nivel-fila { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--borde); font-size: 14px; }
.nivel-fila select { padding: 4px 6px; font-size: 13px; border-radius: 6px; }
.nivel-fila select.nivel-alerta { background: #fdecec; }
.nivel-fila select.nivel-aviso { background: #fff6dd; }
.tabla-chica { border-collapse: collapse; margin: 6px 0 10px; font-size: 13px; }
.tabla-chica td { padding: 3px 10px 3px 0; border-bottom: 1px solid var(--borde); }
.aviso-vivo { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 2000; background: #fff4f4; border: 1px solid var(--rojo); color: var(--texto); padding: 10px 16px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.18); max-width: 92vw; }
.aviso-vivo a { margin-left: 8px; }
form.caja a.boton.demo { display: block; text-align: center; margin-top: 10px; }
form.caja p.pequeño { font-size: 13px; text-align: center; margin: 14px 0 0; }
.aviso-demo { background: #fff7e6; border-bottom: 1px solid #f3d38b; padding: 6px 16px; font-size: 13px; text-align: center; }
