:root {
  --health-bg: #030014;
  --health-text: #f4f2ff;
  --health-muted: rgba(244, 242, 255, 0.62);
  --health-dim: rgba(244, 242, 255, 0.38);
  --health-accent-1: #a78bfa;
  --health-accent-2: #22d3ee;
  --health-ok: #34d399;
  --health-down: #f87171;
  --health-font: "Plus Jakarta Sans", system-ui, sans-serif;
  --health-display: "Fraunces", Georgia, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body.health-page {
  min-height: 100vh;
  color: var(--health-text);
  font-family: var(--health-font);
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(139, 92, 246, 0.22), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 100%, rgba(6, 182, 212, 0.14), transparent 50%),
    var(--health-bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Ambient ── */
.health-ambient {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.health-aurora {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  will-change: transform;
}

.health-aurora--1 {
  width: min(52vw, 460px);
  height: min(52vw, 460px);
  top: -12%;
  left: -10%;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.75), transparent 68%);
  animation: health-drift-1 18s ease-in-out infinite;
}

.health-aurora--2 {
  width: min(44vw, 400px);
  height: min(44vw, 400px);
  top: 28%;
  right: -12%;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.55), transparent 68%);
  animation: health-drift-2 22s ease-in-out infinite;
}

.health-aurora--3 {
  width: min(36vw, 320px);
  height: min(36vw, 320px);
  bottom: -10%;
  left: 30%;
  background: radial-gradient(circle, rgba(52, 211, 153, 0.35), transparent 68%);
  animation: health-drift-3 20s ease-in-out infinite;
}

.health-page--down .health-aurora--3 {
  background: radial-gradient(circle, rgba(248, 113, 113, 0.4), transparent 68%);
}

.health-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(circle at 50% 42%, #000 12%, transparent 70%);
  opacity: 0.5;
  animation: health-grid-pulse 10s ease-in-out infinite;
}

.health-scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(167, 139, 250, 0.06),
    rgba(34, 211, 238, 0.1),
    transparent
  );
  animation: health-scan 8s linear infinite;
}

.health-particles {
  position: absolute;
  inset: 0;
}

.health-particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 8px rgba(167, 139, 250, 0.6);
  animation: health-float 12s ease-in-out infinite;
}

.health-particle--1 { left: 8%; top: 18%; animation-delay: 0s; animation-duration: 11s; }
.health-particle--2 { left: 18%; top: 72%; animation-delay: -2s; animation-duration: 14s; width: 2px; height: 2px; }
.health-particle--3 { left: 28%; top: 32%; animation-delay: -4s; animation-duration: 13s; }
.health-particle--4 { left: 42%; top: 12%; animation-delay: -1s; animation-duration: 15s; width: 4px; height: 4px; }
.health-particle--5 { left: 55%; top: 78%; animation-delay: -3s; animation-duration: 12s; }
.health-particle--6 { left: 68%; top: 24%; animation-delay: -5s; animation-duration: 16s; }
.health-particle--7 { left: 78%; top: 58%; animation-delay: -2.5s; animation-duration: 11s; width: 2px; height: 2px; }
.health-particle--8 { left: 88%; top: 38%; animation-delay: -6s; animation-duration: 14s; }
.health-particle--9 { left: 12%; top: 48%; animation-delay: -1.5s; animation-duration: 13s; }
.health-particle--10 { left: 35%; top: 88%; animation-delay: -7s; animation-duration: 15s; width: 2px; height: 2px; }
.health-particle--11 { left: 62%; top: 8%; animation-delay: -3.5s; animation-duration: 12s; }
.health-particle--12 { left: 72%; top: 85%; animation-delay: -0.5s; animation-duration: 14s; }
.health-particle--13 { left: 92%; top: 70%; animation-delay: -4.5s; animation-duration: 11s; width: 2px; height: 2px; }
.health-particle--14 { left: 48%; top: 45%; animation-delay: -8s; animation-duration: 16s; opacity: 0.4; }
.health-particle--15 { left: 22%; top: 8%; animation-delay: -2.2s; animation-duration: 13s; }
.health-particle--16 { left: 85%; top: 15%; animation-delay: -5.5s; animation-duration: 12s; width: 2px; height: 2px; }
.health-particle--17 { left: 5%; top: 85%; animation-delay: -6.5s; animation-duration: 15s; }
.health-particle--18 { left: 95%; top: 50%; animation-delay: -1.8s; animation-duration: 14s; }

/* ── Layout ── */
.health-main {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.75rem;
  padding: 2rem 1.25rem 2.75rem;
  text-align: center;
}

.health-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  animation: health-rise 0.85s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.health-brand-mark {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.55rem;
  object-fit: cover;
  filter: drop-shadow(0 0 16px rgba(167, 139, 250, 0.45));
  animation: health-logo-glow 3.5s ease-in-out infinite;
}

.health-brand-name {
  font-family: var(--health-display);
  font-size: clamp(1.65rem, 4.5vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  background: linear-gradient(120deg, #fff 20%, #c4b5fd 55%, #67e8f9 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: health-shimmer 5s ease-in-out infinite;
}

.health-status {
  width: min(100%, 34rem);
  animation: health-rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
}

/* ── Stage / radar ── */
.health-stage {
  position: relative;
  width: 11rem;
  height: 11rem;
  margin: 0 auto 1.5rem;
}

.health-radar {
  position: absolute;
  inset: 0;
}

.health-radar-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  animation: health-radar-breathe 4s ease-in-out infinite;
}

.health-radar-ring--1 { inset: 8%; animation-delay: 0s; }
.health-radar-ring--2 { inset: 0; opacity: 0.7; animation-delay: 0.4s; }
.health-radar-ring--3 {
  inset: -12%;
  opacity: 0.4;
  animation-delay: 0.8s;
  border-style: dashed;
}

.health-radar-sweep {
  position: absolute;
  inset: -4%;
  border-radius: 50%;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    transparent 300deg,
    rgba(34, 211, 238, 0.18) 330deg,
    rgba(167, 139, 250, 0.28) 360deg
  );
  mask-image: radial-gradient(circle, transparent 42%, #000 43%, #000 70%, transparent 71%);
  -webkit-mask-image: radial-gradient(circle, transparent 42%, #000 43%, #000 70%, transparent 71%);
  animation: health-sweep 3.2s linear infinite;
}

.health-page--down .health-radar-sweep {
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    transparent 300deg,
    rgba(248, 113, 113, 0.22) 330deg,
    rgba(251, 146, 60, 0.3) 360deg
  );
}

.health-ring-wrap {
  position: absolute;
  inset: 18%;
}

.health-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.health-ring circle {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.health-ring--track circle {
  stroke: rgba(255, 255, 255, 0.08);
}

.health-ring--progress circle {
  stroke: url(#health-gradient);
  stroke-dasharray: 390;
  stroke-dashoffset: 280;
  filter: drop-shadow(0 0 6px rgba(34, 211, 238, 0.45));
  animation: health-ring-draw 2.8s ease-in-out infinite alternate;
}

.health-page--down .health-ring--progress circle {
  stroke: var(--health-down);
  filter: drop-shadow(0 0 6px rgba(248, 113, 113, 0.5));
}

.health-orbit {
  position: absolute;
  inset: -4%;
  animation: health-orbit 5s linear infinite;
}

.health-orbit-dot {
  position: absolute;
  top: 0;
  left: 50%;
  width: 7px;
  height: 7px;
  margin-left: -3.5px;
  border-radius: 50%;
  background: var(--health-accent-2);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.9);
}

.health-page--down .health-orbit-dot {
  background: var(--health-down);
  box-shadow: 0 0 12px rgba(248, 113, 113, 0.9);
}

.health-core {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.health-core-glow {
  position: absolute;
  width: 3.2rem;
  height: 3.2rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(52, 211, 153, 0.35), transparent 70%);
  animation: health-core-pulse 2.4s ease-in-out infinite;
}

.health-page--down .health-core-glow {
  background: radial-gradient(circle, rgba(248, 113, 113, 0.4), transparent 70%);
}

.health-core-dot {
  position: relative;
  z-index: 1;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  background: var(--health-ok);
  box-shadow: 0 0 22px rgba(52, 211, 153, 0.85);
  animation: health-core-pulse 2.4s ease-in-out infinite;
}

.health-page--down .health-core-dot {
  background: var(--health-down);
  box-shadow: 0 0 22px rgba(248, 113, 113, 0.85);
}

.health-core-ping {
  position: absolute;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  border: 1px solid rgba(52, 211, 153, 0.5);
  animation: health-ping 2.4s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.health-page--down .health-core-ping {
  border-color: rgba(248, 113, 113, 0.5);
}

/* ── Copy ── */
.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.85rem;
  color: #a7f3d0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  animation: health-rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.16s both;
}

.health-page--down .health-badge {
  color: #fecaca;
}

.health-badge-live {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 0 currentColor;
  animation: health-live 1.6s ease-out infinite;
}

.health-title {
  margin: 0;
  font-family: var(--health-display);
  font-size: clamp(1.9rem, 5.2vw, 2.75rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.08;
  animation: health-rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.22s both;
}

.health-lede {
  margin: 0.85rem auto 0;
  max-width: 28rem;
  color: var(--health-muted);
  font-size: 0.98rem;
  line-height: 1.65;
  animation: health-rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.28s both;
}

/* ── Waveform ── */
.health-wave {
  margin: 1.35rem auto 0;
  width: min(100%, 18rem);
  height: 2.75rem;
  opacity: 0.9;
  animation: health-rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.32s both;
}

.health-wave-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.health-wave-path {
  fill: none;
  stroke: url(#health-wave);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 420;
  stroke-dashoffset: 420;
  animation: health-wave-draw 2.2s ease-out 0.4s forwards, health-wave-flow 2.8s ease-in-out 2.6s infinite;
}

.health-wave-path--ghost {
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 2;
  stroke-dasharray: none;
  stroke-dashoffset: 0;
  animation: none;
  opacity: 0.7;
}

.health-page--down .health-wave-path {
  stroke: var(--health-down);
}

/* ── Meta metrics ── */
.health-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem 2.5rem;
  margin: 1.75rem 0 0;
  animation: health-rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.38s both;
}

.health-meta-item {
  min-width: 5rem;
}

.health-meta dt {
  margin: 0 0 0.3rem;
  color: var(--health-dim);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.health-meta dd {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.health-pill {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}

.health-pill--ok {
  color: #6ee7b7;
}

.health-pill--down {
  color: #fca5a5;
}

.health-ms {
  font-variant-numeric: tabular-nums;
}

.health-ms-unit {
  margin-left: 0.15rem;
  color: var(--health-dim);
  font-size: 0.78rem;
  font-weight: 600;
}

.health-time span {
  color: var(--health-dim);
  font-size: 0.72rem;
  font-weight: 600;
}

.health-meter {
  margin: 0.55rem auto 0;
  width: 3.5rem;
  height: 2px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.health-meter-fill {
  --health-meter: 70%;
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--health-accent-1), var(--health-accent-2), var(--health-ok));
  animation: health-meter-grow 1.1s cubic-bezier(0.22, 1, 0.36, 1) 0.5s forwards;
}

@keyframes health-meter-grow {
  to { width: var(--health-meter); }
}

.health-error {
  margin: 1.25rem 0 0;
  color: #fecaca;
  font-size: 0.84rem;
  line-height: 1.5;
  word-break: break-word;
  animation: health-rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.42s both;
}

.health-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--health-muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s ease;
  animation: health-rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.46s both;
}

.health-back-arrow {
  display: inline-block;
  transition: transform 0.2s ease;
}

.health-back:hover {
  color: var(--health-text);
}

.health-back:hover .health-back-arrow {
  transform: translateX(-3px);
}

/* ── Keyframes ── */
@keyframes health-drift-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(5%, 7%) scale(1.06); }
}

@keyframes health-drift-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-6%, 5%) scale(1.08); }
}

@keyframes health-drift-3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(4%, -6%) scale(1.05); }
}

@keyframes health-grid-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.58; }
}

@keyframes health-scan {
  0% { top: -15%; opacity: 0; }
  12% { opacity: 1; }
  88% { opacity: 1; }
  100% { top: 105%; opacity: 0; }
}

@keyframes health-float {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.35; }
  50% { transform: translateY(-18px) scale(1.25); opacity: 0.9; }
}

@keyframes health-logo-glow {
  0%, 100% { filter: drop-shadow(0 0 12px rgba(167, 139, 250, 0.35)); }
  50% { filter: drop-shadow(0 0 22px rgba(34, 211, 238, 0.55)); }
}

@keyframes health-shimmer {
  0%, 100% { background-position: 0% center; }
  50% { background-position: 100% center; }
}

@keyframes health-radar-breathe {
  0%, 100% { transform: scale(1); opacity: 0.55; }
  50% { transform: scale(1.04); opacity: 0.9; }
}

@keyframes health-sweep {
  to { transform: rotate(360deg); }
}

@keyframes health-ring-draw {
  0% { stroke-dashoffset: 340; opacity: 0.55; }
  100% { stroke-dashoffset: 55; opacity: 1; }
}

@keyframes health-orbit {
  to { transform: rotate(360deg); }
}

@keyframes health-core-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes health-ping {
  0% { transform: scale(0.65); opacity: 0.9; }
  70%, 100% { transform: scale(1.55); opacity: 0; }
}

@keyframes health-live {
  0% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
  70% { box-shadow: 0 0 0 8px transparent; opacity: 0.7; }
  100% { box-shadow: 0 0 0 0 transparent; opacity: 1; }
}

@keyframes health-wave-draw {
  to { stroke-dashoffset: 0; }
}

@keyframes health-wave-flow {
  0%, 100% { transform: translateY(0); opacity: 0.85; }
  50% { transform: translateY(-2px); opacity: 1; }
}

@keyframes health-rise {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 540px) {
  .health-stage {
    width: 9.5rem;
    height: 9.5rem;
  }

  .health-meta {
    gap: 1.25rem 2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .health-aurora,
  .health-grid,
  .health-scan,
  .health-particle,
  .health-brand,
  .health-brand-mark,
  .health-brand-name,
  .health-status,
  .health-radar-ring,
  .health-radar-sweep,
  .health-ring--progress circle,
  .health-orbit,
  .health-core-glow,
  .health-core-dot,
  .health-core-ping,
  .health-badge,
  .health-badge-live,
  .health-title,
  .health-lede,
  .health-wave,
  .health-wave-path,
  .health-meta,
  .health-meter-fill,
  .health-error,
  .health-back {
    animation: none !important;
  }

  .health-wave-path {
    stroke-dashoffset: 0;
  }

  .health-meter-fill {
    width: var(--health-meter);
  }
}
