/* ==========================================================================
   Heart Wellness — site theme (2026)
   Brand: pulse red #dc2626 + charcoal #374151 (from the logo), on ECG-grid paper.
   Type:  Atkinson Hyperlegible Next — designed for low-vision readers.
   One signature element: the pulse trace from the logo, used for loading,
   sign-in, sign-out and registration progress.
   ========================================================================== */

@view-transition { navigation: auto; }

:root {
  --hw-red: #dc2626;
  --hw-red-deep: #b91c1c;
  --hw-red-ink: #7f1d1d;
  --hw-red-wash: #fef2f2;
  --hw-red-line: #fbd5d5;
  --hw-charcoal: #374151;
  --hw-ink: #1f2937;
  --hw-muted: #5b6472;
  --hw-line: #e4e6eb;
  --hw-bg: #f4f5f7;
  --hw-surface: #ffffff;
  --hw-paper: #fffafa;
  --hw-green: #15803d;
  --hw-green-wash: #ecfdf3;
  --hw-amber: #b45309;
  --hw-amber-wash: #fffbeb;

  --hw-font: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;

  --hw-r-sm: 8px;    /* chips, small controls */
  --hw-r-md: 12px;   /* inputs, buttons */
  --hw-r-lg: 18px;   /* panels, cards */
  --hw-shadow: 0 1px 2px rgba(31,41,55,.06), 0 8px 24px -12px rgba(31,41,55,.18);
  --hw-shadow-lift: 0 2px 4px rgba(31,41,55,.06), 0 22px 44px -18px rgba(127,29,29,.28);
  --hw-ease: cubic-bezier(.2,.8,.2,1);

  /* ECG paper: 1mm minor squares, 5mm major squares */
  --hw-grid:
    linear-gradient(rgba(220,38,38,.10) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(220,38,38,.10) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(rgba(220,38,38,.045) 1px, transparent 1px) 0 0 / 8px 8px,
    linear-gradient(90deg, rgba(220,38,38,.045) 1px, transparent 1px) 0 0 / 8px 8px;
}

/* ---------- Base ---------------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; }
.hw-body, .hw-body *, .hw-body *::before, .hw-body *::after,
.hw-nav, .hw-nav *, .hw-footer, .hw-footer *, .hw-overlay, .hw-overlay *, .hw-toasts * { box-sizing: border-box; }
body.hw-body { margin: 0; }
.hw-body [hidden], body.hw [hidden] { display: none !important; }
body.hw, .hw-body {
  font-family: var(--hw-font) !important;
  font-size: 17px;
  line-height: 1.55;
  color: var(--hw-ink);
  background: var(--hw-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.hw-body h1, .hw-body h2, .hw-body h3, .hw-body h4, .hw-body h5 { font-family: var(--hw-font); color: var(--hw-ink); letter-spacing: -0.015em; }
body.hw h1, body.hw h2, body.hw h3, body.hw h4, body.hw h5 { font-family: var(--hw-font); letter-spacing: -0.015em; }
body.hw .text-white :is(h1, h2, h3, h4, h5, h6, span, i) { color: inherit; }
.hw .tnum, .hw-num { font-variant-numeric: tabular-nums; }
.hw a { text-underline-offset: 3px; }
.hw :focus-visible { outline: 3px solid rgba(220,38,38,.45); outline-offset: 2px; border-radius: 6px; }
.hw-sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hw-skip { position: absolute; left: 12px; top: -60px; z-index: 3000; background: var(--hw-ink); color: #fff; padding: 10px 16px; border-radius: var(--hw-r-sm); transition: top .2s; }
.hw-skip:focus { top: 12px; }

/* ---------- Logo ---------------------------------------------------------- */
.hw-logo { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none !important; color: var(--hw-charcoal); }
.hw-logo__mark { width: 40px; height: 40px; flex: none; }
.hw-logo__mark .heart { fill: var(--hw-red); }
.hw-logo__mark .pulse { fill: none; stroke: #fff; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.hw-logo__word { font-weight: 800; font-size: 1.28rem; letter-spacing: -0.02em; line-height: 1; color: var(--hw-charcoal); }
.hw-logo__word b { color: var(--hw-red); font-weight: 800; }
.hw-logo--light .hw-logo__word { color: #fff; }

/* ---------- ECG trace (signature element) --------------------------------- */
.hw-ecg { display: block; width: 100%; height: 72px; overflow: visible; }
.hw-ecg path { fill: none; stroke: var(--hw-red); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.hw-ecg .ghost { stroke: rgba(220,38,38,.16); }
.hw-ecg .live { stroke-dasharray: var(--len, 2400); stroke-dashoffset: var(--len, 2400); }
.hw-ecg.is-drawing .live { animation: hw-draw var(--dur, 2.2s) var(--hw-ease) forwards; }
.hw-ecg.is-looping .live { animation: hw-sweep 2.4s linear infinite; }
.hw-ecg.is-flat .live { stroke: var(--hw-charcoal); }
@keyframes hw-draw { to { stroke-dashoffset: 0; } }
@keyframes hw-sweep { from { stroke-dashoffset: var(--len, 2400); } to { stroke-dashoffset: 0; } }

.hw-heartbeat { animation: hw-beat 1.1s ease-in-out infinite; transform-origin: center; }
@keyframes hw-beat { 0%,100% { transform: scale(1); } 14% { transform: scale(1.16); } 28% { transform: scale(1); } 42% { transform: scale(1.1); } 70% { transform: scale(1); } }

/* ---------- Buttons ------------------------------------------------------- */
.hw-btn {
  --b: var(--hw-red);
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  min-height: 50px; padding: .75rem 1.4rem;
  font: 700 1.02rem/1.1 var(--hw-font); letter-spacing: .005em;
  color: #fff; background: var(--b); border: 2px solid var(--b); border-radius: var(--hw-r-md);
  cursor: pointer; text-decoration: none !important; position: relative; overflow: hidden;
  transition: background-color .2s, border-color .2s, transform .15s var(--hw-ease), box-shadow .2s;
  box-shadow: 0 6px 16px -8px rgba(220,38,38,.6);
}
.hw-btn:hover { --b: var(--hw-red-deep); color: #fff; }
.hw-btn:active { transform: translateY(1px) scale(.99); }
.hw-btn[disabled], .hw-btn.is-busy { cursor: progress; opacity: .92; }
.hw-btn--block { width: 100%; }
.hw-btn--ghost { color: var(--hw-ink); background: transparent; border-color: var(--hw-line); box-shadow: none; }
.hw-btn--ghost:hover { color: var(--hw-red-deep); background: var(--hw-red-wash); border-color: var(--hw-red-line); }
.hw-btn--dark { --b: var(--hw-charcoal); box-shadow: 0 6px 16px -8px rgba(31,41,55,.55); }
.hw-btn--dark:hover { --b: var(--hw-ink); }
.hw-btn--light { color: var(--hw-red-deep); background: #fff; border-color: #fff; box-shadow: none; }
.hw-btn--light:hover { color: var(--hw-red-ink); background: #fff5f5; }
.hw-btn .hw-btn__beat { display: none; width: 22px; height: 22px; }
.hw-btn.is-busy .hw-btn__label { opacity: .0; }
.hw-btn.is-busy .hw-btn__beat { display: block; position: absolute; inset: 0; margin: auto; width: 64px; height: 26px; }
.hw-btn__beat path { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 34 140; animation: hw-sweep-btn 1s linear infinite; }
@keyframes hw-sweep-btn { from { stroke-dashoffset: 174; } to { stroke-dashoffset: 0; } }
.hw-link { color: var(--hw-red-deep); font-weight: 700; text-decoration: underline; text-decoration-thickness: 1.5px; text-decoration-color: rgba(185,28,28,.35); }
.hw-link:hover { color: var(--hw-red-ink); text-decoration-color: currentColor; }

/* ---------- Form fields --------------------------------------------------- */
.hw-field { display: grid; gap: .4rem; margin-bottom: 1.05rem; }
.hw-label { font-weight: 700; font-size: .95rem; color: var(--hw-charcoal); display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.hw-label small { font-weight: 400; color: var(--hw-muted); font-size: .85rem; }
.hw-input, .hw-select {
  width: 100%; min-height: 52px; padding: .8rem 1rem;
  font: 400 1.05rem/1.3 var(--hw-font); color: var(--hw-ink);
  background: #fff; border: 1.5px solid #cfd3da; border-radius: var(--hw-r-md);
  transition: border-color .18s, box-shadow .18s, background-color .18s;
  appearance: none;
}
.hw-input::placeholder { color: #9aa1ac; }
.hw-input:hover { border-color: #b4bac4; }
.hw-input:focus, .hw-select:focus { outline: none; border-color: var(--hw-red); box-shadow: 0 0 0 4px rgba(220,38,38,.14); }
.hw-input.is-invalid { border-color: var(--hw-red); background: #fffafa; }
.hw-input.is-valid { border-color: #86c79f; }
.hw-hint { font-size: .86rem; color: var(--hw-muted); margin: 0; }
.hw-hint:empty { display: none; }
.hw-hint.is-error { color: var(--hw-red-deep); font-weight: 700; }
.hw-pass { position: relative; }
.hw-pass .hw-input { padding-right: 4.2rem; }
.hw-pass__toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--hw-muted); font: 700 .85rem var(--hw-font); padding: .55rem .7rem; border-radius: var(--hw-r-sm); cursor: pointer; }
.hw-pass__toggle:hover { color: var(--hw-red-deep); background: var(--hw-red-wash); }
.hw-check { display: flex; gap: .75rem; align-items: flex-start; font-size: .96rem; color: var(--hw-charcoal); cursor: pointer; }
.hw-check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--hw-red); flex: none; }

/* 6-box one-time code */
.hw-otp { display: grid; grid-template-columns: repeat(6, 1fr); gap: .5rem; }
.hw-otp input { min-height: 62px; text-align: center; font: 800 1.6rem var(--hw-font); font-variant-numeric: tabular-nums; border: 1.5px solid #cfd3da; border-radius: var(--hw-r-md); background: #fff; color: var(--hw-ink); width: 100%; padding: 0; }
.hw-otp input:focus { outline: none; border-color: var(--hw-red); box-shadow: 0 0 0 4px rgba(220,38,38,.14); }

/* ---------- Alerts -------------------------------------------------------- */
.hw-alert { display: flex; gap: .75rem; align-items: flex-start; padding: .9rem 1rem; border-radius: var(--hw-r-md); font-size: .96rem; line-height: 1.45; border: 1px solid; margin-bottom: 1.1rem; }
.hw-alert i { margin-top: .18rem; }
.hw-alert--error { background: var(--hw-red-wash); color: var(--hw-red-ink); border-color: var(--hw-red-line); }
.hw-alert--ok { background: var(--hw-green-wash); color: #14532d; border-color: #bbe5cb; }
.hw-alert--info { background: #f3f4f6; color: var(--hw-charcoal); border-color: var(--hw-line); }
.hw-alert[hidden] { display: none; }
.hw-alert.is-in { animation: hw-pop-in .35s var(--hw-ease); }
@keyframes hw-pop-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.hw-shake { animation: hw-shake .42s cubic-bezier(.36,.07,.19,.97); }
@keyframes hw-shake { 10%,90% { transform: translateX(-1px); } 20%,80% { transform: translateX(3px); } 30%,50%,70% { transform: translateX(-6px); } 40%,60% { transform: translateX(6px); } }

/* ---------- Auth layout (login, register, logout, 2FA, reset) ------------- */
.hw-auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--hw-surface); }
.hw-auth__paper {
  position: relative; overflow: hidden; color: var(--hw-ink);
  background: var(--hw-grid), var(--hw-paper);
  padding: clamp(1.5rem, 4vw, 3.5rem); display: flex; flex-direction: column; justify-content: space-between; gap: 2rem;
  border-right: 1px solid var(--hw-red-line);
}
.hw-auth__paper .hw-ecg { height: clamp(90px, 14vw, 150px); margin: 0 calc(-1 * clamp(1.5rem, 4vw, 3.5rem)); width: calc(100% + 2 * clamp(1.5rem, 4vw, 3.5rem)); }
.hw-auth__lede { max-width: 30rem; }
.hw-auth__lede h1 { font-size: clamp(2.1rem, 3.6vw, 3.3rem); line-height: 1.04; font-weight: 800; margin: 0 0 1rem; letter-spacing: -0.03em; }
.hw-auth__lede p { font-size: 1.1rem; color: var(--hw-charcoal); margin: 0; max-width: 28rem; }
.hw-auth__foot { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: .9rem; color: var(--hw-muted); }
.hw-auth__foot a { color: var(--hw-muted); }
.hw-auth__panel { display: flex; align-items: center; justify-content: center; padding: clamp(1.5rem, 5vw, 4rem) clamp(1.1rem, 5vw, 4rem); }
.hw-auth__card { width: 100%; max-width: 27rem; }
.hw-auth__card--wide { max-width: 36rem; }
.hw-auth__card h2 { font-size: 1.9rem; font-weight: 800; margin: 0 0 .35rem; letter-spacing: -0.025em; }
.hw-auth__card .hw-sub { color: var(--hw-muted); margin: 0 0 1.75rem; font-size: 1.02rem; }
.hw-auth__alt { text-align: center; margin-top: 1.5rem; color: var(--hw-muted); font-size: .98rem; }
.hw-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin: .15rem 0 1.35rem; }

/* Sliding stages (password -> 2FA -> welcome) */
.hw-stages { position: relative; }
.hw-stage { transition: opacity .35s var(--hw-ease), transform .45s var(--hw-ease); }
.hw-stage[hidden] { display: none; }
.hw-stage.is-leaving { opacity: 0; transform: translateX(-28px); }
.hw-stage.is-entering { opacity: 0; transform: translateX(28px); }

/* Welcome / goodbye moment */
.hw-moment { text-align: center; padding: 1rem 0; }
.hw-moment__heart { width: 84px; height: 84px; margin: 0 auto 1.2rem; display: block; }
.hw-moment h2 { font-size: 2rem; margin-bottom: .4rem; }
.hw-moment p { color: var(--hw-muted); }

@media (max-width: 900px) {
  .hw-auth { grid-template-columns: 1fr; }
  .hw-auth__paper { border-right: 0; border-bottom: 1px solid var(--hw-red-line); padding-bottom: 0; gap: 1rem; }
  .hw-auth__lede h1 { font-size: 1.85rem; }
  .hw-auth__lede p { font-size: 1rem; }
  .hw-auth__foot { display: none; }
  .hw-auth__paper .hw-ecg { height: 70px; }
  .hw-auth__panel { align-items: flex-start; padding-top: 1.75rem; }
  .hw-auth__hide-sm { display: none !important; }
}

/* ---------- Full-screen overlay (logout / login success) ----------------- */
.hw-overlay {
  position: fixed; inset: 0; z-index: 5000; display: grid; place-items: center; text-align: center;
  background: var(--hw-grid), rgba(255,250,250,.97);
  opacity: 0; pointer-events: none; transition: opacity .35s var(--hw-ease);
  padding: 1.5rem;
}
.hw-overlay.is-on { opacity: 1; pointer-events: auto; }
.hw-overlay__inner { width: min(640px, 100%); }
.hw-overlay h2 { font: 800 clamp(1.6rem, 4vw, 2.3rem)/1.1 var(--hw-font); margin: 1rem 0 .4rem; color: var(--hw-ink); letter-spacing: -0.025em; }
.hw-overlay p { color: var(--hw-muted); margin: 0; font-size: 1.05rem; }
.hw-overlay .hw-ecg { height: 120px; }

/* ---------- Toasts -------------------------------------------------------- */
.hw-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 4000; display: grid; gap: .6rem; width: min(380px, calc(100vw - 32px)); }
.hw-toast { background: var(--hw-ink); color: #fff; border-radius: var(--hw-r-md); padding: .85rem 1rem; box-shadow: var(--hw-shadow-lift); font-size: .96rem; display: flex; gap: .7rem; align-items: flex-start; animation: hw-pop-in .3s var(--hw-ease); }
.hw-toast--error { background: var(--hw-red-ink); }

/* ---------- Site header (logged-in app + public) ------------------------- */
.hw-nav { position: sticky; top: 0; z-index: 1030; background: rgba(255,255,255,.92); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--hw-line); font-family: var(--hw-font); }
.hw-nav__bar { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem clamp(1rem, 3vw, 1.5rem); }
.hw-nav__links { display: flex; align-items: center; gap: .25rem; }
.hw-nav__link { display: inline-flex; align-items: center; gap: .45rem; padding: .6rem .85rem; border-radius: var(--hw-r-sm); font-weight: 700; font-size: .98rem; color: var(--hw-charcoal) !important; text-decoration: none !important; transition: background-color .15s, color .15s; }
.hw-nav__link i { color: #8b93a1; font-size: .92em; }
.hw-nav__link:hover { background: #f3f4f6; color: var(--hw-ink) !important; }
.hw-nav__link[aria-current="page"] { color: var(--hw-red-deep) !important; background: var(--hw-red-wash); }
.hw-nav__link[aria-current="page"] i { color: var(--hw-red); }
.hw-nav__menu { position: relative; }
.hw-nav__menu > button { border: 0; background: transparent; cursor: pointer; }
.hw-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--hw-red-wash); color: var(--hw-red-deep); display: inline-grid; place-items: center; font-weight: 800; font-size: .9rem; border: 1.5px solid var(--hw-red-line); }
.hw-dropdown { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: #fff; border: 1px solid var(--hw-line); border-radius: var(--hw-r-md); box-shadow: var(--hw-shadow-lift); padding: .4rem; opacity: 0; transform: translateY(-6px); pointer-events: none; transition: opacity .18s, transform .22s var(--hw-ease); }
.hw-nav__menu.is-open .hw-dropdown { opacity: 1; transform: none; pointer-events: auto; }
.hw-dropdown a, .hw-dropdown button { display: flex; width: 100%; align-items: center; gap: .65rem; padding: .65rem .75rem; border-radius: var(--hw-r-sm); color: var(--hw-ink) !important; text-decoration: none !important; font: 400 .98rem var(--hw-font); background: transparent; border: 0; cursor: pointer; text-align: left; }
.hw-dropdown a i, .hw-dropdown button i { width: 18px; color: #8b93a1; }
.hw-dropdown a:hover, .hw-dropdown button:hover { background: #f3f4f6; }
.hw-dropdown .is-danger { color: var(--hw-red-deep) !important; }
.hw-dropdown .is-danger i { color: var(--hw-red); }
.hw-dropdown hr { border: 0; border-top: 1px solid var(--hw-line); margin: .35rem .25rem; }
.hw-dropdown__who { padding: .55rem .75rem .65rem; font-size: .88rem; color: var(--hw-muted); }
.hw-dropdown__who strong { display: block; color: var(--hw-ink); font-size: 1rem; }
.hw-nav__burger { display: none; width: 46px; height: 46px; border: 1.5px solid var(--hw-line); border-radius: var(--hw-r-md); background: #fff; color: var(--hw-ink); cursor: pointer; font-size: 1.1rem; }
.hw-nav__drawer { display: none; }
.hw-impersonating { background: var(--hw-amber-wash); color: #78350f; border-bottom: 1px solid #fcd9a5; font: 700 .92rem var(--hw-font); text-align: center; padding: .5rem 1rem; }
.hw-impersonating a { color: #78350f; }

@media (max-width: 1080px) {
  .hw-nav__links { display: none; }
  .hw-nav__burger { display: inline-grid; place-items: center; }
  .hw-nav__drawer { display: block; max-height: 0; overflow: hidden; transition: max-height .35s var(--hw-ease); border-top: 1px solid transparent; }
  .hw-nav.is-open .hw-nav__drawer { max-height: 640px; border-top-color: var(--hw-line); }
  .hw-nav__drawer-inner { padding: .5rem clamp(1rem, 3vw, 1.5rem) 1rem; display: grid; gap: .15rem; }
  .hw-nav__drawer .hw-nav__link { padding: .85rem .75rem; font-size: 1.05rem; }
  .hw-nav__drawer .hw-btn { margin-top: .5rem; }
}

/* ---------- Footer -------------------------------------------------------- */
.hw-footer { background: var(--hw-ink); color: #c9ced6; font-family: var(--hw-font); }
.hw-footer__inner { max-width: 1240px; margin: 0 auto; padding: 2.5rem clamp(1rem, 3vw, 1.5rem); display: flex; justify-content: space-between; gap: 2rem; flex-wrap: wrap; align-items: flex-start; }
.hw-footer a { color: #e5e7eb; text-decoration: none; }
.hw-footer a:hover { color: #fff; text-decoration: underline; }
.hw-footer nav { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: .95rem; }
.hw-footer small { display: block; margin-top: .9rem; color: #9aa1ac; font-size: .85rem; max-width: 34rem; }

/* ==========================================================================
   Legacy page layer — restyles the existing Tailwind/Bootstrap markup on the
   dashboard, profile, billing, plans, admin and share pages without
   rewriting them. Scoped to body.hw so nothing leaks elsewhere.
   ========================================================================== */
body.hw { background: var(--hw-bg) !important; }
body.hw .container { max-width: 1240px; }

/* Panels */
body.hw .bg-white.rounded-xl, body.hw .bg-white.rounded-lg.shadow-lg, body.hw .bg-white.rounded-2xl,
body.hw .card {
  border-radius: var(--hw-r-lg) !important;
  border: 1px solid var(--hw-line) !important;
  box-shadow: var(--hw-shadow) !important;
}
body.hw .shadow-xl, body.hw .shadow-2xl { box-shadow: var(--hw-shadow) !important; }

/* Solid red / blue header bars become calm white headers with a red pulse tick */
body.hw .primary-bg.px-6.py-4, body.hw .bg-blue-600.px-6.py-4, body.hw .modal-header.primary-bg, body.hw .card-header.bg-danger, body.hw .card-header.bg-primary {
  background: #fff !important; color: var(--hw-ink) !important;
  border-bottom: 1px solid var(--hw-line); position: relative; padding-left: 1.75rem !important;
}
body.hw .primary-bg.px-6.py-4::before, body.hw .bg-blue-600.px-6.py-4::before, body.hw .modal-header.primary-bg::before {
  content: ""; position: absolute; left: 0; top: 50%; width: 5px; height: 26px; transform: translateY(-50%);
  background: var(--hw-red); border-radius: 0 4px 4px 0;
}
body.hw .primary-bg.px-6.py-4 h1, body.hw .primary-bg.px-6.py-4 h2, body.hw .primary-bg.px-6.py-4 h3, body.hw .primary-bg.px-6.py-4 h5,
body.hw .bg-blue-600.px-6.py-4 h2, body.hw .bg-blue-600.px-6.py-4 h3, body.hw .modal-header.primary-bg .modal-title { color: var(--hw-ink) !important; font-weight: 800; letter-spacing: -0.015em; }
body.hw .primary-bg.px-6.py-4 > * > i, body.hw .primary-bg.px-6.py-4 h2 i, body.hw .primary-bg.px-6.py-4 h3 i, body.hw .bg-blue-600.px-6.py-4 i { color: var(--hw-red) !important; }
body.hw .primary-bg.px-6.py-4 .text-white, body.hw .bg-blue-600.px-6.py-4 .text-white, body.hw .modal-header.primary-bg .text-white { color: var(--hw-ink) !important; }
body.hw .primary-bg.px-6.py-4 .bg-white, body.hw .primary-bg.px-6.py-4 button.bg-white, body.hw .primary-bg.px-6.py-4 a.bg-white {
  background: #fff !important; border: 1.5px solid var(--hw-red-line) !important; color: var(--hw-red-deep) !important; box-shadow: none !important; border-radius: var(--hw-r-md) !important;
}
body.hw .primary-bg.px-6.py-4 .bg-white:hover { background: var(--hw-red-wash) !important; }
body.hw .modal-header.primary-bg .btn-close-white { filter: none; }
body.hw .modal-content { border-radius: var(--hw-r-lg) !important; border: 0; overflow: hidden; }

/* Buttons */
body.hw button.primary-bg, body.hw a.primary-bg, body.hw .btn-danger, body.hw .btn-primary, body.hw button.bg-red-600, body.hw a.bg-red-600 {
  background: var(--hw-red) !important; border-color: var(--hw-red) !important; color: #fff !important;
  border-radius: var(--hw-r-md) !important; font-weight: 700 !important; font-family: var(--hw-font);
  box-shadow: 0 6px 16px -8px rgba(220,38,38,.6) !important; transition: background-color .2s, transform .15s var(--hw-ease) !important;
}
body.hw button.primary-bg:hover, body.hw a.primary-bg:hover, body.hw .btn-danger:hover, body.hw .btn-primary:hover, body.hw button.bg-red-600:hover, body.hw a.bg-red-600:hover { background: var(--hw-red-deep) !important; }
body.hw button.primary-bg:active, body.hw .btn-danger:active, body.hw .btn-primary:active { transform: translateY(1px); }
body.hw button.bg-blue-600, body.hw .btn-info { background: var(--hw-charcoal) !important; border-color: var(--hw-charcoal) !important; color: #fff !important; border-radius: var(--hw-r-md) !important; }
body.hw button.bg-blue-600:hover { background: var(--hw-ink) !important; }
body.hw .btn { border-radius: var(--hw-r-md); font-weight: 700; font-family: var(--hw-font); }
body.hw .btn-outline-danger { color: var(--hw-red-deep); border-color: var(--hw-red-line); }
body.hw .btn-outline-danger:hover { background: var(--hw-red-wash); color: var(--hw-red-ink); border-color: var(--hw-red); }

/* Inputs */
body.hw input.form-control, body.hw select.form-control, body.hw textarea.form-control, body.hw .form-select,
body.hw input[type="text"].border, body.hw input[type="number"].border, body.hw input[type="email"].border, body.hw input[type="password"].border, body.hw textarea.border, body.hw select.border {
  border: 1.5px solid #cfd3da !important; border-radius: var(--hw-r-md) !important; min-height: 48px; font-family: var(--hw-font); font-size: 1.02rem;
}
body.hw .form-control:focus, body.hw .form-select:focus, body.hw input.border:focus, body.hw textarea.border:focus, body.hw select.border:focus {
  border-color: var(--hw-red) !important; box-shadow: 0 0 0 4px rgba(220,38,38,.14) !important; outline: none;
}

/* Tables */
body.hw table thead th, body.hw table thead.bg-gray-50 th, body.hw .table thead th {
  background: #f8f9fb !important; color: var(--hw-muted) !important; font-weight: 700; text-transform: none !important; letter-spacing: 0 !important; font-size: .88rem;
}
body.hw table tbody tr { transition: background-color .15s; }
body.hw table tbody tr:hover { background: #fafbfc; }
body.hw td { font-variant-numeric: tabular-nums; }

/* Reading categories — keep the medical colour language, refine it */
body.hw .bp-normal { border-left-color: var(--hw-green) !important; background: var(--hw-green-wash) !important; }
body.hw .bp-elevated { border-left-color: #d97706 !important; }
body.hw .bp-hypertension2 { border-left-color: var(--hw-red) !important; background: var(--hw-red-wash) !important; }

/* Bootstrap alerts */
body.hw .alert { border-radius: var(--hw-r-md); border-width: 1px; }
body.hw .badge { font-family: var(--hw-font); }

/* Page intro hook — the only page-load motion in the app */
body.hw main { animation: hw-rise .5s var(--hw-ease) both; }
@keyframes hw-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Reduced motion ------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .hw-ecg .live { stroke-dashoffset: 0 !important; }
  @view-transition { navigation: none; }
}

/* ==========================================================================
   Feature components (dashboard extras, home week, settings, clinic, report)
   ========================================================================== */
.hw-grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; margin: 0 0 1.5rem; font-family: var(--hw-font); }
@media (max-width: 1100px) { .hw-grid3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px) { .hw-grid3 { grid-template-columns: 1fr; } }
.hw-card { background: #fff; border: 1px solid var(--hw-line); border-radius: var(--hw-r-lg); box-shadow: var(--hw-shadow); padding: 1.25rem 1.4rem 1.4rem; display: flex; flex-direction: column; gap: .75rem; font-family: var(--hw-font); color: var(--hw-ink); }
.hw-card__head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin: -.15rem 0 .1rem; }
.hw-card__head h2 { font-size: 1.15rem !important; font-weight: 800; margin: 0; display: flex; gap: .6rem; align-items: center; color: var(--hw-ink); }
.hw-card__head h2 i { color: var(--hw-red); font-size: .95em; }
.hw-card__lede { margin: 0; color: var(--hw-charcoal); font-size: .98rem; }
.hw-card__actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: auto; }
.hw-card__actions .hw-btn { flex: 1; min-height: 46px; padding: .55rem 1rem; }
.hw-card .hw-btn--block { margin-top: auto; min-height: 46px; }

.hw-bigavg { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
.hw-bigavg span { font-size: 2.6rem; font-weight: 800; letter-spacing: -0.04em; line-height: 1; }
.hw-bigavg small { color: var(--hw-muted); font-size: .9rem; }
.hw-pill { align-self: flex-start; display: inline-flex; gap: .4rem; align-items: center; font-weight: 700; font-size: .88rem; padding: .3rem .7rem; border-radius: 999px; }
.hw-pill.is-green { background: var(--hw-green-wash); color: #14532d; }
.hw-pill.is-amber { background: var(--hw-amber-wash); color: #92400e; }
.hw-pill.is-red { background: var(--hw-red-wash); color: var(--hw-red-ink); }
.hw-pill.is-blue { background: #eff6ff; color: #1e3a8a; }
.hw-pill.is-grey { background: #f3f4f6; color: var(--hw-charcoal); }
.hw-delta { font-size: .9rem; color: var(--hw-muted); }
.hw-mini { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem .9rem; margin: .25rem 0 0; padding-top: .75rem; border-top: 1px solid var(--hw-line); }
.hw-mini div { display: flex; flex-direction: column; }
.hw-mini dt { font-size: .82rem; color: var(--hw-muted); }
.hw-mini dd { margin: 0; font-weight: 700; font-size: 1.02rem; }

.hw-weekdots { list-style: none; padding: 0; margin: .25rem 0 0; display: grid; grid-template-columns: repeat(7, 1fr); gap: .35rem; }
.hw-weekdots li { display: grid; gap: .25rem; justify-items: center; padding: .4rem 0; border-radius: var(--hw-r-sm); }
.hw-weekdots li.is-today { background: var(--hw-red-wash); outline: 1.5px solid var(--hw-red-line); }
.hw-weekdots li.is-future { opacity: .5; }
.hw-weekdots .d { font-size: .75rem; font-weight: 700; color: var(--hw-muted); }
.hw-weekdots .slot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #cfd3da; background: #fff; }
.hw-weekdots .slot.half { border-color: var(--hw-red); background: linear-gradient(90deg, var(--hw-red) 50%, #fff 50%); }
.hw-weekdots .slot.full { border-color: var(--hw-red); background: var(--hw-red); }
.hw-weekdots li:first-child .slot { border-style: dashed; }

.hw-patterns { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.hw-patterns li { display: grid; grid-template-columns: 22px 1fr; gap: .55rem; font-size: .95rem; }
.hw-patterns i { color: var(--hw-red); margin-top: .2rem; }
.hw-shortcuts { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: auto; padding-top: .75rem; border-top: 1px solid var(--hw-line); }
.hw-shortcuts a { display: flex; gap: .5rem; align-items: center; padding: .6rem .7rem; border-radius: var(--hw-r-md); border: 1px solid var(--hw-line); color: var(--hw-ink) !important; text-decoration: none !important; font-weight: 700; font-size: .9rem; transition: background-color .15s, border-color .15s; min-width: 0; }
.hw-shortcuts a:hover { background: var(--hw-red-wash); border-color: var(--hw-red-line); }
.hw-shortcuts a i { color: var(--hw-red); width: 18px; text-align: center; flex: none; }
.hw-shortcuts a b { margin-left: auto; font-size: .75rem; background: var(--hw-red); color: #fff; padding: .05rem .45rem; border-radius: 999px; }

.hw-safety { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: start; background: var(--hw-red-ink); color: #fff; padding: 1.1rem 1.3rem; border-radius: var(--hw-r-lg); margin-bottom: 1.5rem; font-family: var(--hw-font); font-size: 1.02rem; line-height: 1.5; }
.hw-safety i { font-size: 1.5rem; color: #fecaca; margin-top: .1rem; }
.hw-safety a { color: #fff; font-weight: 800; text-decoration: underline; }

.hw-chips { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .45rem; font-family: var(--hw-font); }
.hw-chips legend { width: 100%; font-weight: 700; font-size: .92rem; color: var(--hw-charcoal); margin-bottom: .45rem; padding: 0; }
.hw-chips legend small { font-weight: 400; color: var(--hw-muted); }
.hw-chips label { cursor: pointer; margin: 0; }
.hw-chips input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.hw-chips span { display: inline-flex; gap: .4rem; align-items: center; padding: .45rem .75rem; border: 1.5px solid #d6d9df; border-radius: 999px; font-size: .9rem; color: var(--hw-charcoal); background: #fff; transition: all .15s; user-select: none; }
.hw-chips span i { color: #8b93a1; }
.hw-chips input:checked + span { border-color: var(--hw-red); background: var(--hw-red-wash); color: var(--hw-red-ink); font-weight: 700; }
.hw-chips input:checked + span i { color: var(--hw-red); }
.hw-chips input:focus-visible + span { outline: 3px solid rgba(220,38,38,.45); outline-offset: 2px; }
.hw-photo { display: grid; gap: .35rem; }
.hw-hint.is-ok { color: var(--hw-green); font-weight: 700; }
input.hw-filled { animation: hw-fill 1.6s var(--hw-ease); }
@keyframes hw-fill { 0% { background: #fde2e2; } 100% { background: #fff; } }

/* Page shell for new pages */
.hw-page { max-width: 1100px; margin: 0 auto; padding: clamp(1.25rem, 3vw, 2.25rem) clamp(1rem, 3vw, 1.5rem) 4rem; font-family: var(--hw-font); color: var(--hw-ink); }
.hw-page > header h1 { font-size: clamp(1.8rem, 3.5vw, 2.4rem); font-weight: 800; letter-spacing: -0.03em; margin: 0 0 .4rem; }
.hw-page > header p { color: var(--hw-charcoal); margin: 0 0 1.75rem; max-width: 46rem; font-size: 1.05rem; }
.hw-section { background: #fff; border: 1px solid var(--hw-line); border-radius: var(--hw-r-lg); box-shadow: var(--hw-shadow); padding: clamp(1.1rem, 3vw, 1.75rem); margin-bottom: 1.5rem; scroll-margin-top: 90px; }
.hw-section h2 { font-size: 1.3rem !important; font-weight: 800; margin: 0 0 .35rem; display: flex; gap: .6rem; align-items: center; }
.hw-section h2 i { color: var(--hw-red); }
.hw-section > p.hw-sub, .hw-section .hw-sub { color: var(--hw-muted); margin: 0 0 1.25rem; }
.hw-split { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .hw-split { grid-template-columns: 1fr; } }
.hw-toggle { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .85rem 0; border-top: 1px solid var(--hw-line); }
.hw-toggle:first-of-type { border-top: 0; }
.hw-toggle span b { display: block; }
.hw-toggle span small { color: var(--hw-muted); }
.hw-switch { position: relative; width: 52px; height: 30px; flex: none; }
.hw-switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 1; margin: 0; }
.hw-switch i { position: absolute; inset: 0; border-radius: 999px; background: #cfd3da; transition: background .2s; }
.hw-switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s var(--hw-ease); }
.hw-switch input:checked + i { background: var(--hw-red); }
.hw-switch input:checked + i::after { transform: translateX(22px); }
.hw-switch input:focus-visible + i { outline: 3px solid rgba(220,38,38,.45); outline-offset: 2px; }
.hw-list { list-style: none; margin: 0 0 1rem; padding: 0; border: 1px solid var(--hw-line); border-radius: var(--hw-r-md); }
.hw-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .85rem 1rem; border-top: 1px solid var(--hw-line); flex-wrap: wrap; }
.hw-list li:first-child { border-top: 0; }
.hw-list b { display: block; }
.hw-list small { color: var(--hw-muted); }
.hw-btn--sm { min-height: 40px; padding: .45rem .9rem; font-size: .92rem; }
.hw-table { width: 100%; border-collapse: collapse; font-size: .96rem; }
.hw-table th { text-align: left; font-weight: 700; font-size: .85rem; color: var(--hw-muted); padding: .6rem .75rem; border-bottom: 1px solid var(--hw-line); background: #f8f9fb; }
.hw-table td { padding: .75rem; border-bottom: 1px solid var(--hw-line); vertical-align: top; font-variant-numeric: tabular-nums; }
.hw-table tr:last-child td { border-bottom: 0; }
.hw-table-wrap { overflow-x: auto; border: 1px solid var(--hw-line); border-radius: var(--hw-r-md); }
.hw-empty { text-align: center; padding: 2rem 1rem; color: var(--hw-muted); }
.hw-table-wrap .hw-table { min-width: 640px; }
@media (max-width: 640px) { .hw-section { padding: 1rem; } .hw-toggle { align-items: flex-start; } }
