:root {
  --bg: #f3f5f8; --card: #fff; --text: #17202b; --muted: #627083; --line: #e2e7ee;
  --brand: #0b5cad; --brand-2: #0a8f8f; --ok: #1d8a4e; --warn: #b7791f; --bad: #c0392b;
  --radius: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
header { background: linear-gradient(120deg, var(--brand), var(--brand-2)); color: #fff; padding: 14px 16px; position: sticky; top: 0; z-index: 5; }
header h1 { margin: 0; font-size: 18px; letter-spacing: .2px; }
header .sub { font-size: 12px; opacity: .85; margin-top: 2px; }
.fila { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.espacio { flex: 1; }
main { padding: 14px 16px 120px; max-width: 760px; margin: 0 auto; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(16,24,40,.06); border: 1px solid var(--line); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.18); }
.chip.gris { background: #eef1f5; color: var(--muted); }
.chip.ok { background: #e3f4ea; color: var(--ok); }
.chip.warn { background: #fdf2dc; color: var(--warn); }
.chip.bad { background: #fbe4e1; color: var(--bad); }
.punto { width: 8px; height: 8px; border-radius: 50%; background: #7CFFB2; }
.punto.off { background: #ffb4a8; }
button, .btn { font: inherit; border: 0; border-radius: 12px; padding: 12px 16px; cursor: pointer; background: #e9eef5; color: var(--text); font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
button.primario, .btn.primario { background: var(--brand); color: #fff; }
button.exito { background: var(--ok); color: #fff; }
button:disabled { opacity: .5; cursor: default; }
select, input { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--text); }
.captura { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); display: flex; gap: 8px; justify-content: center; z-index: 4; }
.captura button { flex: 1; max-width: 360px; padding: 16px; font-size: 16px; box-shadow: 0 6px 20px rgba(11,92,173,.25); }
.lista .item { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lista .item:last-child { border-bottom: 0; }
.sec { width: 30px; height: 30px; border-radius: 50%; background: #eef1f5; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--muted); flex: none; }
.item.leida .sec { background: #e3f4ea; color: var(--ok); }
.item .info { flex: 1; min-width: 0; }
.item .info b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .info span { font-size: 12px; color: var(--muted); }
.modal { position: fixed; inset: 0; background: rgba(10,20,30,.55); z-index: 10; display: none; align-items: flex-end; justify-content: center; }
.modal.abierto { display: flex; }
.hoja { background: var(--bg); width: 100%; max-width: 760px; max-height: 94vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 16px; }
.foto { width: 100%; max-height: 300px; object-fit: contain; border-radius: 12px; background: #111; display: block; }
.lectura-grande { font-size: 40px; font-weight: 800; letter-spacing: 2px; width: 100%; text-align: center; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.alerta { padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-top: 8px; }
.alerta.alta { background: #fbe4e1; color: #8c2a1f; }
.alerta.media { background: #fdf2dc; color: #7a5212; }
.alerta.ok { background: #e3f4ea; color: #145c35; }
.cargando { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 14px 0; }
.spinner { width: 20px; height: 20px; border: 3px solid #cfd8e3; border-top-color: var(--brand); border-radius: 50%; animation: giro .8s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }
.muted { color: var(--muted); font-size: 13px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .v { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--muted); }
.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tabla td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tabla img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.scroll-x { overflow-x: auto; }
.toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); background: #17202b; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 20; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.visible { opacity: 1; }
