/* ================================================================
   ClinicFlow — Design System & Global Styles
   Dark theme default | Light theme override
   ================================================================ */

/* ── Reset & Box Model ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── CSS Custom Properties ─────────────────────────────────────── */
:root {
  /* Brand palette */
  --indigo-400: #818cf8;
  --indigo-500: #6366f1;
  --indigo-600: #4f46e5;
  --indigo-700: #4338ca;
  --violet-400: #a78bfa;
  --violet-500: #8b5cf6;
  --violet-600: #7c3aed;

  /* Semantic colours */
  --success:      #22c55e;
  --success-bg:   rgba(34,197,94,.12);
  --warning:      #f59e0b;
  --warning-bg:   rgba(245,158,11,.12);
  --danger:       #ef4444;
  --danger-bg:    rgba(239,68,68,.12);
  --info:         #38bdf8;
  --info-bg:      rgba(56,189,248,.12);

  /* Layout */
  --sidebar-w:     248px;
  --topbar-h:      64px;
  --mobile-hdr-h:  56px;

  /* Border radius */
  --r-xs:  4px;
  --r-sm:  8px;
  --r:     12px;
  --r-lg:  18px;
  --r-xl:  24px;
  --r-full: 999px;

  /* Transitions */
  --ease:  cubic-bezier(.4,0,.2,1);
  --dur:   220ms;
  --dur-lg: 380ms;

  /* ── Dark Theme Defaults ──────────────────────────────────────── */
  --bg:           #0a0a0f;
  --bg-secondary: #0f0f17;
  --sidebar-bg:   #0d0d14;
  --card-bg:      #111120;
  --card-bg-2:    #131325;
  --border:       rgba(255,255,255,.07);
  --border-hover: rgba(255,255,255,.13);
  --text:         #c4c4d4;
  --text-bright:  #f0f0ff;
  --text-muted:   #6b6b8a;
  --input-bg:     #16161f;
  --input-border: rgba(255,255,255,.1);
  --hover-bg:     rgba(255,255,255,.04);
  --row-hover:    rgba(99,102,241,.06);
  --shadow-card:  0 2px 20px rgba(0,0,0,.45);
  --shadow-modal: 0 24px 80px rgba(0,0,0,.7);
  --gradient-brand: linear-gradient(135deg, #6366f1, #8b5cf6);
  --gradient-subtle: linear-gradient(135deg, rgba(99,102,241,.08), rgba(139,92,246,.04));
}

/* ── Light Theme Override ─────────────────────────────────────── */
[data-theme="light"] {
  --bg:           #f4f6fb;
  --bg-secondary: #eef1f7;
  --sidebar-bg:   #ffffff;
  --card-bg:      #ffffff;
  --card-bg-2:    #f8faff;
  --border:       rgba(0,0,0,.08);
  --border-hover: rgba(0,0,0,.15);
  --text:         #374151;
  --text-bright:  #111827;
  --text-muted:   #9ca3af;
  --input-bg:     #f3f4f8;
  --input-border: rgba(0,0,0,.12);
  --hover-bg:     rgba(0,0,0,.03);
  --row-hover:    rgba(99,102,241,.05);
  --shadow-card:  0 2px 12px rgba(0,0,0,.06);
  --shadow-modal: 0 24px 80px rgba(0,0,0,.18);
  --gradient-subtle: linear-gradient(135deg, rgba(99,102,241,.05), rgba(139,92,246,.02));
}

/* ── Typography Tokens ─────────────────────────────────────────── */
html { font-size: 15px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbars ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ================================================================
   SPLASH SCREEN
   ================================================================ */
.splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  transition: opacity .5s var(--ease), transform .5s var(--ease);
}
.splash.hide {
  opacity: 0;
  pointer-events: none;
}
.splash-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-bright);
  letter-spacing: -.03em;
  animation: splashFade .6s var(--ease) both;
}
.splash-spinner {
  display: flex;
  gap: 7px;
}
.splash-spinner div {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--indigo-500);
  animation: splashDot 1.2s ease-in-out infinite;
}
.splash-spinner div:nth-child(2) { animation-delay: .2s; }
.splash-spinner div:nth-child(3) { animation-delay: .4s; }

@keyframes splashFade {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes splashDot {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40%           { transform: scale(1);  opacity: 1; }
}

/* ================================================================
   APP SHELL LAYOUT
   ================================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.app-shell[hidden] { display: none; }

/* ================================================================
   MOBILE HEADER
   ================================================================ */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--mobile-hdr-h);
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 300;
  gap: 12px;
}
.mobile-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1rem;
  color: var(--text-bright);
  letter-spacing: -.02em;
}
.mobile-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
}
.mobile-menu-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.mobile-menu-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.mobile-menu-btn.open span:nth-child(2) { opacity: 0; }
.mobile-menu-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Sidebar backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 199;
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.sidebar-backdrop.show {
  opacity: 1;
}

/* ================================================================
   SIDEBAR
   ================================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  overflow-y: auto;
  transition:
    background var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    transform var(--dur-lg) var(--ease);
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 18px 18px;
  border-bottom: 1px solid var(--border);
}
.brand-icon { flex-shrink: 0; }
.brand-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-bright);
  letter-spacing: -.03em;
  flex: 1;
}
.sidebar-close-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 2px;
  border-radius: var(--r-sm);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.sidebar-close-btn:hover { color: var(--text-bright); background: var(--hover-bg); }

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-section-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 8px 6px;
}
.nav-divider { height: 1px; background: var(--border); margin: 8px 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  position: relative;
  transition:
    background var(--dur) var(--ease),
    color var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
.nav-item:hover {
  background: var(--hover-bg);
  color: var(--text-bright);
  transform: translateX(2px);
}
.nav-item.active {
  background: rgba(99,102,241,.14);
  color: var(--indigo-400);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--gradient-brand);
  border-radius: 0 var(--r-xs) var(--r-xs) 0;
}
.nav-item-accent:not(.active) {
  color: var(--indigo-400);
}
.nav-icon {
  width: 17px; height: 17px;
  flex-shrink: 0;
  stroke-width: 1.8;
}
.nav-badge {
  margin-left: auto;
  background: var(--indigo-600);
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--r-full);
  min-width: 18px;
  text-align: center;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sidebar-footer-api {
  display: flex;
  align-items: center;
  gap: 7px;
}
.api-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--dur) var(--ease);
}
.sidebar-footer-api.online .api-dot  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.sidebar-footer-api.offline .api-dot { background: var(--danger); }
.api-label {
  font-size: .73rem;
  color: var(--text-muted);
}
.ai-disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: .7rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.ai-disclaimer svg { flex-shrink: 0; margin-top: 1px; }

/* ================================================================
   MAIN CONTENT
   ================================================================ */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--dur-lg) var(--ease);
}

/* ── Topbar ──────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0; z-index: 100;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  gap: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}
.page-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-bright);
  letter-spacing: -.025em;
}
.breadcrumb {
  font-size: .78rem;
  color: var(--text-muted);
}
.topbar-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .73rem;
  color: var(--text-muted);
  padding: 5px 10px;
  background: var(--input-bg);
  border-radius: var(--r-full);
  border: 1px solid var(--border);
}
.topbar-status.online .status-dot  { background: var(--success); box-shadow: 0 0 5px var(--success); }
.topbar-status.offline .status-dot { background: var(--danger); }
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--dur) var(--ease);
}
.topbar-time {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Theme toggle button */
.theme-toggle-btn {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--input-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition:
    color var(--dur) var(--ease),
    background var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
.theme-toggle-btn:hover {
  color: var(--indigo-400);
  border-color: var(--indigo-500);
  background: rgba(99,102,241,.08);
  transform: rotate(20deg);
}

/* ── View Container ──────────────────────────────────────────────── */
.view-container {
  flex: 1;
  padding: 28px;
  animation: viewIn .35s var(--ease) both;
}
@keyframes viewIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── View Loading ────────────────────────────────────────────────── */
.view-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
}
.dot-loader {
  display: flex;
  gap: 8px;
}
.dot-loader span {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--indigo-500);
  animation: dotBounce 1.2s ease-in-out infinite;
}
.dot-loader span:nth-child(2) { animation-delay: .2s; }
.dot-loader span:nth-child(3) { animation-delay: .4s; }
@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40%           { transform: scale(1);  opacity: 1; }
}

/* ================================================================
   CARDS
   ================================================================ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition:
    background var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
.card:hover { box-shadow: var(--shadow-card), 0 0 0 1px var(--border-hover); }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: -.02em;
}
.card-subtitle {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── Stat Cards ───────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
  cursor: default;
  transition:
    transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 32px rgba(0,0,0,.3); }
.stat-card.indigo::before { background: var(--gradient-brand); }
.stat-card.violet::before { background: linear-gradient(90deg, var(--violet-500), var(--violet-400)); }
.stat-card.warning::before { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.stat-card.success::before { background: linear-gradient(90deg, var(--success), #4ade80); }

.stat-icon {
  width: 38px; height: 38px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.stat-card.indigo .stat-icon { background: rgba(99,102,241,.15); color: var(--indigo-400); }
.stat-card.violet .stat-icon { background: rgba(139,92,246,.15); color: var(--violet-400); }
.stat-card.warning .stat-icon { background: rgba(245,158,11,.15); color: var(--warning); }
.stat-card.success .stat-icon { background: rgba(34,197,94,.15); color: var(--success); }

.stat-value {
  font-size: 2.1rem;
  font-weight: 900;
  color: var(--text-bright);
  letter-spacing: -.04em;
  line-height: 1;
}
.stat-label {
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Dashboard bottom grid ────────────────────────────────────────── */
.dash-bottom {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

/* ================================================================
   TABLES
   ================================================================ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-sm);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .855rem;
}
thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  background: var(--input-bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--dur) var(--ease);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--row-hover); }
tbody td {
  padding: 11px 14px;
  color: var(--text);
  vertical-align: middle;
}
.td-name { font-weight: 600; color: var(--text-bright); }

/* ================================================================
   BADGES
   ================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--r-full);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-requested    { background: rgba(56,189,248,.15); color: var(--info); }
.badge-confirmed    { background: var(--success-bg); color: var(--success); }
.badge-checked_in   { background: rgba(99,102,241,.15); color: var(--indigo-400); }
.badge-completed    { background: rgba(34,197,94,.2); color: #4ade80; }
.badge-cancelled    { background: var(--danger-bg); color: var(--danger); }
.badge-no_show      { background: rgba(245,158,11,.12); color: var(--warning); }
.badge-draft        { background: var(--hover-bg); color: var(--text-muted); border: 1px solid var(--border); }
.badge-approved     { background: var(--success-bg); color: var(--success); }
.badge-sent         { background: rgba(99,102,241,.12); color: var(--indigo-400); }
.badge-ai           { background: rgba(139,92,246,.15); color: var(--violet-400); }
.badge-urgent       { background: var(--danger-bg); color: var(--danger); animation: pulseBadge 1.5s ease-in-out infinite; }

@keyframes pulseBadge {
  0%, 100% { opacity: 1; }
  50%       { opacity: .65; }
}

/* ================================================================
   SECTION HEADER + FILTER BAR
   ================================================================ */
.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.section-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-bright);
  letter-spacing: -.03em;
}
.section-subtitle {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 3px;
}
.filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-input-wrap {
  flex: 1;
  min-width: 200px;
  position: relative;
}
.search-input-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-input-wrap input {
  width: 100%;
  padding: 9px 12px 9px 36px;
}

/* ================================================================
   FORMS
   ================================================================ */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text);
}
.required { color: var(--danger); margin-left: 2px; }

.form-input,
.form-select,
.form-textarea,
input[type="text"],
input[type="email"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 9px 13px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--r-sm);
  color: var(--text-bright);
  font-family: inherit;
  font-size: .875rem;
  outline: none;
  transition:
    border-color var(--dur) var(--ease),
    background var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--indigo-500);
  box-shadow: 0 0 0 3px rgba(99,102,241,.18);
}
.filter-select,
select.filter-select {
  padding: 9px 13px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: inherit;
  font-size: .85rem;
  outline: none;
  cursor: pointer;
}
textarea { resize: vertical; line-height: 1.6; }

.checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.checkbox-group input[type="checkbox"] {
  width: 16px;
  min-width: 16px;
  height: 16px;
  margin-top: 1px;
  accent-color: var(--indigo-500);
  cursor: pointer;
}
.checkbox-label {
  font-size: .82rem;
  color: var(--text);
  cursor: pointer;
  line-height: 1.55;
}

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition:
    background var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    color var(--dur) var(--ease),
    transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--gradient-brand);
  color: #fff;
  box-shadow: 0 2px 12px rgba(99,102,241,.35);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 20px rgba(99,102,241,.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--input-bg);
  border-color: var(--border);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--hover-bg);
  border-color: var(--border-hover);
  color: var(--text-bright);
}

.btn-success {
  background: var(--success-bg);
  border-color: rgba(34,197,94,.3);
  color: var(--success);
}
.btn-success:hover:not(:disabled) { background: rgba(34,197,94,.2); }

.btn-danger {
  background: var(--danger-bg);
  border-color: rgba(239,68,68,.3);
  color: var(--danger);
}

.btn-sm  { padding: 6px 13px; font-size: .82rem; }
.btn-xs  { padding: 4px 10px; font-size: .75rem; }
.btn-lg  { padding: 12px 24px; font-size: 1rem; }
.w-full  { width: 100%; }
.mt-12   { margin-top: 12px; }
.mt-16   { margin-top: 16px; }
.mt-24   { margin-top: 24px; }
.mb-16   { margin-bottom: 16px; }
.gap-10  { gap: 10px; }
.text-sm { font-size: .82rem; }
.text-xs { font-size: .74rem; }
.text-muted { color: var(--text-muted); }

/* ================================================================
   MODAL
   ================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 580px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  transform: scale(.94) translateY(10px);
  transition: transform var(--dur) var(--ease);
  overflow: hidden;
}
.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title {
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--text-bright);
}
.modal-close {
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--input-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--dur) var(--ease);
}
.modal-close:hover { color: var(--danger); border-color: var(--danger); }
.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ================================================================
   DETAIL ROWS (in modals)
   ================================================================ */
.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: .875rem;
}
.detail-row:last-child { border-bottom: none; }
.detail-key {
  font-weight: 600;
  color: var(--text-muted);
  min-width: 110px;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  padding-top: 1px;
}
.detail-val {
  color: var(--text);
  flex: 1;
  line-height: 1.5;
}

/* ================================================================
   AI BLOCK
   ================================================================ */
.ai-block {
  background: var(--gradient-subtle);
  border: 1px solid rgba(99,102,241,.2);
  border-radius: var(--r);
  overflow: hidden;
}
.ai-block-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(99,102,241,.08);
  border-bottom: 1px solid rgba(99,102,241,.15);
}
.ai-block-label {
  font-size: .78rem;
  font-weight: 700;
  color: var(--indigo-400);
  flex: 1;
}
.ai-block-disclaimer {
  font-size: .68rem;
  color: var(--warning);
  font-weight: 600;
}
.ai-block-content {
  padding: 12px 14px;
  font-size: .85rem;
  color: var(--text);
  line-height: 1.65;
}

/* ================================================================
   URGENT BANNER
   ================================================================ */
.urgent-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: var(--r-sm);
  color: var(--danger);
  font-size: .82rem;
  font-weight: 700;
  animation: urgentPulse 2s ease-in-out infinite;
}
@keyframes urgentPulse {
  0%, 100% { border-color: rgba(239,68,68,.3); }
  50%       { border-color: rgba(239,68,68,.7); }
}

/* ================================================================
   PROGRESS BAR
   ================================================================ */
.progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.progress-bar {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: var(--r-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--r-full);
  transition: width .6s var(--ease);
}
.progress-fill.high   { background: var(--success); }
.progress-fill.medium { background: var(--warning); }
.progress-fill.low    { background: var(--danger); }
.progress-pct {
  font-size: .72rem;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 32px;
  text-align: right;
}

/* ================================================================
   EMPTY STATE
   ================================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 24px;
  text-align: center;
}
.empty-state-icon { font-size: 2.5rem; }
.empty-state-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-bright);
}
.empty-state-desc { font-size: .85rem; color: var(--text-muted); max-width: 360px; line-height: 1.6; }

/* ================================================================
   TOASTS
   ================================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 360px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--card-bg);
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-bright);
  animation: toastIn .3s var(--ease) both;
  backdrop-filter: blur(12px);
}
.toast .toast-icon {
  width: 22px; height: 22px;
  border-radius: var(--r-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  flex-shrink: 0;
  font-weight: 900;
}
.toast.success .toast-icon { background: var(--success-bg); color: var(--success); }
.toast.error   .toast-icon { background: var(--danger-bg);  color: var(--danger); }
.toast.info    .toast-icon { background: var(--info-bg);    color: var(--info); }
.toast.warning .toast-icon { background: var(--warning-bg); color: var(--warning); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ================================================================
   BOOK APPOINTMENT FORM (Patient Portal)
   ================================================================ */
.book-wrapper {
  max-width: 720px;
  margin: 0 auto;
}
.book-section-title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text-bright);
  margin: 24px 0 12px;
  padding-left: 10px;
  border-left: 3px solid var(--indigo-500);
}
.book-info-banner {
  font-size: .82rem;
  color: var(--text-muted);
  padding: 12px 15px;
  background: var(--input-bg);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  line-height: 1.6;
  margin-bottom: 8px;
}
.book-success-wrap {
  max-width: 520px;
  margin: 48px auto;
  text-align: center;
  animation: viewIn .4s var(--ease) both;
}
.book-success-icon { font-size: 3.8rem; margin-bottom: 16px; }
.book-success-title {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text-bright);
  letter-spacing: -.03em;
  margin-bottom: 10px;
}
.book-success-desc { color: var(--text-muted); line-height: 1.6; margin-bottom: 24px; }

/* ================================================================
   ACTIVITY FEED (Dashboard)
   ================================================================ */
.activity-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  background: var(--input-bg);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  transition: border-color var(--dur) var(--ease);
}
.activity-item:hover { border-color: var(--border-hover); }
.activity-status {
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-bright);
}
.activity-meta { font-size: .72rem; color: var(--text-muted); }

/* ================================================================
   RESPONSIVE — MOBILE
   ================================================================ */
@media (max-width: 768px) {
  .mobile-header {
    display: flex;
  }
  .sidebar-backdrop {
    display: block;
  }
  .sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
    top: 0;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0,0,0,.4);
  }
  .sidebar-close-btn { display: flex; }
  .main-content {
    margin-left: 0;
    padding-top: var(--mobile-hdr-h);
  }
  .topbar { display: none; }
  .view-container { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dash-bottom { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
  .search-input-wrap { min-width: 100%; }
  .toast-container { left: 16px; right: 16px; bottom: 16px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.8rem; }
}
