/* PhysioPulse - Physiotherapy Clinic Management System Styles */
:root {
  --primary: #15803d;
  --primary-hover: #166534;
  --primary-light: #dcfce7;
  --primary-dark: #14532d;
  --accent: #0284c7;
  --accent-light: #e0f2fe;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-subtle: #f1f5f9;
  --border: #e2e8f0;
  --border-focus: #0d9488;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #0d9488;
  --sidebar-text: #e2e8f0;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

/* Layout */
.app-container {
  display: flex;
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Sidebar */
.sidebar {
  width: 270px;
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: all 0.2s ease;
  z-index: 40;
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #fff;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #16a34a, #15803d);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.35);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.nav-section-label {
  padding: 18px 20px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}

.nav-menu {
  list-style: none;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.nav-item:hover {
  background-color: var(--sidebar-hover);
  color: #ffffff;
}

.nav-item.active {
  background-color: var(--sidebar-active);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.4);
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.nav-item.active .nav-badge {
  background: rgba(255, 255, 255, 0.25);
}

/* Sidebar Footer / User Profile */
.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
}

.user-profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: #334155;
  color: #38bdf8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

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

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.role-management {
  background: #14b8a6;
  color: #042f2e;
}

.role-staff {
  background: #38bdf8;
  color: #082f49;
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
}

/* Top App Header */
.top-header {
  height: 68px;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.page-title-wrap {
  display: flex;
  flex-direction: column;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.page-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Role Switcher Pill */
.role-switch-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-subtle);
  padding: 4px 6px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
}

.role-switch-btn {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

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

/* Quick Action Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 2px 6px rgba(13, 148, 136, 0.3);
}

.btn-secondary {
  background-color: var(--surface);
  color: var(--text-main);
  border-color: var(--border);
}
.btn-secondary:hover {
  background-color: var(--surface-subtle);
}

.btn-outline {
  background-color: transparent;
  border-color: var(--primary);
  color: var(--primary);
}
.btn-outline:hover {
  background-color: var(--primary-light);
}

.btn-danger {
  background-color: var(--danger);
  color: white;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* Content Container */
.content-body {
  padding: 24px 28px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Alert Banners */
.alert-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  border-left: 4px solid;
}

.alert-info {
  background: #f0fdf4;
  border-color: var(--primary);
  color: #134e4a;
}

.alert-warning {
  background: var(--warning-light);
  border-color: var(--warning);
  color: #78350f;
}

.alert-staff-role {
  background: #f0f9ff;
  border-color: #0284c7;
  color: #0c4a6e;
}

/* Metric / Stat Cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.metric-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  overflow: hidden;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.metric-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.metric-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.icon-teal { background: #ccfbf1; color: #0d9488; }
.icon-blue { background: #e0f2fe; color: #0284c7; }
.icon-emerald { background: #d1fae5; color: #059669; }
.icon-amber { background: #fef3c7; color: #d97706; }
.icon-purple { background: #f3e8ff; color: #7e22ce; }
.icon-rose { background: #ffe4e6; color: #e11d48; }

.metric-value {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.2;
}

.metric-subtext {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Aliases for stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  overflow: hidden;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stat-title { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.stat-icon { width: 36px; height: 36px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 1rem; }
.stat-value { font-size: 1.65rem; font-weight: 800; letter-spacing: -0.02em; color: var(--text-main); line-height: 1.2; }
.stat-subtitle { font-size: 0.78rem; color: var(--text-muted); margin-top: 6px; display: flex; align-items: center; gap: 4px; }

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

@media (max-width: 1024px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.card-body {
  padding: 20px;
}

/* Interactive SVG Charts */
.chart-container {
  width: 100%;
  height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

svg.custom-chart {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Payment Mode Legend & Distribution */
.mode-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mode-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mode-item-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
}

.mode-bar-bg {
  width: 100%;
  height: 8px;
  background: var(--surface-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.mode-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* Data Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.88rem;
  text-align: left;
}

.data-table th {
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

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

/* Table Filters & Toolbar */
.toolbar-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-box {
  position: relative;
  min-width: 260px;
  flex: 1;
  max-width: 400px;
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  background: var(--surface);
  outline: none;
  transition: border-color 0.15s ease;
}

.search-box input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  width: 18px;
  height: 18px;
  pointer-events: none;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-success { background: var(--success-light); color: #065f46; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-info { background: var(--accent-light); color: #075985; }
.badge-neutral { background: #f1f5f9; color: #475569; }

/* Progress Pills for Sessions */
.session-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
}

.session-healthy {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.session-low {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.session-exhausted {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* Modality Badges */
.modality-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.modality-tag {
  background: #e2e8f0;
  color: #334155;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
}

/* Pain Scale Display */
.pain-score-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: 0.76rem;
}

.pain-mild { background: #dcfce7; color: #166534; }
.pain-moderate { background: #fef9c3; color: #854d0e; }
.pain-high { background: #ffedd5; color: #9a3412; }
.pain-severe { background: #fee2e2; color: #991b1b; }

/* Date Preset Pills */
.date-pills-wrap {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.date-pill {
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.2;
}

.date-pill:hover {
  background: #f1f5f9;
  color: var(--text-main);
  border-color: #cbd5e1;
}

.date-pill.active {
  background: #0f766e;
  color: #ffffff;
  border-color: #0f766e;
  box-shadow: 0 1px 3px rgba(15, 118, 110, 0.25);
}

/* Forms & Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 20px;
  overflow-y: auto;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(12px);
  transition: transform 0.2s ease;
  position: relative;
}

.modal-backdrop.active .modal {
  transform: translateY(0);
}

/* Ensure forms inside modals stretch and allow child .modal-body to scroll */
.modal form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.modal-header {
  flex-shrink: 0;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.3rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  max-height: calc(88vh - 135px);
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-body::-webkit-scrollbar {
  width: 8px;
}

.modal-body::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.modal-footer {
  flex-shrink: 0;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* Form Controls */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-group-full {
  grid-column: span 2;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  font-family: inherit;
  color: var(--text-main);
  background: #ffffff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.form-help {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* Checkbox Grid for Modalities */
.modality-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
  margin-top: 4px;
}

.modality-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.8rem;
  user-select: none;
  transition: all 0.15s ease;
}

.modality-chip input {
  cursor: pointer;
  accent-color: var(--primary);
}

.modality-chip.checked {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 600;
}

/* Pain Slider Widget */
.pain-slider-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
}

.pain-slider {
  flex: 1;
  accent-color: var(--primary);
  cursor: pointer;
}

.pain-val-badge {
  min-width: 48px;
  text-align: center;
  padding: 4px 8px;
  border-radius: var(--radius-md);
  font-weight: 800;
  font-size: 0.95rem;
}

/* Patient Quick Summary Box */
.patient-quick-card {
  background: var(--surface-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-card-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

/* Printable Receipt Styles */
@media print {
  body {
    background: white;
    color: black;
  }
  .sidebar, .top-header, .alert-banner, .modal-footer, .btn, .modal-close {
    display: none !important;
  }
  .modal-backdrop {
    position: static;
    background: none;
    backdrop-filter: none;
    padding: 0;
  }
  .modal {
    box-shadow: none;
    border: none;
    max-width: 100%;
  }
  .receipt-container {
    padding: 20px;
    border: 1px solid #ccc !important;
  }
}

.receipt-container {
  background: white;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.receipt-header {
  text-align: center;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 12px;
}

.receipt-clinic-name {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.receipt-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  font-size: 0.84rem;
}

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

.receipt-table th, .receipt-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e2e8f0;
}

.receipt-total-row {
  font-weight: 700;
  font-size: 1rem;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  background: var(--surface);
  color: var(--text-main);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  min-width: 300px;
  animation: slideIn 0.25s ease forwards;
}

.toast-success { border-color: var(--success); }
.toast-error { border-color: var(--danger); }
.toast-warning { border-color: var(--warning); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsive styling defined in dedicated section at end of file */

/* ==================== CLINIC PUBLIC WEBSITE STYLES ==================== */
#view-website {
  width: 100vw;
  min-height: 100vh;
  background-color: #f8fafc;
  display: flex;
  flex-direction: column;
  color: var(--text-main);
  overflow-x: hidden;
}

.web-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 40px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.web-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--text-main);
}

.web-nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  list-style: none;
}

.web-nav-link {
  text-decoration: none;
  color: #475569;
  font-size: 0.92rem;
  font-weight: 600;
  transition: color 0.15s ease;
}

.web-nav-link:hover {
  color: var(--primary);
}

.web-nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-web-portal {
  background: linear-gradient(135deg, #15803d, #166534);
  color: #ffffff !important;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(21, 128, 61, 0.35);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-web-portal:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(21, 128, 61, 0.45);
}

.web-hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 40%, #14532d 100%);
  color: #ffffff;
  padding: 64px 40px 80px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.web-hero::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(22, 163, 74, 0.12) 0%, transparent 60%);
  pointer-events: none;
}

.web-hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #86efac;
  margin-bottom: 20px;
  backdrop-filter: blur(8px);
}

.web-hero-title {
  font-size: 3rem;
  font-weight: 850;
  line-height: 1.15;
  margin-bottom: 14px;
  letter-spacing: -0.03em;
  color: #ffffff;
}

.web-hero-title span {
  color: #4ade80;
}

.web-hero-subtitle {
  font-size: 1.18rem;
  color: #cbd5e1;
  max-width: 760px;
  margin: 0 auto 28px;
  line-height: 1.6;
}

.web-hero-doctor-pill {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 36px;
  font-size: 0.88rem;
  color: #f1f5f9;
}

/* 3 Big Portal Entry Cards */
.web-portals-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  max-width: 1200px;
  margin: -50px auto 48px;
  padding: 0 24px;
  position: relative;
  z-index: 10;
}

.portal-entry-card {
  background: #ffffff;
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: 0 16px 32px -4px rgba(15, 23, 42, 0.12);
  border: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}

.portal-entry-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 24px 40px -4px rgba(15, 23, 42, 0.18);
  border-color: #86efac;
}

.portal-card-patient {
  border-top: 5px solid #15803d;
}

.portal-card-staff {
  border-top: 5px solid #0284c7;
}

.portal-card-mgmt {
  border-top: 5px solid #b45309;
}

.portal-entry-icon {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin-bottom: 18px;
}

.icon-bg-green { background: #dcfce7; }
.icon-bg-blue { background: #e0f2fe; }
.icon-bg-gold { background: #fef3c7; }

.portal-entry-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 8px;
}

.portal-entry-desc {
  font-size: 0.9rem;
  color: #64748b;
  line-height: 1.5;
  margin-bottom: 24px;
  flex-grow: 1;
}

/* Sections on Website */
.web-section {
  max-width: 1200px;
  margin: 0 auto 64px;
  padding: 0 24px;
  width: 100%;
}

.web-section-header {
  text-align: center;
  margin-bottom: 40px;
}

.web-section-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 6px;
}

.web-section-title {
  font-size: 2rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.web-section-subtitle {
  font-size: 1rem;
  color: #64748b;
  margin-top: 6px;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

/* Sub-Clinics Grid */
.clinics-location-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.clinic-location-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
}

.clinic-location-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-md);
}

.clinic-loc-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
  margin-bottom: 12px;
  width: fit-content;
}

.clinic-loc-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 8px;
}

.clinic-loc-address {
  font-size: 0.84rem;
  color: #64748b;
  line-height: 1.45;
  margin-bottom: 14px;
  flex-grow: 1;
}

.clinic-loc-footer {
  border-top: 1px dashed #e2e8f0;
  padding-top: 12px;
  font-size: 0.8rem;
  color: #475569;
}

/* Services Grid */
.services-feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.service-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.service-card:hover {
  border-color: #86efac;
  box-shadow: var(--shadow-md);
}

.service-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #dcfce7;
  color: #166534;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 14px;
}

.service-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 8px;
}

.service-card-desc {
  font-size: 0.86rem;
  color: #64748b;
  line-height: 1.5;
}

/* Website Footer */
.web-footer {
  background: #0f172a;
  color: #94a3b8;
  padding: 48px 40px 24px;
  margin-top: auto;
}

.web-footer-container {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Badges for Clinics */
.badge-clinic {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* Clinic Wise Comparison Table & Bar Graph */
.clinic-stats-table th, .clinic-stats-table td {
  padding: 10px 14px;
  text-align: left;
}

.clinic-bar-track {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
}

.clinic-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #15803d, #22c55e);
  border-radius: 4px;
}

/* ==================== COMPREHENSIVE MOBILE-FIRST & RESPONSIVE STYLES ==================== */

/* Safe area support for notch and gesture bar */
:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

/* Mobile Sidebar Backdrop */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 990;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
  display: block;
  opacity: 1;
}

/* Mobile Hamburger & Drawer Close */
.btn-mobile-sidebar {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.btn-mobile-sidebar:active {
  background: var(--surface-subtle);
  transform: scale(0.95);
}

.btn-sidebar-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.btn-sidebar-close:active {
  background: rgba(255, 255, 255, 0.2);
}

.btn-web-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #1e293b;
  cursor: pointer;
}

/* Mobile Bottom Navigation Bar */
.mobile-bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(62px + var(--sab));
  padding-bottom: var(--sab);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid #e2e8f0;
  z-index: 850;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.05);
}

.mobile-bottom-item,
.mob-tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex: 1;
  height: 100%;
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 600;
  transition: all 0.15s ease;
  user-select: none;
  padding: 4px 0;
  -webkit-tap-highlight-color: transparent;
}

.mobile-bottom-item svg,
.mob-tab-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  transition: transform 0.15s ease, stroke 0.15s ease;
}

.mobile-bottom-item .mob-icon,
.mob-tab-btn .mob-icon {
  font-size: 1.25rem;
  line-height: 1;
  transition: transform 0.15s ease;
}

.mobile-bottom-item.active,
.mob-tab-btn.active {
  color: #15803d;
  font-weight: 700;
}

.mobile-bottom-item.active svg,
.mob-tab-btn.active svg {
  stroke: #15803d;
  transform: translateY(-2px);
}

.mobile-bottom-item.active .mob-icon,
.mob-tab-btn.active .mob-icon {
  transform: translateY(-2px);
}

/* Helper Class Defaults (Desktop / Baseline) */
.mobile-only-nav-actions {
  display: none !important;
}

.pd-overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  font-size: 0.86rem;
}

#mgmt-clinic-filter {
  min-width: 280px;
  font-weight: 600;
}

/* Multi-Clinic Comparative Performance Section */
.desktop-clinic-table-wrap {
  display: block;
}

.mobile-clinic-cards-wrap {
  display: none;
}

.mobile-clinic-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mobile-clinic-card.active-filter-card {
  border: 2px solid #0f766e;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.15);
}

.mobile-clinic-card-header {
  padding: 12px 14px 10px;
  background: #f8fafc;
  border-bottom: 1px solid #eef2f6;
}

.mobile-clinic-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.mobile-clinic-name {
  font-size: 0.96rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
}

.mobile-clinic-address {
  font-size: 0.78rem;
  color: #64748b;
  line-height: 1.3;
}

.mobile-clinic-revenue-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(180deg, #f0fdf4 0%, #f8fafc 100%);
  border-bottom: 1px solid #dcfce7;
  gap: 8px;
}

.mobile-clinic-rev-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mobile-clinic-rev-col:last-child {
  text-align: right;
}

.mobile-rev-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #64748b;
}

.mobile-rev-val {
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.2;
}

.mobile-rev-val.total-rev {
  color: #14532d;
  font-size: 1.05rem;
}

.mobile-rev-val.month-rev {
  color: #0f766e;
}

.mobile-rev-val.due-alert {
  color: #dc2626;
}

.mobile-rev-val.due-nil {
  color: #15803d;
  font-size: 0.88rem;
  font-weight: 700;
}

.mobile-clinic-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 14px 10px;
  background: #ffffff;
}

.mobile-cmetric-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  padding: 8px 6px;
  border-radius: 8px;
  border: 1px solid #f1f5f9;
}

.mobile-cmetric-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.mobile-cmetric-data {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mobile-cmetric-val {
  font-size: 0.86rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-cmetric-sub {
  font-size: 0.7rem;
  font-weight: 500;
  color: #64748b;
}

.mobile-cmetric-val.text-blue {
  color: #0284c7;
}

.mobile-cmetric-lbl {
  font-size: 0.65rem;
  color: #64748b;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-clinic-card-footer {
  padding: 8px 14px 12px;
  background: #ffffff;
  border-top: 1px dashed #f1f5f9;
}

.mobile-clinic-filter-btn {
  width: 100%;
  padding: 6px 12px;
  font-size: 0.78rem;
  justify-content: center;
}

.modal-footer-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-footer-between .modal-footer-actions {
  display: flex;
  gap: 8px;
}

/* Horizontal Table Swipe Indicator */
.table-scroll-hint {
  display: none;
  font-size: 0.74rem;
  color: #0f766e;
  font-weight: 600;
  background: #f0fdf4;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  border: 1px dashed #86efac;
  align-items: center;
  gap: 6px;
}

/* Tablet & Desktop Large Breakpoints */
@media (max-width: 1024px) {
  .web-nav {
    padding: 14px 24px;
  }
  .web-portals-grid {
    grid-template-columns: 1fr;
    margin-top: -30px;
    gap: 16px;
  }
  .clinics-location-grid {
    grid-template-columns: 1fr 1fr;
  }
  .services-feature-grid {
    grid-template-columns: 1fr 1fr;
  }
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

/* Smartphone Breakpoint (<= 768px) */
@media (max-width: 768px) {
  body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
  }

  /* 1. App Container & Sidebar Off-Canvas */
  .app-container {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    overflow-x: hidden;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 285px;
    height: 100vh;
    height: 100dvh;
    z-index: 999;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 25px rgba(0, 0, 0, 0.4);
  }

  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 16px;
  }

  .btn-sidebar-close {
    display: flex;
  }

  /* 2. Main Wrapper & Content Body */
  .main-wrapper {
    width: 100%;
    min-width: 100%;
    height: 100vh;
    height: 100dvh;
  }

  .content-body {
    padding: 14px 12px calc(80px + var(--sab)) !important;
    gap: 16px;
  }

  /* 3. Top Application Header */
  .top-header {
    height: auto;
    min-height: 56px;
    padding: 10px 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    position: sticky;
    top: 0;
  }

  .btn-mobile-sidebar {
    display: flex;
  }

  .top-header-main-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
  }

  .page-title-wrap {
    flex: 1;
    min-width: 0;
  }

  .page-title {
    font-size: 1.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .page-desc {
    display: none;
  }

  .header-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .quick-action-btns {
    display: flex;
    gap: 8px;
    width: 100%;
  }

  .quick-action-btns .btn {
    flex: 1;
    min-height: 42px;
    font-size: 0.85rem;
    justify-content: center;
    padding: 8px 10px;
  }

  /* Role Switcher Pill */
  .role-switch-pill {
    width: 100%;
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 3px;
  }

  .role-switch-btn {
    flex: 1;
    padding: 6px 6px;
    font-size: 0.72rem;
    white-space: nowrap;
    text-align: center;
  }

  /* 4. Mobile Navigation: Bottom for Staff, Top for Management */
  .mobile-bottom-bar {
    display: flex;
  }

  /* Management Mode: Move Menu Bar to Top */
  body.mgmt-top-menu .mobile-bottom-bar {
    position: sticky !important;
    top: 0 !important;
    bottom: auto !important;
    left: 0 !important;
    right: 0 !important;
    height: 54px !important;
    padding: 0 4px !important;
    padding-bottom: 0 !important;
    background: #ffffff !important;
    border-top: none !important;
    border-bottom: 2px solid #0f766e !important;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.07) !important;
    z-index: 50 !important;
  }

  body.mgmt-top-menu .top-header {
    position: relative !important;
    top: auto !important;
  }

  body.mgmt-top-menu .content-body {
    padding-top: 14px !important;
    padding-bottom: 24px !important;
  }

  body.mgmt-top-menu .mobile-bottom-item {
    font-size: 0.72rem;
    font-weight: 600;
    color: #64748b;
    padding: 6px 2px 4px;
    border-bottom: 3px solid transparent;
    border-radius: 0;
  }

  body.mgmt-top-menu .mobile-bottom-item.active {
    color: #0f766e;
    font-weight: 700;
    border-bottom-color: #0f766e;
    background: rgba(15, 118, 110, 0.05);
  }

  body.mgmt-top-menu .mobile-bottom-item svg {
    width: 18px;
    height: 18px;
  }

  /* 5. Metrics Grid on Mobile */
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
  }

  .metric-card {
    padding: 12px 10px;
    border-radius: var(--radius-md);
  }

  .metric-label {
    font-size: 0.72rem;
  }

  .metric-value {
    font-size: 1.3rem;
  }

  .metric-subtext {
    font-size: 0.68rem;
  }

  /* 6. Toolbars & Filters */
  .toolbar-wrap {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 12px;
  }

  .search-box {
    min-width: 100%;
    max-width: 100%;
  }

  .search-box input {
    min-height: 44px;
    font-size: 16px; /* Prevents auto-zoom in Safari */
  }

  .toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  .toolbar-actions .form-select,
  .toolbar-actions .form-input {
    flex: 1 1 100% !important;
    width: 100% !important;
    min-height: 44px;
    font-size: 16px !important;
  }

  .toolbar-actions .btn {
    flex: 1 1 calc(50% - 4px);
    min-height: 44px;
    font-size: 0.85rem;
    justify-content: center;
    padding: 8px 12px;
  }

  .toolbar-actions .btn-primary {
    flex: 1 1 100% !important;
    font-size: 0.92rem;
  }

  /* Dashboard Multi-Center Filter */
  .dashboard-filter-card {
    padding: 12px 14px !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .dashboard-filter-select-wrap {
    width: 100% !important;
  }

  #mgmt-clinic-filter {
    min-width: 0 !important;
    width: 100% !important;
    font-size: 16px !important;
    min-height: 44px;
  }

  /* Multi-Clinic Performance Mobile Cards Switch */
  .desktop-clinic-table-wrap {
    display: none !important;
  }

  .mobile-clinic-cards-wrap {
    display: flex !important;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
  }

  /* 7. Data Tables & Momentum Scrolling */
  .table-scroll-hint {
    display: flex;
    font-size: 0.72rem;
    padding: 6px 10px;
    margin: 8px 12px 0;
  }

  .table-responsive {
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: #ffffff;
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
    width: 100%;
    display: block;
  }

  .data-table {
    min-width: 660px;
  }

  .data-table th,
  .data-table td {
    padding: 10px 8px;
    font-size: 0.82rem;
  }

  .data-table .btn-sm {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 0.76rem;
  }

  /* 8. Modals & Forms on Mobile */
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh !important;
    max-height: 92dvh !important;
    border-radius: 20px 20px 0 0 !important;
    margin: 0 !important;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.25);
  }

  .modal.modal-compact {
    align-self: center !important;
    border-radius: 16px !important;
    max-width: calc(100% - 24px) !important;
    margin: auto !important;
    max-height: 85vh !important;
    max-height: 85dvh !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
  }

  .modal-header {
    padding: 14px 16px;
  }

  .modal-title {
    font-size: 1.05rem;
  }

  .modal-close {
    min-width: 40px;
    min-height: 40px;
    font-size: 1.5rem;
  }

  .modal-body {
    padding: 14px 14px;
    gap: 12px;
    max-height: calc(92dvh - 130px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .modal-footer {
    padding: 10px 14px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .modal-footer .btn {
    flex: 1;
    min-height: 46px;
    font-size: 0.92rem;
    justify-content: center;
  }

  /* Patient Details Modal Clinical Overview & Footers */
  .pd-overview-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .pd-overview-grid > div {
    grid-column: span 1 !important;
  }

  #pd-footer-actions {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    padding: 10px 14px !important;
  }

  #pd-footer-actions .btn {
    flex: 1 1 calc(50% - 4px) !important;
    min-height: 44px !important;
    font-size: 0.82rem !important;
    justify-content: center !important;
    padding: 8px 10px !important;
  }

  #pd-footer-actions .btn-primary {
    flex: 1 1 100% !important;
    order: -1 !important;
    font-size: 0.92rem !important;
  }

  .modal-footer-between {
    flex-direction: column-reverse !important;
    gap: 10px !important;
    width: 100% !important;
  }

  .modal-footer-between .modal-footer-actions {
    display: flex !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .modal-footer-between .modal-footer-actions .btn {
    flex: 1 !important;
    min-height: 44px !important;
    font-size: 0.9rem !important;
  }

  .modal-footer-between > .btn-danger {
    width: 100% !important;
    min-height: 42px !important;
    justify-content: center !important;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  .form-group-full {
    grid-column: span 1 !important;
  }

  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px !important; /* Prevents auto-zoom in Safari & Chrome */
    min-height: 46px;
    padding: 10px 12px;
  }

  /* Modality Checkbox Chips on Mobile */
  .modality-checkbox-grid,
  .modality-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px !important;
  }

  .modality-chip {
    padding: 8px 6px !important;
    font-size: 0.78rem !important;
    justify-content: center !important;
    text-align: center !important;
    min-height: 38px !important;
  }

  /* Pain Slider Touch Accessibility */
  .pain-slider {
    height: 34px !important;
  }

  /* Patient Portal Mobile */
  .pt-hero-card {
    padding: 16px 14px !important;
    border-radius: 14px !important;
  }

  .pt-hero-wrap {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 14px !important;
  }

  #pt-name {
    font-size: 1.45rem !important;
  }

  .pt-clinic-contact-box {
    text-align: left !important;
    width: 100% !important;
    padding: 10px 12px !important;
  }

  /* Printable Receipt on Mobile */
  .receipt-container {
    padding: 14px 10px !important;
    gap: 12px !important;
    font-size: 0.82rem !important;
  }

  .receipt-meta-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .receipt-meta-grid > div:last-child {
    text-align: left !important;
  }

  /* Toast notification on Mobile */
  #toast-container {
    bottom: calc(72px + var(--sab)) !important;
    left: 12px !important;
    right: 12px !important;
    align-items: center !important;
  }

  .toast {
    min-width: 0 !important;
    width: 100% !important;
    max-width: 420px !important;
  }

  /* 9. Public Website Mobile Optimization */
  .web-nav {
    padding: 10px 14px;
    flex-direction: column;
    align-items: stretch;
  }

  .web-nav-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  .web-nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 6px;
    padding: 10px 0 4px;
    border-top: 1px solid #e2e8f0;
    margin-top: 8px;
  }

  .web-nav-links.open,
  .web-nav-links.mobile-open {
    display: flex !important;
  }

  .mobile-only-nav-actions {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    margin-top: 8px !important;
    border-top: 1px dashed #e2e8f0 !important;
    padding-top: 8px !important;
  }

  .web-nav-link {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: #f8fafc;
    font-size: 0.88rem;
  }

  .btn-web-menu-toggle {
    display: flex;
  }

  .web-nav-actions {
    display: none;
  }

  /* Website Hero */
  .web-hero {
    padding: 32px 14px 40px;
  }

  .web-hero-badge {
    font-size: 0.72rem;
    padding: 5px 10px;
    line-height: 1.35;
  }

  .web-hero-title {
    font-size: 1.95rem;
    line-height: 1.15;
  }

  .web-hero-subtitle {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 16px;
  }

  .web-hero-doctor-pill {
    flex-direction: column;
    gap: 4px;
    text-align: center;
    padding: 8px 12px;
    font-size: 0.76rem;
  }

  .web-hero-actions {
    flex-direction: column;
    width: 100%;
    gap: 10px !important;
  }

  .web-hero-actions .btn,
  .web-hero-actions .btn-web-portal {
    width: 100%;
    min-height: 48px;
    font-size: 0.98rem;
    justify-content: center;
  }

  /* Website Sections */
  .web-section {
    padding: 36px 14px;
  }

  .web-section-title {
    font-size: 1.5rem;
  }

  .clinics-location-grid,
  .services-feature-grid,
  .web-portals-grid {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }

  .portal-entry-card {
    padding: 20px 16px;
  }

  .portal-entry-title {
    font-size: 1.2rem;
  }

  .portal-entry-card .btn {
    min-height: 46px;
    font-size: 0.95rem;
  }

  /* Leadership Card */
  .leadership-card,
  #web-doctor-section .card {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    padding: 20px 14px !important;
    gap: 16px !important;
  }

  .leadership-card > div:first-child {
    margin: 0 auto;
  }

  /* Footer */
  .web-footer-container {
    grid-template-columns: 1fr !important;
    gap: 20px;
  }
}

/* Extra Small Devices (<= 380px) */
@media (max-width: 380px) {
  .metrics-grid {
    grid-template-columns: 1fr !important;
  }
  .web-hero-title {
    font-size: 1.7rem;
  }
  .role-switch-btn {
    padding: 6px 2px;
    font-size: 0.67rem;
  }
}

@media (max-width: 640px) {
  .btn-text-hide-mobile {
    display: none !important;
  }
}


