:root {
  --blue: #1f53cc;
  --blue-dark: #1a45ad;
  --blue-soft: #eaf0ff;
  --ink: #0f1b33;
  --muted: #6b7a90;
  --bg: #e9eef5;
  --card: #ffffff;
  --line: #eaeef4;
  --green: #16a34a;
  --green-bg: #e7f7ec;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(20, 40, 90, 0.12);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
}
body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: radial-gradient(
      1200px 700px at 80% -10%,
      #dbe6ff,
      transparent 60%
    ),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- contenedor tipo app ---------- */
.app {
  width: 100%;
  max-width: 440px;
  background: #f6f8fc;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  overflow: hidden;
}
@media (min-width: 480px) {
  .app {
    margin: 22px 0;
    min-height: auto;
    height: calc(100dvh - 44px);
    border-radius: 30px;
    box-shadow: var(--shadow);
    border: 1px solid #fff;
  }
}

/* ---------- barra superior ---------- */
.appbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.appbar__logo {
  height: 26px;
  width: auto;
}
.appbar__icon {
  background: none;
  border: none;
  color: var(--blue);
  cursor: pointer;
  padding: 4px;
  display: flex;
}

/* ---------- cuerpo desplazable ---------- */
.app__body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.screen {
  display: none;
}
.screen--active {
  display: block;
}

/* ---------- botones ---------- */
.btn {
  font-family: inherit;
  font-weight: 700;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  font-size: 16px;
  padding: 15px 20px;
  width: 100%;
  transition: transform 0.12s ease, opacity 0.2s ease, background 0.2s ease;
}
.btn:active {
  transform: scale(0.985);
}
.btn--primary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 12px 24px rgba(31, 83, 204, 0.28);
}
.btn--primary:hover {
  background: var(--blue-dark);
}
.btn--primary:disabled {
  background: #c5cfe0;
  box-shadow: none;
  cursor: default;
}
.btn--ghost {
  background: transparent;
  color: var(--blue);
  border: 1.5px solid #d6deec;
  margin-top: 10px;
}
.btn--whatsapp {
  background: #25d366;
  color: #04270f;
}
.btn--whatsapp:hover {
  filter: brightness(1.03);
}

/* ---------- INICIO ---------- */
.hero {
  padding: 34px 24px 28px;
  text-align: center;
}
.hero__emblem {
  width: 84px;
  height: 84px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #ff5c6c;
  background: radial-gradient(circle at 50% 40%, #fff, #fff);
  box-shadow: 0 0 0 10px #fff, 0 0 0 11px #ffe3e6, 0 14px 30px rgba(255, 92, 108, 0.18);
}
.hero h1 {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.hero__sub {
  color: var(--blue);
  font-weight: 600;
  margin: 0 0 16px;
  font-size: 14px;
}
.hero__lede {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
  margin: 0 auto 22px;
  max-width: 330px;
}
.check-list {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  display: grid;
  gap: 10px;
  text-align: left;
}
.check-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 15px;
  font-size: 14.5px;
  font-weight: 600;
}
.check-list .chip {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.check-list .tag {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
  background: var(--green-bg);
  padding: 4px 9px;
  border-radius: 999px;
}
.confidential {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  margin: 16px 0 0;
}

/* ---------- VIDEOSELFIE ---------- */
.camera {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  background: #0d1830;
  overflow: hidden;
}
.camera #mxcanvas,
.camera #sim-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
}
.camera--sim #sim-video {
  display: block;
  object-fit: cover;
  transform: scaleX(-1);
}
.camera--real #mxcanvas {
  display: block;
}
/* óvalo guía para encuadrar la cara */
.camera__oval {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.camera__oval svg {
  width: 100%;
  height: 100%;
}
.camera__oval ellipse {
  fill: none;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 2.5;
  stroke-dasharray: 7 8;
  transition: stroke 0.4s ease;
  animation: ovalPulse 2.6s ease-in-out infinite;
}
@keyframes ovalPulse {
  50% {
    opacity: 0.55;
  }
}
.camera--locked .camera__oval ellipse {
  stroke: #34d399;
  stroke-dasharray: none;
  filter: drop-shadow(0 0 6px rgba(52, 211, 153, 0.7));
}

/* malla/mesh animada que "escanea" la cara */
.face-mesh {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.camera--measuring .face-mesh {
  opacity: 1;
}

/* línea de barrido */
.scanline {
  position: absolute;
  left: 18%;
  right: 18%;
  height: 2px;
  top: 22%;
  background: linear-gradient(90deg, transparent, #34d399, transparent);
  box-shadow: 0 0 12px #34d399;
  opacity: 0;
}
.camera--measuring .scanline {
  opacity: 0.9;
  animation: scan 2.6s ease-in-out infinite;
}
@keyframes scan {
  0%,
  100% {
    top: 22%;
  }
  50% {
    top: 78%;
  }
}

/* pletismografía (PPG) en tiempo real debajo del video */
.ppg-strip {
  position: relative;
  height: 64px;
  background: #0d1830;
  display: flex;
  align-items: center;
}
.ppg-strip canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.ppg-strip__label {
  position: absolute;
  left: 12px;
  bottom: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(143, 233, 217, 0.85);
  pointer-events: none;
}
.camera__hint {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 27, 51, 0.7);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.camera__timer {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 27, 51, 0.7);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 11px;
  border-radius: 999px;
}
.camera__timer .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff4d4f;
  animation: blink 1.1s ease-in-out infinite;
}
@keyframes blink {
  50% {
    opacity: 0.25;
  }
}
.camera__signal {
  position: absolute;
  bottom: 14px;
  left: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(15, 27, 51, 0.7);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 11px;
  border-radius: 999px;
}

/* ---------- tarjeta de métricas ---------- */
.metrics-card {
  position: relative;
  margin: 12px 12px 16px;
  background: #fff;
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 18px 16px 16px;
}
.metrics-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.metrics-card__head h2 {
  font-size: 18px;
  font-weight: 800;
  margin: 0;
}
.metrics-card__live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.metrics-card__live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff4d4f;
  animation: blink 1.1s ease-in-out infinite;
}
.metrics-card__live.is-final .metrics-card__live-dot {
  background: var(--green);
  animation: none;
}
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.tile {
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 6px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.tile__icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  margin-bottom: 3px;
}
.tile__label {
  font-size: 10px;
  line-height: 1.15;
  color: var(--muted);
  font-weight: 600;
  min-height: 24px;
  display: flex;
  align-items: center;
}
.tile__value {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  transition: opacity 0.3s ease;
}
.tile__unit {
  font-size: 9.5px;
  color: var(--muted);
  font-weight: 600;
  margin-top: -2px;
}
.tile__tag {
  font-size: 9px;
  font-weight: 700;
  color: var(--green);
  background: var(--green-bg);
  padding: 2px 7px;
  border-radius: 999px;
  margin-top: 2px;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.tile.is-filled .tile__tag {
  opacity: 1;
}

/* ---------- estado general ---------- */
.status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 14px;
  margin: 12px 0;
}
.status-card__shield {
  color: var(--blue);
  flex: 0 0 auto;
}
.status-card__text {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.status-card__label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.status-card__text strong {
  font-size: 17px;
  font-weight: 800;
}
.status-card__hint {
  font-size: 11.5px;
  color: var(--muted);
}
.ring {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
}
.ring svg {
  transform: rotate(-90deg);
}
.ring__bg {
  fill: none;
  stroke: #e8edf5;
  stroke-width: 4;
}
.ring__fg {
  fill: none;
  stroke: var(--green);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 119.4;
  stroke-dashoffset: 119.4;
  transition: stroke-dashoffset 1.1s ease;
}
.ring__num {
  position: absolute;
  text-align: center;
  line-height: 1;
}
.ring__num strong {
  font-size: 15px;
  font-weight: 800;
}
.ring__num small {
  display: block;
  font-size: 8px;
  color: var(--muted);
  font-weight: 600;
}

/* ---------- RESUMEN ---------- */
.summary {
  padding: 22px 20px 26px;
}
.summary__hero {
  text-align: center;
  margin-bottom: 18px;
}
.ring--lg .ring__num strong {
  font-size: 26px;
}
.ring--lg .ring__num small {
  font-size: 11px;
}
.summary__hero h2 {
  font-size: 21px;
  font-weight: 800;
  margin: 14px 0 8px;
  letter-spacing: -0.02em;
}
.summary__hero h2 span {
  color: var(--green);
}
.result-list {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: grid;
  gap: 9px;
}
.result-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.result-list .chip {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.result-list .rl-label {
  font-size: 14px;
  font-weight: 600;
}
.result-list .rl-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.result-list .rl-value {
  font-size: 15px;
  font-weight: 800;
}
.result-list .rl-value small {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  margin-left: 2px;
}
.result-list .tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--green);
  background: var(--green-bg);
  padding: 3px 9px;
  border-radius: 999px;
}

.plan-card {
  background: linear-gradient(135deg, #eef3ff, #e7f7ec);
  border: 1px solid #dbe6ff;
  border-radius: 18px;
  padding: 20px;
}
.plan-card h3 {
  margin: 0 0 6px;
  font-size: 17px;
}
.plan-card p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}
.disclaimer {
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
  margin: 16px 4px 0;
  line-height: 1.5;
}

/* ---------- tabbar ---------- */
.tabbar {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 8px 6px max(8px, env(safe-area-inset-bottom));
}
.tab {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: #9aa6ba;
  font-size: 10.5px;
  font-weight: 600;
  font-family: inherit;
  padding: 4px 6px;
  flex: 1 1 0;
}
.tab.is-active {
  color: var(--blue);
}
.tab--cta {
  color: var(--blue);
}
.tab__fab {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
  margin-top: -24px;
  box-shadow: 0 10px 22px rgba(31, 83, 204, 0.4);
  border: 4px solid #fff;
}

/* ---------- aviso de configuración ---------- */
.setup-error {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
  background: rgba(15, 27, 51, 0.55);
  backdrop-filter: blur(6px);
  padding: 20px;
}
.setup-error.is-visible {
  display: flex;
}
.setup-error__box {
  max-width: 420px;
  background: #fff;
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}
.setup-error__box h2 {
  margin-top: 0;
}
.setup-error__box p {
  color: var(--muted);
  line-height: 1.6;
  font-size: 14px;
}
.setup-error__box code {
  background: #eef2f8;
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 12.5px;
}
