@import url('https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700;900&display=swap');

:root {
  /* Light Mode - Professional Medical-Grade Palette */
  /* Background & Surfaces */
  --bgPrimary: #EEEDF2;
  --bgSecondary: #FFFFFF;
  --bgTertiary: #EEEDF2;
  
  /* Sidebar - Frosted glass effect */
  --sidebarBg: rgba(255, 255, 255, 0.85);
  --sidebarBorder: rgba(0, 0, 0, 0.08);
  --sidebarItemHover: rgba(0, 0, 0, 0.05);
  --sidebarItemActive: #FF4509;
  
  /* Surfaces */
  --surfaceCard: #FFFFFF;
  --surfaceBorder: #E5E7EB;
  --surfaceHover: #EEEDF2;

  /* Text Colors */
  --textPrimary: #1F2937;
  --textSecondary: #6B7280;
  --textMuted: #9CA3AF;
  
  /* Brand & Accent Colors */
  --accentPrimary: #FF4509;
  --accentPrimaryHover: #E63E00;
  --accentLight: #FFA500;
  --accentDark: #E63E00;

  /* Status Colors */
  --statusSuccess: #10B981;
  --statusSuccessLight: #10B981;
  --statusWarning: #F59E0B;
  --statusWarningLight: #F59E0B;
  --statusError: #EF4444;
  --statusErrorLight: #EF4444;
  --statusInfo: #FF4509;
  
  /* Chart Colors */
  --chartTurnover: #FF4509;
  --chartGP: #59BA47;
  --chartPurchases: #FFD600;
  --chartBasket: #8B5CF6;
  --chartExtra1: #FF4509;
  --chartExtra2: #10B981;
  
  /* Legacy chart colors for compatibility */
  --chartPurple: #8B5CF6;
  --chartPink: #FF4509;
  --chartOrange: #FF4509;
  --chartTeal: #10B981;
  --chartIndigo: #8B5CF6;
}

* { 
  box-sizing: border-box; 
  margin: 0;
  padding: 0;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

html, body { 
  height: 100%; 
  height: 100svh; /* Small viewport height - accounts for browser UI on mobile */
  min-height: 100vh; /* Fallback for older browsers */
  overflow: hidden;
  /* Support for safe area insets on notched devices */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body {
  font-family: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  color: var(--textPrimary);
  background: linear-gradient(135deg, #FFFFFF 0%, #FFF8F5 50%, #FFE6D6 100%);
  background-attachment: fixed;
  line-height: 1.5;
  position: relative;
  overflow: hidden;
  /* Use full viewport height on mobile */
  min-height: 100vh;
  min-height: 100svh; /* Small viewport height */
}

/* Enhanced Animated Background */
body::before {
  content: '';
  position: fixed;
  top: -20%;
  left: -20%;
  width: 140%;
  height: 140%;
  background:
    radial-gradient(circle at 20% 50%, rgba(244, 122, 32, 0.05) 0%, transparent 55%),
    radial-gradient(circle at 80% 80%, rgba(255, 69, 9, 0.05) 0%, transparent 55%),
    radial-gradient(circle at 40% 20%, rgba(255, 165, 0, 0.04) 0%, transparent 55%);
  animation: gentleShift 30s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

@keyframes gentleShift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(2%, 2%) scale(1.02); }
}

/* Main App Layout */
.app-layout {
  display: flex !important;
  height: 100vh !important;
  height: 100svh !important; /* Small viewport height - accounts for browser UI */
  min-height: 100vh !important; /* Fallback for older browsers */
  overflow: visible !important;
  overflow-y: hidden !important;
  width: 100% !important;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); /* Account for safe areas */
  gap: 20px;
  position: relative;
  z-index: 1;
  box-sizing: border-box;
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
  .app-layout {
    padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    gap: 10px;
    height: 100vh !important;
    height: 100svh !important; /* Small viewport height for mobile browsers */
    min-height: 100vh !important;
  }
}

/* Refined Glass Sidebar */
.sidebar {
  width: 325px;
  min-width: 325px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  height: calc(100vh - 40px);
  height: calc(100svh - 40px); /* Small viewport height - accounts for browser UI */
  min-height: calc(100vh - 40px); /* Fallback */
  position: relative;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.1),
    0 4px 12px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  will-change: transform;
  overflow: hidden;
  pointer-events: auto;
  /* Ensure sidebar is always visible on larger screens */
  transform: translateX(0) !important;
}

/* Subtle highlight on sidebar */
.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(
    180deg, 
    rgba(255, 255, 255, 0.15) 0%, 
    transparent 100%
  );
  border-radius: 20px 20px 0 0;
  pointer-events: none;
}

.sidebar:hover {
  transform: scale(1.005);
  box-shadow: 
    0 12px 40px rgba(0, 0, 0, 0.12),
    0 6px 16px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.sidebar-header {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--sidebarBorder);
  position: relative;
  z-index: 10;
  pointer-events: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo {
  height: 36px;
  width: auto;
}

.sidebar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--textPrimary);
  letter-spacing: -0.5px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  z-index: 10;
  pointer-events: auto;
}

.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--textMuted);
  padding: 0 12px 8px;
}

/* Removed: .pharmacy-selector and .pharmacy-select-sidebar (moved to top bar) */

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: 12px;
  color: var(--textSecondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
              color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  position: relative;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: auto;
  z-index: 1;
}

.nav-item::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.nav-item:hover {
  background: var(--sidebarItemHover);
  color: var(--textPrimary);
  transform: translateX(4px);
}

.nav-item:hover::before {
  opacity: 1;
}

.nav-item:focus {
  outline: none;
}

.nav-item.active {
  background: var(--sidebarItemActive);
  color: #FFFFFF;
  font-weight: 600;
  box-shadow: 
    0 4px 12px rgba(239, 69, 35, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transform: translateX(2px);
}

.nav-item.active::before {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));
  opacity: 1;
}

.nav-item-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.nav-item-icon svg {
  width: 100%;
  height: 100%;
  color: inherit;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--sidebarBorder);
  position: relative;
  z-index: 10;
  pointer-events: auto;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 12px;
  background: var(--bgPrimary);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF4509 0%, #FFA500 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: white;
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.2);
}

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

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--textPrimary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 10px;
  color: var(--textMuted);
}

.sign-out-btn {
  background: transparent;
  border: none;
  color: var(--textMuted);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  border-radius: 8px;
}

.sign-out-btn:hover {
  color: var(--statusError);
  background: rgba(255, 59, 48, 0.1);
}

.sign-out-btn svg {
  width: 16px;
  height: 16px;
}

/* Main Content Area */
.main-content {
  flex: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow-x: visible !important;
  overflow-y: hidden !important;
  background: transparent !important;
  min-width: 0 !important;
}

/* Top Bar */
.top-bar {
  background: transparent;
  border-bottom: none;
  padding: 0 0 20px 24px; /* Add left padding to match content-area */
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-shrink: 0;
  flex-wrap: wrap;
  position: relative;
}

.mobile-menu-btn {
  display: none;
  background: var(--bgPrimary);
  border: 1px solid var(--surfaceBorder);
  color: var(--textPrimary);
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  transition: all 0.2s ease;
}

.mobile-menu-btn:hover {
  background: var(--surfaceHover);
  border-color: var(--accentPrimary);
}

.mobile-menu-btn svg {
  width: 24px;
  height: 24px;
}

.page-title-section {
  flex: 1;
  min-width: 200px;
}

.page-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--textPrimary);
  margin: 0 0 4px 0;
  letter-spacing: -0.5px;
}

.page-subtitle {
  font-size: 12px;
  color: var(--textMuted);
  margin: 0;
}

.top-bar-controls {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  /* Align right edge with cards: cards are max-width 75%, so their right edge is at 75% of container */
  /* Since controls are in flex container with justify-content: space-between, use margin-right to pull back */
  margin-left: auto;
  margin-right: 25%; /* Position right edge at 75% (100% - 25% = 75%) to match cards */
}

/* Medium and small screens: Align controls to the right */
@media (max-width: 1199px) {
  .top-bar-controls {
    margin-left: auto;
    margin-right: 0;
    justify-content: flex-end;
  }
}

/* Mobile: Make controls fit on one line */
@media (max-width: 768px) {
  .top-bar-controls {
    flex-wrap: nowrap;
    gap: 6px;
    margin-right: 0;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    justify-content: flex-end;
  }
  
  .top-bar-controls::-webkit-scrollbar {
    height: 2px;
  }
  
  .top-bar-controls::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 1px;
  }
}

.top-bar-controls label {
  min-width: 180px;
}

/* Mobile: Smaller month control */
@media (max-width: 768px) {
  .top-bar-controls label {
    min-width: auto;
    flex-shrink: 0;
  }
  
  .top-bar-controls label.with-icon {
    font-size: 12px;
  }
  
  .top-bar-controls .control-lg {
    padding: 6px 8px;
    font-size: 12px;
    border-radius: 8px;
  }
  
  .top-bar-controls .with-icon span {
    font-size: 11px;
  }
}

/* Content Area */
.content-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: visible;
  padding: 24px 0;
  padding-left: 24px;
  background: transparent;
}

.content-area::-webkit-scrollbar {
  width: 8px;
}

.content-area::-webkit-scrollbar-track {
  background: transparent;
}

.content-area::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.content-area::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.15);
}

/* Forms & Controls */
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--textSecondary);
  font-size: 10px;
  font-weight: 500;
}

label span {
  font-size: 10px;
  color: var(--textMuted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input, select {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--surfaceBorder);
  background: var(--bgSecondary);
  color: var(--textPrimary);
  font-size: 12px;
  transition: all 0.2s ease;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accentPrimary);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
  background: white;
}

.control-lg, .control-sm { 
  appearance: none; 
  border: 1px solid var(--surfaceBorder); 
  background: var(--bgSecondary); 
  color: var(--textPrimary); 
  border-radius: 10px; 
  font-size: 12px; 
  transition: all 0.2s ease;
}

.control-lg { 
  padding: 10px 14px; 
  min-height: 40px; 
}

.control-sm { 
  padding: 6px 10px; 
  min-height: 32px; 
  font-size: 11px; 
}

.control-lg:focus, .control-sm:focus { 
  outline: none; 
  border-color: var(--accentPrimary); 
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

input.control-lg[type="month"] {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bgSecondary);
  color: var(--textPrimary);
}

select.control-lg {
  appearance: none;
  -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--textMuted) 50%),
                    linear-gradient(135deg, var(--textMuted) 50%, transparent 50%);
  background-position: right 14px center, right 9px center;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 28px;
  background-color: var(--bgSecondary);
}

select.control-lg option {
  color: var(--textPrimary);
  background: var(--bgSecondary);
  font-family: inherit;
  font-size: 12px;
}

.with-icon input[type="month"]::-webkit-calendar-picker-indicator {
  filter: opacity(0.5);
  opacity: 0.9;
}

/* Buttons */
.btn {
  appearance: none;
  border: 1px solid var(--surfaceBorder);
  background: var(--bgSecondary);
  color: var(--textPrimary);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:hover {
  background: var(--bgPrimary);
  border-color: var(--accentPrimary);
}

.btn:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 11px;
}

.btn-compact {
  max-width: 113px;
  width: auto;
  padding: 6px 10px;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accentPrimary);
  color: white;
  border-color: var(--accentPrimary);
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.25);
}

.btn-primary:hover {
  background: var(--accentPrimaryHover);
  border-color: var(--accentPrimaryHover);
  box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

/* Alert */
.alert {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid;
}

.alert.error {
  background: rgba(255, 59, 48, 0.1);
  border-color: rgba(255, 59, 48, 0.2);
  color: var(--statusError);
}

/* Dashboard Summary Layout - Same as Daily Summary (2 columns) */
.dashboard-summary-layout {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
  max-width: 75%; /* Default width for desktop */
}

/* Spend Analytics Metric Cards (Purchases and Purchase Budget) */
.spend-analytics-metric-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
  max-width: 100%;
}

/* Hide Purchases and Purchase Budget cards on the dashboard UI only */
.spend-analytics-metric-cards { display: none !important; }

/* Hide cards below Purchase vs Spend Budget chart (Spend Analysis and Target Performance) */
.dashboard-below-grid { display: none !important; }

.spend-analytics-metric-cards .card-value-amount {
  font-size: 22px;
  font-weight: 700;
  color: var(--textPrimary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* Spend Analytics Container */
.spend-analytics-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
  max-width: 75%; /* Default width for desktop */
}

.spend-analytics-container .chart-container {
  width: 100%;
  height: 180px; /* reduced vertical size */
  position: relative;
  margin-top: 8px;
  padding: 4px;
}

.spend-analytics-container canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Tooltip for spend analytics */
.spend-analytics-container .chart-tooltip {
  position: absolute;
  min-width: 180px;
  max-width: 240px;
  padding: 8px 10px;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
  color: var(--textSecondary);
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
  z-index: 3;
}

.spend-analytics-container .chart-tooltip .tt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.spend-analytics-container .chart-tooltip .tt-title {
  font-weight: 700;
  color: var(--textPrimary);
  margin-bottom: 6px;
}

.spend-analytics-container .chart-tooltip .tt-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
}

/* Inline legend overlay for spend analytics chart */
.spend-analytics-container .chart-legend {
  position: absolute;
  bottom: 6px;
  right: 8px;
  display: flex;
  gap: 12px;
  align-items: center;
  z-index: 2;
}

.spend-analytics-container .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700; /* match app small label weight */
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--textSecondary); /* grey font colour */
  background: rgba(255,255,255,0.7);
  border-radius: 8px;
  padding: 4px 8px;
  backdrop-filter: blur(6px);
}

.spend-analytics-container .legend-item .legend-line {
  display: inline-block;
  width: 16px;
  height: 4px; /* solid swatch instead of border */
  border-radius: 2px;
}

/* Chart toggle button */
.chart-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--textSecondary);
  transition: all 0.3s ease;
  border-radius: 4px;
}

.chart-toggle-btn:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--textPrimary);
}

.chart-toggle-btn svg {
  transition: transform 0.3s ease;
  transform: rotate(0deg);
}

.chart-toggle-btn.collapsed svg {
  transform: rotate(180deg);
}

/* Reduce card padding when chart is collapsed */
.dashboard-card.chart-collapsed {
  padding: 12px 20px;
}

.dashboard-card.chart-collapsed .card-header {
  margin-bottom: 0;
}

.spend-analytics-container .legend-purchases .legend-line { background-color: #F47A20; }

.spend-analytics-container .legend-budget .legend-line { background-color: #59BA47; }

/* Section Headers */
.section-heading {
  font-size: 22px;
  font-weight: 600;
  color: #000000;
  margin: 0 0 20px 0;
  letter-spacing: 0.5px;
  text-align: left;
}

/* Section heading with toggle */
.section-heading-with-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  max-width: 75%; /* Align with cards - 75% on desktop */
}

.section-heading-with-toggle .section-heading {
  margin-bottom: 0;
}

/* Summary view toggle */
.summary-view-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bgSecondary);
  border: 1px solid var(--surfaceBorder);
  border-radius: 12px;
  padding: 4px;
}

.summary-view-toggle-btn {
  padding: 6px 16px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--textSecondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.summary-view-toggle-btn:hover {
  background: var(--surfaceHover);
  color: var(--textPrimary);
}

.summary-view-toggle-btn.active {
  background: var(--accentPrimary);
  color: white;
  font-weight: 600;
}

/* Medium and small screens: Align toggle to the right */
@media (max-width: 1199px) {
  .section-heading-with-toggle {
    justify-content: space-between;
    max-width: 100%; /* Remove 75% constraint to allow toggle to reach right edge */
    width: 100%;
  }
 
  .summary-view-toggle {
    margin-left: 0;
  }
}

/* Responsive adjustments for toggle on mobile */
@media (max-width: 768px) {
  .section-heading-with-toggle {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    max-width: 100%;
  }
  
  .section-heading-with-toggle .section-heading {
    margin-bottom: 0;
    flex-shrink: 0;
  }
  
  .summary-view-toggle {
    width: auto !important; /* Force auto width to prevent stretching */
    max-width: none !important; /* Remove any max-width constraints */
    flex-shrink: 0;
    margin-left: auto;
    padding: 4px;
    gap: 4px;
  }
  
  .summary-view-toggle-btn {
    padding: 6px 12px;
    font-size: 13px;
    flex: 0 0 auto; /* Don't grow or shrink */
  }
}

/* Stock Management Styles */
.stock-management-container {
  width: 100%;
}

/* Stock Search Styles */
.stock-search-container {
  margin-bottom: 32px;
  width: 100%;
}

.stock-search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: #FFFFFF;
  border: 2px solid var(--borderColor);
  border-radius: 12px;
  padding: 14px 18px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  width: 100%;
}

/* Constrain search box to 1/3 width on large screens */
@media (min-width: 1200px) {
  .stock-search-container {
    max-width: 400px;
  }
}

@media (min-width: 768px) and (max-width: 1199px) {
  .stock-search-container {
    max-width: 500px;
  }
}

.stock-search-input-wrapper:hover {
  border-color: var(--accentPrimary);
  box-shadow: 0 2px 8px rgba(239, 69, 35, 0.08);
}

.stock-search-input-wrapper:focus-within {
  border-color: var(--accentPrimary);
  box-shadow: 0 0 0 4px rgba(239, 69, 35, 0.1),
              0 2px 8px rgba(239, 69, 35, 0.15);
}

.stock-search-input-wrapper .search-icon {
  width: 20px;
  height: 20px;
  color: var(--textSecondary);
  margin-right: 12px;
  flex-shrink: 0;
  transition: color 0.2s;
}

.stock-search-input-wrapper:focus-within .search-icon {
  color: var(--accentPrimary);
}

.stock-search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--textPrimary);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.5;
}

.stock-search-input::placeholder {
  color: var(--textSecondary);
  opacity: 0.6;
}

.search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 12px;
  padding: 2px;
}

.search-loading .spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--borderColor);
  border-top-color: var(--accentPrimary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.search-error {
  margin-top: 16px;
  padding: 14px 16px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 10px;
  color: #DC2626;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.1);
}

.stock-search-results {
  margin-top: 32px;
  width: 100%;
}

/* Constrain results to 66% width only on very large screens (matching daily summary) */
@media (min-width: 1367px) {
  .stock-search-results {
    max-width: 66.6%;
  }
}

.search-results-header {
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--borderColor);
}

.results-count {
  font-size: 14px;
  font-weight: 600;
  color: var(--textPrimary);
  letter-spacing: 0.02em;
}

.stock-results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stock-result-item {
  background: #FFFFFF;
  border: 1px solid var(--borderColor);
  border-radius: 12px;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.stock-result-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border-color: rgba(239, 69, 35, 0.2);
  transform: translateY(-1px);
}

.stock-result-item-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  transition: background-color 0.2s;
  gap: 12px;
}

.stock-result-item-content:hover {
  background: rgba(239, 69, 35, 0.05);
}

.stock-result-item-info {
  flex: 1;
  min-width: 0;
}

.stock-result-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--textPrimary);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
}

.stock-result-item-code {
  font-size: 11px;
  color: var(--textSecondary);
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', 'Courier New', monospace;
  background: rgba(0, 0, 0, 0.03);
  padding: 3px 6px;
  border-radius: 4px;
  display: inline-block;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.stock-expand-arrow {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--textSecondary);
  transition: transform 0.2s, color 0.2s;
  flex-shrink: 0;
}

.stock-expand-arrow.expanded {
  transform: rotate(90deg);
  color: var(--accentPrimary);
}

.stock-product-details-container {
  border-top: 1px solid var(--borderColor);
  padding: 14px 16px;
  background: rgba(239, 69, 35, 0.03);
}

.stock-details-loading,
.stock-details-error {
  padding: 16px;
  text-align: center;
  color: var(--textSecondary);
  font-size: 14px;
}

.stock-details-error {
  color: #EF4444;
}

.stock-details-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Wrapper for chart and summary grid - side by side on tablet+ */
.stock-chart-summary-wrapper {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Stock Summary Grid - Card Based Layout */
.stock-details-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 0 auto;
  max-width: 600px;
  width: 100%;
}

.stock-summary-card {
  background: #FFFFFF;
  border: 1px solid var(--borderColor);
  border-radius: 10px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  transition: all 0.2s;
  min-height: 97px;
  margin-bottom: 0;
}

.stock-summary-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.stock-summary-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: center;
}

.stock-summary-value {
  font-size: 19px;
  font-weight: 700;
  color: var(--textPrimary);
  text-align: center;
  line-height: 1.2;
}

/* Individual card colors */
.soh-card .stock-summary-label {
  color: #FF4509;
}

.sales-card .stock-summary-label {
  color: #F47A20;
}

.daily-avg-card .stock-summary-label {
  color: #FFA500;
}

.gp-card .stock-summary-label {
  color: #59BA47;
}

.cost-card .stock-summary-label {
  color: #FFB800;
}

.month-avg-card .stock-summary-label {
  color: #8B5CF6;
}

.stock-detail-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--textSecondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stock-detail-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--textPrimary);
}

.stock-daily-breakdown {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.stock-detail-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--borderColor);
}

.stock-detail-item:last-child {
  border-bottom: none;
}

.stock-detail-item .stock-detail-label {
  font-size: 13px;
  text-transform: none;
  letter-spacing: normal;
}

.stock-detail-item .stock-detail-value {
  font-size: 14px;
}

@media (max-width: 767px) {
  .stock-details-summary-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .stock-details-summary-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    max-width: 100%;
  }
  
  .stock-summary-card {
    padding: 10px 8px;
    min-height: 80px;
  }
  
  .stock-summary-label {
    font-size: 10px;
  }
  
  .stock-summary-value {
    font-size: 16px;
  }
}

/* Tablet and larger screens - side by side layout */
@media (min-width: 768px) {
  .stock-chart-summary-wrapper {
    flex-direction: row;
    align-items: stretch;
    gap: 16px;
    min-height: 0;
  }
  
  .stock-details-summary-grid {
    flex: 0 0 calc(50% - 8px);
    max-width: none;
    margin: 0;
    padding-bottom: 0;
    align-self: flex-start;
    align-content: start;
  }
  
  .stock-monthly-chart-card {
    flex: 0 0 calc(50% - 8px);
    margin-bottom: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    min-height: 120% !important;
    padding: 19px 19px 19px 19px !important;
    align-self: stretch;
  }
  
  .stock-chart-header {
    flex-shrink: 0;
    margin-bottom: 16px;
  }
  
  .stock-bar-chart-wrapper {
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 120px !important;
    display: flex !important;
    align-items: flex-end !important;
  }
  
  .stock-bar-group {
    height: 100%;
    align-self: stretch;
    display: flex;
    flex-direction: column;
  }
  
  .stock-bar-container {
    height: calc(100% - 24px) !important;
    max-height: none !important;
    min-height: 80px !important;
    flex: 1;
  }
  
  .stock-chart-loading {
    flex: 1 !important;
    height: auto !important;
    min-height: 0 !important;
  }
}

/* Stock Bar Chart Styles */
.stock-monthly-chart-card {
  background: linear-gradient(135deg, #FF4509 0%, #FFA500 100%);
  border-radius: 12px;
  padding: 16px 16px 12px 16px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(244, 122, 32, 0.25);
  position: relative;
  overflow: hidden;
}

.stock-monthly-chart-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 30%;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.15) 0%,
    transparent 100%
  );
  border-radius: 12px 12px 0 0;
  pointer-events: none;
}

.stock-chart-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.stock-chart-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  flex-shrink: 0;
}

.stock-chart-icon svg {
  width: 100%;
  height: 100%;
}

.stock-chart-title {
  font-size: 13px;
  font-weight: 700;
  color: #FFFFFF;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
}

.stock-bar-chart-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 100px;
  padding-bottom: 0;
  padding-top: 0;
  position: relative;
  z-index: 1;
}

.stock-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
}

.stock-bar-container {
  width: 100%;
  max-width: 24px;
  height: 80px;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin-bottom: 0;
}

.stock-bar {
  width: 100%;
  background: #FFFFFF;
  border-radius: 4px;
  transition: all 0.3s ease;
  cursor: pointer;
  min-height: 3px;
  opacity: 0.95;
}

.stock-bar:hover {
  opacity: 1;
  transform: scaleY(1.05);
}

.stock-bar-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 6px;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.85);
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 10;
}

.stock-bar-group:hover .stock-bar-tooltip {
  opacity: 1;
}

.stock-bar-label {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  margin-top: 4px;
  position: relative;
  z-index: 1;
  line-height: 1.2;
}

/* Smaller font on small screens */
@media (max-width: 480px) {
  .stock-bar-chart-wrapper {
    gap: 2px !important;
  }
  
  .stock-bar-label {
    font-size: 7px;
    line-height: 1.1;
    margin-top: 2px;
    padding: 0 1px;
  }
  
  .stock-bar-tooltip {
    font-size: 10px;
    padding: 3px 6px;
    margin-bottom: 4px;
  }
  
  /* Show tooltip on touch devices */
  .stock-bar-group:active .stock-bar-tooltip,
  .stock-bar-group.touched .stock-bar-tooltip {
    opacity: 1;
  }
}

@media (max-width: 767px) {
  .stock-bar-chart-wrapper {
    height: 80px !important;
    gap: 3px;
  }
  
  .stock-bar-container {
    max-width: 20px;
    height: 60px !important;
  }
  
  .stock-bar-label {
    font-size: 8px;
    line-height: 1.1;
  }
  
  .stock-monthly-chart-card {
    padding: 12px;
  }
}

/* Stock Insights Styles */
.stock-insights-section {
  margin-top: 32px;
  width: 100%;
}

.stock-insights-header {
  margin-bottom: 24px;
}

.stock-insights-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--textPrimary);
  margin-bottom: 8px;
}

.stock-insights-description {
  font-size: 14px;
  color: var(--textSecondary);
  line-height: 1.5;
}

.stock-insights-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  padding: 20px;
  background: #FFFFFF;
  border: 1px solid var(--borderColor);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  width: 100%;
}

/* Constrain filters to 66% width only on very large screens (matching daily summary) */
@media (min-width: 1367px) {
  .stock-insights-filters {
    max-width: 66.6%;
  }
}

.stock-insights-filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 150px;
}

.stock-insights-filter-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--textPrimary);
}

/* Custom Dropdown Styles */
.custom-dropdown {
  position: relative;
  width: 100%;
}

.custom-dropdown-button {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--borderColor);
  border-radius: 8px;
  background: #FFFFFF;
  color: var(--textPrimary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  font-family: inherit;
}

.custom-dropdown-button:hover {
  border-color: var(--accentPrimary);
  box-shadow: 0 2px 8px rgba(239, 69, 35, 0.08);
}

.custom-dropdown-button:focus {
  outline: none;
  border-color: var(--accentPrimary);
  box-shadow: 0 0 0 3px rgba(239, 69, 35, 0.1);
}

.custom-dropdown-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-dropdown-arrow {
  flex-shrink: 0;
  color: var(--textSecondary);
  transition: transform 0.2s;
}

.custom-dropdown.open .custom-dropdown-arrow {
  transform: rotate(180deg);
}

.custom-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #FFFFFF;
  border: 2px solid var(--borderColor);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1),
              0 0 0 1px rgba(0, 0, 0, 0.05);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  animation: dropdownFadeIn 0.2s ease;
}

.custom-dropdown.open .custom-dropdown-menu {
  display: block;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.custom-dropdown-item {
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--textPrimary);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-dropdown-item:first-child {
  border-radius: 6px 6px 0 0;
}

.custom-dropdown-item:last-child {
  border-radius: 0 0 6px 6px;
}

.custom-dropdown-item:hover {
  background: rgba(239, 69, 35, 0.08);
  color: var(--accentPrimary);
}

.custom-dropdown-item.active {
  background: rgba(239, 69, 35, 0.1);
  color: var(--accentPrimary);
  font-weight: 600;
}

.custom-dropdown-item.active::before {
  content: '✓';
  font-weight: 700;
  color: var(--accentPrimary);
}

.stock-insights-load-btn {
  padding: 10px 24px;
  background: var(--accentPrimary);
  color: #FFFFFF;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(239, 69, 35, 0.2);
  height: fit-content;
  margin-left: auto;
}

.stock-insights-load-btn:hover {
  background: #E6391A;
  box-shadow: 0 4px 8px rgba(239, 69, 35, 0.3);
  transform: translateY(-1px);
}

.stock-insights-load-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(239, 69, 35, 0.2);
}

.stock-insights-loading-simple {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-top: 16px;
  margin-left: 20px;
  color: var(--textSecondary);
  font-size: 14px;
  font-weight: 500;
  width: 100%;
}

.stock-insights-loading-simple .spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--borderColor);
  border-top-color: var(--accentPrimary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

/* Constrain loading to 66% width only on very large screens (matching daily summary) */
@media (min-width: 1367px) {
  .stock-insights-loading-simple {
    max-width: 66.6%;
  }
}

.stock-insights-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--borderColor);
}

.stock-insights-metric {
  font-size: 13px;
  color: var(--textPrimary);
}

.stock-insights-metric .metric-label {
  font-weight: 600;
  color: var(--textSecondary);
  margin-right: 6px;
}

.stock-insights-metric .metric-value {
  font-weight: 700;
  color: var(--textPrimary);
}

@media (max-width: 768px) {
  .stock-insights-filters {
    flex-direction: column;
    align-items: stretch;
  }
  
  .stock-insights-filter-group {
    min-width: 100%;
  }
  
  .stock-insights-load-btn {
    width: 100%;
  }
  
  .stock-insights-metrics {
    flex-direction: column;
    gap: 8px;
  }
  
  .custom-dropdown-menu {
    max-height: 250px;
  }
}

/* Purchases Section */
.purchases-section {
  margin-top: 10px;
  width: 100%;
  display: block;
  clear: both;
  position: relative;
}

/* Make both budget cards equal width in purchases section */
@media (min-width: 531px) {
  .purchases-section .dispensary-cards-container .metric-split,
  .purchases-section .dispensary-cards-container .metric-scripts {
    flex: 0 0 calc(50% - 8px);
    min-width: 250px;
  }
}

/* Ensure both pie charts are the same size in purchases section on all screen sizes */
.purchases-section .dispensary-chart-container {
  width: 100px;
  height: 100px;
  max-width: 100px;
  max-height: 100px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .purchases-section .dispensary-chart-container {
    width: 80px;
    height: 80px;
    max-width: 80px;
    max-height: 80px;
  }
  
  .purchases-section .chart-center-value {
    font-size: 18px;
  }
}

/* Constrain purchases and stock summary sections to 66.6% width only on very large screens (matching daily summary) */
@media (min-width: 1367px) {
  .stock-management-container .purchases-section,
  .stock-management-container .stock-summary-section {
    max-width: 66.6%;
    margin-left: 0;
    margin-right: auto;
  }
  
  /* Budget card should be full width within the purchases section */
  .stock-management-container .purchases-section .dashboard-card {
    max-width: 100%;
  }
}

/* On smaller screens, budget card is full width */
@media (max-width: 1199px) {
  .stock-management-container .purchases-section .dashboard-card {
    max-width: 100%;
  }
}

/* Debtor Tools Styles */
.debtor-tools-container {
  width: 100%;
}

.debtor-section {
  margin-bottom: 32px;
}

.debtor-reports-container {
  padding: 20px;
  background: var(--bgSecondary);
  border-radius: 12px;
  border: 1px solid var(--surfaceBorder);
}

.debtor-reports-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.debtor-report-card {
  padding: 16px;
  background: var(--bgPrimary);
  border-radius: 8px;
  border: 1px solid var(--surfaceBorder);
  transition: all 0.2s ease;
}

.debtor-report-card:hover {
  border-color: var(--accentPrimary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.debtor-report-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.debtor-report-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--textPrimary);
}

.debtor-report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 14px;
  color: var(--textSecondary);
}

.debtor-report-meta span {
  display: flex;
  align-items: center;
}

.debtor-empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--textSecondary);
  font-size: 14px;
}

.debtor-summary-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
}

/* Ensure debtor summary cards inherit dashboard summary styles */
.debtor-summary-layout .card-value-amount {
  font-size: 22px;
  font-weight: 700;
  color: var(--textPrimary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.debtor-summary-layout .card-value-currency {
  font-size: 16px;
  font-weight: 700;
  color: var(--textMuted);
}

/* Override dashboard summary layout max-width when inside debtor tools */
.debtor-tools-container .debtor-summary-layout {
  max-width: 100% !important;
}

.debtor-overview-cards {
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100%;
}

.debtor-overview-cards .dashboard-card {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.debtor-ageing-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.debtor-ageing-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.debtor-ageing-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--surfaceBorder);
}

.debtor-ageing-item:last-child {
  border-bottom: none;
}

.debtor-ageing-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--textSecondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.debtor-ageing-value-wrapper {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.debtor-ageing-currency {
  font-size: 14px;
  font-weight: 600;
  color: var(--textMuted);
}

.debtor-ageing-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--textPrimary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

@media (max-width: 768px) {
  .debtor-summary-layout {
    grid-template-columns: 1fr;
  }
  
  .debtor-overview-cards {
    height: auto;
  }
  
  .debtor-ageing-card {
    height: auto;
  }
}

.debtor-filters-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
}

.debtor-balance-filter {
  width: 100%;
}

.debtor-ageing-buckets-filter,
.debtor-contact-filters {
  width: 100%;
}

.debtor-filter-label {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.debtor-filter-label > span {
  font-size: 12px;
  font-weight: 700;
  color: var(--textSecondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.debtor-balance-slider-container {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.debtor-balance-slider {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  outline: none;
  border: none;
  -webkit-appearance: none;
  appearance: none;
  transition: all 0.2s ease;
  position: relative;
  background: transparent;
}

/* Webkit browsers - Chrome, Safari, Edge */
.debtor-balance-slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, var(--accentPrimary) 0%, var(--accentPrimary) var(--slider-progress, 0%), var(--surfaceBorder) var(--slider-progress, 0%), var(--surfaceBorder) 100%);
  border: none;
}

.debtor-balance-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accentPrimary);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(244, 122, 32, 0.4);
  margin-top: -6px;
  position: relative;
  z-index: 2;
}

.debtor-balance-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 3px 10px rgba(244, 122, 32, 0.5);
}

/* Firefox */
.debtor-balance-slider::-moz-range-track {
  height: 8px;
  border-radius: 4px;
  background: var(--surfaceBorder);
  border: none;
  outline: none;
}

.debtor-balance-slider::-moz-range-progress {
  height: 8px;
  border-radius: 4px;
  background: var(--accentPrimary);
}

.debtor-balance-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accentPrimary);
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(244, 122, 32, 0.4);
  position: relative;
  z-index: 2;
}

.debtor-balance-slider::-moz-range-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 3px 10px rgba(244, 122, 32, 0.5);
}

.debtor-balance-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--accentPrimary);
  min-width: 70px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.debtor-checkbox-group {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0;
  padding: 0;
  background: transparent;
  border: none;
  width: 100%;
  justify-content: space-between;
}

.debtor-checkbox-group .checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 400;
  color: var(--textPrimary);
  cursor: pointer;
  padding: 8px 0;
  border-radius: 8px;
  transition: background 0.2s ease;
  margin: 0;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
  justify-content: flex-start;
}

.debtor-checkbox-group .checkbox-label:hover {
  background: var(--surfaceHover);
}

.debtor-checkbox-group .checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  max-width: 18px;
  max-height: 18px;
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--chartGP);
  -webkit-appearance: none;
  appearance: none;
  border: 2px solid var(--surfaceBorder);
  border-radius: 4px;
  background: var(--bgSecondary);
  position: relative;
  transition: all 0.2s ease;
  box-sizing: border-box;
  padding: 0;
}

.debtor-checkbox-group .checkbox-label input[type="checkbox"]:checked {
  background-color: var(--chartGP);
  border-color: var(--chartGP);
}

/* White checkmark */
.debtor-checkbox-group .checkbox-label input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  box-sizing: border-box;
}

.debtor-search-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bgSecondary);
  border: 1px solid var(--surfaceBorder);
  border-radius: 10px;
  font-size: 14px;
  color: var(--textPrimary);
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
}

.debtor-search-input::placeholder {
  color: var(--textMuted);
}

.debtor-search-input:focus {
  border-color: var(--accentPrimary);
  box-shadow: 0 0 0 4px rgba(244, 122, 32, 0.1);
  background: white;
}

.debtor-search-input:hover:not(:focus) {
  border-color: var(--accentLight);
}

.debtor-table-search-container {
  margin-bottom: 20px;
  max-width: 500px;
}

.debtor-table-search-container .debtor-filter-label {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.debtor-table-search-container .debtor-filter-label > span {
  font-size: 12px;
  font-weight: 700;
  color: var(--textSecondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Hide filters and send reminders sections on mobile phones only */
/* Keep debtors list and ageing buckets card visible */
@media (max-width: 600px) {
  #debtor-filters-section,
  #debtor-communication-section {
    display: none !important;
  }
  
  /* Ensure debtors list and ageing buckets card remain visible */
  #debtor-statistics-section,
  #debtor-table-section {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  /* Ensure debtor summary layout and cards are visible on mobile */
  .debtor-tools-container .debtor-summary-layout {
    display: grid !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  .debtor-tools-container .debtor-summary-layout > .dashboard-card,
  .debtor-tools-container .debtor-summary-layout > .debtor-overview-cards > .dashboard-card,
  .debtor-tools-container .debtor-ageing-card {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  /* Ensure debtor table is visible */
  #debtor-table-section .debtor-table-search-container,
  #debtor-table-section .debtor-table-container,
  #debtor-table-section .debtor-table-wrapper {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  #debtor-table-section .debtor-table {
    display: table !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
}

@media (max-width: 768px) {
  
  .debtor-filters-grid {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 20px;
  }
  
  .debtor-filter-item-full {
    grid-column: 1;
  }
  
  /* Ageing buckets - 3 column grid on mobile */
  .debtor-ageing-buckets-filter .debtor-checkbox-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  
  .debtor-ageing-buckets-filter .debtor-checkbox-group .checkbox-label {
    font-size: 12px;
    padding: 6px 0;
    gap: 6px;
    justify-content: center;
    text-align: center;
  }
  
  .debtor-ageing-buckets-filter .debtor-checkbox-group .checkbox-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    min-width: 14px;
    min-height: 14px;
    max-width: 14px;
    max-height: 14px;
  }
  
  .debtor-ageing-buckets-filter .debtor-checkbox-group .checkbox-label input[type="checkbox"]:checked::after {
    left: 4px;
    top: 1px;
    width: 3px;
    height: 6px;
    border-width: 0 1.5px 1.5px 0;
  }
  
  /* Contact filters - vertical stack on mobile */
  .debtor-contact-filters .debtor-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
  
  .debtor-contact-filters .debtor-checkbox-group .checkbox-label {
    font-size: 13px;
    padding: 10px 0;
    gap: 10px;
    justify-content: flex-start;
    white-space: normal;
  }
  
  .debtor-contact-filters .debtor-checkbox-group .checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    max-width: 16px;
    max-height: 16px;
  }
  
  .debtor-contact-filters .debtor-checkbox-group .checkbox-label input[type="checkbox"]:checked::after {
    left: 5px;
    top: 2px;
    width: 3px;
    height: 7px;
    border-width: 0 2px 2px 0;
  }
}

.debtor-communication-panel {
  padding: 20px;
  background: var(--bgSecondary);
  border-radius: 12px;
  border: 1px solid var(--surfaceBorder);
}

.debtor-selection-info {
  font-size: 14px;
  color: var(--textSecondary);
  margin-bottom: 16px;
}

.debtor-selection-info span {
  font-weight: 600;
  color: var(--accentPrimary);
}

.debtor-communication-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.debtor-message-config {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 20px;
  padding: 20px;
  background: white;
  border-radius: 10px;
  border: 1px solid var(--surfaceBorder);
}

.debtor-message-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.debtor-message-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--textPrimary);
  text-align: left;
}

.debtor-message-label svg {
  width: 16px;
  height: 16px;
  color: var(--accentPrimary);
}

.debtor-collapsible-header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 0;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  color: var(--textPrimary);
  transition: color 0.2s ease;
}

.debtor-collapsible-header:hover {
  color: var(--accentPrimary);
}

.debtor-collapsible-icon {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.debtor-collapsible-open .debtor-collapsible-icon {
  transform: rotate(90deg);
}

.debtor-collapsible-header > span:first-of-type {
  flex: 0 0 auto;
}

.debtor-collapsible-hint {
  flex: 1;
  font-size: 12px;
  font-weight: 400;
  color: var(--textSecondary);
  text-align: left;
}

.debtor-collapsible-content {
  padding-top: 12px;
  padding-bottom: 8px;
}

.debtor-preview-container {
  padding: 16px;
  background: var(--bgSecondary);
  border-radius: 8px;
  border: 1px solid var(--surfaceBorder);
}

.debtor-preview-email {
  background: white;
  border-radius: 8px;
  border: 1px solid var(--surfaceBorder);
  overflow: hidden;
}

.debtor-preview-email-header {
  padding: 12px 16px;
  background: var(--bgSecondary);
  border-bottom: 1px solid var(--surfaceBorder);
}

.debtor-preview-email-subject {
  font-size: 14px;
  font-weight: 600;
  color: var(--textPrimary);
  text-align: left;
}

.debtor-preview-email-body {
  padding: 16px;
  font-size: 14px;
  color: var(--textPrimary);
  line-height: 1.6;
  text-align: left;
}

.debtor-preview-email-body p {
  margin: 0 0 12px 0;
}

.debtor-preview-email-body hr {
  border: none;
  border-top: 1px solid var(--surfaceBorder);
  margin: 16px 0;
}

.debtor-preview-email-body b {
  font-weight: 600;
}

.debtor-preview-email-body a {
  color: var(--accentPrimary);
  text-decoration: none;
}

.debtor-preview-email-body a:hover {
  text-decoration: underline;
}

.debtor-preview-sms {
  padding: 16px;
  background: white;
  border-radius: 8px;
  border: 1px solid var(--surfaceBorder);
  font-size: 14px;
  color: var(--textPrimary);
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  text-align: left;
  margin-bottom: 8px;
}

.debtor-preview-sms-charcount {
  font-size: 12px;
  color: var(--textSecondary);
  text-align: left;
}

.debtor-message-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bgSecondary);
  border: 1px solid var(--surfaceBorder);
  border-radius: 10px;
  font-size: 14px;
  color: var(--textPrimary);
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
  resize: vertical;
  min-height: 80px;
}

.debtor-message-input::placeholder {
  color: var(--textMuted);
}

.debtor-message-input:focus {
  border-color: var(--accentPrimary);
  box-shadow: 0 0 0 4px rgba(244, 122, 32, 0.1);
  background: white;
}

.debtor-message-input:hover:not(:focus) {
  border-color: var(--accentLight);
}

.debtor-message-hint {
  font-size: 12px;
  color: var(--textSecondary);
  line-height: 1.5;
}

.debtor-message-hint #debtor-sms-char-count {
  font-weight: 600;
  color: var(--textSecondary);
}

.debtor-email-template-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.debtor-template-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.debtor-field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--textSecondary);
}

.debtor-message-input-small {
  width: 100%;
  padding: 10px 14px;
  background: var(--bgSecondary);
  border: 1px solid var(--surfaceBorder);
  border-radius: 8px;
  font-size: 14px;
  color: var(--textPrimary);
  outline: none;
  transition: all 0.2s ease;
  font-family: inherit;
}

.debtor-message-input-small::placeholder {
  color: var(--textMuted);
}

.debtor-message-input-small:focus {
  border-color: var(--accentPrimary);
  box-shadow: 0 0 0 3px rgba(244, 122, 32, 0.1);
  background: white;
}

.debtor-message-input-small:hover:not(:focus) {
  border-color: var(--accentLight);
}

.debtor-template-vars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.debtor-template-var-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.debtor-communication-status {
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  display: none;
}

.debtor-table-container {
  background: var(--bgSecondary);
  border-radius: 12px;
  border: 1px solid var(--surfaceBorder);
  overflow: hidden;
}

.debtor-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--textSecondary);
}

.debtor-error {
  padding: 20px;
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
  border-radius: 8px;
  margin: 20px;
}

.debtor-table-wrapper {
  overflow-x: auto;
}

.debtor-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}

.debtor-table thead {
  background: var(--bgPrimary);
  border-bottom: 2px solid var(--surfaceBorder);
}

.debtor-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--textPrimary);
  white-space: nowrap;
}

.debtor-table th:first-child {
  width: 40px;
}

.debtor-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--surfaceBorder);
  color: var(--textPrimary);
}

.debtor-table tbody tr {
  transition: background-color 0.2s ease;
}

.debtor-table tbody tr:hover {
  background: var(--surfaceHover);
}

.debtor-row-selected {
  background: rgba(74, 144, 226, 0.1) !important;
}

.debtor-sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
}

.debtor-sortable:hover {
  background: var(--surfaceHover);
}

.sort-icon {
  display: inline-block;
  margin-left: 4px;
  font-size: 12px;
  opacity: 0.6;
}

.debtor-table a {
  color: var(--accentPrimary);
  text-decoration: none;
}

.debtor-table a:hover {
  text-decoration: underline;
}

.debtor-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
  border-top: 1px solid var(--surfaceBorder);
}

.debtor-pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 768px) {
  .debtor-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .debtor-overview {
    flex-direction: column;
    gap: 16px;
  }
  
  .debtor-communication-buttons {
    flex-direction: column;
  }
  
  .debtor-communication-buttons button {
    width: 100%;
  }
  
  .debtor-message-config {
    padding: 16px;
    gap: 16px;
  }
  
  .debtor-message-input {
    min-height: 60px;
  }
  
  .debtor-template-vars-grid {
    grid-template-columns: 1fr;
  }
  
  .debtor-email-template-fields {
    gap: 10px;
  }
  
  .debtor-table-wrapper {
    overflow-x: scroll;
  }
  
  .debtor-table {
    min-width: 1000px;
  }
}

.section-heading-with-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}

.section-heading-with-actions .section-heading {
  margin-bottom: 0;
}

.date-range-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-range-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--textSecondary);
}

.date-range-select {
  padding: 8px 12px;
  background: var(--bgSecondary);
  border: 1px solid var(--surfaceBorder);
  border-radius: 8px;
  color: var(--textPrimary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
}

.date-range-select:hover {
  background: var(--surfaceHover);
  border-color: var(--accentPrimary);
}

.date-range-select:focus {
  border-color: var(--accentPrimary);
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

@media (max-width: 768px) {
  .section-heading-with-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .date-range-selector {
    width: 100%;
  }
  
  .date-range-select {
    flex: 1;
  }
}

/* Smallest screens - keep toggle compact */
@media (max-width: 480px) {
  .section-heading-with-toggle {
    max-width: 100% !important;
    width: 100%;
  }
  
  /* DO NOT make toggle full width - keep it compact */
  .summary-view-toggle {
    width: auto !important;
    max-width: none !important;
  }
  
  .summary-view-toggle-btn {
    padding: 6px 10px;
    font-size: 12px;
  }
}

.dispensary-summary-heading { 
  font-size: 22px;
  font-weight: 600;
  color: #000000;
  margin: 0 0 16px 0; 
}

.dispensary-summary-section {
  margin-top: 20px;
  width: 100%;
  display: block;
  clear: both;
  position: relative;
  grid-column: 1 / -1;
}

.stock-summary-section {
  margin-top: 10px;
  width: 100%;
  display: block;
  clear: both;
  position: relative;
  grid-column: 1 / -1;
}

/* Best Sellers Styling */
.best-sellers-content {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 16px 8px 16px;
  min-height: 200px;
  flex: 1;
}

.best-seller-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--surfaceBorder);
  gap: 16px;
}

.best-seller-item:last-child {
  border-bottom: none;
}

/* Worst GP List Modal Styles */
.worst-gp-list-container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 0;
}

.worst-gp-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 16px !important;
  border-bottom: 1px solid var(--surfaceBorder);
  gap: 16px;
  background: transparent !important;
  border-radius: 0 !important;
  margin: 0 !important;
  line-height: 1.2 !important;
  transition: background-color 0.2s ease;
}

.worst-gp-list-item:hover {
  background: var(--surfaceHover) !important;
}

.worst-gp-list-item:last-child {
  margin-bottom: 0 !important;
  border-bottom: none !important;
}

.worst-gp-rank {
  font-size: 1rem;
  font-weight: 700;
  color: var(--textMuted);
  min-width: 30px;
  text-align: center;
  line-height: 1;
}

.worst-gp-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  line-height: 1.2;
}

.worst-gp-name {
  font-weight: 600;
  color: var(--textPrimary);
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
  margin: 0;
  padding: 0;
}

.worst-gp-code {
  font-size: 0.75rem;
  color: var(--textMuted);
  line-height: 1.2;
  margin: 0;
  padding: 0;
}

.worst-gp-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  min-width: 100px;
  line-height: 1.2;
}

.worst-gp-qty {
  font-size: 0.75rem;
  color: var(--textMuted);
  font-weight: 400;
  line-height: 1;
  margin: 0;
  padding: 0;
}

.worst-gp-gp {
  font-size: 1.1rem;
  font-weight: 700;
  color: #e74c3c;
  line-height: 1;
  margin: 0;
  padding: 0;
}

/* Full screen height for Worst GP Modal */
.metric-modal-overlay.worst-gp .metric-modal {
  max-height: 100vh;
  max-height: 100svh; /* Small viewport height for mobile */
  height: 100vh;
  height: 100svh; /* Small viewport height for mobile */
  max-width: 900px;
}

.metric-modal-overlay.worst-gp .metric-modal-content {
  flex: 1;
  overflow-y: auto;
  display: block;
  padding: 16px 24px 24px;
}

/* Threshold Controls */
.worst-gp-threshold-controls {
  padding: 16px 24px;
  background: var(--surfaceCard);
  border-bottom: 1px solid var(--surfaceBorder);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.worst-gp-threshold-controls label {
  font-size: 0.9rem;
  color: var(--textSecondary);
  font-weight: 500;
}

.threshold-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.threshold-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.threshold-input-group input[type="number"] {
  width: 80px;
  padding: 8px 12px;
  border: 1px solid var(--surfaceBorder);
  border-radius: 6px;
  background: var(--surfaceBase);
  color: var(--textPrimary);
  font-size: 1rem;
  font-weight: 600;
}

.threshold-input-group input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.threshold-percent {
  font-size: 1rem;
  font-weight: 600;
  color: var(--textSecondary);
  margin-left: -4px;
}

.threshold-count {
  font-size: 0.85rem;
  color: var(--textMuted);
  font-style: italic;
}

/* Mobile styles for worst GP modal - keep full screen */
@media (max-width: 768px) {
  .metric-modal-overlay.worst-gp .metric-modal {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100svh; /* Small viewport height for mobile browsers */
    max-height: 100vh;
    max-height: 100svh; /* Small viewport height for mobile browsers */
    margin: 0;
    border-radius: 0;
  }
  
  .metric-modal-overlay.worst-gp .metric-modal-content {
    padding: 12px 16px 16px;
  }
  
  .worst-gp-list-container {
    padding: 4px;
  }
  
  .worst-gp-threshold-controls {
    padding: 12px 16px;
  }
  
  .threshold-input-group {
    flex-wrap: wrap;
  }
}

.best-seller-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.best-seller-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--textPrimary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.3px;
}

.best-seller-code {
  font-size: 11px;
  font-weight: 400;
  color: var(--textMuted);
  letter-spacing: 0.3px;
}

.best-seller-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.best-seller-qty {
  font-size: 17px;
  font-weight: 700;
  color: var(--chartGP);
  text-align: right;
  white-space: nowrap;
}

.best-seller-gp {
  font-size: 11px;
  font-weight: 500;
  color: var(--textMuted);
  text-align: right;
  white-space: nowrap;
}

/* Best Sellers responsive font sizes to match dispensary cards */

/* Tablet (600-768px) */
@media (max-width: 768px) {
  .best-seller-name {
    font-size: 13px;
  }
  
  .best-seller-qty {
    font-size: 15px;
  }
}

/* Mobile (< 600px) */
@media (max-width: 600px) {
  .best-seller-name {
    font-size: 14px;
  }
  
  .best-seller-qty {
    font-size: 13px;
  }
}

/* Very Small (< 480px) */
@media (max-width: 480px) {
  .best-seller-name {
    font-size: 13px;
  }
  
  .best-seller-qty {
    font-size: 14px;
  }
}

.daily-summary-header {
  margin-bottom: 24px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--textPrimary);
  margin: 0 0 8px 0;
  letter-spacing: -0.5px;
}

.section-subtitle {
  font-size: 12px;
  color: var(--textMuted);
  margin: 0;
}

/* Dashboard combined metrics card - hidden on larger screens */
.dashboard-combined-metrics-card {
  display: none;
  margin-bottom: 24px;
}

/* Dashboard summary cards styling - match daily screen */
.dashboard-summary-layout > .dashboard-card {
  grid-column: span 1;
}

/* Hide individual dashboard summary cards on very small mobile, show combined card */
@media (max-width: 430px) {
  .dashboard-summary-layout > .dashboard-card {
    display: none;
  }
  
  /* Exception: Keep debtor tools cards visible */
  .debtor-tools-container .debtor-summary-layout > .dashboard-card,
  .debtor-tools-container .debtor-summary-layout > .debtor-overview-cards > .dashboard-card,
  .debtor-tools-container .debtor-ageing-card {
    display: flex !important;
  }
  
  /* Ensure debtor table section and its contents remain visible on very small mobile */
  #debtor-table-section {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  #debtor-table-section .debtor-table-search-container,
  #debtor-table-section .debtor-table-container,
  #debtor-table-section .debtor-table-wrapper {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  #debtor-table-section .debtor-table {
    display: table !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  /* Ensure debtor statistics section remains visible */
  #debtor-statistics-section {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  .single-pharmacy-view .dashboard-combined-metrics-card {
    display: block !important;
    margin-bottom: 16px;
  }
  
  .group-view-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
    max-width: 100% !important;
    margin-left: 0;
    margin-right: 0;
  }
  
  .group-view-container {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
  }
  
  /* Reset grid positions on mobile */
  #group-card-gp,
  #group-card-basket {
    grid-row: auto !important;
    grid-column: auto !important;
  }
  
  .group-pharmacy-card {
    display: block !important;
  }
}

/* Force single column on all mobile screens */
@media (max-width: 430px) {
  #group-view-grid.group-view-grid {
    grid-template-columns: 1fr !important;
  }
  
  /* Reset grid positions on mobile */
  #group-card-gp,
  #group-card-basket {
    grid-row: auto !important;
    grid-column: auto !important;
  }
}

/* Show dashboard summary cards above 430px */
@media (min-width: 431px) {
  .single-pharmacy-view .dashboard-combined-metrics-card {
    display: none !important;
  }
}

/* Below grid section */
.dashboard-below-grid {
  width: 100%;
}

/* Full width on tablet/medium screens (matching daily summary) */
@media (min-width: 769px) and (max-width: 1366px) {
  .dashboard-summary-layout {
    max-width: 100%;
  }
  
  .group-view-container {
    max-width: 100%;
    width: 100%;
  }
  
  .group-view-grid {
    max-width: 100% !important;
    width: 100% !important;
  }
  
  .spend-analytics-container {
    max-width: 100%;
  }
  
  .debtor-tools-container {
    max-width: 100%;
  }
}

/* Very large screens - 2/3 width to match daily summary */
@media (min-width: 1367px) {
  .dashboard-summary-layout {
    max-width: 66.67%;
  }
  
  .spend-analytics-container {
    max-width: 66.67%;
  }
  
  .debtor-tools-container {
    max-width: 66.67%;
  }
  
  /* Ensure summary layout inside debtor tools matches container width */
  .debtor-tools-container .debtor-summary-layout {
    max-width: 100% !important;
  }
  
  /* Make debtor table section full width on large screens */
  #debtor-table-section {
    width: 150% !important; /* 100% / 66.67% = 150% to fill available content width */
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0px !important;
    padding-right: 24px !important;
  }
  
  /* Keep search aligned with other sections */
  #debtor-table-section .debtor-table-search-container {
    width: 66.67%;
    max-width: 66.67%;
    margin-left: 0;
  }
  
  /* Make table container full width within section */
  #debtor-table-section .debtor-table-container {
    max-width: 100% !important;
    width: 100% !important;
  }
  
  .top-bar-controls {
    /* Align with cards on large screens (66.67% instead of 75%) */
    margin-right: calc(100% - 66.67%); /* Position right edge at 66.67% to match cards */
  }
  
  .section-heading-with-toggle {
    max-width: 66.67%; /* Align with cards on large screens */
  }
}

/* Responsive adjustments for tablets - 2 columns */
@media (min-width: 481px) and (max-width: 768px) {
  .dashboard-summary-layout {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 100%;
  }
  
  .spend-analytics-metric-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 100%;
  }
  
  .group-view-container {
    max-width: 100%;
    width: 100%;
  }
  
  .group-view-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 100% !important;
    width: 100% !important;
  }
  
  .spend-analytics-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 100%;
  }
  
  .spend-analytics-container .dashboard-card[style*="grid-column: span 2"] {
    grid-column: span 2 !important;
  }
  
  .spend-analytics-container .chart-container {
    height: 160px; /* reduced on tablets */
  }
  
  .spend-analytics-chart-container {
    height: 160px;
  }
  
  .spend-analytics-chart-svg {
    max-width: 130px;
  }
  
  .stock-bar-label {
    font-size: 7px;
    line-height: 1.1;
    margin-top: 2px;
  }
}

@media (max-width: 480px) {
  .dashboard-summary-layout {
    grid-template-columns: 1fr;
    gap: 10px;
    max-width: 100%;
  }
  
  .spend-analytics-metric-cards {
    grid-template-columns: 1fr;
    gap: 10px;
    max-width: 100%;
  }
  
  .group-view-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
    max-width: 100% !important;
  }
  
  .group-view-container {
    margin-left: 0;
    margin-right: 0;
  }
  
  .spend-analytics-container {
    grid-template-columns: 1fr;
    gap: 10px;
    max-width: 100%;
  }
  
  .spend-analytics-container .dashboard-card[style*="grid-column: span 2"] {
    grid-column: span 1 !important;
  }
  
  .spend-analytics-container .chart-container {
    height: 160px; /* reduced on mobile */
  }
  
  .spend-analytics-chart-container {
    height: 160px;
  }
  
  .spend-analytics-chart-svg {
    max-width: 120px;
  }
  
  .spend-analytics-container .chart-center-value {
    font-size: 18px;
  }
}

/* Daily Summary Layout - 2x2 grid on left, large card on right */
/* Daily Summary Layout - 2-column layout with dispensary card below */
.daily-summary-layout {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

/* First 4 cards span 1 column each in 2x2 grid */
.daily-summary-layout > .dashboard-card:not(.metric-dispensary) {
  grid-column: span 1;
}

/* Dispensary card spans full width below the 4 metric cards */
.metric-dispensary {
  grid-column: span 2;
  grid-row: auto;
}

.detail-card .card-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--textSecondary);
  font-size: 14px;
}


/* Dispensary Metrics List */
.dispensary-metrics-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Three-column layout for dispensary card on screens wider than 530px */
@media (min-width: 531px) {
  .dispensary-columns {
    display: flex;
    gap: 16px;
    width: 100%;
    padding: 0 16px 0 16px;
  }
  
  .dispensary-column-left {
    flex: 0 0 45%;
    display: flex;
    flex-direction: column;
    gap: 0;
  }
  
  .dispensary-column-center {
    flex: 0 0 10%;
    /* Blank column - no content */
  }
  
  .dispensary-column-right {
    flex: 0 0 45%;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-right: 16px;
  }
  
  .dispensary-column-left .dispensary-list-item,
  .dispensary-column-right .dispensary-list-item {
    border-bottom: 1px solid var(--surfaceBorder);
  }
  
  .dispensary-column-left .dispensary-list-item:last-child,
  .dispensary-column-right .dispensary-list-item:last-child {
    border-bottom: none;
  }
}

/* Single column layout for screens 530px and narrower */
@media (max-width: 530px) {
  .dispensary-columns {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0 12px 0 12px;
  }
  
  .dispensary-column-left,
  .dispensary-column-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
  }
  
  .dispensary-column-right {
    padding-right: 12px;
  }
  
  .dispensary-column-center {
    display: none; /* Hide center column on mobile */
  }
  
  .dispensary-column-left .dispensary-list-item,
  .dispensary-column-right .dispensary-list-item {
    border-bottom: 1px solid var(--surfaceBorder);
  }
  
  .dispensary-column-right .dispensary-list-item:last-child {
    border-bottom: none;
  }
}

.dispensary-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--surfaceBorder);
  position: relative;
}

.dispensary-list-item:last-child {
  border-bottom: none;
}


.dispensary-percentage-circle {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: conic-gradient(
    #FF4509 0deg,
    #FF4509 var(--dispensary-percentage-angle, 0deg),
    #E5E7EB var(--dispensary-percentage-angle, 0deg),
    #E5E7EB 360deg
  );
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.dispensary-percentage-circle::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  z-index: 1;
}

.dispensary-percentage-value {
  font-size: 8px;
  font-weight: 700;
  color: var(--textPrimary);
  z-index: 2;
  position: relative;
}

/* Front Shop Percentage Circle */
.dispensary-list-item:nth-child(2) .dispensary-percentage-circle {
  background: conic-gradient(
    var(--chartGP) 0deg,
    var(--chartGP) var(--frontshop-percentage-angle, 0deg),
    #E5E7EB var(--frontshop-percentage-angle, 0deg),
    #E5E7EB 360deg
  );
}

/* Dispensary Content Wrapper - Flex container for list and chart */
.dispensary-content-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: -12px;
}

/* Split and Scripts Card Layout */
.split-content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
  align-items: stretch;
  min-height: auto;
  position: relative;
  overflow: visible;
  padding: 0 16px 0 16px;
}

/* Dispensary Chart Container */
.dispensary-chart-container {
  position: relative;
  width: 100px;
  height: 100px;
  max-width: 100px;
  max-height: 100px;
  flex-shrink: 0;
}

.dispensary-chart-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.chart-segment {
  stroke-dasharray: 314;
  stroke-dashoffset: 314;
  transition: stroke-dashoffset 1s ease;
}

.chart-center-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.chart-center-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--textPrimary);
  line-height: 1;
}

.chart-center-label {
  font-size: 8px;
  font-weight: 400;
  color: #9CA3AF;
  letter-spacing: 0.5px;
  margin-top: 2px;
  line-height: 1;
  text-transform: uppercase;
}

/* Spend Analytics Chart Container */
.spend-analytics-chart-container {
  position: relative;
  width: 100%;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 16px 0;
}

.spend-analytics-chart-svg {
  width: 100%;
  max-width: 140px;
  height: auto;
  transform: rotate(-90deg);
}

/* Spend Budget Card Layout - Metrics on left (2/3), chart on right (1/3) */
.spend-budget-card-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 140px;
}

.spend-budget-metrics {
  flex: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding-right: 10px;
}

.spend-budget-metric-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.spend-budget-metric-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--textSecondary);
}

.spend-budget-metric-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--textPrimary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.spend-budget-chart-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  max-width: 80%;
}

.spend-budget-chart-wrapper .spend-analytics-chart-svg {
  width: 100%;
  height: auto;
}

/* Spend Budget card header color (green) */
.spend-budget-card .card-header.with-icon h3 { color: var(--chartGP); }
.spend-budget-card .card-header.with-icon .card-icon { color: var(--chartGP); }
.spend-budget-card .card-header.with-icon .card-icon svg { width: 20px; height: 20px; }

/* Purchase vs Turnover header (orange) */
.spend-turnover-card .card-header.with-icon h3 { color: var(--chartTurnover); }
.spend-turnover-card .card-header.with-icon .card-icon { color: var(--chartTurnover); }
.spend-turnover-card .card-header.with-icon .card-icon svg { width: 20px; height: 20px; }

.scripts-content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 12px 0 12px;
  margin-top: 12px;
}

.split-list-item,
.scripts-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
  position: relative;
}

/* Border on all split items except last - creates line between items */
.split-list-item:not(:last-child) {
  border-bottom: 1px solid var(--surfaceBorder) !important;
}

/* Border on all scripts items except last */
.scripts-list-item:not(:last-child) {
  border-bottom: 1px solid var(--surfaceBorder);
}

.split-list-item:last-child,
.scripts-list-item:last-child {
  border-bottom: none !important;
}

/* Color coding for new cards */
.metric-split .card-header.with-icon h3 { color: var(--chartTurnover); }
.metric-split .card-header.with-icon .card-icon { color: var(--chartTurnover); }

/* Stock summary best sellers card - green color */
.stock-summary-section .metric-split .card-header.with-icon h3 { color: var(--chartGP); }
.stock-summary-section .metric-split .card-header.with-icon .card-icon { color: var(--chartGP); }
/* Note: .card-arrow is not overridden, so it stays grey by default (like turnover card) */

.metric-scripts .card-header.with-icon h3 { color: var(--chartBasket); }
.metric-scripts .card-header.with-icon .card-icon { color: var(--chartBasket); }

/* Ensure both Split and Scripts cards have same height */
.metric-split {
  min-height: 150px;
  max-height: 150px;
  padding: 8px 0 4px 0;
}

/* Stock summary cards should be flexible to show full list */
.stock-summary-section .metric-split,
.stock-summary-section .metric-scripts {
  min-height: auto;
  max-height: none;
  height: auto;
  display: flex;
  flex-direction: column;
}

/* Make stock summary cards equal width (50% each) */
@media (min-width: 531px) {
  .stock-summary-section .metric-split,
  .stock-summary-section .metric-scripts {
    flex: 0 0 calc(50% - 8px);
    min-width: 250px;
  }
}

.metric-scripts {
  padding: 8px 0 4px 0;
}

.metric-split {
  overflow: visible !important;
}

/* Reduce header margin for dispensary cards */
.metric-split .card-header.with-icon,
.metric-scripts .card-header.with-icon {
  margin-bottom: 2px;
  padding: 0 16px;
}

/* Dispensary Cards Container */
.dispensary-cards-container {
  display: flex;
  flex-direction: row;
  gap: 16px;
  align-items: flex-start;
  margin-top: 0;
  width: 100%;
  flex-wrap: wrap;
  justify-content: flex-start;
  position: relative;
  z-index: 1;
}

/* Responsive layout for Split and Scripts cards */
@media (min-width: 531px) {
  .dispensary-cards-container {
    flex-direction: row;
    justify-content: space-between;
  }
  
  .metric-split {
    flex: 0 0 calc(65% - 8px);
    min-width: 300px;
    margin-bottom: 16px;
    max-width: none;
  }
  
  .metric-scripts {
    flex: 0 0 calc(35% - 8px);
    min-width: 200px;
    margin-bottom: 16px;
    max-width: none;
  }
}

/* On larger screens (>955px), make both cards same height for side-by-side balance */
@media (min-width: 956px) {
  .metric-scripts {
    min-height: 150px;
    max-height: 150px;
  }
}

/* Mobile Scripts Section Styles */
.scripts-section-mobile {
  display: none;
  padding: 0;
  border-top: none;
  margin: 0;
  background: transparent;
}


.scripts-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.scripts-header h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--chartBasket);
  margin: 0;
}

.scripts-icon {
  width: 16px;
  height: 16px;
  color: var(--chartBasket);
}

@media (max-width: 955px) {
  .dispensary-cards-container {
    flex-direction: column;
    gap: 16px;
  }
  
  .metric-split {
    margin-bottom: 0;
    margin-left: 0;
    margin-right: 0;
    flex: none;
    width: 100%;
    max-width: none;
    min-width: auto;
    min-height: auto;
    max-height: none;
    border-radius: 16px;
    overflow: visible;
    padding: 8px 0 4px 0;
  }
  
  .dispensary-content-wrapper {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
  }
  
  .dispensary-chart-container {
    order: 2; /* Keep chart on right */
    flex-shrink: 0;
  }
  
  .split-content-wrapper {
    order: 1; /* Keep list on left */
    flex: 1;
  }
  
  .metric-scripts {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    padding: 8px 0 4px 0;
  }
  
  .scripts-section-mobile {
    display: none;
  }
  
  .split-content-wrapper {
    flex-direction: column;
    gap: 0px;
    min-height: auto;
    align-items: stretch;
    padding: 0 16px 0 16px;
    margin-bottom: 0;
  }
  
  
  /* Progress bar for mobile */
  .dispensary-progress-mobile {
    display: block;
    width: 70%;
    margin: 0 auto;
    padding: 4px 20px 8px 20px;
  }
  
  .progress-label {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 4px;
  }
  
  .progress-percentage {
    font-size: 18px;
    font-weight: 700;
    color: #000000;
  }
  
  .progress-bar-container {
    width: 100%;
    height: 10px;
    background: #E5E7EB;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
  }
  
  .progress-bar-fill {
    height: 100%;
    background: var(--chartTurnover);
    border-radius: 5px;
    transition: width 0.5s ease;
  }
}

@media (max-width: 530px) {
  .dispensary-cards-container {
    flex-direction: column;
    gap: 16px;
  }
  
  .metric-split,
  .metric-scripts {
    margin-bottom: 0;
    margin-left: 0;
    margin-right: 0;
  }
  
  /* Keep horizontal layout for split card */
  .metric-split .dispensary-content-wrapper {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  
  .split-content-wrapper {
    flex: 1;
  }
  
  /* Make chart smaller on very small screens */
  .dispensary-chart-container {
    width: 100px;
    height: 100px;
    flex-shrink: 0;
  }
  
  .chart-center-value {
    font-size: 20px;
  }
  
}

.dispensary-list-label {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.3px;
}

.dispensary-list-value-wrapper {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.dispensary-list-currency {
  font-size: 13px;
  font-weight: 500;
  color: var(--textMuted);
}

.dispensary-list-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--textPrimary);
}


/* Colored labels matching metric colors */
.dispensary-label-scripts {
  color: #000000;
}

.dispensary-label-avg {
  color: #000000;
}

.dispensary-label-dispensary {
  color: #FF4509;
}

.dispensary-label-frontshop {
  color: #59BA47;
}




/* Divider no longer needed in 2x2 grid layout */

.dashboard-card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(15px) saturate(120%);
  -webkit-backdrop-filter: blur(15px) saturate(120%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  padding: 20px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 4px 16px rgba(0, 0, 0, 0.08),
    0 2px 4px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  position: relative;
  overflow: hidden;
  will-change: transform;
}

/* Subtle card highlight */
.dashboard-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 30%;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.1) 0%,
    transparent 100%
  );
  border-radius: 16px 16px 0 0;
  pointer-events: none;
}

.dashboard-card:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 
    0 8px 24px rgba(0, 0, 0, 0.12),
    0 4px 8px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.dashboard-card:hover::before {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.15) 0%,
    transparent 100%
  );
}

.dashboard-card.wide {
  grid-column: span 2;
}

.dashboard-card.primary {
  background: linear-gradient(135deg, #FF4509 0%, #FFA500 100%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 
    0 12px 32px rgba(244, 122, 32, 0.35),
    0 4px 12px rgba(244, 122, 32, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.dashboard-card.primary:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 
    0 20px 48px rgba(244, 122, 32, 0.4),
    0 8px 16px rgba(244, 122, 32, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.dashboard-card.primary::before {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.25) 0%,
    transparent 100%
  );
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.card-header h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--textSecondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.dashboard-summary-layout .card-header.with-icon h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Metric Card Icon Styling */
.metric-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.metric-card-icon svg {
  width: 22px;
  height: 22px;
  color: white;
}

.card-header.with-icon {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  justify-content: flex-start;
}

/* Daily Summary Metric Cards - Smaller fonts */
.daily-summary-layout .card-header.with-icon h3 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0;
}

.card-header.with-icon .card-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.card-header.with-icon .card-icon svg {
  width: 100%;
  height: 100%;
}

.card-header.with-icon .card-arrow {
  margin-left: auto;
  color: var(--textMuted);
  opacity: 0.6;
}

.card-header.with-icon .card-arrow svg {
  width: 100%;
  height: 100%;
}

/* Metric Modal Styles */
.metric-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.metric-modal-overlay.active {
  display: flex;
}

.metric-modal {
  background: var(--surfaceCard);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  width: min(90vw, 1000px);
  height: min(60vh, 450px);
  max-width: 90vw;
  max-height: 60vh;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Responsive modal sizing for portrait */
@media (max-aspect-ratio: 1/1) {
  .metric-modal {
    width: 95vw;
    height: min(52.5vh, 375px);
    max-width: 95vw;
    max-height: 52.5vh;
  }
}

/* Force landscape orientation for screens narrower than 600px */
@media (max-width: 600px) and (orientation: portrait) {
  .metric-modal-overlay.landscape-mode {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 100vh;
    height: 100vw;
    transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center center;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .metric-modal-overlay.landscape-mode .metric-modal {
    width: 85vh;
    height: 75vw;
    max-width: 85vh;
    max-height: 75vw;
  }
  
  /* Adjust modal header for better spacing */
  .metric-modal-overlay.landscape-mode .metric-modal-header {
    padding: 12px 20px;
    min-height: 50px;
  }
  
  .metric-modal-overlay.landscape-mode .metric-modal-title {
    font-size: 18px;
  }
  
  /* Adjust modal content for landscape */
  .metric-modal-overlay.landscape-mode .metric-modal-content {
    flex: 1;
    padding: 12px 20px 16px;
    min-height: 0;
    overflow: hidden;
    position: relative;
  }
  
  .metric-modal-overlay.landscape-mode .metric-modal-content canvas {
    display: block;
  }
  
  /* Ensure body doesn't scroll during landscape modal */
  body.landscape-modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
  }
}

.metric-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--surfaceBorder);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metric-modal-close {
  background: none;
  border: none;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--textSecondary);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.metric-modal-close:hover {
  background: var(--surfaceHover);
  color: var(--textPrimary);
}

.metric-modal-title-section {
  flex: 1;
  text-align: center;
}

.metric-modal-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 4px 0;
  color: var(--textPrimary);
}

.metric-modal-date-info {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.metric-modal-date-range {
  font-size: 13px;
  color: var(--textSecondary);
}

.metric-modal-content {
  flex: 1;
  padding: 16px 24px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.metric-modal-content canvas {
  display: block;
}

/* Metric Modal Header */
.metric-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--surfaceBorder);
}

.metric-modal-title-section {
  flex: 1;
}

/* Metric Modal Title Row */
.metric-modal-title-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.metric-modal-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--chartTurnover);
  margin: 0;
}

.metric-modal-close {
  background: none;
  border: none;
  color: var(--textSecondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.metric-modal-close:hover {
  background: var(--surfaceHover);
  color: var(--chartTurnover);
}

/* Purchases Toggle */
.purchases-toggle {
  display: flex;
  gap: 6px;
}

.toggle-button {
  padding: 4px 8px;
  border: 1px solid var(--surfaceBorder);
  background: transparent;
  color: var(--textSecondary);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.toggle-button:hover {
  border-color: var(--chartTurnover);
  color: var(--chartTurnover);
}

.toggle-button.active {
  background: var(--chartTurnover);
  border-color: var(--chartTurnover);
  color: white;
}

@media (max-width: 600px) {
  .metric-modal-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .purchases-toggle {
    align-self: flex-start;
  }
}

/* All modal titles use orange color */
.metric-modal-overlay .metric-modal-title { color: var(--chartTurnover); }

/* Metric-specific colors */
.metric-turnover .card-header.with-icon h3 { color: var(--chartTurnover); }
.metric-turnover .card-header.with-icon .card-icon { color: var(--chartTurnover); }

.metric-gp .card-header.with-icon h3 { color: var(--chartGP); }
.metric-gp .card-header.with-icon .card-icon { color: var(--chartGP); }

.metric-purchases .card-header.with-icon h3 { color: var(--chartPurchases); }
.metric-purchases .card-header.with-icon .card-icon { color: var(--chartPurchases); }
.metric-purchase-budget .card-header.with-icon h3 { color: var(--chartTurnover); }
.metric-purchase-budget .card-header.with-icon .card-icon { color: var(--chartTurnover); }

.metric-basket .card-header.with-icon h3 { color: var(--chartBasket); }
.metric-basket .card-header.with-icon .card-icon { color: var(--chartBasket); }

/* Cost of Sales uses purple (same as basket color class) */
.metric-cost-of-sales .card-header.with-icon h3 { color: var(--chartBasket); }
.metric-cost-of-sales .card-header.with-icon .card-icon { color: var(--chartBasket); }

.metric-dispensary .card-header.with-icon h3 { color: var(--chartExtra1); }
.metric-dispensary .card-header.with-icon .card-icon { color: var(--chartExtra1); }

/* Value styling with grey R */
.card-value-wrapper {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.daily-summary-layout .card-value-currency {
  font-size: 16px;
  font-weight: 700;
  color: var(--textMuted);
}

/* Hide the % symbol for GP% card */
#daily-gp-percent-currency {
  display: none;
}

.daily-summary-layout .card-value-amount {
  font-size: 22px;
  font-weight: 700;
  color: var(--textPrimary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

/* Card Comparison Styling */
.card-comparison {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.comparison-text {
  font-size: 10px;
  color: var(--textMuted);
  font-weight: 500;
}

.comparison-percentage {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.comparison-percentage.positive {
  color: var(--chartGP);
}

.comparison-percentage.negative {
  color: var(--chartTurnover);
}

/* Simplified Comparison Styling */
.daily-summary-layout .card-comparison-simple {
  font-size: 12px;
  font-weight: 700;
  color: var(--textSecondary);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.daily-summary-layout .card-comparison-simple .comparison-percentage {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.card-comparison-simple .comparison-percentage.positive {
  color: var(--chartGP);
}

.card-comparison-simple .comparison-percentage.negative {
  color: var(--chartTurnover);
}

.dashboard-card.primary .card-header h3 {
  color: rgba(255, 255, 255, 0.9);
}

.dashboard-card.primary .card-header.with-icon .card-icon {
  color: #ffffff !important;
}

.dashboard-card.primary .card-header.with-icon .card-icon svg {
  color: #ffffff !important;
  stroke: #ffffff !important;
}

.dashboard-card.primary .card-header.with-icon h3 {
  color: rgba(255, 255, 255, 0.9);
}

.card-value-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 0;
  position: relative; /* For absolute positioning of percentage badge */
}

.card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--textPrimary);
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  position: relative;
  z-index: 1;
}

.card-value-row .card-value {
  margin-bottom: 0;
}

/* Dashboard summary cards - match daily screen font sizes */
.dashboard-summary-layout .card-value-amount {
  font-size: 22px; /* Match daily screen .card-value-amount size */
  font-weight: 700; /* Match daily screen font weight */
  color: var(--textPrimary);
  font-variant-numeric: tabular-nums;
  line-height: 1; /* Match daily screen line height */
}

/* Dashboard summary currency - match daily screen (smaller, grey on white cards) */
.dashboard-summary-layout .card-value-currency {
  font-size: 16px;
  font-weight: 700;
  color: var(--textMuted);
}

/* Primary card (orange gradient) - white currency */
.dashboard-card.primary .card-value-currency {
  color: rgba(255, 255, 255, 0.9);
}

.dashboard-card.primary .card-value-amount {
  color: white;
}

.card-comparison-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--textSecondary);
  margin-top: 4px; /* Match daily screen spacing */
  text-align: left;
}

.dashboard-card.primary .card-comparison-text {
  color: rgba(255, 255, 255, 0.85);
}

.card-value-percentage {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  position: absolute;
  top: 0;
  right: 0;
  z-index: 10;
  white-space: nowrap;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.card-value-percentage.positive {
  background-color: #59BA47;
  color: white;
}

.dashboard-card.primary .card-value-percentage.positive {
  background-color: #59BA47;
  color: white;
}

.card-value-percentage.negative {
  background-color: #FF4509;
  color: white;
}

.dashboard-card.primary .card-value-percentage.negative {
  background-color: #FF4509;
  color: white;
}

.card-subtitle {
  font-size: 11px;
  color: var(--textMuted);
}

.dashboard-card.primary .card-subtitle {
  color: rgba(255, 255, 255, 0.8);
}

/* Growth Cards */
.dashboard-card.growth .growth-value.positive {
  color: var(--statusSuccess);
}

.dashboard-card.growth .growth-value.negative {
  color: var(--statusError);
}

/* Spend Analysis */
.spend-comparison {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.spend-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.spend-label {
  font-size: 13px;
  color: var(--textSecondary);
  font-weight: 500;
}

.spend-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--textPrimary);
  font-variant-numeric: tabular-nums;
}

.spend-bar {
  height: 10px;
  background: var(--bgPrimary);
  border-radius: 5px;
  overflow: hidden;
}

.spend-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.8s ease;
}

.spend-fill.actual {
  background: linear-gradient(90deg, var(--chartPurple) 0%, var(--chartIndigo) 100%);
}

.spend-fill.purchases {
  background: linear-gradient(90deg, var(--accentPrimary) 0%, var(--accentLight) 100%);
}

.spend-summary {
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--surfaceBorder);
}

.spend-diff {
  font-size: 16px;
  font-weight: 600;
  text-align: center;
}

.spend-diff.positive {
  color: var(--statusSuccess);
}

.spend-diff.negative {
  color: var(--statusError);
}

/* Performance Circle */
.dashboard-card.performance {
  text-align: center;
  display: flex;
  flex-direction: column;
}

.performance-circle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 200px;
}

.progress-ring {
  transform: rotate(-90deg);
  width: min(200px, 70%);
  height: auto;
}

.progress-ring-bg {
  fill: none;
  stroke: var(--bgPrimary);
  stroke-width: 12;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--accentPrimary);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 377;
  stroke-dashoffset: 377;
  transition: stroke-dashoffset 1s ease, stroke 0.3s ease;
}

.performance-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.performance-value {
  font-size: 40px;
  font-weight: 700;
  color: var(--textPrimary);
}

.performance-label {
  font-size: 13px;
  color: var(--textMuted);
  margin-top: 4px;
}

/* Table Styles */
.table-wrap {
  overflow-x: auto;
  margin: 0 auto;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(15px) saturate(120%);
  -webkit-backdrop-filter: blur(15px) saturate(120%);
  box-shadow: 
    0 4px 16px rgba(0, 0, 0, 0.08),
    0 2px 4px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  position: relative;
  -webkit-overflow-scrolling: touch;
}

/* Limit targets table width on large screens */
@media (min-width: 1200px) {
  #tab-targets .table-wrap {
    max-width: 66.6%;
    margin-left: 0;
    margin-right: auto;
  }
}


.table-wrap::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 25%;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.1) 0%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 0;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11px;
  position: relative;
  z-index: 1;
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--bgPrimary);
  text-align: center;
  vertical-align: middle;
  padding: 12px 10px;
  font-size: 9px;
  font-weight: 600;
  color: var(--textMuted);
  border-bottom: 1px solid var(--surfaceBorder);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 10;
}

.data-table th.num, .data-table td.num {
  text-align: right;
}

.data-table tbody td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--surfaceBorder);
  line-height: 1.4;
  color: var(--textPrimary);
}

.data-table tbody tr:hover td {
  background: var(--bgPrimary);
}

.data-table tfoot td {
  padding: 14px 10px;
  font-weight: 700;
  border-top: 2px solid var(--surfaceBorder);
  background: var(--bgPrimary);
  font-size: 11px;
  color: var(--textPrimary);
}

.data-table tr.total td {
  background: var(--bgPrimary);
  font-weight: 700;
}

.center {
  text-align: center;
}

.data-table tbody tr.weekend td {
  background: rgba(0, 122, 255, 0.05);
}

.data-table td.date {
  font-weight: 600;
}

.data-table tbody tr td.budget-to,
.data-table tbody tr td.budget-spend {
  color: var(--textMuted);
}

.data-table tbody tr td.purchase-budget-left {
  font-weight: 700;
}

.data-table tbody tr td.purchase-budget-left.positive {
  color: var(--statusSuccess);
}

.data-table tbody tr td.purchase-budget-left.negative {
  color: var(--statusError);
}

/* Hide second column (Date) on all screens - combine into first column */
.data-table th:nth-child(2),
.data-table td:nth-child(2) {
  display: none;
}

/* Show abbreviated date format on all screens */
.data-table tbody td:first-child .full-date,
.data-table thead th:first-child .full-header {
  display: none;
}

.data-table tbody td:first-child .short-date,
.data-table thead th:first-child .short-header {
  display: inline;
}

/* Make date column wider on desktop for better readability */
@media (min-width: 769px) {
  .data-table th:first-child,
  .data-table td:first-child {
    min-width: 110px;
    font-size: 11px;
    padding: 10px 8px;
  }
}

/* Mobile table optimizations - keep all columns, optimize scrolling */
@media (max-width: 768px) {
  .data-table {
    font-size: 11px;
  }
  
  .data-table thead th,
  .data-table tbody td,
  .data-table tfoot td {
    padding: 10px 8px;
    white-space: nowrap;
  }
  
  /* Sticky first column on mobile with combined date */
  .data-table th:first-child,
  .data-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    font-size: 10px;
    padding: 8px 6px;
    min-width: 95px;
    max-width: 95px;
    line-height: 1.3;
  }
  
  /* Make sure header sticky column has higher z-index */
  .data-table thead th:first-child {
    z-index: 4;
    background: rgba(255, 255, 255, 0.98);
  }
  
  /* Adjust footer sticky column */
  .data-table tfoot td:first-child {
    background: rgba(255, 255, 255, 0.98);
  }
}

.data-table th.soh, .data-table td.soh {
  color: var(--chartPurple);
}

.data-table tbody tr td.soh {
  background: rgba(175, 82, 222, 0.05);
}

.data-table tbody tr.no-data td {
  background: rgba(156, 163, 175, 0.05);
  color: var(--textMuted);
  font-style: italic;
}

.data-table tbody tr td.actual-to {
  color: var(--accentPrimary);
  font-weight: 700;
} 

.data-table input[type="number"],
.data-table input[type="text"],
.data-table input[type="date"] {
  font-size: 10px;
  padding: 2px 8px;
  height: auto;
  min-height: 24px;
  border-radius: 6px;
  margin: 0;
  box-sizing: border-box;
  vertical-align: middle;
  line-height: 1.4;
  border: 1px solid var(--surfaceBorder);
  background: var(--bgSecondary);
  color: var(--textPrimary);
}

.data-table input[type="number"]:focus,
.data-table input[type="text"]:focus,
.data-table input[type="date"]:focus {
  outline: none;
  border-color: var(--accentPrimary);
  box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.1);
}

/* Style for growth % input - can accept negative values */
.data-table input.growth-input {
  text-align: right;
}

.data-table input.target-input {
  text-align: right;
}

/* Reduce padding on cells containing inputs to match regular row height */
.data-table tbody td:has(input) {
  padding: 6px 10px;
}

/* Ensure consistent row height in tables with inputs */
.data-table tbody td {
  vertical-align: middle;
}

.muted {
  color: var(--textMuted);
  text-align: center;
  padding: 20px;
}

/* Toolbar */
.toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

/* Targets screen toolbar styling */
.targets-toolbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 16px;
  margin: 8px 0 24px 0;
  padding: 0;
  flex-wrap: wrap;
}

.targets-controls-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.targets-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--textPrimary);
  white-space: nowrap;
}

.targets-input {
  appearance: none;
  border: 1px solid var(--surfaceBorder);
  background: var(--bgSecondary);
  color: var(--textPrimary);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  width: 90px;
  min-height: 36px;
  transition: all 0.2s ease;
  font-family: inherit;
}

.targets-input:focus {
  outline: none;
  border-color: var(--accentPrimary);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

.targets-btn {
  padding: 8px 16px !important;
  font-size: 13px !important;
  font-weight: 500;
  min-height: 36px;
  height: 36px;
  width: 150px;
  white-space: nowrap;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto !important;
}

@media (max-width: 768px) {
  .targets-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  
  .targets-controls-group {
    width: 100%;
    flex-wrap: wrap;
  }
  
  .targets-btn {
    width: 100%;
  }
}

/* Tab panels */
.tab-panel {
  display: block !important;
  width: 100% !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: relative !important;
  z-index: 1 !important;
}

.tab-panel[hidden] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

/* Responsive Design */
@media (min-width: 1367px) {
  /* Apply 2/3 width constraint only on screens wider than 1366px */
  .daily-summary-layout {
    max-width: 66.67%; /* 2/3 of available width */
  }
}

@media (max-width: 1300px) {
  /* Layout already uses 2-column design, no changes needed */
}

@media (max-width: 1200px) {
  /* Chart size already set to 100px in base styles */
  
  .dispensary-performance-label {
    font-size: 20px;
    left: calc(100% + 20px);
    padding: 6px 10px;
  }
  
  .dispensary-list-value {
    font-size: 15px;
  }
}

/* Tablet Layout for Dispensary Card - Expanded Range */
@media (max-width: 1300px) and (min-width: 400px) {
  .metric-dispensary {
    display: flex;
    flex-direction: column;
  }
  
  .metric-dispensary .card-header {
    margin-bottom: 16px;
  }
  
  .metric-dispensary .dispensary-content-wrapper {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    flex: 1;
    width: 100%;
  }
  
  
  .metric-dispensary .dispensary-columns {
    flex: 1;
    margin-top: 0;
    padding-right: 0;
    min-width: 0;
    display: flex;
    gap: 16px;
    justify-content: center;
  }
  
  .metric-dispensary .dispensary-column-left {
    flex: 0 0 45%;
    display: flex;
    flex-direction: column;
    gap: 0;
  }
  
  .metric-dispensary .dispensary-column-center {
    flex: 0 0 10%;
    /* Blank column - no content */
  }
  
  .metric-dispensary .dispensary-column-right {
    flex: 0 0 45%;
    display: flex;
    flex-direction: column;
    gap: 0;
  }
  
  .metric-dispensary .dispensary-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--surfaceBorder);
    gap: 12px;
  }
  
  .metric-dispensary .dispensary-list-label {
    flex: 0 1 auto;
    min-width: fit-content;
  }
  
  .metric-dispensary .dispensary-list-value-wrapper {
    flex-shrink: 0;
    white-space: nowrap;
    margin-left: auto;
  }
  
  .metric-dispensary .dispensary-performance-label {
    position: static;
    transform: none;
    margin-top: 12px;
    font-size: 16px;
    padding: 6px 10px;
    text-align: center;
    width: fit-content;
    align-self: center;
  }
  
  .metric-dispensary .chart-center-value {
    font-size: 20px;
  }
  
  /* Responsive adjustments for smaller screens within the range */
  @media (max-width: 768px) {
    .metric-dispensary .dispensary-content-wrapper {
      gap: 6px;
    }
    
    .metric-dispensary .dispensary-metrics-list {
      padding-right: 3px;
    }
    
    .metric-dispensary .chart-center-value {
      font-size: 18px;
    }
    
    .metric-dispensary .dispensary-performance-label {
      font-size: 14px;
      padding: 4px 8px;
    }
    
    .metric-dispensary .dispensary-list-item {
      padding: 6px 0;
    }
  }
  
  @media (max-width: 600px) {
    .metric-dispensary .dispensary-content-wrapper {
      gap: 4px;
    }
    
    .metric-dispensary .dispensary-metrics-list {
      padding-right: 2px;
    }
    
    .metric-dispensary .chart-center-value {
      font-size: 16px;
    }
    
    .metric-dispensary .dispensary-performance-label {
      font-size: 12px;
      padding: 3px 6px;
    }
    
    .metric-dispensary .dispensary-list-item {
      padding: 5px 0;
      gap: 8px;
    }
  }
  
  @media (max-width: 480px) {
    .metric-dispensary .dispensary-content-wrapper {
      gap: 3px;
    }
    
    .metric-dispensary .dispensary-metrics-list {
      padding-right: 2px;
    }
    
    .metric-dispensary .chart-center-value {
      font-size: 14px;
    }
    
    .metric-dispensary .dispensary-performance-label {
      font-size: 11px;
      padding: 2px 4px;
    }
    
    .metric-dispensary .dispensary-list-item {
      padding: 4px 0;
      gap: 6px;
    }
  }
}

@media (max-width: 1024px) {
  .dashboard-card {
    padding: 16px;
  }
  
  .dashboard-card.wide {
    grid-column: span 1;
  }
  
  .app-layout {
    padding: 12px;
    gap: 12px;
  }
  
  /* Only apply these styles when NOT in tablet layout */
  .dispensary-chart-container {
    width: 90px;
    height: 90px;
  }
  
  .chart-center-value {
    font-size: 18px;
  }
  
  .dispensary-performance-label {
    font-size: 18px;
    left: calc(100% + 15px);
    padding: 5px 8px;
  }
  
  .chart-center-label {
    font-size: 8px;
  }
  
  .dispensary-list-value {
    font-size: 16px;
  }
  
  .dispensary-list-label {
    font-size: 13px;
  }
  
  .stock-bar-label {
    font-size: 7px;
    line-height: 1.1;
    margin-top: 2px;
  }
}

/* Ensure sidebar is visible on larger screens */
@media (min-width: 769px) {
  .sidebar {
    position: relative !important;
    transform: translateX(0) !important;
    left: auto !important;
    top: auto !important;
    z-index: 100 !important;
  }
}

@media (max-width: 768px) {
  .app-layout {
    padding: 0;
    gap: 0;
  }
  
  .sidebar {
    position: fixed !important;
    left: max(20px, env(safe-area-inset-left)) !important;
    top: max(20px, env(safe-area-inset-top)) !important;
    height: calc(100vh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    height: calc(100svh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important; /* Small viewport height for mobile browsers */
    max-height: calc(100svh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    transform: translateX(-120%) !important;
    z-index: 1003 !important; /* Higher than overlay */
    border-radius: 20px;
    isolation: isolate;
    pointer-events: auto !important;
    width: 325px;
    min-width: 325px;
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(20px) saturate(150%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(150%) !important;
  }
  
  .sidebar.open {
    transform: translateX(0) !important;
    pointer-events: auto !important;
  }
  
  /* Ensure all sidebar elements are interactive on mobile */
  .sidebar * {
    pointer-events: auto !important;
  }
  
  .sidebar-nav,
  .sidebar-header,
  .sidebar-footer {
    pointer-events: auto !important;
  }
  
  .nav-item {
    pointer-events: auto !important;
    cursor: pointer !important;
  }
  
  .mobile-menu-btn {
    display: flex !important;
  }
  
  .main-content {
    border-radius: 0;
    position: relative !important;
    z-index: 1 !important;
    overflow: visible !important;
  }
  
  /* Ensure tab panels are visible on mobile */
  .tab-panel {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 1 !important;
    width: 100% !important;
  }
  
  .top-bar {
    padding: max(16px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 16px max(20px, env(safe-area-inset-left));
  }
  
  /* Responsive dispensary card - stack grid on mobile */
  .dispensary-content {
    flex-direction: column;
    gap: 16px;
  }
  
  .dispensary-metrics-grid {
    flex: 1;
    gap: 12px;
  }
  
  .dispensary-extra-content {
    display: none;
  }
  
  .dispensary-list-value {
    font-size: 13px;
  }
  
  .dispensary-list-label {
    font-size: 14px;
  }
  
  .content-area {
    padding: 16px max(20px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  }
  
  .page-title {
    font-size: 26px;
  }
  
  /* Dashboard grid is already hidden below 1000px, don't override it */
  
  .dashboard-card {
    padding: 14px;
  }
  
  /* Ensure group view cards match single pharmacy view padding */
  .group-metric-card {
    padding: 14px !important;
  }
  
  .card-header h3 {
    font-size: 13px;
  }
  
  .card-value {
    font-size: 18px;
  }
  
  .card-value-amount {
    font-size: 18px;
  }
  
  .card-comparison-simple {
    font-size: 9px;
  }
  
  .card-icon svg {
    width: 18px;
    height: 18px;
  }
  
  .card-arrow svg {
    width: 12px;
    height: 12px;
  }
  
  .toolbar {
    grid-template-columns: 1fr;
  }
}

/* Very small screens - maintain 2 columns but adjust sizing */
@media (max-width: 480px) {
  /* Dashboard grid is already hidden below 1000px, don't override it */
  
  .dashboard-card {
    padding: 12px;
  }
  
  /* Ensure group view cards match single pharmacy view padding */
  .group-metric-card {
    padding: 12px !important;
  }
  
  .card-header h3 {
    font-size: 12px;
  }
  
  .card-value {
    font-size: 16px;
  }
  
  .card-value-amount {
    font-size: 16px;
  }
  
  .card-value-currency {
    font-size: 12px;
  }
  
  .card-comparison-simple {
    font-size: 8px;
  }
  
  /* Very small screen dispensary adjustments */
  .dispensary-list-value {
    font-size: 14px;
  }
  
  .dispensary-list-label {
    font-size: 13px;
  }
  
  /* Split card chart adjustments */
  .metric-split .dispensary-chart-container,
  .metric-scripts .dispensary-chart-container {
    width: 80px;
    height: 80px;
  }
  
  .metric-split .chart-center-value,
  .metric-scripts .chart-center-value {
    font-size: 18px;
  }
  
  .dispensary-performance-label {
    font-size: 16px;
    left: calc(100% + 10px);
    padding: 4px 6px;
  }
  
  .card-icon svg {
    width: 16px;
    height: 16px;
  }
}

/* Ultra small screens - combine metric cards into one card */
@media (max-width: 430px) {
  .daily-summary-layout {
    display: flex;
    flex-direction: column;
    gap: 0;
  }
  
  /* Hide individual metric cards */
  .daily-summary-layout > .dashboard-card:not(.metric-dispensary):not(.combined-metrics-card) {
    display: none;
  }
  
  /* Show combined metrics card */
  .combined-metrics-card {
    display: block;
    margin-bottom: 16px;
  }
}

/* Combined metrics card styling - APPLIES TO ALL SCREENS */
.combined-metric-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--surfaceBorder);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.combined-metric-section:last-child {
  border-bottom: none;
}

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

.combined-metric-header .card-arrow {
  margin-left: auto;
  color: var(--textMuted);
  opacity: 0.6;
}

.combined-metric-header .card-arrow svg {
  width: 100%;
  height: 100%;
}

.combined-metric-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.combined-metric-icon svg {
  width: 100%;
  height: 100%;
}

.combined-metric-header h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  color: var(--textPrimary);
}

/* Value and comparison in same row */
.combined-metric-value-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  position: relative; /* For absolute positioning of percentage badge */
  margin-bottom: 0;
}

.combined-metric-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.combined-metric-value .card-value-currency {
  font-size: 14px;
  font-weight: 700;
  color: var(--textMuted);
}

.combined-metric-value .card-value-amount {
  font-size: 18px;
  font-weight: 700;
  color: var(--textPrimary);
  font-variant-numeric: tabular-nums;
}

.combined-metric-comparison {
  font-size: 13px;
  font-weight: 700;
  color: var(--textSecondary);
  text-align: left;
  margin-top: 4px;
}

.combined-metric-value-row + .combined-metric-comparison {
  text-align: left;
  margin-top: 0px; /* Reduced spacing to match desktop and bring text closer */
}

/* Percentage badge in combined card - absolute overlay (same as desktop) */
.dashboard-combined-metrics-card .combined-metric-percentage {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 10;
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Color coding for combined metrics (DAILY SCREEN) */
.combined-metrics-card .combined-metric-section:nth-child(1) .combined-metric-icon { color: var(--chartTurnover); }
.combined-metrics-card .combined-metric-section:nth-child(1) .combined-metric-header h3 { color: var(--chartTurnover); }

.combined-metrics-card .combined-metric-section:nth-child(2) .combined-metric-icon { color: var(--chartGP); }
.combined-metrics-card .combined-metric-section:nth-child(2) .combined-metric-header h3 { color: var(--chartGP); }

.combined-metrics-card .combined-metric-section:nth-child(3) .combined-metric-icon { color: var(--chartPurchases); }
.combined-metrics-card .combined-metric-section:nth-child(3) .combined-metric-header h3 { color: var(--chartPurchases); }

.combined-metrics-card .combined-metric-section:nth-child(4) .combined-metric-icon { color: var(--chartBasket); }
.combined-metrics-card .combined-metric-section:nth-child(4) .combined-metric-header h3 { color: var(--chartBasket); }

/* Hide DAILY combined metrics card on larger screens */
@media (min-width: 431px) {
  .combined-metrics-card {
    display: none;
  }
}

/* Dashboard Combined Metrics Card Color Scheme */
.dashboard-combined-metrics-card .combined-metric-section:nth-child(1) .combined-metric-icon { color: var(--chartTurnover); }
.dashboard-combined-metrics-card .combined-metric-section:nth-child(1) .combined-metric-header h3 { color: var(--chartTurnover); }

.dashboard-combined-metrics-card .combined-metric-section:nth-child(2) .combined-metric-icon { color: var(--chartTurnover); }
.dashboard-combined-metrics-card .combined-metric-section:nth-child(2) .combined-metric-header h3 { color: var(--chartTurnover); }

.dashboard-combined-metrics-card .combined-metric-section:nth-child(3) .combined-metric-icon { color: var(--chartGP); }
.dashboard-combined-metrics-card .combined-metric-section:nth-child(3) .combined-metric-header h3 { color: var(--chartGP); }

.dashboard-combined-metrics-card .combined-metric-section:nth-child(4) .combined-metric-icon { color: var(--chartPurchases); }
.dashboard-combined-metrics-card .combined-metric-section:nth-child(4) .combined-metric-header h3 { color: var(--chartPurchases); }

.dashboard-combined-metrics-card .combined-metric-section:nth-child(5) .combined-metric-icon { color: var(--chartBasket); }
.dashboard-combined-metrics-card .combined-metric-section:nth-child(5) .combined-metric-header h3 { color: var(--chartBasket); }

.dashboard-combined-metrics-card .combined-metric-section:nth-child(6) .combined-metric-icon { color: var(--chartPurchases); }
.dashboard-combined-metrics-card .combined-metric-section:nth-child(6) .combined-metric-header h3 { color: var(--chartPurchases); }

/* Combined metric percentage styling for dashboard */
.dashboard-combined-metrics-card .combined-metric-percentage {
  font-size: 14px;
  font-weight: 700;
  color: white;
  padding: 4px 12px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dashboard-combined-metrics-card .combined-metric-percentage.positive {
  background-color: #59BA47;
}

.dashboard-combined-metrics-card .combined-metric-percentage.negative {
  background-color: #FF4509;
}

/* ========================================
   LOGIN SCREEN STYLES
   ======================================== */

/* Login Body */
.login-body {
  background: linear-gradient(135deg, #FFFFFF 0%, #FFF8F5 50%, #FFE6D6 100%);
  background-attachment: fixed;
  overflow: auto;
  height: 100vh;
}

/* Login Background Gradients */
.login-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.login-gradient-1 {
  position: absolute;
  top: -20%;
  left: -20%;
  width: 140%;
  height: 140%;
  background: radial-gradient(circle at 20% 50%, rgba(244, 122, 32, 0.05) 0%, transparent 55%);
  animation: gentleShift 30s ease-in-out infinite;
}

.login-gradient-2 {
  position: absolute;
  top: -20%;
  left: -20%;
  width: 140%;
  height: 140%;
  background: radial-gradient(circle at 80% 80%, rgba(255, 69, 9, 0.05) 0%, transparent 55%);
  animation: gentleShift 30s ease-in-out infinite reverse;
}

.login-gradient-3 {
  position: absolute;
  top: -20%;
  left: -20%;
  width: 140%;
  height: 140%;
  background: radial-gradient(circle at 40% 20%, rgba(255, 165, 0, 0.04) 0%, transparent 55%);
  animation: gentleShift 30s ease-in-out infinite;
  animation-delay: -15s;
}

/* Login Container */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  z-index: 1;
}

/* Login Card */
.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.1),
    0 8px 24px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  padding: 48px 40px;
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.8), transparent);
}

/* Login Brand Section */
.login-brand {
  text-align: center;
  margin-bottom: 40px;
}

.login-logo {
  height: 64px;
  width: auto;
  margin-bottom: 24px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--textPrimary);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--textSecondary);
  font-weight: 400;
  line-height: 1.5;
}

/* Login Form Section */
.login-form-section {
  margin-bottom: 32px;
}

.login-form-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--textPrimary);
  margin-bottom: 24px;
  text-align: center;
}

/* Login Form */
.login-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-field {
  display: flex;
  flex-direction: column;
}

.login-label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-label-text {
  font-size: 12px;
  font-weight: 500;
  color: var(--textPrimary);
}

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

.login-input-icon {
  position: absolute;
  left: 16px;
  color: var(--textSecondary);
  z-index: 2;
  pointer-events: none;
}

.login-input {
  width: 100%;
  height: 56px;
  padding: 16px 16px 16px 52px;
  border: 2px solid var(--surfaceBorder);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  font-size: 14px;
  font-weight: 400;
  color: var(--textPrimary);
  transition: all 0.2s ease;
  outline: none;
}

.login-input::placeholder {
  color: var(--textMuted);
}

.login-input:focus {
  border-color: var(--accentPrimary);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 4px rgba(244, 122, 32, 0.1);
}

.login-input:hover:not(:focus) {
  border-color: var(--accentLight);
  background: rgba(255, 255, 255, 0.9);
}

/* Login Button */
.login-button {
  height: 56px;
  background: linear-gradient(135deg, var(--accentPrimary) 0%, var(--accentLight) 100%);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
  box-shadow: 
    0 8px 24px rgba(244, 122, 32, 0.3),
    0 4px 12px rgba(244, 122, 32, 0.2);
}

.login-button:hover {
  transform: translateY(-2px);
  box-shadow: 
    0 12px 32px rgba(244, 122, 32, 0.4),
    0 6px 16px rgba(244, 122, 32, 0.3);
}

.login-button:active {
  transform: translateY(0);
}

.login-button svg {
  transition: transform 0.2s ease;
}

.login-button:hover svg {
  transform: translateX(2px);
}

/* Login Alert */
.login-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 24px;
}

.login-alert.error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: var(--statusError);
}

.login-alert svg {
  flex-shrink: 0;
}

/* Login Footer */
.login-footer {
  text-align: center;
  padding-top: 24px;
  border-top: 1px solid var(--surfaceBorder);
}

.login-footer-text {
  font-size: 11px;
  color: var(--textMuted);
  font-weight: 400;
}

/* Responsive Design */
@media (max-width: 768px) {
  .login-container {
    padding: 16px;
  }
  
  .login-card {
    padding: 32px 24px;
    border-radius: 20px;
  }
  
  .login-logo {
    height: 56px;
    margin-bottom: 20px;
  }
  
  .login-title {
    font-size: 24px;
  }
  
  .login-subtitle {
  font-size: 14px;
  }
  
  .login-form-title {
    font-size: 18px;
  }
  
  .login-input {
    height: 52px;
    font-size: 15px;
  }
  
  .login-button {
    height: 52px;
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  .login-card {
    padding: 24px 20px;
    border-radius: 16px;
  }
  
  .login-logo {
    height: 48px;
    margin-bottom: 16px;
  }
  
  .login-title {
    font-size: 22px;
  }
  
  .login-form {
    gap: 16px;
  }
  
  .login-input {
    height: 48px;
    padding: 14px 14px 14px 48px;
  }
  
  .login-button {
    height: 48px;
  }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 365px; /* Start after sidebar width (325px) + margin (20px) + padding (20px) */
  right: 0;
  bottom: 0;
  background: transparent;
  z-index: 998; /* Lower than sidebar */
  backdrop-filter: none;
  pointer-events: none;
  isolation: isolate;
}

.sidebar-overlay.active {
  display: block;
  pointer-events: auto;
}

/* Date Picker Button */
.date-picker-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--bgSecondary);
  border: 1px solid var(--surfaceBorder);
  border-radius: 12px;
  color: var(--textPrimary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Mobile: Smaller date picker button */
@media (max-width: 768px) {
  .date-picker-btn {
    padding: 6px 10px;
    font-size: 12px;
    gap: 6px;
    border-radius: 8px;
  }
  
  .date-picker-btn svg {
    width: 14px;
    height: 14px;
  }
}

.date-picker-btn:hover {
  background: var(--surfaceHover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.date-picker-btn svg {
  color: var(--accentPrimary);
  flex-shrink: 0;
}

/* Pharmacy Picker Button */
.pharmacy-picker-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--bgSecondary);
  border: 1px solid var(--surfaceBorder);
  border-radius: 12px;
  color: var(--textPrimary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Mobile: Smaller pharmacy picker button */
@media (max-width: 768px) {
  .pharmacy-picker-btn {
    padding: 6px 10px;
    font-size: 12px;
    gap: 6px;
    border-radius: 8px;
    max-width: 140px;
    overflow: hidden;
  }
  
  .pharmacy-picker-btn span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  
  .pharmacy-picker-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
  }
}

.pharmacy-picker-btn:hover {
  background: var(--surfaceHover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.pharmacy-picker-btn svg {
  color: var(--accentPrimary);
  flex-shrink: 0;
}

/* Group View Toggle Button */
.group-view-toggle-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--bgSecondary);
  border: 1px solid var(--surfaceBorder);
  border-radius: 12px;
  color: var(--textPrimary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Mobile: Smaller group view toggle button */
@media (max-width: 768px) {
  .group-view-toggle-btn {
    padding: 6px 10px;
    font-size: 12px;
    gap: 6px;
    border-radius: 8px;
  }
  
  .group-view-toggle-btn svg {
    width: 14px;
    height: 14px;
  }
  
  /* Keep text visible since "Group" is short enough to fit */
}

.group-view-toggle-btn:hover {
  background: var(--surfaceHover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.group-view-toggle-btn.active {
  background: var(--accentPrimary);
  border-color: var(--accentPrimary);
  color: white;
}

.group-view-toggle-btn.active svg {
  color: white;
}

.group-view-toggle-btn svg {
  color: var(--accentPrimary);
  flex-shrink: 0;
  transition: color 0.2s ease;
}

/* Group View Container */
.group-view-container {
  margin-bottom: 24px;
  display: block;
}

.group-view-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
  max-width: 75%; /* Default width for desktop */
}

/* Tablet screens - full width (override base rule) */
@media (min-width: 481px) and (max-width: 1366px) {
  .group-view-container {
    max-width: 100% !important;
    width: 100% !important;
  }
  
  .group-view-grid {
    max-width: 100% !important;
    width: 100% !important;
  }
}

/* Very large screens - 2/3 width to match daily summary */
@media (min-width: 1367px) {
  .group-view-grid {
    max-width: 66.67% !important;
  }
}

/* Card 3 (GP) starts on row 2 */
#group-card-gp {
  grid-row: 2;
  grid-column: 1;
}

/* Card 4 (Basket) is on row 2, column 2 */
#group-card-basket {
  grid-row: 2;
  grid-column: 2;
}

/* Mobile override - must come after base rule with highest specificity */
@media (max-width: 480px) {
  .group-view-grid,
  #group-view-grid.group-view-grid,
  .group-view-container .group-view-grid {
    grid-template-columns: 1fr !important;
    max-width: 100% !important;
  }
  
  /* Reset grid positions on mobile */
  #group-card-gp,
  #group-card-basket {
    grid-row: auto;
    grid-column: auto;
  }
}

.group-pharmacy-metric-header {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--textSecondary);
  margin: 0;
}

/* Group View Pharmacy Card - uses combined metrics card style */
.group-pharmacy-card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(15px) saturate(120%);
  -webkit-backdrop-filter: blur(15px) saturate(120%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  padding: 20px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 4px 16px rgba(0, 0, 0, 0.08),
    0 2px 4px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  position: relative;
  overflow: hidden;
  will-change: transform;
  display: block !important; /* Always show group pharmacy cards */
}

.group-pharmacy-card .pharmacy-card-header {
  font-size: 18px;
  font-weight: 700;
  color: var(--textPrimary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--surfaceBorder);
}

/* Group Metric Cards - new structure */
.group-metric-card {
  display: flex;
  flex-direction: column;
}

/* Hide % symbol for GP card like in single pharmacy view */
#group-gp-percent-currency {
  display: none;
}

/* Hide leading % symbol for GP in single pharmacy view - only show trailing % */
#dash-gp-percent-currency,
#daily-gp-percent-currency,
#monthly-gp-percent-currency {
  display: none;
}

.group-pharmacy-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 8px;
}

/* Primary card (orange gradient) - adjust border color for pharmacy list */
.dashboard-card.primary .group-pharmacy-list-item {
  border-bottom-color: rgba(255, 255, 255, 0.2);
}

.dashboard-card.primary .group-pharmacy-list-item .pharmacy-name {
  color: rgba(255, 255, 255, 0.9);
}

.dashboard-card.primary .group-pharmacy-list-item .pharmacy-value-wrapper,
.dashboard-card.primary .group-pharmacy-list-item .pharmacy-value-wrapper .card-value-currency,
.dashboard-card.primary .group-pharmacy-list-item .pharmacy-value-wrapper .card-value-amount {
  color: white;
}

.dashboard-card.primary .group-pharmacy-list-item .pharmacy-growth,
.dashboard-card.primary .group-pharmacy-list-item .pharmacy-detail,
.dashboard-card.primary .group-pharmacy-list-item .pharmacy-status {
  color: rgba(255, 255, 255, 0.85);
}

.group-pharmacy-list-item {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  border-bottom: 1px solid var(--surfaceBorder);
  gap: 2px;
}

.group-pharmacy-list-item:last-child {
  border-bottom: none;
}

.group-pharmacy-list-item .pharmacy-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--textPrimary);
  margin-bottom: 2px;
}

/* Pharmacy value row - matches single view layout */
.pharmacy-value-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 0;
  position: relative;
}

.pharmacy-value-wrapper {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.group-pharmacy-list-item .pharmacy-value-wrapper {
  font-size: 20px;
  font-weight: 700;
  color: var(--textPrimary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.group-pharmacy-list-item .pharmacy-value-wrapper .card-value-currency {
  font-size: 15px;
  font-weight: 700;
  color: var(--textMuted);
}

.group-pharmacy-list-item .pharmacy-value-wrapper .card-value-amount {
  font-size: 20px;
  font-weight: 700;
  color: var(--textPrimary);
}

/* Percentage badge within pharmacy list item */
.group-pharmacy-list-item .card-value-percentage {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
  color: white;
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 10;
}

.group-pharmacy-list-item .card-value-percentage.positive {
  background-color: #59BA47;
  color: white;
}

.group-pharmacy-list-item .card-value-percentage.negative {
  background-color: #FF4509;
  color: white;
}

.group-pharmacy-list-item .pharmacy-growth {
  font-size: 12px;
  font-weight: 400;
  color: var(--textSecondary);
  margin-top: 2px;
  line-height: 1.3;
}

.group-pharmacy-list-item .pharmacy-detail {
  font-size: 12px;
  font-weight: 400;
  color: var(--textSecondary);
  margin-top: 2px;
  line-height: 1.3;
}

.group-pharmacy-list-item .pharmacy-status {
  font-size: 12px;
  font-weight: 400;
  color: var(--textSecondary);
  margin-top: 2px;
  line-height: 1.3;
}

/* Responsive adjustments for group pharmacy list */
@media (max-width: 768px) {
  .group-pharmacy-list-item {
    padding: 6px 0;
  }
  
  .group-pharmacy-list-item .pharmacy-name {
    font-size: 13px;
  }
  
  .group-pharmacy-list-item .pharmacy-value-wrapper {
    font-size: 18px;
  }
  
  .group-pharmacy-list-item .pharmacy-value-wrapper .card-value-currency {
    font-size: 14px;
  }
  
  .group-pharmacy-list-item .pharmacy-value-wrapper .card-value-amount {
    font-size: 18px;
  }
}

/* Pharmacy Picker Modal */

.pharmacy-picker-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  animation: fadeIn 0.2s ease;
}

.pharmacy-picker-modal-overlay.active {
  display: flex;
}

.pharmacy-picker-modal {
  background: var(--bgSecondary);
  border-radius: 20px;
  padding: 0;
  max-width: 400px;
  width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease;
}

.pharmacy-picker-header {
  padding: 24px;
  border-bottom: 1px solid var(--surfaceBorder);
}

.pharmacy-picker-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--textPrimary);
}

.pharmacy-picker-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.pharmacy-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: none; 
  border-radius: 12px;
  color: var(--textPrimary);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  font-family: inherit;
}

.pharmacy-option:hover {
  background: var(--surfaceHover);
}

.pharmacy-option.selected {
  background: rgba(239, 69, 35, 0.1);
  color: var(--accentPrimary);
}

.pharmacy-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--surfaceHover);
  border-radius: 8px;
  flex-shrink: 0;
}

.pharmacy-option.selected .pharmacy-icon {
  background: rgba(239, 69, 35, 0.15);
}

.pharmacy-icon svg {
  color: var(--textSecondary);
}

.pharmacy-option.selected .pharmacy-icon svg {
  color: var(--accentPrimary);
}

.pharmacy-picker-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--surfaceBorder);
  display: flex;
  justify-content: flex-end;
}

/* Date Picker Modal */
.date-picker-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}

.date-picker-modal-overlay.active {
  display: flex;
}

.date-picker-modal {
  background: var(--bgSecondary);
  border-radius: 20px;
  padding: 24px; 
  width: 100%;
  max-width: 400px;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(20px);
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.date-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--surfaceBorder);
}

.date-picker-month {
  font-size: 18px;
  font-weight: 600;
  color: var(--textPrimary);
  margin: 0;
}

.date-picker-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: transparent;
  border: none;
  color: var(--textSecondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.date-picker-nav:hover {
  background: var(--surfaceHover);
  color: var(--accentPrimary);
}

.date-picker-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}

.weekday {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--textMuted);
  padding: 8px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.date-picker-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 20px;
}

.date-picker-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--textPrimary);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
  background: transparent;
}

.date-picker-day.empty {
  cursor: default;
  pointer-events: none;
}

.date-picker-day:not(.empty):hover {
  background: var(--surfaceHover);
  transform: scale(1.05);
}

.date-picker-day.today {
  color: var(--accentPrimary);
  font-weight: 600;
}

.date-picker-day.selected {
  background: var(--accentPrimary);
  color: white;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(239, 69, 35, 0.3);
}

.date-picker-day.selected:hover {
  background: var(--accentPrimaryHover);
}

.date-picker-footer {
  display: flex;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--surfaceBorder);
}

.btn-secondary,
.btn-primary {
  flex: 1;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-family: inherit;
}

.btn-secondary {
  background: var(--surfaceHover);
  color: var(--textPrimary);
}

.btn-secondary:hover {
  background: var(--bgTertiary);
}

.btn-primary {
  background: var(--accentPrimary);
  color: white;
  box-shadow: 0 4px 12px rgba(239, 69, 35, 0.3);
}

.btn-primary:hover {
  background: var(--accentPrimaryHover);
  box-shadow: 0 6px 16px rgba(239, 69, 35, 0.4);
  transform: translateY(-1px);
}

@media (max-width: 768px) {
  .sidebar-overlay.active {
    display: block;
  }
  
  .date-picker-modal {
    max-width: 90vw;
    padding: 20px;
  }
}

/* Admin Styles */
.admin-nav-item {
  margin-bottom: 12px;
  width: 100%;
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.admin-nav-item:hover:not(.disabled) {
  background: rgba(0, 122, 255, 0.1);
  color: var(--accentPrimary);
}

.admin-nav-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.admin-container {
  padding: 24px;
  max-width: 100%;
  margin: 0;
  overflow-y: auto;
  min-height: 0;
}

/* On large screens, limit to 66% width and align left */
@media (min-width: 1200px) {
  .admin-container {
    max-width: 66.67%;
    margin-left: 0;
    margin-right: auto;
  }
}

/* Allow scrolling on admin page */
body.admin-page .main-content {
  overflow-y: auto !important;
}

.admin-section {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(15px) saturate(120%);
  -webkit-backdrop-filter: blur(15px) saturate(120%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 
    0 4px 16px rgba(0, 0, 0, 0.08),
    0 2px 4px rgba(0, 0, 0, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.admin-section:hover {
  transform: translateY(-2px) scale(1.01);
  box-shadow: 
    0 8px 24px rgba(0, 0, 0, 0.12),
    0 4px 8px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.admin-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 16px;
}

.admin-section-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--textPrimary);
}

/* Limit button width on large screens */
@media (min-width: 1200px) {
  .admin-section-header .btn {
    max-width: 200px;
    white-space: nowrap;
  }
}

.admin-table-container {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table thead {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(15px) saturate(120%);
  -webkit-backdrop-filter: blur(15px) saturate(120%);
  border-bottom: 2px solid var(--surfaceBorder);
}

.admin-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--textSecondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-table td {
  padding: 16px;
  border-bottom: 1px solid var(--surfaceBorder);
  color: var(--textPrimary);
}

.admin-table td.actions-cell {
  white-space: nowrap;
}

.admin-table td.actions-cell .btn {
  margin-right: 8px;
}

.admin-table td.actions-cell .btn:last-child {
  margin-right: 0;
}

.admin-table tbody tr:hover {
  background: var(--bgSecondary);
}

.admin-table .loading-cell,
.admin-table .empty-cell,
.admin-table .error-cell {
  text-align: center;
  padding: 40px;
  color: var(--textSecondary);
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success {
  background: rgba(52, 199, 89, 0.15);
  color: #34C759;
}

.badge-danger {
  background: rgba(255, 59, 48, 0.15);
  color: #FF3B30;
}

.badge-secondary {
  background: rgba(142, 142, 147, 0.15);
  color: #8E8E93;
}

.badge-warning {
  background: rgba(255, 149, 0, 0.15);
  color: #FF9500;
}

.btn-info {
  background: rgba(255, 69, 9, 0.1);
  color: var(--accentPrimary);
  border-color: rgba(255, 69, 9, 0.3);
}

.btn-info:hover {
  background: rgba(255, 69, 9, 0.2);
  color: var(--accentPrimaryHover);
  border-color: rgba(255, 69, 9, 0.5);
}

.btn-danger {
  background: rgba(255, 59, 48, 0.1);
  color: #FF3B30;
  border-color: rgba(255, 59, 48, 0.3);
}

.btn-danger:hover {
  background: rgba(255, 59, 48, 0.2);
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
}

.modal[style*="display: flex"],
.modal[style*="display:block"] {
  display: flex !important;
}

.modal-content {
  background: var(--bgPrimary);
  border-radius: 16px;
  padding: 0;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-large {
  max-width: 800px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid var(--surfaceBorder);
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--textPrimary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--textSecondary);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--bgSecondary);
  color: var(--textPrimary);
}

.modal-body {
  padding: 24px;
}

/* Pharmacy Contact Details Modal */
.pharmacy-contact-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.pharmacy-contact-modal-overlay.active {
  display: flex;
}

.pharmacy-contact-modal {
  background: var(--bgPrimary);
  border-radius: 20px;
  padding: 0;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease;
}

.pharmacy-contact-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid var(--surfaceBorder);
}

.pharmacy-contact-modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--textPrimary);
  text-align: left;
}

.pharmacy-contact-modal-close {
  background: none;
  border: none;
  color: var(--textSecondary);
  cursor: pointer;
  padding: 4px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.pharmacy-contact-modal-close:hover {
  background: var(--bgSecondary);
  color: var(--textPrimary);
}

.pharmacy-contact-modal-body {
  padding: 24px;
}

.pharmacy-contact-modal-message {
  margin: 0 0 24px 0;
  font-size: 14px;
  color: var(--textSecondary);
  line-height: 1.6;
  text-align: left;
}

.pharmacy-contact-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--surfaceBorder);
  border-radius: 10px;
  background: var(--bgSecondary);
  color: var(--textPrimary);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.pharmacy-contact-input::placeholder {
  color: var(--textMuted);
}

.pharmacy-contact-input:focus {
  outline: none;
  border-color: var(--accentPrimary);
  box-shadow: 0 0 0 4px rgba(244, 122, 32, 0.1);
  background: white;
}

.pharmacy-contact-input:hover:not(:focus) {
  border-color: var(--accentLight);
}

.pharmacy-contact-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--surfaceBorder);
}

/* Form Styles */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--textPrimary);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group select {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--surfaceBorder);
  border-radius: 10px;
  background: var(--bgSecondary);
  color: var(--textPrimary);
  font-size: 14px;
  transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accentPrimary);
  box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  cursor: pointer;
}

.pharmacy-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 200px;
  overflow-y: auto;
  padding: 12px;
  background: var(--bgSecondary);
  border-radius: 10px;
  border: 1px solid var(--surfaceBorder);
}

.pharmacy-checkboxes .checkbox-label {
  padding: 8px;
  border-radius: 8px;
  transition: background 0.2s ease;
}

.pharmacy-checkboxes .checkbox-label:hover {
  background: var(--bgPrimary);
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--surfaceBorder);
}

.loading-text {
  text-align: center;
  padding: 20px;
  color: var(--textSecondary);
}

.error-text {
  color: #FF3B30;
  padding: 20px;
  text-align: center;
}

/* User Details Styles */
.user-details-info {
  margin-bottom: 24px;
}

.detail-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--surfaceBorder);
  display: flex;
  gap: 12px;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-row strong {
  min-width: 100px;
  color: var(--textSecondary);
}

.pharmacy-access-section {
  margin-top: 24px;
}

.pharmacy-access-section h3 {
  margin: 0 0 16px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--textPrimary);
}

.pharmacy-search-container {
  margin-bottom: 16px;
}

.pharmacy-search-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--surfaceBorder);
  background: var(--bgSecondary);
  font-size: 14px;
  transition: all 0.2s ease;
}

.pharmacy-search-input:focus {
  outline: none;
  border-color: var(--accentPrimary);
  box-shadow: 0 0 0 4px rgba(255, 69, 9, 0.1);
  background: white;
}

.pharmacy-checkbox-list {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--surfaceBorder);
  border-radius: 10px;
  padding: 8px;
  background: var(--bgSecondary);
}

.pharmacy-checkbox-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 4px;
  transition: background 0.2s ease;
}

.pharmacy-checkbox-item:hover {
  background: var(--surfaceHover);
}

.pharmacy-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  flex: 1;
  font-size: 14px;
  color: var(--textPrimary);
}

.pharmacy-checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accentPrimary);
}

.pharmacy-checkbox-name {
  font-weight: 500;
}

.pharmacy-permissions-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 12px;
}

.checkbox-label-small {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--textSecondary);
  cursor: pointer;
}

.checkbox-label-small input[type="checkbox"] {
  width: 14px;
  height: 14px;
  cursor: pointer;
  accent-color: var(--accentPrimary);
}

.empty-text {
  text-align: center;
  padding: 24px;
  color: var(--textSecondary);
  font-style: italic;
}

.pharmacy-access-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  background: var(--bgSecondary);
  border-radius: 10px;
  margin-bottom: 8px;
}

.pharmacy-name {
  flex: 1;
  font-weight: 500;
  color: var(--textPrimary);
}

.pharmacy-permissions {
  display: flex;
  gap: 8px;
}

/* Alert Styles */
.alert-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alert {
  padding: 16px 20px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  animation: slideIn 0.3s ease;
  min-width: 300px;
  max-width: 400px;
}

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

.alert-error {
  background: rgba(255, 59, 48, 0.15);
  color: #FF3B30;
  border: 1px solid rgba(255, 59, 48, 0.3);
}

.alert-success {
  background: rgba(52, 199, 89, 0.15);
  color: #34C759;
  border: 1px solid rgba(52, 199, 89, 0.3);
}

/* Loading Overlay Modal */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px) saturate(150%);
  -webkit-backdrop-filter: blur(8px) saturate(150%);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.loading-modal {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  padding: 48px 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.2),
    0 8px 32px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 200px;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-20px) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.loading-spinner-large {
  width: 56px;
  height: 56px;
  border: 4px solid rgba(255, 69, 9, 0.1);
  border-top-color: var(--accentPrimary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  position: relative;
}

.loading-spinner-large::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 4px solid transparent;
  border-top-color: rgba(255, 69, 9, 0.3);
  animation: spin 1.2s linear infinite reverse;
}

.loading-text-modal {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  color: var(--textPrimary);
  letter-spacing: 0.3px;
}

/* Styled Modal System (Alert, Confirm, Prompt) */
.styled-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px) saturate(150%);
  -webkit-backdrop-filter: blur(8px) saturate(150%);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.styled-modal {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 20px;
  max-width: 480px;
  width: 100%;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.2),
    0 8px 32px rgba(0, 0, 0, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.styled-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid var(--surfaceBorder);
}

.styled-modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--textPrimary);
}

.styled-modal-close {
  background: none;
  border: none;
  color: var(--textSecondary);
  cursor: pointer;
  padding: 4px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.styled-modal-close:hover {
  background: var(--bgSecondary);
  color: var(--textPrimary);
}

.styled-modal-body {
  padding: 24px;
  text-align: center;
}

.styled-modal-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.styled-modal-icon.info {
  background: rgba(255, 69, 9, 0.1);
  color: var(--accentPrimary);
}

.styled-modal-icon.success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--statusSuccess);
}

.styled-modal-icon.error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--statusError);
}

.styled-modal-icon.warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--statusWarning);
}

.styled-modal-icon.confirm {
  background: rgba(255, 69, 9, 0.1);
  color: var(--accentPrimary);
}

.styled-modal-message {
  margin: 0 0 20px 0;
  font-size: 15px;
  color: var(--textPrimary);
  line-height: 1.6;
  text-align: left;
}

.styled-modal-input-group {
  margin-top: 20px;
}

.styled-modal-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--surfaceBorder);
  border-radius: 10px;
  background: var(--bgSecondary);
  color: var(--textPrimary);
  font-size: 14px;
  font-family: inherit;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.styled-modal-input::placeholder {
  color: var(--textMuted);
}

.styled-modal-input:focus {
  outline: none;
  border-color: var(--accentPrimary);
  box-shadow: 0 0 0 4px rgba(255, 69, 9, 0.1);
  background: white;
}

.styled-modal-input:hover:not(:focus) {
  border-color: var(--accentLight);
}

.styled-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid var(--surfaceBorder);
  background: rgba(255, 255, 255, 0.5);
}

.styled-modal-actions .btn-primary,
.styled-modal-actions .btn-secondary {
  min-width: 100px;
}

/* Mobile Full Height Support */
@media (max-width: 768px) {
  html {
    height: 100%;
    height: 100svh; /* Use small viewport height */
    min-height: 100vh;
  }
  
  body {
    height: 100%;
    height: 100svh; /* Use small viewport height */
    min-height: 100vh;
  }
  
  .sidebar {
    height: calc(100svh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important; /* Use small viewport height */
    max-height: calc(100svh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    min-height: calc(100vh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
  }
  
  .main-content {
    height: 100%;
    height: 100svh; /* Use small viewport height */
    min-height: 100vh;
  }
  
  .content-area {
    height: 100%;
    max-height: 100svh; /* Use small viewport height */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  }
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
  html, body {
    height: -webkit-fill-available;
  }
  
  .sidebar {
    /* Safari fallback for viewport height with safe areas */
    height: calc(100vh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    max-height: calc(100vh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
  }
  
  @media (max-width: 768px) {
    .sidebar {
      height: calc(100vh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
      max-height: calc(100vh - 40px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    }
  }
  
  .app-layout {
    height: -webkit-fill-available !important;
    min-height: -webkit-fill-available !important;
  }
  
  @media (max-width: 768px) {
    .app-layout {
      height: -webkit-fill-available !important;
      min-height: -webkit-fill-available !important;
    }
  }
}


