/* ==========================================================================
   ARDS - Adaptive Rehabilitation Decision Support System
   Clinical Design System & Styling - Professional UI/UX Redesign
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* Community Dashboard Styles */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- CSS Variables & Themes --- */
:root {
  /* Dark Theme (Default) */
  --bg-app: #060a13;
  --bg-surface: #0c1220;
  --bg-surface-elevated: #131b2c;
  --bg-card: rgba(12, 18, 32, 0.82);
  --bg-card-hover: rgba(19, 27, 44, 0.95);
  --bg-input: rgba(10, 15, 27, 0.9);
  --bg-glass: rgba(15, 23, 42, 0.72);
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-card: rgba(255, 255, 255, 0.10);
  --border-glow: rgba(14, 165, 233, 0.35);
  --border-active: rgba(14, 165, 233, 0.55);

  --text-main: #dbe4f0;
  --text-muted: #93a5bd;
  --text-dim: #5f7189;
  --text-heading: #ffffff;
  --text-on-primary: #ffffff;

  --color-primary: #0ea5e9;
  --color-primary-hover: #38bdf8;
  --color-primary-subtle: rgba(14, 165, 233, 0.13);

  --color-teal: #14b8a6;
  --color-teal-subtle: rgba(20, 184, 166, 0.13);

  --color-emerald: #34d399;
  --color-emerald-subtle: rgba(52, 211, 153, 0.13);

  --color-amber: #fbbf24;
  --color-amber-subtle: rgba(251, 191, 36, 0.13);

  --color-rose: #fb7185;
  --color-rose-subtle: rgba(251, 113, 133, 0.13);

  --color-sky: #38bdf8;
  --color-sky-subtle: rgba(56, 189, 248, 0.13);

  --color-violet: #a78bfa;
  --color-violet-subtle: rgba(167, 139, 250, 0.13);

  --shadow-card: 0 2px 10px -2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 22px rgba(14, 165, 233, 0.10), 0 0 44px rgba(14, 165, 233, 0.04);
  --shadow-elevated: 0 10px 36px -8px rgba(0, 0, 0, 0.55), 0 4px 10px -4px rgba(0, 0, 0, 0.3);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.04);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --header-height: 56px;
  --sidebar-width: 262px;

  --t-fast: 0.15s ease;
  --t-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
  --bg-app: #eef2f7;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f4f6fa;
  --bg-card: rgba(255, 255, 255, 0.92);
  --bg-card-hover: rgba(255, 255, 255, 1);
  --bg-input: #ffffff;
  --bg-glass: rgba(255, 255, 255, 0.86);
  --border-subtle: #e3e9f2;
  --border-card: #d4dde9;
  --border-glow: rgba(14, 165, 233, 0.28);
  --border-active: rgba(2, 132, 199, 0.5);

  --text-main: #1e2a40;
  --text-muted: #47586e;
  --text-dim: #66758a;
  --text-heading: #0b1220;
  --text-on-primary: #ffffff;

  --color-primary: #0284c7;
  --color-primary-hover: #0ea5e9;
  --color-primary-subtle: rgba(2, 132, 199, 0.08);

  --color-teal: #0d9488;
  --color-teal-subtle: rgba(13, 148, 136, 0.08);

  --color-emerald: #059669;
  --color-emerald-subtle: rgba(5, 150, 105, 0.1);

  --color-amber: #d97706;
  --color-amber-subtle: rgba(217, 119, 6, 0.1);

  --color-rose: #e11d48;
  --color-rose-subtle: rgba(225, 29, 72, 0.1);

  --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.06), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
  --shadow-glow: 0 0 15px rgba(2, 132, 199, 0.12);
  --color-emerald-subtle: rgba(5, 150, 105, 0.08);

  --color-amber: #d97706;
  --color-amber-subtle: rgba(217, 119, 6, 0.08);

  --color-rose: #e11d48;
  --color-rose-subtle: rgba(225, 29, 72, 0.08);

  --color-sky: #0369a1;
  --color-sky-subtle: rgba(3, 105, 161, 0.08);

  --color-violet: #7c3aed;
  --color-violet-subtle: rgba(124, 58, 237, 0.08);

  --shadow-card: 0 1px 3px rgba(15, 30, 60, 0.06), 0 1px 2px rgba(15, 30, 60, 0.04);
  --shadow-glow: 0 0 16px rgba(2, 132, 199, 0.08);
  --shadow-elevated: 0 12px 30px -6px rgba(15, 30, 60, 0.14), 0 6px 12px -6px rgba(15, 30, 60, 0.06);
  --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
/* --- Base & Reset --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
  font-size: 14px;
  transition: background-color var(--t-base), color var(--t-base);
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', 'Inter', sans-serif;
  color: var(--text-heading);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(14, 165, 233, 0.06), transparent 55%),
    radial-gradient(900px 500px at -10% 110%, rgba(20, 184, 166, 0.05), transparent 55%);
  pointer-events: none;
  z-index: 0;
}

/* --- Layout Structure --- */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Navigation */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 50;
  transition: transform var(--t-base), width var(--t-base);
}

.sidebar-logo {
  padding: 1.05rem 1.15rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: var(--header-height);
}

.ards-logo {
  width: 35px;
  height: 35px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-teal));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.25);
}

.ards-logo-ecg {
  width: 18px;
  height: 18px;
  stroke: white;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.ards-logo-lg {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
}

.ards-logo-lg .ards-logo-ecg {
  width: 27px;
  height: 27px;
}

.ards-wordmark {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.6rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.16rem;
}

.sidebar-nav::-webkit-scrollbar {
  width: 3px;
}
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 4px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.68rem;
  padding: 0.58rem 0.72rem;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--t-fast);
  text-align: left;
  width: 100%;
  position: relative;
}

.nav-btn:hover {
  background: var(--color-primary-subtle);
  color: var(--text-heading);
  border-color: rgba(14, 165, 233, 0.12);
  transform: translateX(2px);
}

.nav-btn-active {
  background: var(--color-primary-subtle);
  color: var(--color-sky);
  border-color: rgba(14, 165, 233, 0.25);
  font-weight: 600;
}

.nav-btn-active::before {
  content: '';
  position: absolute;
  left: -0.65rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 64%;
  background: linear-gradient(180deg, var(--color-primary), var(--color-teal));
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px rgba(14, 165, 233, 0.4);
}

.nav-btn i {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-btn-active i {
  opacity: 1;
}

.nav-btn span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  padding: 0.6rem 0.85rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.sidebar-user-chip {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem;
  border-radius: 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
}

.sidebar-user-chip:hover {
  border-color: var(--border-glow);
}

.sidebar-user-avatar {
  width: 27px;
  height: 27px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-teal));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-heading);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.62rem;
  color: var(--text-dim);
}

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

/* Header */
.app-header {
  min-height: var(--header-height);
  padding: 0.55rem 1.5rem;
  background: var(--bg-surface);
  background: color-mix(in srgb, var(--bg-surface) 82%, transparent);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: 0.62rem;
  min-width: 0;
}

.mobile-menu-toggle {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--t-fast);
}

.mobile-menu-toggle:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-heading);
  border-color: var(--border-subtle);
}

.app-header-title {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-heading);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* Content Wrapper */
.content-wrapper {
  flex: 1;
  padding: 1.4rem 1.5rem 2rem;
  max-width: 100%;
  position: relative;
  z-index: 1;
}

.tab-section {
  animation: fadeInUp 0.3s var(--t-base);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Cards --- */
.ards-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--t-base), border-color var(--t-base), transform var(--t-base);
  backdrop-filter: blur(6px);
}

.ards-card:hover {
  box-shadow: var(--shadow-elevated);
  border-color: var(--border-glow);
}

[data-theme="light"] .ards-card {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05), 0 2px 6px -1px rgba(0, 0, 0, 0.02) !important;
}

[data-theme="light"] .ards-card:hover {
  border-color: rgba(2, 132, 199, 0.4) !important;
  box-shadow: 0 8px 25px -4px rgba(0, 0, 0, 0.08), 0 0 15px rgba(2, 132, 199, 0.08) !important;
}

/* ==========================================================================
   LIGHT MODE CONTRAST & READABILITY OVERRIDES (Desktop & Mobile)
   ========================================================================== */

/* Typography & Text Contrast Overrides for Light Mode */
[data-theme="light"] h1,
[data-theme="light"] h2,
[data-theme="light"] h3,
[data-theme="light"] h4,
[data-theme="light"] h5,
[data-theme="light"] h6,
[data-theme="light"] .text-slate-100,
[data-theme="light"] .text-slate-200 {
  color: #0f172a !important;
}

[data-theme="light"] .text-slate-300 {
  color: #1e293b !important;
}

[data-theme="light"] .text-slate-400 {
  color: #334155 !important;
}

[data-theme="light"] .text-slate-500 {
  color: #475569 !important;
}

/* Colored text contrast in Light Mode (replaces pale dark-mode accents with rich, legible tones) */
[data-theme="light"] .text-amber-100,
[data-theme="light"] .text-amber-200,
[data-theme="light"] .text-amber-300 {
  color: #78350f !important; /* amber-900 */
}

[data-theme="light"] .text-amber-400 {
  color: #b45309 !important; /* amber-700 */
}

[data-theme="light"] .text-sky-300 {
  color: #0369a1 !important; /* sky-700 */
}

[data-theme="light"] .text-sky-400 {
  color: #0284c7 !important; /* sky-600 */
}

[data-theme="light"] .text-teal-300 {
  color: #0f766e !important; /* teal-700 */
}

[data-theme="light"] .text-teal-400 {
  color: #0d9488 !important; /* teal-600 */
}

[data-theme="light"] .text-emerald-300 {
  color: #047857 !important; /* emerald-700 */
}

[data-theme="light"] .text-emerald-400 {
  color: #059669 !important; /* emerald-600 */
}

[data-theme="light"] .text-purple-300,
[data-theme="light"] .text-purple-400 {
  color: #7e22ce !important; /* purple-700 */
}

[data-theme="light"] .text-rose-300,
[data-theme="light"] .text-rose-400 {
  color: #e11d48 !important; /* rose-600 */
}

[data-theme="light"] .text-cyan-400 {
  color: #0891b2 !important; /* cyan-600 */
}

[data-theme="light"] .text-indigo-400 {
  color: #4338ca !important; /* indigo-700 */
}

/* Elevated Subcards, Blocks & Panels in Light Mode */
[data-theme="light"] .bg-slate-950,
[data-theme="light"] .bg-slate-900,
[data-theme="light"] .bg-slate-900\/90,
[data-theme="light"] .bg-slate-900\/80,
[data-theme="light"] .bg-slate-900\/70,
[data-theme="light"] .bg-slate-900\/60,
[data-theme="light"] .bg-slate-900\/40,
[data-theme="light"] .bg-slate-900\/30,
[data-theme="light"] .bg-slate-800,
[data-theme="light"] .bg-slate-800\/90,
[data-theme="light"] .bg-slate-800\/80,
[data-theme="light"] .bg-slate-800\/60,
[data-theme="light"] .bg-slate-800\/40 {
  background-color: #f8fafc !important;
}

[data-theme="light"] .bg-gradient-to-br.from-slate-900\/90.to-slate-800\/80,
[data-theme="light"] .bg-gradient-to-br.from-slate-900\/90.to-slate-700 {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%) !important;
}

/* Light mode borders */
[data-theme="light"] .border-slate-800,
[data-theme="light"] .border-slate-800\/80,
[data-theme="light"] .border-slate-800\/60,
[data-theme="light"] .border-slate-700,
[data-theme="light"] .border-slate-700\/80,
[data-theme="light"] .border-slate-700\/60,
[data-theme="light"] .border-slate-700\/50,
[data-theme="light"] .divide-slate-800 > :not([hidden]) ~ :not([hidden]),
[data-theme="light"] .divide-slate-800\/60 > :not([hidden]) ~ :not([hidden]) {
  border-color: #e2e8f0 !important;
}

/* --- Disclaimer & Advisory Alert Boxes --- */
[data-theme="light"] .bg-amber-500\/10 {
  background-color: #fffbeb !important;
  border-color: #fcd34d !important;
}

[data-theme="light"] .bg-amber-500\/10.text-amber-200,
[data-theme="light"] .bg-amber-500\/10 .text-amber-100\/90,
[data-theme="light"] .bg-amber-500\/10 ul,
[data-theme="light"] .bg-amber-500\/10 li {
  color: #78350f !important;
}

[data-theme="light"] .bg-amber-500\/10 .text-amber-400,
[data-theme="light"] .bg-amber-500\/10 i {
  color: #b45309 !important;
}

/* Tinted info and narrative boxes in Light Mode */
[data-theme="light"] .bg-sky-500\/10 {
  background-color: #f0f9ff !important;
  border-color: #bae6fd !important;
  color: #0369a1 !important;
}
[data-theme="light"] .bg-sky-500\/10 p,
[data-theme="light"] .bg-sky-500\/10 span {
  color: #0369a1 !important;
}

[data-theme="light"] .bg-emerald-500\/10 {
  background-color: #ecfdf5 !important;
  border-color: #a7f3d0 !important;
}

[data-theme="light"] .bg-rose-500\/10 {
  background-color: #fff1f2 !important;
  border-color: #fecdd3 !important;
}

/* Recommendation Banner in Light Mode */
[data-theme="light"] #homeRecBanner > div {
  background: linear-gradient(90deg, rgba(2, 132, 199, 0.08) 0%, rgba(13, 148, 136, 0.08) 50%, rgba(16, 185, 129, 0.08) 100%) !important;
  border-color: rgba(2, 132, 199, 0.25) !important;
}

/* Code & Formula Badges */
[data-theme="light"] #section-about .bg-slate-900.font-mono {
  background-color: #0f172a !important;
  color: #38bdf8 !important;
  border-color: #1e293b !important;
}

/* Circular Score Gauge */
[data-theme="light"] svg path.text-slate-800 {
  stroke: #e2e8f0 !important;
}

/* Progress Bars */
[data-theme="light"] .bg-slate-800.rounded-full {
  background-color: #e2e8f0 !important;
}

/* Form Controls & Inputs */
[data-theme="light"] .form-select,
[data-theme="light"] .form-input,
[data-theme="light"] select,
[data-theme="light"] textarea,
[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="number"],
[data-theme="light"] input[type="password"],
[data-theme="light"] input[type="file"] {
  background-color: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
  color: #0f172a !important;
  font-weight: 500;
}

[data-theme="light"] .form-select:focus,
[data-theme="light"] .form-input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] input:focus,
[data-theme="light"] textarea:focus {
  border-color: #0284c7 !important;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15) !important;
}

[data-theme="light"] select option {
  background-color: #ffffff !important;
  color: #0f172a !important;
}

/* Custom Sliders in Light Mode */
[data-theme="light"] input[type=range]::-webkit-slider-runnable-track {
  background: #cbd5e1 !important;
}
[data-theme="light"] input[type=range]::-webkit-slider-thumb {
  background: #0284c7 !important;
  border: 2px solid #ffffff !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25) !important;
}

/* Tables in Light Mode */
[data-theme="light"] table thead,
[data-theme="light"] table thead.bg-slate-800\/80 {
  background-color: #f1f5f9 !important;
  color: #334155 !important;
  border-bottom: 1px solid #cbd5e1 !important;
}

[data-theme="light"] table thead th {
  color: #475569 !important;
  font-weight: 700;
}

[data-theme="light"] table tbody tr {
  color: #0f172a !important;
  border-color: #e2e8f0 !important;
}

[data-theme="light"] table tbody tr:hover,
[data-theme="light"] table tr.hover\:bg-slate-800\/30:hover {
  background-color: #f1f5f9 !important;
}

/* Dropzone & Drag Area */
[data-theme="light"] #csvDropzone {
  background-color: #f8fafc !important;
  border-color: #cbd5e1 !important;
}
[data-theme="light"] #csvDropzone:hover {
  border-color: #0284c7 !important;
  background-color: #f0f9ff !important;
}

/* Header & Navigation in Light Mode */
[data-theme="light"] .app-header {
  background-color: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid #e2e8f0;
}

[data-theme="light"] .app-sidebar {
  background-color: #ffffff;
  border-right: 1px solid #e2e8f0;
}

[data-theme="light"] #themeToggleBtn {
  background-color: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
  color: #334155 !important;
}
[data-theme="light"] #themeToggleBtn:hover {
  background-color: #e2e8f0 !important;
}

[data-theme="light"] .header-user-widget {
  background-color: #ffffff !important;
  border-color: #cbd5e1 !important;
}
[data-theme="light"] .header-user-widget:hover {
  background-color: #f8fafc !important;
  border-color: #0284c7 !important;
}

[data-theme="light"] .user-dropdown-menu {
  background-color: #ffffff !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.12), 0 4px 10px -2px rgba(0, 0, 0, 0.05) !important;
}

[data-theme="light"] .user-dropdown-item {
  color: #1e293b !important;
}
[data-theme="light"] .user-dropdown-item:hover {
  background-color: #f1f5f9 !important;
  color: #0284c7 !important;
}

[data-theme="light"] .sidebar-user-details,
[data-theme="light"] #sidebarUserBadge {
  background-color: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

[data-theme="light"] .sidebar-footer {
  background-color: #fffbeb !important;
  border-color: #fde68a !important;
}

/* Modals & Overlay in Light Mode */
[data-theme="light"] #modalAddPatient .ards-card,
[data-theme="light"] #modalAddSession .ards-card,
[data-theme="light"] .lock-card {
  background-color: #ffffff !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.25) !important;
}

[data-theme="light"] .auth-card {
  background-color: #ffffff !important;
  border-color: #e2e8f0 !important;
}

[data-theme="light"] .auth-preset-btn {
  background-color: #f8fafc !important;
  border-color: #e2e8f0 !important;
}
[data-theme="light"] .auth-preset-btn:hover {
  background-color: #f1f5f9 !important;
  border-color: #0284c7 !important;
}

[data-theme="light"] .auth-input {
  background-color: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

/* Printable Report in Light Mode */
[data-theme="light"] .printable-report {
  background-color: #ffffff !important;
  border-color: #e2e8f0 !important;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.08) !important;
}

.ards-card-pinned {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-glow), var(--shadow-card);
}

.ards-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--border-subtle);
}

.ards-card-title {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.01em;
}

.ards-card-subtitle {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.4;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--color-primary);
  background: linear-gradient(135deg, var(--color-primary), color-mix(in srgb, var(--color-primary) 75%, #0d9488));
  color: var(--text-on-primary);
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.2);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-heading);
  border-color: var(--border-card);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-card);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-surface-elevated);
  color: var(--text-heading);
}

.btn-success {
  background: var(--color-emerald);
  background: linear-gradient(135deg, var(--color-emerald), color-mix(in srgb, var(--color-emerald) 70%, #059669));
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(52, 211, 153, 0.2);
}

.btn-success:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 4px 14px rgba(52, 211, 153, 0.32);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--color-rose);
  background: linear-gradient(135deg, var(--color-rose), color-mix(in srgb, var(--color-rose) 70%, #e11d48));
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(251, 113, 133, 0.2);
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 4px 14px rgba(251, 113, 133, 0.32);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 0.32rem 0.7rem;
  font-size: 0.72rem;
  border-radius: 8px;
}

.btn-lg {
  padding: 0.62rem 1.5rem;
  font-size: 0.86rem;
  border-radius: 12px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-sm {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
}

/* --- Form Controls --- */
.form-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  letter-spacing: 0.01em;
}

.form-input,
.form-select {
  width: 100%;
  padding: 0.5rem 0.7rem;
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  font-size: 0.8rem;
  color: var(--text-main);
  line-height: 1.4;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  appearance: none;
}

.form-input::placeholder {
  color: var(--text-dim);
}

.form-input:hover,
.form-select:hover {
  border-color: var(--border-glow);
}

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

.form-input:disabled,
.form-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' width=\'12\' height=\'12\' viewBox=\'0 0 24 24\' fill=\'none\' stroke=\'%2394a3b8\' stroke-width=\'2\' stroke-linecap=\'round\' stroke-linejoin=\'round\'%3E%3Cpath d=\'M6 9l6 6 6-6\'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
}

.form-hint {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
}

.form-error {
  font-size: 0.68rem;
  color: var(--color-rose);
  margin-top: 0.2rem;
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.17rem 0.5rem;
  border-radius: 7px;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-primary {
  background: var(--color-primary-subtle);
  color: var(--color-sky);
  border: 1px solid var(--border-glow);
}

.badge-success {
  background: var(--color-emerald-subtle);
  color: var(--color-emerald);
  border: 1px solid rgba(52, 211, 153, 0.2);
}

.badge-warning {
  background: var(--color-amber-subtle);
  color: var(--color-amber);
  border: 1px solid rgba(251, 191, 36, 0.2);
}

.badge-danger {
  background: var(--color-rose-subtle);
  color: var(--color-rose);
  border: 1px solid rgba(251, 113, 133, 0.2);
}

.badge-neutral {
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

/* --- Alerts --- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  border: 1px solid;
  font-size: 0.78rem;
  line-height: 1.5;
}

.alert-info {
  background: var(--color-primary-subtle);
  border-color: var(--border-glow);
  color: var(--text-main);
}

.alert-success {
  background: var(--color-emerald-subtle);
  border-color: rgba(52, 211, 153, 0.2);
  color: var(--text-main);
}

.alert-warning {
  background: var(--color-amber-subtle);
  border-color: rgba(251, 191, 36, 0.2);
  color: var(--text-main);
}

.alert-danger {
  background: var(--color-rose-subtle);
  border-color: rgba(251, 113, 133, 0.2);
  color: var(--text-main);
}

.alert-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 2px;
}

.alert-content {
  flex: 1;
  min-width: 0;
}

.alert-title {
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 0.1rem;
}

/* --- Tables --- */
.ards-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.ards-table thead {
  background: var(--bg-surface-elevated);
}

.ards-table th {
  padding: 0.6rem 0.7rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.ards-table td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

.ards-table tbody tr {
  transition: background var(--t-fast);
}

.ards-table tbody tr:hover {
  background: var(--bg-surface-elevated);
}

.ards-table tbody tr:last-child td {
  border-bottom: none;
}

/* --- Modals --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.62);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-elevated);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.95rem 1.15rem;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.01em;
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--t-fast);
}

.modal-close:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-heading);
}

.modal-body {
  padding: 1.15rem 1.25rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  padding: 0.7rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
}

/* --- Stat Cards --- */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1rem 1.15rem;
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  transition: box-shadow var(--t-base), border-color var(--t-base), transform var(--t-base);
}

.stat-card:hover {
  box-shadow: var(--shadow-elevated);
  border-color: var(--border-glow);
  transform: translateY(-1px);
}

.stat-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon i {
  width: 18px;
  height: 18px;
}

.stat-content {
  flex: 1;
  min-width: 0;
}

.stat-value {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
}

.stat-trend {
  font-size: 0.68rem;
  font-weight: 600;
  margin-top: 0.2rem;
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.stat-trend-up { color: var(--color-emerald); }
.stat-trend-down { color: var(--color-rose); }

/* --- Progress Bar --- */
.progress-bar {
  height: 5px;
  background: var(--bg-surface-elevated);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Dividers --- */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0.85rem 0;
}

/* --- Utility --- */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-mono { font-family: 'JetBrains Mono', monospace; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

/* --- Login Screen --- */
/* --- Login Screen Overlay --- */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #070a12;
  background-image: radial-gradient(circle at 50% 20%, rgba(14, 165, 233, 0.12), transparent 70%),
                    radial-gradient(circle at 80% 80%, rgba(13, 148, 136, 0.1), transparent 60%);
  padding: 1.5rem;
  overflow-y: auto;
  color: #ffffff !important;
  color-scheme: dark;
}

/* Force crisp pure white text contrast across all login card elements */
.login-card h1,
.login-portal-card h1,
.login-brand h1 {
  color: #ffffff !important;
  font-weight: 800 !important;
}

.login-brand span {
  color: #e2e8f0 !important;
}

.login-quickfill-section h3 {
  color: #ffffff !important;
  font-weight: 700 !important;
}

.login-quickfill-section span {
  color: #e2e8f0 !important;
}

.quickfill-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(51, 65, 85, 0.8);
  border-radius: 0.85rem;
  padding: 0.75rem 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.quickfill-card span.text-slate-200,
.quickfill-card .text-slate-200,
.quickfill-card span.font-bold {
  color: #ffffff !important;
  font-weight: 700 !important;
}

.quickfill-card span.text-slate-400,
.quickfill-card .text-slate-400 {
  color: #e2e8f0 !important;
}

.login-field label {
  color: #ffffff !important;
  font-weight: 700 !important;
}

.login-remember {
  color: #cbd5e1 !important;
}

.login-footer {
  color: #94a3b8 !important;
}

/* Defense-in-depth: once the dashboard is unlocked (no .auth-locked on
   <body>), the auth overlay must never render — over or inside the
   dashboard layout — even if a script error leaves stale classes behind. */
body:not(.auth-locked) .login-screen {
  display: none !important;
}

.login-orbs {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.35;
  animation: orbFloat 14s ease-in-out infinite;
}

.login-orb-1 {
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, #0284c7, transparent 70%);
  top: -10%;
  right: -5%;
  animation-delay: 0s;
}

.login-orb-2 {
  width: 360px;
  height: 360px;
  background: radial-gradient(circle, #0d9488, transparent 70%);
  bottom: -10%;
  left: -5%;
  animation-delay: -5s;
}

.login-orb-3 {
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, #8b5cf6, transparent 70%);
  top: 40%;
  left: 50%;
  animation-delay: -9s;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(18px, -18px) scale(1.04); }
  66% { transform: translate(-12px, 12px) scale(0.96); }
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(51, 65, 85, 0.7);
  border-radius: 1.25rem;
  padding: 1.85rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 35px rgba(14, 165, 233, 0.1);
  animation: scaleIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-sizing: border-box;
}

.login-portal-card {
  max-width: 960px;
  padding: 2.25rem;
}

.login-split-layout {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  width: 100%;
}

@media (min-width: 900px) {
  .login-split-layout {
    flex-direction: row;
    align-items: stretch;
    gap: 2.5rem;
  }
  .login-quickfill-section {
    flex: 1 1 0%;
    min-width: 0;
  }
  .login-manual-section {
    flex: 0 0 360px;
    min-width: 0;
    border-left: 1px solid rgba(51, 65, 85, 0.6);
    padding-left: 2.5rem;
    box-sizing: border-box;
  }
}

.clinician-quickfill-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 600px) {
  .clinician-quickfill-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.quickfill-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(51, 65, 85, 0.7);
  border-radius: 0.85rem;
  padding: 0.75rem 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.quickfill-card:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(56, 189, 248, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.avatar-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: inherit;
  z-index: -1;
}

.login-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid rgba(51, 65, 85, 0.6);
}

.login-divider span {
  padding: 0 0.75rem;
  color: #94a3b8;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

@media (min-width: 900px) {
  .login-divider {
    display: none;
  }
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.login-brand .ards-logo {
  width: 3rem;
  height: 3rem;
  border-radius: 0.85rem;
}

.login-tabs {
  display: flex;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(51, 65, 85, 0.7);
  border-radius: 0.75rem;
  padding: 4px;
  margin-bottom: 1.25rem;
  width: 100%;
  box-sizing: border-box;
}

.login-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  color: #94a3b8;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  white-space: nowrap;
}

.login-tab svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.login-tab:hover {
  color: #f8fafc;
}

.login-tab.login-tab-active,
.login-tab.active {
  background: #0284c7;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  width: 100%;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
}

.login-field label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  display: block;
}

.login-input-wrap {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.login-input-icon {
  position: absolute;
  left: 0.85rem;
  width: 1.1rem;
  height: 1.1rem;
  color: #64748b;
  pointer-events: none;
  transition: color 0.2s ease;
  z-index: 2;
}

.login-input {
  width: 100%;
  height: 2.75rem;
  padding-left: 2.6rem;
  padding-right: 2.5rem;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(51, 65, 85, 0.8);
  border-radius: 0.75rem;
  font-size: 0.875rem;
  color: #f8fafc;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.login-input::placeholder {
  color: #64748b;
  opacity: 1;
}

.login-input:focus {
  outline: none;
  border-color: #38bdf8;
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.25);
}

.login-input-wrap:focus-within .login-input-icon {
  color: #38bdf8;
}

.login-pw-toggle {
  position: absolute;
  right: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  padding: 0.35rem;
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
  z-index: 2;
}

.login-pw-toggle:hover {
  color: #f8fafc;
}

.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  margin-top: 0.2rem;
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: #94a3b8;
  cursor: pointer;
}

.login-remember input[type="checkbox"] {
  accent-color: #0284c7;
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.login-forgot {
  color: #38bdf8;
  text-decoration: none;
}

.login-forgot:hover {
  text-decoration: underline;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  pointer-events: none;
}

.login-submit {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.85rem;
  background: linear-gradient(135deg, #0284c7, #0d9488);
  color: #ffffff;
  border: none;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 0.5rem;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
}

.login-submit svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.login-submit:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.5);
  transform: translateY(-1px);
}

.login-message {
  padding: 0.6rem 0.85rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  margin-top: 0.5rem;
}

.login-message-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.login-message-error {
  background: rgba(244, 63, 94, 0.15);
  color: #fb7185;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.login-demo-box {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.65rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 0.6875rem;
  color: var(--text-dim);
}

.login-demo-box > svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
  color: #f59e0b;
}

.login-demo-box strong {
  color: var(--text-muted);
}
/* ==========================================================================
   LOGIN SCREEN — FIELD / INPUT STYLES (referenced by markup but previously
   undefined; token-based so they follow both themes automatically)
   ========================================================================== */
.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.login-field label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.login-input-wrap {
  position: relative;
}

.login-input-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-dim);
  pointer-events: none;
}

.login-input {
  width: 100%;
  padding: 0.6rem 2.4rem 0.6rem 2.15rem;
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text-main);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

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

.login-input::placeholder {
  color: var(--text-dim);
}

select.login-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
  cursor: pointer;
}

.login-pw-toggle {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s ease;
}

.login-pw-toggle:hover {
  color: var(--text-main);
  background: var(--bg-surface-elevated);
}

.login-pw-toggle svg {
  width: 16px;
  height: 16px;
}

.login-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: none;
  background: transparent;
  color: var(--color-sky);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.25rem 0.45rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.login-link-btn:hover {
  background: var(--color-primary-subtle);
}

.login-demo-cred {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6875rem;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 0.05rem 0.3rem;
  color: var(--text-main);
}

.login-footer {
  margin-top: 1rem;
  font-size: 0.6875rem;
  color: var(--text-dim);
  line-height: 1.5;
  text-align: center;
}

.login-footer svg {
  width: 12px;
  height: 12px;
  vertical-align: -2px;
}

/* --------------------------------------------------------------------------
   Login-screen layout insurance — scoped fallbacks mirroring the utility
   classes used in the login markup, so the card stays perfectly aligned
   even if the Tailwind CDN is unreachable (offline / blocked network).
   No effect when the CDN loads (identical values).
   -------------------------------------------------------------------------- */
.login-brand .flex { display: flex; }
.login-brand .flex-col { flex-direction: column; }
.login-brand .items-center { align-items: center; }
.login-brand .justify-center { justify-content: center; }
.login-brand .gap-1\.5 { gap: 0.375rem; }
.login-brand .flex-shrink-0 { flex-shrink: 0; }
.login-brand .min-w-0 { min-width: 0; }
.login-brand .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-brand .text-white { color: #fff; }

.login-form .flex { display: flex; }
.login-form .items-center { align-items: center; }
.login-form .justify-between { justify-content: space-between; }
.login-form .flex-wrap { flex-wrap: wrap; }
.login-form .gap-2 { gap: 0.5rem; }
.login-form .grid { display: grid; }
.login-form .grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.login-form .gap-3 { gap: 0.75rem; }

/* ==========================================================================
/* --- Auth & Gating ---
   When unlocked, the app is visible and the login screen overlay
   is hidden, while locked (body.auth-locked) the dashboard content and
   sidebar are hidden so the login screen acts as a dedicated portal view.
*/
body.auth-locked {
  overflow: hidden;
}

body.auth-locked .app-container {
  display: none !important;
}

body.auth-locked .ards-chatbot-root {
  display: none;
}

/* Do not print the auth gate */
@media print {
  .login-screen {
    display: none;
  }
}

/* ==========================================================================
   CLINICAL ASSISTANT — FLOATING CHATBOT (injected by js/chatbot.js)
   ========================================================================== */
.ards-chatbot-root {
  position: fixed;
  right: 1.35rem;
  bottom: 1.35rem;
  z-index: 90;
  font-size: 0.8rem;
}

.ards-chatbot-fab {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--color-primary);
  background: linear-gradient(135deg, var(--color-primary), color-mix(in srgb, var(--color-primary) 65%, #0d9488));
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.35), 0 2px 6px rgba(2, 6, 23, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ards-chatbot-fab:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 12px 30px rgba(14, 165, 233, 0.45), 0 3px 8px rgba(2, 6, 23, 0.3);
}

.ards-chatbot-fab-open {
  transform: rotate(90deg);
}

.ards-chatbot-fab-icon {
  width: 24px;
  height: 24px;
}

.ards-chatbot-fab-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(14, 165, 233, 0.5);
  animation: chatbotPulse 2.4s ease-out infinite;
  pointer-events: none;
}

@keyframes chatbotPulse {
  0% { transform: scale(0.85); opacity: 0.9; }
  70% { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

.ards-chatbot-panel {
  position: absolute;
  right: 0;
  bottom: 68px;
  width: min(380px, calc(100vw - 2.2rem));
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: 18px;
  box-shadow: var(--shadow-elevated);
  overflow: hidden;
  animation: chatbotSlideUp 0.28s cubic-bezier(0.34, 1.4, 0.64, 1);
  font-size: 0.8rem;
}

@keyframes chatbotSlideUp {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ards-chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.8rem 0.9rem;
  background: linear-gradient(135deg, var(--bg-surface-elevated), var(--bg-surface));
  border-bottom: 1px solid var(--border-subtle);
}

.ards-chatbot-header-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.ards-chatbot-avatar {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-primary), var(--color-teal));
  color: #fff;
  box-shadow: 0 3px 10px rgba(14, 165, 233, 0.3);
}

.ards-chatbot-title {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-weight: 700;
  font-size: 0.87rem;
  color: var(--text-heading);
  letter-spacing: -0.01em;
}

.ards-chatbot-subtitle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}

.ards-chatbot-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-emerald);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.6);
  flex-shrink: 0;
}

.ards-chatbot-header-actions {
  display: flex;
  gap: 0.25rem;
}

.ards-chatbot-icon-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.ards-chatbot-icon-btn:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-heading);
}

.ards-chatbot-messages {
  max-height: 320px;
  overflow-y: auto;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bg-app);
}

.ards-chatbot-messages::-webkit-scrollbar {
  width: 4px;
}

.ards-chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 4px;
}

.ards-chatbot-row {
  display: flex;
  gap: 0.45rem;
  max-width: 100%;
}

.ards-chatbot-row-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ards-chatbot-row-bot {
  align-self: flex-start;
}

.ards-chatbot-bubble {
  padding: 0.5rem 0.68rem;
  border-radius: 14px;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.ards-chatbot-bubble-bot {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  border-top-left-radius: 4px;
}

.ards-chatbot-bubble-user {
  background: linear-gradient(135deg, var(--color-primary), #0284c7);
  color: #fff;
  border-top-right-radius: 4px;
}

.ards-chatbot-typing {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.65rem 0.8rem;
  align-items: center;
}

.ards-chatbot-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: typingBounce 1.2s infinite ease-in-out;
}

.ards-chatbot-typing span:nth-child(2) { animation-delay: 0.15s; }
.ards-chatbot-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.ards-chatbot-heading {
  font-weight: 700;
  margin-top: 0.35rem;
  margin-bottom: 0.25rem;
  color: var(--text-heading);
}

.ards-chatbot-table-wrap {
  overflow-x: auto;
  margin: 0.35rem 0;
}

.ards-chatbot-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.72rem;
}

.ards-chatbot-table th,
.ards-chatbot-table td {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border-subtle);
  text-align: left;
}

.ards-chatbot-table th {
  background: var(--bg-surface-elevated);
  color: var(--text-heading);
  font-weight: 600;
}

.ards-chatbot-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0 0.9rem 0.65rem;
  background: var(--bg-app);
}

.ards-chatbot-chip {
  padding: 0.3rem 0.55rem;
  font-size: 0.68rem;
  border-radius: 16px;
  border: 1px solid var(--border-card);
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
.ards-chatbot-chip:hover {
  border-color: var(--border-glow);
  color: var(--color-sky);
  background: var(--color-primary-subtle);
}

.ards-chatbot-form {
  display: flex;
  gap: 0.45rem;
  padding: 0.75rem 0.9rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.ards-chatbot-input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.7rem;
  font-size: 0.8rem;
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  border-radius: 10px;
  color: var(--text-main);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ards-chatbot-input::placeholder {
  color: var(--text-dim);
}

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

.ards-chatbot-send {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: linear-gradient(135deg, var(--color-primary), #0284c7);
  color: #fff;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ards-chatbot-send:hover {
  filter: brightness(1.1);
  transform: scale(1.04);
}

.ards-chatbot-footer {
  padding: 0.5rem 0.9rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  font-size: 0.65rem;
  color: var(--text-dim);
  text-align: center;
}

/* Responsive chatbot on mobile & small tablets */
@media (max-width: 640px) {
  .ards-chatbot-root {
    right: 0.85rem;
    bottom: 0.85rem;
  }

  .ards-chatbot-panel {
    right: 0;
    bottom: 64px;
    width: min(396px, calc(100vw - 1.7rem));
    border-radius: 16px;
  }

  .ards-chatbot-fab {
    width: 52px;
    height: 52px;
  }

  .ards-chatbot-messages {
    max-height: 46vh;
  }
}
}

/* ==========================================================================
   LIGHT MODE ADAPTATION LAYER
   --------------------------------------------------------------------------
   The markup and JS-rendered templates use Tailwind utilities hard-coded for
   the dark theme (slate surfaces, light text, 300/400-level accents). Rather
   than rewriting ~380 call sites (high regression risk), this layer remaps
   those exact utilities to light-theme equivalents ONLY when <html> carries
   [data-theme="light"]. Dark Mode output is untouched. Selectors keep the
   original class names (escaped "/"), so no markup or JS changes are needed.
   All replacement values meet WCAG AA (>= 4.5:1) on white / #f8fafc cards.
   ========================================================================== */

/* --- 1. Neutral surfaces: dark slate panels -> soft light panels ---------- */
[data-theme="light"] .bg-slate-900,
[data-theme="light"] .bg-slate-900\/30,
[data-theme="light"] .bg-slate-900\/40,
[data-theme="light"] .bg-slate-900\/60,
[data-theme="light"] .bg-slate-900\/70,
[data-theme="light"] .bg-slate-900\/80,
[data-theme="light"] .bg-slate-900\/90 {
  background-color: #f8fafc;
}

[data-theme="light"] .bg-slate-800,
[data-theme="light"] .bg-slate-800\/60,
[data-theme="light"] .bg-slate-800\/40,
[data-theme="light"] .bg-slate-800\/30 {
  background-color: #f1f5f9;
}

[data-theme="light"] .bg-slate-800\/80 {
  background-color: #f8fafc;
}

/* Toggle-switch track (kept gray so the white knob stays visible) */
[data-theme="light"] .bg-slate-700 {
  background-color: #cbd5e1;
}

/* Hover states for slate buttons/rows (progressively darker) */
[data-theme="light"] .hover\:bg-slate-700:hover {
  background-color: #e2e8f0;
}

[data-theme="light"] .hover\:bg-slate-800\/30:hover {
  background-color: #f1f5f9;
}

[data-theme="light"] .hover\:bg-slate-800\/40:hover,
[data-theme="light"] .hover\:bg-slate-800\/60:hover {
  background-color: #eef2f7;
}

/* --- 2. Borders: dark slate borders -> subtle light borders --------------- */
[data-theme="light"] .border-slate-800,
[data-theme="light"] .border-slate-800\/80,
[data-theme="light"] .border-slate-800\/60 {
  border-color: #e2e8f0;
}

[data-theme="light"] .border-slate-700,
[data-theme="light"] .border-slate-700\/80,
[data-theme="light"] .border-slate-700\/60,
[data-theme="light"] .border-slate-700\/50 {
  border-color: #cbd5e1;
}

[data-theme="light"] .divide-slate-800 > :not([hidden]) ~ :not([hidden]) {
  border-color: #e2e8f0;
}

/* Active auth tab (auth.js toggles .login-tab-active) */
.login-tab-active,
.login-tab.active {
  background: var(--bg-card);
  color: var(--text-heading);
  box-shadow: var(--shadow-card);
}

.ards-logo-sm {
  width: 36px;
  height: 36px;
}


.login-demo-cred {
  font-family: 'JetBrains Mono', monospace;
  color: var(--color-sky);
  font-size: 0.6875rem;
}

.login-demo-btn {
  margin-top: 0.4rem;
  padding: 0.3rem 0.6rem;
  background: var(--color-primary-subtle);
  color: var(--color-sky);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-sm);
  font-size: 0.6875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.login-demo-btn:hover {
  background: var(--color-primary);
  color: white;
}

/* --- Dashboard Specific Components --- */

/* Patient Selector */
.patient-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.patient-selector .form-select {
  min-width: 180px;
  width: auto;
}

/* Score Display */
.score-display {
  text-align: center;
  padding: 1.5rem;
}

.score-value {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 3rem;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, var(--color-primary), var(--color-teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.score-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.score-band {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
}

/* Chart Container */
.chart-container {
  position: relative;
  width: 100%;
  min-height: 250px;
}

.chart-container canvas {
  width: 100% !important;
}

/* Pipeline Visualization */
.pipeline-stage {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  transition: all 0.2s ease;
}

.pipeline-stage.active {
  border-color: var(--border-glow);
  background: var(--color-primary-subtle);
  box-shadow: var(--shadow-glow);
}

.pipeline-stage.completed {
  border-color: rgba(16, 185, 129, 0.25);
  background: var(--color-emerald-subtle);
}

.pipeline-stage-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.pipeline-stage.active .pipeline-stage-icon {
  background: var(--color-primary);
  color: white;
}

.pipeline-stage.completed .pipeline-stage-icon {
  background: var(--color-emerald);
  color: white;
}

.pipeline-stage.pending .pipeline-stage-icon {
  background: var(--bg-surface);
  color: var(--text-dim);
}

.pipeline-stage-content {
  flex: 1;
  min-width: 0;
}

.pipeline-stage-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-heading);
}

.pipeline-stage-desc {
  font-size: 0.6875rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
}

.pipeline-log {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  max-height: 200px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6875rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.pipeline-log-entry {
  padding: 0.15rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.pipeline-log-entry:last-child {
  border-bottom: none;
}

.pipeline-log-entry .log-time {
  color: var(--text-dim);
}

.pipeline-log-entry .log-level {
  font-weight: 600;
  margin: 0 0.3rem;
}

.pipeline-log-entry .log-level-info { color: var(--color-sky); }
.pipeline-log-entry .log-level-success { color: var(--color-emerald); }
.pipeline-log-entry .log-level-warning { color: var(--color-amber); }
.pipeline-log-entry .log-level-error { color: var(--color-rose); }

/* --- 3. Text: light slate text -> dark slate text (inverted scale) -------- */
[data-theme="light"] .text-slate-100 { color: #0f172a; }
[data-theme="light"] .text-slate-200 { color: #1e293b; }
[data-theme="light"] .text-slate-300 { color: #334155; }
[data-theme="light"] .text-slate-400 { color: #475569; }
[data-theme="light"] .text-slate-500 { color: #5b6a7d; }

[data-theme="light"] .hover\:text-slate-200:hover { color: #1e293b; }

/* --- 4. Accent text & icons: 300/400-level -> 600/700-level (AA on white) - */
[data-theme="light"] .text-sky-400,
[data-theme="light"] .text-sky-300 { color: #0369a1; }

[data-theme="light"] .text-emerald-400,
[data-theme="light"] .text-emerald-300 { color: #047857; }

[data-theme="light"] .text-teal-400,
[data-theme="light"] .text-teal-300 { color: #0f766e; }

[data-theme="light"] .text-amber-400,
[data-theme="light"] .text-amber-300 { color: #b45309; }

[data-theme="light"] .text-rose-400,
[data-theme="light"] .text-rose-300 { color: #be123c; }

[data-theme="light"] .text-cyan-400 { color: #0e7490; }
[data-theme="light"] .text-fuchsia-400 { color: #a21caf; }
[data-theme="light"] .text-purple-400 { color: #7e22ce; }
[data-theme="light"] .text-indigo-400 { color: #4f46e5; }

/* Warning copy that sits on amber-500/10 tints (stays amber in both themes) */
[data-theme="light"] .text-amber-200,
[data-theme="light"] .text-amber-200\/90,
[data-theme="light"] .text-amber-100\/90 { color: #92400e; }

/* --- 5. Hero/panel gradient stops: slate-900/800 -> light slate ----------- */
[data-theme="light"] .from-slate-900\/90 {
  --tw-gradient-from: rgb(241 245 249 / 0.95) var(--tw-gradient-from-position, );
}

[data-theme="light"] .to-slate-800\/80 {
  --tw-gradient-to: rgb(226 232 240 / 0.9) var(--tw-gradient-to-position, );
}

/* --- 6. Native dropdown popups (patient/session/role selects) ------------- */
[data-theme="light"] select option,
[data-theme="light"] select optgroup {
  background-color: #ffffff;
  color: #0f172a;
}

[data-theme="dark"] select option,
[data-theme="dark"] select optgroup {
  background-color: #1e293b;
  color: #f1f5f9;
}


/* ==========================================================================
   RESPONSIVE LAYER
   --------------------------------------------------------------------------
   Layout targets: 320 / 375 / 390 / 430 / 768 / 1024 / 1280 / 1440.
   Desktop layout (sidebar + content) is untouched above 1024px; below that
   the sidebar becomes an off-canvas drawer driven by body.sidebar-open.
   No HTML/JS behavior changes: Tailwind sm:/md:/lg: grid prefixes already
   collapse most grids; this layer fixes the header, nav, tables, forms,
   modals, touch targets and horizontal-overflow edge cases.
   ========================================================================== */

/* --- Wide desktop (>=1280): use available space efficiently --------------- */
@media (min-width: 1280px) {
  .content-wrapper {
    max-width: 1720px;
    margin-inline: auto;
    width: 100%;
  }

  /* Dashboard grid optimizations */
  .dashboard-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  /* Chart containers */
  .chart-container {
    height: 300px;
  }
}

/* --- Large desktop (>=1440): maximum space utilization ------------------- */
@media (min-width: 1440px) {
  .content-wrapper {
    max-width: 1600px;
  }

  .dashboard-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
  }
}

/* --- Responsive Adjustments (Desktop, Tablet & Mobile) --- */
/* Backdrop behind the off-canvas drawer (mobile/tablet only) */
.sidebar-backdrop {
  display: none;
}

/* --- Tablet & below (<=1024): off-canvas sidebar --------------------------- */
@media (max-width: 1024px) {
  .app-sidebar {
    transform: translateX(-100%);
    width: min(300px, 85vw);
    transition: transform 0.3s ease;
  }
  
  .sidebar-logo span,
  .nav-btn span,
  .nav-btn span.badge-num,
  .sidebar-footer,
  .sidebar-user-details {
    display: none;
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.45);
  }

  .app-main {
    margin-left: 0;
  }

  .mobile-menu-toggle {
    display: inline-flex;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(2, 6, 23, 0.55);
    backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .content-wrapper {
    padding: 1.25rem 1.25rem 1.75rem;
  }

  /* Header adjustments */
  .app-header {
    padding-inline: 1rem;
  }

  /* Grid adjustments */
  .grid-cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Card adjustments */
  .ards-card {
    padding: 1.5rem;
  }

  /* Table adjustments */
  .ards-card:has(> table),
  .ards-card:has(.ards-table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 700px;
  }
}

/* --- Phone landscape / small tablet (<=768) -------------------------------- */
@media (max-width: 768px) {
  /* Improved header layout */
  .app-header {
    flex-wrap: wrap;
    row-gap: 0.5rem;
    padding-inline: 0.75rem;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }

  /* Better sidebar behavior - keep as off-canvas drawer */
  .app-sidebar {
    transform: translateX(-100%);
    width: min(280px, 85vw);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    border-right: 1px solid var(--border-subtle);
  }

  body.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .sidebar-logo {
    padding: 1rem;
  }

  .sidebar-nav {
    flex-direction: column;
    padding: 0.5rem 1rem;
    gap: 0.25rem;
    overflow-y: auto;
  }

  .nav-btn {
    white-space: normal;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    width: 100%;
    min-height: 48px;
  }

  .nav-btn-active::before {
    display: block;
  }

  /* Show sidebar text on mobile */
  .sidebar-logo span,
  .nav-btn span,
  .sidebar-footer {
    display: block;
  }

  /* Content area adjustments */
  .app-main {
    margin-left: 0;
  }

  .content-wrapper {
    padding: 1rem 0.75rem 1.5rem;
  }

  .ards-card {
    padding: 1.1rem !important;
    margin-bottom: 1rem;
  }

  /* Improved overflow handling */
  .overflow-x-auto {
    margin-left: -0.75rem;
    margin-right: -0.75rem;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    -webkit-overflow-scrolling: touch;
  }

  /* Tables */
  table {
    min-width: 600px;
    font-size: 0.85rem;
  }

  th, td {
    padding: 0.5rem 0.75rem;
  }

  /* Form inputs */
  .form-select, .form-input, button, input[type=range] {
    min-height: 44px;
    font-size: 16px;
  }

  /* Modals */
  #modalAddPatient .ards-card,
  #modalAddSession .ards-card,
  .lock-card,
  .auth-card {
    margin: 0.5rem;
    padding: 1.25rem !important;
    max-height: 92vh;
    max-width: calc(100vw - 1rem);
  }

  /* Patient/session selectors */
  .app-header > div:first-of-type {
    order: 10;
    width: 100%;
    margin-bottom: 0.5rem;
  }

  #globalPatientSelect,
  #globalSessionSelect {
    min-width: 0;
    width: 100%;
  }

  /* Touch-friendly targets */
  .btn {
    min-height: 44px;
    padding: 0.75rem 1rem;
  }

  .nav-btn {
    min-height: 48px;
  }

  .modal-close,
  .mobile-menu-toggle,
  #themeToggleBtn,
  .login-pw-toggle {
    min-width: 44px;
    min-height: 44px;
  }

  /* Responsive tables */
  .ards-card:has(> table),
  .ards-card:has(.ards-table),
  .content-wrapper div:has(> table),
  .modal-dialog div:has(> table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
  }

  .content-wrapper table,
  .modal-dialog table {
    min-width: 600px;
  }

  /* Charts */
  canvas {
    max-width: 100%;
    height: auto !important;
  }

  .chart-container {
    position: relative;
    height: 250px;
    width: 100%;
  }

  /* Modals */
  .modal-body {
    padding: 1rem;
    max-height: 60vh;
    overflow-y: auto;
  }

  .modal-footer {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Cards */
  .ards-card {
    overflow-wrap: break-word;
  }

  .stat-card {
    padding: 0.85rem 1rem;
  }

  .login-card {
    padding: 1.5rem 1.25rem;
  }

  #csvDropzone {
    padding: 1.5rem 1rem;
  }

  /* Alert filter chips */
  #alertFilterBar {
    min-width: 0;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* Grid layouts */
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }

  /* Stat cards */
  .stat-value {
    font-size: 1.4rem;
  }

  .stat-label {
    font-size: 0.8rem;
  }

  /* Dashboard cards */
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  /* Override Tailwind grid classes for mobile */
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4,
  .grid-cols-5,
  .grid-cols-9 {
    grid-template-columns: 1fr !important;
  }

  .lg\:grid-cols-2,
  .lg\:grid-cols-3,
  .lg\:grid-cols-4,
  .lg\:grid-cols-5,
  .lg\:grid-cols-9 {
    grid-template-columns: 1fr !important;
  }

  .sm\:grid-cols-2,
  .sm\:grid-cols-3,
  .sm\:grid-cols-4,
  .sm\:grid-cols-5 {
    grid-template-columns: 1fr !important;
  }

  .md\:grid-cols-2,
  .md\:grid-cols-3,
  .md\:grid-cols-4 {
    grid-template-columns: 1fr !important;
  }

  /* Horizontal scroll containers */
  .horizontal-scroll-container {
    display: flex;
    overflow-x: auto;
    gap: 0.75rem;
    padding: 0.5rem 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .horizontal-scroll-container::-webkit-scrollbar {
    height: 4px;
  }

  .horizontal-scroll-container::-webkit-scrollbar-thumb {
    background: var(--border-card);
    border-radius: 4px;
  }

  .horizontal-scroll-container > * {
    min-width: 200px;
    flex-shrink: 0;
  }
}

/* ==========================================================================
   ARDS CLINICAL AUTHENTICATION & WORKSTATION LOCK STYLES
   ========================================================================== */

/* Fullscreen Auth Overlay */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background-color: var(--bg-app);
  overflow-y: auto;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.auth-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Ambient Medical Glow Background */
.auth-bg-ambient {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.auth-blob-1 {
  position: absolute;
  top: -10%;
  left: 15%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(2, 132, 199, 0.18) 0%, rgba(2, 132, 199, 0) 70%);
  border-radius: 50%;
  filter: blur(40px);
  animation: floatPulse 12s infinite alternate ease-in-out;
}

.auth-blob-2 {
  position: absolute;
  bottom: -10%;
  right: 15%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(13, 148, 136, 0.15) 0%, rgba(13, 148, 136, 0) 70%);
  border-radius: 50%;
  filter: blur(50px);
  animation: floatPulse 15s infinite alternate-reverse ease-in-out;
}

@keyframes floatPulse {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(25px, 20px) scale(1.08); }
  100% { transform: translate(-20px, 30px) scale(0.95); }
}

/* Glassmorphic Auth Card */
.auth-card {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 1050px;
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.6), var(--shadow-glow);
  overflow: hidden;
  animation: authCardEnter 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authCardEnter {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Quick Clinician Selector Buttons */
.auth-preset-btn {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-align: left;
  transition: all 0.2s ease;
  cursor: pointer;
  width: 100%;
}

.auth-preset-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px -5px rgba(2, 132, 199, 0.25);
}

.auth-preset-btn:active {
  transform: translateY(0);
}

/* Input Fields inside Auth */
.auth-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-group i.input-icon {
  position: absolute;
  left: 0.95rem;
  color: var(--text-dim);
  pointer-events: none;
}

.auth-input {
  width: 100%;
  padding: 0.75rem 0.95rem 0.75rem 2.6rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-card);
  background: var(--bg-surface);
  color: var(--text-main);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

.password-toggle-btn {
  position: absolute;
  right: 0.85rem;
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.password-toggle-btn:hover {
  color: var(--text-main);
}

/* Header User Profile Widget */
.header-user-widget {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.75rem 0.35rem 0.45rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.header-user-widget:hover {
  background: var(--bg-surface-elevated);
  border-color: var(--border-glow);
}

.user-avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--color-primary);
}

/* Dropdown Menu */
.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 250px;
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.5), var(--shadow-glow);
  padding: 0.5rem;
  z-index: 50;
  backdrop-filter: blur(16px);
  display: none;
  animation: dropdownEnter 0.15s ease-out;
}

.user-dropdown-menu.active {
  display: block;
}

@keyframes dropdownEnter {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-main);
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s;
}

.user-dropdown-item:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-heading);
}

.user-dropdown-item.danger {
  color: var(--color-rose);
}

.user-dropdown-item.danger:hover {
  background: var(--color-rose-subtle);
}

/* Workstation Lock Screen */
.lock-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(9, 13, 22, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.25s ease-out;
}

.lock-modal.hidden {
  display: none;
}

.lock-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-xl);
  padding: 2rem;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), var(--shadow-glow);
}

/* --- Phones (<=480): 320 / 375 / 390 / 430 --------------------------------- */
@media (max-width: 480px) {
  /* Container */
  .content-wrapper {
    padding: 0.75rem 0.5rem 1rem;
  }

  /* Header */
  .app-header {
    padding-inline: 0.5rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    gap: 0.5rem;
  }

  .app-header-actions {
    gap: 0.35rem;
  }

  /* Compact card padding */
  .content-wrapper .ards-card {
    padding: 0.9rem !important;
  }

  /* Sidebar */
  .app-sidebar {
    width: min(260px, 90vw);
  }

  .nav-btn {
    padding: 0.65rem 0.85rem;
    font-size: 0.85rem;
  }

  /* Grid layouts */
  body .grid-cols-2,
  body .grid-cols-3,
  body .grid-cols-4 {
    grid-template-columns: 1fr;
  }

  /* Patient/session selectors */
  #globalPatientSelect,
  #globalSessionSelect {
    min-width: 0;
    width: 100%;
  }

  /* Stats */
  .stat-value {
    font-size: 1.25rem;
  }

  .stat-label {
    font-size: 0.75rem;
  }

  /* Login card */
  .login-card {
    padding: 1.25rem 1rem;
  }

  /* Card headers */
  .ards-card-header {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .ards-card-title {
    font-size: 0.95rem;
  }

  /* Buttons */
  .btn {
    padding: 0.65rem 0.85rem;
    font-size: 0.85rem;
  }

  /* Tables */
  table {
    font-size: 0.8rem;
  }

  th, td {
    padding: 0.4rem 0.6rem;
  }

  /* Modals */
  .modal-body {
    padding: 0.85rem;
  }

  /* Charts */
  .chart-container {
    height: 200px;
  }

  /* Form inputs */
  .form-input,
  .form-select {
    padding: 0.65rem 0.85rem;
    font-size: 15px;
  }
}

/* --- Small phones (<=360, e.g. 320px) -------------------------------------- */
@media (max-width: 360px) {
  /* Container */
  .content-wrapper {
    padding: 0.65rem 0.4rem 0.85rem;
  }

  /* Header */
  .app-header {
    padding-inline: 0.4rem;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
  }

  /* Cards */
  .content-wrapper .ards-card {
    padding: 0.8rem !important;
  }

  /* Sidebar */
  .app-sidebar {
    width: min(240px, 95vw);
  }

  .nav-btn {
    padding: 0.6rem 0.75rem;
    font-size: 0.8rem;
  }

  /* Stats */
  .stat-value {
    font-size: 1.15rem;
  }

  .stat-label {
    font-size: 0.7rem;
  }

  /* Typography */
  .ards-card-title {
    font-size: 0.9rem;
  }

  .heading-sm {
    font-size: 0.95rem;
  }

  /* Buttons */
  .btn {
    padding: 0.6rem 0.75rem;
    font-size: 0.8rem;
  }

  /* Tables */
  table {
    font-size: 0.75rem;
  }

  th, td {
    padding: 0.35rem 0.5rem;
  }

  /* Form inputs */
  .form-input,
  .form-select {
    padding: 0.6rem 0.75rem;
    font-size: 14px;
  }

  /* Modals */
  .modal-body {
    padding: 0.75rem;
  }

  /* Charts */
  .chart-container {
    height: 180px;
  }
}

/* --- Touch devices: enforce ~44px targets regardless of viewport ----------- */
@media (pointer: coarse) {
  .btn,
  .nav-btn,
  .modal-close,
  .mobile-menu-toggle,
  .login-tab,
  .login-pw-toggle,
  .alert-filter-btn {
    min-height: 44px;
  }

  #themeToggleBtn {
    min-width: 44px;
    min-height: 44px;
  }

  .form-input,
  .form-select,
  .login-input {
    min-height: 44px;
  }
}

/* ==========================================================================
   ACCESSIBILITY & MOTION
   --------------------------------------------------------------------------
   Respect reduced-motion preferences and add polished scrollbar styling.
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Custom scrollbars (WebKit) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-surface);
}
::-webkit-scrollbar-thumb {
  background: var(--border-card);
  border-radius: 8px;
  border: 2px solid var(--bg-surface);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

/* Focus-visible ring for keyboard users */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Selection color */
::selection {
  background: var(--color-primary-subtle);
  color: var(--text-heading);
}

/* ==========================================================================
   GAIT AI INSIGHTS SECTION (additive module — js/ai-insights.js)
   ========================================================================== */
.ards-ai-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.9rem;
  padding: 1.15rem 1.35rem;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-card), var(--shadow-inset);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
}

.ards-ai-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-heading);
  margin: 0;
}

.ards-ai-title-icon {
  width: 22px;
  height: 22px;
  color: var(--color-violet);
  filter: drop-shadow(0 0 8px rgba(167, 139, 250, 0.45));
}

.ards-ai-subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 62ch;
}

.ards-ai-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ards-ai-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.52rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--border-card);
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast),
              background-color var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}

.ards-ai-btn svg { width: 15px; height: 15px; }

.ards-ai-btn:hover {
  transform: translateY(-1px);
  border-color: var(--border-active);
  color: var(--text-heading);
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, 0.45), var(--shadow-glow);
}

.ards-ai-btn:active { transform: translateY(0); }

.ards-ai-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.ards-ai-btn-ghost { background: transparent; }

.ards-ai-btn-primary,
.ards-ai-btn-primary:hover {
  background: linear-gradient(135deg, var(--color-primary), var(--color-teal));
  border-color: transparent;
  color: #ffffff;
}

.ards-ai-btn-primary:hover { box-shadow: 0 8px 22px -6px rgba(14, 165, 233, 0.55); }

.ards-ai-status {
  min-height: 1.1rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.ards-ai-status:not(:empty) {
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
}

.ards-ai-status-err { color: var(--color-rose); border-color: var(--color-rose-subtle) !important; }

.ards-ai-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
}

.ards-ai-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  padding: 2.2rem 1.4rem;
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border-card);
  background: var(--bg-surface-elevated);
}

.ards-ai-empty-icon { width: 42px; height: 42px; color: var(--color-violet); opacity: 0.85; }

.ards-ai-empty-title { margin: 0.35rem 0 0; font-weight: 800; font-size: 0.95rem; color: var(--text-heading); }

.ards-ai-empty-text {
  margin: 0;
  max-width: 58ch;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.ards-ai-empty-text strong { color: var(--text-main); }

.ards-ai-empty-text code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--color-sky);
  background: var(--color-primary-subtle);
  border-radius: 5px;
  padding: 0.08rem 0.32rem;
}

.ards-ai-paste {
  width: 100%;
  margin-top: 0.85rem;
  padding: 0.8rem 0.9rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-card);
  background: var(--bg-input);
  color: var(--text-main);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  line-height: 1.55;
  resize: vertical;
  text-align: left;
}

.ards-ai-paste:focus {
  outline: none;
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
}

.ards-ai-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-card);
  border-left-width: 3px;
  background: var(--bg-card);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-card);
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}

.ards-ai-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-elevated); }

.ards-ai-card-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ards-ai-card-icon { width: 16px; height: 16px; flex-shrink: 0; }

.ards-ai-card-title {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-heading);
  flex: 1;
  min-width: 0;
}

.ards-ai-badge {
  flex-shrink: 0;
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.16rem 0.5rem;
  border-radius: 999px;
}

.ards-ai-card-text {
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.ards-ai-card.sev-critical { border-left-color: var(--color-rose); }
.ards-ai-card.sev-critical .ards-ai-card-icon,
.ards-ai-card.sev-critical .ards-ai-card-title { color: var(--color-rose); }
.ards-ai-card.sev-critical .ards-ai-badge { color: var(--color-rose); background: var(--color-rose-subtle); }

.ards-ai-card.sev-warning { border-left-color: var(--color-amber); }
.ards-ai-card.sev-warning .ards-ai-card-icon,
.ards-ai-card.sev-warning .ards-ai-card-title { color: var(--color-amber); }
.ards-ai-card.sev-warning .ards-ai-badge { color: var(--color-amber); background: var(--color-amber-subtle); }

.ards-ai-card.sev-info { border-left-color: var(--color-sky); }
.ards-ai-card.sev-info .ards-ai-card-icon,
.ards-ai-card.sev-info .ards-ai-card-title { color: var(--color-sky); }
.ards-ai-card.sev-info .ards-ai-badge { color: var(--color-sky); background: var(--color-sky-subtle); }

.ards-ai-card.sev-ok { border-left-color: var(--color-emerald); }
.ards-ai-card.sev-ok .ards-ai-card-icon,
.ards-ai-card.sev-ok .ards-ai-card-title { color: var(--color-emerald); }
.ards-ai-card.sev-ok .ards-ai-badge { color: var(--color-emerald); background: var(--color-emerald-subtle); }

.ards-ai-columns {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.85rem;
}

.ards-ai-col {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1.05rem 1.15rem;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-card), var(--shadow-inset);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  min-width: 0;
}

.ards-ai-col-wide { grid-column: 1 / -1; }

@media (min-width: 1100px) {
  .ards-ai-columns { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr); }
  .ards-ai-col-wide { grid-column: auto; }
}

.ards-ai-col-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.2rem;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.ards-ai-col-icon { width: 14px; height: 14px; color: var(--color-violet); }

.ards-ai-note {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.55;
}

.ards-ai-risk-visual {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  flex-wrap: wrap;
}

.ards-ai-ring {
  position: relative;
  width: 118px;
  height: 118px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    conic-gradient(var(--ring-color) calc(var(--p, 0) * 1%), var(--ring-track) 0);
}

.ards-ai-ring::before {
  content: '';
  position: absolute;
  inset: 11px;
  border-radius: 50%;
  background: var(--bg-surface);
  box-shadow: var(--shadow-inset);
}

.ards-ai-ring > span {
  position: relative;
  z-index: 1;
  font-family: 'Outfit', sans-serif;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-heading);
}

.ards-ai-ring.risk-emerald { --ring-color: var(--color-emerald); }
.ards-ai-ring.risk-amber   { --ring-color: var(--color-amber); }
.ards-ai-ring.risk-rose    { --ring-color: var(--color-rose); }
.ards-ai-ring { --ring-track: var(--bg-surface-elevated); }

[data-theme="light"] .ards-ai-ring { --ring-track: #e6ebf3; }

.ards-ai-risk-parts {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1;
  min-width: 180px;
}

.ards-ai-risk-part {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.72rem;
}

.ards-ai-risk-name {
  width: 62px;
  flex-shrink: 0;
  font-weight: 700;
  color: var(--text-muted);
}

.ards-ai-risk-bar {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.ards-ai-risk-bar > div {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-teal));
  transition: width var(--t-base);
}

.ards-ai-disclaimer {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-amber-subtle);
  background: var(--bg-surface-elevated);
  font-size: 0.72rem;
  line-height: 1.55;
  color: var(--text-muted);
}

.ards-ai-disclaimer svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--color-amber); }

@media (max-width: 720px) {
  .ards-ai-header { flex-direction: column; }
  .ards-ai-actions { width: 100%; }
  .ards-ai-actions .ards-ai-btn { flex: 1; }
  .ards-ai-columns { grid-template-columns: minmax(0, 1fr); }
  .ards-ai-ring { width: 104px; height: 104px; }
}

@media (prefers-reduced-motion: reduce) {
  .ards-ai-btn,
  .ards-ai-card,
  .ards-ai-risk-bar > div { transition: none; }
}

/* ==========================================================================
   LOGIN INTERACTION FEEDBACK (restored after merge — hover/click response,
   focus rings, busy spinner. Additive; overrides nothing functional.)
   ========================================================================== */

/* Tab hover + press feedback */
.login-tab:hover {
  color: var(--text-heading);
  background: var(--bg-surface-elevated);
}

.login-tab:active { transform: scale(0.97); }

.login-tab:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Submit button: hover lift + press + disabled/busy state */
.login-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.4);
  filter: brightness(1.08);
}

.login-submit:active:not(:disabled) { transform: translateY(0) scale(0.99); }

.login-submit:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.75;
  filter: saturate(0.7);
}

/* Spinner inside the busy submit button */
.login-submit .animate-spin,
.login-submit svg.animate-spin {
  animation: authSpin 0.9s linear infinite;
}

@keyframes authSpin {
  to { transform: rotate(360deg); }
}

/* Input hover + focus ring on the wrapper */
.login-input:hover {
  border-color: var(--border-active);
}

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

.login-input-wrap:focus-within .login-input-icon {
  color: var(--color-primary);
}

/* Password toggle + link button */
.login-pw-toggle {
  cursor: pointer;
  transition: color var(--t-fast), background-color var(--t-fast);
}

.login-pw-toggle:hover {
  color: var(--color-primary);
  background: var(--color-primary-subtle);
}

.login-link-btn {
  cursor: pointer;
  transition: color var(--t-fast);
}

.login-link-btn:hover { color: var(--color-primary-hover); }

/* Remember label + quickfill keyboard focus */
.login-remember { cursor: pointer; }
.login-remember:hover span { color: var(--text-heading); }

.quickfill-card:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Global interactive sanity: any button that is clickable shows a pointer */
.login-screen button { cursor: pointer; }
.login-screen button:disabled { cursor: not-allowed; }

@media (prefers-reduced-motion: reduce) {
  .login-submit .animate-spin,
  .login-submit svg.animate-spin { animation: none; }
  .login-tab:active,
  .login-submit:hover:not(:disabled),
  .login-submit:active:not(:disabled) { transform: none; }
}

/* ==========================================================================
   RESPONSIVE DESIGN - MOBILE OPTIMIZATIONS
   ========================================================================== */

/* Tablet (<= 1024px) */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 240px;
  }
  
  .content-wrapper {
    padding: 1.2rem 1.3rem 1.8rem;
  }
}

/* Mobile (<= 768px) */
@media (max-width: 768px) {
  /* Enable mobile menu toggle */
  .mobile-menu-toggle {
    display: flex;
  }
  
  /* Sidebar becomes off-canvas on mobile */
  .app-sidebar {
    transform: translateX(-100%);
    width: 280px;
    box-shadow: var(--shadow-elevated);
  }
  
  .app-sidebar.open {
    transform: translateX(0);
  }
  
  /* Overlay when sidebar is open */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 49;
    backdrop-filter: blur(4px);
  }
  
  .sidebar-overlay.active {
    display: block;
  }
  
  /* Main content adjusts */
  .app-main {
    margin-left: 0;
  }
  
  .content-wrapper {
    padding: 0.8rem 0.8rem 1.2rem;
    max-width: 100%;
  }
  
  /* Header adjustments */
  .app-header {
    padding: 0.5rem 0.8rem;
  }
  
  .app-header-title {
    font-size: 0.8rem;
  }
  
  /* Card adjustments - more organized layout */
  .ards-card {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.8rem;
  }
  
  .ards-card-header {
    margin-bottom: 0.6rem;
    padding-bottom: 0.5rem;
  }
  
  .ards-card-title {
    font-size: 0.85rem;
  }
  
  /* Horizontal scrolling for stats and key metrics */
  .horizontal-scroll-container {
    display: flex;
    overflow-x: auto;
    gap: 0.75rem;
    padding: 0.5rem 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  
  .horizontal-scroll-container::-webkit-scrollbar {
    height: 4px;
  }
  
  .horizontal-scroll-container::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 4px;
  }
  
  /* Stat cards in horizontal layout */
  .stat-card {
    padding: 0.8rem;
    min-width: 140px;
    flex-shrink: 0;
  }
  
  .stat-value {
    font-size: 1.1rem;
  }
  
  /* Button sizing for touch */
  .btn {
    min-height: 44px;
    padding: 0.6rem 1rem;
  }
  
  .btn-sm {
    min-height: 36px;
    padding: 0.4rem 0.8rem;
  }
  
  /* Form inputs */
  .form-input,
  .form-select {
    padding: 0.6rem 0.8rem;
    font-size: 16px; /* Prevents iOS zoom */
    min-height: 44px;
  }
  
  /* Table responsive */
  .ards-table {
    font-size: 0.72rem;
  }
  
  .ards-table th,
  .ards-table td {
    padding: 0.4rem 0.5rem;
  }
  
  /* Modal adjustments */
  .modal-dialog {
    max-width: 95%;
    margin: 1rem;
    max-height: 85vh;
  }
  
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 0.8rem 1rem;
  }
  
  /* Alerts */
  .alert {
    padding: 0.6rem 0.8rem;
    font-size: 0.72rem;
  }
  
  /* Badges */
  .badge {
    padding: 0.12rem 0.4rem;
    font-size: 0.62rem;
  }
  
  /* Improved grid layout for mobile */
  .mobile-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  
  .mobile-grid-3 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  
  /* Patient context card improvements */
  .patient-context-mobile {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .patient-controls-mobile {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .patient-controls-mobile .form-select {
    flex: 1;
    min-width: 120px;
  }
  
  /* Action buttons row */
  .action-buttons-mobile {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .action-buttons-mobile .btn {
    flex: 1;
    min-width: 100px;
  }
  
  /* Visual hierarchy improvements */
  .ards-card {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }
  
  .ards-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  }
  
  /* Better spacing between sections */
  .space-y-6 > * + * {
    margin-top: 1rem;
  }
  
  /* Improved header spacing */
  .app-header {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }
  
  /* Mobile-specific card improvements */
  .mobile-card-compact {
    padding: 0.8rem;
  }
  
  .mobile-card-compact .ards-card-header {
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
  }
  
  /* Improved text hierarchy */
  .text-lg {
    font-size: 1rem;
    line-height: 1.4;
  }
  
  .text-md {
    font-size: 0.9rem;
    line-height: 1.5;
  }
  
  /* Better button grouping */
  .btn-group-mobile {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
  }
  
  .btn-group-mobile .btn {
    flex: 1;
    min-width: 80px;
  }
}

/* Small Mobile (<= 480px) */
@media (max-width: 480px) {
  :root {
    --header-height: 52px;
  }
  
  .content-wrapper {
    padding: 0.6rem 0.6rem 1rem;
  }
  
  .ards-card {
    padding: 0.7rem;
    margin-bottom: 0.6rem;
  }
  
  .ards-card-title {
    font-size: 0.8rem;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
  
  .btn-sm {
    width: auto;
  }
  
  /* Stack flex containers */
  .app-header-actions {
    gap: 0.3rem;
  }
  
  /* Form adjustments */
  .form-row {
    flex-direction: column;
    gap: 0.8rem;
  }
  
  /* Hide less critical elements */
  .sidebar-user-role {
    display: none;
  }
  
  /* Typography adjustments */
  h1, h2, h3, h4, h5, h6 {
    font-size: 0.9em;
  }
  
  .text-2xl {
    font-size: 1.25rem !important;
  }
  
  .text-3xl {
    font-size: 1.5rem !important;
  }
  
  /* Adjust hero section */
  .hero-title {
    font-size: 1.5rem !important;
  }
  
  .hero-description {
    font-size: 0.9rem !important;
  }
  
  /* Adjust sidebar logo */
  .ards-wordmark {
    font-size: 0.7rem;
  }
  
  /* Adjust nav buttons */
  .nav-btn {
    padding: 0.5rem 0.6rem;
    font-size: 0.7rem;
  }
  
  /* Adjust stat cards */
  .stat-value {
    font-size: 1rem;
  }
  
  .stat-label {
    font-size: 0.6rem;
  }
  
  /* Adjust modal */
  .modal-dialog {
    margin: 0.5rem;
    max-height: 90vh;
  }
  
  /* Adjust table */
  .ards-table {
    font-size: 0.65rem;
  }
  
  .ards-table th,
  .ards-table td {
    padding: 0.3rem 0.4rem;
  }
  
  /* Optimized card sizing for small screens */
  .horizontal-scroll-container {
    gap: 0.5rem;
  }
  
  .stat-card {
    min-width: 120px;
    padding: 0.6rem;
  }
  
  /* Compact patient context */
  .patient-context-mobile {
    gap: 0.5rem;
  }
  
  /* Smaller gaps in grids */
  .mobile-grid-2,
  .mobile-grid-3 {
    gap: 0.5rem;
  }
  
  /* Reduced padding for compact cards */
  .mobile-card-compact {
    padding: 0.6rem;
  }
  
  /* Better fit for action buttons */
  .action-buttons-mobile .btn {
    min-width: 90px;
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem;
  }
}

/* Landscape Mobile (<= 768px height) */
@media (max-width: 768px) and (max-height: 500px) {
  .app-sidebar {
    width: 260px;
  }
  
  .content-wrapper {
    padding: 0.6rem 0.8rem 1rem;
  }
  
  .ards-card {
    padding: 0.6rem 0.8rem;
  }
}

/* Responsive Grid Overrides for Mobile */
@media (max-width: 768px) {
  /* Force single column grids on mobile */
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4,
  .lg\\:grid-cols-2,
  .lg\\:grid-cols-3,
  .lg\\:grid-cols-4 {
    grid-template-columns: 1fr !important;
  }
  
  /* Adjust gap for mobile */
  .gap-3,
  .gap-4,
  .gap-6 {
    gap: 0.75rem !important;
  }
  
  /* Stack flex containers */
  .lg\\:flex-row {
    flex-direction: column !important;
  }
  
  .lg\\:col-span-2,
  .lg\\:col-span-3 {
    grid-column: span 1 !important;
  }
  
  /* Adjust text sizes for mobile */
  .text-xl {
    font-size: 1.1rem !important;
  }
  
  .text-lg {
    font-size: 1rem !important;
  }
  
  .text-sm {
    font-size: 0.8rem !important;
  }
  
  .text-xs {
    font-size: 0.7rem !important;
  }
  
  /* Adjust padding for cards */
  .p-5,
  .p-6 {
    padding: 1rem !important;
  }
  
  .p-4 {
    padding: 0.8rem !important;
  }
  
  /* Adjust spacing */
  .space-y-4 > * + * {
    margin-top: 0.75rem !important;
  }
  
  .space-y-3 > * + * {
    margin-top: 0.5rem !important;
  }
  
  /* Touch-friendly interactive elements */
  button,
  .btn,
  input[type="button"],
  input[type="submit"],
  select {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Touch-friendly clickable areas */
  a,
  .nav-btn,
  .mobile-nav-link {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
  }
  
  /* Touch-friendly icons */
  .btn-icon,
  .btn-icon-sm {
    min-width: 44px;
    min-height: 44px;
  }
  
  /* Touch-friendly form controls */
  .form-input,
  .form-select,
  textarea {
    min-height: 44px;
    font-size: 16px;
  }
  
  /* Touch-friendly checkboxes and radios */
  input[type="checkbox"],
  input[type="radio"] {
    min-width: 24px;
    min-height: 24px;
  }
  
  /* Touch-friendly dropdowns */
  select {
    padding: 0.75rem 1rem;
  }
  
  /* Touch-friendly close buttons */
  .modal-close,
  button[aria-label*="close"],
  button[aria-label*="Close"] {
    min-width: 44px;
    min-height: 44px;
  }
  
  /* Prevent text selection on touch interactions */
  .btn,
  button,
  .nav-btn {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
  }
  
  /* Touch-friendly spacing between interactive elements */
  .app-header-actions > *,
  .sidebar-footer > * {
    margin-bottom: 0.25rem;
  }
}

