 :root{
      --bg:#ded8ea;
      --ink:#1f1a2a;
      --muted:#4b4458;
      --purple:#4b3a77;
      --purple2:#5b46a1;
      --panel:#3b3b40;
      --badge: rgba(48,48,55,.78);
      --safeTop: env(safe-area-inset-top, 0px);
      --safeBottom: env(safe-area-inset-bottom, 0px);
      --padX: clamp(18px, 5vw, 26px);
    }
    :root[data-theme="dark"]{
      --bg:#0f1116;
      --ink:#f4f4f6;
      --muted:#c7c7d1;
      --purple:#5b46a1;
      --purple2:#8b5cf6;
      --panel:#1f2025;
      --badge: rgba(20,20,24,.78);
    }

    *{ box-sizing:border-box; }
    html,body{ height:100%; }
    body{
      margin:0;
      font-family:Poppins, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
      background: var(--bg);
      color: var(--ink);
    }

    .app{
      width:100vw;
      min-height:100dvh;
      min-height:100vh;
      background:
        radial-gradient(900px 520px at 50% 55%, rgba(0,0,0,.06), transparent 60%),
        var(--bg);
      position:relative;
      overflow:hidden;
    }

    .screen{
      max-width:430px;
      margin:0 auto;
      padding: calc(16px + var(--safeTop)) var(--padX) calc(112px + var(--safeBottom));
    }

    .brand{ display:flex; align-items:center; gap:10px; }
    .mark{ width:44px; height:44px; display:grid; place-items:center; }
    .brandName{
      font-size: clamp(30px, 6.2vw, 36px);
      font-weight: 900;
      line-height:1;
      white-space:nowrap;
    }
    .brandName b{ color: var(--purple2); }

    .greeting{
      margin-top: 20px;
      color: var(--muted);
      font-size: 14px;
      line-height: 1.35;
      font-weight: 500;
    }

    .stage{ position: relative; margin-top: 10px; min-height: 520px; }

    .ecg{ position:absolute; left: 0; top: 220px; }
    .ecg .lbl{ font-size: 16px; font-weight: 500; opacity:.9; }
    .ecg .row{ display:flex; align-items:baseline; gap:8px; line-height:1; }
    .ecg .num{ font-size: 64px; font-weight: 400; letter-spacing: -1px; }
    .ecg .unit{
      font-size: 22px;
      font-weight: 600;
      color: var(--purple2);
      opacity:.9;
      transform: translateY(2px);
    }

    .heart{
      position:absolute;
      top: 120px;
      left: 62%;
      transform: translateX(-50%);
      width: min(240px, 56vw);
      height:auto;
      filter: drop-shadow(0 18px 28px rgba(0,0,0,.18));
      user-select:none;
      -webkit-user-drag:none;
      -webkit-tap-highlight-color: transparent;
      transition: transform .18s ease, filter .18s ease;
    }
    .heart:active{
      transform: translateX(-50%) scale(.985);
      filter: drop-shadow(0 14px 22px rgba(0,0,0,.18));
    }

    .heartShadow{
      position:absolute;
      top: 470px;
      left: 62%;
      transform: translateX(-50%);
      width: min(270px, 64vw);
      height: 26px;
      background: rgba(0,0,0,.16);
      filter: blur(10px);
      border-radius: 50%;
      opacity: .52;
    }

    .badge{
      position:absolute;
      right: 0;
      top: 390px;
      width: min(185px, 48vw);
      padding: 14px;
      background: var(--badge);
      border-radius: 18px;
      color:#f6f6f7;
      box-shadow: 0 16px 30px rgba(0,0,0,.18);
      backdrop-filter: blur(8px);
      -webkit-tap-highlight-color: transparent;
      transition: transform .18s ease, box-shadow .18s ease;
    }
    .badge:active{
      transform: scale(.99);
      box-shadow: 0 12px 24px rgba(0,0,0,.18);
    }
    .badge .title{ font-weight: 700; font-size: 15px; margin-bottom: 6px; }
    .badge .row{ display:flex; align-items:center; justify-content:space-between; gap:10px; }
    .badge .val{ font-weight: 600; font-size: 16px; opacity:.95; white-space:nowrap; }
    .badge .mini{
      width: 32px; height: 32px;
      border-radius: 10px;
      display:grid; place-items:center;
      background: rgba(255,255,255,.10);
    }
    .badge .mini ion-icon{ font-size: 18px; color:#fff; }

    .connRow{
      margin-top: 10px;
      display:flex;
      align-items:center;
      gap:10px;
      color: var(--muted);
      font-size: 12px;
      font-weight: 700;
    }
    .connDot{
      width:10px;
      height:10px;
      border-radius:999px;
      background:#ef4444;
      box-shadow: 0 0 0 4px rgba(239,68,68,.12);
    }
    .connDot.on{
      background:#22c55e;
      box-shadow: 0 0 0 4px rgba(34,197,94,.14);
    }

    .addTitle{
      text-align:center;
      margin-top:22px;
      font-size:20px;
      font-weight:500;
      color:var(--purple2);
    }

    .panel{
      margin-top:18px;
      width:100%;
      height:min(560px,64vh);
      background:var(--panel);
      border-radius:22px;
      overflow:hidden;
      box-shadow:0 18px 40px rgba(0,0,0,.18);
    }
    .panelHeader{
      height:64px;
      background:rgba(0,0,0,.18);
      display:flex;
      align-items:center;
      justify-content:space-between;
      padding:0 18px;
      color:#f3f3f4;
    }
    .panelHeader .hText{font-size:18px;font-weight:500}
    .actions{display:flex;gap:10px}
    .iconBtn{
      width:40px;height:40px;border:none;border-radius:12px;
      background:rgba(255,255,255,.10);
      display:grid;place-items:center;cursor:pointer;color:#fff;
      -webkit-tap-highlight-color: transparent;
      transition: transform .12s ease, background .12s ease;
    }
    .iconBtn:active{ transform: scale(.96); background: rgba(255,255,255,.12); }
    .iconBtn ion-icon{font-size:22px}
    .panelBody{height:calc(100% - 64px);padding:14px;overflow:auto}

    .pill{
      display:flex;align-items:center;gap:8px;padding:10px 12px;border-radius:12px;
      background:rgba(0,0,0,.18);
      color:rgba(255,255,255,.88);
      font-size:12px;margin-bottom:10px
    }
    .pill ion-icon{font-size:16px}

    .sectionTitle{
      color:rgba(255,255,255,.78);
      font-size:12px;margin:12px 2px 8px;letter-spacing:.2px
    }
    .list{display:flex;flex-direction:column;gap:10px}

    .deviceCard{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:12px;
      padding:12px;
      border-radius:14px;
      background:rgba(255,255,255,.06);
      border:1px solid rgba(255,255,255,.08);
    }
    .deviceCard.active{
      outline:2px solid rgba(139,92,246,.35);
      background: rgba(139,92,246,.10);
    }
    .deviceCard .dName{
      color:#fff;font-weight:700;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:190px
    }
    .deviceCard .dSub{
      color:rgba(255,255,255,.75);font-size:11px;margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:220px
    }
    .topLine{ display:flex; align-items:center; gap:8px; }
    .tag{
      font-size:11px;padding:4px 8px;border-radius:999px;
      background:rgba(0,0,0,.25);color:rgba(255,255,255,.92)
    }
    .right{ display:flex; align-items:center; gap:8px; }
    .miniBtn{
      border:none;cursor:pointer;
      padding:8px 10px;border-radius:12px;
      background:#fff;color:#2a2140;
      font-weight:800;font-size:12px;
      -webkit-tap-highlight-color: transparent;
      transition: transform .12s ease, opacity .12s ease;
    }
    .miniBtn:active{ transform: scale(.98); }
    .miniBtn.ghost{ background: rgba(255,255,255,.12); color:#fff; }
    .empty{
      color:rgba(255,255,255,.70);
      font-size:13px;
      padding:10px 2px;
    }

    .ctaWrap{ margin-top:18px; display:flex; justify-content:center; gap:12px; flex-wrap:wrap }
    .cta{
      width:min(320px,88%);
      height:56px;border:none;border-radius:18px;
      background:var(--purple);
      color:#fff;font-size:18px;font-weight:700;
      cursor:pointer;
      box-shadow:0 16px 30px rgba(0,0,0,.16);
      -webkit-tap-highlight-color: transparent;
      transition: transform .12s ease, opacity .12s ease;
    }
    .cta:active{ transform: scale(.99); }
    .cta.secondary{ background:rgba(75,58,119,.18); color:#fff; box-shadow:none }
    .cta:disabled{ opacity:.55; cursor:not-allowed }

    .bottom{
      position:fixed;
      left:0; right:0; bottom:0;
      padding: 0 var(--padX) calc(18px + var(--safeBottom));
      height: calc(104px + var(--safeBottom));
      display:flex;
      align-items:flex-end;
      justify-content:center;
      pointer-events:none;
      z-index: 40;
    }
    .nav{
      pointer-events:auto;
      width:min(430px, 100%);
      height: 64px;
      background: var(--purple);
      border-radius: 18px;
      display:flex;
      align-items:center;
      justify-content:space-between;
      padding: 0 22px;
      box-shadow: 0 18px 34px rgba(0,0,0,.20);
      position:relative;
    }
    .navBtn{
      width: 44px;
      height: 44px;
      border:none;
      background: transparent;
      border-radius: 12px;
      display:grid;
      place-items:center;
      cursor:pointer;
      color: rgba(255,255,255,.92);
      -webkit-tap-highlight-color: transparent;
      transition: transform .12s ease, background .12s ease, opacity .12s ease;
    }
    .navBtn ion-icon{ font-size: 22px; }
    .navBtn:active{ transform: scale(.96); }
    .navBtn.square{ background: rgba(0,0,0,.16); }
    .navBtn.active{ background: rgba(255,255,255,.10); }

    .fab{
      position:absolute;
      left:50%;
      transform: translate(-50%, -22px);
      width: 56px;
      height: 56px;
      border-radius: 999px;
      border:none;
      background: #fff;
      color: var(--purple);
      display:grid;
      place-items:center;
      cursor:pointer;
      box-shadow: 0 18px 30px rgba(0,0,0,.22);
      -webkit-tap-highlight-color: transparent;
      transition: transform .12s ease;
    }
    .fab ion-icon{ font-size: 26px; }
    .fab:active{ transform: translate(-50%, -22px) scale(.97); }

    /* ========== Settings screen wrapper (FALTABA EN TU HTML) ========== */
    .settingsScreen{
      position:fixed;
      inset:0;
      background:
        radial-gradient(900px 520px at 50% 55%, rgba(0,0,0,.08), transparent 60%),
        var(--bg);
      transform: translateX(102%);
      transition: transform .22s ease;
      z-index: 60;
      padding: calc(14px + var(--safeTop)) var(--padX) calc(18px + var(--safeBottom));
    }
    .settingsScreen.open{ transform: translateX(0); }
    .settingsTop{
      max-width:430px;
      margin: 0 auto;
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:10px;
    }
    .iconChip{
      width:40px;
      height:40px;
      border:none;
      border-radius: 14px;
      background: rgba(0,0,0,.08);
      color: var(--ink);
      display:grid;
      place-items:center;
      cursor:pointer;
      -webkit-tap-highlight-color: transparent;
      transition: transform .12s ease, background .12s ease;
    }
    .iconChip:active{ transform: scale(.96); background: rgba(0,0,0,.10); }
    .iconChip ion-icon{ font-size: 22px; }
    .settingsTitle{ font-size: 20px; font-weight: 700; color: var(--ink); }

    .settingsCard{
      max-width:430px;
      margin: 18px auto 0;
      background: rgba(0,0,0,.08);
      border: 1px solid rgba(0,0,0,.06);
      border-radius: 22px;
      padding: 14px;
    }
    :root[data-theme="dark"] .settingsCard{
      background: rgba(255,255,255,.06);
      border-color: rgba(255,255,255,.08);
    }
    .cardHead{ font-weight: 800; color: var(--ink); margin: 4px 2px 12px; }

    .rowItem{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap: 12px;
      padding: 12px 10px;
      border-radius: 16px;
      background: rgba(255,255,255,.06);
    }
    :root[data-theme="light"] .rowItem{ background: rgba(255,255,255,.35); }
    .rowLeft{ display:flex; flex-direction:column; gap:2px; }
    .rowLabel{ font-weight: 700; color: var(--ink); font-size: 14px; }
    .rowSub{ color: var(--muted); font-size: 12px; font-weight: 500; }
    .select{
      border:none;
      outline:none;
      padding: 10px 12px;
      border-radius: 14px;
      background: rgba(0,0,0,.10);
      color: var(--ink);
      font-weight: 700;
    }
    :root[data-theme="dark"] .select{ background: rgba(255,255,255,.10); color: var(--ink); }

    .toggle{
      width: 54px;
      height: 32px;
      border:none;
      border-radius: 999px;
      background: rgba(0,0,0,.12);
      position:relative;
      cursor:pointer;
      -webkit-tap-highlight-color: transparent;
      transition: background .18s ease;
    }
    :root[data-theme="dark"] .toggle{ background: rgba(255,255,255,.12); }
    .toggle .knob{
      position:absolute;
      top: 4px; left: 4px;
      width: 24px; height: 24px;
      border-radius: 999px;
      background: #fff;
      transition: transform .18s ease;
      box-shadow: 0 10px 18px rgba(0,0,0,.18);
    }
    .toggle.on{ background: rgba(91,70,161,.55); }
    .toggle.on .knob{ transform: translateX(22px); }
    .miniNote{ margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 1.35; }

    .hidden{ display:none !important; }

    @media (hover:hover){
      .navBtn:hover{ background: rgba(255,255,255,.10); }
      .fab:hover{ transform: translate(-50%, -24px); }
      .iconChip:hover{ background: rgba(0,0,0,.10); }
      .miniBtn:hover{ opacity:.92; }
    }

    /* ===== Extras Ajustes ===== */
    .settingsCard + .settingsCard{ margin-top: 12px; }
    .rowRight{ display:flex; align-items:center; gap:10px; }

    .valuePill{
      font-size:12px;
      font-weight:800;
      padding:6px 10px;
      border-radius:999px;
      background: rgba(0,0,0,.10);
      color: var(--ink);
    }
    :root[data-theme="dark"] .valuePill{ background: rgba(255,255,255,.10); }

    .stepper{
      display:flex; align-items:center; gap:8px;
      background: rgba(0,0,0,.10);
      padding:6px; border-radius:14px;
    }
    :root[data-theme="dark"] .stepper{ background: rgba(255,255,255,.10); }

    .stepBtn{
      width:32px; height:32px;
      border:none; border-radius:12px;
      background: rgba(255,255,255,.55);
      color: var(--ink);
      font-weight:900;
      cursor:pointer;
      -webkit-tap-highlight-color: transparent;
      transition: transform .12s ease, opacity .12s ease;
    }
    :root[data-theme="dark"] .stepBtn{ background: rgba(0,0,0,.25); color: var(--ink); }
    .stepBtn:active{ transform: scale(.96); }

    .input{
      width: 180px;
      max-width: 50vw;
      border:none; outline:none;
      padding: 10px 12px;
      border-radius: 14px;
      background: rgba(0,0,0,.10);
      color: var(--ink);
      font-weight: 800;
    }
    :root[data-theme="dark"] .input{ background: rgba(255,255,255,.10); }

    .divider{
      height:1px;
      background: rgba(0,0,0,.08);
      margin: 12px 0 4px;
    }
    :root[data-theme="dark"] .divider{ background: rgba(255,255,255,.08); }

    .dangerBtn{
      width:100%;
      border:none;
      padding: 12px 14px;
      border-radius: 16px;
      background: rgba(239,68,68,.14);
      color: #b91c1c;
      font-weight: 900;
      cursor:pointer;
      -webkit-tap-highlight-color: transparent;
    }
    :root[data-theme="dark"] .dangerBtn{ color:#fecaca; background: rgba(239,68,68,.18); }
    .dangerBtn:active{ transform: scale(.99); }

    .stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px; /* Espacio entre el corazón y los badges */
  position: relative;
}

.badge {
  background: var(--badge);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 15px 20px;
  width: 160px; /* Tamaño fijo para que se vean uniformes */
  border: 1px solid rgba(255,255,255,0.1);
}

/* Estilo específico para el icono de oxígeno */
.spo2-badge .mini ion-icon {
  color: #35c7ff; /* Azul para oxígeno */
}