/* =============================================================================
   LEASING PERFORMANCE TAB STYLES
   Velocity Metrics & Loss Reason Analysis
   
   INSTALLATION: Append this entire file to the end of styles.css
   ============================================================================= */

/* Sub-tab Navigation */
.leasing-subtab-nav {
  display: flex;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xs);
  margin-bottom: var(--spacing-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  gap: var(--spacing-xs);
}

.leasing-subtab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
}

.leasing-subtab-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.leasing-subtab-btn.active {
  background: var(--color-primary);
  color: var(--text-white);
  box-shadow: var(--shadow-md);
}

/* Leasing Sub-tabs Content */
.leasing-subtab {
  display: none;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

.leasing-subtab.active {
  display: block;
}

/* Velocity KPI Cards */
.velocity-kpi-section {
  margin-bottom: var(--spacing-2xl);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.velocity-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-lg);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* 4-Column Grid for New Velocity Cards */
.velocity-kpi-grid-four {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--spacing-lg);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

@media (max-width: 1024px) {
  .velocity-kpi-grid-four {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .velocity-kpi-grid-four {
    grid-template-columns: 1fr;
  }
}

.velocity-kpi-card {
  background: linear-gradient(135deg, var(--bg-primary), var(--bg-tertiary));
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  transition: all 0.2s;
}

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

.velocity-kpi-card.lead-velocity {
  border-left: 4px solid #3b82f6;
}

.velocity-kpi-card.opp-velocity {
  border-left: 4px solid #10b981;
}

.velocity-kpi-card.reactivated-velocity {
  border-left: 4px solid #f59e0b;
}

.velocity-kpi-card.fast-conversion {
  border-left: 4px solid #8b5cf6;
}

.velocity-kpi-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--spacing-sm);
}

.velocity-kpi-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--spacing-xs);
  line-height: 1;
}

.velocity-kpi-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Velocity Chart Container */
.velocity-chart-container {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  margin-bottom: 50px; /* Increased spacing between chart sections */
  min-height: 600px; /* INCREASED: from 450px to 600px */
  overflow-x: hidden; /* Prevent horizontal overflow */
  overflow-y: visible; /* Allow tooltips to show */
  position: relative;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.velocity-chart-wrapper {
  position: relative;
  height: 650px; /* INCREASED: from 500px to 650px */
  width: 100%;
  max-width: 100%;
  min-height: 550px; /* INCREASED: from 400px to 550px */
  box-sizing: border-box;
}

.velocity-chart-wrapper canvas {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  box-sizing: border-box;
}

/* Lead Source Performance section - full height layout */
.lead-source-section {
  min-height: 900px !important;
}

.lead-source-section .velocity-chart-wrapper {
  height: 100% !important;
  min-height: 850px !important;
}

#lead-source-matrix-chart {
  min-height: 800px !important;
}

/* =============================================================================
   LOSS REASONS FILTER STYLES
   ============================================================================= */

/* Loss Reasons Filter Container - Date Range + Type Toggle */
.loss-reasons-filter-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 30px;
  margin: 20px 0 30px 0;
  padding: 20px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  flex-wrap: wrap;
}

/* Loss Type Toggle Group */
.loss-type-toggle-group {
  display: flex;
  gap: 0;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 4px;
  border: 1px solid var(--border-light);
}

.loss-type-btn {
  padding: 10px 28px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.loss-type-btn:hover {
  color: var(--text-primary);
  background: var(--bg-primary);
}

.loss-type-btn.active {
  background: var(--color-primary);
  color: var(--text-white);
  box-shadow: var(--shadow-sm);
}

/* Velocity Filter Container */
.velocity-filter-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 20px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  flex-wrap: wrap;
  gap: 20px;
}

/* Velocity Type Toggle Group */
.velocity-type-toggle-group {
  display: flex;
  gap: 0;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 4px;
  border: 1px solid var(--border-light);
}

.velocity-type-btn {
  padding: 10px 28px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.velocity-type-btn:hover {
  color: var(--text-primary);
  background: var(--bg-primary);
}

.velocity-type-btn.active {
  background: var(--color-primary);
  color: var(--text-white);
  box-shadow: var(--shadow-sm);
}

/* Loss Reasons Date Range Buttons - Scoped to avoid conflict with velocity tab */
.loss-reasons-filter-container .date-range-filter-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* =============================================================================
   LOSS REASON CHARTS
   ============================================================================= */

/* Loss Reason Charts Grid - UPDATED: Display two charts side by side */
.loss-reason-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px; /* Increased gap between dual charts */
  margin-bottom: 50px; /* Increased spacing after grid section */
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.loss-reason-chart-wrapper {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  position: relative;
  height: 450px; /* Increased height for better chart display */
  min-height: 400px;
  overflow-x: hidden; /* Prevent horizontal overflow */
  overflow-y: visible; /* Allow tooltips to show */
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.loss-reason-chart-wrapper canvas {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  box-sizing: border-box;
}

/* Legacy styles for backwards compatibility */
.loss-reason-chart-container {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  margin-bottom: 50px; /* Increased spacing */
  min-height: 450px;
  overflow: visible;
}

.loss-reason-chart-container .loss-reason-chart-wrapper {
  position: relative;
  height: 450px; /* Increased height */
  width: 100%;
  min-height: 400px;
}

/* Loss Reason Heatmap */
.loss-reason-heatmap-container {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  overflow: hidden; /* Container handles overflow via scroll container */
  margin-bottom: 50px; /* Consistent spacing */
  min-height: 400px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Scroll container for sticky headers */
.loss-reason-heatmap-scroll-container {
  max-height: 600px;
  overflow-y: auto;
  overflow-x: auto;
  position: relative;
}

.loss-reason-heatmap-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.loss-reason-heatmap-table th,
.loss-reason-heatmap-table td {
  padding: var(--spacing-sm);
  text-align: center;
  border: 1px solid var(--border-light);
}

.loss-reason-heatmap-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.loss-reason-heatmap-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
  border-bottom: 2px solid #e2e8f0;
}

.loss-reason-heatmap-table th.facility-header {
  text-align: left;
  min-width: 150px;
  padding: 8px 12px;
}

.loss-reason-heatmap-table th.reason-header {
  writing-mode: vertical-lr;
  transform: rotate(180deg);
  white-space: nowrap;
  min-width: 40px;
  max-width: 40px;
  padding: var(--spacing-md) var(--spacing-xs);
}

.loss-reason-heatmap-table th.other-header {
  background: #f1f5f9;
  color: #6366f1;
  font-weight: 700;
}

.loss-reason-heatmap-table th.total-header {
  min-width: 80px;
}

.loss-reason-heatmap-table .facility-name {
  text-align: left;
  font-weight: 500;
  background: var(--bg-tertiary);
  position: sticky;
  left: 0;
  z-index: 5;
}

.loss-reason-heatmap-table .heatmap-cell {
  min-width: 70px;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}

.loss-reason-heatmap-table .heatmap-cell:hover {
  transform: scale(1.05);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
  z-index: 20;
  position: relative;
}

/* Cell count and percentage display */
.loss-reason-heatmap-table .cell-count {
  font-weight: 600;
}

.loss-reason-heatmap-table .percent-deviation {
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.85;
  margin-left: 2px;
}

.loss-reason-heatmap-table .total-cell {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-primary);
  position: sticky;
  right: 0;
  z-index: 5;
}

/* Expandable "Other" column styles */
.other-cell.expandable {
  cursor: pointer;
  position: relative;
}

.other-cell.expandable:hover {
  background-color: rgba(99, 102, 241, 0.2) !important;
}

.other-cell.expanded {
  background-color: rgba(99, 102, 241, 0.15) !important;
}

.expand-icon {
  font-size: 8px;
  margin-left: 4px;
  color: #6366f1;
  transition: transform 0.2s ease;
}

.other-cell.expanded .expand-icon {
  color: #4f46e5;
}

/* Expandable details row */
.other-details-row {
  background: #f8fafc;
}

.other-details-row td {
  padding: 0 !important;
  border-top: none !important;
}

.other-details-content {
  padding: 12px 16px;
  font-size: 12px;
  background: linear-gradient(to right, #f8fafc, #f1f5f9);
  border-left: 3px solid #6366f1;
  margin: 4px 8px;
  border-radius: 4px;
}

.other-details-content strong {
  color: #374151;
  font-size: 13px;
}

.other-reasons-list {
  margin: 8px 0 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px 24px;
}

.other-reasons-list li {
  margin-bottom: 0;
  padding: 4px 8px;
  background: white;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  border: 1px solid #e5e7eb;
}

.other-reasons-list .reason-name {
  color: #4b5563;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 8px;
}

.other-reasons-list .reason-count {
  color: #6366f1;
  font-weight: 600;
  flex-shrink: 0;
}

/* Leasing Performance Section Headers */
.leasing-section-header {
  margin-bottom: 30px; /* Increased spacing below section headers */
  margin-top: 50px; /* Added spacing above section headers */
}

.leasing-section-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--spacing-xs);
}

.leasing-section-header p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Section Headers within Velocity Tab (h3 tags before charts) */
#leasing-velocity-tab > h3 {
  margin-top: 50px; /* Space above section headers */
  margin-bottom: 30px; /* Space below section headers */
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Special height for facility velocity chart (vertical bar chart with many items) */
#facility-velocity-chart {
  min-height: 600px !important; /* Taller for displaying all facilities */
}

.velocity-chart-wrapper:has(#facility-velocity-chart) {
  height: 650px; /* Increased height for facility chart container */
  min-height: 600px;
}

/* Ensure consistent spacing for KPI section */
.velocity-kpi-section {
  margin-bottom: 40px; /* Space between KPI cards and first chart */
}

/* Dashboard Container for Leasing Tab */
#leasing-velocity-tab {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden; /* Prevent horizontal scroll */
  box-sizing: border-box;
}

/* =============================================================================
   DATE RANGE FILTER STYLES
   ============================================================================= */

/* Date Range Filter Container */
.date-range-filter-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 20px 0;
  padding: 15px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.date-range-filter-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.date-range-btn {
  padding: 10px 24px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.date-range-btn:hover {
  background: var(--bg-primary);
  border-color: var(--color-primary);
  color: var(--text-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.date-range-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--text-white);
  box-shadow: var(--shadow-md);
}

/* =============================================================================
   DATE FIELD TOGGLE SWITCH STYLES
   ============================================================================= */

/* Toggle Container */
.date-field-toggle-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 20px 0;
  padding: 15px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.toggle-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-right: 15px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Toggle Switch Group */
.toggle-switch-group {
  display: inline-flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 4px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.toggle-option {
  position: relative;
}

.toggle-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-option label {
  display: inline-block;
  padding: 8px 20px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: calc(var(--radius-md) - 2px);
  transition: all 0.3s ease;
  user-select: none;
  white-space: nowrap;
}

.toggle-option input[type="radio"]:checked + label {
  background: var(--color-primary);
  color: var(--text-white);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.toggle-option label:hover {
  color: var(--text-primary);
}

.toggle-option input[type="radio"]:checked + label:hover {
  color: var(--text-white);
}

/* Active state animation */
.toggle-option input[type="radio"]:checked + label::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: var(--color-primary);
  border-radius: 50%;
  opacity: 0;
  animation: togglePulse 0.3s ease-out;
}

@keyframes togglePulse {
  0% {
    opacity: 0;
    transform: translateX(-50%) scale(0.5);
  }
  50% {
    opacity: 1;
    transform: translateX(-50%) scale(1.5);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) scale(1);
  }
}

/* Responsive adjustments for toggle */
@media (max-width: 768px) {
  .date-field-toggle-container {
    flex-direction: column;
    gap: 10px;
  }

  .toggle-label {
    margin-right: 0;
    margin-bottom: 5px;
  }

  .toggle-option label {
    padding: 6px 16px;
    font-size: 0.8125rem;
  }
}

/* Responsive Design for Leasing Tab */
@media (max-width: 768px) {
  .velocity-kpi-grid {
    grid-template-columns: 1fr;
  }
  
  .velocity-chart-wrapper {
    height: 400px;
  }
  
  /* Stack charts vertically on mobile */
  .loss-reason-charts-grid {
    grid-template-columns: 1fr;
  }
  
  .loss-reason-chart-wrapper {
    height: 350px;
  }
  
  .loss-reason-heatmap-table {
    font-size: 0.75rem;
  }
  
  .loss-reason-heatmap-table th.reason-header {
    min-width: 30px;
    max-width: 30px;
  }
}

@media (max-width: 480px) {
  .leasing-subtab-nav {
    flex-direction: column;
  }
  
  .leasing-subtab-btn {
    width: 100%;
    justify-content: flex-start;
  }
  
  .velocity-kpi-value {
    font-size: 1.5rem;
  }
  
  .velocity-chart-wrapper {
    height: 300px;
  }
  
  .loss-reason-chart-wrapper {
    height: 300px;
  }
}

/* Full-width Chart Container */
.chart-container.full-width {
  grid-column: 1 / -1;
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  min-height: 450px; /* Increased min-height */
  margin-bottom: 50px; /* Consistent spacing */
  overflow: visible; /* Don't clip tooltips */
}

/* =============================================================================
   BENCHMARK CONTROLS & PERIOD COMPARISON STYLES
   ============================================================================= */

/* Benchmark Controls */
.benchmark-header {
    margin-bottom: 30px;
}

.benchmark-header h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #1e293b;
}

.benchmark-header .subtitle {
    color: #64748b;
    font-size: 14px;
}

.benchmark-controls {
    background: #f8fafc;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 30px;
}

.control-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #1e293b;
}

.period-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.period-box {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
}

.period-label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: #475569;
    margin-bottom: 12px;
}

.date-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
}

.date-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
}

.date-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.date-separator {
    color: #64748b;
    font-weight: 500;
}

.comparison-select {
    width: 100%;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    background: white;
}

.helper-text {
    display: block;
    margin-top: 8px;
    color: #64748b;
    font-size: 12px;
    font-style: italic;
}

.control-actions {
    display: flex;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
    margin-top: 20px;
}

.btn-primary {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background: white;
    color: #475569;
    border: 2px solid #e2e8f0;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

#benchmark-results-container {
    margin-top: 40px;
}

/* Positive and negative change indicators */
.positive {
    color: #10b981;
    font-weight: 600;
}

.negative {
    color: #ef4444;
    font-weight: 600;
}

/* =============================================================================
   DELTA CARDS STYLES
   ============================================================================= */

/* Delta Cards */
.delta-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.delta-card {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.delta-card-title {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}

.metrics-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.metric-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.metric-label {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-values {
    display: flex;
    align-items: center;
    gap: 8px;
}

.current-value {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
}

.vs-separator {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 500;
}

.previous-value {
    font-size: 16px;
    color: #64748b;
}

.metric-delta {
    font-size: 14px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
    width: fit-content;
}

.metric-delta.positive {
    background: #dcfce7;
    color: #15803d;
}

.metric-delta.negative {
    background: #fee2e2;
    color: #b91c1c;
}

/* VPS Card (Special Styling) */
.vps-card {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
}

.vps-card .delta-card-title {
    color: white;
    border-bottom-color: rgba(255, 255, 255, 0.3);
}

.vps-display {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.vps-score-row {
    display: flex;
    justify-content: space-around;
    gap: 20px;
}

.vps-current,
.vps-previous {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.vps-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
    margin-bottom: 8px;
}

.vps-value {
    font-size: 36px;
    font-weight: 700;
}

.vps-delta {
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    padding: 12px;
    border-radius: 8px;
}

.vps-card .vps-delta.positive {
    background: rgba(220, 252, 231, 0.2);
    color: #dcfce7;
}

.vps-card .vps-delta.negative {
    background: rgba(254, 226, 226, 0.2);
    color: #fee2e2;
}

.vps-explanation {
    font-size: 13px;
    text-align: center;
    opacity: 0.9;
    line-height: 1.5;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
}

/* =============================================================================
   VELOCITY LEADERBOARD STYLES
   ============================================================================= */

/* Leaderboard Styling */
.leaderboard-container {
    background: white;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.leaderboard-header {
    margin-bottom: 24px;
}

.leaderboard-header h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.leaderboard-subtitle {
    color: #64748b;
    font-size: 14px;
}

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

.velocity-leaderboard {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.velocity-leaderboard thead {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
}

.velocity-leaderboard th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
}

.velocity-leaderboard th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.velocity-leaderboard th.sortable:hover {
    background: #f1f5f9;
}

.sort-arrow {
    margin-left: 4px;
    color: #94a3b8;
}

.velocity-leaderboard tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.2s;
}

.velocity-leaderboard tbody tr:hover {
    background: #f8fafc;
}

.velocity-leaderboard tbody tr.improving {
    border-left: 3px solid #10b981;
}

.velocity-leaderboard tbody tr.declining {
    border-left: 3px solid #ef4444;
}

.velocity-leaderboard td {
    padding: 16px;
}

.rank-cell {
    text-align: center;
}

.rank-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    background: #f1f5f9;
    color: #475569;
    font-weight: 600;
}

.rank-badge.top-rank {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
}

.facility-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.facility-cell strong {
    color: #1e293b;
}

.facility-cell small {
    color: #94a3b8;
    font-size: 12px;
}

.velocity-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.velocity-cell small {
    color: #94a3b8;
    font-size: 11px;
}

.delta-cell {
    font-weight: 600;
}

.delta-value.positive {
    color: #10b981;
}

.delta-value.negative {
    color: #ef4444;
}

.vps-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-weight: 600;
}

.vps-cell small {
    font-size: 11px;
    font-weight: 500;
}

.trend-cell {
    text-align: center;
}

.trend-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.trend-badge.improving {
    background: #dcfce7;
    color: #15803d;
}

.trend-badge.declining {
    background: #fee2e2;
    color: #b91c1c;
}

.leaderboard-footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

.legend {
    display: flex;
    gap: 24px;
    font-size: 13px;
    color: #64748b;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* =============================================================================
   LEAD SOURCE FILTER BUTTONS
   ============================================================================= */

.lead-source-filter-container {
    margin-bottom: 20px;
    padding: 15px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.filter-buttons-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.filter-label {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin: 0;
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    font-weight: 500;
    color: #4b5563;
}

.filter-btn:hover {
    border-color: var(--group-color, #6366f1);
    background: rgba(var(--group-color-rgb, 99, 102, 241), 0.05);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.filter-btn.active {
    background: var(--group-color, #6366f1);
    border-color: var(--group-color, #6366f1);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.filter-btn .filter-emoji {
    font-size: 16px;
    line-height: 1;
}

.filter-btn .filter-text {
    font-weight: 600;
}

.filter-btn .filter-count {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.filter-btn.active .filter-count {
    background: rgba(255, 255, 255, 0.25);
}

/* Responsive */
@media (max-width: 768px) {
    .filter-buttons {
        flex-direction: column;
    }

    .filter-btn {
        justify-content: space-between;
        width: 100%;
    }
}
