:root {
      --red: #e64e68;
      --red2: #c93652;
      --ink: #222634;
      --muted: #72788a;
      --line: #e7e9ef;
      --bg: #f6f7fb;
      --card: #fff;
      --good: #169565;
    }
    * {
      box-sizing: border-box;
    }
    body {
      margin: 0;
      background: var(--bg);
      color: var(--ink);
      font-family: Inter, system-ui, -apple-system, sans-serif;
    }
    button, input {
      font: inherit;
    }
    button {
      cursor: pointer;
    }
    button:disabled {
      opacity: 0.65;
      cursor: not-allowed;
    }
    .view {
      display: none;
      min-height: 100vh;
    }
    .view.active {
      display: grid;
    }
    .auth {
      grid-template-columns: 44% 1fr;
    }
    .aside {
      padding: 46px clamp(28px, 6vw, 88px);
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      color: #fff;
      background: linear-gradient(150deg, #9e183d, #e64e68 58%, #ff9b92);
    }
    .brand {
      display: flex;
      align-items: center;
      gap: 10px;
      font-size: 20px;
      font-weight: 850;
    }
    .mark {
      width: 36px;
      height: 36px;
      display: grid;
      place-items: center;
      background: #fff;
      color: var(--red);
      border-radius: 11px;
      font-size: 20px;
    }
    .aside h1 {
      margin: 0;
      font-size: clamp(36px, 4vw, 56px);
      line-height: 1.08;
      letter-spacing: -2px;
    }
    .aside p {
      max-width: 360px;
      color: #ffe6e9;
      line-height: 1.65;
      margin-top: 16px;
    }
    .legal {
      color: #ffe1e6;
      font-size: 13px;
    }
    .auth-panel {
      display: grid;
      place-items: center;
      padding: 32px;
    }
    .form {
      width: min(100%, 410px);
    }
    .form h2 {
      margin: 0 0 8px;
      font-size: 31px;
      letter-spacing: -1px;
    }
    .lead {
      margin: 0 0 22px;
      color: var(--muted);
      line-height: 1.55;
    }
    .banner-info {
      background: #fff9e6;
      border: 1px solid #fed776;
      color: #8c6000;
      padding: 10px 14px;
      border-radius: 10px;
      font-size: 13px;
      margin-bottom: 20px;
      line-height: 1.45;
    }
    .field {
      margin: 15px 0;
    }
    .field label {
      display: block;
      margin-bottom: 7px;
      font-size: 14px;
      font-weight: 750;
    }
    .field input {
      width: 100%;
      height: 51px;
      border: 1px solid var(--line);
      border-radius: 11px;
      padding: 0 14px;
      outline: 0;
      background: #fff;
      color: var(--ink);
    }
    .field input:focus {
      border-color: var(--red);
      box-shadow: 0 0 0 4px #e64e681c;
    }
    .primary {
      width: 100%;
      height: 51px;
      margin-top: 10px;
      border: 0;
      border-radius: 11px;
      background: var(--red);
      color: #fff;
      font-weight: 800;
      transition: background 0.15s ease;
    }
    .primary:hover:not(:disabled) {
      background: var(--red2);
    }
    .switch-text {
      margin: 23px 0 0;
      text-align: center;
      color: var(--muted);
      font-size: 14px;
    }
    .switch-text a {
      color: var(--red);
      font-weight: 800;
      text-decoration: none;
    }
    .message {
      min-height: 22px;
      margin: 12px 0 0;
      text-align: center;
      color: var(--red);
      font-size: 13px;
      font-weight: 600;
      line-height: 1.4;
    }
    .message.success {
      color: var(--good);
    }

    /* Estilos del panel una vez iniciada la sesión */
    .app {
      grid-template-columns: 230px 1fr;
    }
    .side {
      min-height: 100vh;
      padding: 25px 15px;
      color: #fff;
      background: #25283a;
    }
    .side .brand {
      margin: 0 10px 36px;
    }
    .side .mark {
      color: #25283a;
    }
    .nav {
      display: grid;
      gap: 5px;
    }
    .nav button {
      display: flex;
      align-items: center;
      gap: 11px;
      padding: 12px;
      border: 0;
      border-radius: 9px;
      color: #c7c9d6;
      background: transparent;
      text-align: left;
    }
    .nav button.active, .nav button:hover {
      color: #fff;
      background: #ffffff18;
    }
    .sidebar-account {
      margin-top: 32px;
      padding: 15px 10px 0;
      border-top: 1px solid #ffffff20;
    }

    .sidebar-user-label {
      color: #c7c9d6;
      font-size: 11px;
      text-transform: uppercase;
      letter-spacing: 0.7px;
    }

    .sidebar-account h2 {
      margin: 8px 0 12px;
      color: #fff;
      font-size: 18px;
      line-height: 1.4;
      overflow-wrap: anywhere;
    }

    .sidebar-profile-edit {
      width: 100%;
      padding: 9px 10px;
      border: 1px solid #ffffff30;
      border-radius: 8px;
      color: #fff;
      background: #ffffff10;
      text-align: left;
      cursor: pointer;
    }

    .sidebar-profile-edit:hover {
      background: #ffffff20;
    }

    .sidebar-account .logout {
      margin: 10px 0 0;
      width: 100%;
    }

    .logout {
      margin: 35px 10px 0;
      width: calc(100% - 20px);
      border: 0;
      border-radius: 9px;
      padding: 10px;
      color: #fff;
      background: #ffffff15;
      transition: background 0.15s ease;
    }
    .logout:hover {
      background: #ffffff2b;
    }
    .dashboard {
      width: min(100%, 1050px);
      padding: 42px;
      margin: auto;
    }
    .top {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 20px;
      margin-bottom: 30px;
    }
    .top h1 {
      margin: 3px 0 0;
      font-size: 29px;
      letter-spacing: -1px;
    }
    .top small {
      color: var(--muted);
    }
    .badge {
      padding: 8px 11px;
      border-radius: 30px;
      background: #e1f8ed;
      color: var(--good);
      font-size: 12px;
      font-weight: 800;
    }
    .grid {
      display: grid;
      grid-template-columns: 1.4fr 1fr 1fr;
      gap: 17px;
    }
    .card {
      padding: 21px;
      border: 1px solid var(--line);
      border-radius: 16px;
      background: var(--card);
      box-shadow: 0 5px 15px #22263408;
    }
    .card h3 {
      margin: 0 0 17px;
      font-size: 14px;
    }
    .pulse {
      grid-row: span 2;
      text-align: center;
    }
    .heart {
      font-size: 53px;
      color: var(--red);
      animation: beat 1.5s ease-in-out infinite alternate;
    }
    @keyframes beat {
      0% { transform: scale(1); }
      100% { transform: scale(1.1); }
    }
    .bpm {
      margin-top: 5px;
      font-size: 57px;
      font-weight: 850;
      letter-spacing: -3px;
    }
    .unit, .card small {
      color: var(--muted);
    }
    .state {
      margin-top: 10px;
      color: var(--good);
      font-size: 14px;
      font-weight: 700;
    }
    .metric b {
      display: block;
      margin-top: 8px;
      font-size: 21px;
    }
    .metric {
      min-height: 122px;
    }
    .wide {
      grid-column: span 2;
    }
        .record-list {
      display: grid;
      gap: 12px;
      margin-top: 14px;
    }

    .record-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      flex-wrap: wrap;
      padding: 14px;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: var(--bg);
    }

    .record-info {
      min-width: 0;
      overflow-wrap: anywhere;
    }

    .record-info strong {
      display: block;
      margin-bottom: 5px;
    }

    .record-info small {
      color: var(--muted);
      line-height: 1.5;
    }

    .record-actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
    }

    .record-actions button {
      border: 0;
      border-radius: 8px;
      padding: 9px 12px;
      font-weight: 700;
    }

    .edit-button {
      background: #e8edff;
      color: #3049a5;
    }

    .delete-button {
      background: #ffe8ec;
      color: #a51e39;
    }

    .secondary {
      width: 100%;
      min-height: 44px;
      margin-top: 10px;
      border: 1px solid var(--line);
      border-radius: 11px;
      background: white;
      color: var(--ink);
      font-weight: 700;
    }
	.danger {
      border-color: #ffcbd2;
      background: #fff6f7;
    }
    .empty {
      color: var(--muted);
      font-size: 14px;
      line-height: 1.5;
    }
    .modal {
      position: fixed;
      inset: 0;
      z-index: 10;
      display: none;
      place-items: center;
      padding: 20px;
      background: #1718268a;
    }
    .modal.show {
      display: grid;
    }
    .modal-card {
      width: min(100%, 430px);
      padding: 25px;
      border-radius: 16px;
      background: #fff;
    }
    .modal-card h2 {
      margin-top: 0;
    }
    .modal-card button + button {
      margin-top: 8px;
    }
    .secondary {
      width: 100%;
      padding: 12px;
      border: 1px solid var(--line);
      border-radius: 9px;
      background: #fff;
    }
    .device-key {
      padding: 11px;
      border-radius: 8px;
      overflow-wrap: anywhere;
      background: #f5f6fa;
      font: 12px ui-monospace, monospace;
    }

    @media (max-width: 760px) {
      .auth {
        display: block !important;
      }
      .aside {
        display: none;
      }
      .auth-panel {
        min-height: 100vh;
        padding: 28px 22px;
      }
      .app {
        display: block !important;
      }
      .side {
        min-height: auto;
        padding: 15px;
        position: sticky;
        top: 0;
        z-index: 2;
      }
      .side .brand {
        margin: 0 0 12px;
      }
      .nav {
        display: flex;
        overflow: auto;
      }
      .nav button {
        white-space: nowrap;
      }
      .logout {
        display: none;
      }
      .dashboard {
        padding: 26px 18px;
      }
      .top {
        align-items: flex-start;
      }
      .grid {
        grid-template-columns: 1fr 1fr;
      }
      .pulse {
        grid-column: span 2;
        grid-row: auto;
      }
      .wide {
        grid-column: span 2;
      }
    }
    @media (max-width: 410px) {
      .grid {
        grid-template-columns: 1fr;
      }
      .pulse, .wide {
        grid-column: span 1;
      }
      .top h1 {
        font-size: 25px;
      }
      .badge {
        font-size: 10px;
      }
    }

/* Calendario de seguimiento cardíaco */
.heart-history-card {
  min-width: 0;
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.calendar-toolbar strong {
  text-align: center;
  text-transform: capitalize;
  font-size: 1.05rem;
}

.calendar-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
}

.calendar-nav:hover {
  border-color: var(--good);
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 16px 0 12px;
  color: var(--muted);
  font-size: 0.8rem;
}

.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
}

.legend-dot.has-readings {
  border-color: var(--good);
  background: var(--good);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.calendar-weekday {
  padding: 8px 0;
  color: var(--muted);
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
}

.calendar-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 48px;
  padding: 6px 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.calendar-day:disabled {
  border-color: transparent;
  background: transparent;
  cursor: default;
}

.calendar-day:not(:disabled):hover {
  border-color: var(--good);
}

.calendar-day.has-data {
  border-color: var(--good);
}

.calendar-day.selected {
  outline: 2px solid var(--good);
  outline-offset: 1px;
}

.calendar-day.today .day-number {
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.day-number {
  font-size: 0.9rem;
}

.day-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
}

.calendar-day.has-data .day-indicator {
  background: var(--good);
}

.calendar-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.calendar-stat {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.calendar-stat small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}

.calendar-stat strong {
  display: block;
  margin-top: 5px;
  font-size: 1.15rem;
  overflow-wrap: anywhere;
}

.selected-day {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.selected-day h4 {
  margin: 0 0 12px;
}

@media (max-width: 520px) {
  .calendar-grid {
    gap: 4px;
  }

  .calendar-day {
    min-height: 42px;
    border-radius: 7px;
  }

  .calendar-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calendar-legend {
    gap: 8px 12px;
  }
}


    .dashboard-section {
      display: none;
    }

    .dashboard-section.active {
      display: block;
    }

    .daily-summary-card {
      min-width: 0;
    }

    .nav button {
      cursor: pointer;
    }





/* ==========================================
   A.M.A.R. — Botón SOS y confirmación
   ========================================== */

.sos-button {
  position: fixed;
  z-index: 9;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: min(420px, calc(100% - 32px));
  min-height: 60px;
  margin: 0;
  padding: 14px 22px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 18px;
  background: linear-gradient(135deg, #e53945, #b91f32);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: .04em;
  box-shadow: 0 8px 24px rgba(185,31,50,.30);
  cursor: pointer;
  transition: background 180ms ease, box-shadow 180ms ease;
}

.sos-button::before {
  content: "!";
  display: grid;
  place-items: center;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 50%;
  font-size: 1.2rem;
  font-weight: 900;
}

.sos-button:hover {
  background: linear-gradient(135deg, #f04450, #c91f35);
  box-shadow: 0 10px 28px rgba(185,31,50,.38);
}

.sos-button:focus-visible,
.sos-confirm-button:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 4px;
}

.sos-button:disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* El modal real de index.html usa #modalContent */
#modal.show #modalContent:has(.sos-confirmation) {
  width: min(100%, 440px);
  padding: 30px 26px 24px;
  border: 1px solid rgba(229,57,69,.12);
  border-radius: 24px;
  background: #fff;
  color: #20232a;
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
}

.sos-confirmation {
  text-align: center;
}

.sos-confirmation-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  border: 8px solid #fdebed;
  border-radius: 50%;
  background: #d92f40;
  color: #fff;
  font-size: 1.8rem;
  font-weight: 900;
}

.sos-confirmation h2 {
  margin: 0 0 12px;
  color: #20232a;
  font-size: 1.55rem;
  line-height: 1.2;
}

.sos-confirmation > p {
  color: #656b75;
  font-size: .95rem;
  line-height: 1.55;
}

.sos-countdown {
  margin: 22px 0;
  padding: 16px;
  border: 1px solid #f5d4d8;
  border-radius: 14px;
  background: #fff5f6;
  color: #5c2630 !important;
}

#manualSOSCountdown {
  display: inline-block;
  min-width: 1.5em;
  color: #c52236;
  font-size: 1.8rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.sos-confirm-button {
  display: block;
  width: 100%;
  min-height: 52px;
  margin: 0 0 10px;
  padding: 14px 18px;
  border: 0;
  border-radius: 13px;
  background: #d92f40;
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.sos-confirm-button:hover {
  background: #b91f32;
}

.sos-confirmation button.secondary {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 0;
  padding: 12px 18px;
  border: 1px solid #d9dce2;
  border-radius: 13px;
  background: #f5f6f8;
  color: #343943;
  font-weight: 700;
  cursor: pointer;
}

.sos-confirmation button.secondary:hover {
  background: #e9ebef;
}

.sos-confirmation .sos-disclaimer {
  margin: 18px 0 0;
  padding-top: 15px;
  border-top: 1px solid #eceef1;
  color: #747a84;
  font-size: .8rem;
  line-height: 1.5;
}

@media (max-width: 480px) {
  #modal.show #modalContent:has(.sos-confirmation) {
    padding: 26px 20px 20px;
    border-radius: 20px;
  }

  .sos-button {
    bottom: max(14px, env(safe-area-inset-bottom));
    width: calc(100% - 28px);
    min-height: 58px;
  }
}


/* =========================================================
   A.M.A.R. PULSE — Sistema visual renovado
   La paleta completa está documentada en README-PALETA.md.
   ========================================================= */
:root {
  color-scheme: dark;
  --red: #FF5D70;
  --red2: #E7475D;
  --ink: #F1F5F9;
  --muted: #9AAAC0;
  --line: #28384D;
  --bg: #0B1220;
  --card: #131F32;
  --good: #35D07F;
  --text: #F1F5F9;
  --panel-raised: #192941;
  --teal: #20D6C2;
  --cyan: #55B8FF;
  --amber: #FFBE55;
  --radius-card: 20px;
  --shadow-card: 0 18px 44px rgba(0, 0, 0, .18);
}
* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 78% -12%, rgba(32,214,194,.10), transparent 35%),
    radial-gradient(ellipse at 0% 100%, rgba(85,184,255,.06), transparent 34%),
    var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
}
.view { min-height: 100vh; }
.auth { grid-template-columns: minmax(300px, 44%) 1fr; }
.aside {
  position: relative;
  overflow: hidden;
  padding: clamp(32px, 5vw, 72px);
  background:
    radial-gradient(circle at 15% 82%, rgba(85,184,255,.22), transparent 32%),
    linear-gradient(145deg, #142B42 0%, #0F2639 45%, #0B1220 100%);
  border-right: 1px solid rgba(85,184,255,.14);
}
.aside::after {
  content: "";
  position: absolute;
  width: 360px; height: 360px;
  right: -190px; bottom: -160px;
  border: 1px solid rgba(32,214,194,.20);
  border-radius: 50%;
  box-shadow: 0 0 0 35px rgba(32,214,194,.025), 0 0 0 75px rgba(32,214,194,.02);
  pointer-events: none;
}
.brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #F7FBFF;
  font-size: 21px;
  font-weight: 850;
  letter-spacing: .06em;
}
.mark {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px; height: 42px;
  border: 1px solid rgba(32,214,194,.48);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(32,214,194,.22), rgba(85,184,255,.10));
  color: var(--teal);
  box-shadow: 0 8px 24px rgba(0,0,0,.18), inset 0 1px rgba(255,255,255,.08);
  font-size: 20px;
}
.mark svg { width: 24px; height: 24px; }
.aside h1 {
  max-width: 540px;
  margin: 0;
  font-size: clamp(38px, 4.3vw, 62px);
  line-height: 1.04;
  letter-spacing: -.055em;
}
.aside p { max-width: 390px; color: #B6C8D9; font-size: 16px; line-height: 1.8; }
.legal { color: #91A8BC; line-height: 1.6; }
.auth-panel { padding: clamp(24px, 5vw, 64px); }
.form { width: min(100%, 430px); }
.form h2 { color: var(--ink); font-size: clamp(29px, 3vw, 36px); letter-spacing: -.04em; }
.lead, .switch-text { color: var(--muted); }
.field label { color: #DCE7F2; font-size: 13px; letter-spacing: .015em; }
.field input {
  height: 52px;
  border: 1px solid #31445C;
  border-radius: 13px;
  background: #0F1A2B;
  color: var(--ink);
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.field input::placeholder { color: #70839B; }
.field input:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(32,214,194,.12); }
.primary {
  min-height: 50px;
  border-radius: 13px;
  background: linear-gradient(110deg, #20BFAF, #20D6C2);
  color: #06201F;
  font-weight: 850;
  box-shadow: 0 8px 20px rgba(32,214,194,.13);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.primary:hover:not(:disabled) { background: linear-gradient(110deg, #28D4C2, #63E7D8); transform: translateY(-1px); box-shadow: 0 12px 26px rgba(32,214,194,.20); }
.switch-text a { color: var(--teal); }
.message { color: #FF8795; }
.message.success { color: var(--good); }

/* Navegación y espacio de trabajo */
.app { grid-template-columns: 254px minmax(0, 1fr); }
.side {
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 620px;
  display: flex;
  flex-direction: column;
  padding: 28px 17px 20px;
  border-right: 1px solid #223249;
  background: rgba(13, 23, 38, .94);
  backdrop-filter: blur(18px);
}
.side .brand { margin: 0 9px 42px; }
.side .mark { color: var(--teal); }
.nav { display: grid; gap: 7px; }
.nav button {
  position: relative;
  min-height: 47px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #9EADC0;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease;
}
.nav button.active {
  border-color: rgba(32,214,194,.15);
  color: #DFFFFA;
  background: linear-gradient(90deg, rgba(32,214,194,.16), rgba(32,214,194,.04));
}
.nav button.active::before {
  content: "";
  position: absolute;
  left: -1px; top: 10px; bottom: 10px;
  width: 3px; border-radius: 0 4px 4px 0;
  background: var(--teal);
}
.nav button:hover { color: #F1F5F9; background: #1B2A3F; transform: translateX(2px); }
.sidebar-account { margin-top: auto; padding: 20px 8px 0; border-top: 1px solid #25364B; }
.sidebar-user-label { color: #8498AE; font-size: 10px; letter-spacing: .12em; }
.sidebar-account h2 { font-size: 16px; }
.sidebar-profile-edit, .logout {
  min-height: 42px;
  border: 1px solid #2B4057;
  border-radius: 11px;
  color: #CFDCE9;
  background: #17263A;
  transition: background .18s ease, border-color .18s ease;
}
.sidebar-profile-edit:hover, .logout:hover { background: #22364D; border-color: #42617D; }
.sidebar-account .logout { margin: 9px 0 0; width: 100%; }
.dashboard {
  width: min(100%, 1480px);
  min-width: 0;
  padding: clamp(24px, 3.8vw, 54px);
}
.top {
  min-height: 76px;
  margin-bottom: 30px;
  padding-bottom: 23px;
  border-bottom: 1px solid rgba(68,91,117,.35);
}
.top h1 { margin: 2px 0 4px; color: var(--ink); font-size: clamp(26px, 2.5vw, 34px); letter-spacing: -.045em; }
.top small { color: var(--muted); }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid #30435A;
  border-radius: 999px;
  background: #16263A;
  color: #B9CADB;
  font-size: 11px;
  letter-spacing: .01em;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px rgba(255,190,85,.10); }
.grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: stretch; }
.card {
  min-width: 0;
  padding: clamp(18px, 2vw, 25px);
  border: 1px solid #25374D;
  border-radius: var(--radius-card);
  background: linear-gradient(145deg, rgba(22,36,56,.98), rgba(17,30,48,.98));
  box-shadow: var(--shadow-card);
  transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
  animation: card-enter .45s both;
}
.card:hover { border-color: #38516B; box-shadow: 0 22px 50px rgba(0,0,0,.22); }
.card h3 { color: #DDE8F3; font-size: 14px; letter-spacing: .005em; }
.card h4 { color: #C8D7E6; }
.pulse {
  grid-row: span 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 35%, rgba(32,214,194,.13), transparent 42%),
    linear-gradient(145deg, #182B42, #121F32);
  border-color: #2C4A5D;
}
.pulse h3 { align-self: flex-start; }
.heart { color: var(--teal); filter: drop-shadow(0 0 18px rgba(32,214,194,.25)); }
@keyframes beat { 0% { transform: scale(1); } 100% { transform: scale(1.075); } }
.bpm { color: #F5FAFF; font-size: clamp(54px, 5vw, 72px); letter-spacing: -.065em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.unit, .card small { color: #91A4B9; }
.state { color: var(--teal); font-size: 12px; line-height: 1.6; }
.metric { min-height: 132px; }
.metric b { color: #F1F5F9; font-size: clamp(18px, 1.7vw, 24px); overflow-wrap: anywhere; }
.wide { grid-column: span 2; }
.record-list { gap: 10px; }
.record-item { border-color: #293C53; border-radius: 13px; background: #101D2F; }
.record-info strong { color: #E7EFF7; }
.record-info small { color: #9AAEC2; }
.record-actions button { min-height: 38px; padding: 9px 13px; transition: filter .18s ease, transform .18s ease; }
.record-actions button:hover { filter: brightness(1.12); transform: translateY(-1px); }
.edit-button { background: rgba(85,184,255,.13); color: #83CCFF; }
.delete-button { background: rgba(255,93,112,.13); color: #FF9AA7; }
.secondary {
  min-height: 44px;
  border: 1px solid #34475D;
  border-radius: 12px;
  background: #192A40;
  color: #D7E3EE;
  transition: background .18s ease, border-color .18s ease;
}
.secondary:hover { background: #21364F; border-color: #49627C; }
.empty { color: #92A5BA; }
.danger { border-color: rgba(255,93,112,.28); background: linear-gradient(145deg, rgba(50,31,48,.60), rgba(22,31,48,.98)); }
.modal { background: rgba(3,9,18,.76); backdrop-filter: blur(8px); }
.modal-card {
  max-height: min(88vh, 760px);
  overflow: auto;
  border: 1px solid #30445B;
  border-radius: 22px;
  background: #132137;
  color: var(--ink);
  box-shadow: 0 30px 100px rgba(0,0,0,.5);
}
.modal-card h2 { color: #F1F5F9; }
.modal-card p { color: #A9B9CA; }
.device-key { background: #0B1627; color: #B8D0E4; border: 1px solid #2B4057; }

/* Seguimiento e historial */
.calendar-nav, .calendar-day { border-color: #2B3F56; background: #101D2F; color: #D9E6F2; }
.calendar-nav:hover, .calendar-day:not(:disabled):hover { border-color: var(--teal); }
.calendar-day.has-data { border-color: rgba(32,214,194,.5); background: rgba(32,214,194,.07); }
.calendar-day.selected { outline-color: var(--teal); }
.calendar-day.today .day-number { color: var(--cyan); }
.legend-dot { border-color: #50647A; }
.legend-dot.has-readings, .calendar-day.has-data .day-indicator { border-color: var(--teal); background: var(--teal); }
.calendar-stat { border-color: #2A3D53; background: #101D2F; border-radius: 12px; }
.calendar-stat strong { color: #EDF5FC; }
.selected-day { border-top-color: #2A3D53; }
.calendar-legend, .calendar-weekday { color: #94A9BE; }

/* SOS visible sin tapar el contenido del panel */
.sos-button {
  position: relative;
  left: auto;
  bottom: auto;
  transform: none;
  width: 100%;
  min-height: 52px;
  margin-top: 24px;
  padding: 11px 15px;
  border: 1px solid rgba(255,93,112,.34);
  border-radius: 13px;
  background: linear-gradient(120deg, #E7475D, #C82E48);
  box-shadow: 0 8px 22px rgba(231,71,93,.17);
  font-size: 12px;
  letter-spacing: .035em;
}
.sos-button:hover { transform: translateY(-1px); box-shadow: 0 12px 25px rgba(231,71,93,.23); }
.sos-button::before { flex-basis: 25px; width: 25px; height: 25px; font-size: 1rem; }
#modal.show #modalContent:has(.sos-confirmation) {
  border-color: rgba(255,93,112,.22);
  background: #172338;
  color: #F1F5F9;
}
.sos-confirmation h2 { color: #F1F5F9; }
.sos-confirmation > p { color: #A7B6C7; }
.sos-countdown { border-color: rgba(255,93,112,.22); background: rgba(255,93,112,.08); color: #F3C7CD !important; }
.sos-confirmation button.secondary { border-color: #34475D; background: #1A2A40; color: #D8E4EF; }
.sos-confirmation .sos-disclaimer { border-top-color: #2C3D52; color: #96A8BA; }
@keyframes card-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 1080px) {
  .app { grid-template-columns: 220px minmax(0,1fr); }
  .dashboard { padding: 28px 24px; }
  .grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .pulse { grid-row: span 2; }
}
@media (max-width: 760px) {
  .auth { display: block !important; }
  .aside { display: none; }
  .auth-panel { min-height: 100vh; padding: 30px 22px; }
  .app { display: block !important; }
  .side {
    position: sticky; top: 0; z-index: 5;
    height: auto; min-height: 0;
    padding: 12px 14px 10px;
    border-right: 0; border-bottom: 1px solid #263950;
    background: rgba(11,18,32,.94);
  }
  .side .brand { margin: 0 0 10px; font-size: 18px; }
  .side .mark { flex-basis: 34px; width: 34px; height: 34px; border-radius: 11px; }
  .side .mark svg { width: 20px; height: 20px; }
  .nav { display: flex; gap: 6px; overflow-x: auto; padding: 1px 0 3px; scrollbar-width: thin; }
  .nav button { flex: 0 0 auto; min-height: 42px; padding: 10px 12px; font-size: 12px; }
  .nav button.active::before { left: 10px; right: 10px; top: auto; bottom: -1px; width: auto; height: 2px; }
  .nav button:hover { transform: none; }
  .sidebar-account { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 10px 0 0; }
  .sidebar-user-label { display: none; }
  .sidebar-account h2 { flex: 1; min-width: 0; margin: 0; font-size: 13px; }
  .sidebar-profile-edit { width: auto; padding: 8px 10px; font-size: 12px; }
  .sidebar-account .logout { display: block; width: auto; margin: 0; padding: 8px 10px; font-size: 12px; }
  .dashboard { padding: 24px 16px 36px; }
  .top { align-items: flex-start; margin-bottom: 20px; padding-bottom: 18px; }
  .top h1 { font-size: 26px; }
  .grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
  .pulse { grid-column: span 2; grid-row: auto; padding: 25px 20px; }
  .wide { grid-column: span 2; }
  .card { border-radius: 16px; padding: 18px; }
  .sos-button { margin-top: 20px; }
}
@media (max-width: 480px) {
  .dashboard { padding: 18px 12px 28px; }
  .top { flex-direction: column; gap: 12px; }
  .top h1 { font-size: 24px; }
  .grid { grid-template-columns: minmax(0,1fr); gap: 11px; }
  .pulse, .wide { grid-column: span 1; }
  .pulse { padding: 22px 18px; }
  .metric { min-height: 0; }
  .metric b { font-size: 21px; }
  .card { padding: 17px; }
  .calendar-summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .calendar-grid { gap: 4px; }
  .calendar-day { min-height: 40px; }
  .calendar-legend { gap: 8px; font-size: 11px; }
  .sidebar-account { flex-wrap: wrap; }
  .sidebar-account h2 { flex-basis: 100%; }
  .sidebar-profile-edit, .sidebar-account .logout { flex: 1; }
  .record-item { align-items: flex-start; }
  .record-actions { width: 100%; }
  .record-actions button { flex: 1; }
  .modal { padding: 12px; }
  .modal-card { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}


/* Jerarquía del encabezado del panel */
.top-heading { min-width: 0; }
.top-heading > small {
  display: block;
  margin-bottom: 5px;
  color: var(--teal);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .16em;
}
.top-heading h1 { margin: 0 0 5px; }
.top-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
@media (max-width: 760px) {
  .top-heading p { max-width: 42ch; }
}


/* =========================================================
   SPA behavior: una sola vista visible en cualquier pantalla.
   Este bloque debe permanecer al final para prevalecer sobre
   las reglas responsive anteriores.
   ========================================================= */
.view:not(.active) {
  display: none !important;
}
.view.active {
  animation: spa-view-enter .22s ease-out both;
}
@keyframes spa-view-enter {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}
.dashboard-section:not(.active) {
  display: none !important;
}
.dashboard-section.active {
  display: block;
  animation: spa-section-enter .2s ease-out both;
}
@keyframes spa-section-enter {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (max-width: 760px) {
  /* En móvil cambia la distribución, nunca la visibilidad de vistas. */
  .view.auth.active { display: block !important; }
  .view.app.active { display: block !important; }
  .view:not(.active) { display: none !important; }
  .dashboard-section:not(.active) { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .view.active, .dashboard-section.active {
    animation: none !important;
  }
}


/* Contacto directo y onda animada de A.M.A.R. */
.record-actions .call-button,
.record-actions .email-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 13px;
  border-radius: 9px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 750;
}
.record-actions .call-button { background: rgba(53,208,127,.13); color: #7DE8A8; }
.record-actions .email-button { background: rgba(32,214,194,.12); color: #6DE6D9; }
.record-actions .email-button[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.heartbeat-visual {
  width: min(100%, 320px);
  margin: 10px 0 16px;
  opacity: .58;
  transition: opacity .25s ease;
}
.heartbeat-visual.is-live { opacity: 1; }
.heartbeat-visual svg { display: block; width: 100%; height: auto; overflow: visible; }
.heartbeat-grid { fill: none; stroke: #38516B; stroke-width: 1; stroke-dasharray: 3 6; }
.heartbeat-wave {
  fill: none;
  stroke: var(--teal);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 18 8;
  animation: heartbeat-trace var(--beat-duration, 1s) linear infinite;
  filter: drop-shadow(0 0 4px rgba(32,214,194,.45));
}
.heartbeat-visual small { display: block; margin-top: 3px; text-align: center; color: var(--muted); font-size: 10px; }
@keyframes heartbeat-trace { to { stroke-dashoffset: -52; } }
@media (prefers-reduced-motion: reduce) {
  .heartbeat-wave { animation: none; }
}


/* Acceso a WhatsApp en las acciones de contactos SOS */
.record-actions .whatsapp-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 9px 13px;
  border: 1px solid #1f9d55;
  border-radius: 9px;
  background: #168447;
  color: #fff;
  font: inherit;
  font-size: .9rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.record-actions .whatsapp-button:hover {
  background: #116b39;
}

.record-actions .whatsapp-button:focus-visible {
  outline: 3px solid #6ee7a0;
  outline-offset: 3px;
}


/* =========================================================
   SOS — jerarquía visual, legibilidad y acciones de contacto
   ========================================================= */
#modal.show #modalContent:has(.sos-confirmation) {
  width: min(100%, 560px);
  max-height: min(88dvh, 820px);
  overflow-y: auto;
  padding: clamp(20px, 4vw, 30px);
  border: 1px solid rgba(255,93,112,.24);
  border-radius: 24px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(231,71,93,.13), transparent 55%),
    linear-gradient(155deg, #17263B 0%, #111D2F 70%, #0F1A2B 100%);
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(0,0,0,.48), 0 0 0 1px rgba(255,255,255,.025) inset;
}
.sos-confirmation {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}
.sos-confirmation .sos-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 4px;
}
.sos-confirmation .sos-confirmation-icon {
  flex: 0 0 54px;
  width: 54px;
  height: 54px;
  margin: 0;
  border: 1px solid rgba(255,255,255,.28);
  background: linear-gradient(145deg, #FF687A, #D92F49);
  box-shadow: 0 8px 24px rgba(231,71,93,.24);
}
.sos-confirmation .sos-kicker {
  display: block;
  margin-bottom: 5px;
  color: #FF8290;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.sos-confirmation h2 {
  margin: 0;
  color: #F7FAFD;
  font-size: clamp(1.25rem, 4vw, 1.6rem);
  line-height: 1.2;
  letter-spacing: -.025em;
}
.sos-confirmation > p {
  margin: 0;
  color: #B5C4D4;
  font-size: .91rem;
  line-height: 1.65;
}
.sos-confirmation .sos-result-status {
  padding: 14px 15px;
  border: 1px solid rgba(53,208,127,.22);
  border-radius: 14px;
  background: rgba(53,208,127,.075);
  color: #D5FBE3;
}
.sos-confirmation .sos-result-status strong {
  color: #8EF0B2;
}
.sos-confirmation .sos-result-status.is-partial {
  border-color: rgba(255,190,85,.28);
  background: rgba(255,190,85,.07);
  color: #FFE7BC;
}
.sos-emergency-contacts {
  margin: 4px 0;
  padding: 16px;
  border: 1px solid #2B4058;
  border-radius: 16px;
  background: rgba(8,17,30,.42);
}
.sos-emergency-contacts h3 {
  margin: 0 0 6px;
  color: #F0F6FC;
  font-size: .98rem;
}
.sos-emergency-contacts > p {
  margin: 0 0 12px;
  color: #9FB2C6;
  font-size: .82rem;
  line-height: 1.55;
}
.sos-contact-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.sos-contact-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid #2A3D53;
  border-radius: 12px;
  background: #15243A;
}
.sos-contact-item > strong {
  min-width: 0;
  color: #EAF2FA;
  overflow-wrap: anywhere;
}
.sos-contact-item .record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 0;
}
.sos-contact-item .record-actions a {
  min-height: 36px;
  border-radius: 9px;
  font-size: .78rem;
}
.sos-contact-item small {
  width: 100%;
  color: #9FB2C6;
  line-height: 1.5;
}
.sos-confirmation .sos-disclaimer {
  margin: 0;
  padding: 13px 14px;
  border: 1px solid #2B4057;
  border-radius: 12px;
  background: rgba(8,17,30,.3);
  color: #9FB2C6;
  font-size: .78rem;
  line-height: 1.6;
}
.sos-confirmation > button.primary {
  width: 100%;
  min-height: 48px;
  margin-top: 2px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  background: linear-gradient(110deg, #E7475D, #C92F49);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(231,71,93,.16);
}
.sos-confirmation > button.primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
@media (max-width: 480px) {
  #modal.show #modalContent:has(.sos-confirmation) {
    width: 100%;
    max-height: 91dvh;
    padding: 17px;
    border-radius: 19px;
  }
  .sos-emergency-contacts { padding: 12px; }
  .sos-contact-item { align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  .sos-confirmation > button.primary:hover { transform: none; }
}


/* Pulido del dashboard principal: jerarquía, profundidad y consistencia */
.dashboard {
  background:
    radial-gradient(ellipse at 8% 0%, rgba(32,214,194,.045), transparent 34%),
    radial-gradient(ellipse at 96% 14%, rgba(85,184,255,.035), transparent 30%),
    var(--bg);
}
.dashboard .top {
  align-items: center;
  gap: 18px;
}
.dashboard .grid {
  align-items: stretch;
}
.dashboard .card {
  position: relative;
  overflow: hidden;
  border-color: rgba(62,86,112,.62);
}
.dashboard .card:hover {
  border-color: rgba(85,184,255,.34);
  transform: translateY(-2px);
}
.dashboard .pulse {
  border-color: rgba(32,214,194,.28);
  background:
    radial-gradient(ellipse at 50% 28%, rgba(32,214,194,.15), transparent 48%),
    linear-gradient(145deg, #192C43 0%, #131F32 72%);
}
.dashboard .pulse::after {
  position: absolute;
  top: 0;
  right: 22px;
  left: 22px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(32,214,194,.55), transparent);
  content: "";
  pointer-events: none;
}
.dashboard .metric {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  background: linear-gradient(145deg, rgba(22,36,56,.96), rgba(15,27,44,.98));
}
.dashboard .metric > small {
  color: #9DB1C5;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .105em;
  text-transform: uppercase;
}
.dashboard .metric > b {
  line-height: 1.28;
}
.dashboard .daily-summary-card,
.dashboard .wide:not(.danger) {
  background: linear-gradient(145deg, rgba(21,35,54,.98), rgba(15,27,44,.98));
}
.dashboard .danger {
  border-color: rgba(255,93,112,.24);
  background:
    radial-gradient(ellipse at 100% 0%, rgba(255,93,112,.07), transparent 42%),
    linear-gradient(145deg, rgba(38,30,46,.88), rgba(17,29,46,.98));
}
.dashboard .sos-button {
  min-height: 54px;
  margin-top: 22px;
  border-radius: 14px;
  background: linear-gradient(110deg, #F04F65 0%, #D92F49 100%);
  box-shadow: 0 10px 24px rgba(217,47,73,.2), 0 1px 0 rgba(255,255,255,.13) inset;
  font-size: 12px;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.dashboard .sos-button:hover {
  box-shadow: 0 13px 28px rgba(217,47,73,.28), 0 1px 0 rgba(255,255,255,.17) inset;
}
.dashboard .sos-button:focus-visible {
  outline: 3px solid #55B8FF;
  outline-offset: 4px;
}
@media (max-width: 760px) {
  .dashboard .top { align-items: flex-start; }
  .dashboard .card:hover { transform: none; }
}


/* Acciones de contactos: una misma geometría para Llamar, Editar y Eliminar. */
.record-actions {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
}
.record-actions > .call-button,
.record-actions > .edit-button,
.record-actions > .delete-button {
  box-sizing: border-box;
  display: inline-flex;
  flex: 1 1 88px;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  min-height: 40px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.record-actions > .call-button {
  border-color: rgba(53,208,127,.18);
  background: rgba(53,208,127,.13);
  color: #7DE8A8;
}
.record-actions > .edit-button {
  border-color: rgba(85,184,255,.2);
  background: rgba(85,184,255,.13);
  color: #83CCFF;
}
.record-actions > .delete-button {
  border-color: rgba(255,93,112,.2);
  background: rgba(255,93,112,.13);
  color: #FF9AA7;
}
.record-actions > .call-button:hover,
.record-actions > .edit-button:hover,
.record-actions > .delete-button:hover {
  filter: brightness(1.12);
}
.record-actions > .call-button:focus-visible,
.record-actions > .edit-button:focus-visible,
.record-actions > .delete-button:focus-visible {
  outline: 2px solid #55B8FF;
  outline-offset: 2px;
}
@media (max-width: 480px) {
  .record-actions {
    width: 100%;
    gap: 6px;
  }
  .record-actions > .call-button,
  .record-actions > .edit-button,
  .record-actions > .delete-button {
    flex: 1 1 0;
    min-width: 0;
    min-height: 42px;
    padding-inline: 6px;
  }
}
