/* ============================================================
   SPS V2 — Graphic Template V2
   Same colour palette, completely refreshed components.
   ============================================================ */

/* ── 1. TOKENS ─────────────────────────────────────────────── */
:root {
  color-scheme: light;

  --color-bg:            #eaf7ff;
  --color-bg-subtle:     #dff2fb;
  --color-surface:       #ffffff;
  --color-surface-raised:#ffffff;
  --color-surface-muted: #f7faf9;
  --color-border:        #d7e5ec;
  --color-border-strong: #b9cbd4;
  --color-text:          #32414d;
  --color-text-muted:    #61717d;
  --color-heading:       #2f3f4b;
  --color-accent:        #eb0015;
  --color-accent-strong: #cc0013;
  --color-accent-soft:   #ffe4e7;
  --color-warning:       #a15c05;
  --color-warning-soft:  #fff0cf;
  --color-success:       #157347;
  --color-success-soft:  #def7ea;
  --color-focus:         #e60016;

  --shadow-card: 0 1px 3px rgba(56,78,92,.07), 0 4px 18px rgba(56,78,92,.07);
  --shadow-soft: 0 8px 40px rgba(56,78,92,.13);

  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;

  --radius-1:   4px;
  --radius-2:   8px;
  --radius-3:   14px;
  --radius-full: 999px;

  --font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-xs:   .75rem;
  --font-sm:   .875rem;
  --font-md:   1rem;
  --font-lg:   1.25rem;
  --font-xl:   1.75rem;
  --font-2xl:  2.25rem;

  --lh-tight:  1.2;
  --lh-normal: 1.55;

  --motion-fast:   140ms;
  --motion-normal: 200ms;

  --sidebar-w:       220px;
  --topbar-h:        68px;
  --brand-panel-pct: 42%;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --color-bg:            #111c24;
  --color-bg-subtle:     #172b38;
  --color-surface:       #1e2b34;
  --color-surface-raised:#263744;
  --color-surface-muted: #17232c;
  --color-border:        #344b59;
  --color-border-strong: #536a78;
  --color-text:          #edf5f8;
  --color-text-muted:    #adbdc6;
  --color-heading:       #ffffff;
  --color-accent:        #ff3648;
  --color-accent-strong: #ff6b78;
  --color-accent-soft:   #4a1720;
  --color-warning:       #f0b35d;
  --color-warning-soft:  #4a3417;
  --color-success:       #65d596;
  --color-success-soft:  #1b3d2b;
  --color-focus:         #7fc8ff;

  --shadow-card: 0 1px 3px rgba(0,0,0,.22), 0 4px 18px rgba(0,0,0,.16);
  --shadow-soft: 0 8px 40px rgba(0,0,0,.28);
}

/* ── 2. RESET / BASE ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--color-bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--color-text);
  background: var(--color-bg);
  font-family: var(--font-family);
  font-size: var(--font-md);
  line-height: var(--lh-normal);
}

h1, h2, h3, p { margin: 0; }

h1, h2, h3, strong { color: var(--color-heading); }

h1 {
  font-size: clamp(1.6rem, 3vw, var(--font-2xl));
  font-weight: 900;
  line-height: var(--lh-tight);
}

h2 {
  font-size: var(--font-lg);
  font-weight: 800;
  line-height: 1.25;
}

button, input, select { font: inherit; }

a {
  color: var(--color-accent-strong);
  transition: color var(--motion-fast);
}

button, a {
  transition:
    background-color var(--motion-fast),
    border-color var(--motion-fast),
    color var(--motion-fast),
    box-shadow var(--motion-fast),
    transform var(--motion-fast);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--color-focus) 42%, transparent);
  outline-offset: 2px;
}

/* ── 3. UTILITY ─────────────────────────────────────────────── */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

/* ── 4. SHARED UI ELEMENTS ──────────────────────────────────── */

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--font-xs);
  font-weight: 800;
}

.badge::before {
  content: "";
  display: block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .7;
}

.badge-success {
  color: var(--color-success);
  background: var(--color-success-soft);
}

.badge-warning {
  color: var(--color-warning);
  background: var(--color-warning-soft);
}

/* Eyebrow label */
.eyebrow {
  color: var(--color-accent);
  font-size: var(--font-xs);
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 36px;
  padding: 0 var(--space-3);
  color: var(--color-text-muted);
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  cursor: pointer;
  font-size: var(--font-sm);
  font-weight: 700;
}

.theme-toggle:hover { color: var(--color-heading); }

.toggle-track {
  position: relative;
  flex: 0 0 auto;
  width: 36px; height: 20px;
  background: var(--color-border-strong);
  border-radius: var(--radius-full);
}

.toggle-thumb {
  position: absolute;
  top: 3px; left: 3px;
  width: 14px; height: 14px;
  background: var(--color-surface);
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
  transition: transform var(--motion-normal);
}

:root[data-theme="dark"] .toggle-thumb { transform: translateX(16px); }

.toggle-label { min-width: 32px; }

/* Language select */
.lang-select {
  min-height: 36px;
  padding: 0 var(--space-3);
  color: var(--color-text);
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  cursor: pointer;
  font-weight: 700;
  font-size: var(--font-sm);
}

/* ── 5. AUTH / LOGIN PAGE ───────────────────────────────────── */

.auth-page {
  display: grid;
  grid-template-columns: var(--brand-panel-pct) 1fr;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Brand panel (left) ── */
.auth-brand {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100vh;
  padding: var(--space-10) var(--space-8);
  background: var(--color-accent);
  overflow: hidden;
}

/* ECG decoration SVG — full width, positioned behind content */
.auth-ecg-bg {
  position: absolute;
  top: 50%;
  left: -5%;
  right: -5%;
  width: 110%;
  height: 90px;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: .18;
}

.auth-ecg-bg polyline {
  fill: none;
  stroke: #ffffff;
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Brand identity */
.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
}

.brand-mark-icon {
  display: inline-grid;
  place-items: center;
  width: 46px; height: 46px;
  color: var(--color-accent);
  background: #ffffff;
  border-radius: var(--radius-2);
  font-size: 0;
}

.brand-mark-icon svg {
  width: 26px; height: 26px;
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-mark-name {
  display: grid;
  line-height: 1.15;
}

.brand-mark-name strong {
  color: #ffffff;
  font-size: 1.3rem;
  font-weight: 900;
}

.brand-mark-name span {
  color: rgba(255,255,255,.72);
  font-size: var(--font-sm);
  font-weight: 700;
}

/* Hero copy */
.auth-hero {
  position: relative;
  z-index: 1;
  margin-top: var(--space-10);
}

.auth-hero-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: 26px;
  padding: 0 var(--space-3);
  color: rgba(255,255,255,.9);
  background: rgba(255,255,255,.18);
  border-radius: var(--radius-full);
  font-size: var(--font-xs);
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: var(--space-5);
}

.auth-hero h1 {
  color: #ffffff;
  font-size: clamp(1.7rem, 2.8vw, 2.4rem);
  font-weight: 900;
  line-height: 1.15;
  margin-bottom: var(--space-4);
}

.auth-hero p {
  color: rgba(255,255,255,.78);
  font-size: var(--font-md);
  max-width: 400px;
  line-height: 1.6;
}

/* Feature list */
.auth-features {
  position: relative;
  z-index: 1;
  display: grid;
  gap: var(--space-3);
  list-style: none;
  margin: 0;
  padding: 0;
}

.auth-features li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  color: rgba(255,255,255,.82);
  font-size: var(--font-sm);
}

.auth-features li::before {
  content: "✓";
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 20px; height: 20px;
  color: var(--color-accent);
  background: #ffffff;
  border-radius: 50%;
  font-size: .65rem;
  font-weight: 900;
  margin-top: 1px;
}

/* ── Centered single-card auth layout ── */
.auth-centered {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: var(--space-8);
  background: var(--color-bg);
}

.login-card {
  width: min(100%, 420px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-3);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

/* Brand strip at top of login card */
.login-card-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5) var(--space-8);
  background: var(--color-surface-muted);
  border-bottom: 1px solid var(--color-border);
}

.login-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
}

.login-brand-icon {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: #ffffff;
  background: var(--color-accent);
  border-radius: var(--radius-2);
  box-shadow: 0 4px 12px rgba(235,0,21,.22);
  flex: 0 0 auto;
}

.login-brand-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.login-brand-text {
  display: grid;
  line-height: 1.2;
}

.login-brand-text strong {
  color: var(--color-heading);
  font-size: 1.05rem;
  font-weight: 900;
}

.login-brand-text small {
  color: var(--color-text-muted);
  font-size: var(--font-xs);
  font-weight: 600;
}

.login-card-head {
  padding: var(--space-6) var(--space-8);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-muted);
}

.login-card-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-1);
}

.login-card-head h2 {
  font-size: 1.18rem;
  font-weight: 900;
  margin-bottom: 0;
}

.login-card-head p {
  color: var(--color-text-muted);
  font-size: var(--font-sm);
}

/* Minimal language toggle inside the card heading */
.lang-select-mini {
  height: 26px;
  padding: 0 var(--space-2);
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-1);
  cursor: pointer;
  font-size: var(--font-xs);
  font-weight: 700;
  letter-spacing: .02em;
  transition: border-color var(--motion-fast), color var(--motion-fast);
}

.lang-select-mini:hover {
  border-color: var(--color-border-strong);
  color: var(--color-heading);
}

.lang-select-mini:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--color-focus) 40%, transparent);
  outline-offset: 2px;
}

.login-card-body {
  padding: var(--space-8);
}

/* Form stack */
.form-stack {
  display: grid;
  gap: var(--space-5);
}

.field {
  display: grid;
  gap: var(--space-2);
}

.field label {
  color: var(--color-heading);
  font-size: var(--font-sm);
  font-weight: 700;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 13px;
  z-index: 1;
  display: inline-grid;
  place-items: center;
  width: 18px; height: 18px;
  color: var(--color-text-muted);
  pointer-events: none;
}

.input-icon svg {
  width: 18px; height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.field input {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-4);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-2);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}

.input-wrap input { padding-left: 42px; }

.field input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--color-accent) 60%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 12%, transparent);
}

.field input::placeholder { color: var(--color-text-muted); }

.password-wrap { position: relative; }

.password-wrap input { padding-right: 44px; }

.password-eye {
  position: absolute;
  top: 50%; right: 14px;
  transform: translateY(-50%);
  width: 18px; height: 12px;
  border: 2px solid var(--color-border-strong);
  border-radius: 50% / 40%;
  pointer-events: none;
}

.password-eye::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 5px; height: 5px;
  background: var(--color-border-strong);
  border-radius: 50%;
}

/* Form row (remember + reset) */
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--font-sm);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  min-height: 0;
  width: 16px; height: 16px;
  padding: 0;
  border-radius: var(--radius-1);
  accent-color: var(--color-accent);
}

.text-link {
  color: var(--color-accent);
  font-size: var(--font-sm);
  font-weight: 700;
  text-decoration: none;
}

.text-link:hover { text-decoration: underline; }

/* Submit button */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 46px;
  padding: 0 var(--space-5);
  color: #ffffff;
  background: var(--color-accent);
  border: none;
  border-radius: var(--radius-2);
  cursor: pointer;
  font-size: var(--font-md);
  font-weight: 800;
  letter-spacing: .01em;
  box-shadow: 0 4px 14px rgba(235,0,21,.24);
  margin-top: var(--space-2);
}

.btn-primary:hover {
  background: var(--color-accent-strong);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(235,0,21,.28);
}

.btn-primary:active { transform: translateY(0); }

/* Audit note */
.audit-note {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  color: var(--color-text-muted);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  font-size: var(--font-xs);
  line-height: 1.5;
}

/* Form footer */
.auth-form-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-8);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: var(--font-xs);
}

.auth-form-footer strong {
  color: var(--color-text);
  font-weight: 700;
}

.footer-dot {
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--color-border-strong);
}

/* ── 6. APP SHELL / DASHBOARD ───────────────────────────────── */

.app-page { overflow-x: hidden; }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
}

.sidebar-top {
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
}

.sidebar-brand-mark {
  display: inline-grid;
  place-items: center;
  width: 36px; height: 36px;
  color: #ffffff;
  background: var(--color-accent);
  border-radius: var(--radius-2);
}

.sidebar-brand-mark svg {
  width: 20px; height: 20px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-brand-text {
  display: grid;
  line-height: 1.2;
}

.sidebar-brand-text strong {
  color: var(--color-heading);
  font-size: .92rem;
  font-weight: 900;
}

.sidebar-brand-text small {
  color: var(--color-text-muted);
  font-size: var(--font-xs);
  font-weight: 600;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: var(--space-4);
}

.nav-section-label {
  padding: var(--space-2) var(--space-2) var(--space-1);
  color: var(--color-text-muted);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.nav-items {
  display: grid;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 40px;
  padding: 0 var(--space-3);
  color: var(--color-text-muted);
  border-radius: var(--radius-2);
  border-left: 3px solid transparent;
  text-decoration: none;
  font-size: var(--font-sm);
  font-weight: 600;
  transition:
    background-color var(--motion-fast),
    color var(--motion-fast),
    border-color var(--motion-fast);
}

.nav-link:hover {
  color: var(--color-heading);
  background: var(--color-accent-soft);
}

.nav-link.is-active {
  color: var(--color-accent);
  background: var(--color-accent-soft);
  border-left-color: var(--color-accent);
  font-weight: 700;
}

.nav-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 22px; height: 22px;
}

.nav-icon svg {
  width: 18px; height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Sidebar footer — user card + logout */
.sidebar-footer {
  padding: var(--space-3) var(--space-4) var(--space-4);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  min-width: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 1px;
}

.sidebar-user-info strong {
  font-size: var(--font-sm);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-info small {
  color: var(--color-text-muted);
  font-size: var(--font-xs);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  width: 100%;
  min-height: 36px;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  cursor: pointer;
  font-size: var(--font-sm);
  font-weight: 700;
  transition: color var(--motion-fast), border-color var(--motion-fast), background-color var(--motion-fast);
}

.btn-logout:hover {
  color: var(--color-accent);
  border-color: color-mix(in srgb, var(--color-accent) 40%, transparent);
  background: var(--color-accent-soft);
}

/* Icon-only theme toggle for topbar */
.btn-theme-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  cursor: pointer;
  transition: color var(--motion-fast), background-color var(--motion-fast);
  flex: 0 0 auto;
}

.btn-theme-icon:hover {
  color: var(--color-heading);
  background: var(--color-surface-muted);
}

.btn-theme-icon svg {
  width: 17px; height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Show moon in light mode, sun in dark mode */
:root[data-theme="light"] .icon-sun  { display: none; }
:root[data-theme="dark"]  .icon-moon { display: none; }

/* Mini language select in topbar */
.topbar .lang-select-mini {
  height: 38px;
  padding: 0 var(--space-3);
  font-size: var(--font-xs);
}

/* ── Main panel ── */
.main-panel {
  min-width: 0;
  padding: var(--space-6) var(--space-8);
  background: var(--color-bg);
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.topbar-left {}

.topbar-left h1 {
  font-size: 1.45rem;
  font-weight: 900;
  margin-top: var(--space-1);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* User chip */
.user-chip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
}

.user-avatar {
  display: inline-grid;
  place-items: center;
  width: 32px; height: 32px;
  color: var(--color-accent-strong);
  background: var(--color-accent-soft);
  border-radius: 50%;
  font-size: var(--font-xs);
  font-weight: 900;
}

.user-chip-text { display: grid; line-height: 1.25; }

.user-chip-text strong {
  font-size: var(--font-sm);
  font-weight: 700;
}

.user-chip-text small {
  color: var(--color-text-muted);
  font-size: var(--font-xs);
  font-weight: 600;
}

/* ── Metric cards ── */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.metric-card {
  position: relative;
  display: grid;
  gap: var(--space-1);
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-accent);
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* Clickable metric card — stretch link over the whole card */
.metric-card-link {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-2);
  z-index: 0;
}

.metric-card:has(.metric-card-link):hover {
  box-shadow: 0 0 0 2px var(--color-accent);
  cursor: pointer;
}

.metric-card-icon {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  display: inline-grid;
  place-items: center;
  width: 32px; height: 32px;
  color: var(--color-accent);
  background: var(--color-accent-soft);
  border-radius: var(--radius-2);
}

.metric-card-icon svg {
  width: 17px; height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.metric-label {
  color: var(--color-text-muted);
  font-size: var(--font-xs);
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  padding-right: 40px;
}

.metric-value {
  color: var(--color-heading);
  font-size: 1.9rem;
  font-weight: 900;
  line-height: 1.1;
  margin-top: var(--space-1);
}

.metric-trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: var(--space-2);
  font-size: var(--font-xs);
  font-weight: 700;
}

.metric-trend.positive { color: var(--color-success); }
.metric-trend.neutral  { color: var(--color-text-muted); }

.metric-trend.positive::before { content: "↑ "; }

/* ── Content grid ── */
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(260px, 0.7fr);
  gap: var(--space-5);
}

/* ── Panel ── */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.panel-head-text h2 { font-size: 1rem; font-weight: 800; }
.panel-head-text p { margin-top: 2px; }

/* Ghost button */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 34px;
  padding: 0 var(--space-3);
  color: var(--color-accent-strong);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  cursor: pointer;
  font-size: var(--font-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.btn-ghost:hover {
  background: var(--color-accent-soft);
  border-color: transparent;
}

/* Danger button — irreversible destructive actions */
.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 34px;
  padding: 0 var(--space-3);
  color: #fff;
  background: var(--color-accent);
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-2);
  cursor: pointer;
  font-size: var(--font-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.btn-danger:hover {
  background: var(--color-accent-strong);
  border-color: var(--color-accent-strong);
}

/* Danger panel — visually distinct danger zone */
.panel--danger {
  border-color: var(--color-accent) !important;
}

.panel--danger .panel-head {
  background: var(--color-accent-soft);
  border-bottom-color: var(--color-accent);
}

.btn-ghost svg {
  width: 14px; height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

/* ── Table ── */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

thead th {
  padding: var(--space-3) var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--font-xs);
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
  text-align: left;
  background: var(--color-surface-muted);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background-color var(--motion-fast);
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--color-bg-subtle); }

td {
  padding: var(--space-3) var(--space-4);
  color: var(--color-text);
  font-size: var(--font-sm);
  vertical-align: middle;
  white-space: nowrap;
}

.patient-list-filter {
  display: flex;
  align-items: end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface-muted);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.patient-list-filter .field {
  min-width: min(100%, 320px);
}

.sortable-heading {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.sort-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.sort-arrow {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 9px;
  line-height: 1;
  text-decoration: none;
}

.sort-arrow:hover,
.sort-arrow.is-active {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-soft);
}

.patient-table-link {
  font-weight: 600;
  color: var(--color-accent);
  text-decoration: none;
}

.patient-table-link:hover { text-decoration: underline; }

.mono-muted {
  font-family: ui-monospace, monospace;
  font-size: var(--font-xs);
  color: var(--color-text-muted);
}

.text-muted-nowrap {
  color: var(--color-text-muted);
  font-size: var(--font-sm);
  white-space: nowrap;
}

/* Patients table — specific column overrides */
.patient-list-table td.col-patient,
.patient-list-table td.col-facility {
  white-space: normal;
  word-break: break-word;
  min-width: 100px;
}

/* Patient cell with avatar */
.patient-cell {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.patient-avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px; height: 30px;
  color: var(--color-accent-strong);
  background: var(--color-accent-soft);
  border-radius: 50%;
  font-size: .65rem;
  font-weight: 900;
}

/* ── Sync timeline ── */
.timeline-body {
  padding: var(--space-5);
  display: grid;
  gap: var(--space-4);
}

.timeline-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: var(--space-3);
  align-items: start;
}

.timeline-dot {
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  color: var(--color-accent);
  background: var(--color-accent-soft);
  border-radius: 50%;
  font-size: var(--font-xs);
  font-weight: 900;
  flex: 0 0 auto;
}

.timeline-content { display: grid; gap: 3px; }

.timeline-content strong {
  font-size: var(--font-sm);
  font-weight: 700;
  line-height: 1.3;
}

.timeline-content span {
  color: var(--color-text-muted);
  font-size: var(--font-xs);
}

/* ── 7. ADMIN / USERS + FACILITIES PAGES ───────────────────── */

/* Field select + textarea */
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 0 var(--space-4);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-2);
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
  cursor: pointer;
}

.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--color-accent) 60%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 12%, transparent);
}

.field textarea { min-height: 90px; padding-top: var(--space-3); resize: vertical; }

/* Status badges (admin variants) */
.badge-active   { color: var(--color-success); background: var(--color-success-soft); }
.badge-inactive { color: var(--color-text-muted); background: var(--color-surface-muted); border: 1px solid var(--color-border); }
.badge-archived { color: var(--color-warning); background: var(--color-warning-soft); border: 1px solid rgba(217, 119, 6, .25); }
.badge-locked   { color: var(--color-warning); background: var(--color-warning-soft); }

/* ECG review-status badges */
.badge-ecg-new        { color: var(--color-text-muted); background: var(--color-surface-muted); border: 1px solid var(--color-border); }
.badge-ecg-sinus      { color: var(--color-success); background: var(--color-success-soft); }
.badge-ecg-afib       { color: #fff; background: var(--color-accent-strong); }
.badge-ecg-arrhythmia { color: var(--color-warning); background: var(--color-warning-soft); }
.badge-ecg-noise      { color: #7a6200; background: #fef6cc; border: 1px solid #e8d96b; }

/* Role chip */
.role-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 var(--space-2);
  color: var(--color-text-muted);
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-1);
  font-size: var(--font-xs);
  font-weight: 700;
  white-space: nowrap;
}

/* Table action column + row buttons */
.col-actions { text-align: right; width: 1%; white-space: nowrap; }

.row-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  justify-content: flex-end;
}

.btn-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
  padding: 0 var(--space-3);
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-1);
  cursor: pointer;
  font-size: var(--font-xs);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--motion-fast), color var(--motion-fast);
}

.btn-row:hover { color: var(--color-heading); background: var(--color-surface-muted); }

.btn-row-danger { color: var(--color-accent); border-color: transparent; }
.btn-row-danger:hover { background: var(--color-accent-soft); color: var(--color-accent-strong); }

/* Add / primary topbar button */
.btn-add {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 38px;
  padding: 0 var(--space-4);
  color: #ffffff;
  background: var(--color-accent);
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: var(--font-sm);
  font-weight: 800;
  box-shadow: 0 3px 10px rgba(235,0,21,.22);
}

.btn-add:hover { background: var(--color-accent-strong); transform: translateY(-1px); }

.btn-add svg {
  width: 14px; height: 14px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 2.8;
  stroke-linecap: round;
}

/* Field helpers */
.field-help {
  color: var(--color-text-muted);
  font-size: var(--font-xs);
  margin-top: 2px;
}

.field-error {
  color: var(--color-accent);
  font-size: var(--font-xs);
  font-weight: 700;
  margin-top: 2px;
}

/* Fieldset reset */
fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

fieldset legend {
  color: var(--color-heading);
  font-size: var(--font-sm);
  font-weight: 700;
  margin-bottom: var(--space-2);
  padding: 0;
}

/* Checkbox grid for roles */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-2);
}

.checkbox-grid .checkbox-label {
  align-items: flex-start;
  padding: var(--space-3);
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  transition: background-color var(--motion-fast), border-color var(--motion-fast);
  font-size: var(--font-sm);
  color: var(--color-text);
}

.checkbox-grid .checkbox-label:has(input:checked) {
  background: var(--color-accent-soft);
  border-color: color-mix(in srgb, var(--color-accent) 35%, transparent);
}

.checkbox-grid .checkbox-label span {
  display: grid;
  gap: 1px;
}

.checkbox-grid .checkbox-label strong { font-size: var(--font-sm); font-weight: 700; }
.checkbox-grid .checkbox-label small { color: var(--color-text-muted); font-size: var(--font-xs); }

/* Two-column field grid */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

/* Sync status badges */
.badge-linked   { color: var(--color-success); background: var(--color-success-soft); }
.badge-unlinked { color: var(--color-text-muted); background: var(--color-surface-muted); border: 1px solid var(--color-border); }

/* Doctor visibility badges */
.badge-visible { color: var(--color-success); background: var(--color-success-soft); }
.badge-hidden  { color: var(--color-text-muted); background: var(--color-surface-muted); border: 1px solid var(--color-border); }

/* Numeric count chip (patient count per facility) */
.col-num { width: 80px; text-align: right; }
.num-chip {
  display: inline-block;
  min-width: 28px;
  padding: 1px 7px;
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-1);
  font-size: var(--font-sm);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
  text-align: center;
}
.num-chip.num-chip-zero {
  color: var(--color-text-muted);
  font-weight: 400;
  border-style: dashed;
}

/* Sync cell: ID monospace + badge */
.sync-cell {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.sync-id {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: var(--font-xs);
  font-weight: 700;
  color: var(--color-heading);
  letter-spacing: .02em;
}

/* Doctor chips inline in table cell */
.doctor-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

/* Stats strip inside a panel */
.panel-stats {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-3) var(--space-5);
  background: var(--color-surface-muted);
  border-bottom: 1px solid var(--color-border);
}

.panel-stat {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.panel-stat-value {
  font-size: var(--font-lg);
  font-weight: 900;
  color: var(--color-heading);
  line-height: 1;
}

.panel-stat-label {
  font-size: var(--font-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.panel-stats-sep {
  width: 1px;
  height: 28px;
  background: var(--color-border);
}

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(3px);
  animation: backdrop-in var(--motion-normal) ease;
}

.modal-backdrop.is-hidden { display: none; }

@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  width: min(100%, 500px);
  max-height: calc(100dvh - var(--space-8) * 2);
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-3);
  box-shadow: var(--shadow-soft);
  animation: modal-in var(--motion-normal) ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-muted);
}

.modal-head h2 { font-size: 1rem; font-weight: 800; }
.modal-head p { color: var(--color-text-muted); font-size: var(--font-sm); margin-top: 3px; }

.modal-close {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 28px; height: 28px;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-1);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
}

.modal-close:hover { color: var(--color-heading); background: var(--color-bg-subtle); }

.modal-body { padding: var(--space-6); }

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-muted);
}

.modal-foot .btn-primary {
  width: auto;
  min-height: 40px;
  padding: 0 var(--space-5);
  font-size: var(--font-sm);
  margin-top: 0;
  box-shadow: none;
}

.modal-foot .btn-primary:hover { transform: none; }

/* Mode-based visibility inside modal */
.modal[data-mode="create"] [data-edit-only] { display: none; }
.modal[data-mode="edit"]   [data-create-only] { display: none; }

/* ── Danger / confirm button ── */
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-5);
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-1);
  font-size: var(--font-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn-danger:hover  { background: var(--color-accent-strong); transform: translateY(-1px); }
.btn-danger:active { transform: translateY(0); }

/* ── Danger modal head variant ── */
.modal-head--danger {
  background: #fff5f5;
  border-bottom-color: #fecaca;
}
[data-theme="dark"] .modal-head--danger {
  background: rgba(220,38,38,.12);
  border-bottom-color: rgba(220,38,38,.25);
}
.modal-danger-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  background: #fee2e2;
  border-radius: 50%;
  color: var(--color-accent);
}
[data-theme="dark"] .modal-danger-icon { background: rgba(220,38,38,.2); }

/* ── Toggle switch (single yes/no field) ── */
.toggle-field {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}
.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.toggle-label {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
}
.toggle-track {
  flex-shrink: 0;
  display: inline-block;
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--color-border);
  border-radius: 10px;
  transition: background .2s;
  margin-top: 2px;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle-input:checked + .toggle-label .toggle-track {
  background: var(--color-success);
}
.toggle-input:checked + .toggle-label .toggle-track::after {
  transform: translateX(16px);
}
.toggle-input:focus-visible + .toggle-label .toggle-track {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.toggle-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.toggle-text strong {
  font-size: var(--font-sm);
  font-weight: 600;
  color: var(--color-text);
}
.toggle-text small {
  font-size: var(--font-xs);
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* ── 8. PATIENT DETAIL ──────────────────────────────────────── */

/* Back link above patient name */
.patient-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-1);
  color: var(--color-text-muted);
  font-size: var(--font-sm);
  font-weight: 600;
  text-decoration: none;
}
.patient-back::before { content: "←  "; }
.patient-back:hover { color: var(--color-heading); }

/* Birth year tag */
.patient-dob {
  color: var(--color-text-muted);
  font-size: 1rem;
  font-weight: 500;
  font-style: normal;
  margin-left: var(--space-2);
}

/* Critical findings strip */
.alert-strip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--color-accent-soft);
  border-bottom: 1px solid color-mix(in srgb, var(--color-accent) 22%, transparent);
  color: var(--color-accent-strong);
  font-size: var(--font-sm);
  font-weight: 600;
  margin-bottom: var(--space-5);
  border-radius: var(--radius-2);
  border: 1px solid color-mix(in srgb, var(--color-accent) 22%, transparent);
}

.alert-strip svg {
  width: 16px; height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.alert-strip-label {
  font-size: var(--font-xs);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .06em;
  flex-shrink: 0;
}

.alert-strip-text { flex: 1; }

.btn-alert-resolve {
  min-height: 26px;
  padding: 0 var(--space-3);
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: var(--font-xs);
  font-weight: 800;
  flex-shrink: 0;
  white-space: nowrap;
}

/* 6-column vitals strip */
.vitals-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

/* Alert metric value (elevated BP, critical weight gain) */
.metric-value.is-alert { color: var(--color-accent); }

/* Sub-label under metric value */
.metric-sub {
  font-size: var(--font-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  margin-top: 2px;
}
.metric-sub.is-warn { color: var(--color-accent); }

/* Chart range tabs */
.chart-tabs {
  display: flex;
  gap: var(--space-1);
}

.chart-tab {
  min-height: 28px;
  padding: 0 var(--space-3);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: var(--font-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  transition: background-color var(--motion-fast), color var(--motion-fast), border-color var(--motion-fast);
}

.chart-tab:hover {
  border-color: var(--color-border-strong);
  color: var(--color-heading);
}

.chart-tab.is-active {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

/* Chart legend */
.chart-legend {
  display: flex;
  gap: var(--space-5);
  padding: 0 var(--space-5) var(--space-3);
  justify-content: flex-end;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-xs);
  font-weight: 700;
  color: var(--color-text-muted);
}

.chart-legend-swatch {
  display: inline-block;
  width: 20px; height: 3px;
  border-radius: 2px;
}

/* SVG chart container */
.chart-area {
  padding: var(--space-2) var(--space-4) var(--space-4);
  overflow: hidden;
}

.chart-area svg {
  display: block;
  width: 100%;
  height: auto;
}

/* SVG chart line styles (CSS-driven for dark mode) */
.chart-line-systolic {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-dot-systolic {
  fill: var(--color-surface);
  stroke: var(--color-accent);
  stroke-width: 1.5;
}

.chart-line-diastolic {
  fill: none;
  stroke: #3b82f6;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-dot-diastolic {
  fill: var(--color-surface);
  stroke: #3b82f6;
  stroke-width: 1.5;
}

.chart-grid-line {
  stroke: var(--color-border);
  stroke-width: 1;
}

.chart-axis-text {
  fill: var(--color-text-muted);
  font-family: var(--font-family);
  font-size: 11px;
}

/* Patient info list */
.info-list {
  list-style: none;
  margin: 0;
  padding: var(--space-3) var(--space-5);
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  font-size: var(--font-sm);
  border-bottom: 1px solid var(--color-border);
}

.info-row:last-child { border-bottom: none; }

.info-label {
  color: var(--color-text-muted);
  font-size: var(--font-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding-top: 1px;
  flex-shrink: 0;
}

.info-value {
  text-align: right;
  font-weight: 600;
  font-size: var(--font-sm);
  word-break: break-word;
}

.patient-profile-info .info-row {
  display: grid !important;
  grid-template-columns: minmax(120px, max-content) minmax(0, 1fr);
  align-items: start;
  gap: var(--space-3);
}

.patient-profile-info .info-label {
  min-width: 0;
  white-space: normal;
}

.patient-profile-info .info-value {
  min-width: 0;
  max-width: none !important;
  text-align: right;
  word-break: normal;
  overflow-wrap: break-word;
  line-height: 1.45;
}

.patient-profile-info .btn-ghost {
  white-space: normal;
  min-height: 42px;
}

.patient-profile-info .info-row > form:only-child,
.patient-profile-info .info-row > .btn-ghost:only-child {
  grid-column: 1 / -1;
}

@media (max-width: 1180px) {
  .patient-profile-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ── Panel-level tab navigation (Logs page, etc.) ── */
.tab-nav {
  display: flex;
  gap: 0;
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.tab-btn {
  position: relative;
  min-height: 44px;
  padding: 0 var(--space-4);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  font-size: var(--font-sm);
  font-weight: 700;
  color: var(--color-text-muted);
  transition: color var(--motion-fast);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.tab-btn:hover { color: var(--color-heading); }

.tab-btn.is-active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--color-bg-subtle);
  border-radius: var(--radius-full);
  font-size: .68rem;
  font-weight: 800;
  color: var(--color-text-muted);
}

.tab-btn.is-active .tab-count {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.tab-count--error {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ── Log severity badges ── */
.badge-info {
  color: #1d6fb5;
  background: #ddeefe;
}
.badge-danger {
  color: var(--color-accent-strong);
  background: var(--color-accent-soft);
}
.badge-critical {
  color: #fff;
  background: var(--color-accent);
}
.badge-debug {
  color: var(--color-text-muted);
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
}

:root[data-theme="dark"] .badge-info {
  color: #60a5fa;
  background: #1a3356;
}

/* ── Log table cells ── */
.log-action { font-size: var(--font-sm); font-weight: 600; }
.log-action small {
  display: block;
  font-size: var(--font-xs);
  font-weight: 400;
  color: var(--color-text-muted);
  margin-top: 1px;
}

.log-ip {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: var(--font-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.log-msg {
  font-size: var(--font-sm);
  max-width: 480px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-msg small {
  display: block;
  font-size: var(--font-xs);
  color: var(--color-text-muted);
  font-family: ui-monospace, monospace;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 9. SETTINGS PAGE ──────────────────────────────────────── */

/* Connection status badge */
.connection-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-sm);
  font-weight: 500;
}
.connection-status::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-text-muted);
  flex-shrink: 0;
}
.connection-status.is-ok::before   { background: var(--color-success); }
.connection-status.is-error::before { background: var(--color-accent); }
.connection-status.is-checking::before {
  background: var(--color-warning);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: .3; }
}

/* Script status dot */
.script-status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.script-status-dot.idle    { background: var(--color-text-muted); }
.script-status-dot.running {
  background: var(--color-warning);
  animation: pulse-dot 1.2s ease-in-out infinite;
}
.script-status-dot.ok      { background: var(--color-success); }
.script-status-dot.error   { background: var(--color-accent); }
.script-status-dot.pending { background: var(--color-warning); }

/* Script status cell */
.script-status-cell {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-sm);
}

/* PROFILOG record freshness indicator */
.freshness-indicator {
  display: inline-flex;
  align-items: flex-start;
  gap: 5px;
  font-size: var(--font-xs);
  font-weight: 600;
  line-height: 1.35;
}

.freshness-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
  background: var(--color-text-muted);
}

.freshness-indicator.is-checking .freshness-dot {
  background: var(--color-text-muted);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.freshness-indicator.is-current .freshness-dot  { background: var(--color-success); }
.freshness-indicator.is-current                 { color: var(--color-success); }

.freshness-indicator.is-outdated .freshness-dot { background: var(--color-warning); }
.freshness-indicator.is-outdated                { color: var(--color-warning); }

.freshness-indicator.is-unavailable .freshness-dot { background: var(--color-text-muted); }
.freshness-indicator.is-unavailable                { color: var(--color-text-muted); }

/* Toggle switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  user-select: none;
}
.toggle-wrap .toggle-label {
  font-size: var(--font-sm);
  color: var(--color-text);
}
.toggle-wrap .toggle-label small {
  display: block;
  font-size: var(--font-xs);
  color: var(--color-text-muted);
  font-weight: 400;
}
.toggle-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.toggle-track {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  background: var(--color-border-strong);
  border-radius: var(--radius-full);
  transition: background .2s;
  flex-shrink: 0;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.toggle-input:checked + .toggle-track {
  background: var(--color-accent);
}
.toggle-input:checked + .toggle-track::after {
  transform: translateX(18px);
}
.toggle-input:focus-visible + .toggle-track {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* Delivery row */
.delivery-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-border);
}
.delivery-row:last-child { border-bottom: 0; }
.delivery-row-info { flex: 1; min-width: 0; }
.delivery-row-info strong {
  font-size: var(--font-sm);
  font-weight: 600;
  display: block;
}
.delivery-row-info p {
  font-size: var(--font-xs);
  color: var(--color-text-muted);
  margin: 2px 0 0;
}

/* Threshold cards */
.threshold-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-5);
}
.threshold-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  overflow: hidden;
}
.threshold-card-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-muted);
  border-bottom: 1px solid var(--color-border);
}
.threshold-card-head .card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-1);
  background: var(--color-accent-soft);
  color: var(--color-accent);
  flex-shrink: 0;
}
.threshold-card-head .card-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.threshold-card-title {
  font-size: var(--font-sm);
  font-weight: 600;
}
.threshold-rows { padding: var(--space-2) 0; }
.threshold-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-sm);
}
.threshold-row + .threshold-row {
  border-top: 1px solid var(--color-border);
}
.severity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.severity-dot.critical { background: var(--color-accent); }
.severity-dot.warning  { background: var(--color-warning); }
.severity-dot.info     { background: #3b82f6; }

.threshold-label {
  color: var(--color-text);
  line-height: 1.3;
}
.threshold-label small {
  display: block;
  font-size: var(--font-xs);
  color: var(--color-text-muted);
}
.threshold-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.threshold-edit {
  display: grid;
  grid-template-columns: minmax(72px, 96px) auto;
  align-items: center;
  gap: var(--space-2);
  white-space: normal;
}

.threshold-edit input {
  width: 100%;
  min-height: 34px;
  padding: 6px var(--space-2);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-1);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.threshold-edit input:focus {
  outline: 2px solid var(--color-focus);
  outline-offset: 1px;
}

.field-error {
  grid-column: 1 / -1;
  color: var(--color-accent);
  font-size: var(--font-xs);
  font-weight: 600;
  white-space: normal;
}

.settings-section-title {
  margin-bottom: var(--space-4);
  font-size: var(--font-sm);
  font-weight: 700;
}

.settings-section-desc {
  margin-bottom: 0;
  color: var(--color-text-muted);
  font-size: var(--font-xs);
}

/* Settings form rows */
.settings-field-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  align-items: start;
  gap: var(--space-4) var(--space-6);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-border);
}
.settings-field-row:last-child { border-bottom: 0; }
.settings-field-label {
  font-size: var(--font-sm);
  font-weight: 600;
  padding-top: 6px;
}
.settings-field-label small {
  display: block;
  font-size: var(--font-xs);
  font-weight: 400;
  color: var(--color-text-muted);
  margin-top: 2px;
}
.settings-field-control input[type="text"],
.settings-field-control input[type="url"],
.settings-field-control input[type="number"],
.settings-field-control select {
  width: 100%;
  max-width: 420px;
  padding: 7px var(--space-3);
  font-size: var(--font-sm);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-1);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-family);
}
.settings-field-control input:focus,
.settings-field-control select:focus {
  outline: 2px solid var(--color-focus);
  outline-offset: 1px;
}

/* Final monitoring reports */
.final-report-page {
  display: grid;
  justify-items: center;
}

.final-report-sheet {
  width: min(100%, 920px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.report-actions-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: var(--color-surface-muted);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-sm);
}

.report-actions-inline {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.report-letterhead,
.report-section,
.report-status-row {
  padding-inline: var(--space-8);
}

.report-letterhead {
  padding-top: var(--space-8);
  padding-bottom: var(--space-5);
}

.report-letterhead h2 {
  margin-top: var(--space-1);
}

.report-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
  padding: 0 var(--space-8) var(--space-4);
}

.report-meta-card {
  display: grid;
  gap: 3px;
  min-height: 62px;
  padding: var(--space-3);
  background: var(--color-surface-muted);
  border: 1px solid transparent;
  border-radius: var(--radius-2);
}

.report-meta-card span:first-child,
.report-section h3,
.report-section label,
.report-status-row .field > span {
  color: var(--color-text-muted);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.report-meta-card strong,
.report-meta-card input,
.report-meta-card select,
.report-status-row input,
.report-status-row select {
  color: var(--color-heading);
  font-size: var(--font-sm);
  font-weight: 800;
}

.report-meta-card input,
.report-meta-card select,
.report-status-row input,
.report-status-row select,
.report-signature-grid input {
  width: 100%;
  min-height: 30px;
  padding: 0;
  color: var(--color-heading);
  background: transparent;
  border: 0;
  font-family: var(--font-family);
}

.report-meta-card input:focus,
.report-meta-card select:focus,
.report-status-row input:focus,
.report-status-row select:focus,
.report-signature-grid input:focus,
.report-section textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--color-focus) 35%, transparent);
  outline-offset: 2px;
}

.report-date-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.report-status-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
  gap: var(--space-4);
  padding-bottom: var(--space-4);
}

.report-status-row .field {
  padding: var(--space-3);
  background: var(--color-surface-muted);
  border-radius: var(--radius-2);
}

.report-separator {
  height: 2px;
  margin: 0 var(--space-8);
  background: var(--color-accent);
  opacity: .8;
}

.report-data-note {
  margin: var(--space-6) var(--space-8);
  color: var(--color-text-muted);
  font-size: var(--font-sm);
  font-style: italic;
  text-align: center;
}

.report-section {
  display: grid;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.report-section h3,
.report-section label {
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

.report-vitals-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

.report-vitals-grid div {
  min-height: 66px;
  padding: var(--space-3);
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
}

.report-vitals-grid span {
  display: block;
  color: var(--color-text-muted);
  font-size: var(--font-xs);
  margin-bottom: var(--space-1);
}

.report-vitals-grid strong {
  font-size: var(--font-sm);
}

.report-section textarea {
  width: 100%;
  min-height: 160px;
  padding: var(--space-4);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border-strong);
  border-radius: var(--radius-2);
  resize: vertical;
  font: inherit;
  line-height: 1.65;
}

.report-signature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-5);
  padding-bottom: var(--space-8);
}

.report-signature-grid label {
  display: grid;
  gap: var(--space-1);
  border-bottom: 1px solid var(--color-border-strong);
}

.report-signature-grid span {
  color: var(--color-text-muted);
  font-size: var(--font-xs);
}

/* Save bar */
.settings-save-bar {
  position: sticky;
  bottom: 0;
  margin: var(--space-6) calc(-1 * var(--space-6)) calc(-1 * var(--space-6));
  padding: var(--space-4) var(--space-6);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  z-index: 10;
}
.settings-saved-msg {
  font-size: var(--font-sm);
  color: var(--color-success);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  opacity: 0;
  transition: opacity .3s;
}
.settings-saved-msg.is-visible { opacity: 1; }
.settings-saved-msg svg {
  width: 14px; height: 14px;
  fill: none; stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}

/* Dark overrides – settings */
:root[data-theme="dark"] .threshold-card {
  border-color: var(--color-border);
}
:root[data-theme="dark"] .threshold-card-head {
  background: var(--color-surface-muted);
}
:root[data-theme="dark"] .settings-save-bar {
  background: var(--color-surface);
}
:root[data-theme="dark"] .settings-field-control input,
:root[data-theme="dark"] .settings-field-control select {
  background: var(--color-surface-muted);
  border-color: var(--color-border);
  color: var(--color-text);
}

/* Backend integration helpers */
.btn-add {
  text-decoration: none;
}

.btn-add:disabled,
.btn-row:disabled,
.btn-ghost:disabled {
  cursor: not-allowed;
  opacity: .45;
  transform: none;
}

.form-panel-body {
  padding: var(--space-6);
}

.patient-edit-form {
  display: grid;
  gap: var(--space-5);
}

.field-grid--patient {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.patient-edit-form .field,
.static-field {
  min-width: 0;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
}

.patient-edit-form .field input,
.patient-edit-form .field select {
  min-height: 40px;
  padding-inline: var(--space-3);
  background: var(--color-surface);
  border-color: var(--color-border);
}

.static-field {
  display: grid;
  gap: var(--space-2);
}

.static-label {
  color: var(--color-text-muted);
  font-size: var(--font-xs);
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.static-value {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--color-heading);
  font-size: var(--font-sm);
  font-weight: 800;
}

.patient-edit-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: var(--space-4);
  margin-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.patient-edit-actions .btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.narrow-panel {
  max-width: 760px;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding-top: var(--space-2);
}

.row-actions form {
  margin: 0;
}

.empty-state {
  color: var(--color-text-muted);
  text-align: center;
}

.empty-hint {
  padding: var(--space-3);
  color: var(--color-text-muted);
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  font-size: var(--font-sm);
}

.role-chip.is-empty {
  color: var(--color-border-strong);
  border-style: dashed;
}

.flash {
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  background: var(--color-surface);
  font-size: var(--font-sm);
  font-weight: 700;
}

.flash.success {
  color: var(--color-success);
  background: var(--color-success-soft);
}

.flash.error {
  color: var(--color-accent);
  background: var(--color-accent-soft);
}

@media (max-width: 640px) {
  .form-panel-body {
    padding: var(--space-4);
  }

  .field-grid--patient {
    grid-template-columns: 1fr;
  }

  .patient-edit-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .patient-edit-actions .btn-ghost {
    justify-content: center;
    width: 100%;
  }

  .form-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .form-actions .btn-add,
  .form-actions .btn-ghost {
    justify-content: center;
    width: 100%;
  }
}

/* ── 11. RESPONSIVE ──────────────────────────────────────────── */

@media (max-width: 1200px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
  .vitals-grid {
    grid-template-columns: repeat(3, minmax(0,1fr));
  }
  .patient-profile-grid,
  .content-grid {
    grid-template-columns: 1fr !important;
  }

  .report-meta-grid,
  .report-vitals-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  /* Sidebar: collapse to top bar */
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--color-border);
  }

  .nav-items {
    grid-template-columns: repeat(3, minmax(0,1fr));
  }

  .nav-section-label { display: none; }
}

@media (max-width: 640px) {
  .auth-centered { padding: var(--space-4); }

  .login-card-brand,
  .login-card-head,
  .login-card-body  { padding: var(--space-5); }

  .main-panel { padding: var(--space-4); }

  .topbar {
    flex-wrap: wrap;
    gap: var(--space-3);
  }

  .topbar-right { width: 100%; flex-wrap: wrap; }

  .user-chip { flex: 1; justify-content: center; }

  .nav-items { grid-template-columns: repeat(2, minmax(0,1fr)); }

  .metric-grid { grid-template-columns: 1fr; }
  .vitals-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }

  .report-actions-bar,
  .report-status-row,
  .report-signature-grid,
  .report-meta-grid,
  .report-vitals-grid {
    grid-template-columns: 1fr;
  }

  .report-actions-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .report-letterhead,
  .report-section,
  .report-status-row {
    padding-inline: var(--space-5);
  }

  .report-meta-grid {
    padding-inline: var(--space-5);
  }

  .report-separator,
  .report-data-note {
    margin-inline: var(--space-5);
  }
}

/* ── BP chart: controls ─────────────────────────────────────────────────── */

.chart-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
}

.chart-custom-range {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.input-sm {
  height: 28px;
  padding: 0 var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--font-xs);
  font-family: var(--font-family);
  cursor: pointer;
  transition: border-color var(--motion-fast);
}

.input-sm:focus {
  outline: none;
  border-color: var(--color-accent);
}

.btn-sm {
  height: 28px;
  padding: 0 var(--space-3);
  background: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--font-xs);
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--motion-fast);
}

.btn-sm:hover { opacity: .85; }

/* ── BP chart: SVG interaction ──────────────────────────────────────────── */

.bp-crosshair {
  stroke: var(--color-border-strong);
  stroke-width: 1;
  stroke-dasharray: 4 3;
  pointer-events: none;
}

.bp-highlight-sys {
  fill: var(--color-accent);
  stroke: var(--color-surface);
  stroke-width: 2;
  pointer-events: none;
}

.bp-highlight-dia {
  fill: #3b82f6;
  stroke: var(--color-surface);
  stroke-width: 2;
  pointer-events: none;
}

/* ── BP chart: tooltip ──────────────────────────────────────────────────── */

.bp-tooltip {
  position: fixed;
  z-index: 200;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  pointer-events: none;
  min-width: 150px;
  white-space: nowrap;
}

.bp-tooltip-date {
  font-size: var(--font-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: var(--space-2);
}

.bp-tooltip-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-sm);
  line-height: 1.6;
}

.bp-tooltip-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
