:root {
  --azul: #0b3c8c;
  --azul-2: #1550b0;
  --azul-claro: #e8eff9;
  --fondo: #f3f6fb;
  --tarjeta: #ffffff;
  --texto: #13233f;
  --texto-2: #4a5873;
  --tenue: #7a869c;
  --borde: #d6deea;
  --ok: #137a3a;      --ok-f: #e3f3e8;
  --mal: #b42318;     --mal-f: #fde9e7;
  --alerta: #a15c00;  --alerta-f: #fff1db;
  --gris: #5b667a;    --gris-f: #edf0f5;
  --sombra: 0 1px 2px rgba(16, 34, 70, .08), 0 2px 8px rgba(16, 34, 70, .06);
  --radio: 14px;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fondo); color: var(--texto); font-size: 16px; line-height: 1.45;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--azul-2); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 20px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
.oculto { display: none !important; }

/* ---------- Barra superior ---------- */
.top {
  position: sticky; top: 0; z-index: 20; background: var(--azul); color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; gap: 10px;
}
.top .atras { background: none; border: 0; color: #fff; padding: 4px; margin-left: -6px; display: flex; }
.top .titulo { flex: 1; min-width: 0; }
.top .titulo b { display: block; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .titulo small { opacity: .8; font-size: 12.5px; }
.marca { width: 30px; height: 30px; border-radius: 8px; background: #fff; color: var(--azul); display: grid; place-items: center; font-weight: 800; }
.demo-banda { background: #fff1db; color: #7a4500; font-size: 13px; padding: 6px 16px; text-align: center; }

main { max-width: 760px; margin: 0 auto; padding: 14px 16px 24px; }

/* ---------- Navegación inferior ---------- */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; background: #fff; border-top: 1px solid var(--borde);
  display: flex; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.nav a { flex: 1; text-decoration: none; color: var(--tenue); font-size: 11.5px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; position: relative; }
.nav a svg { width: 24px; height: 24px; }
.nav a.activo { color: var(--azul); font-weight: 600; }
.nav .punto { position: absolute; top: 2px; right: calc(50% - 18px); background: var(--mal); color: #fff; border-radius: 9px; font-size: 10.5px; min-width: 17px; padding: 0 4px; text-align: center; }

/* ---------- Tarjetas y elementos ---------- */
.tarjeta { background: var(--tarjeta); border-radius: var(--radio); box-shadow: var(--sombra); padding: 14px; margin-bottom: 12px; }
.tarjeta > h2, .tarjeta > h3 { margin-bottom: 10px; }
.seccion-titulo { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--texto-2); margin: 18px 2px 8px; font-weight: 700; }
.fila { display: flex; gap: 10px; align-items: center; }
.fila.entre { justify-content: space-between; }
.crece { flex: 1; min-width: 0; }
.tenue { color: var(--tenue); font-size: 13.5px; }
.chico { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }
.lista-datos { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14.5px; }
.lista-datos dt { color: var(--tenue); }
.lista-datos dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px;
  padding: 13px 18px; font-weight: 600; background: var(--azul); color: #fff; cursor: pointer; min-height: 48px; text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; }
.btn.sec { background: var(--azul-claro); color: var(--azul); }
.btn.borde { background: #fff; color: var(--azul); border: 1.5px solid var(--borde); }
.btn.peligro { background: var(--mal); }
.btn.ok { background: var(--ok); }
.btn.bloque { width: 100%; }
.btn.chico { min-height: 38px; padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn svg { width: 20px; height: 20px; }

label.etq { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 6px; }
.campo { width: 100%; padding: 12px; border: 1.5px solid var(--borde); border-radius: 10px; background: #fff; font-size: 16px; }
.campo:focus { outline: 2px solid var(--azul-2); outline-offset: 0; border-color: transparent; }
textarea.campo { min-height: 70px; resize: vertical; }

.buscador { display: flex; gap: 8px; }
.buscador .campo { font-size: 20px; font-weight: 600; letter-spacing: .02em; }

/* ---------- Chips de estado (siempre con ícono + texto) ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px 3px 7px; border-radius: 99px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.chip svg { width: 14px; height: 14px; }
.chip.ok { background: var(--ok-f); color: var(--ok); }
.chip.mal { background: var(--mal-f); color: var(--mal); }
.chip.alerta { background: var(--alerta-f); color: var(--alerta); }
.chip.gris { background: var(--gris-f); color: var(--gris); }
.chip.azul { background: var(--azul-claro); color: var(--azul); }

.aviso { border-radius: 12px; padding: 12px 14px; font-size: 14.5px; margin-bottom: 12px; display: flex; gap: 10px; }
.aviso svg { flex: none; width: 22px; height: 22px; margin-top: 1px; }
.aviso.alerta { background: var(--alerta-f); color: #6e3f00; }
.aviso.mal { background: var(--mal-f); color: #7a160f; }
.aviso.ok { background: var(--ok-f); color: #0c4f26; }
.aviso.info { background: var(--azul-claro); color: #0b2d66; }

/* ---------- Semáforo grande ---------- */
.semaforo { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.luz { border-radius: 12px; padding: 10px 8px; text-align: center; font-size: 12.5px; font-weight: 600; }
.luz svg { width: 26px; height: 26px; display: block; margin: 0 auto 4px; }
.luz small { display: block; font-weight: 500; opacity: .85; }
.luz.ok { background: var(--ok-f); color: var(--ok); }
.luz.mal { background: var(--mal-f); color: var(--mal); }
.luz.alerta { background: var(--alerta-f); color: var(--alerta); }
.luz.gris { background: var(--gris-f); color: var(--gris); }
.luz.azul { background: var(--azul-claro); color: var(--azul); }
.veredicto { margin-top: 10px; border-radius: 12px; padding: 12px; font-weight: 700; text-align: center; }

/* ---------- Lista de OT ---------- */
.filtros { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.filtros::-webkit-scrollbar { display: none; }
.filtros button { flex: none; border: 1.5px solid var(--borde); background: #fff; border-radius: 99px; padding: 7px 13px; font-size: 14px; font-weight: 600; color: var(--texto-2); }
.filtros button.activo { background: var(--azul); border-color: var(--azul); color: #fff; }
.ot-item { display: block; text-decoration: none; color: inherit; background: #fff; border-radius: 12px; box-shadow: var(--sombra); padding: 12px 14px; margin-bottom: 8px; }
.ot-item .cab { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ot-item .nro { font-weight: 700; font-size: 16px; }
.ot-item .placa { font-weight: 700; background: var(--azul-claro); color: var(--azul); border-radius: 6px; padding: 1px 7px; font-size: 13.5px; }
.ot-item .sub { font-size: 13.5px; color: var(--texto-2); margin: 3px 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Inicio ---------- */
.accesos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.acceso { background: #fff; border-radius: var(--radio); box-shadow: var(--sombra); padding: 14px; text-decoration: none; color: var(--texto); display: flex; flex-direction: column; gap: 8px; min-height: 104px; position: relative; }
.acceso svg { width: 28px; height: 28px; color: var(--azul); }
.acceso b { font-size: 15px; }
.acceso span { font-size: 12.5px; color: var(--tenue); }
.acceso .punto { position: absolute; top: 10px; right: 10px; background: var(--mal); color: #fff; border-radius: 99px; font-size: 12px; padding: 1px 8px; font-weight: 700; }

/* ---------- Hojas ---------- */
.hoja-op { display: flex; gap: 14px; align-items: center; background: #fff; border: 2px solid transparent; border-radius: var(--radio); box-shadow: var(--sombra); padding: 16px; margin-bottom: 10px; width: 100%; text-align: left; cursor: pointer; }
.hoja-op:active { border-color: var(--azul-2); }
.hoja-op .ico { width: 52px; height: 52px; border-radius: 12px; background: var(--azul-claro); color: var(--azul); display: grid; place-items: center; flex: none; }
.hoja-op .ico svg { width: 30px; height: 30px; }
.hoja-op b { font-size: 17px; display: block; }

/* ---------- Formulario de inspección ---------- */
.progreso { position: sticky; top: var(--alto-top, 56px); z-index: 15; background: var(--fondo); padding: 8px 0 10px; margin: -4px 0 6px; }
.progreso .barra { height: 8px; background: var(--borde); border-radius: 99px; overflow: hidden; }
.progreso .barra i { display: block; height: 100%; background: var(--azul-2); border-radius: 99px; transition: width .25s; }
.progreso .fila { font-size: 13px; color: var(--texto-2); margin-top: 5px; }
.punto-c { background: #fff; border-radius: var(--radio); box-shadow: var(--sombra); padding: 14px; margin-bottom: 10px; border-left: 5px solid transparent; }
.punto-c.r-si { border-left-color: var(--ok); }
.punto-c.r-no { border-left-color: var(--mal); background: #fffafa; }
.punto-c.r-na { border-left-color: var(--gris); }
.punto-c .enc { display: flex; gap: 10px; }
.punto-c .num { flex: none; width: 30px; height: 30px; border-radius: 9px; background: var(--azul-claro); color: var(--azul); font-weight: 800; display: grid; place-items: center; font-size: 14px; }
.punto-c .txt { font-size: 15.5px; font-weight: 500; }
.punto-c .estrella { color: #c27c00; font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; gap: 3px; margin-top: 2px; }
.punto-c .ayuda { font-size: 13px; color: var(--tenue); margin-top: 4px; }
.sino { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 12px; }
.sino.dos { grid-template-columns: 1fr 1fr; }
.sino button { min-height: 50px; border-radius: 11px; border: 2px solid var(--borde); background: #fff; font-weight: 700; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.sino button svg { width: 20px; height: 20px; }
.sino button.sel-si { background: var(--ok); border-color: var(--ok); color: #fff; }
.sino button.sel-no { background: var(--mal); border-color: var(--mal); color: #fff; }
.sino button.sel-na { background: var(--gris); border-color: var(--gris); color: #fff; }
.extra { margin-top: 10px; }
.extra .campo { padding: 10px; }

.cond { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--fondo); }
.cond:last-child { border-bottom: 0; }
.cond span { flex: 1; font-size: 15px; }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; background: var(--borde); border-radius: 99px; transition: .2s; }
.switch i::after { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 2px #0003; }
.switch input:checked + i { background: var(--azul-2); }
.switch input:checked + i::after { transform: translateX(22px); }
.switch input:focus-visible + i { outline: 2px solid var(--azul); outline-offset: 2px; }

.personas { display: flex; flex-wrap: wrap; gap: 8px; }
.personas button { border: 1.5px solid var(--borde); background: #fff; border-radius: 99px; padding: 8px 14px; font-size: 14.5px; font-weight: 600; color: var(--texto-2); }
.personas button.sel { background: var(--azul); border-color: var(--azul); color: #fff; }
.personas button:disabled { opacity: .45; text-decoration: line-through; }

.fotos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.foto { position: relative; width: 84px; height: 84px; border-radius: 10px; overflow: hidden; background: var(--gris-f); }
.foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto .estado { position: absolute; left: 4px; bottom: 4px; background: #000a; color: #fff; font-size: 11px; border-radius: 6px; padding: 1px 6px; }
.foto .quitar { position: absolute; top: 3px; right: 3px; width: 26px; height: 26px; border-radius: 50%; background: #000a; color: #fff; border: 0; display: grid; place-items: center; }
.btn-foto { width: 84px; height: 84px; border-radius: 10px; border: 2px dashed var(--azul-2); background: var(--azul-claro); color: var(--azul); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 700; cursor: pointer; }
.btn-foto svg { width: 26px; height: 26px; }
.btn-foto input { display: none; }

.pie-fijo { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: #fff; border-top: 1px solid var(--borde); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
.pie-fijo .in { max-width: 760px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
body.con-pie .nav { display: none; }

/* ---------- Reporte ---------- */
.res-grande { border-radius: var(--radio); padding: 18px; text-align: center; color: #fff; margin-bottom: 12px; }
.res-grande.ok { background: var(--ok); } .res-grande.mal { background: var(--mal); }
.res-grande b { font-size: 26px; letter-spacing: .04em; display: block; }
.rep-punto { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--fondo); font-size: 14.5px; }
.rep-punto:last-child { border-bottom: 0; }
.rep-punto .r { flex: none; width: 46px; text-align: center; font-weight: 800; font-size: 12.5px; border-radius: 7px; padding: 3px 0; height: fit-content; }
.rep-punto .r.si { background: var(--ok-f); color: var(--ok); }
.rep-punto .r.no { background: var(--mal-f); color: var(--mal); }
.rep-punto .r.na { background: var(--gris-f); color: var(--gris); }
.galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.galeria a { display: block; border-radius: 10px; overflow: hidden; aspect-ratio: 4/3; background: var(--gris-f); }
.galeria img { width: 100%; height: 100%; object-fit: cover; }
.visor { position: fixed; inset: 0; background: #000e; z-index: 50; display: grid; place-items: center; padding: 16px; }
.visor img { max-width: 100%; max-height: 100%; border-radius: 6px; }

/* ---------- Panel ---------- */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.kpi { background: #fff; border-radius: var(--radio); box-shadow: var(--sombra); padding: 14px; }
.kpi .v { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; margin: 4px 0; }
.kpi .n { font-size: 13px; color: var(--texto-2); font-weight: 600; }
.kpi .m { font-size: 12.5px; color: var(--tenue); }
.kpi .estado { margin-top: 6px; }
.rango { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.rango-fechas { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.barras { display: flex; flex-direction: column; gap: 9px; }
.barra-f .et { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; margin-bottom: 3px; }
.barra-f .et span:first-child { min-width: 0; }
.barra-f .et b { font-variant-numeric: tabular-nums; }
.barra-f .pista { height: 10px; background: var(--fondo); border-radius: 0 4px 4px 0; }
.barra-f .pista i { display: block; height: 100%; background: var(--azul-2); border-radius: 0 4px 4px 0; min-width: 2px; }
.barra-f .pista i.mal { background: var(--mal); }
.columnas { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding-top: 18px; }
.columnas .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 12px; color: var(--texto-2); }
.columnas .col i { width: 100%; max-width: 34px; background: var(--azul-2); border-radius: 4px 4px 0 0; min-height: 2px; }
.columnas .col b { font-size: 12px; color: var(--texto); margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.columnas .col span { margin-top: 4px; }
.tabla-wrap { overflow-x: auto; margin: 0 -14px; padding: 0 14px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; color: var(--tenue); font-weight: 600; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--borde); white-space: nowrap; }
table.t td:first-child { white-space: nowrap; }
table.t td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--fondo); vertical-align: top; }
table.t td.num, table.t th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Usuarios ---------- */
.usuario { display: flex; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--fondo); }
.usuario:last-child { border-bottom: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--azul-claro); color: var(--azul); display: grid; place-items: center; font-weight: 800; flex: none; }

/* ---------- Ventana modal y mensajes ---------- */
.modal-fondo { position: fixed; inset: 0; background: #0b1a3366; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 90vh; overflow: auto; }
@media (min-width: 600px) { .modal-fondo { align-items: center; } .modal { border-radius: 18px; } }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); background: #13233f; color: #fff; padding: 11px 16px; border-radius: 12px; z-index: 60; font-size: 14.5px; max-width: calc(100% - 32px); white-space: pre-line; box-shadow: 0 4px 16px #0004; }
.toast.mal { background: var(--mal); }
.cargando { display: grid; place-items: center; padding: 40px 0; color: var(--tenue); }
.giro { width: 30px; height: 30px; border: 3px solid var(--borde); border-top-color: var(--azul-2); border-radius: 50%; animation: giro .8s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }
.vacio { text-align: center; color: var(--tenue); padding: 30px 10px; }

/* ---------- Ingreso ---------- */
.ingreso { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px 16px; max-width: 420px; margin: 0 auto; }
.ingreso .logo { width: 64px; height: 64px; border-radius: 16px; background: var(--azul); color: #fff; display: grid; place-items: center; margin: 0 auto 12px; }
.ingreso .logo svg { width: 36px; height: 36px; }
.ingreso h1 { text-align: center; color: var(--azul); font-size: 24px; }
.ingreso .lema { text-align: center; color: var(--texto-2); margin: 4px 0 20px; }
body.sin-nav { padding-bottom: 0; }

@media print {
  .top, .nav, .pie-fijo, .no-imprimir { display: none !important; }
  body { background: #fff; padding: 0; }
  .tarjeta { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}

.chip.empresa { font-size: 11.5px; padding: 1px 8px; vertical-align: 2px; }
