/* ============================================
   Rosheta AI — Main Stylesheet
   Mobile-first Responsive | Medical EHR Grade
   RTL-ready via logical properties
   ============================================ */

/* ============================================
   DESIGN TOKENS
   ============================================ */
:root {
  /* Medical palette — professional blues + teal accent */
  --primary-50: #EFF6FF;
  --primary-100: #DBEAFE;
  --primary-200: #BFDBFE;
  --primary-300: #93C5FD;
  --primary-400: #60A5FA;
  --primary-500: #2563EB;
  --primary-600: #1D4ED8;
  --primary-700: #1E40AF;
  --primary-800: #1E3A8A;
  --primary-900: #172554;

  --teal-50: #F0FDFA;
  --teal-100: #CCFBF1;
  --teal-500: #14B8A6;
  --teal-600: #0D9488;

  /* Neutrals */
  --white: #FFFFFF;
  --gray-50: #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --gray-900: #0F172A;

  /* Semantic */
  --success: #059669;
  --success-light: #D1FAE5;
  --success-50: #ECFDF5;
  --success-700: #047857;
  --warning: #D97706;
  --warning-light: #FEF3C7;
  --warning-500: #F59E0B;
  --error: #DC2626;
  --error-light: #FEE2E2;
  --error-dark: #B91C1C;
  --danger-500: #DC2626;
  --info: #2563EB;
  --info-light: #DBEAFE;

  /* Surfaces & shadows */
  --glass-bg: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(226, 232, 240, 0.7);
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 8px 28px rgba(15, 23, 42, 0.1);
  --shadow-xl: 0 16px 48px rgba(15, 23, 42, 0.14);

  /* Typography */
  --font-arabic: 'Cairo', sans-serif;
  --font-english: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-primary: var(--font-arabic);

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 0.95rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: clamp(1.5rem, 4vw, 2rem);

  /* Radius */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Spacing — relative scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: clamp(2rem, 5vw, 3.5rem);

  /* Transitions — minimal & purposeful */
  --t-fast: 140ms ease;
  --t-base: 220ms ease;

  /* Layout */
  --sidebar-width: 280px;
  --header-height: 68px;
  --max-width: 1440px;

  /* Dark mode */
  --dark-bg: #0B1120;
  --dark-surface: #161F2E;
  --dark-border: #26334A;
  --dark-card: #1B2637;
}

[data-theme="dark"] {
  --glass-bg: rgba(22, 31, 46, 0.9);
  --glass-border: rgba(38, 51, 74, 0.7);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.55);
}

/* Language-driven font + base alignment */
[dir="ltr"] { --font-primary: var(--font-english); }
[dir="rtl"] { --font-primary: var(--font-arabic); }

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-primary);
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
  transition: background var(--t-base), color var(--t-base);
}

[data-theme="dark"] body { background: var(--dark-bg); color: var(--gray-100); }

img { max-width: 100%; height: auto; display: block; }
a { text-decoration: none; color: inherit; }
ul, ol { list-style: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; font-size: inherit; color: inherit; }
input, textarea, select { font-family: inherit; font-size: inherit; outline: none; border: none; color: inherit; }
textarea { resize: vertical; }

:focus-visible { outline: 2px solid var(--primary-400); outline-offset: 2px; border-radius: var(--radius-sm); }

::selection { background: var(--primary-500); color: var(--white); }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: var(--radius-full); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--gray-600); }

/* ============================================
   UTILITIES
   ============================================ */
.text-center { text-align: center; }
.text-primary { color: var(--primary-500); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-muted { color: var(--gray-400); }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.text-sm { font-size: 0.8rem; }
.hidden { display: none !important; }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }

.flex { display: flex; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { align-items: center; justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* ============================================
   LOADING SCREEN
   ============================================ */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--gray-50);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}
.loading-screen.hidden { opacity: 0; visibility: hidden; }
[data-theme="dark"] .loading-screen { background: var(--dark-bg); }
.loading-content { text-align: center; }
.loading-logo {
  font-size: clamp(1.8rem, 6vw, 2.5rem);
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 1rem;
  letter-spacing: -0.03em;
}
.loading-spinner {
  width: 2.25rem;
  height: 2.25rem;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary-500);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   LANGUAGE SELECTOR
   ============================================ */
.language-selector {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background: linear-gradient(160deg, var(--primary-50) 0%, var(--white) 50%, var(--teal-50) 100%);
}
[data-theme="dark"] .language-selector { background: linear-gradient(160deg, var(--dark-bg), var(--dark-surface)); }

.language-selector-content {
  text-align: center;
  max-width: 32rem;
  width: 100%;
}
.language-selector .app-logo {
  font-size: clamp(2.2rem, 8vw, 3.5rem);
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-500), var(--teal-500));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
  letter-spacing: -0.04em;
}
.language-selector .app-tagline { color: var(--gray-500); font-size: 1rem; margin-bottom: 2rem; }
.language-selector h2 { font-size: 1.15rem; font-weight: 600; margin-bottom: 1.5rem; color: var(--gray-600); }

.language-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}
.language-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 1.5rem 1rem;
  border-radius: var(--radius-xl);
  background: var(--glass-bg);
  border: 2px solid var(--glass-border);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  width: min(100%, 13rem);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.language-btn:hover { border-color: var(--primary-300); box-shadow: var(--shadow-md); }
.language-btn .language-flag { font-size: 2.5rem; line-height: 1; }
.language-btn .language-name { font-weight: 700; color: var(--gray-700); }
[data-theme="dark"] .language-btn .language-name { color: var(--gray-200); }
.language-btn .language-dir {
  font-size: 0.75rem;
  color: var(--gray-400);
  font-weight: 500;
  padding: 0.2rem 0.75rem;
  background: var(--gray-100);
  border-radius: var(--radius-full);
}
[data-theme="dark"] .language-btn .language-dir { background: var(--dark-border); }

/* ============================================
   AUTH PAGES
   ============================================ */
.auth-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  background: linear-gradient(160deg, var(--primary-50) 0%, var(--white) 40%, var(--gray-50) 100%);
}
[data-theme="dark"] .auth-page { background: linear-gradient(160deg, var(--dark-bg), var(--dark-surface)); }

.auth-container { width: 100%; max-width: 30rem; }
.auth-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-2xl);
  padding: clamp(1.5rem, 5vw, 2.5rem) clamp(1.25rem, 4vw, 2rem);
  box-shadow: var(--shadow-lg);
}
.auth-header { text-align: center; margin-bottom: var(--space-xl); }
.auth-header .auth-logo {
  font-size: clamp(1.8rem, 6vw, 2.25rem);
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-500), var(--teal-500));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
  letter-spacing: -0.03em;
}
.auth-header h1 { font-size: var(--text-2xl); font-weight: 700; margin-bottom: 0.35rem; }
.auth-header p { color: var(--gray-500); font-size: 0.9rem; }

.auth-links { text-align: center; margin-top: var(--space-lg); font-size: 0.9rem; color: var(--gray-500); }
.auth-links a { color: var(--primary-600); font-weight: 600; }
.auth-links a:hover { text-decoration: underline; }

.auth-divider { display: flex; align-items: center; gap: 1rem; margin: var(--space-lg) 0; color: var(--gray-400); font-size: 0.85rem; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--gray-200); }

.checkbox-group { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 0.9rem; color: var(--gray-600); }
.checkbox-group input[type="checkbox"] { width: 1.1rem; height: 1.1rem; accent-color: var(--primary-500); }

/* ============================================
   FORMS & BUTTONS
   ============================================ */
.form-group { margin-bottom: var(--space-lg); }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: var(--space-xs); color: var(--gray-700); }
[data-theme="dark"] .form-label { color: var(--gray-300); }

.form-input, .form-input:is(textarea) {
  width: 100%;
  max-width: 100%;
  padding: 0.75rem 1rem;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--gray-900);
  line-height: 1.5;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
[data-theme="dark"] .form-input, [data-theme="dark"] .form-input:is(textarea) { background: var(--dark-surface); border-color: var(--dark-border); color: var(--gray-100); }
.form-input:focus { border-color: var(--primary-400); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.form-input::placeholder { color: var(--gray-400); }
.form-input.error { border-color: var(--error); box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1); }

.form-error { color: var(--error); font-size: 0.8rem; margin-top: var(--space-xs); font-weight: 500; }

/* Floating label */
.floating-input-group { position: relative; margin-bottom: var(--space-lg); }
.floating-input-group .form-input { padding-block: 1.25rem 0.5rem; height: 3.5rem; background: var(--gray-50); }
[data-theme="dark"] .floating-input-group .form-input { background: var(--dark-bg); }
.floating-input-group .floating-label {
  position: absolute;
  inset-inline-start: 1rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.95rem;
  color: var(--gray-400);
  pointer-events: none;
  transition: all var(--t-fast);
  padding: 0 4px;
  line-height: 1;
}
.floating-input-group .form-input:focus ~ .floating-label,
.floating-input-group .form-input:not(:placeholder-shown) ~ .floating-label {
  top: 0.55rem;
  transform: translateY(0);
  font-size: 0.75rem;
  color: var(--primary-500);
  font-weight: 600;
}

/* Selects */
select.form-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 12 12'%3E%3Cpath fill='%2364748B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 1rem center;
  padding-inline-start: 2.4rem;
}
[dir="ltr"] select.form-input { background-position: right 1rem center; padding-inline-start: 1rem; padding-inline-end: 2.4rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.25rem;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--text-base);
  line-height: 1.4;
  text-align: center;
  transition: background-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(0.98); }

.btn-primary { background: linear-gradient(135deg, var(--primary-500), var(--primary-600)); color: var(--white); box-shadow: 0 3px 12px rgba(37, 99, 235, 0.3); }
.btn-primary:hover { box-shadow: 0 5px 18px rgba(37, 99, 235, 0.4); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
[data-theme="dark"] .btn-secondary { background: var(--dark-surface); color: var(--gray-200); border-color: var(--dark-border); }
.btn-secondary:hover { background: var(--gray-200); }
[data-theme="dark"] .btn-secondary:hover { background: var(--dark-border); }
.btn-ghost { background: transparent; color: var(--gray-600); border: 1px solid transparent; }
.btn-ghost:hover { background: rgba(0, 0, 0, 0.04); border-color: var(--gray-200); }
[data-theme="dark"] .btn-ghost:hover { background: rgba(255, 255, 255, 0.05); border-color: var(--dark-border); }
.btn-danger { background: linear-gradient(135deg, var(--error), var(--error-dark)); color: var(--white); box-shadow: 0 3px 12px rgba(220, 38, 38, 0.28); }
.btn-success { background: linear-gradient(135deg, var(--success), var(--success-700)); color: var(--white); box-shadow: 0 3px 12px rgba(5, 150, 105, 0.28); }

.btn-sm { padding: 0.45rem 0.85rem; font-size: 0.85rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 0.85rem 1.6rem; font-size: 1rem; border-radius: var(--radius-lg); }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

/* Role selector */
.role-selector { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: var(--space-lg); }
.role-option {
  padding: 1.25rem 0.75rem;
  text-align: center;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-lg);
  cursor: pointer;
  background: var(--white);
  transition: border-color var(--t-fast), background var(--t-fast);
}
[data-theme="dark"] .role-option { background: var(--dark-surface); border-color: var(--dark-border); }
.role-option.active { border-color: var(--primary-500); background: linear-gradient(135deg, var(--primary-50), var(--white)); }
[data-theme="dark"] .role-option.active { background: linear-gradient(135deg, rgba(37, 99, 235, 0.18), var(--dark-surface)); }
.role-option .role-icon { font-size: 2rem; margin-bottom: 0.4rem; display: block; }
.role-option .role-name { font-weight: 700; font-size: 1rem; color: var(--gray-700); }
[data-theme="dark"] .role-option .role-name { color: var(--gray-200); }

/* ============================================
   DASHBOARD LAYOUT — mobile-first
   ============================================ */
.dashboard-layout { display: flex; min-height: 100dvh; }

/* Sidebar — off-canvas by default (<1024px) */
.sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: min(86vw, 320px);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  border-inline-end: 1px solid var(--gray-200);
  padding: var(--space-md);
  z-index: 120;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform var(--t-base);
}
[dir="rtl"] .sidebar { transform: translateX(100%); }
[data-theme="dark"] .sidebar { background: rgba(22, 31, 46, 0.97); border-color: var(--dark-border); }
.sidebar.open { transform: translateX(0); }

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.5);
  z-index: 110;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-base), visibility var(--t-base);
}
.sidebar-overlay.open { opacity: 1; visibility: visible; }

.sidebar-brand { display: flex; align-items: center; gap: 0.75rem; padding: var(--space-sm); margin-bottom: var(--space-lg); }
.brand-icon-wrapper {
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-50), var(--primary-100));
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
[data-theme="dark"] .brand-icon-wrapper { background: rgba(37, 99, 235, 0.18); }
.brand-icon-wrapper .brand-icon { font-size: 1.4rem; }
.brand-text-group { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.brand-text { font-size: 1.3rem; font-weight: 800; background: linear-gradient(135deg, var(--primary-500), var(--teal-500)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; line-height: 1.2; }
.brand-subtitle { font-size: 0.7rem; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.05em; }
[data-theme="dark"] .brand-subtitle { color: var(--gray-500); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-section-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--space-md) var(--space-md) var(--space-xs);
}
[data-theme="dark"] .nav-section-title { color: var(--gray-500); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--gray-600);
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: background var(--t-fast), color var(--t-fast);
}
[data-theme="dark"] .nav-item { color: var(--gray-400); }
.nav-item:hover { background: rgba(37, 99, 235, 0.08); color: var(--primary-600); }
.nav-item.active {
  background: linear-gradient(135deg, var(--primary-50), rgba(37, 99, 235, 0.06));
  color: var(--primary-700);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--primary-500);
}
[dir="ltr"] .nav-item.active { box-shadow: inset -3px 0 0 var(--primary-500); }
[data-theme="dark"] .nav-item.active { background: rgba(37, 99, 235, 0.18); color: var(--primary-300); }
.nav-item .nav-icon { font-size: 1.1rem; width: 1.75rem; height: 1.75rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-item .nav-icon svg { width: 1.25rem; height: 1.25rem; stroke: var(--gray-500); }
.nav-item:hover .nav-icon svg { stroke: var(--primary-500); }
.nav-item.active .nav-icon svg { stroke: var(--primary-500); }
[data-theme="dark"] .nav-item .nav-icon svg { stroke: var(--gray-400); }
[data-theme="dark"] .nav-item:hover .nav-icon svg { stroke: var(--primary-400); }
[data-theme="dark"] .nav-item.active .nav-icon svg { stroke: var(--primary-300); }

.nav-item .nav-badge {
  margin-inline-start: auto;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: var(--white);
  padding: 2px 9px;
  border-radius: var(--radius-full);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.nav-divider { height: 1px; background: var(--gray-200); margin: var(--space-md) 0; }
[data-theme="dark"] .nav-divider { background: var(--dark-border); }

.sidebar-footer { margin-top: auto; padding-top: var(--space-md); border-top: 1px solid var(--gray-100); }
[data-theme="dark"] .sidebar-footer { border-color: var(--dark-border); }
.sidebar-footer .nav-item:hover { background: var(--error-light); color: var(--error-dark); }
[data-theme="dark"] .sidebar-footer .nav-item:hover { background: rgba(220, 38, 38, 0.12); color: var(--error); }

/* Main content */
.main-content {
  flex: 1;
  min-width: 0;
  padding: var(--space-md);
  margin-inline-start: 0;
  transition: margin var(--t-base);
}

/* Header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  padding-block: var(--space-sm);
  flex-wrap: wrap;
}
.header-left { display: flex; align-items: center; gap: var(--space-sm); min-width: 0; }
.header-right { display: flex; align-items: center; gap: var(--space-sm); }
.header-title-group { min-width: 0; }
.page-header h1 { font-size: var(--text-xl); font-weight: 700; color: var(--gray-800); letter-spacing: -0.02em; line-height: 1.3; }
[data-theme="dark"] .page-header h1 { color: var(--gray-100); }
.header-date { font-size: 0.75rem; color: var(--gray-400); font-weight: 500; }

.mobile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  flex-shrink: 0;
}
.mobile-menu-btn svg { width: 1.4rem; height: 1.4rem; stroke: var(--gray-600); }
[data-theme="dark"] .mobile-menu-btn svg { stroke: var(--gray-300); }

.header-btn {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  position: relative;
  flex-shrink: 0;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.header-btn:hover { background: var(--primary-50); border-color: var(--primary-200); }
.header-btn svg { width: 1.25rem; height: 1.25rem; stroke: var(--gray-600); }
[data-theme="dark"] .header-btn svg { stroke: var(--gray-300); }
.notification-dot { position: absolute; top: 6px; inset-inline-end: 6px; width: 9px; height: 9px; background: var(--error); border-radius: 50%; border: 2px solid var(--white); }
[data-theme="dark"] .notification-dot { border-color: var(--dark-surface); }

/* Desktop layout */
@media (min-width: 1024px) {
  .sidebar {
    position: sticky;
    top: 0;
    width: var(--sidebar-width);
    height: 100dvh;
    transform: none !important;
    border-inline-end: 1px solid var(--gray-200);
  }
  [dir="rtl"] .sidebar { transform: none !important; }
  .sidebar-overlay { display: none; }
  .mobile-menu-btn { display: none; }
  .main-content { margin-inline-start: var(--sidebar-width); padding: var(--space-xl); }
  .page-header { margin-bottom: var(--space-2xl); }
}

/* ============================================
   CARDS & GRIDS
   ============================================ */
.card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
[data-theme="dark"] .card { background: var(--dark-card); border-color: var(--dark-border); }

.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); margin-bottom: var(--space-lg); flex-wrap: wrap; }
.card-header h2, .card-header h3 { font-size: var(--text-lg); font-weight: 700; color: var(--gray-800); }
[data-theme="dark"] .card-header h2, [data-theme="dark"] .card-header h3 { color: var(--gray-100); }
.card-body { line-height: 1.6; color: var(--gray-700); }
[data-theme="dark"] .card-body { color: var(--gray-300); }

.card-premium {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-md);
  min-width: 0;
}
[data-theme="dark"] .card-premium { background: var(--dark-surface); border-color: var(--dark-border); }

.card-modern {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  min-width: 0;
  overflow: hidden;
}
[data-theme="dark"] .card-modern { background: var(--dark-card); border-color: var(--dark-border); }
.card-modern-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--gray-100); flex-wrap: wrap; }
[data-theme="dark"] .card-modern-header { border-color: var(--dark-border); }
.card-modern-header h3 { font-size: var(--text-base); font-weight: 700; color: var(--gray-800); }
[data-theme="dark"] .card-modern-header h3 { color: var(--gray-100); }
.card-modern-body { padding: var(--space-md); }

/* Grids — fluid, auto-wrapping */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); gap: var(--space-lg); }
.card-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: var(--space-lg); }
.card-grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: var(--space-lg); }
.card-grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: var(--space-md); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: var(--space-md); margin-bottom: var(--space-xl); }

.stat-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  min-width: 0;
}
[data-theme="dark"] .stat-card { background: var(--dark-card); border-color: var(--dark-border); }
.stat-icon { width: 3rem; height: 3rem; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-icon.blue { background: linear-gradient(135deg, var(--primary-100), var(--primary-50)); color: var(--primary-600); }
.stat-icon.green { background: linear-gradient(135deg, var(--success-light), var(--success-50)); color: var(--success); }
.stat-icon.info { background: linear-gradient(135deg, var(--info-light), var(--primary-50)); color: var(--info); }
.stat-icon.red { background: linear-gradient(135deg, var(--error-light), #FEF2F2); color: var(--error); }
[data-theme="dark"] .stat-icon.blue { background: rgba(37, 99, 235, 0.22); color: var(--primary-400); }
[data-theme="dark"] .stat-icon.green { background: rgba(5, 150, 105, 0.22); color: #34D399; }
[data-theme="dark"] .stat-icon.info { background: rgba(37, 99, 235, 0.22); color: var(--primary-400); }
[data-theme="dark"] .stat-icon.red { background: rgba(220, 38, 38, 0.22); color: #F87171; }

.stat-info { min-width: 0; }
.stat-info h3 { font-size: 0.78rem; color: var(--gray-500); font-weight: 600; margin-bottom: 0.2rem; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-info .stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1.2; color: var(--gray-900); letter-spacing: -0.02em; word-break: break-word; }
[data-theme="dark"] .stat-info .stat-value { color: var(--gray-100); }
.stat-info .stat-change { font-size: 0.78rem; margin-top: 0.2rem; font-weight: 500; }
.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--error); }

/* ============================================
   BADGES
   ============================================ */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: var(--radius-full); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
.badge-primary { background: linear-gradient(135deg, var(--primary-500), var(--primary-600)); color: var(--white); box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25); }
.badge-success { background: linear-gradient(135deg, var(--success-light), #A7F3D0); color: var(--success-700); }
.badge-info { background: linear-gradient(135deg, var(--info-light), #BFDBFE); color: var(--primary-700); }
.badge-warning { background: linear-gradient(135deg, var(--warning-light), #FDE68A); color: var(--warning); }
.badge-error { background: linear-gradient(135deg, var(--error-light), #FECACA); color: var(--error-dark); }
.badge-super-admin { background: linear-gradient(135deg, #7C3AED, #6D28D9); color: #fff; }
.badge-admin { background: linear-gradient(135deg, var(--primary-500), var(--primary-600)); color: #fff; }

/* ============================================
   DASHBOARD COMPONENTS
   ============================================ */
.welcome-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  padding: var(--space-lg);
  background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-lg);
  color: var(--white);
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(37, 99, 235, 0.22);
  flex-wrap: wrap;
}
.welcome-content { flex: 1; min-width: 0; }
.welcome-content h2 { font-size: clamp(1.15rem, 3vw, 1.4rem); font-weight: 700; margin-bottom: 0.3rem; }
.welcome-content p { font-size: 0.9rem; opacity: 0.85; }
.welcome-doctor-info { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 0.82rem; opacity: 0.92; flex-wrap: wrap; }
.welcome-doctor-name { font-weight: 700; }
.welcome-doctor-sep { opacity: 0.5; }
.welcome-mini-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  backdrop-filter: blur(4px);
}
.welcome-mini-icon { font-size: 0.85rem; }
.welcome-illustration { flex-shrink: 0; opacity: 0.9; }
@media (max-width: 767px) { .welcome-illustration { display: none; } }

/* Modern stats */
.stats-grid-modern { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: var(--space-md); margin-bottom: var(--space-xl); }
.stat-card-modern {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
[data-theme="dark"] .stat-card-modern { background: var(--dark-card); border-color: var(--dark-border); }
.stat-card-modern-icon {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.2);
  flex-shrink: 0;
}
.stat-patients .stat-card-modern-icon { background: linear-gradient(135deg, #3B82F6, #2563EB); }
.stat-prescriptions .stat-card-modern-icon { background: linear-gradient(135deg, #10B981, #059669); }
.stat-appointments .stat-card-modern-icon { background: linear-gradient(135deg, #F59E0B, #D97706); }
.stat-activity .stat-card-modern-icon { background: linear-gradient(135deg, #8B5CF6, #7C3AED); }
.stat-card-modern-content { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-card-modern-label { font-size: 0.75rem; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.04em; }
[data-theme="dark"] .stat-card-modern-label { color: var(--gray-400); }
.stat-card-modern-value { font-size: 1.6rem; font-weight: 800; color: var(--gray-900); line-height: 1.2; letter-spacing: -0.02em; }
[data-theme="dark"] .stat-card-modern-value { color: var(--gray-100); }
.stat-card-modern-trend {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.stat-card-modern-trend.up { background: var(--success-light); color: var(--success-700); }
.stat-card-modern-trend.down { background: var(--error-light); color: var(--error-dark); }

.dashboard-grid-2col { display: grid; grid-template-columns: 1fr; gap: var(--space-lg); margin-bottom: var(--space-lg); }
@media (min-width: 992px) { .dashboard-grid-2col { grid-template-columns: 1fr 1fr; } }

/* Quick actions */
.quick-actions-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-sm); }
.quick-action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 5px;
  padding: var(--space-md) var(--space-sm);
  border-radius: var(--radius-lg);
  background: var(--white);
  border: 1px solid var(--gray-200);
  cursor: pointer;
  min-width: 0;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
[data-theme="dark"] .quick-action-card { background: var(--dark-surface); border-color: var(--dark-border); }
.quick-action-card:hover { border-color: var(--primary-200); box-shadow: var(--shadow-sm); }
.quick-action-icon { width: 2.8rem; height: 2.8rem; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.quick-action-icon.voice { background: linear-gradient(135deg, var(--primary-100), var(--primary-200)); }
.quick-action-icon.calendar { background: linear-gradient(135deg, var(--warning-light), #FDE68A); }
.quick-action-icon.patients { background: linear-gradient(135deg, var(--success-light), #A7F3D0); }
.quick-action-icon.chat { background: linear-gradient(135deg, var(--info-light), #BFDBFE); }
.quick-action-label { font-size: 0.8rem; font-weight: 700; color: var(--gray-700); }
[data-theme="dark"] .quick-action-label { color: var(--gray-200); }
.quick-action-desc { font-size: 0.68rem; color: var(--gray-400); line-height: 1.3; }

/* Rows & timelines */
.timeline-item-sm { display: flex; align-items: flex-start; gap: var(--space-md); padding: var(--space-sm); border-bottom: 1px solid var(--gray-50); }
.timeline-item-sm:last-child { border-bottom: none; }
[data-theme="dark"] .timeline-item-sm { border-color: var(--dark-border); }
.timeline-time { font-size: 0.78rem; font-weight: 700; color: var(--primary-600); min-width: 3rem; padding-top: 2px; font-family: monospace; }
.timeline-content-sm { flex: 1; min-width: 0; }
.timeline-title { font-size: 0.9rem; font-weight: 600; color: var(--gray-700); margin-bottom: 2px; word-break: break-word; }
[data-theme="dark"] .timeline-title { color: var(--gray-200); }
.timeline-subtitle { font-size: 0.76rem; color: var(--gray-400); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

.patient-row-sm, .prescription-row-sm { display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-sm); border-bottom: 1px solid var(--gray-50); min-width: 0; }
.patient-row-sm:last-child, .prescription-row-sm:last-child { border-bottom: none; }
[data-theme="dark"] .patient-row-sm, [data-theme="dark"] .prescription-row-sm { border-color: var(--dark-border); }
.patient-row-sm:hover, .prescription-row-sm:hover { background: rgba(37, 99, 235, 0.03); }
.patient-row-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-400), var(--primary-600));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.15);
}
.patient-row-info, .prescription-row-left { flex: 1; min-width: 0; }
.patient-row-name, .prescription-row-patient { font-size: 0.88rem; font-weight: 600; color: var(--gray-700); word-break: break-word; }
[data-theme="dark"] .patient-row-name, [data-theme="dark"] .prescription-row-patient { color: var(--gray-200); }
.patient-row-meta, .prescription-row-diagnosis { font-size: 0.76rem; color: var(--gray-400); }
.prescription-row-date { font-size: 0.7rem; color: var(--gray-400); margin-top: 2px; }

/* Empty states */
.empty-state { text-align: center; padding: var(--space-2xl) var(--space-lg); }
.empty-state .empty-icon { font-size: 3rem; margin-bottom: var(--space-md); opacity: 0.45; }
.empty-state h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: var(--space-sm); color: var(--gray-600); }
[data-theme="dark"] .empty-state h3 { color: var(--gray-400); }
.empty-state p { color: var(--gray-400); margin-bottom: var(--space-lg); max-width: 24rem; margin-inline: auto; }

.empty-state-sm { text-align: center; padding: var(--space-xl) var(--space-md); }
.empty-state-sm .empty-icon { font-size: 2.2rem; margin-bottom: var(--space-sm); opacity: 0.4; }
.empty-state-sm h4 { font-size: 0.92rem; font-weight: 600; color: var(--gray-500); margin-bottom: 4px; }
[data-theme="dark"] .empty-state-sm h4 { color: var(--gray-400); }
.empty-state-sm p { font-size: 0.8rem; color: var(--gray-400); }

/* Skeleton */
.skeleton { background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%); background-size: 200% 100%; animation: shimmer 1.5s ease-in-out infinite; border-radius: var(--radius-sm); }
[data-theme="dark"] .skeleton { background: linear-gradient(90deg, var(--dark-border) 25%, var(--dark-surface) 50%, var(--dark-border) 75%); background-size: 200% 100%; }
.skeleton-text { height: 0.875rem; margin-bottom: 8px; width: 80%; }
.skeleton-text.short { width: 40%; }
.skeleton-avatar { width: 2.75rem; height: 2.75rem; border-radius: var(--radius-full); }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* Patient selector */
.patient-selector { margin-bottom: var(--space-2xl); }
.patient-selector .search-input {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  transition: border-color var(--t-fast);
}
[data-theme="dark"] .patient-selector .search-input { background: var(--dark-surface); border-color: var(--dark-border); color: var(--gray-100); }
.patient-selector .search-input:focus { border-color: var(--primary-400); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.patient-selector .patient-list { margin-top: var(--space-md); max-height: 24rem; overflow-y: auto; }
.patient-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.8rem 0.85rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.patient-item:hover { background: var(--primary-50); border-color: var(--primary-200); }
[data-theme="dark"] .patient-item:hover { background: rgba(37, 99, 235, 0.1); }
.patient-avatar {
  width: 2.9rem;
  height: 2.9rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-300), var(--primary-500));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-weight: 700;
  font-size: 1.05rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}
.patient-info { flex: 1; min-width: 0; }
.patient-name { font-weight: 600; font-size: 0.95rem; color: var(--gray-800); word-break: break-word; }
[data-theme="dark"] .patient-name { color: var(--gray-100); }
.patient-meta { font-size: 0.78rem; color: var(--gray-500); word-break: break-word; }

/* Doctor appointments */
.doctor-appointment-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); gap: var(--space-md); margin-bottom: var(--space-lg); }
.doctor-appointment-summary-card { padding: var(--space-md); background: linear-gradient(135deg, var(--primary-50), var(--primary-100)); border-radius: var(--radius-md); text-align: center; }
[data-theme="dark"] .doctor-appointment-summary-card { background: rgba(37, 99, 235, 0.12); }
.doctor-appointment-summary-title { font-size: 0.78rem; color: var(--gray-500); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.doctor-appointment-summary-value { font-size: 1.15rem; font-weight: 700; color: var(--primary-700); margin-top: 4px; }
[data-theme="dark"] .doctor-appointment-summary-value { color: var(--primary-400); }
.doctor-appointment-item { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); padding: var(--space-md); border-bottom: 1px solid var(--gray-100); flex-wrap: wrap; }
.doctor-appointment-item:last-child { border-bottom: none; }
[data-theme="dark"] .doctor-appointment-item { border-color: var(--dark-border); }
.doctor-appointment-patient { font-weight: 600; font-size: 0.95rem; word-break: break-word; }
.doctor-appointment-meta { font-size: 0.78rem; color: var(--gray-400); margin-top: 2px; }
.doctor-appointment-status { flex-shrink: 0; }

/* ============================================
   PRESCRIPTION SCREEN (EHR workflow)
   ============================================ */
.prescription-screen { width: 100%; max-width: 100rem; margin: 0 auto; display: flex; flex-direction: column; gap: var(--space-md); }

.rx-page-header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: clamp(0.9rem, 2vw, 1.25rem);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #F8FBFF 0%, #F1F6FF 100%);
  box-shadow: var(--shadow-xs);
}
[data-theme="dark"] .rx-page-header { background: var(--dark-surface); border-color: var(--dark-border); }
.rx-header-brand { min-width: 0; }
.rx-brand-title { font-size: clamp(1.05rem, 2.2vw, 1.3rem); font-weight: 800; color: var(--primary-700); letter-spacing: -0.02em; }
[data-theme="dark"] .rx-brand-title { color: var(--gray-100); }
.rx-brand-subtitle { font-size: clamp(0.8rem, 1.5vw, 0.92rem); color: var(--gray-600); font-weight: 600; }
[data-theme="dark"] .rx-brand-subtitle { color: var(--gray-400); }

.rx-header-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: 0.5rem 0.85rem; width: 100%; font-size: 0.88rem; color: var(--gray-700); }
[data-theme="dark"] .rx-header-summary { color: var(--gray-300); }
.rx-header-summary > div { min-width: 0; overflow-wrap: anywhere; }
.rx-header-summary strong { color: var(--gray-900); }
[data-theme="dark"] .rx-header-summary strong { color: var(--gray-100); }
@media (min-width: 768px) {
  .rx-page-header { flex-direction: row; justify-content: space-between; align-items: center; }
}

.rx-body {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  background: #FCFDFF;
  padding: clamp(0.8rem, 2vw, 1.25rem);
  overflow: hidden;
  min-width: 0;
}
[data-theme="dark"] .rx-body { background: var(--dark-surface); border-color: var(--dark-border); }

.rx-layout { display: grid; grid-template-columns: 1fr; gap: clamp(0.8rem, 1.6vw, 1rem); align-items: start; min-width: 0; }
.rx-left-panel, .rx-right-panel { display: grid; gap: clamp(0.75rem, 1.4vw, 0.95rem); min-width: 0; }
@media (min-width: 1024px) { .rx-layout { grid-template-columns: minmax(0, 320px) minmax(0, 1fr); } }

.rx-section-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: clamp(0.9rem, 1.8vw, 1.1rem);
  background: var(--white);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  min-width: 0;
}
[data-theme="dark"] .rx-section-card { background: var(--dark-bg); border-color: var(--dark-border); }

.rx-section-title { font-size: clamp(0.95rem, 1.6vw, 1rem); font-weight: 800; color: var(--gray-900); margin-bottom: 0.75rem; letter-spacing: 0.01em; }
[data-theme="dark"] .rx-section-title { color: var(--gray-100); }

.rx-patient-search, .rx-med-search-box { display: grid; gap: 0.5rem; min-width: 0; }
.rx-search-input {
  width: 100%;
  min-width: 0;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: #FCFDFF;
  color: var(--gray-800);
  font-size: var(--text-base);
}
[data-theme="dark"] .rx-search-input { background: var(--dark-surface); border-color: var(--dark-border); color: var(--gray-100); }
.rx-search-input:focus { border-color: var(--primary-400); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

.rx-search-results {
  display: none;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: var(--white);
  max-height: 12rem;
  overflow-y: auto;
  min-width: 0;
}
[data-theme="dark"] .rx-search-results { background: var(--dark-surface); border-color: var(--dark-border); }
.rx-search-results.active { display: grid; }
.rx-search-item, .rx-search-empty { padding: 0.7rem 0.8rem; font-size: 0.9rem; color: var(--gray-700); cursor: pointer; }
.rx-search-item:hover { background: var(--primary-50); }
.rx-search-item { display: flex; align-items: center; gap: 0.6rem; }
.rx-search-item-avatar {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-300), var(--primary-500));
  color: var(--white);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.rx-search-item-info { flex: 1; min-width: 0; }
.rx-search-item-name { font-weight: 600; color: var(--gray-800); }
.rx-search-item-sub { font-size: 0.78rem; color: var(--gray-500); }
.rx-search-item-action { font-size: 0.78rem; font-weight: 700; color: var(--primary-600); flex-shrink: 0; }

.rx-patient-card, .rx-doctor-card { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; padding-top: 0.7rem; border-top: 1px solid var(--gray-200); }
[data-theme="dark"] .rx-patient-card, [data-theme="dark"] .rx-doctor-card { border-color: var(--dark-border); }
.rx-patient-avatar, .rx-doctor-avatar {
  width: clamp(2.4rem, 4.5vw, 3rem);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-600), var(--teal-500));
  color: var(--white);
  font-weight: 700;
  flex-shrink: 0;
}
.rx-patient-details, .rx-doctor-details { display: grid; gap: 0.25rem; flex: 1 1 12rem; min-width: 0; }
.rx-patient-name, .rx-doctor-name { font-weight: 700; color: var(--gray-900); word-break: break-word; }
[data-theme="dark"] .rx-patient-name, [data-theme="dark"] .rx-doctor-name { color: var(--gray-100); }
.rx-patient-meta, .rx-doctor-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); gap: 0.3rem 0.6rem; font-size: 0.82rem; color: var(--gray-600); }
[data-theme="dark"] .rx-patient-meta, [data-theme="dark"] .rx-doctor-meta { color: var(--gray-400); }
.meta-label { font-weight: 700; color: var(--gray-700); }
[data-theme="dark"] .meta-label { color: var(--gray-300); }
.rx-patient-change-btn {
  margin-inline-start: auto;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius-full);
  background: var(--primary-50);
  color: var(--primary-700);
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}
.rx-doctor-error { color: var(--error); font-size: 0.88rem; }

/* Voice panel */
.rx-voice-card { height: 100%; }
.rx-voice-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  padding: clamp(0.85rem, 2vw, 1rem);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #F8FBFF 0%, #FFFFFF 100%);
}
[data-theme="dark"] .rx-voice-panel { background: var(--dark-surface); border-color: var(--dark-border); }
.rx-mic-button {
  width: clamp(4.25rem, 12vw, 5.75rem);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid var(--primary-100);
  background: var(--primary-50);
  font-size: clamp(1.6rem, 3vw, 2rem);
  color: var(--primary-700);
  transition: background var(--t-fast), color var(--t-fast);
}
.rx-mic-button.recording { background: var(--danger-500); color: var(--white); box-shadow: 0 0 0 6px rgba(220, 38, 38, 0.12); }
.rx-voice-status { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.65rem; }
.rx-status-pill { display: inline-flex; align-items: center; padding: 0.35rem 0.7rem; border-radius: var(--radius-full); background: var(--success-50); color: var(--success-700); font-size: 0.78rem; font-weight: 700; }
.rx-timer { font-size: 0.95rem; font-weight: 700; color: var(--gray-800); font-family: monospace; }
[data-theme="dark"] .rx-timer { color: var(--gray-100); }
.rx-waveform { display: flex; align-items: flex-end; gap: 0.3rem; height: 2rem; }
.rx-waveform span { display: block; width: 0.35rem; border-radius: var(--radius-full); background: var(--gray-400); height: 0.6rem; }
.rx-waveform.active span { background: var(--primary-500); }
.rx-progress-block { width: 100%; }
.rx-progress-track { width: 100%; height: 0.45rem; border-radius: var(--radius-full); background: var(--gray-200); overflow: hidden; }
.rx-progress-track span { display: block; width: 18%; height: 100%; background: linear-gradient(90deg, var(--primary-500), var(--primary-400)); transition: width 0.3s ease; }
.rx-progress-label { margin-top: 0.35rem; font-size: 0.8rem; color: var(--gray-600); text-align: center; }
[data-theme="dark"] .rx-progress-label { color: var(--gray-400); }

.rx-record-actions { display: grid; grid-template-columns: 1fr; gap: 0.6rem; width: 100%; }
@media (min-width: 640px) { .rx-record-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.rx-textarea {
  width: 100%;
  min-width: 0;
  min-height: clamp(7rem, 18vw, 9rem);
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: #FCFDFF;
  color: var(--gray-800);
  font-size: var(--text-base);
  line-height: 1.55;
  margin-bottom: 0.6rem;
}
[data-theme="dark"] .rx-textarea { background: var(--dark-surface); border-color: var(--dark-border); color: var(--gray-100); }
.rx-textarea:focus { border-color: var(--primary-400); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

/* Medicine toolbar & search */
.rx-med-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-bottom: 0.75rem; }
.rx-med-search-box { position: relative; margin-bottom: 0.75rem; }
.rx-med-search-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: #FCFDFF;
}
[data-theme="dark"] .rx-med-search-input-wrapper { background: var(--dark-surface); border-color: var(--dark-border); }
.rx-search-icon { padding-inline: 0.4rem; color: var(--gray-500); }
.rx-med-search-input { flex: 1 1 auto; min-width: 0; padding: 0.6rem 0.25rem; border: none; background: transparent; color: var(--gray-800); font-size: var(--text-base); }
[data-theme="dark"] .rx-med-search-input { color: var(--gray-100); }
.rx-med-search-voice, .rx-voice-btn-sm {
  width: 2.4rem;
  height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-700);
  flex-shrink: 0;
  font-size: 1rem;
}
[data-theme="dark"] .rx-med-search-voice, [data-theme="dark"] .rx-voice-btn-sm { background: var(--dark-surface); border-color: var(--dark-border); color: var(--gray-100); }

.rx-med-search-dropdown {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 0.3rem);
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  max-height: 15rem;
  overflow-y: auto;
  display: none;
}
[data-theme="dark"] .rx-med-search-dropdown { background: var(--dark-surface); border-color: var(--dark-border); }
.rx-med-search-dropdown.active { display: block; }
.rx-med-search-item { display: flex; align-items: center; gap: 0.7rem; padding: 0.7rem 0.8rem; border-bottom: 1px solid var(--gray-100); cursor: pointer; }
.rx-med-search-item:last-child { border-bottom: none; }
.rx-med-search-item:hover { background: var(--gray-50); }
.rx-med-search-item-icon { font-size: 1.1rem; }
.rx-med-search-item-info { flex: 1; min-width: 0; }
.rx-med-search-item-name { font-weight: 600; color: var(--gray-900); word-break: break-word; }
.rx-med-search-item-sub { font-size: 0.78rem; color: var(--gray-600); }
.rx-med-search-custom { padding: 0.7rem 0.8rem; color: var(--primary-600); font-weight: 600; cursor: pointer; }

/* Medicine table — horizontally scrollable */
.rx-medicine-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: #FCFDFF;
  -webkit-overflow-scrolling: touch;
}
[data-theme="dark"] .rx-medicine-table-wrap { background: var(--dark-surface); border-color: var(--dark-border); }
.rx-medicine-table { width: 100%; min-width: 34rem; border-collapse: collapse; font-size: 0.88rem; }
.rx-medicine-table th, .rx-medicine-table td { padding: 0.65rem 0.7rem; border-bottom: 1px solid var(--gray-200); text-align: start; }
.rx-medicine-table th { font-weight: 800; color: var(--gray-700); background: var(--gray-50); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
[data-theme="dark"] .rx-medicine-table th, [data-theme="dark"] .rx-medicine-table td { border-color: var(--dark-border); }
[data-theme="dark"] .rx-medicine-table th { background: rgba(37, 99, 235, 0.08); color: var(--gray-300); }
.rx-medicine-table input { width: 100%; border: none; background: transparent; color: var(--gray-800); padding: 0; min-width: 5rem; }
[data-theme="dark"] .rx-medicine-table input { color: var(--gray-100); }
.rx-table-empty { color: var(--gray-500); text-align: center; padding: 0.9rem; }
.rx-table-remove { width: 1.75rem; height: 1.75rem; border: 1px solid var(--gray-200); border-radius: 50%; background: var(--white); color: var(--gray-700); flex-shrink: 0; }

.rx-med-cards { display: grid; gap: 0.6rem; margin-top: 0.75rem; }
.rx-med-card { border: 1px solid var(--gray-200); border-radius: var(--radius-md); padding: 0.85rem; background: var(--white); min-width: 0; }
[data-theme="dark"] .rx-med-card { background: var(--dark-surface); border-color: var(--dark-border); }
.rx-med-card-header { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.6rem; flex-wrap: wrap; }
.rx-med-card-icon { font-size: 1.3rem; }
.rx-med-card-title { flex: 1; min-width: 0; }
.rx-med-card-name-input { width: 100%; border: none; background: transparent; font-weight: 700; color: var(--gray-800); padding: 0; font-size: 0.95rem; }
[data-theme="dark"] .rx-med-card-name-input { color: var(--gray-100); }
.rx-med-card-caption { font-size: 0.72rem; color: var(--gray-400); }
.rx-med-card-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.rx-med-card-voice, .rx-med-card-remove { width: 2rem; height: 2rem; border: 1px solid var(--gray-200); border-radius: 50%; background: var(--white); color: var(--gray-700); font-size: 0.85rem; }
[data-theme="dark"] .rx-med-card-voice, [data-theme="dark"] .rx-med-card-remove { background: var(--dark-surface); border-color: var(--dark-border); color: var(--gray-100); }
.rx-med-card-voice.recording { background: var(--danger-500); color: var(--white); }
.rx-med-card-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: 0.6rem; }
.rx-med-card-field { display: flex; flex-direction: column; gap: 0.25rem; }
.rx-med-card-field-full { grid-column: 1 / -1; }
.rx-med-card-field label { font-size: 0.72rem; color: var(--gray-500); font-weight: 600; }
.rx-med-card-input { width: 100%; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: 0.5rem 0.6rem; background: #FCFDFF; color: var(--gray-800); font-size: 0.88rem; }
[data-theme="dark"] .rx-med-card-input { background: var(--dark-surface); border-color: var(--dark-border); color: var(--gray-100); }

.rx-med-empty { padding: 0.8rem 0 0; color: var(--gray-500); font-size: 0.9rem; }

/* ============================================
   DRUG INFO PANEL (integrated drugbank search)
   ============================================ */
.rx-drug-info-panel {
  margin-top: 0.85rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #FFFFFF 0%, #F8FBFF 100%);
  overflow: hidden;
  min-width: 0;
  animation: fadeInUp 0.25s ease;
}
[data-theme="dark"] .rx-drug-info-panel { background: var(--dark-surface); border-color: var(--dark-border); }

.rx-drug-info-header {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--gray-200);
  flex-wrap: wrap;
}
[data-theme="dark"] .rx-drug-info-header { border-color: var(--dark-border); }
.rx-drug-info-icon {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.2);
}
.rx-drug-info-title-block { flex: 1; min-width: 0; }
.rx-drug-info-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--gray-900);
  word-break: break-word;
  line-height: 1.3;
}
[data-theme="dark"] .rx-drug-info-title { color: var(--gray-100); }
.rx-drug-info-subtitle { font-size: 0.78rem; color: var(--gray-500); margin-top: 2px; word-break: break-word; }
.rx-drug-info-actions { display: flex; gap: 0.5rem; flex-shrink: 0; flex-wrap: wrap; }
.rx-drug-info-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: var(--white);
  font-size: 0.82rem;
  font-weight: 700;
  transition: box-shadow var(--t-fast), transform var(--t-fast);
}
.rx-drug-info-add-btn:hover { box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35); transform: translateY(-1px); }
.rx-drug-info-close-btn {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full);
  background: var(--gray-100);
  color: var(--gray-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}
[data-theme="dark"] .rx-drug-info-close-btn { background: var(--dark-border); color: var(--gray-300); }

.rx-drug-info-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  padding: 0.9rem 1rem;
  max-height: 24rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 640px) { .rx-drug-info-body { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.rx-drug-info-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.6rem 0.7rem;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  border-inline-start: 3px solid var(--primary-300);
  min-width: 0;
}
[data-theme="dark"] .rx-drug-info-item { background: var(--dark-bg); border-color: var(--primary-700); }
.rx-drug-info-item.rx-drug-item-full { grid-column: 1 / -1; }
.rx-drug-info-item.rx-drug-item-warning { border-inline-start-color: var(--warning-500); }
.rx-drug-info-item.rx-drug-item-danger { border-inline-start-color: var(--error); }
.rx-drug-info-label {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
[data-theme="dark"] .rx-drug-info-label { color: var(--gray-400); }
.rx-drug-info-value {
  font-size: 0.85rem;
  color: var(--gray-700);
  word-break: break-word;
  line-height: 1.55;
  white-space: pre-line;
}
[data-theme="dark"] .rx-drug-info-value { color: var(--gray-300); }

.rx-drug-tag-list { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.rx-drug-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  background: var(--primary-50);
  border: 1px solid var(--primary-100);
  color: var(--primary-700);
  font-size: 0.78rem;
  font-weight: 600;
  word-break: break-word;
}
[data-theme="dark"] .rx-drug-tag { background: rgba(37, 99, 235, 0.12); border-color: rgba(37, 99, 235, 0.28); color: var(--primary-300); }

.rx-drug-warning-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
}
.rx-drug-warning-badge.danger { background: var(--error-light); color: var(--error-dark); }
.rx-drug-warning-badge.warning { background: var(--warning-light); color: var(--warning); }
.rx-drug-warning-badge.safe { background: var(--success-light); color: var(--success-700); }

.rx-drug-info-loading, .rx-drug-info-empty {
  padding: 1.4rem 1rem;
  text-align: center;
  color: var(--gray-400);
  font-size: 0.88rem;
}
.rx-drug-info-loading { display: flex; align-items: center; justify-content: center; gap: 0.6rem; }
.rx-drug-info-loading .rx-mini-spinner {
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary-500);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Brand/generic chip in search dropdown */
.rx-med-search-item .rx-drug-type-chip {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: var(--teal-50);
  color: var(--teal-600);
  border: 1px solid rgba(20, 184, 166, 0.3);
  flex-shrink: 0;
}
[data-theme="dark"] .rx-med-search-item .rx-drug-type-chip { background: rgba(20, 184, 166, 0.12); color: #2DD4BF; }


/* Warning card */
.rx-warning-content { min-height: 3.75rem; border: 1px solid var(--gray-200); border-radius: var(--radius-md); padding: 0.8rem; background: var(--white); }
[data-theme="dark"] .rx-warning-content { background: var(--dark-surface); border-color: var(--dark-border); }
.rx-warning-card {
  border-inline-start: 3px solid var(--warning-500);
  padding: 0.8rem;
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.08) 0%, rgba(255, 255, 255, 0.95) 100%);
  border-radius: var(--radius-sm);
}
[data-theme="dark"] .rx-warning-card { background: linear-gradient(90deg, rgba(245, 158, 11, 0.12), var(--dark-surface) 60%); }
.rx-warning-summary { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }
.rx-warning-summary h4 { font-size: 0.92rem; font-weight: 700; color: var(--warning); }
.rx-warning-summary p { font-size: 0.82rem; color: var(--gray-600); }
.rx-safety-ring {
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  flex-shrink: 0;
}
.rx-safety-risk { background: var(--warning-light); color: var(--warning); border: 3px solid var(--warning-500); }
.rx-warning-actions { display: grid; gap: 0.5rem; margin-top: 0.7rem; }
@media (min-width: 640px) { .rx-warning-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Analysis & suggestions */
.rx-analysis-body { display: flex; flex-direction: column; gap: 0.55rem; color: var(--gray-700); font-size: 0.9rem; min-width: 0; }
[data-theme="dark"] .rx-analysis-body { color: var(--gray-300); }
.rx-pill-list { display: flex; flex-direction: column; gap: 0.45rem; }
.rx-pill-card {
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #FFFFFF 0%, #F8FBFF 100%);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
[data-theme="dark"] .rx-pill-card { background: var(--dark-surface); border-color: var(--dark-border); }
.rx-pill-card strong { font-size: 0.88rem; color: var(--gray-800); }
[data-theme="dark"] .rx-pill-card strong { color: var(--gray-100); }
.rx-pill-card span { font-size: 0.82rem; color: var(--gray-600); }
.rx-skeleton-list { display: flex; flex-direction: column; gap: 0.5rem; }

/* Final prescription preview */
.rx-prescription-preview {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #F8FBFF 0%, #FFFFFF 100%);
  padding: 0.9rem;
  min-width: 0;
}
[data-theme="dark"] .rx-prescription-preview { background: var(--dark-surface); border-color: var(--dark-border); }
.rx-prescription-preview-header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.6rem; margin-bottom: 0.7rem; }
.rx-prescription-preview-header h4 { margin: 0; font-size: 0.95rem; color: var(--gray-900); }
[data-theme="dark"] .rx-prescription-preview-header h4 { color: var(--gray-100); }
.rx-prescription-preview-header p { margin: 0.2rem 0 0; font-size: 0.78rem; color: var(--gray-600); }
.rx-prescription-stamp { padding: 0.3rem 0.6rem; border-radius: var(--radius-full); background: var(--success-50); color: var(--success-700); font-size: 0.75rem; font-weight: 700; }
.rx-prescription-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.6rem; margin-bottom: 0.7rem; }
.rx-prescription-meta div { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.rx-prescription-meta strong { font-size: 0.72rem; color: var(--gray-500); text-transform: uppercase; }
.rx-prescription-meta span { word-break: break-word; }
.rx-prescription-med-list { display: flex; flex-direction: column; gap: 0.45rem; }
.rx-prescription-med-item {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  background: var(--gray-50);
  flex-wrap: wrap;
}
[data-theme="dark"] .rx-prescription-med-item { background: var(--dark-bg); border-color: var(--dark-border); }
.rx-empty-mini { font-size: 0.82rem; color: var(--gray-400); padding: 0.5rem 0; }

/* Action buttons */
.rx-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--gray-200);
  align-items: center;
}
.rx-actions .btn { width: 100%; }
@media (min-width: 640px) { .rx-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .rx-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* Print preview modal */
.rx-print-preview {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm);
}
.rx-print-preview.active { display: flex; }
.rx-print-overlay { position: absolute; inset: 0; background: rgba(2, 6, 23, 0.6); backdrop-filter: blur(6px); }
.rx-print-content {
  position: relative;
  width: min(100%, 56rem);
  max-height: 92dvh;
  background: var(--white);
  border-radius: var(--radius-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
}
.rx-print-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding: var(--space-md); border-bottom: 1px solid var(--gray-200); background: var(--gray-50); flex-wrap: wrap; }
.rx-print-document { flex: 1; overflow-y: auto; padding: var(--space-lg); background: var(--white); }

/* Print document */
.rx-print-inner { font-family: 'Inter', 'Cairo', sans-serif; color: #1A1A1A; max-width: 50rem; margin: 0 auto; padding: 1rem; }
.rx-print-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding-bottom: 1.25rem; border-bottom: 3px solid var(--primary-500); margin-bottom: 1.5rem; flex-wrap: wrap; }
.rx-print-logo { display: flex; align-items: center; gap: 12px; }
.rx-print-logo-icon { font-size: 2.5rem; }
.rx-print-logo-text h1 { font-size: 1.4rem; font-weight: 800; color: var(--primary-600); margin: 0; }
.rx-print-logo-text p { font-size: 0.8rem; color: #666; margin: 2px 0 0; }
.rx-print-info { text-align: end; }
.rx-print-date { font-size: 0.9rem; font-weight: 600; color: #333; }
.rx-print-time { font-size: 0.8rem; color: #666; margin-top: 4px; }
.rx-print-info-section { display: grid; grid-template-columns: 1fr; gap: 1.25rem; margin-bottom: 1.5rem; }
@media (min-width: 768px) { .rx-print-info-section { grid-template-columns: 1fr 1fr; } }
.rx-print-doctor, .rx-print-patient { padding: 1rem; background: #F8F9FA; border-radius: 8px; }
.rx-print-doctor h4, .rx-print-patient h4 { font-size: 0.85rem; font-weight: 700; color: var(--primary-600); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--primary-200); }
.rx-print-doctor-details p, .rx-print-patient-details p { font-size: 0.85rem; color: #444; margin: 4px 0; line-height: 1.5; word-break: break-word; }
.rx-print-diagnosis { margin-bottom: 1.5rem; padding: 1rem; background: #FFFBEB; border-radius: 8px; border-inline-start: 4px solid #F59E0B; }
.rx-print-diagnosis h4 { font-size: 0.85rem; font-weight: 700; color: #B45309; text-transform: uppercase; margin-bottom: 8px; }
.rx-print-diagnosis p { font-size: 0.9rem; color: #333; line-height: 1.6; word-break: break-word; }
.rx-print-medications { margin-bottom: 1.5rem; }
.rx-print-medications h4 { font-size: 0.85rem; font-weight: 700; color: var(--primary-600); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px; }
.rx-print-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.rx-print-table thead { background: var(--primary-500); color: #fff; }
.rx-print-table th { padding: 10px 12px; text-align: start; font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; white-space: nowrap; }
.rx-print-table td { padding: 10px 12px; border-bottom: 1px solid #E5E7EB; color: #333; word-break: break-word; }
.rx-print-table tbody tr:nth-child(even) { background: #F9FAFB; }
.rx-print-notes { margin-bottom: 1.5rem; padding: 1rem; background: #F0F9FF; border-radius: 8px; border-inline-start: 4px solid #3B82F6; }
.rx-print-notes h4 { font-size: 0.85rem; font-weight: 700; color: #2563EB; text-transform: uppercase; margin-bottom: 8px; }
.rx-print-notes p { font-size: 0.9rem; color: #333; line-height: 1.6; word-break: break-word; }
.rx-print-footer { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-top: 2.5rem; padding-top: 1.5rem; border-top: 2px solid #E5E7EB; flex-wrap: wrap; }
.rx-print-signature { text-align: center; min-width: 12.5rem; }
.rx-print-signature-line { width: 12.5rem; height: 2px; background: #333; margin: 0 auto 8px; }
.rx-print-signature p { font-size: 0.8rem; color: #666; font-weight: 500; }
.rx-print-qr { text-align: center; }
.rx-print-qr-placeholder { width: 5rem; height: 5rem; border: 2px dashed #CCC; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 2rem; margin: 0 auto 4px; }
.rx-print-qr p { font-size: 0.75rem; color: #666; }
.rx-print-stamp { text-align: center; margin-top: 1rem; padding: 8px; border-top: 1px solid #E5E7EB; font-size: 0.75rem; color: var(--primary-500); font-weight: 600; }

/* ============================================
   MEDICATION MODULE
   ============================================ */
.medication-page { width: 100%; max-width: 62rem; margin: 0 auto; }
.medication-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-lg); flex-wrap: wrap; gap: var(--space-md); }
.medication-header-info h2 { font-size: var(--text-2xl); font-weight: 700; }
.medication-header-actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; }
.medication-filters { display: flex; align-items: center; gap: var(--space-md); margin-bottom: var(--space-xl); flex-wrap: wrap; }
.med-search { flex: 1; min-width: min(100%, 13rem); }
.med-search .search-input {
  width: 100%;
  padding: 0.65rem 1rem;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
}
[data-theme="dark"] .med-search .search-input { background: var(--dark-surface); border-color: var(--dark-border); color: var(--gray-100); }
.med-search .search-input:focus { border-color: var(--primary-400); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

.med-filter-group { display: flex; gap: var(--space-xs); background: var(--gray-100); padding: 4px; border-radius: var(--radius-md); overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
[data-theme="dark"] .med-filter-group { background: var(--dark-surface); }
.filter-btn { padding: 0.5rem 0.85rem; border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 600; color: var(--gray-600); white-space: nowrap; cursor: pointer; background: transparent; border: none; }
[data-theme="dark"] .filter-btn { color: var(--gray-400); }
.filter-btn:hover { color: var(--primary-600); background: rgba(37, 99, 235, 0.06); }
.filter-btn.active { background: linear-gradient(135deg, var(--primary-500), var(--primary-600)); color: var(--white); box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25); }
.med-sort select { padding: 0.5rem 0.75rem; border-radius: var(--radius-sm); font-size: 0.85rem; min-width: 8rem; border: 1px solid var(--gray-200); background: var(--white); color: var(--gray-700); }
[data-theme="dark"] .med-sort select { background: var(--dark-surface); border-color: var(--dark-border); color: var(--gray-200); }

.medication-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); gap: var(--space-md); margin-bottom: var(--space-xl); }
.med-stat-card { display: flex; align-items: center; gap: 1rem; padding: var(--space-md) var(--space-lg); background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); min-width: 0; }
[data-theme="dark"] .med-stat-card { background: var(--dark-card); border-color: var(--dark-border); }
.med-stat-icon { width: 2.9rem; height: 2.9rem; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.med-stat-icon.active { background: linear-gradient(135deg, var(--success-light), var(--success-50)); color: var(--success); }
.med-stat-icon.completed { background: linear-gradient(135deg, var(--info-light), var(--primary-50)); color: var(--info); }
.med-stat-icon.expired { background: linear-gradient(135deg, var(--error-light), #FEF2F2); color: var(--error); }
.med-stat-value { font-size: 1.4rem; font-weight: 800; line-height: 1.2; }
.med-stat-label { font-size: 0.78rem; color: var(--gray-500); font-weight: 500; }

.medication-card-modern {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: var(--space-lg);
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
[data-theme="dark"] .medication-card-modern { background: var(--dark-card); border-color: var(--dark-border); }
.med-card-header { display: flex; align-items: center; gap: 0.85rem; margin-bottom: var(--space-md); flex-wrap: wrap; }
.med-card-icon { width: 3rem; height: 3rem; border-radius: var(--radius-lg); background: linear-gradient(135deg, var(--primary-100), var(--primary-200)); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
[data-theme="dark"] .med-card-icon { background: rgba(37, 99, 235, 0.18); }
.med-icon-pill { font-size: 1.4rem; }
.med-card-info { flex: 1; min-width: 0; }
.med-card-name { font-size: 1.05rem; font-weight: 700; color: var(--gray-800); word-break: break-word; }
[data-theme="dark"] .med-card-name { color: var(--gray-100); }
.med-card-dose { font-size: 0.82rem; color: var(--gray-500); font-weight: 500; }
.med-card-body { padding-top: var(--space-md); border-top: 1px solid var(--gray-200); }
[data-theme="dark"] .med-card-body { border-color: var(--dark-border); }
.med-card-details { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: var(--space-md); margin-bottom: var(--space-md); }
.med-detail-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.med-detail-label { font-size: 0.72rem; color: var(--gray-400); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.med-detail-value { font-size: 0.88rem; font-weight: 600; color: var(--gray-700); word-break: break-word; }
[data-theme="dark"] .med-detail-value { color: var(--gray-200); }
.med-card-instructions { margin-bottom: var(--space-md); padding: var(--space-sm) var(--space-md); background: var(--primary-50); border-radius: var(--radius-md); border-inline-start: 3px solid var(--primary-400); }
[data-theme="dark"] .med-card-instructions { background: rgba(37, 99, 235, 0.1); }
.med-card-instructions p { font-size: 0.85rem; margin-top: 4px; color: var(--gray-600); word-break: break-word; }
[data-theme="dark"] .med-card-instructions p { color: var(--gray-300); }
.med-card-actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; }
.med-card-actions .btn { flex: 1 1 auto; min-width: 0; }
@media (max-width: 480px) { .med-card-actions .btn { width: 100%; } }

/* ============================================
   MODALS
   ============================================ */
.modal-overlay, .booking-modal-overlay, .logout-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--space-md);
  backdrop-filter: blur(6px);
}
.modal-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  width: min(100%, 31rem);
  max-height: 86dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
}
[data-theme="dark"] .modal-card { background: var(--dark-surface); }
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--gray-200); }
[data-theme="dark"] .modal-header { border-color: var(--dark-border); }
.modal-header h3 { font-size: 1.05rem; font-weight: 700; }
.modal-close-btn, .modal-close {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
  flex-shrink: 0;
  line-height: 1;
}
.modal-close-btn:hover, .modal-close:hover { background: var(--gray-200); }
.modal-body { padding: var(--space-lg); overflow-y: auto; }

.log-timeline { display: flex; flex-direction: column; gap: var(--space-md); }
.log-item { display: flex; align-items: flex-start; gap: 0.75rem; padding: var(--space-sm) 0; border-bottom: 1px solid var(--gray-100); }
.log-item:last-child { border-bottom: none; }
.log-status { font-size: 1.1rem; flex-shrink: 0; }
.log-info { min-width: 0; }
.log-status-text { font-weight: 600; font-size: 0.9rem; }
.log-time { font-size: 0.78rem; color: var(--gray-400); }
.log-notes { font-size: 0.8rem; color: var(--gray-500); margin-top: 4px; word-break: break-word; }

/* Booking modal */
.booking-modal-card {
  background: var(--white);
  border-radius: var(--radius-2xl);
  width: min(100%, 36rem);
  max-height: 92dvh;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
[data-theme="dark"] .booking-modal-card { background: var(--dark-surface); }
.booking-modal-header { display: flex; justify-content: space-between; gap: var(--space-md); padding: var(--space-lg); border-bottom: 1px solid var(--gray-200); }
[data-theme="dark"] .booking-modal-header { border-color: var(--dark-border); }
.booking-modal-icon { width: 2.75rem; height: 2.75rem; border-radius: var(--radius-full); display: inline-flex; align-items: center; justify-content: center; background: var(--primary-50); font-size: 1.3rem; margin-bottom: var(--space-sm); }
.booking-modal-header h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 0.25rem; }
.booking-modal-header p { color: var(--gray-500); font-size: 0.88rem; }
.booking-modal-body { padding: var(--space-lg); overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-md); }
.booking-modal-grid { display: grid; grid-template-columns: 1fr; gap: var(--space-md); }
@media (min-width: 560px) { .booking-modal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.booking-field { display: flex; flex-direction: column; gap: 0.45rem; }
.booking-field-full { grid-column: 1 / -1; }
.booking-field span { font-size: 0.82rem; font-weight: 700; color: var(--gray-600); }
[data-theme="dark"] .booking-field span { color: var(--gray-300); }
.booking-field input, .booking-field textarea, .booking-field select {
  width: 100%;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 0.92rem;
}
[data-theme="dark"] .booking-field input, [data-theme="dark"] .booking-field textarea, [data-theme="dark"] .booking-field select { background: var(--dark-bg); border-color: var(--dark-border); color: var(--gray-100); }
.booking-field input:focus, .booking-field textarea:focus, .booking-field select:focus { border-color: var(--primary-400); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.booking-modal-actions { display: flex; justify-content: flex-end; gap: var(--space-md); padding: var(--space-md) var(--space-lg); border-top: 1px solid var(--gray-200); flex-wrap: wrap; }
[data-theme="dark"] .booking-modal-actions { border-color: var(--dark-border); }
.booking-modal-actions .btn { min-width: 8rem; flex: 1 1 auto; }
.booking-schedule-card { background: linear-gradient(135deg, var(--primary-50), var(--primary-100)); border: 1px solid var(--primary-200); border-radius: var(--radius-lg); padding: var(--space-md) var(--space-lg); }
[data-theme="dark"] .booking-schedule-card { background: rgba(37, 99, 235, 0.1); border-color: rgba(37, 99, 235, 0.25); }
.booking-schedule-title { font-size: 0.78rem; font-weight: 700; color: var(--primary-700); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: var(--space-xs); }
.booking-schedule-card div { font-size: 0.85rem; color: var(--gray-700); line-height: 1.6; word-break: break-word; }
[data-theme="dark"] .booking-schedule-card div { color: var(--gray-300); }
.booking-schedule-card strong { color: var(--primary-600); }
.booking-duration-pill { display: inline-flex; align-items: center; justify-content: center; padding: 0.7rem 1rem; background: var(--gray-100); border: 1px solid var(--gray-200); border-radius: var(--radius-full); font-size: 0.85rem; font-weight: 600; color: var(--gray-700); width: 100%; }
[data-theme="dark"] .booking-duration-pill { background: var(--dark-bg); border-color: var(--dark-border); color: var(--gray-300); }
.booking-slot-list { display: flex; flex-direction: column; gap: var(--space-sm); }
.booking-slot-header { display: flex; align-items: center; justify-content: space-between; font-size: 0.8rem; font-weight: 600; color: var(--gray-500); padding: 0 var(--space-xs); margin-bottom: var(--space-xs); flex-wrap: wrap; gap: 0.4rem; }
.booking-slot-header span:last-child { background: var(--primary-50); color: var(--primary-600); padding: 2px 10px; border-radius: var(--radius-full); font-size: 0.72rem; }
.booking-slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 4.8rem), 1fr)); gap: var(--space-sm); }
.booking-slot-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 0.4rem;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  min-width: 0;
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
}
[data-theme="dark"] .booking-slot-pill { background: var(--dark-surface); border-color: var(--dark-border); color: var(--gray-200); }
.booking-slot-pill:not(.disabled):not([disabled]):hover { border-color: var(--primary-400); background: var(--primary-50); color: var(--primary-700); }
.booking-slot-pill.selected { background: var(--primary-500); border-color: var(--primary-600); color: var(--white); }
[data-theme="dark"] .booking-slot-pill.selected { background: var(--primary-600); border-color: var(--primary-700); }
.booking-slot-pill.disabled, .booking-slot-pill[disabled] {
  background: var(--gray-50);
  border-color: var(--gray-200);
  color: var(--gray-300);
  cursor: not-allowed;
  opacity: 0.55;
  text-decoration: line-through;
}
[data-theme="dark"] .booking-slot-pill.disabled, [data-theme="dark"] .booking-slot-pill[disabled] { background: var(--dark-bg); border-color: var(--dark-border); color: var(--gray-600); }
.booking-empty-slot { text-align: center; padding: var(--space-xl) var(--space-md); color: var(--gray-400); font-size: 0.88rem; background: var(--gray-50); border: 1px dashed var(--gray-300); border-radius: var(--radius-lg); }

/* Logout modal */
.logout-modal-card {
  background: var(--white);
  border-radius: var(--radius-2xl);
  padding: var(--space-xl);
  width: min(100%, 24rem);
  text-align: center;
  box-shadow: var(--shadow-xl);
}
[data-theme="dark"] .logout-modal-card { background: var(--dark-surface); }
.logout-modal-icon { font-size: 2.5rem; margin-bottom: var(--space-md); opacity: 0.8; }
.logout-modal-card h3 { font-size: 1.15rem; font-weight: 700; color: var(--gray-800); margin-bottom: var(--space-sm); }
[data-theme="dark"] .logout-modal-card h3 { color: var(--gray-100); }
.logout-modal-card p { color: var(--gray-500); font-size: 0.9rem; margin-bottom: var(--space-xl); }
.logout-modal-actions { display: flex; gap: var(--space-md); justify-content: center; flex-wrap: wrap; }
.logout-modal-actions .btn { min-width: 7.5rem; }

/* ============================================
   FEEDBACK MODULE
   ============================================ */
.feedback-page { width: 100%; max-width: 50rem; margin: 0 auto; }
.feedback-header { margin-bottom: var(--space-lg); }
.feedback-header h2 { font-size: var(--text-2xl); font-weight: 700; }
.feedback-form-card { padding: var(--space-xl); }
.pain-scale { display: flex; gap: var(--space-xs); justify-content: center; flex-wrap: wrap; margin-bottom: var(--space-sm); }
.pain-btn { width: 2.6rem; height: 2.6rem; border-radius: var(--radius-full); font-weight: 700; font-size: 0.88rem; color: var(--gray-600); background: var(--gray-100); border: 2px solid transparent; cursor: pointer; transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast); }
[data-theme="dark"] .pain-btn { background: var(--dark-border); color: var(--gray-300); }
.pain-btn.selected { background: linear-gradient(135deg, var(--primary-500), var(--primary-600)); color: var(--white); border-color: var(--primary-600); }
.pain-labels { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--gray-400); padding: 0 4px; }
.med-taken-options { display: flex; gap: var(--space-lg); flex-wrap: wrap; }
.radio-label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.92rem; cursor: pointer; }
.radio-label input[type="radio"] { accent-color: var(--primary-500); width: 1.1rem; height: 1.1rem; }
.feedback-history-item { padding: var(--space-md); border-bottom: 1px solid var(--gray-100); margin-bottom: var(--space-sm); }
.feedback-history-item:last-child { border-bottom: none; }
.feedback-history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--space-sm); gap: var(--space-sm); flex-wrap: wrap; }
.feedback-doctor { font-weight: 600; font-size: 0.9rem; color: var(--primary-600); }
.feedback-date { font-size: 0.78rem; color: var(--gray-400); }
.feedback-history-body p { font-size: 0.85rem; margin-bottom: 4px; color: var(--gray-600); word-break: break-word; }

/* ============================================
   FOLLOW-UP MODULE
   ============================================ */
.followup-page { width: 100%; max-width: 75rem; margin: 0 auto; }
.followup-header { margin-bottom: var(--space-lg); }
.followup-header h2 { font-size: var(--text-2xl); font-weight: 700; }
.followup-layout { display: grid; grid-template-columns: 1fr; gap: var(--space-lg); }
@media (min-width: 992px) { .followup-layout { grid-template-columns: 280px 1fr; align-items: start; } }
.followup-sidebar .card { position: static; max-height: none; }
@media (min-width: 992px) { .followup-sidebar .card { position: sticky; top: var(--space-lg); max-height: calc(100dvh - 3rem); overflow-y: auto; } }
.followup-patient-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem; border-radius: var(--radius-md); cursor: pointer; margin-bottom: 4px; border: 1px solid transparent; }
.followup-patient-item:hover { background: var(--primary-50); }
.followup-patient-item.active { background: var(--primary-100); border-color: var(--primary-200); box-shadow: inset 3px 0 0 var(--primary-500); }
[dir="ltr"] .followup-patient-item.active { box-shadow: inset -3px 0 0 var(--primary-500); }
[data-theme="dark"] .followup-patient-item.active { background: rgba(37, 99, 235, 0.15); }
.followup-main { min-width: 0; }
.feedback-timeline { position: relative; padding: var(--space-md) 0; }
.timeline-item { display: flex; gap: var(--space-md); padding: var(--space-md) 0; position: relative; }
.timeline-item::before { content: ''; position: absolute; inset-inline-start: 11px; top: 2.5rem; bottom: 0; width: 2px; background: var(--gray-200); }
[dir="ltr"] .timeline-item::before { inset-inline-start: auto; inset-inline-end: 11px; }
.timeline-item:last-child::before { display: none; }
.timeline-dot { width: 1.5rem; height: 1.5rem; border-radius: var(--radius-full); flex-shrink: 0; z-index: 1; border: 3px solid var(--white); box-shadow: var(--shadow-sm); }
.timeline-dot.success { background: var(--success); }
.timeline-dot.warning { background: var(--warning-500); }
.timeline-dot.danger { background: var(--error); }
.timeline-content { flex: 1; min-width: 0; background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius-md); padding: var(--space-md); box-shadow: var(--shadow-xs); }
[data-theme="dark"] .timeline-content { background: var(--dark-card); border-color: var(--dark-border); }
.timeline-header { display: flex; justify-content: space-between; gap: var(--space-sm); margin-bottom: var(--space-sm); flex-wrap: wrap; }
.timeline-date { font-size: 0.82rem; font-weight: 600; color: var(--primary-600); }
.timeline-pain { font-size: 0.78rem; color: var(--gray-500); }
.timeline-text { font-size: 0.88rem; margin-bottom: 4px; color: var(--gray-700); word-break: break-word; }
[data-theme="dark"] .timeline-text { color: var(--gray-200); }
.timeline-text.muted { color: var(--gray-500); font-size: 0.82rem; }

.followup-note-item { padding: var(--space-md); border-bottom: 1px solid var(--gray-100); margin-bottom: var(--space-sm); }
.followup-note-item:last-child { border-bottom: none; }
.note-header { display: flex; justify-content: space-between; gap: var(--space-sm); margin-bottom: var(--space-sm); flex-wrap: wrap; }
.note-doctor { font-weight: 600; font-size: 0.9rem; color: var(--primary-600); }
.note-date { font-size: 0.78rem; color: var(--gray-400); }
.note-text { font-size: 0.9rem; color: var(--gray-700); line-height: 1.6; word-break: break-word; }
[data-theme="dark"] .note-text { color: var(--gray-200); }

.bar-chart { display: flex; align-items: flex-end; gap: var(--space-md); height: 14rem; padding: var(--space-lg) 0; overflow-x: auto; border-bottom: 2px solid var(--gray-200); }
[data-theme="dark"] .bar-chart { border-color: var(--dark-border); }
.bar-item { display: flex; flex-direction: column; align-items: center; gap: var(--space-xs); min-width: 2.5rem; }
.bar-value { border-radius: var(--radius-sm) var(--radius-sm) 0 0; display: flex; align-items: flex-start; justify-content: center; padding-top: 4px; min-height: 4px; }
.bar-label { font-size: 0.7rem; font-weight: 700; color: var(--white); }
.bar-date { font-size: 0.68rem; color: var(--gray-400); white-space: nowrap; }

.add-note-form { padding: var(--space-md) 0; }
.add-note-form .form-input { min-height: 5rem; }

/* ============================================
   PROFILE & SETTINGS
   ============================================ */
.profile-page, .settings-page { width: 100%; max-width: 50rem; margin: 0 auto; }
.profile-card, .settings-card { padding: var(--space-xl); }
.profile-summary { display: flex; align-items: center; gap: var(--space-lg); margin-bottom: var(--space-xl); padding-bottom: var(--space-lg); border-bottom: 1px solid var(--gray-200); flex-wrap: wrap; }
[data-theme="dark"] .profile-summary { border-color: var(--dark-border); }
.profile-avatar { width: 4.5rem; height: 4.5rem; border-radius: var(--radius-full); background: linear-gradient(135deg, var(--primary-400), var(--primary-600)); display: flex; align-items: center; justify-content: center; color: var(--white); font-weight: 700; font-size: 1.6rem; flex-shrink: 0; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2); }
.profile-summary h3 { font-size: 1.2rem; font-weight: 700; word-break: break-word; }
.profile-summary p { color: var(--gray-500); word-break: break-word; }
.profile-form { display: flex; flex-direction: column; gap: var(--space-lg); }
.form-grid { display: grid; grid-template-columns: 1fr; gap: var(--space-lg); }
@media (min-width: 640px) { .form-grid { grid-template-columns: repeat(2, 1fr); } }

.settings-grid { display: flex; flex-direction: column; gap: var(--space-lg); }
.settings-description { color: var(--gray-500); font-size: 0.9rem; margin-bottom: var(--space-lg); }
.settings-actions { display: flex; gap: var(--space-md); flex-wrap: wrap; margin-top: var(--space-md); }
.settings-form { display: flex; flex-direction: column; gap: var(--space-md); }
.doctor-schedule-form { display: flex; flex-direction: column; gap: var(--space-lg); }
.doctor-schedule-days { display: flex; flex-wrap: wrap; gap: var(--space-sm); }
.doctor-day-chip { display: flex; align-items: center; gap: 6px; padding: 6px 12px; background: var(--gray-100); border-radius: var(--radius-full); font-size: 0.82rem; font-weight: 500; cursor: pointer; }
[data-theme="dark"] .doctor-day-chip { background: var(--dark-border); }
.doctor-day-chip input[type="checkbox"] { accent-color: var(--primary-500); }
.doctor-day-chip:has(input:checked) { background: var(--primary-50); color: var(--primary-700); font-weight: 600; }
[data-theme="dark"] .doctor-day-chip:has(input:checked) { background: rgba(37, 99, 235, 0.18); color: var(--primary-400); }
.doctor-schedule-fields { display: grid; grid-template-columns: 1fr; gap: var(--space-md); }
@media (min-width: 640px) { .doctor-schedule-fields { grid-template-columns: repeat(3, 1fr); } }

/* ============================================
   CHAT UI
   ============================================ */
.chat-layout {
  display: grid;
  grid-template-columns: 1fr;
  height: calc(100dvh - 8rem);
  min-height: 26rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
@media (min-width: 1024px) { .chat-layout { grid-template-columns: 320px 1fr; } }

.chat-sidebar {
  display: none;
  flex-direction: column;
  background: var(--white);
  min-width: 0;
}
[data-theme="dark"] .chat-sidebar { background: var(--dark-surface); }
@media (min-width: 1024px) { .chat-sidebar { display: flex; } }
.chat-sidebar.mobile-visible { display: flex; position: absolute; inset: 0; z-index: 10; }

.chat-sidebar-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--gray-200); }
[data-theme="dark"] .chat-sidebar-header { border-color: var(--dark-border); }
.chat-sidebar-header h2 { font-size: 1.05rem; font-weight: 700; }
.chat-search { padding: var(--space-md); border-bottom: 1px solid var(--gray-200); }
[data-theme="dark"] .chat-search { border-color: var(--dark-border); }
.chat-search .search-input {
  width: 100%;
  padding: 0.65rem 1rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-full);
  font-size: 0.85rem;
}
[data-theme="dark"] .chat-search .search-input { background: var(--dark-bg); border-color: var(--dark-border); color: var(--gray-100); }
.chat-conversations { flex: 1; overflow-y: auto; padding: var(--space-sm); }
.chat-conversation-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.8rem 0.9rem; border-radius: var(--radius-md); cursor: pointer; margin-bottom: 2px; }
.chat-conversation-item:hover { background: var(--primary-50); }
.chat-conversation-item.active { background: var(--primary-100); box-shadow: inset 3px 0 0 var(--primary-500); }
[dir="ltr"] .chat-conversation-item.active { box-shadow: inset -3px 0 0 var(--primary-500); }
[data-theme="dark"] .chat-conversation-item.active { background: rgba(37, 99, 235, 0.15); }
.chat-conv-avatar { width: 2.9rem; height: 2.9rem; border-radius: var(--radius-full); background: linear-gradient(135deg, var(--primary-300), var(--primary-500)); display: flex; align-items: center; justify-content: center; color: var(--white); font-weight: 700; font-size: 1rem; flex-shrink: 0; }
.chat-conv-info { flex: 1; min-width: 0; }
.chat-conv-name { font-weight: 600; font-size: 0.88rem; color: var(--gray-800); margin-bottom: 2px; }
[data-theme="dark"] .chat-conv-name { color: var(--gray-100); }
.chat-conv-preview { font-size: 0.78rem; color: var(--gray-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.chat-conv-time { font-size: 0.68rem; color: var(--gray-400); font-weight: 500; }
.chat-conv-badge { background: linear-gradient(135deg, var(--primary-500), var(--primary-600)); color: var(--white); font-size: 0.65rem; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-full); min-width: 1.25rem; text-align: center; }

.chat-main { display: flex; flex-direction: column; background: var(--gray-50); min-width: 0; position: relative; }
[data-theme="dark"] .chat-main { background: var(--dark-bg); }
.chat-messages-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding: var(--space-md) var(--space-lg); background: var(--white); border-bottom: 1px solid var(--gray-200); }
[data-theme="dark"] .chat-messages-header { background: var(--dark-surface); border-color: var(--dark-border); }
.chat-header-info { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.chat-header-avatar { width: 2.6rem; height: 2.6rem; border-radius: var(--radius-full); background: linear-gradient(135deg, var(--primary-400), var(--primary-600)); display: flex; align-items: center; justify-content: center; color: var(--white); font-weight: 700; font-size: 0.95rem; flex-shrink: 0; }
.chat-header-name { font-weight: 700; font-size: 0.92rem; color: var(--gray-800); }
[data-theme="dark"] .chat-header-name { color: var(--gray-100); }
.chat-header-status { font-size: 0.78rem; color: var(--success); font-weight: 500; }
.chat-messages-area { flex: 1; overflow-y: auto; padding: var(--space-md); display: flex; flex-direction: column; gap: var(--space-sm); }
.chat-message { display: flex; margin-bottom: var(--space-sm); }
.chat-message.mine { justify-content: flex-end; }
.chat-message.theirs { justify-content: flex-start; }
.chat-bubble { max-width: 85%; padding: 0.7rem 0.95rem; border-radius: var(--radius-lg); font-size: 0.88rem; line-height: 1.6; word-wrap: break-word; box-shadow: var(--shadow-xs); }
@media (min-width: 768px) { .chat-bubble { max-width: 70%; } }
.chat-message.mine .chat-bubble { background: linear-gradient(135deg, var(--primary-500), var(--primary-600)); color: var(--white); border-bottom-start-radius: 4px; }
.chat-message.theirs .chat-bubble { background: var(--white); color: var(--gray-800); border: 1px solid var(--gray-200); border-bottom-end-radius: 4px; }
[data-theme="dark"] .chat-message.theirs .chat-bubble { background: var(--dark-surface); color: var(--gray-100); border-color: var(--dark-border); }
.chat-message-time { display: flex; align-items: center; gap: 4px; font-size: 0.65rem; margin-top: 6px; opacity: 0.7; direction: ltr; }
.chat-message.mine .chat-message-time { justify-content: flex-end; }
.chat-image-wrapper { border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 4px; }
.chat-image { width: 100%; max-height: 14rem; object-fit: cover; border-radius: var(--radius-sm); }
.chat-voice-wrapper { display: flex; align-items: center; gap: 0.5rem; min-width: 0; flex-wrap: wrap; }
.chat-play-btn { width: 2.25rem; height: 2.25rem; border-radius: var(--radius-full); background: rgba(255,255,255,0.2); color: var(--white); display: flex; align-items: center; justify-content: center; font-size: 0.85rem; flex-shrink: 0; }
.chat-message.theirs .chat-play-btn { background: var(--primary-100); color: var(--primary-600); }
.chat-voice-wave { display: flex; align-items: center; gap: 3px; flex: 1; min-width: 4rem; }
.chat-voice-wave span { width: 3px; height: 1.25rem; background: rgba(255,255,255,0.5); border-radius: 2px; }
.chat-message.theirs .chat-voice-wave span { background: var(--primary-300); }
.chat-voice-duration { font-size: 0.72rem; color: rgba(255,255,255,0.7); }
.chat-message.theirs .chat-voice-duration { color: var(--gray-500); }
.chat-pdf-wrapper { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem; background: rgba(255,255,255,0.1); border-radius: var(--radius-sm); min-width: 0; flex-wrap: wrap; }
.chat-message.theirs .chat-pdf-wrapper { background: var(--gray-50); }
.chat-pdf-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chat-pdf-name { font-size: 0.82rem; font-weight: 500; word-break: break-word; }
.chat-pdf-link { font-size: 0.72rem; color: var(--primary-400); text-decoration: underline; }
.chat-caption { font-size: 0.82rem; margin-top: 4px; opacity: 0.9; }

.chat-input-container { padding: var(--space-md) var(--space-lg); background: var(--white); border-top: 1px solid var(--gray-200); }
[data-theme="dark"] .chat-input-container { background: var(--dark-surface); border-color: var(--dark-border); }
.chat-input-area { display: flex; align-items: flex-end; gap: var(--space-sm); background: var(--gray-50); border-radius: var(--radius-lg); padding: var(--space-sm); border: 1px solid var(--gray-200); }
[data-theme="dark"] .chat-input-area { background: var(--dark-bg); border-color: var(--dark-border); }
.chat-input { flex: 1; min-width: 0; padding: 0.5rem 0.75rem; background: transparent; font-size: 0.9rem; resize: none; max-height: 7.5rem; color: var(--gray-800); line-height: 1.5; }
[data-theme="dark"] .chat-input { color: var(--gray-100); }
.chat-attach-btn, .chat-voice-btn, .chat-send-btn { width: 2.3rem; height: 2.3rem; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; cursor: pointer; }
.chat-attach-btn:hover, .chat-voice-btn:hover { background: var(--gray-200); }
[data-theme="dark"] .chat-attach-btn:hover, [data-theme="dark"] .chat-voice-btn:hover { background: var(--dark-border); }
.chat-voice-btn.recording { background: var(--error); color: var(--white); }
.chat-send-btn { background: linear-gradient(135deg, var(--primary-500), var(--primary-600)); color: var(--white); box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3); }

.chat-file-preview-overlay { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.6); display: none; align-items: center; justify-content: center; z-index: 1000; padding: var(--space-md); backdrop-filter: blur(6px); }
.chat-file-preview-card { background: var(--white); border-radius: var(--radius-xl); width: min(100%, 30rem); max-height: 86dvh; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-xl); }
[data-theme="dark"] .chat-file-preview-card { background: var(--dark-surface); }
.chat-file-preview-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--gray-200); }
[data-theme="dark"] .chat-file-preview-header { border-color: var(--dark-border); }
.chat-close-btn { width: 2rem; height: 2rem; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; background: var(--gray-100); font-size: 0.85rem; flex-shrink: 0; }
.chat-file-preview-body { padding: var(--space-md) var(--space-lg); overflow-y: auto; }
.chat-preview-image { width: 100%; max-height: 16rem; object-fit: contain; border-radius: var(--radius-md); }
.chat-pdf-preview { display: flex; align-items: center; gap: 1rem; padding: var(--space-lg); background: var(--gray-50); border-radius: var(--radius-md); flex-wrap: wrap; }
.chat-pdf-icon-large { font-size: 2rem; }
.chat-file-preview-footer { padding: var(--space-md) var(--space-lg); border-top: 1px solid var(--gray-200); display: flex; flex-direction: column; gap: var(--space-md); }
[data-theme="dark"] .chat-file-preview-footer { border-color: var(--dark-border); }
.chat-typing { padding: 0.7rem 0.95rem; display: flex; align-items: center; gap: 0.75rem; background: var(--white); border: 1px solid var(--gray-200); }
[data-theme="dark"] .chat-typing { background: var(--dark-surface); border-color: var(--dark-border); }
.typing-dots { display: flex; gap: 5px; }
.typing-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--gray-400); }
.typing-name { font-size: 0.78rem; color: var(--gray-400); }

/* ============================================
   TOASTS
   ============================================ */
.toast-container { position: fixed; top: var(--space-md); inset-inline-end: var(--space-md); z-index: 9999; display: flex; flex-direction: column; gap: var(--space-sm); pointer-events: none; width: min(92vw, 26rem); }
.toast {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  background: var(--white);
  box-shadow: var(--shadow-lg);
  border-inline-start: 4px solid var(--primary-500);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.88rem;
  pointer-events: all;
  position: relative;
  overflow: hidden;
}
[data-theme="dark"] .toast { background: var(--dark-surface); color: var(--gray-100); }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--error); }
.toast.warning { border-color: var(--warning-500); }
.toast .toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast .toast-close { margin-inline-start: auto; cursor: pointer; opacity: 0.5; flex-shrink: 0; padding: 2px; }
.toast .toast-close:hover { opacity: 1; }

/* ============================================
   LANGUAGE SWITCHER
   ============================================ */
.lang-switcher-permanent {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-full);
  padding: 3px;
  z-index: 999;
  position: fixed;
  bottom: var(--space-md);
  inset-inline-start: var(--space-md);
  box-shadow: var(--shadow-md);
}
[data-theme="dark"] .lang-switcher-permanent { background: var(--dark-surface); border-color: var(--dark-border); }
.lang-switcher-permanent.dashboard-mode { position: static; box-shadow: none; background: transparent; }
.lang-switcher-btn { display: flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--radius-full); font-size: 0.78rem; font-weight: 500; color: var(--gray-600); background: transparent; cursor: pointer; white-space: nowrap; transition: background var(--t-fast); }
.lang-switcher-btn:hover { background: var(--gray-100); }
[data-theme="dark"] .lang-switcher-btn:hover { background: var(--dark-border); }
.lang-switcher-btn.active { background: linear-gradient(135deg, var(--primary-500), var(--primary-600)); color: var(--white); box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3); }
.lang-switcher-btn .lang-flag { font-size: 0.9rem; line-height: 1; }
.lang-switcher-btn .lang-name { font-size: 0.72rem; font-weight: 600; }

/* ============================================
   DRUG INTERACTION DIALOG
   ============================================ */
.drug-interaction-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: var(--space-md);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.drug-interaction-overlay.active { opacity: 1; visibility: visible; }
.drug-interaction-modal {
  width: min(100%, 40rem);
  max-height: 88dvh;
  background: var(--white);
  border-radius: var(--radius-2xl);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--gray-200);
}
[data-theme="dark"] .drug-interaction-modal { background: var(--dark-surface); border-color: var(--dark-border); }
.drug-int-header { display: flex; align-items: flex-start; gap: var(--space-md); padding: var(--space-lg); background: linear-gradient(135deg, var(--error-light), #FEF2F2); border-bottom: 1px solid rgba(220, 38, 38, 0.15); }
[data-theme="dark"] .drug-int-header { background: rgba(220, 38, 38, 0.12); }
.drug-int-warning-icon { font-size: 2rem; flex-shrink: 0; line-height: 1; }
.drug-int-header h3 { font-size: 1.15rem; font-weight: 700; color: var(--error-dark); margin-bottom: 2px; }
[data-theme="dark"] .drug-int-header h3 { color: #FECACA; }
.drug-int-subtitle { font-size: 0.85rem; color: var(--gray-600); line-height: 1.5; }
.drug-int-close { width: 2.1rem; height: 2.1rem; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.6); border: 1px solid rgba(220, 38, 38, 0.2); color: var(--gray-500); font-size: 0.9rem; cursor: pointer; flex-shrink: 0; margin-inline-start: auto; }
.drug-int-body { flex: 1; overflow-y: auto; padding: var(--space-lg); display: flex; flex-direction: column; gap: var(--space-lg); }
.drug-int-score-row { display: flex; align-items: center; gap: var(--space-xl); padding: var(--space-md); background: var(--gray-50); border-radius: var(--radius-lg); border: 1px solid var(--gray-100); flex-wrap: wrap; }
[data-theme="dark"] .drug-int-score-row { background: var(--dark-bg); border-color: var(--dark-border); }
.drug-int-score { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.drug-int-score-ring {
  width: 5.25rem;
  height: 5.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: conic-gradient(var(--error) calc(var(--score) * 1%), var(--gray-200) 0);
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.15);
}
.drug-int-score-ring::before { content: ''; position: absolute; inset: 10px; background: var(--white); border-radius: 50%; }
[data-theme="dark"] .drug-int-score-ring::before { background: var(--dark-surface); }
.drug-int-score-ring span { position: relative; z-index: 1; font-size: 1.4rem; font-weight: 800; color: var(--gray-900); }
[data-theme="dark"] .drug-int-score-ring span { color: var(--gray-100); }
.drug-int-score-ring.rec-caution { background: conic-gradient(var(--warning-500) calc(var(--score) * 1%), var(--gray-200) 0); }
.drug-int-score-ring.rec-safe { background: conic-gradient(var(--success) calc(var(--score) * 1%), var(--gray-200) 0); }
.drug-int-score-label { font-size: 0.72rem; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.04em; }
.drug-int-summary { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-sm); }
.drug-int-count { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
.drug-int-count-num { font-size: 2rem; font-weight: 800; color: var(--error-dark); line-height: 1; }
[data-theme="dark"] .drug-int-count-num { color: #FECACA; }
.drug-int-count-label { font-size: 0.88rem; color: var(--gray-600); font-weight: 500; }
.drug-int-section h4 { font-size: 0.82rem; font-weight: 700; color: var(--gray-700); margin-bottom: var(--space-sm); text-transform: uppercase; letter-spacing: 0.04em; }
[data-theme="dark"] .drug-int-section h4 { color: var(--gray-300); }
.drug-int-medicines { display: flex; flex-wrap: wrap; gap: var(--space-sm); }
.drug-int-med-pill { display: inline-flex; align-items: center; padding: 0.4rem 0.85rem; border-radius: var(--radius-full); background: var(--primary-50); border: 1px solid var(--primary-200); color: var(--primary-700); font-size: 0.82rem; font-weight: 600; }
[data-theme="dark"] .drug-int-med-pill { background: rgba(37, 99, 235, 0.12); border-color: rgba(37, 99, 235, 0.3); color: var(--primary-300); }
.drug-int-item { padding: var(--space-md); background: var(--gray-50); border-radius: var(--radius-md); border: 1px solid var(--gray-200); margin-bottom: var(--space-sm); }
[data-theme="dark"] .drug-int-item { background: var(--dark-bg); border-color: var(--dark-border); }
.drug-int-pair { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; margin-bottom: 6px; }
.drug-int-pill { display: inline-flex; align-items: center; padding: 0.35rem 0.75rem; border-radius: var(--radius-full); background: var(--error-light); color: var(--error-dark); font-size: 0.8rem; font-weight: 600; }
.drug-int-arrow { color: var(--gray-400); font-weight: 700; }
.drug-int-desc { font-size: 0.83rem; color: var(--gray-600); line-height: 1.6; word-break: break-word; }
.drug-int-severity { display: inline-flex; margin-top: 6px; padding: 2px 10px; border-radius: var(--radius-full); font-size: 0.68rem; font-weight: 700; text-transform: uppercase; }
.drug-int-severity-major, .drug-int-severity-high { background: var(--error-light); color: var(--error-dark); }
.drug-int-severity-moderate, .drug-int-severity-medium { background: var(--warning-light); color: var(--warning); }
.drug-int-severity-minor, .drug-int-severity-low { background: var(--success-light); color: var(--success-700); }
.drug-int-unknown { padding: var(--space-sm) var(--space-md); background: var(--warning-light); border-radius: var(--radius-md); border: 1px solid rgba(245, 158, 11, 0.3); font-size: 0.8rem; color: var(--warning); }
.drug-int-suggestions { padding: var(--space-md); background: var(--success-light); border-radius: var(--radius-md); border: 1px solid rgba(5, 150, 105, 0.3); }
.drug-int-suggestions h4 { color: var(--success-700); margin-bottom: var(--space-sm); }
.drug-int-suggestion-row { display: flex; justify-content: space-between; align-items: center; gap: var(--space-sm); padding: 6px 0; font-size: 0.8rem; color: var(--gray-600); flex-wrap: wrap; }
.drug-int-alt { font-weight: 600; color: var(--success-700); }
.drug-int-empty { color: var(--gray-400); font-size: 0.88rem; text-align: center; padding: var(--space-sm); }
.drug-int-footer { display: flex; gap: var(--space-md); padding: var(--space-lg); border-top: 1px solid var(--gray-200); background: var(--gray-50); flex-direction: column-reverse; }
[data-theme="dark"] .drug-int-footer { border-color: var(--dark-border); background: var(--dark-bg); }
.drug-int-footer .btn { width: 100%; }
@media (min-width: 640px) { .drug-int-footer { flex-direction: row; } .drug-int-footer .btn { flex: 1; } }
@media (max-width: 640px) {
  .drug-int-score-row { flex-direction: column; align-items: center; text-align: center; }
  .drug-int-summary { align-items: center; }
}

/* ============================================
   ADMIN PANEL — preserved, responsive-safe
   ============================================ */
.admin-login-page { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: var(--space-md); background: linear-gradient(160deg, #0B1120 0%, #1A2332 100%); position: relative; overflow: hidden; }
.admin-login-container { width: 100%; max-width: 26rem; position: relative; z-index: 1; }
.admin-login-card { background: rgba(26, 35, 50, 0.95); backdrop-filter: blur(20px); border: 1px solid rgba(42, 53, 71, 0.6); border-radius: var(--radius-2xl); padding: clamp(1.5rem, 5vw, 2.5rem) clamp(1.25rem, 4vw, 2rem); box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5); }
.admin-login-header { text-align: center; margin-bottom: var(--space-xl); }
.admin-login-shield { font-size: 2.75rem; margin-bottom: 0.75rem; }
.admin-login-header h1 { font-size: var(--text-2xl); font-weight: 700; color: #fff; margin-bottom: 0.35rem; }
.admin-login-header p { color: var(--gray-400); font-size: 0.9rem; }
.admin-login-card .form-input { background: rgba(15, 23, 42, 0.6); border-color: rgba(42, 53, 71, 0.8); color: #fff; }
.admin-login-card .floating-label { color: var(--gray-400); }
.admin-login-footer { text-align: center; margin-top: var(--space-lg); }
.admin-login-footer a { font-size: 0.9rem; }

.admin-layout { display: flex; min-height: 100dvh; background: var(--gray-50); }
[data-theme="dark"] .admin-layout { background: var(--dark-bg); }
.admin-sidebar {
  width: 260px;
  background: linear-gradient(180deg, #0F172A 0%, #1E293B 100%);
  color: #fff;
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform var(--t-base);
  overflow-y: auto;
  transform: translateX(-100%);
}
[dir="rtl"] .admin-sidebar { transform: translateX(100%); }
.admin-sidebar.open { transform: translateX(0); }
.admin-sidebar-brand { padding: var(--space-lg); border-bottom: 1px solid rgba(255,255,255,0.08); text-align: center; }
.admin-brand-icon { font-size: 2rem; display: block; margin-bottom: 4px; }
.admin-brand-text { display: block; font-size: 1.2rem; font-weight: 800; color: #fff; }
.admin-brand-sub { display: block; font-size: 0.75rem; color: var(--gray-400); font-weight: 500; }
.admin-sidebar-user { display: flex; align-items: center; gap: 0.75rem; padding: var(--space-md) var(--space-lg); border-bottom: 1px solid rgba(255,255,255,0.08); }
.admin-user-avatar { width: 2.5rem; height: 2.5rem; border-radius: var(--radius-full); background: linear-gradient(135deg, var(--primary-500), var(--primary-700)); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1rem; color: #fff; flex-shrink: 0; }
.admin-user-name { font-weight: 600; font-size: 0.9rem; color: #fff; }
.admin-user-role { font-size: 0.75rem; color: var(--gray-400); }
.admin-nav { flex: 1; padding: var(--space-sm) var(--space-md); display: flex; flex-direction: column; gap: 1px; }
.admin-nav-section { font-size: 0.65rem; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.08em; padding: var(--space-md) var(--space-md) var(--space-xs); }
.admin-nav-item { display: flex; align-items: center; gap: 0.75rem; padding: 0.65rem 0.85rem; border-radius: var(--radius-sm); color: var(--gray-300); font-weight: 500; font-size: 0.9rem; transition: background var(--t-fast), color var(--t-fast); cursor: pointer; }
.admin-nav-item:hover { background: rgba(37, 99, 235, 0.12); color: #fff; }
.admin-nav-item.active { background: linear-gradient(135deg, var(--primary-600), var(--primary-700)); color: #fff; font-weight: 600; box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3); }
.admin-nav-item .admin-nav-icon { font-size: 1.1rem; width: 1.5rem; text-align: center; flex-shrink: 0; }
.admin-overlay { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.5); z-index: 99; opacity: 0; visibility: hidden; transition: opacity var(--t-base), visibility var(--t-base); }
.admin-overlay.open { opacity: 1; visibility: visible; }
.admin-main { flex: 1; min-width: 0; margin-inline-start: 0; min-height: 100dvh; display: flex; flex-direction: column; }
.admin-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); padding: var(--space-sm) var(--space-md); background: var(--glass-bg); backdrop-filter: blur(16px); border-bottom: 1px solid var(--glass-border); position: sticky; top: 0; z-index: 50; flex-wrap: wrap; }
[data-theme="dark"] .admin-header { background: rgba(22, 31, 46, 0.85); }
.admin-header-left { display: flex; align-items: center; gap: var(--space-md); min-width: 0; }
.admin-header-left h1 { font-size: 1.15rem; font-weight: 700; color: var(--gray-800); }
[data-theme="dark"] .admin-header-left h1 { color: var(--gray-100); }
.admin-header-right { display: flex; align-items: center; gap: var(--space-sm); }
.admin-header-btn { width: 2.3rem; height: 2.3rem; border-radius: var(--radius-full); display: flex; align-items: center; justify-content: center; background: var(--gray-100); border: 1px solid var(--gray-200); cursor: pointer; font-size: 1rem; flex-shrink: 0; }
[data-theme="dark"] .admin-header-btn { background: var(--dark-surface); border-color: var(--dark-border); }
.admin-header-time { font-size: 0.82rem; color: var(--gray-500); font-weight: 500; font-family: monospace; }
@media (max-width: 767px) { .admin-header-time { display: none; } }
.admin-mobile-btn { display: flex; width: 2.3rem; height: 2.3rem; border-radius: var(--radius-md); background: var(--gray-100); border: 1px solid var(--gray-200); cursor: pointer; font-size: 1.15rem; align-items: center; justify-content: center; flex-shrink: 0; }
[data-theme="dark"] .admin-mobile-btn { background: var(--dark-surface); border-color: var(--dark-border); }
.admin-content { flex: 1; padding: var(--space-md); animation: fadeIn 0.3s ease; min-width: 0; }
.admin-loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--space-3xl); color: var(--gray-400); gap: var(--space-md); }
.admin-loading-sm { display: flex; align-items: center; justify-content: center; padding: var(--space-lg); }
.admin-empty { text-align: center; padding: var(--space-2xl); color: var(--gray-400); font-size: 0.95rem; }

.admin-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); gap: var(--space-md); margin-bottom: var(--space-xl); }
.admin-stat-card { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius-lg); padding: var(--space-md) var(--space-lg); display: flex; align-items: center; gap: 1rem; min-width: 0; }
[data-theme="dark"] .admin-stat-card { background: var(--dark-card); border-color: var(--dark-border); }
.admin-stat-icon { width: 3rem; height: 3rem; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.admin-stat-icon.blue { background: linear-gradient(135deg, var(--primary-100), var(--primary-50)); }
.admin-stat-icon.green { background: linear-gradient(135deg, var(--success-light), var(--success-50)); }
.admin-stat-icon.purple { background: linear-gradient(135deg, #E9D5FF, #F3E8FF); }
.admin-stat-icon.orange { background: linear-gradient(135deg, var(--warning-light), #FFFBEB); }
.admin-stat-icon.info { background: linear-gradient(135deg, var(--info-light), var(--primary-50)); }
.admin-stat-icon.red { background: linear-gradient(135deg, var(--error-light), #FEF2F2); }
.admin-stat-label { font-size: 0.78rem; color: var(--gray-500); font-weight: 600; margin-bottom: 2px; }
.admin-stat-value { font-size: 1.4rem; font-weight: 800; line-height: 1.2; color: var(--gray-900); }
[data-theme="dark"] .admin-stat-value { color: var(--gray-100); }

.admin-dashboard-grid { display: grid; grid-template-columns: 1fr; gap: var(--space-lg); }
@media (min-width: 992px) { .admin-dashboard-grid { grid-template-columns: 1fr 1fr; } }
.admin-card-full { grid-column: 1 / -1; }
.admin-card { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius-lg); padding: var(--space-lg); min-width: 0; }
[data-theme="dark"] .admin-card { background: var(--dark-card); border-color: var(--dark-border); }
.admin-card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); margin-bottom: var(--space-md); flex-wrap: wrap; }
.admin-card-header h3 { font-size: 1rem; font-weight: 700; color: var(--gray-800); }
[data-theme="dark"] .admin-card-header h3 { color: var(--gray-100); }

.admin-status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); gap: var(--space-md); }
.admin-status-item { display: flex; align-items: center; gap: 0.75rem; padding: var(--space-sm) var(--space-md); background: var(--gray-50); border-radius: var(--radius-sm); font-size: 0.85rem; color: var(--gray-600); }
[data-theme="dark"] .admin-status-item { background: var(--dark-bg); }
.admin-status-item span { flex: 1; }
.admin-status-item strong { color: var(--gray-800); font-weight: 600; }
[data-theme="dark"] .admin-status-item strong { color: var(--gray-200); }
.admin-status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.admin-status-item.online .admin-status-dot { background: var(--success); }
.admin-status-item.offline .admin-status-dot { background: var(--error); }
.admin-daily-stats { display: flex; flex-direction: column; gap: var(--space-sm); }
.admin-daily-item { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding: var(--space-sm) var(--space-md); background: var(--gray-50); border-radius: var(--radius-sm); font-size: 0.85rem; color: var(--gray-600); }
[data-theme="dark"] .admin-daily-item { background: var(--dark-bg); }
.admin-daily-item strong { color: var(--gray-800); font-weight: 700; font-size: 1rem; }
[data-theme="dark"] .admin-daily-item strong { color: var(--gray-100); }

.admin-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); margin-bottom: var(--space-lg); flex-wrap: wrap; }
.admin-search-box { flex: 1; min-width: min(100%, 13rem); }
.admin-search-input { width: 100%; padding: 0.65rem 1rem; background: var(--white); border: 1.5px solid var(--gray-200); border-radius: var(--radius-md); font-size: 0.9rem; color: var(--gray-800); }
[data-theme="dark"] .admin-search-input { background: var(--dark-surface); border-color: var(--dark-border); color: var(--gray-100); }
.admin-filter-group { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
.admin-filter-btn { padding: 0.45rem 0.85rem; border-radius: var(--radius-sm); font-size: 0.8rem; font-weight: 600; color: var(--gray-600); background: var(--gray-100); border: 1px solid var(--gray-200); cursor: pointer; white-space: nowrap; }
[data-theme="dark"] .admin-filter-btn { background: var(--dark-surface); border-color: var(--dark-border); color: var(--gray-400); }
.admin-filter-btn.active { background: linear-gradient(135deg, var(--primary-500), var(--primary-600)); color: #fff; border-color: var(--primary-500); box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25); }
.admin-select { padding: 0.5rem 0.75rem; border-radius: var(--radius-sm); font-size: 0.85rem; border: 1px solid var(--gray-200); background: var(--white); color: var(--gray-700); min-width: 8rem; }
[data-theme="dark"] .admin-select { background: var(--dark-surface); border-color: var(--dark-border); color: var(--gray-200); }
.admin-date-input { padding: 0.45rem 0.65rem; border-radius: var(--radius-sm); font-size: 0.85rem; border: 1px solid var(--gray-200); background: var(--white); color: var(--gray-700); }

.admin-table-container { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius-lg); overflow-x: auto; box-shadow: var(--shadow-xs); -webkit-overflow-scrolling: touch; }
[data-theme="dark"] .admin-table-container { background: var(--dark-card); border-color: var(--dark-border); }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 42rem; }
.admin-table thead { background: var(--gray-50); border-bottom: 2px solid var(--gray-200); }
[data-theme="dark"] .admin-table thead { background: var(--dark-surface); border-color: var(--dark-border); }
.admin-table th { padding: 0.75rem 1rem; text-align: start; font-weight: 700; font-size: 0.78rem; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.admin-table td { padding: 0.7rem 1rem; border-bottom: 1px solid var(--gray-100); color: var(--gray-700); }
[data-theme="dark"] .admin-table td { border-color: var(--dark-border); color: var(--gray-300); }
.admin-table tbody tr:hover { background: var(--primary-50); }
[data-theme="dark"] .admin-table tbody tr:hover { background: rgba(37, 99, 235, 0.06); }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table-empty { text-align: center; padding: var(--space-xl) !important; color: var(--gray-400) !important; font-size: 0.9rem; }
.admin-details-cell { max-width: 12.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.82rem; }
.admin-table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.admin-badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: var(--radius-full); font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; white-space: nowrap; }
.admin-badge.green { background: linear-gradient(135deg, var(--success-light), #A7F3D0); color: var(--success-700); }
.admin-badge.blue { background: linear-gradient(135deg, var(--info-light), #BFDBFE); color: var(--primary-700); }
.admin-badge.orange { background: linear-gradient(135deg, var(--warning-light), #FDE68A); color: var(--warning); }
.admin-badge.red { background: linear-gradient(135deg, var(--error-light), #FECACA); color: var(--error-dark); }
.admin-badge.purple { background: linear-gradient(135deg, #E9D5FF, #D8B4FE); color: #7C3AED; }

.admin-action-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.admin-btn-sm { width: 1.9rem; height: 1.9rem; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; font-size: 0.8rem; cursor: pointer; border: 1px solid transparent; flex-shrink: 0; }
.admin-btn-sm.primary { background: var(--primary-50); color: var(--primary-600); border-color: var(--primary-200); }
.admin-btn-sm.success { background: var(--success-light); color: var(--success-700); border-color: rgba(5, 150, 105, 0.3); }
.admin-btn-sm.warning { background: var(--warning-light); color: var(--warning); border-color: rgba(245, 158, 11, 0.3); }
.admin-btn-sm.danger { background: var(--error-light); color: var(--error-dark); border-color: rgba(220, 38, 38, 0.3); }
.admin-actions { display: flex; gap: 4px; flex-wrap: nowrap; }

.admin-pagination { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: var(--space-md); flex-wrap: wrap; }
.admin-page-btn { width: 2.1rem; height: 2.1rem; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 0.85rem; font-weight: 600; color: var(--gray-600); background: var(--white); border: 1px solid var(--gray-200); cursor: pointer; }
[data-theme="dark"] .admin-page-btn { background: var(--dark-surface); border-color: var(--dark-border); color: var(--gray-300); }
.admin-page-btn.active { background: linear-gradient(135deg, var(--primary-500), var(--primary-600)); color: #fff; border-color: var(--primary-500); }

.admin-tabs { display: flex; gap: 2px; background: var(--gray-100); padding: 4px; border-radius: var(--radius-md); margin-bottom: var(--space-lg); overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
[data-theme="dark"] .admin-tabs { background: var(--dark-surface); }
.admin-tab { padding: 0.5rem 1rem; border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 600; color: var(--gray-600); border: none; background: transparent; cursor: pointer; white-space: nowrap; }
.admin-tab.active { background: linear-gradient(135deg, var(--primary-500), var(--primary-600)); color: #fff; box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25); }

.admin-settings-grid { display: grid; gap: var(--space-lg); }
.admin-settings-form { display: flex; flex-direction: column; }
.admin-chat-list { display: flex; flex-direction: column; gap: var(--space-sm); }
.admin-chat-item { display: flex; flex-direction: column; gap: 4px; padding: var(--space-md) var(--space-lg); background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: var(--radius-md); cursor: pointer; min-width: 0; }
[data-theme="dark"] .admin-chat-item { background: var(--dark-card); border-color: var(--dark-border); }
.admin-chat-users { font-size: 0.9rem; color: var(--gray-700); }
.admin-chat-preview { font-size: 0.85rem; color: var(--gray-400); }
.admin-chat-time { font-size: 0.75rem; color: var(--gray-500); direction: ltr; }
.admin-msg-item { padding: var(--space-sm) var(--space-md); margin-bottom: var(--space-sm); border-radius: var(--radius-md); background: var(--gray-50); border-inline-start: 3px solid var(--primary-400); }
[data-theme="dark"] .admin-msg-item { background: var(--dark-surface); }
.admin-msg-item.doctor { border-inline-start-color: var(--success); }
.admin-msg-sender { font-size: 0.8rem; margin-bottom: 4px; }
.admin-msg-text { font-size: 0.9rem; color: var(--gray-700); line-height: 1.5; word-break: break-word; }
.admin-msg-time { font-size: 0.7rem; color: var(--gray-400); margin-top: 4px; direction: ltr; }
.admin-analytics-grid { display: grid; grid-template-columns: 1fr; gap: var(--space-md); }
@media (min-width: 992px) { .admin-analytics-grid { grid-template-columns: repeat(3, 1fr); } }
.admin-analytics-period { padding: var(--space-md); background: var(--gray-50); border-radius: var(--radius-md); }
[data-theme="dark"] .admin-analytics-period { background: var(--dark-bg); }
.admin-analytics-period h4 { font-size: 0.82rem; font-weight: 700; color: var(--primary-600); margin-bottom: var(--space-sm); text-transform: uppercase; }
.admin-analytics-period p { font-size: 0.85rem; color: var(--gray-600); margin-bottom: 4px; word-break: break-word; }

.admin-page-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-md); margin-bottom: var(--space-lg); flex-wrap: wrap; }
.admin-page-header-left h2 { font-size: 1.25rem; font-weight: 700; color: var(--gray-800); }
[data-theme="dark"] .admin-page-header-left h2 { color: var(--gray-100); }
.search-input-wrapper { display: flex; align-items: center; gap: var(--space-sm); background: var(--gray-50); border: 1.5px solid var(--gray-200); border-radius: var(--radius-md); padding: 2px; }
[data-theme="dark"] .search-input-wrapper { background: var(--dark-bg); border-color: var(--dark-border); }
.search-icon { padding: 0 var(--space-sm) 0 var(--space-md); font-size: 1rem; color: var(--gray-400); }
.search-input-wrapper .form-input { flex: 1; min-width: 0; border: none; background: transparent; padding: 0.65rem 0; color: var(--gray-800); }
[data-theme="dark"] .search-input-wrapper .form-input { color: var(--gray-100); }
.admin-cell-username { display: flex; align-items: center; gap: 0.5rem; }
.admin-avatar-sm { width: 2rem; height: 2rem; border-radius: var(--radius-full); background: linear-gradient(135deg, var(--primary-400), var(--primary-600)); display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 0.8rem; flex-shrink: 0; }
.default-admin-row { background: rgba(37, 99, 235, 0.03) !important; }
.status-indicator { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 6px; vertical-align: middle; }
.status-active { background: var(--success); box-shadow: 0 0 6px rgba(5, 150, 105, 0.4); }
.status-inactive { background: var(--gray-400); }
.btn-icon { width: 2rem; height: 2rem; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; font-size: 0.9rem; cursor: pointer; border: 1px solid transparent; background: transparent; }
.btn-icon:hover { background: var(--gray-100); border-color: var(--gray-200); }
.btn-icon:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination-info { font-size: 0.85rem; color: var(--gray-500); }
.pagination-buttons { display: flex; gap: var(--space-sm); flex-wrap: wrap; }
.admin-detail-grid { display: grid; grid-template-columns: 1fr; gap: var(--space-md); }
@media (min-width: 560px) { .admin-detail-grid { grid-template-columns: 1fr 1fr; } }
.admin-detail-item { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.admin-detail-item .form-label { margin-bottom: 0; font-size: 0.75rem; color: var(--gray-500); }
.admin-detail-item .detail-value { font-size: 0.92rem; color: var(--gray-800); font-weight: 500; word-break: break-word; }
[data-theme="dark"] .admin-detail-item .detail-value { color: var(--gray-100); }
.admin-modal { width: min(100%, 36rem); background: var(--white); border-radius: var(--radius-xl); overflow: hidden; box-shadow: var(--shadow-xl); display: flex; flex-direction: column; max-height: 88dvh; }
[data-theme="dark"] .admin-modal { background: var(--dark-surface); }
.admin-modal .modal-header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); padding: var(--space-lg); border-bottom: 1px solid var(--gray-200); }
[data-theme="dark"] .admin-modal .modal-header { border-color: var(--dark-border); }
.admin-modal .modal-header h3 { font-size: 1.05rem; font-weight: 700; color: var(--gray-800); }
[data-theme="dark"] .admin-modal .modal-header h3 { color: var(--gray-100); }
.admin-modal .modal-body { padding: var(--space-lg); overflow-y: auto; }
.admin-modal .modal-footer { display: flex; justify-content: flex-end; gap: var(--space-sm); padding-top: var(--space-lg); border-top: 1px solid var(--gray-100); margin-top: var(--space-lg); flex-wrap: wrap; }
[data-theme="dark"] .admin-modal .modal-footer { border-color: var(--dark-border); }

/* Admin sidebar visible on desktop */
@media (min-width: 1024px) {
  .admin-sidebar { transform: none !important; }
  [dir="rtl"] .admin-sidebar { transform: none !important; }
  .admin-overlay { display: none; }
  .admin-main { margin-inline-start: 260px; }
  .admin-mobile-btn { display: none; }
  .admin-content { padding: var(--space-xl); }
}

/* ============================================
   ANIMATIONS & MOTION
   ============================================ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.page-enter { animation: fadeInUp 0.3s ease; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ============================================
   PRINT
   ============================================ */
@media print {
  body * { visibility: hidden; }
  .rx-print-preview, .rx-print-preview * { visibility: visible !important; }
  .rx-print-preview { position: absolute !important; inset: 0 !important; background: #fff !important; overflow: visible !important; padding: 0; }
  .rx-print-overlay { display: none !important; }
  .rx-print-content { width: 100% !important; max-width: 100% !important; max-height: none !important; box-shadow: none !important; border-radius: 0 !important; overflow: visible !important; }
  .rx-print-toolbar { display: none !important; }
  .rx-print-document { overflow: visible !important; padding: 0 !important; }
  .rx-print-inner { max-width: 100%; padding: 0.5rem; }
  .sidebar, .mobile-menu-btn, .header-actions, .toast-container, .lang-switcher-permanent, .btn { display: none !important; }
  .main-content { margin: 0 !important; padding: 0 !important; }
}

/* ============================================
   PREMIUM INSTALL CARD (Snapchat-style)
   ============================================ */
.install-card {
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  z-index: 2000;
  background: var(--white);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  box-shadow: 0 -8px 40px rgba(15, 23, 42, 0.18);
  border-top: 1px solid var(--glass-border);
  transform: translateY(110%);
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.28s ease;
  opacity: 0;
  pointer-events: none;
  max-width: 100%;
  overscroll-behavior: contain;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
[data-theme="dark"] .install-card {
  background: var(--dark-surface);
  border-color: var(--dark-border);
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.5);
}
.install-card.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Drag-handle (grabber) — iOS bottom-sheet feel */
.install-card-grabber {
  width: 2.6rem;
  height: 5px;
  border-radius: var(--radius-full);
  background: var(--gray-300);
  margin: 0.7rem auto 0.4rem;
  flex-shrink: 0;
}
[data-theme="dark"] .install-card-grabber { background: var(--gray-600); }

.install-card-content {
  padding: 0.9rem var(--space-lg) calc(1.25rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Top row: logo + title + close */
.install-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}
.install-card-brand {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
}
.install-card-logo {
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 0.9rem;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.28);
}
.install-card-title-group { min-width: 0; }
.install-card-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1.3;
  word-break: break-word;
}
[data-theme="dark"] .install-card-title { color: var(--gray-100); }
.install-card-subtitle {
  font-size: 0.78rem;
  color: var(--gray-500);
  font-weight: 500;
  line-height: 1.4;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
[data-theme="dark"] .install-card-subtitle { color: var(--gray-400); }

.install-card-close {
  width: 2.1rem;
  height: 2.1rem;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
  color: var(--gray-500);
  font-size: 1.15rem;
  line-height: 1;
  flex-shrink: 0;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
[data-theme="dark"] .install-card-close { background: var(--dark-border); color: var(--gray-300); }
.install-card-close:hover { background: var(--gray-200); color: var(--gray-700); }
[data-theme="dark"] .install-card-close:hover { background: var(--gray-600); color: var(--white); }

/* Description */
.install-card-desc {
  font-size: 0.86rem;
  color: var(--gray-600);
  line-height: 1.6;
  word-break: break-word;
}
[data-theme="dark"] .install-card-desc { color: var(--gray-400); }

/* Actions */
.install-card-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-sm);
}
.install-card-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), opacity var(--t-fast);
}
.install-card-btn:active { transform: scale(0.985); }
.install-card-btn-primary {
  background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
  color: var(--white);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.32);
}
.install-card-btn-primary:hover { box-shadow: 0 6px 22px rgba(37, 99, 235, 0.42); }
.install-card-btn-primary.loading { opacity: 0.7; pointer-events: none; }
.install-card-btn-icon { width: 1.15rem; height: 1.15rem; flex-shrink: 0; }
.install-card-btn-secondary {
  background: var(--gray-100);
  color: var(--gray-600);
  font-weight: 600;
}
[data-theme="dark"] .install-card-btn-secondary { background: var(--dark-bg); color: var(--gray-400); }
.install-card-btn-secondary:hover { background: var(--gray-200); }
[data-theme="dark"] .install-card-btn-secondary:hover { background: var(--dark-border); color: var(--gray-200); }

/* Desktop / tablet — floating card instead of bottom sheet */
@media (min-width: 768px) {
  .install-card {
    inset-inline: auto;
    inset-inline-end: var(--space-lg);
    bottom: var(--space-lg);
    width: min(24rem, calc(100vw - 3rem));
    border-radius: var(--radius-2xl);
    border: 1px solid var(--glass-border);
    transform: translateY(24px) scale(0.98);
    box-shadow: var(--shadow-xl);
  }
  .install-card.visible { transform: translateY(0) scale(1); }
  .install-card-grabber { display: none; }
  .install-card-content { padding: var(--space-lg); }
  .install-card-actions { grid-template-columns: 1fr 1fr; }
  .install-card-btn-secondary { order: -1; }
}

/* Small phones — keep buttons stacked, tighter padding */
@media (max-width: 380px) {
  .install-card-content { padding-inline: var(--space-md); }
  .install-card-logo { width: 2.9rem; height: 2.9rem; }
  .install-card-title { font-size: 0.98rem; }
}

/* Safe-area support (iPhone notch) */
@supports (padding: env(safe-area-inset-bottom)) {
  .install-card.visible { bottom: 0; }
}
@media (min-width: 768px) {
  @supports (padding: env(safe-area-inset-bottom)) {
    .install-card.visible { bottom: calc(var(--space-lg) + env(safe-area-inset-bottom, 0px)); }
  }
}

