/* Mismos colores que la app del móvil (Ui.java). */
:root {
  --primario: #4F46E5;
  --primario-suave: #EEF0FF;
  --fondo: #F4F5FB;
  --superficie: #FFFFFF;
  --texto: #1F2937;
  --tenue: #6B7280;
  --campo: #F3F4F6;
  --peligro: #DC2626;
  --peligro-suave: #FEE2E2;
  --bien: #16A34A;
  --radio: 24px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.vista {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
}

.oculto { display: none !important; }
.centro { text-align: center; }
.tenue { color: var(--tenue); margin: 4px 0; }

h1 { font-size: 28px; font-weight: 600; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 18px; font-weight: 600; margin: 0 0 14px; }

.etiqueta { font-size: 14px; font-weight: 600; color: var(--tenue); margin: 18px 0 10px; }
.etiqueta:first-child { margin-top: 0; }
.grande { font-size: 20px; font-weight: 600; margin: 0; }

.tarjeta {
  background: var(--superficie);
  border-radius: var(--radio);
  padding: 20px;
  margin-top: 16px;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
}

/* --- Entrar --- */
.entrar { padding-top: 12vh; text-align: center; }
.entrar .logo { width: 72px; height: 72px; margin-bottom: 16px; }
.entrar .tarjeta { text-align: left; margin-top: 24px; }

input[type=password], input[type=text] {
  width: 100%;
  font: inherit;
  font-size: 18px;
  padding: 16px;
  border: 0;
  border-radius: 16px;
  background: var(--campo);
  color: var(--texto);
  outline: none;
}
input:focus { box-shadow: 0 0 0 2px var(--primario); }

/* --- Botones --- */
.boton {
  display: block;
  width: 100%;
  min-height: 52px;
  margin-top: 10px;
  border: 0;
  border-radius: 18px;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
}
.boton:active { transform: scale(0.98); }
.boton:disabled { opacity: 0.45; cursor: default; }
.boton.primario { background: var(--primario); color: #fff; }
.boton.suave { background: var(--primario-suave); color: var(--primario); }
.boton.peligro { background: var(--peligro-suave); color: var(--peligro); }
.boton.texto { background: none; color: var(--tenue); width: auto; min-height: 40px; padding: 0 8px; }
.boton.peligro-texto { color: var(--peligro); padding: 0; }
.boton:hover:not(:disabled) { filter: brightness(0.97); }

.fila { display: grid; gap: 8px; }
.fila .boton { margin-top: 10px; }
.fila.tres { grid-template-columns: repeat(3, 1fr); margin-top: 8px; }
.fila.dos { grid-template-columns: 1fr 1fr; }

.redondo {
  width: 56px; height: 56px;
  border: 0; border-radius: 50%;
  background: var(--primario-suave); color: var(--primario);
  font-size: 28px; cursor: pointer;
}

.error { color: var(--peligro); text-align: center; margin: 12px 0 0; }
.nota { color: var(--tenue); font-size: 14px; margin: 12px 0 0; }

/* --- Cabecera --- */
.cabecera { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-top: 8px; }
.punto { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; background: #9CA3AF; }
.punto.vivo { background: var(--bien); box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.18); }

/* --- Alerta --- */
.alerta { background: var(--peligro-suave); color: var(--peligro); font-weight: 600; }
.alerta p { color: var(--texto); font-weight: 400; margin: 6px 0 0; }

/* --- Ahora --- */
.ahora { display: flex; align-items: center; gap: 16px; }
.ahora p { margin: 0; }
.ahora .etiqueta { margin: 0 0 2px; }
.avatar {
  flex: none;
  width: 52px; height: 52px; border-radius: 16px;
  display: grid; place-items: center;
  background: var(--primario-suave); color: var(--primario);
  font-size: 22px; font-weight: 700;
}
.avatar.controlada { background: var(--primario); color: #fff; }
.avatar.apagada { background: var(--campo); color: var(--tenue); }

/* --- Anillo --- */
.anillo { width: 220px; height: 220px; display: block; margin: 4px auto 8px; }
.anillo circle { fill: none; stroke-width: 16; }
.anillo .pista { stroke: var(--primario-suave); }
.anillo .arco { stroke: var(--primario); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset 0.6s, stroke 0.3s; }
.anillo .arco.poco { stroke: var(--peligro); }
.anillo .valor { font-size: 52px; font-weight: 600; text-anchor: middle; fill: var(--texto); }
.anillo .pie { font-size: 15px; text-anchor: middle; fill: var(--tenue); }

/* --- Barras --- */
.barra { margin: 0 0 12px; }
.barra .nombre { display: flex; justify-content: space-between; font-size: 15px; margin-bottom: 4px; }
.barra .pista { height: 10px; border-radius: 6px; background: var(--primario-suave); overflow: hidden; }
.barra .relleno { height: 100%; border-radius: 6px; background: var(--primario); }

.semana { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 150px; }
.semana .dia { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 12px; color: var(--tenue); }
.semana .columna { width: 100%; max-width: 34px; border-radius: 8px 8px 4px 4px; background: var(--primario); min-height: 3px; }
.semana .columna.pasado { background: var(--peligro); }
.semana .cifra { font-size: 11px; margin-bottom: 4px; color: var(--texto); }

/* --- Ajustes --- */
.paso { display: flex; align-items: center; justify-content: space-between; }
.paso span { font-size: 26px; font-weight: 600; }

.app { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid #F1F2F6; }
.app:first-child { border-top: 0; }
.app small { display: block; color: var(--tenue); font-size: 12px; }

.interruptor { position: relative; flex: none; width: 50px; height: 30px; }
.interruptor input { opacity: 0; width: 0; height: 0; }
.interruptor span { position: absolute; inset: 0; border-radius: 30px; background: #D1D5DB; transition: background 0.2s; cursor: pointer; }
.interruptor span::before { content: ""; position: absolute; width: 24px; height: 24px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.2); transition: transform 0.2s; }
.interruptor input:checked + span { background: var(--primario); }
.interruptor input:checked + span::before { transform: translateX(20px); }

/* --- Eventos --- */
.eventos { list-style: none; margin: 0; padding: 0; }
.eventos li { padding: 10px 0; border-top: 1px solid #F1F2F6; font-size: 15px; }
.eventos li:first-child { border-top: 0; }
.eventos time { display: block; font-size: 12px; color: var(--tenue); }

/* --- Emparejar --- */
.codigo { font-size: 44px; font-weight: 700; letter-spacing: 0.18em; text-align: center; margin: 12px 0 4px; color: var(--primario); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--texto); color: #fff;
  padding: 12px 18px; border-radius: 14px; font-size: 15px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
  max-width: calc(100% - 32px);
}
