/* ═══════════════════════════════════════════════════════════════════════════
   Clinical SaaS Management System — Design System v10.0 (2026 Edition)
   Modern Clinical Slate & Iris · Refined Typography · High Ergonomics
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1. Color Palette & Design Tokens (SaaS 2026 Standards) ──────────────── */
:root {
  /* Brand Core: Deep Medical Slate & Iris */
  --primary:            #0D5276;
  --primary-hover:      #093C57;
  --primary-active:     #062B3F;
  --primary-light:      #F0F7FA;
  --primary-subtle:     #E0EFF5;
  --primary-gradient:   linear-gradient(135deg, #0D5276 0%, #166B99 100%);
  --primary-glow:       0 4px 12px rgba(13, 82, 118, 0.18);
  --primary-focus:      rgba(13, 82, 118, 0.12);

  /* Modern Semantic Palette */
  --success:            #059669;
  --success-hover:      #047857;
  --success-light:      #ECFDF5;
  --success-subtle:     #D1FAE5;
  --success-gradient:   linear-gradient(135deg, #059669 0%, #10B981 100%);
  --success-glow:       0 4px 12px rgba(5, 150, 105, 0.18);

  --danger:             #DC2626;
  --danger-hover:       #B91C1C;
  --danger-light:       #FEF2F2;
  --danger-subtle:     #FEE2E2;
  --danger-gradient:    linear-gradient(135deg, #DC2626 0%, #EF4444 100%);
  --danger-glow:        0 4px 12px rgba(220, 38, 38, 0.18);

  --warning:            #D97706;
  --warning-hover:      #B45309;
  --warning-light:      #FFFBEB;
  --warning-subtle:     #FEF3C7;
  --warning-gradient:   linear-gradient(135deg, #D97706 0%, #F59E0B 100%);
  --warning-glow:       0 4px 12px rgba(217, 119, 6, 0.18);

  --info:               #0284C7;
  --info-hover:         #0369A1;
  --info-light:         #F0F9FF;
  --info-subtle:        #E0F2FE;
  --info-gradient:      linear-gradient(135deg, #0284C7 0%, #38BDF8 100%);
  --info-glow:          0 4px 12px rgba(2, 132, 199, 0.18);

  --violet:             #6366F1;
  --violet-light:       #EEF2FF;
  --violet-gradient:    linear-gradient(135deg, #6366F1 0%, #818CF8 100%);
  --violet-glow:        0 4px 12px rgba(99, 102, 241, 0.18);

  --secondary:          #334E68;
  --secondary-light:    #F1F5F9;

  /* Refined Modern Sidebar Theme (Deep Slate Obsidian) */
  --sidebar-bg:         #0F172A;
  --sidebar-card:       rgba(255, 255, 255, 0.04);
  --sidebar-card-hover: rgba(255, 255, 255, 0.08);
  --sidebar-border:     rgba(255, 255, 255, 0.07);
  --sidebar-text:       #E2E8F0;

  /* Surfaces & Clean Borders */
  --body-bg:            #F8FAFC;
  --body-mesh:          none;
  --card-bg:            #FFFFFF;
  --surface-muted:      #F1F5F9;
  --border-color:       #E2E8F0;
  --border-strong:      #CBD5E1;
  --text-main:          #0F172A;
  --text-secondary:     #475569;
  --text-muted:         #64748B;
  --text-light:         #94A3B8;

  /* Dimensions & Radius */
  --sidebar-w:          268px;
  --navbar-h:           64px;
  --radius-xs:          6px;
  --radius-sm:          8px;
  --radius-md:          12px;
  --radius-lg:          14px;
  --radius-xl:          18px;

  /* Subtle Crisp Elevation Shadows */
  --shadow-xs:          0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm:          0 1px 3px rgba(15, 23, 42, 0.05), 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-md:          0 4px 12px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
  --shadow-lg:          0 12px 28px -6px rgba(15, 23, 42, 0.08), 0 4px 10px -2px rgba(15, 23, 42, 0.04);

  /* Precise Smooth Transitions */
  --transition-fast:    120ms ease;
  --transition:         180ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth:  200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── 2. Base & Typography ───────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
textarea,
[contenteditable="true"] {
  caret-color: var(--primary) !important;
  -webkit-user-select: text !important;
  user-select: text !important;
  cursor: text;
}

.sidebar,
.top-navbar,
.btn,
.badge,
.nav-link,
.stat-card,
.content-card-header,
.modal-header,
.modal-footer,
.dropdown-menu,
.page-hero,
th,
label {
  -webkit-user-select: none;
  user-select: none;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'IBM Plex Sans Arabic', 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--body-bg);
  background-image: none;
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  overflow-x: hidden;
}

html[dir="rtl"] body { direction: rtl; text-align: right; }
html[dir="ltr"] body { direction: ltr; text-align: left; }

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
  color: var(--text-main);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

h3, .h3 {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: none !important;
  -webkit-text-fill-color: initial !important;
}

h3 i, .h3 i {
  color: var(--primary);
  font-size: 1.25rem;
}

.stat-number,
.font-monospace,
code,
input[type="number"],
input[type="date"],
input[type="time"],
input[type="tel"],
[dir="ltr"] {
  font-variant-numeric: tabular-nums;
}

code {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: 0.85em;
  color: #1E40AF;
  background: #EFF6FF;
  border: 1px solid #DBEAFE;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-weight: 500;
}

a, button, .btn, [role="button"], label[for],
select, .form-select, .form-check-input, .form-check-label,
summary, [onclick], [tabindex]:not([tabindex="-1"]) {
  cursor: pointer;
}

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

a:hover {
  color: var(--primary-hover);
}

/* ── 3. App Shell Layout ────────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
  background-color: var(--body-bg);
}

/* ── 4. Refined Modern Sidebar ──────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  border-inline-end: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 1030;
  transition: transform var(--transition-smooth), width var(--transition-smooth);
}

.sidebar-header {
  height: var(--navbar-h);
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
  background: transparent;
}

.sidebar-brand-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.sidebar-brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary-gradient);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(13, 82, 118, 0.35);
}

.sidebar-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.sidebar .sidebar-brand:hover {
  color: #93C5FD;
}

.top-navbar .sidebar-brand {
  color: var(--primary);
}

.sidebar-nav {
  list-style: none;
  padding: 1rem 0.75rem;
  margin: 0;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sidebar-nav .nav-item {
  margin-bottom: 0;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  color: #94A3B8;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.92rem;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.sidebar-nav .nav-link i {
  font-size: 1.15rem;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.sidebar-nav .nav-link:hover {
  background: var(--sidebar-card-hover);
  color: #FFFFFF;
}

.sidebar-nav .nav-link:hover i {
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF !important;
}

.sidebar-nav .nav-link.active {
  background: var(--primary);
  color: #FFFFFF !important;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(13, 82, 118, 0.35);
}

.sidebar-nav .nav-link.active i,
.sidebar-nav .nav-link.active span {
  color: #FFFFFF !important;
}

.sidebar-nav .nav-link.active i {
  background: rgba(255, 255, 255, 0.2);
}

.sidebar-footer {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--sidebar-border);
  background: rgba(15, 23, 42, 0.4);
  flex-shrink: 0;
}

.sidebar-footer .text-muted {
  color: #64748B !important;
}

.sidebar-footer .btn-outline-danger {
  color: #F87171;
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.05);
  font-size: 0.82rem;
}

.sidebar-footer .btn-outline-danger:hover {
  background: var(--danger);
  color: #FFFFFF;
  border-color: transparent;
}

/* Sidebar Switcher & Collapsible Rail Controls */
.sidebar-switcher-select {
  background-color: rgba(255, 255, 255, 0.08) !important;
  color: #F8FAFC !important;
  border: 1px solid rgba(255, 255, 255, 0.16) !important;
  font-size: 0.84rem;
  border-radius: 8px;
  cursor: pointer;
}

.sidebar-switcher-select option {
  background-color: #0F172A;
  color: #F8FAFC;
}

.sidebar-toggle-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  flex-shrink: 0;
  color: #CBD5E1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  transition: all 0.2s ease;
}

.sidebar-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #FFFFFF;
}

/* Collapsed Icon-Only Sidebar State (Desktop >= 992px) */
@media (min-width: 992px) {
  .sidebar.collapsed {
    width: 72px !important;
    overflow-x: hidden;
  }

  .sidebar.collapsed .sidebar-header {
    padding: 0 0.75rem;
    justify-content: center;
  }

  .sidebar.collapsed .sidebar-switcher-area,
  .sidebar.collapsed .sidebar-mode-indicator,
  .sidebar.collapsed .sidebar-label {
    display: none !important;
  }

  .sidebar.collapsed .sidebar-nav {
    padding: 0.85rem 0.5rem;
    align-items: center;
  }

  .sidebar.collapsed .sidebar-nav .nav-item {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .sidebar.collapsed .sidebar-nav .nav-link {
    justify-content: center;
    padding: 0.6rem;
    width: 48px;
    height: 44px;
  }
}

/* Mobile Sidebar Backdrop */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  z-index: 1025;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-smooth), visibility var(--transition-smooth);
}

.sidebar-backdrop.show {
  opacity: 1;
  visibility: visible;
}

/* ── 5. Clean Top Navbar ────────────────────────────────────────────────── */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  background-color: var(--body-bg);
}

.top-navbar {
  background: #FFFFFF;
  border-bottom: 1px solid var(--border-color);
  padding: 0 1.5rem;
  height: var(--navbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 1010;
  box-shadow: var(--shadow-xs);
}

.top-navbar::after {
  content: none;
}

/* Super Admin Header Bar */
.top-navbar.top-navbar-admin {
  background: #0F172A;
  color: #FFFFFF;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow-sm);
}

.top-navbar.top-navbar-admin .sidebar-brand {
  color: #FFFFFF !important;
}

.top-navbar.top-navbar-admin #userMenuDropdown {
  color: #FFFFFF !important;
}

.top-navbar.top-navbar-admin #userMenuDropdown small.text-muted {
  color: #93C5FD !important;
}

.top-navbar.top-navbar-admin #langToggleBtn {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
}

.top-navbar.top-navbar-admin #langToggleBtn i {
  color: #93C5FD !important;
}

/* Clean Page Hero Banner */
.page-hero,
.page-container > .d-flex.justify-content-between {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.35rem;
  box-shadow: var(--shadow-xs);
  margin-bottom: 1.25rem;
}

.mobile-nav-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #FFFFFF;
  color: var(--text-main);
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  padding: 0;
  transition: all var(--transition-fast);
}

.mobile-nav-toggle:hover {
  background: var(--surface-muted);
  color: var(--primary);
}

.page-container {
  padding: 1.5rem 1.75rem;
  flex-grow: 1;
  width: 100%;
  max-width: 100%;
  margin: 0;
}

@media (min-width: 1600px) {
  .page-container {
    max-width: 1650px;
    margin: 0 auto;
    padding: 2rem 2.5rem;
  }
}

@media (max-width: 767.98px) {
  .page-container {
    padding: 1rem 0.75rem;
  }
}

/* ── 6. Clean KPI Stat Cards (2026 SaaS Minimalist) ─────────────────────── */
.stat-card {
  background: #FFFFFF;
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  height: 100%;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  display: none !important;
}

.stat-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  background: var(--primary-light) !important;
  color: var(--primary) !important;
}

/* Subtle Semantic Accents for Stat Icons */
.stat-card:has(.text-primary) .stat-icon,
.stat-card:has(.bg-primary) .stat-icon {
  background: var(--primary-light) !important;
  color: var(--primary) !important;
}

.stat-card:has(.text-success) .stat-icon,
.stat-card:has(.bg-success) .stat-icon {
  background: var(--success-light) !important;
  color: var(--success) !important;
}

.stat-card:has(.text-warning) .stat-icon,
.stat-card:has(.bg-warning) .stat-icon {
  background: var(--warning-light) !important;
  color: var(--warning) !important;
}

.stat-card:has(.text-danger) .stat-icon,
.stat-card:has(.bg-danger) .stat-icon {
  background: var(--danger-light) !important;
  color: var(--danger) !important;
}

.stat-card:has(.text-info) .stat-icon,
.stat-card:has(.bg-info) .stat-icon {
  background: var(--info-light) !important;
  color: var(--info) !important;
}

.stat-number {
  font-size: 1.65rem;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 0.2rem;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.stat-label,
.stat-card .text-muted.small {
  font-size: 0.84rem;
  color: var(--text-secondary) !important;
  font-weight: 500;
}

/* ── 7. Content Cards & Containers ──────────────────────────────────────── */
.content-card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-xs);
  margin-bottom: 1.25rem;
  overflow: visible;
  position: relative;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.content-card:hover {
  border-color: var(--border-strong);
}

.content-card-header {
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.65rem;
  background: #FFFFFF;
  position: relative;
}

.content-card-header::before {
  display: none !important;
}

.content-card-body {
  padding: 1.25rem;
}

/* ── 8. High-Legibility Clinical Data Tables ────────────────────────────── */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-responsive::-webkit-scrollbar {
  height: 6px;
}

.table-responsive::-webkit-scrollbar-track {
  background: #F1F5F9;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 4px;
}

.table {
  font-size: 0.91rem;
  margin-bottom: 0;
  border-collapse: collapse;
  width: 100%;
}

.table thead th,
.table th {
  font-weight: 600;
  font-size: 0.8rem;
  color: #475569 !important;
  background: #F8FAFC !important;
  border-bottom: 1px solid var(--border-color) !important;
  padding: 0.8rem 1rem;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.table tbody td,
.table td {
  padding: 0.8rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid #F1F5F9;
  color: var(--text-main);
  background-color: #FFFFFF;
  transition: background-color var(--transition-fast);
}

.table tbody tr:nth-child(even) > td {
  background-color: #FFFFFF;
}

.table-hover > tbody > tr:hover > * {
  background-color: #F8FAFC !important;
  color: var(--text-main);
}

html[dir="rtl"] .table-hover > tbody > tr:hover > td:first-child,
html[dir="ltr"] .table-hover > tbody > tr:hover > td:first-child {
  box-shadow: none !important;
}

.table tfoot td,
.table tfoot th {
  background: #F8FAFC !important;
  border-top: 1px solid var(--border-color) !important;
  padding: 0.8rem 1rem;
  font-weight: 600;
}

.table td:last-child .btn-group,
.table td:last-child .d-inline-flex {
  flex-wrap: nowrap;
  white-space: nowrap;
  gap: 0.35rem;
}

/* ── 9. Forms & Input Fields ────────────────────────────────────────────── */
.form-label {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
  color: var(--text-main);
}

.form-control,
.form-select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  padding: 0.55rem 0.85rem;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--text-main);
  background-color: #FFFFFF;
  box-shadow: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:hover:not(:disabled):not([readonly]),
.form-select:hover:not(:disabled) {
  border-color: var(--border-strong);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-focus);
  background-color: #FFFFFF;
  outline: none;
}

.form-control-sm,
.form-select-sm {
  padding: 0.38rem 0.7rem;
  font-size: 0.84rem;
  border-radius: var(--radius-xs);
}

.input-group-text {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #F8FAFC;
  color: var(--text-muted);
}

/* ── 10. Refined Tactile Buttons (No Table Row Shaking) ──────────────────── */
.btn {
  font-family: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  border-radius: var(--radius-sm);
  padding: 0.48rem 0.95rem;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  box-shadow: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: #FFFFFF !important;
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: #FFFFFF !important;
  transform: none !important;
}

.btn-success {
  background: var(--success);
  border: 1px solid var(--success);
  color: #FFFFFF !important;
}

.btn-success:hover,
.btn-success:focus {
  background: var(--success-hover);
  border-color: var(--success-hover);
  color: #FFFFFF !important;
  transform: none !important;
}

.btn-danger {
  background: var(--danger);
  border: 1px solid var(--danger);
  color: #FFFFFF !important;
}

.btn-danger:hover,
.btn-danger:focus {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  color: #FFFFFF !important;
  transform: none !important;
}

.btn-warning {
  background: var(--warning);
  border: 1px solid var(--warning);
  color: #FFFFFF !important;
}

.btn-warning:hover,
.btn-warning:focus {
  background: var(--warning-hover);
  border-color: var(--warning-hover);
  color: #FFFFFF !important;
  transform: none !important;
}

.btn-info {
  background: var(--info);
  border: 1px solid var(--info);
  color: #FFFFFF !important;
}

.btn-info:hover,
.btn-info:focus {
  background: var(--info-hover);
  border-color: var(--info-hover);
  color: #FFFFFF !important;
  transform: none !important;
}

.btn-outline-primary {
  color: var(--primary);
  border: 1px solid var(--border-color);
  background-color: #FFFFFF;
}

.btn-outline-primary:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary) !important;
  transform: none !important;
}

.btn-outline-success {
  color: var(--success);
  border: 1px solid var(--border-color);
  background-color: #FFFFFF;
}

.btn-outline-success:hover {
  background: var(--success-light);
  border-color: var(--success);
  color: var(--success) !important;
  transform: none !important;
}

.btn-outline-danger {
  color: var(--danger);
  border: 1px solid var(--border-color);
  background-color: #FFFFFF;
}

.btn-outline-danger:hover {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger) !important;
  transform: none !important;
}

.btn-outline-warning {
  color: var(--warning);
  border: 1px solid var(--border-color);
  background-color: #FFFFFF;
}

.btn-outline-warning:hover {
  background: var(--warning-light);
  border-color: var(--warning);
  color: var(--warning) !important;
  transform: none !important;
}

.btn-outline-info {
  color: var(--info);
  border: 1px solid var(--border-color);
  background-color: #FFFFFF;
}

.btn-outline-info:hover {
  background: var(--info-light);
  border-color: var(--info);
  color: var(--info) !important;
  transform: none !important;
}

.btn-outline-secondary {
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  background-color: #FFFFFF;
}

.btn-outline-secondary:hover {
  background-color: var(--surface-muted);
  color: var(--text-main) !important;
  border-color: var(--border-strong);
  transform: none !important;
}

.btn-sm {
  font-size: 0.82rem;
  padding: 0.32rem 0.65rem;
  border-radius: var(--radius-xs);
  gap: 0.28rem;
}

/* ── 11. Modern Pill Badges & Progress ───────────────────────────────────── */
.badge {
  font-weight: 600;
  font-size: 0.77rem;
  padding: 0.3em 0.7em;
  border-radius: 9999px;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  box-shadow: none;
}

.badge-status-scheduled  { background: #EFF6FF; color: #1D4ED8; border: 1px solid #DBEAFE; }
.badge-status-arrived    { background: #F0F9FF; color: #0284C7; border: 1px solid #E0F2FE; }
.badge-status-waiting    { background: #FFFBEB; color: #B45309; border: 1px solid #FEF3C7; }
.badge-status-in_session { background: #ECFDF5; color: #059669; border: 1px solid #D1FAE5; }
.badge-status-completed  { background: #F0FDF4; color: #15803D; border: 1px solid #DCFCE7; }
.badge-status-cancelled  { background: #F8FAFC; color: #64748B; border: 1px solid #E2E8F0; }
.badge-status-no_show    { background: #FEF2F2; color: #DC2626; border: 1px solid #FEE2E2; }

.progress {
  background-color: #E2E8F0;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: none;
  height: 6px;
}

.progress-bar {
  border-radius: 999px;
  transition: width 0.6s ease;
}

.progress-bar.bg-success { background: var(--success) !important; }
.progress-bar.bg-primary { background: var(--primary) !important; }
.progress-bar.bg-danger  { background: var(--danger) !important; }
.progress-bar.bg-info    { background: var(--info) !important; }
.progress-bar.bg-warning { background: var(--warning) !important; }

/* ── 12. Modals & Alerts ────────────────────────────────────────────────── */
.modal-content {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  padding: 1rem 1.35rem;
  border-bottom: 1px solid var(--border-color);
  background: #FFFFFF;
}

.modal-header.bg-primary {
  background: var(--primary) !important;
  color: #FFFFFF;
  border-bottom: none;
}

.modal-header.bg-danger {
  background: var(--danger) !important;
  color: #FFFFFF;
  border-bottom: none;
}

.modal-body {
  padding: 1.35rem;
}

.modal-footer {
  padding: 0.9rem 1.35rem;
  border-top: 1px solid var(--border-color);
  background-color: #F8FAFC;
}

.alert {
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
  border-inline-start-width: 4px;
  padding: 0.85rem 1.15rem;
  box-shadow: var(--shadow-xs);
}

.alert-success { background: #ECFDF5; color: #065F46; border-color: #A7F3D0; border-inline-start-color: var(--success); }
.alert-danger  { background: #FEF2F2; color: #991B1B; border-color: #FECACA; border-inline-start-color: var(--danger); }
.alert-warning { background: #FFFBEB; color: #92400E; border-color: #FDE68A; border-inline-start-color: var(--warning); }
.alert-info    { background: #F0F9FF; color: #075985; border-color: #BAE6FD; border-inline-start-color: var(--info); }

/* ── 13. Tabs, Pills & Subscriber Cards ─────────────────────────────────── */
.nav-pills .nav-link {
  color: var(--text-secondary);
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 0.5rem 1.1rem;
  transition: all var(--transition-fast);
}

.nav-pills .nav-link:hover:not(.active) {
  background-color: var(--surface-muted);
  color: var(--text-main);
}

.nav-pills .nav-link.active {
  background: var(--primary) !important;
  color: #FFFFFF !important;
  box-shadow: var(--shadow-xs);
}

.subscriber-card {
  background: #FFFFFF;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-md) !important;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast) !important;
}

.subscriber-card:hover {
  transform: none !important;
  box-shadow: var(--shadow-sm) !important;
  border-color: var(--primary) !important;
}

/* ── 14. Modern Auth Login Portal ───────────────────────────────────────── */
.auth-page-wrapper {
  min-height: calc(100vh - 4rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 0.75rem;
  background-color: var(--body-bg);
}

.auth-card {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: box-shadow var(--transition-smooth);
}

.auth-card:hover {
  box-shadow: var(--shadow-lg);
}

.empty-state {
  padding: 3.5rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
}

.empty-state .bi {
  font-size: 2.8rem;
  color: var(--text-light);
  display: block;
  margin-bottom: 0.75rem;
}

/* ── 15. Bilingual LTR Overrides ────────────────────────────────────────── */
html[dir="ltr"] .ms-auto { margin-left: auto !important; margin-right: 0 !important; }
html[dir="ltr"] .me-auto { margin-right: auto !important; margin-left: 0 !important; }
html[dir="ltr"] .text-start { text-align: left !important; }
html[dir="ltr"] .text-end { text-align: right !important; }
html[dir="ltr"] .dropdown-menu-end { --bs-position: end; right: 0; left: auto; }
html[dir="ltr"] .bi-arrow-right::before { content: "\f12f"; }
html[dir="ltr"] .bi-chevron-left::before { content: "\f285"; }

/* ── 16. Responsive Breakpoints ─────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .mobile-nav-toggle {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    width: var(--sidebar-w);
    transform: translateX(100%);
    box-shadow: var(--shadow-lg);
  }

  html[dir="ltr"] .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0) !important;
  }

  .page-container {
    padding: 1.25rem 1rem;
  }
}

@media (max-width: 767.98px) {
  html {
    font-size: 14.5px;
  }

  .top-navbar {
    padding: 0 1rem;
    height: 58px;
  }

  .page-container {
    padding: 1rem 0.75rem;
  }

  .content-card-header,
  .content-card-body {
    padding: 1rem;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-number {
    font-size: 1.4rem;
  }

  .stat-icon {
    width: 38px;
    height: 38px;
    font-size: 1.15rem;
  }

  .table thead th,
  .table tbody td {
    padding: 0.65rem 0.75rem;
    font-size: 0.85rem;
  }
}

/* ── 16b. Universal Smart Table Column-Header Filters ───────────────────── */
.st-filter-th {
  vertical-align: middle;
}
.st-hdr-trigger {
  font-size: inherit;
  line-height: 1.3;
  transition: color 0.15s ease;
}
.st-hdr-trigger:hover,
.st-hdr-trigger.st-filter-active {
  color: var(--primary) !important;
}
.st-inline-search-box {
  min-width: 120px;
}
.st-active-filters-bar {
  background: #F8FAFC;
  border-bottom: 1px solid var(--border-color);
  padding: 0.45rem 0.9rem;
}
.st-chip {
  font-weight: 600;
  font-size: 0.78rem;
}
.st-select-option:hover {
  background-color: #F1F5F9;
}

/* ── 17. Clean Print Stylesheet ─────────────────────────────────────────── */
.print-only-header {
  display: none;
}

@media print {
  @page {
    size: A4 landscape;
    margin: 10mm;
  }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .sidebar,
  .sidebar-backdrop,
  .top-navbar,
  .no-print,
  .btn,
  .btn-group,
  .btn-close,
  .collapse,
  .modal,
  .smart-col-filter-btn,
  .smart-col-filter-popover,
  .smart-list-gear-btn,
  .pagination,
  .alert-dismissible .btn-close {
    display: none !important;
  }

  .print-only-header {
    display: block !important;
  }

  .app-wrapper,
  .main-wrapper,
  .main-content,
  .page-container,
  .container-fluid {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
  }

  body {
    background: #FFFFFF !important;
    color: #000000 !important;
    font-size: 9.5pt !important;
  }

  .content-card {
    box-shadow: none !important;
    border: 1px solid #CBD5E1 !important;
    break-inside: auto !important;
    page-break-inside: auto !important;
    overflow: visible !important;
    background: #FFFFFF !important;
    margin-bottom: 10pt !important;
  }

  .stat-card {
    box-shadow: none !important;
    border: 1px solid #CBD5E1 !important;
    break-inside: avoid !important;
    page-break-inside: avoid !important;
    background: #FFFFFF !important;
    padding: 8pt !important;
  }

  .table-responsive {
    overflow: visible !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .table {
    width: 100% !important;
    border-collapse: collapse !important;
    font-size: 9pt !important;
    table-layout: auto !important;
  }

  .table thead {
    display: table-header-group !important;
  }

  .table tfoot {
    display: table-row-group !important;
  }

  .table tr {
    break-inside: avoid !important;
    page-break-inside: avoid !important;
  }

  .table th,
  .table td {
    padding: 4pt 5pt !important;
    white-space: normal !important;
    word-break: break-word !important;
    border: 1px solid #D1D5DB !important;
    vertical-align: middle !important;
  }

  a[href]::after {
    content: none !important;
  }
}


/* ═══════════════════════════════════════════════════════════════════════════
   Phase 5 Design System Enhancements (v12.2)
   Accessibility (:focus-visible, Skip Link, Reduced Motion), Tabular Numerals,
   Error/Empty State Components, Loading States & Responsive Polish
   ═══════════════════════════════════════════════════════════════════════════ */

/* 1. Keyboard Accessibility: Skip Navigation & High-Contrast Focus Rings */
.skip-to-content {
  position: fixed;
  top: -100px;
  inset-inline-start: 16px;
  z-index: 3000;
  padding: 0.6rem 1rem;
  background: var(--primary);
  color: #FFFFFF;
  font-weight: 600;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  transition: top var(--transition-fast);
}
.skip-to-content:focus {
  top: 12px;
  color: #FFFFFF;
  outline: 3px solid #38BDF8;
  outline-offset: 2px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2.5px solid var(--primary);
  outline-offset: 2px;
}

#mainContent:focus {
  outline: none;
}

/* 2. Tabular Numerals for Financial, Queue, KPI & Statistical Clarity */
.stat-card,
.stat-value,
.kpi-value,
.table td,
.table th,
.badge,
.font-tabular {
  font-variant-numeric: tabular-nums;
}

/* 3. Branded Error & Empty State Components */
.error-state-card {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
}
.error-state-icon {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.9rem;
}
.empty-state-panel {
  text-align: center;
  padding: 2.5rem 1.5rem;
  border-radius: var(--radius-lg);
  background: var(--surface-muted);
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
}

/* 4. Form Submit Loading Feedback */
.btn-is-loading {
  position: relative;
  opacity: 0.82;
  cursor: wait !important;
}
.btn-is-loading::after {
  content: "";
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  margin-inline-start: 0.45rem;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: 50%;
  vertical-align: -0.12em;
  animation: clinic-btn-spin 0.65s linear infinite;
}
@keyframes clinic-btn-spin {
  to { transform: rotate(360deg); }
}

/* 5. Refined Responsive Mobile Tap Targets & Reduced Motion Support */
@media (max-width: 767.98px) {
  .btn:not(.btn-sm):not(.btn-close),
  .form-control:not(.form-control-sm),
  .form-select:not(.form-select-sm) {
    min-height: 42px;
  }
  .page-container {
    padding-inline: 0.75rem;
  }
  .table-responsive {
    -webkit-overflow-scrolling: touch;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Phase 6 Pro Mobile-First & Offline PWA Responsive System (v14.0)
   Edge-to-Edge App Bar · Native Bottom Nav · Auto Card Tables · Zero Overflow
   ═══════════════════════════════════════════════════════════════════════════ */

.main-content {
  overflow-x: clip;
}

/* Eliminate duplicate dropdown arrows on smart-combo enhanced inputs */
.smart-select-combo-wrap input.form-select,
input.smart-combo-input.form-select {
  background-image: none !important;
}
select.form-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

body.mobile-drawer-open {
  overflow: hidden;
  touch-action: none;
}

.auth-card-container {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}

/* Edge-to-Edge Native Mobile App Bar (< 992px, Clinic Users) */
.mobile-app-bar {
  position: sticky;
  top: 0;
  z-index: 1020;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  background: linear-gradient(135deg, #0F172A 0%, #113C59 100%);
  color: #FFFFFF;
  padding: max(0.55rem, env(safe-area-inset-top)) 0.85rem 0.55rem;
  box-shadow: 0 2px 14px rgba(15, 23, 42, 0.18);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.mobile-app-menu-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background-color 0.15s ease;
}

.mobile-app-menu-btn:active {
  background: rgba(255, 255, 255, 0.22);
}

.mobile-app-title {
  font-size: 0.96rem;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.25;
}

.mobile-app-subtitle {
  font-size: 0.72rem;
  color: #93C5FD;
  line-height: 1.2;
}

.global-offline-bar {
  border-radius: var(--radius-md);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

/* Native-like Mobile Sticky Bottom Navigation Bar (< 768px) */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  z-index: 1020;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.09);
  padding: 0.3rem 0.35rem calc(0.35rem + env(safe-area-inset-bottom));
}

.mobile-bnav-item {
  flex: 1 1 0;
  min-width: 0;
  min-height: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
  color: #64748B;
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 10px;
  padding: 0.25rem 0.15rem;
  position: relative;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.mobile-bnav-item i {
  font-size: 1.25rem;
  line-height: 1;
}

.mobile-bnav-item.active {
  color: var(--primary);
  background: var(--primary-light);
}

.mobile-bnav-item.active::before {
  content: "";
  position: absolute;
  top: 0;
  width: 24px;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: var(--primary);
}

/* Mobile Slide-Over Drawer Polish (< 992px) */
@media (max-width: 991.98px) {
  .sidebar {
    width: min(84vw, 310px);
    height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sidebar-nav .nav-link {
    min-height: 46px;
    font-size: 0.95rem;
    padding: 0.7rem 0.95rem;
  }
}

/* ── Comprehensive Professional Mobile Layout (< 768px) ─────────────────── */
@media (max-width: 767.98px) {
  html {
    font-size: 15px;
  }

  body {
    background-color: #F1F5F9;
  }

  .page-container {
    padding: 0.85rem 0.75rem calc(84px + env(safe-area-inset-bottom)) !important;
  }

  .guest-main-container {
    padding-inline: 0.75rem !important;
  }

  /* 1. Prevent iOS Safari zoom-on-focus & ensure comfy touch inputs */
  input.form-control:not(.form-control-sm),
  select.form-select:not(.form-select-sm),
  textarea.form-control:not(.form-control-sm) {
    font-size: 16px !important;
    min-height: 46px;
    border-radius: 10px;
  }

  .btn:not(.btn-sm):not(.btn-xs):not(.btn-close) {
    min-height: 44px;
    border-radius: 10px;
  }

  /* Full-width primary form submit buttons on narrow phone screens */
  form .d-flex.justify-content-end > .btn[type="submit"],
  form .d-flex.justify-content-between > .btn[type="submit"] {
    width: 100%;
  }

  /* Allow long compound buttons (e.g. Subscription Status pill) to wrap cleanly instead of overflowing 360px screens */
  .page-container .btn {
    max-width: 100%;
    white-space: normal;
    line-height: 1.3;
  }

  /* 2. Clean Mobile Page Headers (ditch heavy outer box, add sleek horizontal swipeable toolbar!) */
  .page-hero,
  .page-container > .d-flex.justify-content-between {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0.15rem 0 0.35rem;
    margin-bottom: 0.85rem !important;
    gap: 0.65rem !important;
    flex-direction: column;
    align-items: stretch !important;
  }

  .page-container > .d-flex.justify-content-between > .d-flex:last-child,
  .page-container > .d-flex.justify-content-between > div:last-child {
    width: 100%;
  }

  .mobile-action-strip {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 0.45rem !important;
    padding-bottom: 0.25rem;
  }
  .mobile-action-strip::-webkit-scrollbar {
    display: none;
  }
  .mobile-action-strip > * {
    flex-shrink: 0;
  }
  .mobile-action-strip .btn {
    white-space: nowrap !important;
    min-height: 38px;
    font-size: 0.82rem;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
  }

  h3, .h3 {
    font-size: 1.2rem;
  }

  /* 3. Compact 2-Column KPI Stat Card Grid on Phones (Saves 60% vertical space!) */
  .row:has(> .col > .stat-card) {
    --bs-gutter-x: 0.6rem;
    --bs-gutter-y: 0.6rem;
    margin-bottom: 0.9rem !important;
  }
  .row:has(> .col > .stat-card) > .col {
    flex: 0 0 50% !important;
    max-width: 50% !important;
  }
  /* When there are exactly 3 stat cards (e.g. Super Admin), make the 1st span full width cleanly */
  .row:has(> .col > .stat-card):has(> .col:nth-child(3):last-child) > .col:first-child {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  .stat-card {
    padding: 0.85rem 0.9rem;
    border-radius: 14px;
    gap: 0.5rem;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  }
  .stat-number {
    font-size: 1.32rem !important;
    margin-top: 0.15rem;
  }
  .stat-label,
  .stat-card .text-muted.small {
    font-size: 0.76rem;
    line-height: 1.25;
  }
  .stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 1.05rem;
  }

  /* 4. Single-Row Swipeable Doctor Selector Strip on Appointments */
  #doctorSelectorCard {
    border-radius: 14px;
    margin-bottom: 0.85rem !important;
  }
  #doctorSelectorBar {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  #doctorSelectorBar::-webkit-scrollbar {
    display: none;
  }
  #doctorSelectorBar > * {
    flex-shrink: 0;
  }
  .doctor-selector-pill {
    white-space: nowrap !important;
    min-height: 36px;
  }

  /* 5. Content Cards & Horizontal Scrollable Tab Pills */
  .content-card {
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.045);
    margin-bottom: 0.9rem;
  }
  .content-card-header {
    padding: 0.8rem 0.95rem;
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
  }
  .content-card-body {
    padding: 0.9rem;
  }

  .nav-pills {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-radius: 12px !important;
  }
  .nav-pills::-webkit-scrollbar {
    display: none;
  }
  .nav-pills .nav-item {
    flex-shrink: 0;
  }
  .nav-pills .nav-link {
    padding: 0.5rem 0.9rem !important;
    font-size: 0.85rem;
    white-space: nowrap;
    border-radius: 10px;
  }

  /* 6. Universal Automatic Mobile Table-to-Card Transformation (Zero Horizontal Table Scroll!) */
  .table-responsive:has(> table.mobile-card-table) {
    overflow-x: visible !important;
    background: #F8FAFC;
  }
  table.mobile-card-table {
    display: block;
    width: 100%;
    background: transparent !important;
  }
  table.mobile-card-table thead {
    display: none !important;
  }
  table.mobile-card-table tbody {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding: 0.65rem;
  }
  table.mobile-card-table tbody tr {
    display: block;
    background: #FFFFFF;
    border: 1px solid #E2E8F0;
    border-radius: 14px;
    padding: 0.7rem 0.9rem;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.045);
  }
  table.mobile-card-table tbody tr > td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.42rem 0 !important;
    border: none !important;
    border-bottom: 1px dashed #F1F5F9 !important;
    background: transparent !important;
    white-space: normal !important;
    word-break: break-word;
    font-size: 0.86rem;
    text-align: end;
  }
  table.mobile-card-table tbody tr > td:last-child {
    border-bottom: none !important;
  }
  table.mobile-card-table tbody tr > td::before {
    content: attr(data-mobile-label);
    font-size: 0.76rem;
    font-weight: 600;
    color: #64748B;
    text-align: start;
    flex-shrink: 0;
    max-width: 45%;
  }
  table.mobile-card-table tbody tr > td.mobile-card-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding-top: 0.65rem !important;
    padding-bottom: 0.15rem !important;
    border-bottom: none !important;
  }
  table.mobile-card-table tbody tr > td.mobile-card-actions::before {
    content: none !important;
  }
  table.mobile-card-table tbody tr > td.mobile-card-actions .btn-group,
  table.mobile-card-table tbody tr > td.mobile-card-actions .d-inline-flex {
    flex-wrap: wrap !important;
    white-space: normal !important;
    gap: 0.35rem;
  }
  table.mobile-card-table tbody tr > td.mobile-card-actions .btn {
    min-height: 36px;
    padding: 0.35rem 0.7rem;
    border-radius: 8px !important;
  }
  table.mobile-card-table tbody tr > td.mobile-card-span-cell {
    display: block;
    text-align: center;
    border-bottom: none !important;
  }
  table.mobile-card-table tbody tr > td.mobile-card-span-cell::before {
    content: none !important;
  }
  table.mobile-card-table tfoot {
    display: block;
    padding: 0 0.65rem 0.65rem;
  }
  table.mobile-card-table tfoot tr {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    background: #FFFFFF;
    border: 1px solid #CBD5E1;
    border-radius: 12px;
    padding: 0.65rem 0.85rem;
  }
  table.mobile-card-table tfoot td,
  table.mobile-card-table tfoot th {
    border: none !important;
    background: transparent !important;
    padding: 0.25rem 0.35rem !important;
  }

  /* 7. Prevent wide dropdown popovers from overflowing narrow viewports */
  .dropdown-menu {
    max-width: calc(100vw - 1.25rem) !important;
  }
  #hdrDateDropdownMenu {
    min-width: min(320px, calc(100vw - 1.5rem)) !important;
  }

  /* 8. Native-feeling Mobile Modals (Bottom-sheet rounded polish) */
  .modal-dialog {
    margin: 0.5rem auto;
    max-width: calc(100vw - 1rem);
  }
  .modal-content {
    border-radius: 18px;
  }
  .modal-body {
    padding: 1rem;
    max-height: 76dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-header,
  .modal-footer {
    padding: 0.8rem 1rem;
  }
  .modal-footer {
    gap: 0.45rem;
  }

  /* 9. Compact Super Admin Top App Bar on Phones */
  .top-navbar.top-navbar-admin {
    padding: max(0.45rem, env(safe-area-inset-top)) 0.75rem 0.45rem;
    height: auto;
    min-height: 56px;
    background: linear-gradient(135deg, #0F172A 0%, #113C59 100%);
  }
  .top-navbar.top-navbar-admin .sidebar-brand-icon {
    width: 34px;
    height: 34px;
    font-size: 1rem;
  }
  .top-navbar.top-navbar-admin .sidebar-brand {
    font-size: 0.94rem;
  }

  /* 10. Clean Mobile Auth Screens (Login / OTP / Forgot Password) */
  .auth-page-wrapper {
    padding: 0.75rem 0;
    min-height: 88dvh;
    background: transparent;
  }
  .auth-card {
    border-radius: 18px;
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
  }
  .auth-card > .p-4 {
    padding: 1.5rem 1.25rem !important;
  }
}

@media print {
  .mobile-app-bar,
  .mobile-sticky-header,
  .mobile-bottom-nav,
  .global-offline-bar,
  .pwa-install-btn,
  .clinic-net-pill {
    display: none !important;
  }
}
