@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

/* ==========================================================================
   DESIGN SYSTEM — Precision Clinical
   Clean, confident, light-mode-first. No glassmorphism, no blur, no glow.
   ========================================================================== */

:root {
  /* Primary */
  --primary: #0F766E;
  --primary-hover: #0D9488;
  --primary-light: #CCFBF1;
  --primary-subtle: rgba(15, 118, 110, 0.08);

  /* Semantic */
  --success: #059669;
  --success-light: #D1FAE5;
  --warning: #D97706;
  --warning-light: #FEF3C7;
  --danger: #DC2626;
  --danger-light: #FEE2E2;
  --info: #2563EB;
  --info-light: #DBEAFE;

  /* Backgrounds */
  --bg-app: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-elevated: #FFFFFF;
  --bg-inset: #F1F5F9;

  /* Text */
  --text-heading: #0F172A;
  --text-body: #334155;
  --text-muted: #94A3B8;
  --text-inverse: #FFFFFF;

  /* Borders & Dividers */
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --divider: #F1F5F9;

  /* Shadows — no color tint, just depth */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-dropdown: 0 10px 40px rgba(0, 0, 0, 0.12);

  /* Typography */
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-lg: 1rem;
  --text-xl: 1.125rem;
  --text-2xl: 1.375rem;
  --text-3xl: 1.75rem;
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  /* Spacing (4px grid) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Transitions */
  --ease: 150ms ease;
  --ease-medium: 250ms ease;

  /* Layout */
  --sidebar-w: 252px;
  --topnav-h: 60px;
}

/* ---------- Dark Mode ---------- */
html.dark {
  --bg-app: #0B1222;
  --bg-surface: #151F32;
  --bg-elevated: #1A2540;
  --bg-inset: #111B2E;

  --text-heading: #F1F5F9;
  --text-body: #CBD5E1;
  --text-muted: #64748B;

  --border: #1E293B;
  --border-strong: #334155;
  --divider: #1E293B;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
  --shadow-dropdown: 0 10px 40px rgba(0, 0, 0, 0.5);

  --primary-subtle: rgba(20, 184, 166, 0.12);
  --success-light: rgba(5, 150, 105, 0.15);
  --warning-light: rgba(217, 119, 6, 0.15);
  --danger-light: rgba(220, 38, 38, 0.15);
  --info-light: rgba(37, 99, 235, 0.15);
}

/* ==========================================================================
   RESET & BASE
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-app);
  color: var(--text-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font);
  color: var(--text-heading);
  line-height: var(--leading-tight);
  font-weight: 600;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--ease);
}
a:hover { color: var(--primary-hover); }

*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

img { display: block; max-width: 100%; }

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ==========================================================================
   LAYOUT
   ========================================================================== */
.dashboard-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--ease-medium);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-6) var(--sp-5);
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-inverse);
  flex-shrink: 0;
}
.sidebar-logo svg { width: 18px; height: 18px; min-width: 18px; min-height: 18px; display: block; }

.sidebar-brand {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: -0.02em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-4) var(--sp-3);
  flex: 1;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  color: var(--text-body);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all var(--ease);
  position: relative;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--bg-inset);
  color: var(--text-heading);
}

.nav-item.active {
  background: var(--primary-subtle);
  color: var(--primary);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.nav-item [data-lucide], .nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke-width: 1.75;
}

.sidebar-footer {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
}

/* ---------- Main Area ---------- */
.dashboard-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------- Top Nav ---------- */
.topnav {
  height: var(--topnav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-8);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  gap: var(--sp-4);
}

.page-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-heading);
}

.topnav-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.topnav-user {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  border-left: 1px solid var(--border);
  padding-left: var(--sp-4);
  margin-left: var(--sp-1);
}

.topnav-username {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-body);
  white-space: nowrap;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: var(--primary-subtle);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: var(--text-sm);
}

.topnav-signout {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius-sm);
  transition: all var(--ease);
  white-space: nowrap;
}
.topnav-signout:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-light); }

/* Mobile hamburger */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--sp-2);
  color: var(--text-body);
  border-radius: var(--radius-md);
}
.mobile-menu-btn:hover { background: var(--bg-inset); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 99;
}

/* ---------- Content ---------- */
.content-area {
  flex: 1;
  padding: var(--sp-8) var(--sp-10);
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

/* ==========================================================================
   COMPONENTS
   ========================================================================== */

/* ---------- Card ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}

.card-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-heading);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-5);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--ease);
  line-height: var(--leading-normal);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: var(--text-inverse);
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--text-inverse);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-body);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--bg-inset);
  border-color: var(--border-strong);
  color: var(--text-heading);
}

.btn-cta {
  background: var(--primary);
  color: var(--text-inverse);
  border-color: var(--primary);
}
.btn-cta:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--text-inverse);
}

.btn-danger {
  background: var(--danger);
  color: var(--text-inverse);
  border-color: var(--danger);
}

.btn-ghost {
  background: transparent;
  color: var(--text-body);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--bg-inset);
  color: var(--text-heading);
}

.btn-sm {
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--text-xs);
}

.btn-lg {
  padding: 12px var(--sp-6);
  font-size: var(--text-base);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-normal {
  background: var(--success-light);
  color: var(--success);
}
.badge-normal::before { background: var(--success); }

.badge-warning {
  background: var(--warning-light);
  color: var(--warning);
}
.badge-warning::before { background: var(--warning); }

.badge-critical {
  background: var(--danger-light);
  color: var(--danger);
}
.badge-critical::before { background: var(--danger); }

.badge-info {
  background: var(--info-light);
  color: var(--info);
}
.badge-info::before { background: var(--info); }

.badge-muted {
  background: var(--bg-inset);
  color: var(--text-muted);
}
.badge-muted::before { background: var(--text-muted); }

/* ---------- Forms ---------- */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--sp-4);
}

.input-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-body);
}

.input-field {
  width: 100%;
  padding: 10px var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-heading);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  transition: border-color var(--ease), box-shadow var(--ease);
}

.input-field::placeholder { color: var(--text-muted); }

.input-field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

select.input-field { cursor: pointer; }
textarea.input-field { resize: vertical; min-height: 80px; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-inset);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-sm);
  color: var(--text-body);
  border-bottom: 1px solid var(--divider);
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--primary-subtle); }

/* Legacy wrapper compat */
.table-container { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }

/* ---------- Metrics Grid ---------- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-5);
  margin-bottom: var(--sp-6);
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-5);
  border-left: 3px solid var(--border);
}

.metric-card.status-normal  { border-left-color: var(--success); }
.metric-card.status-warning { border-left-color: var(--warning); }
.metric-card.status-critical { border-left-color: var(--danger); }

.metric-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--sp-3);
  background: var(--bg-inset);
  color: var(--text-muted);
}
.metric-card.status-normal .metric-icon { background: var(--success-light); color: var(--success); }
.metric-card.status-warning .metric-icon { background: var(--warning-light); color: var(--warning); }
.metric-card.status-critical .metric-icon { background: var(--danger-light); color: var(--danger); }
.metric-icon svg, .metric-icon [data-lucide] { width: 18px; height: 18px; }

.metric-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-heading);
  display: flex;
  align-items: baseline;
  gap: var(--sp-1);
  line-height: 1.2;
}

.metric-unit {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
}

.metric-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  margin-top: var(--sp-1);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.green  { background: var(--success); }
.status-dot.amber  { background: var(--warning); }
.status-dot.red    { background: var(--danger); }
.status-dot.gray   { background: var(--text-muted); }

/* ---------- HTMX ---------- */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* CSS Spinner */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Utilities ---------- */
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); }
.gap-6 { gap: var(--sp-6); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-baseline { align-items: baseline; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.text-center { text-align: center; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-muted { color: var(--text-muted); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Welcome Banner ---------- */
.welcome-banner {
  margin-bottom: var(--sp-6);
}
.welcome-banner h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: var(--sp-1);
}
.welcome-banner p {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ---------- CTA Banner ---------- */
.cta-banner {
  background: var(--primary);
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--sp-6) var(--sp-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-6);
  flex-wrap: wrap;
  box-shadow: var(--shadow-md);
}
.cta-banner-text h2 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: #FFFFFF;
  margin-bottom: var(--sp-1);
}
.cta-banner-text p {
  font-size: var(--text-sm);
  color: rgba(255,255,255,0.75);
}
.cta-banner .btn {
  background: #FFFFFF;
  color: var(--primary);
  border-color: #FFFFFF;
  font-weight: 600;
}
.cta-banner .btn:hover {
  background: rgba(255,255,255,0.9);
  border-color: rgba(255,255,255,0.9);
  color: var(--primary);
}

/* ---------- Quick Actions Grid ---------- */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--sp-4);
}
.quick-action-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
  text-decoration: none;
  transition: all var(--ease);
  box-shadow: var(--shadow-xs);
}
.quick-action-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  color: inherit;
}
.quick-action-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.quick-action-icon svg, .quick-action-icon [data-lucide] {
  width: 20px;
  height: 20px;
}
.quick-action-icon.teal { background: rgba(15,118,110,0.08); color: var(--primary); }
.quick-action-icon.blue { background: rgba(37,99,235,0.08); color: var(--info); }
.quick-action-icon.amber { background: rgba(217,119,6,0.08); color: var(--warning); }
.quick-action-icon.emerald { background: rgba(5,150,105,0.08); color: var(--success); }
.quick-action-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 2px;
}
.quick-action-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.4;
}

/* ---------- Onboarding Card ---------- */
.onboarding-card {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  padding: var(--sp-8);
  flex-wrap: wrap;
}
.onboarding-card-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-xl);
  background: var(--primary-subtle);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.onboarding-card-icon svg, .onboarding-card-icon [data-lucide] {
  width: 28px;
  height: 28px;
}
.onboarding-card-body {
  flex: 1;
  min-width: 200px;
}
.onboarding-card-body h2 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: var(--sp-2);
}
.onboarding-card-body p {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--sp-4);
}

/* ---------- Auth Pages ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
  padding: var(--sp-6);
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

.auth-container.auth-wide { max-width: 540px; }

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-8);
}

.auth-brand-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  background: var(--primary);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-inverse);
  overflow: hidden;
  flex-shrink: 0;
}
.auth-brand-icon svg { width: 20px; height: 20px; min-width: 20px; min-height: 20px; max-width: 20px; max-height: 20px; display: block; }

.auth-brand-name {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: -0.02em;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp-10) var(--sp-8);
  box-shadow: var(--shadow-md);
}

.auth-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: var(--sp-2);
}

.auth-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--sp-6);
}

.auth-footer {
  text-align: center;
  margin-top: var(--sp-6);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.error-msg {
  background: var(--danger-light);
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-sm);
  color: var(--danger);
  margin-bottom: var(--sp-4);
}

.section-divider {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: var(--sp-5) 0 var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}

/* ---------- Chart ---------- */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-5);
}
@media (max-width: 768px) { .chart-grid { grid-template-columns: 1fr; } }

/* ---------- Analytics KPI ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-5);
  margin-bottom: var(--sp-6);
}

.kpi-card {
  text-align: center;
  padding: var(--sp-5);
}

.kpi-number {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.1;
}

.kpi-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  margin-top: var(--sp-2);
}

/* ---------- Info callout ---------- */
.callout {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  background: var(--bg-inset);
}

.callout-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: var(--sp-2);
}

.callout-body {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--leading-relaxed);
}

.callout code {
  font-size: 12px;
  background: var(--bg-surface);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ---------- Alert Toast ---------- */
.alert-toast {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  z-index: 9999;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: 500;
  max-width: 380px;
  border: 1px solid;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.25s ease;
}
.alert-toast--critical { background: var(--danger-light); color: var(--danger); border-color: rgba(220,38,38,0.2); }
.alert-toast--warning  { background: var(--warning-light); color: var(--warning); border-color: rgba(217,119,6,0.2); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: var(--sp-10) var(--sp-6);
  color: var(--text-muted);
}
.empty-state-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--sp-5);
  color: var(--border-strong);
  background: var(--bg-inset);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-state-icon svg, .empty-state-icon [data-lucide] {
  width: 24px;
  height: 24px;
}
.empty-state-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: var(--sp-2);
}
.empty-state-text {
  font-size: var(--text-sm);
  max-width: 360px;
  margin: 0 auto;
  line-height: var(--leading-relaxed);
}

/* ---------- Dark mode toggle ---------- */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 500;
  width: 100%;
  transition: all var(--ease);
}
.theme-toggle:hover { background: var(--bg-inset); color: var(--text-heading); }
.theme-toggle [data-lucide] { width: 18px; height: 18px; }

/* ---------- WS status ---------- */
.ws-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}
.ws-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}
.ws-dot.live { background: var(--success); }
.ws-dot.offline { background: var(--danger); }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

/* ---------- Profile Page ---------- */
.profile-header-inner {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  flex-wrap: wrap;
}
.profile-avatar-lg {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--text-2xl);
  flex-shrink: 0;
}
.profile-header-info {
  flex: 1;
  min-width: 180px;
}
.profile-header-meta {
  display: flex;
  gap: var(--sp-8);
  margin-left: auto;
}
.profile-stat {
  text-align: center;
}
.profile-stat-value {
  display: block;
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.2;
}
.profile-stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 500;
}
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: var(--sp-6);
  align-items: start;
}

/* ---------- Device Page ---------- */
.device-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-5);
}
.device-card {
  padding: var(--sp-5);
}
.device-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}
.device-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  background: var(--bg-inset);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.device-card-icon svg, .device-card-icon [data-lucide] { width: 22px; height: 22px; }
.device-card-icon.active {
  background: var(--success-light);
  color: var(--success);
}
.device-card-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 2px;
}
.device-card-type {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--sp-4);
}
.device-card-meta {
  border-top: 1px solid var(--border);
  padding-top: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.device-card-meta-item {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--text-body);
}

/* ---------- How It Works ---------- */
.how-it-works-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-6);
}
.how-it-works-item {
  text-align: center;
  padding: var(--sp-4);
}
.how-it-works-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--sp-4);
}
.how-it-works-icon svg, .how-it-works-icon [data-lucide] { width: 24px; height: 24px; }
.how-it-works-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: var(--sp-2);
}
.how-it-works-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: var(--leading-relaxed);
}

/* ---------- Setup Steps ---------- */
.setup-steps {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}
.setup-step {
  display: flex;
  gap: var(--sp-4);
  align-items: flex-start;
}
.setup-step-num {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--primary-subtle);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--text-sm);
  flex-shrink: 0;
}
.setup-step-body {
  flex: 1;
  padding-top: 4px;
}
.setup-step-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: var(--sp-1);
}

/* ---------- Code Inline / Block ---------- */
.code-inline {
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  background: var(--bg-inset);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.code-block {
  display: block;
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', ui-monospace, monospace;
  background: var(--bg-inset);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-top: var(--sp-2);
  color: var(--text-heading);
  word-break: break-all;
}

/* ---------- Success Message ---------- */
.success-msg {
  background: var(--success-light);
  border: 1px solid rgba(5, 150, 105, 0.2);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-sm);
  color: var(--success);
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-backdrop.show {
    display: block;
  }
  .dashboard-main {
    margin-left: 0;
  }
  .mobile-menu-btn {
    display: flex;
  }
  .topnav {
    padding: 0 var(--sp-4);
  }
  .content-area {
    padding: var(--sp-4);
  }
  .metrics-grid {
    grid-template-columns: 1fr 1fr;
  }
  .profile-grid {
    grid-template-columns: 1fr;
  }
  .profile-header-meta {
    margin-left: 0;
    width: 100%;
    justify-content: space-around;
  }
  .device-card-grid {
    grid-template-columns: 1fr;
  }
  .how-it-works-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .auth-card {
    padding: var(--sp-6);
  }
}

/* ==========================================================================
   DIAGNOSIS PAGE
   ========================================================================== */

/* ---------- Page Layout ---------- */
.dx-page {
  max-width: 1100px;
}

.dx-header {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-5);
  margin-bottom: var(--sp-6);
}

.dx-header-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: var(--primary-subtle);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.dx-header-icon [data-lucide] { width: 24px; height: 24px; }

.dx-header-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 4px;
}

.dx-header-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--leading-relaxed);
  max-width: 560px;
}

.dx-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--sp-6);
  align-items: start;
}

.dx-form-col { min-width: 0; }
.dx-sidebar-col { min-width: 0; }

/* ---------- Textarea ---------- */
.dx-textarea {
  resize: vertical;
  min-height: 140px;
  line-height: var(--leading-relaxed);
}

.dx-textarea-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: -2px;
}

/* ---------- Animated dots ---------- */
.dx-dots::after {
  content: '';
  animation: dx-dots 1.5s steps(4, end) infinite;
}
@keyframes dx-dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

.dx-analysing-text {
  display: inline-flex;
}

/* ---------- Steps Sidebar ---------- */
.dx-steps {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  position: relative;
}

.dx-steps::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 32px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}

.dx-step {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  position: relative;
}

.dx-step-num {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--text-sm);
  flex-shrink: 0;
  z-index: 1;
}

.dx-step-body {
  padding-top: 4px;
}

.dx-step-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 2px;
}

.dx-step-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: var(--leading-relaxed);
}

/* ---------- Tips ---------- */
.dx-tips {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.dx-tips li {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--text-sm);
  color: var(--text-body);
}

.dx-tip-icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ---------- Disclaimer ---------- */
.dx-disclaimer {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--radius-lg);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.dx-disclaimer p {
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
  color: var(--text-muted);
}

/* ---------- Result Card ---------- */
.dx-result {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.dx-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-6);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.dx-result-header-left {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-width: 0;
}

.dx-result-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.dx-result-icon [data-lucide] { width: 22px; height: 22px; }
.dx-result-icon--low      { background: var(--success-light); color: var(--success); }
.dx-result-icon--medium   { background: var(--warning-light); color: var(--warning); }
.dx-result-icon--high     { background: var(--warning-light); color: var(--warning); }
.dx-result-icon--critical { background: var(--danger-light);  color: var(--danger); }

.dx-result-condition {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 2px;
}

.dx-result-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ---------- Urgency Pill ---------- */
.dx-urgency-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.dx-urgency-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dx-urgency-pill--low      { background: var(--success-light); color: var(--success); }
.dx-urgency-pill--low .dx-urgency-dot { background: var(--success); }
.dx-urgency-pill--medium   { background: var(--warning-light); color: var(--warning); }
.dx-urgency-pill--medium .dx-urgency-dot { background: var(--warning); }
.dx-urgency-pill--high     { background: var(--warning-light); color: #B45309; }
.dx-urgency-pill--high .dx-urgency-dot { background: #B45309; }
.dx-urgency-pill--critical { background: var(--danger-light);  color: var(--danger); }
.dx-urgency-pill--critical .dx-urgency-dot { background: var(--danger); }

/* ---------- Hospital Alert ---------- */
.dx-hospital-alert {
  margin: 0;
  padding: var(--sp-4) var(--sp-6);
  background: var(--danger-light);
  border-bottom: 1px solid rgba(220, 38, 38, 0.12);
}

.dx-hospital-alert-inner {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  color: var(--danger);
}

.dx-hospital-alert-inner strong {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 2px;
}

.dx-hospital-alert-inner p {
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
  opacity: 0.85;
  margin: 0;
}

/* ---------- Section ---------- */
.dx-section {
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
}

.dx-section:last-of-type {
  border-bottom: none;
}

.dx-section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--sp-3);
}

.dx-advice-body {
  font-size: var(--text-sm);
  color: var(--text-body);
  line-height: var(--leading-relaxed);
}

/* ---------- Doctor Cards ---------- */
.dx-doctor-grid {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.dx-doctor-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.dx-doctor-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-xs);
}

.dx-doctor-card-top {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.dx-doctor-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--primary-subtle);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.dx-doctor-info {
  flex: 1;
  min-width: 0;
}

.dx-doctor-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dx-doctor-hospital {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.dx-doctor-score {
  text-align: center;
  flex-shrink: 0;
}

.dx-doctor-score-value {
  display: block;
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.dx-doctor-score-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
}

.dx-doctor-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--divider);
}

.dx-doctor-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ---------- Result Footer ---------- */
.dx-result-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-6);
  background: var(--bg-inset);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.dx-result-footer p {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: var(--leading-relaxed);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .dx-layout {
    grid-template-columns: 1fr;
  }
  .dx-sidebar-col {
    order: -1;
  }
}

@media (max-width: 768px) {
  .dx-header {
    flex-direction: column;
    gap: var(--sp-3);
  }
  .dx-result-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ==========================================================================
   ALERTS PAGE
   ========================================================================== */

.al-page { max-width: 960px; }

/* Header */
.al-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}
.al-header-left {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
}
.al-header-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: var(--warning-light);
  color: var(--warning);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.al-header-icon [data-lucide] { width: 24px; height: 24px; }
.al-header-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 4px;
}
.al-header-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--leading-relaxed);
}

/* Summary cards */
.al-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.al-summary-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4) var(--sp-5);
  text-align: center;
  box-shadow: var(--shadow-xs);
  border-top: 3px solid var(--border);
}
.al-summary-card--critical { border-top-color: var(--danger); }
.al-summary-card--high { border-top-color: #B45309; }
.al-summary-card--warning { border-top-color: var(--warning); }
.al-summary-card--pending { border-top-color: var(--info); }
.al-summary-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.2;
}
.al-summary-card--critical .al-summary-value { color: var(--danger); }
.al-summary-card--high .al-summary-value { color: #B45309; }
.al-summary-card--warning .al-summary-value { color: var(--warning); }
.al-summary-card--pending .al-summary-value { color: var(--info); }
.al-summary-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Filters */
.al-filters {
  margin-bottom: var(--sp-5);
  padding: var(--sp-3) var(--sp-5);
}
.al-filter-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
}
.al-filter-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.al-filter-chips {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.al-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 14px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-body);
  text-decoration: none;
  transition: all var(--ease);
  cursor: pointer;
}
.al-chip:hover {
  border-color: var(--border-strong);
  background: var(--bg-inset);
  color: var(--text-heading);
}
.al-chip--active {
  background: var(--primary-subtle);
  border-color: var(--primary);
  color: var(--primary);
}
.al-filter-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 var(--sp-1);
}

/* Alert list rows */
.al-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.al-row {
  display: flex;
  gap: var(--sp-4);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4) var(--sp-5);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--ease);
}
.al-row:hover { border-color: var(--border-strong); }
.al-row-severity {
  display: flex;
  align-items: flex-start;
  padding-top: 6px;
}
.al-severity-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.al-severity-indicator--critical { background: var(--danger); }
.al-severity-indicator--high { background: #B45309; }
.al-severity-indicator--warning { background: var(--warning); }
.al-row-body { flex: 1; min-width: 0; }
.al-row-top {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.al-row-code {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-body);
  background: var(--bg-inset);
  padding: 1px 8px;
  border-radius: var(--radius-sm);
}
.al-row-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
}
.al-row-message {
  font-size: var(--text-sm);
  color: var(--text-body);
  line-height: var(--leading-relaxed);
  margin: 0 0 var(--sp-3);
}
.al-row-bottom {
  display: flex;
  align-items: center;
}
.al-row-ack-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
}
.al-row-ack-status--done { color: var(--success); font-weight: 500; }

@media (max-width: 768px) {
  .al-summary-grid { grid-template-columns: repeat(3, 1fr); }
  .al-header { flex-direction: column; }
}
@media (max-width: 480px) {
  .al-summary-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ==========================================================================
   NOTIFICATIONS PAGE
   ========================================================================== */

.ntf-page { max-width: 720px; }

/* Header */
.ntf-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}
.ntf-header-left {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-4);
}
.ntf-header-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: var(--primary-subtle);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ntf-header-icon [data-lucide] { width: 24px; height: 24px; }
.ntf-header-title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 4px;
}
.ntf-header-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: var(--leading-relaxed);
}

/* Section dividers */
.ntf-section {
  margin-bottom: var(--sp-6);
}
.ntf-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
  padding-left: var(--sp-1);
}
.ntf-section-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.ntf-section-dot--unread { background: var(--danger); }
.ntf-section-dot--read { background: var(--border-strong); }

/* Notification items */
.ntf-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.ntf-item {
  display: flex;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  transition: border-color var(--ease), background var(--ease);
}
.ntf-item--unread {
  background: var(--bg-surface);
  box-shadow: var(--shadow-xs);
}
.ntf-item--unread:hover { border-color: var(--border-strong); }
.ntf-item--read {
  background: transparent;
  border-color: var(--divider);
  opacity: 0.75;
}
.ntf-item-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ntf-item-icon [data-lucide] { width: 18px; height: 18px; }
.ntf-item-icon--critical { background: var(--danger-light); color: var(--danger); }
.ntf-item-icon--high { background: var(--warning-light); color: #B45309; }
.ntf-item-icon--warning { background: var(--warning-light); color: var(--warning); }
.ntf-item-icon--muted { background: var(--bg-inset); color: var(--text-muted); }
.ntf-item-body { flex: 1; min-width: 0; }
.ntf-item-top {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: 4px;
}
.ntf-item-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
}
.ntf-item-message {
  font-size: var(--text-sm);
  color: var(--text-body);
  line-height: var(--leading-relaxed);
  margin: 0 0 var(--sp-3);
}
.ntf-item-message--read { color: var(--text-muted); }
.ntf-item-actions { display: flex; align-items: center; gap: var(--sp-2); }
.ntf-item-ack {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

@media (max-width: 768px) {
  .ntf-header { flex-direction: column; }
}

/* ======================================================================
   DEVICE SIMULATOR  (.sim-*)
   ====================================================================== */

.sim-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: var(--sp-8);
  align-items: start;
}

/* ── Watch Container ──────────────────────────────────────────────────── */
.sim-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-6);
}

.sim-watch {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Band straps */
.sim-band {
  width: 100px;
  height: 48px;
  background: linear-gradient(180deg, #2d2d2d 0%, #1a1a1a 100%);
  border-radius: 6px;
  position: relative;
}
.sim-band::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 6px;
  background: #444;
  border-radius: 3px;
}
.sim-band-top { border-radius: 10px 10px 6px 6px; }
.sim-band-top::after { bottom: 8px; }
.sim-band-bottom { border-radius: 6px 6px 10px 10px; }
.sim-band-bottom::after { top: 8px; }

/* Bezel ring */
.sim-bezel {
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: linear-gradient(145deg, #3a3a3a 0%, #1a1a1a 50%, #2a2a2a 100%);
  padding: 8px;
  box-shadow:
    0 0 0 3px #555,
    0 8px 32px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.08);
}

/* Watch face */
.sim-face {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(ellipse at 30% 20%, #1e293b 0%, #0f172a 60%, #020617 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Digital clock */
.sim-watch-time {
  position: absolute;
  top: 28px;
  font-family: 'Plus Jakarta Sans', monospace;
  font-size: 13px;
  font-weight: 600;
  color: rgba(148, 163, 184, 0.7);
  letter-spacing: 2px;
}

/* Main reading display */
.sim-watch-reading {
  text-align: center;
  margin-top: -8px;
}
.sim-reading-value {
  display: block;
  font-size: 52px;
  font-weight: 700;
  color: #e2e8f0;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.sim-reading-unit {
  display: block;
  font-size: 14px;
  color: rgba(148,163,184,0.6);
  margin-top: 2px;
}
.sim-reading-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #38bdf8;
  margin-top: 6px;
}

/* Small metric pills around the bottom */
.sim-watch-metrics {
  position: absolute;
  bottom: 22px;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  max-width: 240px;
}
.sim-metric {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: rgba(148,163,184,0.55);
  background: rgba(255,255,255,0.04);
  padding: 2px 6px;
  border-radius: 8px;
}
.sim-metric i { width: 10px; height: 10px; }

/* LED status dot */
.sim-watch-led {
  position: absolute;
  top: 24px;
  right: 40px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #475569;
  transition: background 0.3s;
}
.sim-led-idle   { background: #475569; }
.sim-led-sending { background: #38bdf8; box-shadow: 0 0 8px #38bdf8; animation: sim-pulse 0.6s infinite alternate; }
.sim-led-ok     { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.sim-led-error  { background: #ef4444; box-shadow: 0 0 6px #ef4444; }

@keyframes sim-pulse {
  from { opacity: 0.5; }
  to   { opacity: 1; }
}

/* ── Activity Log ─────────────────────────────────────────────────────── */
.sim-log-wrap {
  width: 100%;
  max-width: 380px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.sim-log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}
.sim-log-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius-sm);
}
.sim-log-clear:hover { background: var(--hover-bg); }
.sim-log-clear i { width: 14px; height: 14px; }
.sim-log {
  max-height: 220px;
  overflow-y: auto;
  padding: var(--sp-2);
}
.sim-log-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
  padding: var(--sp-6) 0;
}
.sim-log-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}
.sim-log-entry:nth-child(odd) { background: var(--hover-bg); }
.sim-log-error { color: #ef4444; }
.sim-log-time { color: var(--text-muted); font-variant-numeric: tabular-nums; min-width: 60px; }
.sim-log-type { font-weight: 500; min-width: 80px; }
.sim-log-val  { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }

.sim-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
.sim-badge-ok   { background: rgba(34,197,94,0.12); color: #22c55e; }
.sim-badge-warn { background: rgba(245,158,11,0.12); color: #f59e0b; }
.sim-badge-crit { background: rgba(239,68,68,0.12); color: #ef4444; }
.sim-badge-error{ background: rgba(239,68,68,0.12); color: #ef4444; }

/* ── Control Panel ────────────────────────────────────────────────────── */
.sim-controls {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.sim-section { display: flex; flex-direction: column; gap: var(--sp-2); }

.sim-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.sim-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card-bg);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: inherit;
}
.sim-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,0.15); }

.sim-device-info {
  font-size: 12px;
  color: var(--text-muted);
  min-height: 18px;
}

/* Mode tabs */
.sim-mode-tabs {
  display: flex;
  gap: 4px;
  background: var(--hover-bg);
  padding: 3px;
  border-radius: var(--radius-md);
}
.sim-tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.sim-tab:hover { color: var(--text-primary); }
.sim-tab.active {
  background: var(--card-bg);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* Panels */
.sim-panel { display: flex; flex-direction: column; gap: var(--sp-4); }
.sim-panel.hidden { display: none; }

/* Vital type chips */
.sim-vital-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sim-vital-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.sim-vital-chip i { width: 14px; height: 14px; }
.sim-vital-chip:hover { border-color: var(--primary); color: var(--primary); }
.sim-vital-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Value input row */
.sim-value-row {
  display: flex;
  gap: var(--sp-4);
  align-items: flex-end;
}
.sim-value-input-wrap { flex: 1; display: flex; flex-direction: column; gap: var(--sp-2); }

.sim-input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card-bg);
  color: var(--text-primary);
  font-size: var(--text-base);
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
}
.sim-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,0.15); }

.sim-unit-display {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.sim-unit-badge {
  display: inline-block;
  padding: 10px 16px;
  background: var(--hover-bg);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Buttons */
.sim-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.sim-btn i { width: 16px; height: 16px; }
.sim-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.sim-btn-primary { background: var(--primary); color: #fff; }
.sim-btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.sim-btn-muted { background: var(--hover-bg); color: var(--text-primary); }
.sim-btn-muted:hover:not(:disabled) { background: var(--border); }
.sim-btn-danger { background: rgba(239,68,68,0.1); color: #ef4444; }
.sim-btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.2); }

/* ── Scenario cards ───────────────────────────────────────────────────── */
.sim-scenario-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.sim-scenario-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.sim-scenario-card:hover { border-color: var(--primary); }
.sim-scenario-card.active {
  border-color: var(--primary);
  background: rgba(15,118,110,0.06);
  box-shadow: 0 0 0 2px rgba(15,118,110,0.15);
}
.sim-scenario-icon { margin-bottom: 6px; }
.sim-scenario-icon i { width: 22px; height: 22px; }
.sim-scenario-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.sim-scenario-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Interval slider */
.sim-interval-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.sim-interval-row .sim-label { white-space: nowrap; }
.sim-range {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
}
.sim-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
}

/* Auto action row */
.sim-auto-actions {
  display: flex;
  gap: 8px;
}
.sim-auto-counter {
  font-size: 12px;
  color: var(--text-muted);
  min-height: 18px;
}

/* ── Custom auto grid ─────────────────────────────────────────────────── */
.sim-custom-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sim-custom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.sim-custom-row label {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 80px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
}
.sim-custom-row .sim-input { width: 70px; padding: 6px 8px; font-size: 13px; text-align: center; }
.sim-custom-pm { color: var(--text-muted); font-size: 12px; }
.sim-custom-unit { color: var(--text-muted); font-size: 12px; min-width: 40px; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sim-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .sim-controls { width: 100%; max-width: 500px; }
}
