@font-face { font-family: "Satoshi"; src: url("/assets/fonts/Satoshi-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Satoshi"; src: url("/assets/fonts/Satoshi-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
html[data-theme="dark"] {
  --red: #E31F26; --red-dim: #FF6B6F; --red-soft: rgba(227,31,38,.18);
  --chrome: #1A1A1A; --chrome-2: #222; --chrome-border: #3A3A3A; --chrome-text: #F7F7F7; --chrome-muted: #8A8A8A;
  --bg: #1F1F1F; --surface: #2A2A2A; --surface-2: #303030; --border: #3A3A3A; --border-strong: #4A4A4A;
  --text: #F2F2F2; --muted: #9A9A9A; --ok: #3DCC8A; --ok-soft: rgba(31,166,106,.18); --warn: #F5A524; --warn-soft: rgba(245,165,36,.16);
  --radius: 12px; --tap: 52px; --font: "Satoshi", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { overflow-anchor: auto; scroll-behavior: auto; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 var(--font); -webkit-tap-highlight-color: transparent; min-height: 100dvh; padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
a { color: #ff8a8e; }
[hidden] { display: none !important; }

/* —— cabecera —— */
.top { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 10px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: var(--chrome); border-bottom: 3px solid var(--red); }
.logo { background: none; border: 0; padding: 4px 2px; display: flex; align-items: center; }
.logo img { height: 22px; display: block; }
.top-tit { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; flex: 1; }
.top-tit b { font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--chrome-text); }
.top-tit span { font-size: 12px; color: var(--chrome-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-der { display: flex; align-items: center; gap: 6px; }
.chip { font-size: 12px; padding: 4px 8px; border-radius: 999px; background: var(--chrome-2); border: 1px solid var(--chrome-border); color: var(--chrome-text); white-space: nowrap; }
.chip.ok { border-color: var(--ok); color: var(--ok); }
.chip.mal { border-color: var(--red); color: #fff; background: var(--red-soft); }
.btn-salir { background: transparent; border: 1px solid var(--chrome-border); color: var(--chrome-text); border-radius: 8px; padding: 6px 10px; font-size: 13px; }

main { max-width: 760px; margin: 0 auto; padding: 14px 14px 20px; outline: none; }
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 17px; margin: 18px 0 8px; color: var(--text); }
h3 { font-size: 15px; margin: 12px 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.cab { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cab h1 { margin: 0; flex: 1; }
.volver { background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; padding: 8px 12px; min-height: 42px; }

/* —— tarjetas y botones —— */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 10px 0; }
.card.rojo { border-color: var(--red); background: linear-gradient(0deg, var(--red-soft), var(--red-soft)), var(--surface); }
.card.ok { border-color: var(--ok); }
.card.warn { border-color: var(--warn); background: linear-gradient(0deg, var(--warn-soft), var(--warn-soft)), var(--surface); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 10px 16px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface-2); font-weight: 700; text-align: center; text-decoration: none; color: var(--text); }
.btn.pri { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ok { background: #1c7a50; border-color: #1c7a50; color: #fff; }
.btn.chico { min-height: 40px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn.full { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.cargando { opacity: .7; pointer-events: none; }
.fila { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fila > .btn { flex: 1; }
.grilla { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 6px; min-height: 104px; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); text-align: left; position: relative; }
.tile .ico { font-size: 28px; line-height: 1; }
.tile b { font-size: 16px; }
.tile small { color: var(--muted); font-size: 12.5px; }
.tile .num { position: absolute; top: 10px; right: 12px; min-width: 26px; height: 26px; border-radius: 13px; background: var(--red); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 14px; padding: 0 7px; }
.tile .num.gris { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); }
.tile.ancho { grid-column: span 2; min-height: 72px; flex-direction: row; align-items: center; justify-content: flex-start; gap: 12px; }

/* —— formularios —— */
label.lab { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input[type=text], input[type=number], input[type=search], input[type=datetime-local], input[type=tel], select, textarea { width: 100%; min-height: 48px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: #1a1a1a; color: var(--text); font-size: 16px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--red); outline-offset: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 44px; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface-2); font-size: 14.5px; }
.chips button[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
.chips.g button[data-v="leve"][aria-pressed="true"] { background: #3a3a3a; border-color: #777; }
.chips.g button[data-v="media"][aria-pressed="true"] { background: #b26a00; border-color: #b26a00; }
.foto-box { display: flex; gap: 12px; align-items: center; }
.foto-box img { width: 74px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border-strong); cursor: zoom-in; }
.mic { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.mic .rec { background: var(--red); border-color: var(--red); color: #fff; }

/* —— listas —— */
.lista { list-style: none; margin: 0; padding: 0; }
.item { display: flex; align-items: center; gap: 10px; padding: 12px; border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: 0; }
.item .tx { flex: 1; min-width: 0; }
.item .tx b { display: block; }
.item .tx small { color: var(--muted); display: block; font-size: 13px; }
.item img.mini { width: 46px; height: 74px; object-fit: cover; border-radius: 6px; cursor: zoom-in; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border-strong); vertical-align: middle; }
.badge.rojo { background: var(--red); border-color: var(--red); color: #fff; }
.badge.ok { background: #1c7a50; border-color: #1c7a50; color: #fff; }
.badge.warn { background: #8a5a00; border-color: #b26a00; color: #fff; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin: 0 -2px 8px; scrollbar-width: none; }
.tabs button { flex: 0 0 auto; min-height: 42px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 14.5px; }
.tabs button[aria-selected="true"] { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
.vacio { padding: 18px; text-align: center; color: var(--muted); }

/* —— puntaje —— */
.puntaje { display: flex; align-items: center; gap: 14px; }
.puntaje .n { font-size: 44px; font-weight: 700; line-height: 1; }
.barra { height: 8px; border-radius: 4px; background: #3a3a3a; overflow: hidden; }
.barra > i { display: block; height: 100%; background: var(--ok); }
.comp { display: grid; grid-template-columns: 110px 1fr 40px; gap: 8px; align-items: center; font-size: 13px; margin: 4px 0; }

/* —— PIN —— */
.pin { max-width: 360px; margin: 6vh auto 0; text-align: center; }
.pin h1 { margin-bottom: 4px; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); }
.pin-dots i.on { background: var(--red); border-color: var(--red); }
.teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.teclado button { min-height: 64px; font-size: 26px; font-weight: 700; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); }
.teclado button:active { background: var(--surface-2); }
.pin-err { color: var(--red-dim); min-height: 22px; }

/* —— mapa —— */
.mapa { height: 320px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: #111; }
.mapa.alto { height: 420px; }
.leaflet-container { font: 13px var(--font); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #222; color: #eee; }
.lbl-pt { background: rgba(0,0,0,.65); color: #fff; border: 0; border-radius: 6px; padding: 1px 5px; font-weight: 700; box-shadow: none; }
.lbl-pt::before { display: none; }

/* —— ronda —— */
.ronda-pts { list-style: none; margin: 0; padding: 0; }
.ronda-pts li { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.ronda-pts .dot { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; border: 2px solid var(--border-strong); flex: 0 0 auto; }
.ronda-pts li.ok .dot { background: var(--ok); border-color: var(--ok); color: #0c2b1d; }
.ronda-pts li.cerca .dot { border-color: var(--warn); color: var(--warn); }
.cerca-banner { position: sticky; top: 60px; z-index: 5; }

/* —— SOS —— */
#sos { position: fixed; right: 14px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 60; width: 84px; height: 84px; border-radius: 50%; border: 0; background: #b0141a; color: #fff; box-shadow: 0 6px 22px rgba(0,0,0,.55), 0 0 0 3px rgba(255,255,255,.12); display: flex; flex-direction: column; align-items: center; justify-content: center; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
#sos span { font-weight: 800; font-size: 22px; letter-spacing: .06em; position: relative; }
#sos small { font-size: 9.5px; opacity: .85; position: relative; }
#sos svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
#sos .sos-bg { fill: none; stroke: rgba(255,255,255,.18); stroke-width: 6; }
#sos .sos-arco { fill: none; stroke: #fff; stroke-width: 6; stroke-dasharray: 289; stroke-dashoffset: 289; }
#sos.apretando .sos-arco { transition: stroke-dashoffset 2s linear; stroke-dashoffset: 0; }
#sos.apretando { transform: scale(1.08); background: var(--red); }

/* —— capas (alarmas, escáner, confirmaciones) —— */
#capa { position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.86); display: flex; align-items: center; justify-content: center; padding: 18px; }
.capa-caja { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; padding: 18px; text-align: center; }
.capa-caja h2 { margin-top: 0; font-size: 22px; }
.capa-caja.alarma { border: 3px solid var(--red); animation: lat 1s infinite; }
.capa-caja .cuenta { font-size: 48px; font-weight: 800; margin: 10px 0; }
.capa-caja .btn { width: 100%; margin-top: 10px; min-height: 64px; font-size: 19px; }
@keyframes lat { 0%,100% { box-shadow: 0 0 0 0 rgba(227,31,38,.7); } 50% { box-shadow: 0 0 0 16px rgba(227,31,38,0); } }
.scan { position: fixed; inset: 0; z-index: 2100; background: #000; display: flex; flex-direction: column; }
.scan video { flex: 1; width: 100%; object-fit: cover; }
.scan .marco { position: absolute; left: 50%; top: 45%; width: 64vmin; height: 64vmin; transform: translate(-50%,-50%); border: 3px solid #fff; border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
.scan .scan-top { position: absolute; top: 0; left: 0; right: 0; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; display: flex; gap: 10px; align-items: center; background: rgba(0,0,0,.5); color: #fff; z-index: 2; }
.scan .scan-pie { position: absolute; bottom: 0; left: 0; right: 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); background: rgba(0,0,0,.6); color: #fff; text-align: center; z-index: 2; }

#toast { position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 3000; background: #111; color: #fff; border: 1px solid var(--border-strong); padding: 10px 16px; border-radius: 12px; max-width: 92vw; box-shadow: 0 8px 24px rgba(0,0,0,.5); font-size: 15px; }
#toast.mal { border-color: var(--red); }
#toast.ok { border-color: var(--ok); }

/* —— banda de alertas de gerencia (fija hasta atender) —— */
#banda-alertas { position: sticky; top: 52px; z-index: 40; background: #8f0f14; color: #fff; padding: 8px 12px; border-bottom: 2px solid #ff4d52; animation: parp 1.2s infinite; }
#banda-alertas .al { display: flex; align-items: center; gap: 8px; padding: 4px 0; max-width: 760px; margin: 0 auto; }
#banda-alertas .al .tx { flex: 1; font-size: 14px; }
#banda-alertas .btn { background: #fff; color: #8f0f14; border: 0; min-height: 38px; }
@keyframes parp { 0%,100% { background: #8f0f14; } 50% { background: #c4161d; } }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.t th { color: var(--muted); font-weight: 400; font-size: 12.5px; }
table.t input { min-height: 40px; padding: 6px 8px; font-size: 15px; }
.tl { font-size: 13.5px; }
.tl div { padding: 3px 0; border-bottom: 1px dashed #333; }
.tl .hora { color: var(--muted); display: inline-block; width: 48px; }
.ok-t { color: var(--ok); } .mal-t { color: var(--red-dim); } .warn-t { color: var(--warn); }
.pie-prueba { text-align: center; color: var(--muted); font-size: 12px; margin-top: 24px; }
@media (max-width: 380px) { .grilla { gap: 8px; } .tile { min-height: 96px; padding: 12px; } }
a.tile { text-decoration: none; color: var(--text); }
.ronda-pts .tx b, .ronda-pts .tx small { display: block; } .ronda-pts .tx small { font-size: 13px; margin-top: 2px; }
