/* Comodoro Responde — hoja propia, sin CDN, para que la app abra sin conexión. */
:root {
  --ink: #1c1917;
  --ink-2: #44403c;
  --ink-3: #78716c;
  --line: #e7e5e4;
  --paper: #faf9f7;
  --card: #ffffff;
  --soft: #f5f5f4;
  --red: #c81e1e;
  --red-dark: #9b1515;
  --red-soft: #fdecec;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --ok: #2e7d32;
  --ok-soft: #e7f3e8;
  --off: #57534e;
  --off-soft: #e7e5e4;
  --radius: 14px;
  --nav-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.45;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 1.1em; height: 1.1em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 3px solid #f59e0b; outline-offset: 2px; }

/* ---------- Aviso superior ---------- */
.aviso {
  background: var(--amber-soft);
  color: #78350f;
  font-size: 12px;
  padding: 7px 16px;
  text-align: center;
  border-bottom: 1px solid #fcd34d;
}
.aviso strong { font-weight: 700; }

/* ---------- Cabecera ---------- */
.top {
  position: sticky; top: 0; z-index: 30;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.top-in {
  max-width: 1120px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
}
.marca { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; text-align: left; }
.marca-ico {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--red); color: #fff;
  display: grid; place-items: center;
}
.marca-ico svg { width: 22px; height: 22px; }
.marca b { display: block; font-size: 15px; letter-spacing: .02em; }
.marca small { display: block; font-size: 11px; color: var(--ink-3); }
.top-der { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pill {
  font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px;
  background: var(--soft); color: var(--ink-2); white-space: nowrap;
}
.pill.off { background: var(--amber-soft); color: #78350f; }
.btn-instalar {
  border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  font-size: 12px; font-weight: 700; padding: 7px 10px;
}
.llamar-top {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--red); color: #fff; text-decoration: none;
  font-weight: 800; font-size: 14px; padding: 9px 14px; border-radius: 11px;
}

/* ---------- Navegación: abajo en móvil, arriba en escritorio ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
}
.nav button {
  background: none; border: 0; color: var(--ink-3);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600; min-height: 48px;
}
.nav button svg { width: 22px; height: 22px; }
.nav button[aria-current="page"] { color: var(--red); box-shadow: inset 0 3px 0 var(--red); background: var(--red-soft); }
.nav button[data-tab="sos"] { color: var(--red); font-weight: 800; }

@media (min-width: 860px) {
  body { padding-bottom: 0; }
  .nav {
    position: static; height: auto; padding: 0 16px; border-top: 0;
    max-width: 1120px; margin: 0 auto; display: flex; gap: 4px;
  }
  .nav button {
    flex-direction: row; font-size: 14px; gap: 7px;
    padding: 10px 14px; border-bottom: 3px solid transparent; border-radius: 0;
  }
  .nav button svg { width: 18px; height: 18px; }
  .nav button[aria-current="page"] { border-bottom-color: var(--red); color: var(--ink); box-shadow: none; background: none; }
  .nav button[data-tab="sos"][aria-current="page"] { color: var(--red); }
}

/* ---------- Estructura ---------- */
main { max-width: 1120px; margin: 0 auto; padding: 16px; }
.vista { display: grid; gap: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.card h2 { font-size: 20px; font-weight: 800; }
.card h3 { font-size: 16px; font-weight: 800; }
.sub { color: var(--ink-3); font-size: 13px; margin-top: 4px; }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--red); }
.grid-2 { display: grid; gap: 16px; }
@media (min-width: 860px) {
  .grid-2 { grid-template-columns: 7fr 5fr; align-items: start; }
  .grid-2.par { grid-template-columns: 1fr 1fr; }
}

/* ---------- SOS ---------- */
.sos-head h2 { font-size: 22px; }
.llamadas { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; margin-top: 14px; }
.llamar {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  text-decoration: none; border-radius: 14px; padding: 16px 12px;
  font-weight: 900; font-size: 22px; min-height: 68px;
}
.llamar svg { width: 26px; height: 26px; }
.llamar.l107 { background: var(--red); color: #fff; }
.llamar.l107:active { background: var(--red-dark); }
.llamar.l911 { background: var(--ink); color: #fff; font-size: 20px; }
.llamar small { display: block; font-size: 11px; font-weight: 600; opacity: .85; }
.nota-llamada { font-size: 12px; color: var(--ink-2); margin-top: 8px; }

.pasos { display: grid; gap: 8px; margin-top: 14px; counter-reset: paso; }
.paso {
  display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start;
  padding: 10px 12px; background: var(--soft); border-radius: 12px; font-size: 14px;
}
.paso::before {
  counter-increment: paso; content: counter(paso);
  width: 26px; height: 26px; border-radius: 8px; background: var(--red); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
}
.paso b { display: block; }
.paso span { color: var(--ink-2); font-size: 13px; }

/* Metrónomo */
.metro { background: var(--ink); color: #fafaf9; border-color: var(--ink); }
.metro .sub { color: #a8a29e; }
.metro-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.metro-top .eyebrow { color: #fca5a5; }
.tag-guia { font-size: 11px; background: #292524; color: #d6d3d1; padding: 4px 8px; border-radius: 8px; }
.pulso-wrap { display: grid; place-items: center; padding: 18px 0 8px; }
.pulso {
  width: 168px; height: 168px; border-radius: 50%;
  border: 5px solid rgba(239, 68, 68, .45); background: #292524;
  display: grid; place-items: center; text-align: center;
  transition: transform 90ms ease-out, background-color 90ms ease-out;
}
.pulso.latido { transform: scale(.9); background: var(--red); }
.pulso b { font-size: 46px; font-weight: 900; display: block; line-height: 1; }
.pulso small { font-size: 12px; color: #d6d3d1; font-weight: 700; }
.metro-datos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.dato { background: #292524; border-radius: 10px; padding: 8px 10px; text-align: center; }
.dato b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.dato span { font-size: 11px; color: #a8a29e; }
.rango { display: grid; gap: 4px; margin: 8px 0 12px; }
.rango-et { display: flex; justify-content: space-between; font-size: 11px; color: #a8a29e; }
input[type=range] { width: 100%; accent-color: #ef4444; height: 32px; }
.btn-metro {
  width: 100%; border: 0; border-radius: 12px; padding: 15px; min-height: 54px;
  background: var(--red); color: #fff; font-weight: 800; font-size: 16px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-metro.activo { background: #44403c; }
.btn-sec-osc {
  width: 100%; border: 0; border-radius: 10px; padding: 10px; margin-top: 8px;
  background: #292524; color: #d6d3d1; font-size: 13px; font-weight: 600;
}
.relevo {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  background: #fef3c7; color: #78350f; font-size: 13px; font-weight: 700;
}
.metro-nota { font-size: 12px; color: #a8a29e; margin-top: 10px; }
.metro-nota b { color: #e7e5e4; }

/* Alerta comunitaria */
.campo { display: grid; gap: 5px; }
.campo label, .campo .et { font-size: 12px; font-weight: 700; color: var(--ink-2); }
select, input[type=text], textarea {
  width: 100%; border: 1px solid #d6d3d1; border-radius: 10px;
  padding: 10px 12px; background: #fff; font-size: 15px; min-height: 44px;
}
textarea { min-height: 70px; resize: vertical; }
.btn {
  border: 0; border-radius: 11px; padding: 12px 16px; min-height: 46px;
  font-weight: 800; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-rojo { background: var(--red); color: #fff; }
.btn-negro { background: var(--ink); color: #fff; }
.btn-claro { background: var(--soft); color: var(--ink); border: 1px solid var(--line); }
.btn-ancho { width: 100%; }
.btn-chico { min-height: 36px; padding: 8px 12px; font-size: 12px; }
.fila { display: flex; flex-wrap: wrap; gap: 8px; }

.alerta-activa {
  margin-top: 14px; border: 2px solid #fca5a5; background: var(--red-soft);
  border-radius: 12px; padding: 14px; display: grid; gap: 10px;
}
.alerta-cab { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 800; color: var(--red-dark); font-size: 14px; }
.punto { width: 10px; height: 10px; border-radius: 50%; background: var(--red); display: inline-block; margin-right: 6px; animation: titila 1.2s infinite; }
@keyframes titila { 50% { opacity: .25; } }
.alerta-datos { background: #fff; border-radius: 10px; padding: 12px; display: grid; gap: 8px; font-size: 13px; }
.alerta-datos .k { color: var(--ink-3); font-size: 12px; }
.alerta-datos .v { font-weight: 700; }
.sin-dea { background: var(--amber-soft); color: #78350f; border-radius: 10px; padding: 10px 12px; font-size: 13px; font-weight: 600; }
.estado {
  display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800;
  background: var(--amber-soft); color: #78350f;
}
.estado.e1 { background: #ede9fe; color: #4c1d95; }
.estado.e2 { background: #e0e7ff; color: #312e81; }
.estado.e3 { background: var(--ok-soft); color: #1b5e20; }
.recordatorio { font-size: 12px; color: var(--red-dark); font-weight: 700; }

/* ---------- Mapa ---------- */
.filtros { display: grid; gap: 8px; margin-top: 12px; }
@media (min-width: 600px) { .filtros { grid-template-columns: 1fr 1fr; } }
.mapa {
  position: relative; width: 100%; aspect-ratio: 3 / 2;
  background: #f0eeeb; border-radius: 12px; overflow: hidden; border: 1px solid var(--line);
}
.mapa svg.fondo { position: absolute; inset: 0; width: 100%; height: 100%; }
.pin {
  position: absolute; transform: translate(-50%, -50%);
  width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.35); color: #fff;
  display: grid; place-items: center; padding: 0;
}
.pin svg { width: 15px; height: 15px; }
@media (max-width: 599px) { .pin { width: 24px; height: 24px; border-width: 2px; } .pin svg { width: 12px; height: 12px; } }
.pin.verified { background: var(--ok); }
.pin.unconfirmed { background: #d97706; }
.pin.unavailable { background: #78716c; }
.pin.sel { outline: 3px solid var(--red); outline-offset: 2px; z-index: 2; }
.leyenda { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--ink-2); margin-top: 10px; }
.leyenda i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; margin-right: 5px; vertical-align: -1px; }
.mapa-nota { font-size: 11px; color: var(--ink-3); margin-top: 6px; }

.lista { display: grid; gap: 10px; }
@media (min-width: 860px) { .lista { max-height: 620px; overflow-y: auto; padding-right: 4px; } }
.dea { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fff; display: grid; gap: 8px; }
.dea.sel { border-color: var(--red); box-shadow: 0 0 0 2px var(--red-soft); }
.dea-cab { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.dea h4 { font-size: 15px; }
.badge { font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.badge.verified { background: var(--ok-soft); color: #1b5e20; }
.badge.unconfirmed { background: var(--amber-soft); color: #78350f; }
.badge.unavailable { background: var(--off-soft); color: var(--off); }
.dea-dir { font-size: 13px; color: var(--ink-2); }
.dea-det { background: var(--soft); border-radius: 10px; padding: 10px; font-size: 13px; display: grid; gap: 3px; }
.dea-det .meta { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--ink-3); padding-top: 4px; }
.dea-acc { display: flex; gap: 8px; flex-wrap: wrap; }
.link-btn { background: none; border: 0; padding: 6px 0; font-size: 12px; font-weight: 700; color: var(--red-dark); text-decoration: underline; }
.vacio { text-align: center; color: var(--ink-3); font-size: 14px; padding: 20px; }

/* ---------- Capacitación ---------- */
.modulos { display: grid; gap: 10px; margin-top: 14px; }
@media (min-width: 700px) { .modulos { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .modulos { grid-template-columns: repeat(4, 1fr); } }
.modulo { border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.modulo .n { width: 34px; height: 34px; border-radius: 9px; background: var(--red-soft); color: var(--red); font-weight: 900; display: grid; place-items: center; margin-bottom: 8px; }
.modulo h4 { font-size: 15px; margin-bottom: 4px; }
.modulo p { font-size: 13px; color: var(--ink-2); }
.pregunta { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.pregunta p.q { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.opcion {
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; margin-bottom: 6px;
  font-size: 14px; cursor: pointer; background: #fff;
}
.opcion input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--red); flex: none; }
.opcion.bien { border-color: var(--ok); background: var(--ok-soft); }
.opcion.mal { border-color: #f87171; background: var(--red-soft); }
.explica { font-size: 13px; color: var(--ink-2); background: var(--soft); border-radius: 10px; padding: 10px 12px; margin-top: 4px; }
.resultado { margin-top: 12px; padding: 12px; border-radius: 10px; font-weight: 700; font-size: 14px; }
.resultado.ok { background: var(--ok-soft); color: #1b5e20; }
.resultado.warn { background: var(--amber-soft); color: #78350f; }

/* ---------- Simulador ---------- */
.sim { max-width: 760px; margin: 0 auto; width: 100%; }
.contexto { background: var(--soft); border-radius: 12px; padding: 14px; margin: 14px 0; }
.contexto h3 { margin-bottom: 4px; }
.contexto p { font-size: 14px; color: var(--ink-2); }
.progreso { font-size: 11px; font-weight: 800; color: var(--ink-3); letter-spacing: .06em; margin-bottom: 6px; }
.decision {
  width: 100%; text-align: left; border: 1px solid var(--line); background: #fff;
  border-radius: 12px; padding: 13px 14px; margin-bottom: 8px; font-size: 14px; min-height: 48px;
}
.decision:disabled { cursor: default; opacity: .75; }
.decision.bien { border-color: var(--ok); background: var(--ok-soft); opacity: 1; }
.decision.mal { border-color: #f87171; background: var(--red-soft); opacity: 1; }
.devolucion { border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-top: 4px; display: grid; gap: 10px; }
.devolucion.ok { background: var(--ok-soft); color: #1b5e20; }
.devolucion.no { background: var(--red-soft); color: var(--red-dark); }
.fin { text-align: center; padding: 18px 0; display: grid; gap: 10px; justify-items: center; }
.fin b.n { font-size: 40px; }

/* ---------- Red y administración ---------- */
form.grilla { display: grid; gap: 12px; margin-top: 12px; }
.dos { display: grid; gap: 12px; }
@media (min-width: 600px) { .dos { grid-template-columns: 1fr 1fr; } }
.consent {
  display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--ink-2);
  background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
}
.consent input { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--red); }
.ok-msg { background: var(--ok-soft); color: #1b5e20; border-radius: 10px; padding: 12px; font-size: 13px; font-weight: 700; }
.bitacora { list-style: none; margin: 8px 0 0; padding: 10px; background: var(--soft); border-radius: 12px; display: grid; gap: 6px; max-height: 240px; overflow-y: auto; font-size: 13px; }
.bitacora li { display: flex; justify-content: space-between; gap: 10px; }
.bitacora time { color: var(--ink-3); font-size: 11px; white-space: nowrap; }
.totales { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--ink-3); border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.totales b { color: var(--ink); }

/* ---------- Diálogo ---------- */
dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(440px, calc(100vw - 24px));
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(28, 25, 23, .5); }
.dlg { padding: 18px; display: grid; gap: 12px; }
.dlg-cab { display: flex; justify-content: space-between; align-items: center; }
.cerrar { background: none; border: 0; font-size: 22px; line-height: 1; padding: 6px 10px; color: var(--ink-3); }

footer { max-width: 1120px; margin: 24px auto 0; padding: 18px 16px; font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--line); }

@media (prefers-reduced-motion: reduce) {
  .punto { animation: none; }
  .pulso { transition: none; }
}
