/* CuidAPP — hoja de estilos
   ---------------------------------------------------------------
   Paleta oscura a proposito: la app se mira de noche, en la mesa de
   luz o desde la cama, y un fondo blanco a las 3 de la manana no lo
   perdona nadie. Los colores de estado son siempre los mismos en toda
   la app: verde bien, ambar atencion, rojo urgente.                */

:root {
  --fondo:    #111417;
  --tarjeta:  #191d21;
  --borde:    #262b30;
  --texto:    #e8e6e1;
  --apagado:  #8d8a83;
  --verde:    #4ade80;
  --ambar:    #fbbf24;
  --rojo:     #f87171;
  --azul:     #60a5fa;
  --rojofuerte: #8a1c1c;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  min-height: 100vh;
  padding: 16px 16px calc(84px + env(safe-area-inset-bottom));
}

/* ---------- cabecera ---------- */
.top { display: flex; align-items: center; gap: 11px; margin-bottom: 5px; }
.top img { width: 34px; height: 34px; border-radius: 9px; flex: none; }
.top h1 { flex: 1; font-size: 19px; font-weight: 600; letter-spacing: -.3px; }
.top h1 small { display: block; font-size: 12px; font-weight: 400; color: var(--apagado); letter-spacing: 0; }

.icono {
  width: 36px; height: 36px; border-radius: 10px;
  background: #1d2227; border: 1px solid var(--borde);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; cursor: pointer; flex: none;
}

.subtop {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 14px; font-size: 13px; color: var(--apagado); flex-wrap: wrap;
}
.estado { display: flex; align-items: center; gap: 7px; }
.punto { width: 9px; height: 9px; border-radius: 50%; background: #5a5751; flex: none; }
.punto.on   { background: var(--verde); box-shadow: 0 0 8px #4ade8099; }
.punto.nube.on { background: var(--azul); box-shadow: 0 0 8px #60a5fa99; }

/* ---------- tarjetas ---------- */
.card {
  background: var(--tarjeta); border: 1px solid var(--borde);
  border-radius: 14px; padding: 17px; margin-bottom: 12px;
}
.etq {
  font-size: 12px; color: var(--apagado); text-transform: uppercase;
  letter-spacing: .6px; margin-bottom: 8px;
}
.grande { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.prog { font-size: 13px; color: var(--apagado); margin-top: 9px; line-height: 1.65; }
.prog b { color: var(--texto); font-variant-numeric: tabular-nums; }
.fila { display: flex; gap: 12px; }
.fila .card { flex: 1; }

.bpm { display: flex; align-items: baseline; gap: 9px; }
.bpm b { font-size: 48px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.bpm span { font-size: 15px; color: var(--apagado); }
.corazon { margin-left: auto; font-size: 25px; }
.lat { animation: lat .9s ease-in-out infinite; }
@keyframes lat { 0%,100% { transform: scale(1); } 18% { transform: scale(1.28); } 36% { transform: scale(1); } }

canvas { width: 100%; display: block; margin-top: 12px; border-radius: 6px; }
#gAcc { height: 88px; } #gPulso { height: 68px; } #gBpm { height: 58px; }
#gHistBat, #gHistAct { height: 84px; }

.barra { height: 6px; background: var(--borde); border-radius: 3px; overflow: hidden; margin-top: 9px; }
.barra i { display: block; height: 100%; background: var(--verde); border-radius: 3px; transition: width .4s; }

/* ---------- botones ---------- */
button {
  width: 100%; padding: 14px; border: 0; border-radius: 12px;
  font-size: 16px; font-weight: 600; background: var(--texto);
  color: var(--fondo); cursor: pointer; font-family: inherit;
}
button:active { opacity: .75; }
button.sec { background: #242a30; color: #c9c6bf; font-weight: 500; font-size: 14px; padding: 12px; }
button.rojo { background: #dc2626; color: #fff; }
button:disabled { opacity: .4; }
.botones { display: flex; gap: 10px; margin-top: 8px; }
.botones.col { flex-direction: column; }

/* ---------- lista de pacientes (modo cuidador) ---------- */
.paciente {
  display: flex; align-items: center; gap: 13px;
  background: var(--tarjeta); border: 1px solid var(--borde);
  border-radius: 14px; padding: 15px 16px; margin-bottom: 10px; cursor: pointer;
}
.paciente:active { background: #1d2227; }
.paciente .luz { width: 12px; height: 12px; border-radius: 50%; flex: none; background: #5a5751; }
.paciente .luz.ok    { background: var(--verde); box-shadow: 0 0 9px #4ade8099; }
.paciente .luz.aviso { background: var(--ambar); box-shadow: 0 0 9px #fbbf2499; }
.paciente .luz.mal   { background: var(--rojo);  box-shadow: 0 0 9px #f8717199; animation: parpadeo 1s infinite; }
@keyframes parpadeo { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.paciente .txt { flex: 1; min-width: 0; }
.paciente .txt b { display: block; font-size: 16px; font-weight: 600; }
.paciente .txt small { display: block; color: var(--apagado); font-size: 12.5px; margin-top: 3px; }
.paciente .flecha { color: var(--apagado); font-size: 20px; flex: none; }

/* ---------- eventos ---------- */
#log, #listaHist { max-height: 260px; overflow-y: auto; }
.ev { display: flex; gap: 11px; padding: 9px 0; border-bottom: 1px solid #22262b; font-size: 14px; }
.ev:last-child { border-bottom: 0; }
.ev time { color: #7d7a74; font-variant-numeric: tabular-nums; flex: none; font-size: 12.5px; padding-top: 1px; }
.ev b { font-weight: 500; }
.ev.rojo b { color: var(--rojo); } .ev.ambar b { color: var(--ambar); } .ev.verde b { color: var(--verde); }
.ev small { display: block; color: #7d7a74; font-size: 12px; margin-top: 2px; }

/* ---------- grabacion ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chip {
  padding: 9px 13px; border-radius: 20px; background: var(--tarjeta);
  border: 1px solid #2c3238; font-size: 13px; cursor: pointer; color: #c9c6bf;
}
.chip.sel { background: var(--texto); color: var(--fondo); border-color: var(--texto); font-weight: 600; }
.grab {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 0; border-bottom: 1px solid #22262b; font-size: 14px; gap: 10px;
}
.grab:last-child { border-bottom: 0; }
.grab small { color: #7d7a74; display: block; font-size: 12px; margin-top: 2px; }
.grab .x { color: var(--rojo); font-size: 20px; cursor: pointer; padding: 0 6px; flex: none; }

/* ---------- navegacion ---------- */
nav {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex;
  background: #161a1e; border-top: 1px solid var(--borde);
  padding-bottom: env(safe-area-inset-bottom); z-index: 50;
}
nav div { flex: 1; text-align: center; padding: 12px 4px; font-size: 11.5px; color: #7d7a74; cursor: pointer; }
nav div.sel { color: var(--texto); }
nav div i { display: block; font-size: 18px; font-style: normal; margin-bottom: 3px; opacity: .85; }
.pag { display: none; } .pag.ver { display: block; }

/* ---------- alerta ---------- */
#alerta {
  position: fixed; inset: 0; z-index: 99; display: none; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; padding: 26px; gap: 13px;
}
#alerta.ver { display: flex; }
#alerta.pre { background: #7c4a06; }
#alerta.conf { background: var(--rojofuerte); animation: pulso 1s ease-in-out infinite; }
@keyframes pulso { 0%,100% { background: #8a1c1c; } 50% { background: #b02222; } }
#alerta h2 { font-size: 28px; font-weight: 700; letter-spacing: -.5px; }
#alerta p { font-size: 16px; opacity: .9; max-width: 340px; line-height: 1.5; }
#cuenta { font-size: 62px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
#alerta .botones { max-width: 340px; width: 100%; flex-direction: column; }
#alerta button { background: #fff; color: #111; }
#alerta button.sec { background: rgba(255,255,255,.16); color: #fff; }
.datos { font-size: 13px; opacity: .75; font-family: ui-monospace, monospace; }

/* ---------- ajustes ---------- */
#ajustes {
  position: fixed; inset: 0; z-index: 98; background: var(--fondo);
  display: none; overflow-y: auto; padding: 20px 16px calc(30px + env(safe-area-inset-bottom));
}
#ajustes.ver { display: block; }
#ajustes h2 { font-size: 19px; font-weight: 600; margin-bottom: 6px; }
#ajustes h3 {
  font-size: 12.5px; color: var(--apagado); text-transform: uppercase; letter-spacing: .6px;
  margin: 24px 0 4px; padding-top: 15px; border-top: 1px solid #22262b;
}
label { display: block; font-size: 13px; color: var(--apagado); margin: 13px 0 6px; }
input, select {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid #2c3238;
  background: var(--tarjeta); color: var(--texto); font-size: 16px; font-family: inherit;
}
.modos { display: flex; gap: 8px; margin-top: 6px; }
.modos div {
  flex: 1; padding: 12px 6px; text-align: center; border-radius: 10px; font-size: 13.5px;
  background: var(--tarjeta); border: 1px solid #2c3238; cursor: pointer;
}
.modos div.sel { background: var(--texto); color: var(--fondo); font-weight: 600; border-color: var(--texto); }
.dos { display: flex; gap: 10px; } .dos > div { flex: 1; }
.nota { font-size: 12px; color: #7d7a74; line-height: 1.55; margin-top: 8px; }
.aviso { font-size: 12px; color: #7d7a74; line-height: 1.5; text-align: center; margin: 16px 0 4px; }

.interruptor { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #22262b; }
.interruptor:last-child { border-bottom: 0; }
.interruptor .txt { flex: 1; }
.interruptor .txt b { display: block; font-size: 14.5px; font-weight: 500; }
.interruptor .txt small { display: block; color: var(--apagado); font-size: 12px; margin-top: 2px; line-height: 1.5; }
.interruptor input[type=checkbox] { width: 46px; height: 27px; flex: none; accent-color: var(--verde); }

video { display: none; }
