/* ========================================
   DentaCare Pro â€” Design System
   ======================================== */

:root {
  /* Crextio Warm Golden Light Theme */
  --bg-primary: #e2e8f0;    /* Slightly darker than sidebar #eff4f6 */
  --bg-secondary: #cbd5e1;  
  --bg-card: #FFFFFF;       /* Pure white floating panels */
  --bg-card-hover: color-mix(in srgb, var(--text-primary) 2%, transparent);
  --bg-input: #FFFFFF;
  --bg-sidebar: #eff4f6;    /* Icy light gray/blue sidebar color */
  --nav-hover: rgba(255, 255, 255, 0.4); 
  
  /* Accent Colors */
  --accent: #27272A;        /* Dark Charcoal for active elements */
  --accent-glow: rgba(39, 39, 42, 0.15);
  --accent-hover: #3F3F46;  
  --accent-2: #9DD2FA;      /* Sky Blue for highlights */
  --accent-3: #27272A;      
  
  --nav-active: #9DD2FA;
  --nav-active-glow: rgba(157, 210, 250, 0.25);
  --nav-active-text: #27272A; /* High contrast text for light theme */
  
  --brand-highlight: #82C2EF; /* Very slightly darker than #9DD2FA for better contrast in light mode */
  
  --accent-green: #10B981;
  --accent-amber: #9DD2FA;
  --accent-rose: #F43F5E;
  --accent-purple: #8B5CF6;
  
  --btn-gradient: linear-gradient(135deg, var(--accent), var(--accent-2));
  --btn-text: #FFFFFF;

  /* Typography */
  --font-heading: 'Poppins', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --font-numbers: 'Inter', sans-serif;

  --text-primary: #18181B;  /* Very Dark Zinc */
  --text-secondary: #71717A;/* Muted Zinc */
  --text-muted: #A1A1AA;    /* Light Zinc */

  /* Structural */
  --border: rgba(0, 0, 0, 0.03); /* Extremely subtle border */
  --border-focus: rgba(157, 210, 250, 0.6);

  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  /* Premium Box Shadows */
  --shadow-sm: 0 4px 10px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 25px 50px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 40px rgba(255, 112, 67, 0.2);

  --sidebar-width: 280px;
  --header-height: 70px;

  --transition-fast: 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

body.dark-mode {
  /* Updated Observability Theme */
  --bg-primary: #1A2129;
  --bg-secondary: #222A33;
  --bg-card: #222A33;
  --bg-card-hover: color-mix(in srgb, var(--text-primary) 4%, transparent);
  --bg-input: #1A2129;
  --bg-sidebar: #1A2129;

  --accent: #9DD2FA;
  --accent-glow: rgba(157, 210, 250, 0.25);
  --accent-hover: #BAE6FD;
  --accent-2: #38BDF8;
  
  --btn-gradient: linear-gradient(135deg, var(--accent), var(--accent-2));
  --btn-text: #020C1B;
  
  --nav-active: #9DD2FA;
  --nav-active-glow: rgba(157, 210, 250, 0.25);
  --nav-active-text: #9DD2FA;
  
  --brand-highlight: #9DD2FA;
  
  --text-primary: #FFFFFF;
  --text-secondary: #9CA3AF;
  --text-muted: #6B7280;

  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(157, 210, 250, 0.4);

  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.6);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.8);
  --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 1);
  --shadow-glow: 0 0 25px rgba(157, 210, 250, 0.2);
  
  --flatpickr-highlight: #0284c7; /* Sky 600, darker than before */
}

/* ========== RESET ========== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.auth-title,
.card-header h3,
.page-title,
.page-header h1 {
  font-family: var(--font-heading) !important;
  font-weight: 700;
}

/* Explicitly apply Inter font to all quantitative and numeric elements */
.stat-value,
.currency,
input[type="number"],
.flatpickr-day,
.flatpickr-monthDropdown-months,
.flatpickr-yearDropdown-years,
.custom-date-picker-input,
#invTotalExpenseDisplay,
#referralPointsDisplay,
#referralCountDisplay,
.badge {
  font-family: var(--font-numbers) !important;
  font-variant-numeric: tabular-nums; /* ensures monospaced digit widths for data alignment */
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ========== SIDEBAR ========== */
.sidebar {
  position: fixed;
  left: 24px;
  top: 24px;
  bottom: 24px;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-slow);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 30px 16px 26px 14px;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  font-size: 24px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.brand-text,
.auth-brand h1,
.mobile-brand {
  font-family: 'Plus Jakarta Sans', sans-serif !important;
  font-size: 24px;
  font-weight: 700 !important;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1;
  margin-top: 0;
}

.brand-accent {
  color: var(--accent);
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s ease, color 0.2s ease;
  width: 100%;
  text-align: left;
  position: relative;
  overflow: hidden;
}

.nav-btn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--brand-highlight);
  transform: scaleY(0);
  transform-origin: center;
  transition: transform var(--transition-normal);
  border-radius: 0 4px 4px 0;
}

.nav-btn:hover {
  background: rgba(56, 189, 248, 0.05);
  color: var(--text-primary);
}

.nav-btn.active {
  background: var(--nav-active-glow);
  color: var(--nav-active-text);
}

.nav-btn.active::before {
  transform: scaleY(1);
}

.nav-btn svg {
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px 16px 20px;
  border-top: 1px solid var(--border);
}

.doctor-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.patient-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: rgba(157, 210, 250, 0.12);
  border: 1px solid rgba(157, 210, 250, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--brand-highlight);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.patient-icon.patient-icon-due {
  background: rgba(244, 63, 94, 0.08);
  border-color: rgba(244, 63, 94, 0.2);
  color: var(--accent-rose);
}

.patient-card:hover .patient-icon {
  background: rgba(157, 210, 250, 0.22);
  border-color: rgba(157, 210, 250, 0.38);
}

.patient-card:hover .patient-icon.patient-icon-due {
  background: rgba(244, 63, 94, 0.14);
  border-color: rgba(244, 63, 94, 0.38);
}

.doctor-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(157, 210, 250, 0.12);
  border: 1px solid rgba(157, 210, 250, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--brand-highlight);
}

.doctor-info {
  display: flex;
  flex-direction: column;
}

.wishlist-patient-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doctor-name {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-lock {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-left: auto;
}

.btn-lock:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* ========== MOBILE HEADER ========== */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  z-index: 99;
}

.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.hamburger span {
  width: 22px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: all var(--transition-fast);
}

.mobile-brand {
  font-size: 18px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
  backdrop-filter: blur(4px);
}

/* ========== MAIN CONTENT ========== */
.main-content {
  margin-left: calc(var(--sidebar-width) + 32px);
  min-height: 100vh;
  padding: 28px 48px 24px 16px;
  max-width: 1400px;
  overflow: visible;
}

/* ========== PAGE ========== */
.page {
  display: none;
  animation: fadeInUp 0.4s ease;
}

.page.active {
  display: block;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0% { opacity: 0.4; }
  50% { opacity: 0.8; }
  100% { opacity: 0.4; }
}

.page-header {
  display: grid;
  grid-template-columns: 1fr auto;
  margin-bottom: 32px;
  gap: 4px 16px;
}

.page-header > div:first-child {
  display: contents;
}

.page-header > div:first-child > h1 {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
}

.page-header > div:first-child > p {
  grid-column: 1;
  grid-row: 2;
  margin-top: 4px;
}

.page-header > :nth-child(2) {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
}

.page-title,
.page-header h1 {
  font-family: var(--font-heading) !important;
  font-size: 28px;
  font-weight: 700 !important;
  letter-spacing: -0.5px;
  line-height: 1;
  margin-top: 0;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.page-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.header-date {
  font-size: 14px;
  color: var(--text-secondary);
  background: var(--bg-card);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-primary {
  background: var(--btn-gradient);
  color: var(--btn-text);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.btn-primary:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: var(--shadow-lg);
  filter: brightness(1.1); /* Slightly brightens the gradient on hover */
}

.btn-primary:active {
  transform: translateY(0);
}

/* Universal click state for ALL buttons to turn into gradient */
.btn:active {
  background: var(--btn-gradient) !important;
  color: var(--btn-text) !important;
  border-color: transparent !important;
  transform: translateY(1px) scale(0.98);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1) !important;
  transition: all 0.05s ease-out; /* Immediate snap into gradient */
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.btn-icon {
  padding: 8px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-active {
  background: var(--btn-gradient) !important;
  color: var(--btn-text) !important;
  border: none !important;
  padding: 11px 21px; /* Compensate for the removed 1px border from btn-secondary */
  box-shadow: var(--shadow-md);
}

.btn-danger {
  background: rgba(251, 113, 133, 0.1);
  color: var(--accent-rose);
  border: 1px solid rgba(251, 113, 133, 0.2);
}

.btn-danger:hover {
  background: rgba(251, 113, 133, 0.2);
}

.btn-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.btn-success:hover {
  background: rgba(16, 185, 129, 0.2);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* ========== STAT CARDS ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 22px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  cursor: default;
}

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

/* Top row: icon + trend indicator */
.stat-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-patients .stat-icon    { background: rgba(56, 189, 248, 0.12);  color: var(--accent); box-shadow: 0 0 0 6px rgba(56,189,248,0.06); }
.stat-appointments .stat-icon { background: rgba(52, 211, 153, 0.12); color: var(--accent-green); box-shadow: 0 0 0 6px rgba(52,211,153,0.06); }
.stat-revenue .stat-icon      { background: rgba(251, 191, 36, 0.12); color: var(--accent-amber); box-shadow: 0 0 0 6px rgba(251,191,36,0.06); }
.stat-pending .stat-icon      { background: rgba(167, 139, 250, 0.12); color: var(--accent-purple); box-shadow: 0 0 0 6px rgba(167,139,250,0.06); }

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-number {
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.1;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-top: 2px;
}

/* ========== DASHBOARD GRID ========== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 4px;
}

/* ========== CARDS ========== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-body {
  padding: 20px 24px;
  max-height: 400px;
  overflow-y: auto;
}

/* ========== EMPTY STATE ========== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  gap: 12px;
}

.empty-state.large {
  padding: 80px 20px;
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 14px;
  max-width: 300px;
}

/* ========== SEARCH BAR ========== */
.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  margin-bottom: 24px;
  transition: border-color var(--transition-fast);
}

.search-bar:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

.search-bar svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-bar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

/* ========== PATIENT LIST ========== */
.patients-list {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 400px;
}

.patient-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

@media (min-width: 640px) {
  .patient-card {
    padding: 20px 24px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }
}

.patient-card:hover {
  border-color: rgba(56, 189, 248, 0.2);
  background: var(--bg-card-hover);
  transform: translateX(4px);
}

.patient-main {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.patient-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: white;
  flex-shrink: 0;
}

.patient-details {
  flex: 1;
  min-width: 0;
}

.patient-name {
  font-family: 'Inter', sans-serif !important;
  font-weight: 400 !important;
  font-size: 17px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.patient-meta {
  display: flex;
  gap: 16px;
  margin-top: 2px;
  flex-wrap: wrap;
}

.patient-meta span {
  font-family: 'Inter', sans-serif !important;
  font-weight: 400 !important;
  font-size: 14px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.patient-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-self: flex-end;
}

/* ========== APPOINTMENT LIST ========== */
.appointment-controls {
  margin-bottom: 24px;
}

.date-navigator {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.date-input {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color var(--transition-fast);
  min-width: 220px;
}

.date-input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.date-input::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

.appointments-list {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 400px;
}

.appointment-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.appointment-card:hover {
  border-color: rgba(56, 189, 248, 0.2);
  background: var(--bg-card-hover);
}

.appt-time {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  min-width: 80px;
  flex-shrink: 0;
}

.appt-info {
  flex: 1;
  min-width: 0;
}

.appt-patient-name {
  font-weight: 700;
  font-size: 17px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.appt-type {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-top: 2px;
}

.appt-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.status-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: color-mix(in srgb, currentColor 12%, transparent);
}

.status-scheduled {
  color: var(--accent);
}

.status-completed {
  color: var(--accent-green);
}

.status-cancelled {
  color: var(--accent-rose);
}

.status-noshow {
  color: var(--accent-amber);
}

/* ========== PAYMENTS TABLE ========== */
.table-responsive, .payments-table-wrap, .table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

.payments-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.payments-table thead {
  background: rgba(56, 189, 248, 0.05);
}

.payments-table th {
  padding: 14px 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.payments-table td {
  padding: 14px 20px;
  font-size: 14px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.payments-table tr:last-child td {
  border-bottom: none;
}

.payments-table tbody tr {
  transition: background var(--transition-fast);
}

.payments-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.amount-paid { color: var(--accent-green); font-weight: 600; }
.amount-pending { color: var(--accent-rose); font-weight: 600; }
.amount-total { color: var(--text-primary); font-weight: 600; }

/* ========== OVERLAY ========== */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

/* ========== MODALS ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.show {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-body {
  overflow-y: auto;
  scrollbar-width: none;
  flex-grow: 1;
  padding: 24px 28px;
}

.modal-body::-webkit-scrollbar {
  display: none;
}

.add-visit-mode #patientVisitDate {
  max-width: 220px;
}

.modal-lg {
  max-width: 720px;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 28px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 24px 28px;
  border-top: 1px solid var(--border);
}

/* ========== DOWNLOAD FILTER ========== */
.download-filter-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.15);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  margin-top: 4px;
}

.download-filter-info svg {
  color: var(--accent);
  flex-shrink: 0;
}

.download-filter-info span {
  font-weight: 700;
  color: var(--accent);
}

/* ========== FORMS ========== */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.form-row .form-group {
  margin-bottom: 0;
}

.form-group {
  margin-bottom: 20px;
}

.add-visit-mode .hide-on-visit {
  display: none !important;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-group select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 40px;
}

input[type="date"],
input[type="month"] {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 40px;
  position: relative;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
  position: absolute;
  right: 0;
  top: 0;
  width: 40px;
  height: 100%;
  margin: 0;
  padding: 0;
  opacity: 0;
  cursor: pointer;
}

.form-group textarea {
  resize: vertical;
}

/* Flatpickr Theme Overrides - Comprehensive Aesthetic Enhancement */
.flatpickr-calendar {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow-lg) !important;
  border-radius: var(--radius-md) !important;
  padding: 10px !important;
  font-family: inherit !important;
  width: 340px !important; /* Wide enough to fit the custom margin on days */
}
.flatpickr-calendar.hasTime {
  width: 340px !important; 
}
.flatpickr-innerContainer {
  width: 100% !important;
}
.flatpickr-rContainer {
  width: 100% !important;
}
.flatpickr-days {
  width: 100% !important;
}
.dayContainer {
  width: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
}
.flatpickr-calendar::before, .flatpickr-calendar::after {
  display: none !important; /* Removes the ugly default triangle arrow */
}

/* Headers */
.flatpickr-months .flatpickr-month {
  background: transparent !important;
  color: var(--text-primary) !important;
  fill: var(--text-primary) !important;
}
.flatpickr-current-month .flatpickr-monthDropdown-months {
  appearance: none !important;
  -webkit-appearance: none !important;
  background-color: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  padding: 4px 28px 4px 10px !important;
  margin: 0 4px !important;
  font-family: inherit !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  transition: all var(--transition-fast) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 8px center !important;
  background-size: 14px !important;
}
.flatpickr-current-month .flatpickr-monthDropdown-months:hover {
  border-color: var(--accent-1) !important;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1) !important;
}
.flatpickr-current-month .flatpickr-monthDropdown-months:focus {
  border-color: var(--accent-1) !important;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2) !important;
  outline: none !important;
}
.flatpickr-current-month input.cur-year {
  display: none !important; /* Hide native year input completely, as it is replaced by our JS dropdown */
}

/* Arrows */
.flatpickr-prev-month, .flatpickr-next-month {
  color: var(--text-secondary) !important;
  fill: var(--text-secondary) !important;
}
.flatpickr-prev-month:hover, .flatpickr-next-month:hover {
  color: var(--text-primary) !important;
  fill: var(--text-primary) !important;
}

/* Weekdays */
span.flatpickr-weekday {
  color: var(--text-secondary) !important;
  font-weight: 600 !important;
}

/* Days (Grid) */
.flatpickr-day {
  color: var(--text-primary) !important;
  background: transparent !important;
  border-color: transparent !important;
  border-radius: var(--radius-sm) !important;
  margin: 2px !important;
  transition: all var(--transition-fast) !important;
}
.flatpickr-day:hover, .flatpickr-day:focus {
  background: var(--bg-card-hover) !important;
  border-color: var(--bg-card-hover) !important;
  color: var(--text-primary) !important;
}
.flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay {
  color: var(--text-muted) !important;
}

/* Today */
.flatpickr-day.today {
  border-color: var(--accent-1) !important;
  color: var(--accent-1) !important;
  background: rgba(56, 189, 248, 0.05) !important;
}
.flatpickr-day.today:hover {
  background: rgba(56, 189, 248, 0.1) !important;
}

/* Selected Date Gradient Effect */
.flatpickr-day.selected, 
.flatpickr-day.startRange, 
.flatpickr-day.endRange,
.flatpickr-day.selected:hover,
.flatpickr-monthSelect-month.selected {
  background: var(--btn-gradient) !important;
  border-color: transparent !important;
  color: var(--btn-text) !important;
  font-weight: 600 !important;
  box-shadow: 0 4px 10px rgba(56, 189, 248, 0.3) !important;
  transform: scale(1.05) !important; /* Slight pop effect */
}

/* Month Select Plugin */
.flatpickr-monthSelect-month {
  color: var(--text-primary) !important;
  border-radius: var(--radius-sm) !important;
  transition: all var(--transition-fast) !important;
}
.flatpickr-monthSelect-month:hover {
  background: var(--bg-card-hover) !important;
}
.custom-date-picker-input {
  background-color: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--text-primary) !important;
  font-weight: 500 !important;
  font-size: 15px !important;
  transition: all var(--transition-fast) !important;
  box-shadow: var(--shadow-sm) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 14px center !important;
  padding: 9px 14px !important;
  padding-right: 36px !important;
  width: 160px !important;
  cursor: pointer !important;
}
.custom-date-picker-input:hover {
  border-color: var(--accent-1) !important;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1) !important;
}
.custom-date-picker-input:focus {
  border-color: var(--accent-1) !important;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2) !important;
  outline: none !important;
}

/* Add calendar SVG icon next to the year in the flatpickr popup */
.flatpickr-current-month {
  display: flex !important;
  align-items: center;
  justify-content: center;
}
.flatpickr-current-month::after {
  content: "";
  display: inline-block;
  vertical-align: middle;
  width: 16px;
  height: 16px;
  margin-left: 8px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  flex-shrink: 0;
}

/* Custom Select Dropdown */
.custom-select {
  position: relative;
  width: 100%;
  user-select: none;
}
.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.custom-select-trigger:hover {
  border-color: var(--border-focus);
}
.custom-select.open .custom-select-trigger {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(157, 210, 250, 0.15); /* Using var(--accent-2) basically */
}
.custom-select-options {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-5px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
  max-height: 250px;
  overflow-y: auto;
}

.custom-cb-label:hover {
  background: var(--bg-card-hover);
}

.custom-select.open .custom-select-options {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.custom-option {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.custom-option:last-child {
  border-bottom: none;
}
.custom-option:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}
.custom-option.selected {
  background: rgba(157, 210, 250, 0.15);
  color: var(--text-primary);
  font-weight: 600;
}

/* ========== PATIENT DETAIL ========== */
.detail-section {
  margin-bottom: 24px;
}

.detail-section h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.detail-item {
  padding: 10px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.detail-item.full {
  grid-column: 1 / -1;
}

.detail-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.detail-value {
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
  word-break: break-word;
  white-space: pre-wrap;
}

.detail-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ========== TOAST ========== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: white;
  box-shadow: var(--shadow-md);
  animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast-success { background: linear-gradient(135deg, #059669, #34d399); }
.toast-error { background: linear-gradient(135deg, #e11d48, #fb7185); }
.toast-info { background: linear-gradient(135deg, #2563eb, #38bdf8); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
  to { opacity: 0; transform: translateX(40px); }
}

/* ========== SCHEDULE ITEM (Dashboard) ========== */
.schedule-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.schedule-item:last-child {
  border-bottom: none;
}

.schedule-time {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  min-width: 70px;
}

.schedule-info {
  flex: 1;
}

.schedule-patient {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}

.schedule-type {
  font-size: 12px;
  color: var(--text-muted);
}

/* Recent patient item */
.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.recent-item:last-child {
  border-bottom: none;
}

.recent-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(157, 210, 250, 0.1);
  border: 1px solid rgba(157, 210, 250, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--brand-highlight);
  transition: background 0.2s ease;
}

.recent-item:hover .recent-avatar {
  background: rgba(157, 210, 250, 0.18);
  border-color: rgba(157, 210, 250, 0.35);
}

.recent-info {
  flex: 1;
}

.recent-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-condition {
  font-size: 12px;
  color: var(--text-muted);
}

/* ========== WISHLIST ========== */
.wishlist-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  padding: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  scrollbar-width: none;
}

.wishlist-tabs::-webkit-scrollbar {
  display: none;
}

.wishlist-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  position: relative;
}

.wishlist-tab:hover {
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-primary);
}

.wishlist-tab.active {
  background: rgba(56, 189, 248, 0.1);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.tab-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-endo { background: #f472b6; }
.dot-oral-surgery { background: #fb923c; }
.dot-pedo { background: #a78bfa; }
.dot-perio { background: #34d399; }
.dot-ortho { background: #38bdf8; }
.dot-prostho { background: #fbbf24; }
.dot-dental-implants { background: #818cf8; }

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-muted);
}

.wishlist-tab.active .tab-count {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent);
}

.wishlist-tab[data-category="Endo"].active { background: rgba(244, 114, 182, 0.1); }
.wishlist-tab[data-category="Endo"].active .tab-count { background: rgba(244, 114, 182, 0.2); color: #f472b6; }

.wishlist-tab[data-category="Oral Surgery"].active { background: rgba(251, 146, 60, 0.1); }
.wishlist-tab[data-category="Oral Surgery"].active .tab-count { background: rgba(251, 146, 60, 0.2); color: #fb923c; }

.wishlist-tab[data-category="Pedo"].active { background: rgba(167, 139, 250, 0.1); }
.wishlist-tab[data-category="Pedo"].active .tab-count { background: rgba(167, 139, 250, 0.2); color: #a78bfa; }

.wishlist-tab[data-category="Perio"].active { background: rgba(52, 211, 153, 0.1); }
.wishlist-tab[data-category="Perio"].active .tab-count { background: rgba(52, 211, 153, 0.2); color: #34d399; }

.wishlist-tab[data-category="Ortho"].active { background: rgba(56, 189, 248, 0.1); }
.wishlist-tab[data-category="Ortho"].active .tab-count { background: rgba(56, 189, 248, 0.2); color: #38bdf8; }

.wishlist-tab[data-category="Prostho"].active { background: rgba(251, 191, 36, 0.1); }
.wishlist-tab[data-category="Prostho"].active .tab-count { background: rgba(251, 191, 36, 0.2); color: #fbbf24; }

.wishlist-tab[data-category="Dental Implants"].active { background: rgba(129, 140, 248, 0.1); }
.wishlist-tab[data-category="Dental Implants"].active .tab-count { background: rgba(129, 140, 248, 0.2); color: #818cf8; }

.wishlist-list {
  display: grid;
  gap: 12px;
}

.wishlist-card {
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  border-color: rgba(255, 255, 255, 0.15);
}

.wishlist-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 0 3px 3px 0;
}

.wishlist-card.cat-endo::before { background: #f472b6; }
.wishlist-card.cat-oral-surgery::before { background: #fb923c; }
.wishlist-card.cat-pedo::before { background: #a78bfa; }
.wishlist-card.cat-perio::before { background: #34d399; }
.wishlist-card.cat-ortho::before { background: #38bdf8; }
.wishlist-card.cat-prostho::before { background: #fbbf24; }
.wishlist-card.cat-dental-implants::before { background: #818cf8; }

.wishlist-card:hover {
  border-color: rgba(148, 163, 184, 0.2);
  background: var(--bg-card-hover);
  transform: translateX(4px);
}

.wishlist-avatar {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: rgba(157, 210, 250, 0.1);
  border: 1px solid rgba(157, 210, 250, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--brand-highlight);
  transition: background 0.2s ease;
}

.cat-endo .wishlist-avatar        { background: rgba(244,114,182,0.1); border-color: rgba(244,114,182,0.22); color: #f472b6; }
.cat-oral-surgery .wishlist-avatar{ background: rgba(251,146,60,0.1);  border-color: rgba(251,146,60,0.22);  color: #fb923c; }
.cat-pedo .wishlist-avatar        { background: rgba(167,139,250,0.1); border-color: rgba(167,139,250,0.22); color: #a78bfa; }
.cat-perio .wishlist-avatar       { background: rgba(52,211,153,0.1);  border-color: rgba(52,211,153,0.22);  color: #34d399; }
.cat-ortho .wishlist-avatar       { background: rgba(56,189,248,0.1);  border-color: rgba(56,189,248,0.22);  color: #38bdf8; }
.cat-prostho .wishlist-avatar     { background: rgba(251,191,36,0.1);  border-color: rgba(251,191,36,0.22);  color: #fbbf24; }
.cat-dental-implants .wishlist-avatar { background: rgba(129,140,248,0.1); border-color: rgba(129,140,248,0.22); color: #818cf8; }

.wishlist-details {
  flex: 1;
  min-width: 0;
}

.wishlist-patient-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wishlist-meta {
  display: flex;
  gap: 12px;
  margin-top: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.wishlist-meta span {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.wishlist-note {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wishlist-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: center;
}


/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    left: 0;
    top: 0;
    bottom: 0;
    border-radius: 0;
    z-index: 1000;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.show {
    display: block;
    opacity: 1;
  }

  .mobile-header {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding: 80px 16px 32px;
  }

  .page-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  
  .page-header > div:first-child {
    display: block;
    flex: 1 1 100%; /* Take full width so buttons wrap, OR let it auto size */
    /* Actually, to keep them on the same line if possible, just flex: 1; min-width: 200px; */
    flex: 1;
    min-width: 200px;
  }

  .page-header-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }
  .desktop-only {
    display: none !important;
  }

  .page-subtitle {
    font-size: 13px;
    line-height: 1.4;
    margin-top: 4px;
  }

  .page-title,
  .page-header h1 {
    font-size: 24px;
    font-weight: 700 !important;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .stat-card {
    padding: 16px 18px 14px;
    gap: 10px;
  }

  .stat-number {
    font-size: clamp(18px, 5vw, 24px);
  }

  .stat-icon {
    width: 40px;
    height: 40px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    margin: 0;
    border-radius: 24px 24px 0 0;
    max-height: 95vh;
    height: auto;
    border: none;
    animation: slideUpSheet 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  @keyframes slideUpSheet {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .patient-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .patient-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 16px;
  }

  .appointment-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .appt-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 16px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .wishlist-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .wishlist-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 16px;
  }
  
  .btn-sm {
    padding: 10px 16px;
    font-size: 14px;
  }
  
  .inventory-grid {
    grid-template-columns: 1fr;
  }

  .bar-chart-container {
    min-width: 500px;
  }

  .chart-container-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .auth-card {
    padding: 32px 24px;
    margin: auto;
    width: 100%;
  }

  .date-navigator {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    align-items: center;
  }

  .date-navigator .btn-secondary {
    grid-column: 1 / -1;
    text-align: center;
  }
}

/* ========== AUTH GATE ========== */
.auth-gate {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 40px 16px;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.auth-gate.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

html.optimistic-unlock .auth-gate {
  display: none !important;
}

.auth-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 1;
}

.auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  animation: authFloatOrb 10s infinite ease-in-out alternate;
}

.auth-orb-1 {
  width: 400px;
  height: 400px;
  background: rgba(37, 99, 235, 0.15);
  top: -100px;
  left: -100px;
}

.auth-orb-2 {
  width: 300px;
  height: 300px;
  background: rgba(16, 185, 129, 0.15);
  bottom: -50px;
  right: -50px;
  animation-delay: -5s;
}

@keyframes authFloatOrb {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, 30px) scale(1.1); }
}

.auth-card {
  position: relative;
  z-index: 2;
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px;
  width: 100%;
  max-width: 440px;
  margin: auto;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2), var(--shadow-glow);
  animation: authSlideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.auth-card.hidden {
  display: none !important;
}

@keyframes authSlideUpFade {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-brand {
  text-align: center;
  margin-bottom: 24px;
}

.auth-tooth {
  font-size: 48px;
  margin-bottom: 8px;
  display: inline-flex;
  filter: drop-shadow(0 0 16px rgba(59, 130, 246, 0.5));
}

.auth-brand h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.auth-tagline {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.auth-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 8px;
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form.hidden {
  display: none;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.auth-field input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  transition: all 0.2s ease;
}

.auth-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
  background: var(--bg-card);
}

.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-toggle {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

.password-toggle:hover {
  color: var(--accent);
}

.auth-field input[type="password"] {
  padding-right: 44px;
}

.auth-field input::placeholder {
  color: var(--text-secondary);
}

.auth-btn {
  margin-top: 4px;
  padding: 12px;
  font-size: 15px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--btn-text);
  box-shadow: 0 4px 15px var(--accent-glow);
  width: 100%;
  justify-content: center;
  border: none;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.auth-btn:hover {
  box-shadow: 0 6px 20px var(--accent-glow);
  transform: translateY(-2px);
}

.auth-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  margin-bottom: 0px;
}

.auth-switch a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  margin-left: 4px;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.auth-error {
  color: #ef4444;
  font-size: 13px;
  font-weight: 500;
  background: rgba(239, 68, 68, 0.1);
  padding: 10px 14px;
  border-radius: 8px;
  display: none;
}

.auth-error.show {
  display: block;
  animation: authShake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes authShake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

.auth-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-left-color: var(--accent);
  border-radius: 50%;
  animation: authSpin 1s linear infinite;
  margin: 0 auto 20px;
}

.auth-loading-text {
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 500;
}

@keyframes authSpin {
  to { transform: rotate(360deg); }
}

/* Sidebar Button overrides for hidden elements */
.nav-btn.hidden {
  display: none !important;
}

/* ========== THEME TOGGLE ICON ========== */
.theme-icon {
  width: 18px;
  height: 18px;
}
.theme-mask, .theme-circle, .theme-rays {
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: center;
}
.theme-mask {
  transform: translate(0, 0);
}
.theme-circle {
  r: 8px;
}
.theme-rays {
  transform: scale(1);
  opacity: 1;
}

body.dark-mode .theme-mask {
  transform: translate(-11px, 14px);
}
body.dark-mode .theme-circle {
  r: 10px;
}
body.dark-mode .theme-rays {
  transform: scale(0.5);
  opacity: 0;
}

/* (Removed native calendar invert since we use a custom SVG globally) */
.hidden { display: none !important; }

/* Theme-aware Logo Image */
.auth-logo { width: 170px; height: 170px; object-fit: contain; padding: 12px 12px 0 12px; margin-bottom: -12px; box-sizing: border-box; mix-blend-mode: normal; filter: drop-shadow(0 4px 16px rgba(59, 130, 246, 0.4)); }
.sidebar-logo { width: 100px; height: 100px; object-fit: contain; padding: 2px; box-sizing: border-box; flex-shrink: 0; }

.logo-dark { display: none; mix-blend-mode: screen; }
.logo-light { display: block; mix-blend-mode: multiply; }

.dark-mode .logo-light { display: none !important; }
.dark-mode .logo-dark { display: block !important; }

/* ==================== ANALYTICS CHART ==================== */
.bar-chart-container {
  display: flex;
  height: 250px;
  position: relative;
  padding-left: 66px;
  margin-top: 20px;
}
.y-axis {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 30px;
  width: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  border-right: 1px solid var(--border);
  padding-right: 10px;
  align-items: flex-end;
}
.chart-area {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  flex: 1;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 30px;
}
.bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  width: 60px;
  position: relative;
}
.bar {
  width: 100%;
  background: var(--nav-active);
  border-radius: 6px 6px 0 0;
  position: relative;
  transition: all var(--transition-normal);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 8px;
  box-shadow: var(--shadow-glow);
}
.bar:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}
.bar-label {
  color: #0f172a;
  font-weight: 800;
  font-size: 14px;
  text-shadow: 0px 1px 2px rgba(255,255,255,0.4);
}
body.dark-mode .bar-label {
  color: #ffffff;
  text-shadow: 0px 1px 3px rgba(0,0,0,0.7);
}
.x-label {
  position: absolute;
  bottom: -30px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

/* ==================== INVENTORY ROWS ==================== */
.inventory-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.inventory-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.inventory-item:hover {
  border-color: var(--nav-active);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
.inventory-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
}
.inventory-label {
  flex: 1;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 15px;
}
.currency-symbol {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 18px;
  z-index: 2;
  pointer-events: none;
}
.inventory-input {
  padding-left: 28px !important;
  font-weight: 700;
  font-size: 20px;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid transparent;
  border-radius: 8px;
  transition: all 0.2s;
  width: 140px;
  outline: none !important;
  box-shadow: none !important;
}
.inventory-input::-webkit-outer-spin-button,
.inventory-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.inventory-input[type=number] {
  -moz-appearance: textfield;
}
.inventory-input:hover {
  background: var(--bg-body);
}
.inventory-input:focus {
  background: var(--bg-body);
  border-color: var(--nav-active);
}
.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  font-size: 14px;
}
.btn-icon-only {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.btn-icon-only:hover {
  background: rgba(239, 68, 68, 0.1);
}

.analytics-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

/* ========== DOWNLOAD REPORT DROPDOWN ========== */
.download-report-dropdown {
  position: relative;
  flex-shrink: 0;
}

.download-report-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 260px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  z-index: 200;
  animation: fadeInUp 0.2s ease;
}

.download-report-panel.open {
  display: block;
}

.download-panel-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.download-panel-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}


.download-panel-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.download-panel-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

/* ========== SETTINGS DROPDOWN ========== */
.settings-dropdown-panel {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  width: 220px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.settings-dropdown-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.settings-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.settings-menu-item:hover {
  background: var(--bg-card-hover);
  color: var(--brand-highlight);
}
.settings-menu-item svg {
  color: var(--text-secondary);
  transition: color 0.15s ease;
}
.settings-menu-item:hover svg {
  color: var(--brand-highlight);
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}
/* ==================== INVENTORY ROWS ==================== */
.inventory-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.inventory-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.inventory-item:hover {
  border-color: var(--nav-active);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
.inventory-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
}
.inventory-label {
  flex: 1;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 15px;
}
.currency-symbol {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 18px;
  z-index: 2;
  pointer-events: none;
}
.inventory-input {
  padding-left: 28px !important;
  font-weight: 700;
  font-size: 20px;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid transparent;
  border-radius: 8px;
  transition: all 0.2s;
  width: 140px;
  outline: none !important;
  box-shadow: none !important;
}
.inventory-input::-webkit-outer-spin-button,
.inventory-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.inventory-input[type=number] {
  -moz-appearance: textfield;
}
.inventory-input:hover {
  background: var(--bg-body);
}
.inventory-input:focus {
  background: var(--bg-body);
  border-color: var(--nav-active);
}
.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  font-size: 14px;
}
.btn-icon-only {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.btn-icon-only:hover {
  background: rgba(239, 68, 68, 0.1);
}

.analytics-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

/* ========== DOWNLOAD REPORT DROPDOWN ========== */
.download-report-dropdown {
  position: relative;
  flex-shrink: 0;
}

.download-report-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 260px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  z-index: 200;
  animation: fadeInUp 0.2s ease;
}

.download-report-panel.open {
  display: block;
}

.download-panel-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.download-panel-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  margin-bottom: 30px;
}
.bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  width: 60px;
  position: relative;
}
.bar {
  width: 100%;
  background: var(--nav-active);
  border-radius: 6px 6px 0 0;
  position: relative;
  transition: all var(--transition-normal);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 8px;
  box-shadow: var(--shadow-glow);
}
.bar:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}
.bar-label {
  color: #0f172a;
  font-weight: 800;
  font-size: 14px;
  text-shadow: 0px 1px 2px rgba(255,255,255,0.4);
}
body.dark-mode .bar-label {
  color: #ffffff;
  text-shadow: 0px 1px 3px rgba(0,0,0,0.7);
}
.x-label {
  position: absolute;
  bottom: -30px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

/* ==================== INVENTORY ROWS ==================== */
.inventory-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.inventory-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-body);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.inventory-item:hover {
  border-color: var(--nav-active);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
.inventory-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
}
.inventory-label {
  flex: 1;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 15px;
}
.currency-symbol {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 18px;
  z-index: 2;
  pointer-events: none;
}
.inventory-input {
  padding-left: 28px !important;
  font-weight: 700;
  font-size: 20px;
  color: var(--text-primary);
  background: var(--bg-card);
  border: 1px solid transparent;
  border-radius: 8px;
  transition: all 0.2s;
  width: 140px;
  outline: none !important;
  box-shadow: none !important;
}
.inventory-input::-webkit-outer-spin-button,
.inventory-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.inventory-input[type=number] {
  -moz-appearance: textfield;
}
.inventory-input:hover {
  background: var(--bg-body);
}
.inventory-input:focus {
  background: var(--bg-body);
  border-color: var(--nav-active);
}
.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  font-size: 14px;
}
.btn-icon-only {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.btn-icon-only:hover {
  background: rgba(239, 68, 68, 0.1);
}

.analytics-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

/* ========== DOWNLOAD REPORT DROPDOWN ========== */
.download-report-dropdown {
  position: relative;
  flex-shrink: 0;
}

.download-report-panel {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 260px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  z-index: 200;
  animation: fadeInUp 0.2s ease;
}

.download-report-panel.open {
  display: block;
}

.download-panel-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.download-panel-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 4px;
}

.download-panel-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.download-panel-divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

/* ========== SETTINGS DROPDOWN ========== */
.settings-dropdown-panel {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.settings-dropdown-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.settings-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.settings-menu-item:hover {
  background: var(--bg-card-hover);
  color: var(--brand-highlight);
}
.settings-menu-item svg {
  color: var(--text-secondary);
  transition: color 0.15s ease;
}
.settings-menu-item:hover svg {
  color: var(--brand-highlight);
}

/* Ensure mobile overrides happen at the very end of the file */
@media (max-width: 768px) {
  .analytics-grid,
  .inventory-grid {
    grid-template-columns: 1fr;
  }
}

/* ========== ANALYTICS CONTROLS ========== */
.analytics-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
  min-width: 0; /* Prevents flex blowout on mobile */
  width: 100%;
}

.analytics-date-block {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.analytics-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}

.analytics-filters::-webkit-scrollbar {
  display: none;
}

.analytics-filters .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .analytics-controls {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .analytics-date-block {
    width: auto;
  }
  .analytics-filters {
    width: auto;
    overflow-x: visible;
    padding-bottom: 0;
  }
}

/* Revenue Stat Gold Glow */
.stat-revenue .stat-number {
  color: #fbbf24 !important;
  text-shadow: 0 0 20px rgba(251, 191, 36, 0.6) !important;
}
.stat-revenue .stat-icon {
  color: #fbbf24 !important;
  background: rgba(251, 191, 36, 0.1) !important;
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.4) !important;
}

/* ========== AREA ANALYTICS TABLES ========== */
.area-tables-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 24px;
}

.area-table-card {
  margin-top: 0;
  overflow: hidden;
}

.area-card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.area-card-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.area-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.area-icon-top {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}

.area-icon-least {
  background: rgba(239, 68, 68, 0.1);
  color: var(--accent-rose);
}

.area-card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin: 2px 0 0 0;
  font-weight: 400;
}

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

.area-th {
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  background: rgba(56, 189, 248, 0.04);
  white-space: nowrap;
}

.area-th.rank-col {
  width: 40px;
  text-align: center;
}

.area-th.count-col {
  text-align: right;
  width: 90px;
}

.area-table tbody tr {
  transition: background var(--transition-fast);
}

.area-table tbody tr:hover {
  background: var(--bg-card-hover);
}

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

.area-table td {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.area-rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-hover);
  color: var(--text-muted);
  margin: 0 auto;
}

.area-rank-badge.rank-1 { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.area-rank-badge.rank-2 { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }
.area-rank-badge.rank-3 { background: rgba(180, 120, 60, 0.15); color: #b47840; }

.area-count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  float: right;
}

.area-count-pill.pill-top {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}

.area-count-pill.pill-least {
  background: rgba(239, 68, 68, 0.08);
  color: var(--accent-rose);
}

.area-name-cell {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
}

.area-empty-cell {
  text-align: center;
  padding: 32px 20px !important;
  color: var(--text-muted);
  font-size: 13px;
  border-bottom: none !important;
}

@media (max-width: 768px) {
  .area-tables-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .area-th, .area-table td {
    padding: 10px 12px;
  }
}

/* ============================================================
   DEEP INSIGHTS — REPORT SECTION COMPONENTS
   ============================================================ */

/* Section Divider */
.rpt-section-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 32px 0 24px;
}
.rpt-divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}
.rpt-divider-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  white-space: nowrap;
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-card);
}

/* Grid Layouts */
.rpt-three-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.rpt-two-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 32px;
}
.rpt-asymmetric {
  grid-template-columns: 3fr 2fr;
}
.rpt-full-row {
  margin-bottom: 20px;
}
.rpt-full-row .card {
  margin-top: 0;
}

/* Base rpt-card */
.rpt-card {
  margin-top: 0;
  overflow: hidden;
  position: relative;
  border-radius: var(--radius-lg);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.rpt-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Colored top-border accent strips */
.rpt-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.rpt-card-accent-blue::before  { background: linear-gradient(90deg, #38bdf8, #0ea5e9); }
.rpt-card-accent-amber::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.rpt-card-accent-purple::before{ background: linear-gradient(90deg, #8b5cf6, #a78bfa); }
.rpt-card-accent-red::before   { background: linear-gradient(90deg, #dc2626, #f87171); }
.rpt-card-accent-green::before { background: linear-gradient(90deg, #059669, #34d399); }

/* Card Header */
.rpt-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--border);
}

/* Icon badge */
.rpt-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.rpt-icon-blue   { background: rgba(56, 189, 248, 0.12);  color: #38bdf8; }
.rpt-icon-amber  { background: rgba(245, 158, 11, 0.12);  color: #f59e0b; }
.rpt-icon-purple { background: rgba(139, 92, 246, 0.12);  color: #8b5cf6; }
.rpt-icon-red    { background: rgba(220, 38, 38,  0.10);  color: #dc2626; }
.rpt-icon-green  { background: rgba(5,  150, 105, 0.12);  color: #059669; }

/* Subtitle */
.rpt-card-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin: 3px 0 0;
  font-weight: 400;
  line-height: 1.4;
}

/* Card Body */
.rpt-card-body {
  padding: 20px 22px;
}

/* Progress bar row */
.rpt-bar-row { margin-bottom: 16px; }
.rpt-bar-row:last-child { margin-bottom: 0; }
.rpt-bar-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.rpt-bar-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.rpt-bar-badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 20px;
}
.rpt-bar-track {
  height: 9px;
  background: var(--bg-secondary);
  border-radius: 6px;
  overflow: hidden;
}
.rpt-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Day-row for peak days */
.rpt-day-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.rpt-day-row:last-child { margin-bottom: 0; }
.rpt-day-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  width: 86px;
  flex-shrink: 0;
}
.rpt-day-track {
  flex: 1;
  height: 10px;
  background: var(--bg-secondary);
  border-radius: 6px;
  overflow: hidden;
}
.rpt-day-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}
.rpt-day-count {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  width: 26px;
  text-align: right;
}

/* Stat boxes (retention) */
.rpt-stat-box {
  flex: 1;
  border-radius: 14px;
  padding: 18px 16px;
  text-align: center;
  border: 1px solid transparent;
}
.rpt-stat-number {
  font-size: 32px;
  font-weight: 800;
  font-family: 'Poppins', sans-serif;
  line-height: 1.1;
  margin-bottom: 2px;
}
.rpt-stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
}
.rpt-stat-pct {
  font-size: 13px;
  font-weight: 700;
  margin-top: 6px;
}

@media (max-width: 1024px) {
  .rpt-three-grid {
    grid-template-columns: 1fr 1fr;
  }
  .rpt-asymmetric {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 768px) {
  .rpt-three-grid,
  .rpt-two-grid,
  .rpt-asymmetric {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .rpt-card-header {
    padding: 14px 16px 12px;
  }
  .rpt-card-body {
    padding: 16px;
  }
}

/* ============================================================
   COMPREHENSIVE RESPONSIVE OPTIMIZATION
   Breakpoints: 1400px | 1200px | 1024px | 768px | 480px | 360px
   ============================================================ */

/* ── Large Desktops (1400px+) ── */
@media (min-width: 1400px) {
  .rpt-three-grid {
    gap: 24px;
  }
  .rpt-card-header {
    padding: 20px 26px 18px;
  }
  .rpt-card-body {
    padding: 22px 26px;
  }
  .card-header {
    padding: 22px 28px;
  }
  .card-body {
    padding: 22px 28px;
  }
}

/* ── Standard Desktops (1200px) ── */
@media (max-width: 1200px) {
  .rpt-three-grid {
    grid-template-columns: 1fr 1fr;
    gap: 18px;
  }
  .rpt-asymmetric {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Small Laptops / Large Tablets (1024px) ── */
@media (max-width: 1024px) {
  /* Stats */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 24px;
  }
  .stat-card {
    padding: 18px 20px 16px;
    gap: 12px;
  }
  .stat-number {
    font-size: clamp(20px, 4vw, 28px);
  }

  /* Analytics bar chart + pie */
  .analytics-grid {
    grid-template-columns: 3fr 2fr;
    gap: 18px;
  }

  /* Area tables */
  .area-tables-grid {
    grid-template-columns: 1fr 1fr;
    gap: 18px;
  }

  /* New report grids */
  .rpt-three-grid {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .rpt-two-grid {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .rpt-asymmetric {
    grid-template-columns: 1fr 1fr;
  }
  .rpt-card-header {
    padding: 16px 20px 14px;
    gap: 12px;
  }
  .rpt-card-body {
    padding: 18px 20px;
  }
  .rpt-card-icon {
    width: 34px;
    height: 34px;
  }

  /* Section divider */
  .rpt-section-divider {
    margin: 24px 0 18px;
  }
}

/* ── Tablets (768px) ── */
@media (max-width: 768px) {
  /* Stats — 2 columns on tablet */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
  }
  .stat-card {
    padding: 16px 16px 14px;
    gap: 10px;
  }
  .stat-number {
    font-size: clamp(18px, 5vw, 26px);
  }
  .stat-icon {
    width: 38px;
    height: 38px;
  }

  /* Dashboard grid */
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* Bar chart + pie — stack */
  .analytics-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* Area tables — stack */
  .area-tables-grid {
    grid-template-columns: 1fr;
    gap: 14px;
    margin-top: 16px;
  }
  .area-th, .area-table td {
    padding: 10px 12px;
    font-size: 13px;
  }

  /* New report grids — all single column */
  .rpt-three-grid,
  .rpt-two-grid,
  .rpt-asymmetric {
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 14px;
  }
  .rpt-full-row {
    margin-bottom: 14px;
  }
  .rpt-card-header {
    padding: 14px 16px 12px;
    gap: 10px;
  }
  .rpt-card-body {
    padding: 16px;
  }
  .rpt-card-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }
  .rpt-divider-label {
    font-size: 10px;
    padding: 4px 12px;
  }
  .rpt-section-divider {
    margin: 20px 0 16px;
  }

  /* Card defaults */
  .card-header {
    padding: 16px 18px;
  }
  .card-body {
    padding: 16px 18px;
  }

  /* Bar chart */
  .bar-chart-container {
    min-width: 480px;
  }
  .chart-container-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Pie chart card */
  #patientPieChart {
    width: 140px !important;
    height: 140px !important;
  }
}

/* ── Mobile Phones (480px) ── */
@media (max-width: 480px) {
  /* Stats — keep 2 cols but tighter */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
  }
  .stat-card {
    padding: 14px 14px 12px;
    gap: 8px;
    border-radius: 14px;
  }
  .stat-number {
    font-size: clamp(16px, 6vw, 22px);
    letter-spacing: -0.5px;
  }
  .stat-label {
    font-size: 10px;
    letter-spacing: 0.4px;
  }
  .stat-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  /* Pie chart */
  #patientPieChart {
    width: 120px !important;
    height: 120px !important;
  }

  /* New report cards — compact on phones */
  .rpt-card-header {
    padding: 12px 14px 10px;
    gap: 9px;
  }
  .rpt-card-body {
    padding: 14px;
  }
  .rpt-card-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }
  .rpt-card-icon svg {
    width: 14px;
    height: 14px;
  }
  .rpt-card-sub {
    font-size: 10px;
  }
  .card-title {
    font-size: 13px;
  }

  /* Area tables */
  .area-th {
    font-size: 10px;
    padding: 8px 10px;
  }
  .area-table td {
    padding: 10px;
    font-size: 12px;
  }
  .area-rank-badge {
    width: 22px;
    height: 22px;
    font-size: 10px;
  }
  .area-count-pill {
    font-size: 11px;
    padding: 2px 8px;
    min-width: 26px;
  }

  /* Section divider */
  .rpt-section-divider {
    margin: 16px 0 12px;
    gap: 10px;
  }
  .rpt-divider-label {
    font-size: 9px;
    padding: 4px 10px;
    letter-spacing: 0.8px;
  }

  /* Analytics controls */
  .analytics-filters .btn {
    padding: 8px 12px;
    font-size: 12px;
  }
}

/* ── Very Small Phones (360px) ── */
@media (max-width: 360px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .stat-card {
    padding: 12px 12px 10px;
  }
  .stat-number {
    font-size: 16px;
  }
  .stat-icon {
    width: 30px;
    height: 30px;
  }
  .rpt-card-header {
    padding: 10px 12px 8px;
  }
  .rpt-card-body {
    padding: 12px;
  }
  .card-header {
    padding: 12px 14px;
  }
  .card-body {
    padding: 12px 14px;
  }
}

/* ============================================================
   FULL SITE MOBILE OPTIMIZATION — Final Pass
   All sections: Dashboard · Patients · Appointments ·
   Payments · Analytics · Modals · Cards
   ============================================================ */

/* ─── Shared: fluid padding for page sections on mobile ─── */
@media (max-width: 768px) {

  /* ── Layout ── */
  .main-content {
    padding: 76px 12px 40px;
  }
  .page-header {
    margin-bottom: 20px;
  }
  .page-title, .page-header h1 {
    font-size: 22px;
  }
  .page-subtitle {
    font-size: 12px;
  }
  .page-header-actions {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* ── Buttons ── */
  .btn {
    padding: 9px 16px;
    font-size: 13px;
  }
  .btn-sm {
    padding: 7px 12px;
    font-size: 12px;
  }

  /* ── Patient Cards ── */
  .patient-card {
    padding: 14px;
    gap: 10px;
    flex-direction: column;
    align-items: flex-start;
  }
  .patient-main {
    gap: 12px;
    width: 100%;
  }
  .patient-avatar {
    width: 40px;
    height: 40px;
    font-size: 15px;
  }
  .patient-name {
    font-size: 15px;
  }
  .patient-meta {
    gap: 10px;
    margin-top: 3px;
  }
  .patient-meta span {
    font-size: 12px;
  }
  .patient-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 10px;
  }

  /* ── Search + Filter bar ── */
  .search-filter-bar,
  .controls-row {
    flex-direction: column;
    gap: 10px;
  }
  .search-box {
    width: 100%;
  }
  .search-box input {
    font-size: 13px;
    padding: 9px 12px 9px 36px;
  }
  .date-navigator {
    flex-wrap: wrap;
    gap: 8px;
  }
  .date-nav-label {
    font-size: 13px;
  }

  /* ── Appointment Card ── */
  .appointment-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
  }
  .appt-actions {
    width: 100%;
    justify-content: flex-end;
    gap: 8px;
  }
  .appt-time {
    font-size: 13px;
  }
  .appt-patient-name {
    font-size: 15px;
  }

  /* ── Dashboard grid ── */
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  /* ── Recent patients / appointments list ── */
  .recent-item {
    padding: 10px 14px;
    gap: 10px;
  }
  .recent-avatar {
    width: 36px;
    height: 36px;
    font-size: 13px;
  }
  .recent-name {
    font-size: 13px;
  }
  .recent-condition {
    font-size: 12px;
  }

  /* ── Payment cards ── */
  .payment-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
  }
  .payment-amount {
    font-size: 17px;
  }

  /* ── Modals ── */
  .modal {
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 20px 20px 0 0;
    padding: 20px 16px 32px;
    max-height: 92vh;
  }
  .modal-header {
    margin-bottom: 16px;
  }
  .modal-title {
    font-size: 17px;
  }
  .form-group label {
    font-size: 12px;
  }
  .form-group input,
  .form-group select,
  .form-group textarea {
    font-size: 14px;
    padding: 10px 12px;
  }
  .form-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .modal-actions {
    flex-direction: column-reverse;
    gap: 10px;
  }
  .modal-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* ── Wishlist card ── */
  .wishlist-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px;
  }
  .wishlist-actions {
    width: 100%;
    justify-content: flex-end;
  }

  /* ── Inventory ── */
  .inventory-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .inventory-card {
    padding: 14px;
  }

  /* ── Table overrides ── */
  table {
    font-size: 12px;
  }
  table th, table td {
    padding: 8px 10px;
  }

  /* ── Card defaults ── */
  .card-header {
    padding: 14px 16px;
  }
  .card-body {
    padding: 14px 16px;
  }
  .card-title {
    font-size: 14px;
  }

  /* ── Analytics controls ── */
  .analytics-controls {
    flex-direction: column;
    gap: 10px;
  }
  .analytics-date-block {
    width: 100%;
  }
  .analytics-filters {
    overflow-x: auto;
    padding-bottom: 4px;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
  }
  .analytics-filters::-webkit-scrollbar { display: none; }
  .analytics-filters .btn {
    flex-shrink: 0;
  }
  .download-report-panel {
    width: calc(100vw - 32px);
    right: -60px;
  }
}

/* ─── Extra small phones (≤ 480px) ─── */
@media (max-width: 480px) {
  .main-content {
    padding: 72px 10px 36px;
  }

  /* Stats — tight 2-column */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
  }
  .stat-card {
    padding: 12px 12px 10px;
    gap: 8px;
    border-radius: 16px;
  }
  .stat-number {
    font-size: clamp(15px, 5.5vw, 22px);
    letter-spacing: -0.5px;
  }
  .stat-label {
    font-size: 10px;
  }
  .stat-icon {
    width: 32px;
    height: 32px;
  }
  .stat-card-top {
    gap: 8px;
  }

  /* Patient cards */
  .patient-card {
    padding: 12px;
    border-radius: 14px;
  }
  .patient-avatar {
    width: 36px;
    height: 36px;
    font-size: 13px;
  }
  .patient-name {
    font-size: 14px;
  }
  .patient-meta span {
    font-size: 11px;
  }

  /* Appointment cards */
  .appointment-card {
    padding: 12px;
    border-radius: 14px;
  }

  /* Payment cards */
  .payment-card {
    padding: 12px;
    border-radius: 14px;
  }

  /* Modals */
  .modal {
    padding: 18px 14px 28px;
    border-radius: 18px 18px 0 0;
  }
  .modal-title {
    font-size: 16px;
  }

  /* Page title */
  .page-title, .page-header h1 {
    font-size: 20px;
  }

  /* Report card internals */
  .rpt-bar-label { font-size: 12px; }
  .rpt-day-name  { font-size: 11px; width: 72px; }
  .rpt-day-count { font-size: 12px; }
  .rpt-stat-number { font-size: 26px; }
  .rpt-stat-label  { font-size: 10px; }
  .rpt-bar-badge   { font-size: 10.5px; padding: 1px 8px; }

  /* Area table */
  .area-th {
    font-size: 10px;
    padding: 7px 9px;
  }
  .area-table td {
    font-size: 12px;
    padding: 9px;
  }
}

/* ─── Very small phones (≤ 360px) ─── */
@media (max-width: 360px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 7px;
  }
  .stat-card {
    padding: 10px 10px 8px;
  }
  .stat-number {
    font-size: 15px;
  }
  .main-content {
    padding: 70px 8px 32px;
  }
  .btn {
    padding: 8px 12px;
    font-size: 12px;
  }
  .patient-card {
    padding: 10px;
  }
}

/* ============================================================
   PENDING APPOINTMENTS — Date Group Styles
   ============================================================ */

.pending-date-group {
  margin-bottom: 28px;
}
.pending-date-group:last-child {
  margin-bottom: 0;
}

.pending-date-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}

.pending-date-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  letter-spacing: 0.3px;
}

.pending-date-pill.pill-today {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.3);
  color: var(--accent);
}

.pending-date-count {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Count badge on the Pending button */
#pendingApptCount {
  line-height: 1;
  vertical-align: middle;
}

/* Active state for Pending button */
#btnPendingAppts.btn-active {
  background: rgba(244, 63, 94, 0.1);
  border-color: rgba(244, 63, 94, 0.3);
  color: var(--accent-rose);
}

@media (max-width: 480px) {
  .pending-date-pill {
    font-size: 11px;
    padding: 4px 10px;
  }
  .pending-date-count {
    font-size: 10.5px;
  }
}
