/* ============================================================
   CliniQ+ v2 — Application Stylesheet
   Chong Hua Hospital Clinical Management System
   ============================================================ */

/* ─── FONTS ───────────────────────────────────────────────── */
@import url('https://api.fontshare.com/v2/css?f[]=general-sans@400,500,600,700&display=swap');

/* ─── DESIGN TOKENS ───────────────────────────────────────── */
:root {
  /* Type scale */
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Brand Colors — CHH Green palette */
  --color-primary:           #275228;
  --color-primary-hover:     #1e4220;
  --color-primary-active:    #163318;
  --color-primary-light:     #e8f5ee;
  --color-primary-mid:       #b8ddc8;
  --color-gold:              #e0ba5b;
  --color-gold-light:        #fdf6e3;
  --color-red:               #d12027;

  /* Surfaces */
  --color-bg:              #F7F8FA;
  --color-surface:         #FFFFFF;
  --color-surface-2:       #F9FAFB;
  --color-surface-offset:  #F3F4F6;
  --color-surface-dynamic: #EAECF0;
  --color-border:          #E5E7EB;
  --color-divider:         #F0F1F3;

  /* Text */
  --color-text:        #1A1A2E;
  --color-text-muted:  #6B7280;
  --color-text-faint:  #9CA3AF;
  --color-text-inverse: #FFFFFF;

  /* Semantic */
  --color-error:           #DC2626;
  --color-error-light:     #FEF2F2;
  --color-warning:         #F59E0B;
  --color-warning-light:   #FFFBEB;
  --color-success:         #10B981;
  --color-success-light:   #ECFDF5;
  --color-blue:            #3B82F6;
  --color-blue-light:      #EFF6FF;
  --color-purple:          #8B5CF6;
  --color-purple-light:    #F5F3FF;
  --color-orange:          #F97316;
  --color-orange-light:    #FFF7ED;
  --color-gray:            #6B7280;
  --color-gray-light:      #F9FAFB;

  /* Radius */
  --radius-sm:   0.375rem;   /* 6px */
  --radius-md:   0.5rem;     /* 8px */
  --radius-lg:   0.75rem;    /* 12px */
  --radius-xl:   1rem;       /* 16px */
  --radius-full: 9999px;     /* pills */

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:  0 12px 32px rgba(0,0,0,0.12);
  --shadow-xl:  0 20px 48px rgba(0,0,0,0.15);

  /* Transitions */
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Layout */
  --sidebar-width:         260px;
  --sidebar-collapsed:     64px;
  --header-height:         60px;
  --font-display:          'General Sans', system-ui, -apple-system, sans-serif;
  --font-body:             system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* Dark mode */
[data-theme="dark"] {
  --color-bg:              #0F1117;
  --color-surface:         #161B25;
  --color-surface-2:       #1C2333;
  --color-surface-offset:  #1A2030;
  --color-surface-dynamic: #222838;
  --color-border:          #2D3748;
  --color-divider:         #1E2A3A;
  --color-text:            #E2E8F0;
  --color-text-muted:      #94A3B8;
  --color-text-faint:      #64748B;
  --color-text-inverse:    #0F1117;
  --color-primary:         #34D399;
  --color-primary-hover:   #10B981;
  --color-primary-active:  #059669;
  --color-primary-light:   #064E3B;
  --color-primary-mid:     #065F46;
  --color-error:           #F87171;
  --color-error-light:     #450A0A;
  --color-warning:         #FCD34D;
  --color-warning-light:   #451A03;
  --color-success:         #34D399;
  --color-success-light:   #064E3B;
  --color-blue:            #60A5FA;
  --color-blue-light:      #1E3A5F;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg:  0 12px 32px rgba(0,0,0,0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:              #0F1117;
    --color-surface:         #161B25;
    --color-surface-2:       #1C2333;
    --color-surface-offset:  #1A2030;
    --color-surface-dynamic: #222838;
    --color-border:          #2D3748;
    --color-divider:         #1E2A3A;
    --color-text:            #E2E8F0;
    --color-text-muted:      #94A3B8;
    --color-text-faint:      #64748B;
    --color-text-inverse:    #0F1117;
    --color-primary:         #34D399;
    --color-primary-hover:   #10B981;
    --color-primary-active:  #059669;
    --color-primary-light:   #064E3B;
    --color-error:           #F87171;
    --color-error-light:     #450A0A;
  }
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  min-height: 100dvh;
  line-height: 1.6;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  overflow: hidden;
}

img, picture, video, canvas, svg { display: block; max-width: 100%; }
ul[role='list'], ol[role='list'] { list-style: none; }
input, button, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, h4, h5, h6 { text-wrap: balance; line-height: 1.2; font-family: var(--font-display); }

button { cursor: pointer; background: none; border: none; }
table { border-collapse: collapse; width: 100%; }

a, button, [role='button'], input, textarea, select {
  transition: color var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition), opacity var(--transition);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

::selection { background: rgba(27,107,59,0.15); color: var(--color-text); }

/* ─── SKELETON LOADERS ────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg,
    var(--color-surface-offset) 25%,
    var(--color-surface-dynamic) 50%,
    var(--color-surface-offset) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
.skeleton-text  { height: 1em;    margin-bottom: var(--space-2); }
.skeleton-text:last-child { width: 60%; }
.skeleton-heading { height: 1.5em; width: 40%; margin-bottom: var(--space-4); }
.skeleton-avatar  { width: 40px; height: 40px; border-radius: var(--radius-full); }
.skeleton-rect    { height: 80px; width: 100%; }

/* ─── APP SHELL ───────────────────────────────────────────── */
#app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ─── LOGIN SCREEN ────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  background: linear-gradient(135deg, #0f2e1c 0%, #1B6B3B 50%, #2a8f52 100%);
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.login-bg-pattern {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 20% 20%, rgba(255,255,255,0.05) 1px, transparent 1px),
                    radial-gradient(circle at 80% 80%, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.login-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: var(--space-10) var(--space-10);
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 1;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
  justify-content: center;
}

.login-logo-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, #1B6B3B, #2a8f52);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.login-title { text-align: center; margin-bottom: var(--space-8); }
.login-title h1 {
  font-size: var(--text-xl);
  font-family: var(--font-display);
  color: var(--color-text);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.login-title p {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* Role Selector */
.role-selector {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
  background: var(--color-surface-offset);
  padding: var(--space-1);
  border-radius: var(--radius-full);
}

.role-btn {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  transition: all var(--transition);
  white-space: nowrap;
  text-align: center;
}

.role-btn.active {
  background: var(--color-primary);
  color: white;
  box-shadow: var(--shadow-sm);
}

.role-btn:hover:not(.active) {
  color: var(--color-text);
  background: var(--color-surface-dynamic);
}

/* Form */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.form-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: var(--text-sm);
  color: var(--color-text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(27,107,59,0.1);
}

.form-input::placeholder { color: var(--color-text-faint); }
.form-input.error { border-color: var(--color-error); }

.form-error {
  font-size: var(--text-xs);
  color: var(--color-error);
  margin-top: var(--space-1);
  display: none;
}
.form-error.visible { display: block; }

.input-wrapper {
  position: relative;
}
.input-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-faint);
  pointer-events: none;
}
.input-wrapper .form-input { padding-left: var(--space-10); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}
.btn-primary:hover { background: var(--color-primary-hover); box-shadow: var(--shadow-md); }
.btn-primary:active { background: var(--color-primary-active); }

.btn-secondary {
  background: var(--color-surface-offset);
  color: var(--color-text);
  border: 1.5px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-surface-dynamic); }

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

.btn-danger {
  background: var(--color-error-light);
  color: var(--color-error);
  border: 1.5px solid rgba(220,38,38,0.2);
}
.btn-danger:hover { background: var(--color-error); color: white; }

.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); }
.btn-icon { padding: var(--space-2); border-radius: var(--radius-md); }
.btn-icon-sm { padding: var(--space-1); border-radius: var(--radius-sm); }

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

.btn-loading { position: relative; pointer-events: none; }
.btn-loading::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login-footer {
  text-align: center;
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
}
.login-footer p {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

/* Alert */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
  display: none;
  align-items: center;
  gap: var(--space-2);
}
.alert.visible { display: flex; }
.alert-error { background: var(--color-error-light); color: var(--color-error); border: 1px solid rgba(220,38,38,0.2); }
.alert-success { background: var(--color-success-light); color: #047857; border: 1px solid rgba(16,185,129,0.2); }
.alert-warning { background: var(--color-warning-light); color: #92400E; border: 1px solid rgba(245,158,11,0.2); }

/* ─── SIDEBAR ─────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  height: 100dvh;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition);
  overflow: hidden;
  position: relative;
  z-index: 100;
}

#sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-header {
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--header-height);
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #1B6B3B, #2a8f52);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand {
  overflow: hidden;
  transition: opacity var(--transition), max-width var(--transition);
  max-width: 200px;
}
#sidebar.collapsed .sidebar-brand { opacity: 0; max-width: 0; pointer-events: none; }

.sidebar-brand-name {
  font-size: var(--text-base);
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--color-text);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.sidebar-brand-sub {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  white-space: nowrap;
}

/* User card */
.sidebar-user {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--color-primary), #2a8f52);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.user-info {
  overflow: hidden;
  transition: opacity var(--transition), max-width var(--transition);
  max-width: 160px;
}
#sidebar.collapsed .user-info { opacity: 0; max-width: 0; pointer-events: none; }

.user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.role-doctor   { background: var(--color-blue-light);   color: var(--color-blue);    }
.role-nurse    { background: var(--color-purple-light);  color: var(--color-purple);  }
.role-clerk    { background: var(--color-warning-light); color: #92400E;              }
.role-admin    { background: var(--color-primary-light); color: var(--color-primary); }

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-2);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-faint);
  padding: var(--space-2) var(--space-3);
  margin-top: var(--space-2);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition);
}
#sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  text-decoration: none;
  cursor: pointer;
  position: relative;
  margin-bottom: var(--space-1);
  white-space: nowrap;
  overflow: hidden;
}

.nav-item:hover {
  background: var(--color-surface-offset);
  color: var(--color-text);
}

.nav-item.active {
  background: var(--color-primary);
  color: white;
}

.nav-item.active:hover { background: var(--color-primary-hover); }

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-label {
  flex: 1;
  transition: opacity var(--transition), max-width var(--transition);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}
#sidebar.collapsed .nav-label { opacity: 0; max-width: 0; pointer-events: none; }

.nav-badge {
  background: var(--color-error);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-1);
  transition: opacity var(--transition);
}
#sidebar.collapsed .nav-badge { opacity: 0; }

.nav-chevron {
  transition: transform var(--transition), opacity var(--transition);
}
#sidebar.collapsed .nav-chevron { opacity: 0; }
.nav-item.expanded .nav-chevron { transform: rotate(90deg); }

/* Sub-nav */
.subnav {
  overflow: hidden;
  max-height: 0;
  transition: max-height var(--transition);
}
.subnav.open { max-height: 400px; }

.subnav-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3) var(--space-2) var(--space-10);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  cursor: pointer;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
}
.subnav-item:hover { background: var(--color-surface-offset); color: var(--color-text); }
.subnav-item.active { color: var(--color-primary); font-weight: 600; }

/* Sidebar footer */
.sidebar-footer {
  padding: var(--space-3) var(--space-2);
  border-top: 1px solid var(--color-divider);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.collapse-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  width: 100%;
  text-align: left;
}
.collapse-btn:hover { background: var(--color-surface-offset); color: var(--color-text); }

.collapse-icon { transition: transform var(--transition); flex-shrink: 0; }
#sidebar.collapsed .collapse-icon { transform: rotate(180deg); }

/* ─── MAIN AREA ───────────────────────────────────────────── */
#main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ─── HEADER BAR ──────────────────────────────────────────── */
#header {
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-6);
  flex-shrink: 0;
  z-index: 50;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  flex: 1;
  min-width: 0;
}
.breadcrumb-item {
  color: var(--color-text-muted);
  white-space: nowrap;
}
.breadcrumb-item.current { color: var(--color-text); font-weight: 500; }
.breadcrumb-sep { color: var(--color-text-faint); }

/* Search bar */
.header-search {
  position: relative;
  flex: 0 0 280px;
}
.header-search-input {
  width: 100%;
  padding: var(--space-2) var(--space-4) var(--space-2) var(--space-8);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-bg);
  font-size: var(--text-sm);
  color: var(--color-text);
}
.header-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: var(--color-surface);
  box-shadow: 0 0 0 3px rgba(27,107,59,0.08);
}
.header-search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-faint);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Notification bell */
.notif-btn {
  position: relative;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
}
.notif-btn:hover { background: var(--color-surface-offset); color: var(--color-text); }
.notif-badge {
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  background: var(--color-error);
  border-radius: var(--radius-full);
  border: 2px solid var(--color-surface);
}

/* Campus badge */
.campus-badge {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  background: var(--color-primary-light);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-primary);
  white-space: nowrap;
}

/* Theme toggle */
.theme-toggle {
  padding: var(--space-2);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
}
.theme-toggle:hover { background: var(--color-surface-offset); color: var(--color-text); }

/* ─── CONTENT AREA ────────────────────────────────────────── */
#content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

/* Page layout */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: var(--space-4);
}
.page-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}
.page-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* ─── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
.card-padded { padding: var(--space-5); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-divider);
}
.card-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  font-family: var(--font-display);
}
.card-body { padding: var(--space-5); }

/* ─── STAT CARDS ──────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
  cursor: default;
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-4);
}

.stat-card-value {
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem);
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--color-text);
  line-height: 1;
  margin-bottom: var(--space-1);
}
.stat-card-label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
}
.stat-card-trend {
  font-size: var(--text-xs);
  margin-top: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.trend-up   { color: var(--color-success); }
.trend-down { color: var(--color-error);   }

/* ─── WELCOME CARD ────────────────────────────────────────── */
.welcome-card {
  background: linear-gradient(135deg, #1B6B3B 0%, #2a8f52 60%, #34a563 100%);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-8);
  margin-bottom: var(--space-6);
  color: white;
  position: relative;
  overflow: hidden;
}
.welcome-card::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -10%;
  width: 300px;
  height: 300px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
}
.welcome-card::after {
  content: '';
  position: absolute;
  bottom: -50%;
  right: 15%;
  width: 200px;
  height: 200px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
}
.welcome-card-content { position: relative; z-index: 1; }
.welcome-greeting {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.8;
  margin-bottom: var(--space-2);
}
.welcome-name {
  font-size: var(--text-lg);
  font-weight: 700;
  font-family: var(--font-display);
  margin-bottom: var(--space-1);
}
.welcome-date {
  font-size: var(--text-sm);
  opacity: 0.8;
}

/* ─── GRID LAYOUTS ────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-6); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }

/* Quick actions */
.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}
.quick-action-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  cursor: pointer;
  text-align: center;
  transition: all var(--transition);
}
.quick-action-card:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.quick-action-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-3);
  color: var(--color-primary);
  transition: background var(--transition);
}
.quick-action-card:hover .quick-action-icon { background: var(--color-primary); color: white; }
.quick-action-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

/* ─── TABLES ──────────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}

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

.data-table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

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

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr {
  cursor: pointer;
  transition: background var(--transition);
}
.data-table tbody tr:hover { background: var(--color-surface-offset); }

/* ─── BADGES / STATUS PILLS ───────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}

/* Appointment status */
.badge-scheduled  { background: var(--color-blue-light);   color: var(--color-blue);   }
.badge-in-progress{ background: var(--color-warning-light); color: #92400E;             }
.badge-completed  { background: var(--color-success-light); color: #047857;             }
.badge-cancelled  { background: var(--color-error-light);   color: var(--color-error);  }
.badge-no-show    { background: var(--color-surface-offset);color: var(--color-text-muted);}

/* Appointment type */
.badge-new          { background: var(--color-primary-light); color: var(--color-primary); }
.badge-follow-up    { background: var(--color-blue-light);    color: var(--color-blue);    }
.badge-surgery      { background: var(--color-error-light);   color: var(--color-error);   }
.badge-treatment    { background: var(--color-purple-light);  color: var(--color-purple);  }
.badge-vaccination  { background: var(--color-orange-light);  color: var(--color-orange);  }

/* Patient type */
.badge-inpatient    { background: var(--color-blue-light);    color: var(--color-blue);    }
.badge-outpatient   { background: var(--color-success-light); color: #047857;              }

/* Badge dot indicator */
.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* ─── TABS ────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: var(--space-1);
  border-bottom: 2px solid var(--color-border);
  margin-bottom: var(--space-5);
}
.tab-btn {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.tab-btn:hover { color: var(--color-text); }
.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

/* ─── FILTER CHIPS ────────────────────────────────────────── */
.filter-chips {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.chip {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  transition: all var(--transition);
}
.chip:hover  { border-color: var(--color-primary); color: var(--color-primary); }
.chip.active { border-color: var(--color-primary); background: var(--color-primary); color: white; }

/* ─── TOOLBAR ─────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}
.toolbar-left  { display: flex; align-items: center; gap: var(--space-3); flex: 1; }
.toolbar-right { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }

/* Search input */
.search-input-wrap {
  position: relative;
  flex: 1;
  max-width: 360px;
}
.search-input {
  width: 100%;
  padding: var(--space-2) var(--space-4) var(--space-2) var(--space-8);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  font-size: var(--text-sm);
}
.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(27,107,59,0.08);
}
.search-icon {
  position: absolute;
  left: var(--space-3);
  top: 50%; transform: translateY(-50%);
  color: var(--color-text-faint);
  pointer-events: none;
}

/* View toggle */
.view-toggle {
  display: flex;
  gap: var(--space-1);
  background: var(--color-surface-offset);
  padding: var(--space-1);
  border-radius: var(--radius-md);
}
.view-toggle-btn {
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
}
.view-toggle-btn.active { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-sm); }
.view-toggle-btn:hover:not(.active) { color: var(--color-text); }

/* ─── PATIENT CARDS ───────────────────────────────────────── */
.patient-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
}

.patient-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: var(--space-5);
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}
.patient-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.patient-card-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.patient-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary), #2a8f52);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.patient-info { flex: 1; min-width: 0; }
.patient-name {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  font-family: var(--font-display);
}
.patient-num {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

.patient-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: var(--text-sm);
}
.patient-meta-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
}
.patient-meta-row svg { flex-shrink: 0; }

.patient-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-divider);
}
.patient-last-visit {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

/* ─── PATIENT PROFILE ─────────────────────────────────────── */
.profile-hero {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-sm);
}
.profile-hero-inner {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}
.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary), #2a8f52);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.profile-info { flex: 1; }
.profile-name {
  font-size: var(--text-xl);
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--color-text);
  letter-spacing: -0.02em;
}
.profile-sub {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}
.profile-details-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-divider);
}
.profile-detail-item {}
.profile-detail-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-faint);
  font-weight: 600;
  margin-bottom: var(--space-1);
}
.profile-detail-value {
  font-size: var(--text-sm);
  color: var(--color-text);
  font-weight: 500;
}

/* ─── APPOINTMENT DETAIL ──────────────────────────────────── */
.appt-detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-6);
}
.appt-info-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.appt-info-title {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text);
  font-family: var(--font-display);
  margin-bottom: var(--space-4);
}
.detail-row {
  display: flex;
  align-items: center;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-divider);
  gap: var(--space-4);
}
.detail-row:last-child { border-bottom: none; }
.detail-label {
  width: 140px;
  flex-shrink: 0;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-faint);
}
.detail-value {
  font-size: var(--text-sm);
  color: var(--color-text);
  flex: 1;
}

/* ─── SCHEDULE / TIMELINE ─────────────────────────────────── */
.schedule-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.schedule-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition);
}
.schedule-item:hover { background: var(--color-surface-offset); }
.schedule-time {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  width: 60px;
  flex-shrink: 0;
  font-family: var(--font-display);
}
.schedule-bar {
  width: 4px;
  height: 40px;
  border-radius: 2px;
  flex-shrink: 0;
}
.schedule-info { flex: 1; min-width: 0; }
.schedule-patient {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}
.schedule-detail {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ─── MODAL / DIALOG ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}
.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 600px;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  transform: translateY(16px) scale(0.98);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.modal-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  font-family: var(--font-display);
}
.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  flex-shrink: 0;
}

/* Stepper in modal */
.stepper {
  display: flex;
  align-items: center;
  margin-bottom: var(--space-6);
  gap: var(--space-2);
}
.step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
}
.step-num {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  background: var(--color-surface-offset);
  color: var(--color-text-muted);
  border: 2px solid var(--color-border);
  flex-shrink: 0;
}
.step.active .step-num { background: var(--color-primary); color: white; border-color: var(--color-primary); }
.step.completed .step-num { background: var(--color-success); color: white; border-color: var(--color-success); }
.step-label { color: var(--color-text-muted); }
.step.active .step-label { color: var(--color-text); }
.step-connector { flex: 1; height: 1px; background: var(--color-border); }

/* ─── CALENDAR GRID ───────────────────────────────────────── */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.cal-day-header {
  background: var(--color-surface-2);
  padding: var(--space-2);
  text-align: center;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}
.cal-day {
  background: var(--color-surface);
  padding: var(--space-2);
  min-height: 80px;
  cursor: pointer;
  transition: background var(--transition);
}
.cal-day:hover { background: var(--color-surface-offset); }
.cal-day.other-month { opacity: 0.4; }
.cal-day.today { background: var(--color-primary-light); }
.cal-day-num {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}
.cal-day.today .cal-day-num {
  background: var(--color-primary);
  color: white;
  width: 22px; height: 22px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-dots { display: flex; gap: 2px; flex-wrap: wrap; margin-top: var(--space-1); }
.cal-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
}

/* ─── AUTOCOMPLETE DROPDOWN ───────────────────────────────── */
.autocomplete-wrap { position: relative; }
.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-height: 280px;
  overflow-y: auto;
  display: none;
}
.autocomplete-dropdown.open { display: block; }
.autocomplete-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  font-size: var(--text-sm);
  transition: background var(--transition);
}
.autocomplete-item:hover { background: var(--color-surface-offset); }
.autocomplete-empty {
  padding: var(--space-8);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* ─── TIME SLOTS ──────────────────────────────────────────── */
.time-slot-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}
.time-slot {
  padding: var(--space-2) var(--space-3);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  color: var(--color-text);
  transition: all var(--transition);
}
.time-slot:hover { border-color: var(--color-primary); color: var(--color-primary); }
.time-slot.selected { background: var(--color-primary); color: white; border-color: var(--color-primary); }
.time-slot.unavailable {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  text-decoration: line-through;
}

/* ─── MINI CALENDAR ───────────────────────────────────────── */
.mini-cal {
  font-size: var(--text-sm);
}
.mini-cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}
.mini-cal-title { font-weight: 600; color: var(--color-text); }
.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.mini-cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  cursor: pointer;
  transition: background var(--transition);
}
.mini-cal-day:hover { background: var(--color-surface-offset); }
.mini-cal-day.selected { background: var(--color-primary); color: white; }
.mini-cal-day.today { font-weight: 700; color: var(--color-primary); }
.mini-cal-day.other { color: var(--color-text-faint); }
.mini-cal-day.header { font-weight: 700; color: var(--color-text-muted); font-size: 9px; text-transform: uppercase; cursor: default; }
.mini-cal-day.header:hover { background: none; }

/* ─── DIVIDER ─────────────────────────────────────────────── */
.divider { height: 1px; background: var(--color-divider); margin: var(--space-5) 0; }

/* ─── EMPTY STATE ─────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-16) var(--space-8);
  color: var(--color-text-muted);
}
.empty-state-icon {
  width: 56px; height: 56px;
  margin-bottom: var(--space-4);
  color: var(--color-text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-state h3 { color: var(--color-text); margin-bottom: var(--space-2); font-size: var(--text-base); }
.empty-state p { max-width: 36ch; margin-bottom: var(--space-6); font-size: var(--text-sm); }

/* ─── VITALS CHART ────────────────────────────────────────── */
.vitals-chart-wrap {
  position: relative;
  width: 100%;
  height: 220px;
}

/* ─── TOAST NOTIFICATIONS ─────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-5);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 280px;
  max-width: 380px;
  pointer-events: auto;
  transform: translateY(8px);
  opacity: 0;
  transition: all var(--transition);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { border-left: 3px solid var(--color-success); }
.toast-error   { border-left: 3px solid var(--color-error); }
.toast-warning { border-left: 3px solid var(--color-warning); }
.toast-info    { border-left: 3px solid var(--color-blue); }
.toast-message { flex: 1; color: var(--color-text); }

/* ─── RESPONSIVE ──────────────────────────────────────────── */

/* Mobile menu button - hidden on desktop */
.mobile-menu-btn { display: none; }
@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .quick-actions-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .appt-detail-grid { grid-template-columns: 1fr; }
  .profile-details-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }

  #sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    width: 280px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.25s ease;
    box-shadow: none;
  }
  #sidebar.mobile-open {
    left: 0;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }
  #sidebar.collapsed { width: 280px; }
  #sidebar.collapsed .sidebar-brand,
  #sidebar.collapsed .user-info,
  #sidebar.collapsed .nav-label,
  #sidebar.collapsed .nav-section-label,
  #sidebar.collapsed .nav-badge,
  #sidebar.collapsed .nav-chevron { opacity: 1; max-width: 200px; pointer-events: auto; }

  .mobile-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 999;
  }
  .mobile-overlay.active { display: block; }

  .mobile-menu-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: 8px;
    border: 1.5px solid var(--color-border);
    background: var(--color-surface);
    cursor: pointer;
    margin-right: var(--space-3);
  }

  #main { margin-left: 0; }
  .header-search { display: none; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .patient-grid { grid-template-columns: 1fr; }
  #content { padding: var(--space-4); }
  .welcome-card { padding: var(--space-5); }
  .campus-badge { display: none; }
  .page-header { flex-wrap: wrap; }
  .toolbar { flex-wrap: wrap; }
  .time-slot-grid { grid-template-columns: repeat(3, 1fr); }
  .header-actions .btn-primary span { display: none; }
  .header-actions .btn-primary { padding: var(--space-2) var(--space-3); }
  .breadcrumb { font-size: var(--text-xs); }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .quick-actions-grid { grid-template-columns: repeat(2, 1fr); }
  .modal { border-radius: 0; max-height: 100dvh; }
  .modal-overlay { padding: 0; align-items: flex-end; }
}

/* ─── UTILITY ─────────────────────────────────────────────── */
.text-muted  { color: var(--color-text-muted); }
.text-faint  { color: var(--color-text-faint); }
.text-xs     { font-size: var(--text-xs); }
.text-sm     { font-size: var(--text-sm); }
.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2       { gap: var(--space-2); }
.gap-3       { gap: var(--space-3); }
.gap-4       { gap: var(--space-4); }
.mt-2        { margin-top: var(--space-2); }
.mt-4        { margin-top: var(--space-4); }
.mb-4        { margin-bottom: var(--space-4); }
.mb-6        { margin-bottom: var(--space-6); }
.w-full      { width: 100%; }
.hidden      { display: none !important; }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Select / dropdown */
.select-input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: var(--text-sm);
  color: var(--color-text);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
}
.select-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(27,107,59,0.08);
}

/* Textarea */
.textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: var(--text-sm);
  color: var(--color-text);
  resize: vertical;
  min-height: 80px;
}
.textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(27,107,59,0.08);
}

/* Date picker */
input[type="date"] {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  font-size: var(--text-sm);
  color: var(--color-text);
}
input[type="date"]:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(27,107,59,0.08);
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: var(--text-sm);
}
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* Recent patients list */
.recent-patient-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition);
}
.recent-patient-item:hover { background: var(--color-surface-offset); }
.recent-patient-name { font-size: var(--text-sm); font-weight: 600; color: var(--color-text); }
.recent-patient-meta { font-size: var(--text-xs); color: var(--color-text-muted); }

/* Vitals item */
.vital-item {
  background: var(--color-surface-offset);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.vital-label { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: var(--space-2); }
.vital-value { font-size: var(--text-lg); font-weight: 700; color: var(--color-text); font-family: var(--font-display); }
.vital-unit  { font-size: var(--text-xs); color: var(--color-text-muted); }

/* Print/action row */
.action-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ─── SPLASH / LOADING ────────────────────────────────────── */
#loading-splash {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  transition: opacity 0.3s ease;
}
#loading-splash.hidden { opacity: 0; pointer-events: none; }

.splash-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}
.splash-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Notification panel */
.notif-panel {
  position: fixed;
  top: var(--header-height);
  right: var(--space-4);
  width: 340px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 300;
  display: none;
}
.notif-panel.open { display: block; }
.notif-panel-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  font-size: var(--text-sm);
}
.notif-item {
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-divider);
  cursor: pointer;
  transition: background var(--transition);
}
.notif-item:hover { background: var(--color-surface-offset); }
.notif-item:last-child { border-bottom: none; }
.notif-item-title { font-size: var(--text-sm); font-weight: 500; color: var(--color-text); }
.notif-item-time  { font-size: var(--text-xs); color: var(--color-text-faint); margin-top: var(--space-1); }

/* ══════════════════════════════════════════════════════════
   FAQ REFERENCE MODULE — CliniQ+ Staff Tool
══════════════════════════════════════════════════════════ */

.faq-page {
  padding: var(--space-6);
  max-width: 960px;
  margin: 0 auto;
}

.faq-search-bar-wrap {
  margin-bottom: var(--space-5);
}

.faq-search-bar {
  position: relative;
  display: flex;
  align-items: center;
}

.faq-search-icon {
  position: absolute;
  left: 14px;
  color: var(--color-text-muted);
  pointer-events: none;
  flex-shrink: 0;
}

.faq-search-input {
  width: 100%;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 12px 16px 12px 42px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-surface);
  outline: none;
  transition: border-color 0.15s;
  box-shadow: var(--shadow-sm);
}

.faq-search-input:focus {
  border-color: var(--color-primary);
  background: var(--color-bg);
}

.faq-search-input::placeholder { color: var(--color-text-faint); }

.faq-search-count {
  position: absolute;
  right: 14px;
  font-size: 12px;
  color: var(--color-primary);
  font-weight: 600;
  font-family: var(--font-body);
  pointer-events: none;
}

.faq-category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: var(--space-5);
}

.faq-cat-pill {
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: 20px;
  padding: 5px 14px;
  font-family: var(--font-body);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.faq-cat-pill:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: #eef6ee;
}

.faq-cat-pill.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.faq-dept-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.faq-dept-card {
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.faq-dept-card:hover {
  border-color: #c8dfc8;
  box-shadow: var(--shadow-md);
}

.faq-dept-card.open {
  border-color: var(--color-primary);
}

.faq-dept-header {
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  gap: 12px;
}

.faq-dept-header-left {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.faq-dept-icon {
  width: 36px;
  height: 36px;
  background: #eef6ee;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-primary);
}

.faq-dept-icon svg {
  width: 18px;
  height: 18px;
}

.faq-dept-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.faq-dept-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.faq-dept-cat-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1px 6px;
}

.faq-dept-hours {
  font-size: 11px;
  color: var(--color-text-faint);
  display: flex;
  align-items: center;
  gap: 3px;
}

.faq-dept-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.faq-dept-q-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-primary);
  background: #eef6ee;
  border-radius: 20px;
  padding: 2px 10px;
}

.faq-dept-chevron {
  color: var(--color-text-muted);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.faq-dept-card.open .faq-dept-chevron {
  transform: rotate(180deg);
  color: var(--color-primary);
}

.faq-dept-body {
  display: none;
  border-top: 1px solid var(--color-border);
}

.faq-dept-card.open .faq-dept-body {
  display: block;
}

.faq-dept-info-bar {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: 10px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.faq-dept-info-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.5;
  max-width: 400px;
}

.faq-dept-info-item svg {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--color-primary);
}

.faq-qa-list {
  padding: 8px 0;
}

.faq-qa-item {
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  transition: background 0.12s;
}

.faq-qa-item:last-child { border-bottom: none; }
.faq-qa-item:hover { background: var(--color-bg); }
.faq-qa-item.open { background: #f0f7f0; }

.faq-qa-q {
  padding: 12px 18px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.faq-qa-num {
  min-width: 22px;
  height: 22px;
  background: var(--color-primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.faq-qa-q-text {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--color-text);
  flex: 1;
  line-height: 1.5;
}

.faq-qa-chevron {
  color: var(--color-text-muted);
  flex-shrink: 0;
  margin-top: 3px;
  transition: transform 0.2s ease;
}

.faq-qa-item.open .faq-qa-chevron {
  transform: rotate(180deg);
  color: var(--color-primary);
}

.faq-qa-a {
  display: none;
  padding: 0 18px 14px 50px;
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.7;
  white-space: pre-wrap;
}

.faq-qa-item.open .faq-qa-a {
  display: block;
}

mark.faq-highlight {
  background: rgba(224,186,91,0.35);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.faq-empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}

.faq-empty-state svg {
  display: block;
  margin: 0 auto 16px;
}

.faq-empty-state p {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-text);
}

.faq-empty-state span { font-size: 13px; }

@media (max-width: 640px) {
  .faq-page { padding: var(--space-4); }
  .faq-dept-name { font-size: 13.5px; }
}

/* ══ END FAQ MODULE CSS ══ */
