/* ===================================================================
   Enhanced Dashboard Page Styles
   Based on the enhanced design system from subcontractor-details.css
   =================================================================== */

/* Import enhanced CSS custom properties */
:root {
  /* Extended color palette */
  --success: #22C55E;
  --success-light: #DCFCE7;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --danger: #EF4444;
  --danger-light: #FEE2E2;
  --neutral: #6B7280;
  --neutral-light: #F3F4F6;

  /* Enhanced spacing system */
  --space-xs: 0.25rem;    /* 4px */
  --space-sm: 0.5rem;     /* 8px */
  --space-md: 0.75rem;    /* 12px */
  --space-lg: 1rem;       /* 16px */
  --space-xl: 1.5rem;     /* 24px */
  --space-2xl: 2rem;      /* 32px */
  --space-3xl: 3rem;      /* 48px */

  /* Typography enhancements */
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Enhanced shadows */
  --shadow-soft: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-medium: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-large: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  /* Border radius system */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-2xl: 16px;

  /* Transition system */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.2s ease;
  --transition-slow: 0.3s ease;
}

/* ===================================================================
   Enhanced Page Header
   =================================================================== */

.page-header {
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--border);
}

.header-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.page-title {
  font-size: 1.875rem;
  font-weight: var(--font-weight-bold);
  color: var(--text);
  margin: 0;
  line-height: 1.2;
}

.page-subtitle {
  color: var(--muted);
  font-size: var(--fs-16);
  margin: 0;
}

.page-subtitle strong {
  color: var(--brand);
  font-weight: var(--font-weight-semibold);
}

/* ===================================================================
   Enhanced Statistics Section
   =================================================================== */

.stats-section {
  margin-bottom: var(--space-2xl);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
}

@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-soft);
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--border);
  transition: background var(--transition-normal);
}

.stat-card:hover {
  box-shadow: var(--shadow-medium);
  transform: translateY(-2px);
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg2);
  color: var(--muted);
  transition: all var(--transition-normal);
}

.stat-trend {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  opacity: 0.7;
}

.stat-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.stat-value {
  font-size: 2rem;
  font-weight: var(--font-weight-bold);
  line-height: 1;
  color: var(--text);
}

.stat-label {
  font-size: var(--fs-14);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.stat-description {
  font-size: var(--fs-12);
  color: var(--muted);
}

/* Stat card variants */
.compliant-card::before {
  background: var(--success);
}

.compliant-card .stat-icon {
  background: var(--success-light);
  color: var(--success);
}

.compliant-card .stat-value {
  color: var(--success);
}

.compliant-card .stat-trend {
  background: var(--success-light);
  color: var(--success);
}

.expiring-card::before {
  background: var(--warning);
}

.expiring-card .stat-icon {
  background: var(--warning-light);
  color: var(--warning);
}

.expiring-card .stat-value {
  color: var(--warning);
}

.expiring-card .stat-trend {
  background: var(--warning-light);
  color: var(--warning);
}

.expired-card::before {
  background: var(--danger);
}

.expired-card .stat-icon {
  background: var(--danger-light);
  color: var(--danger);
}

.expired-card .stat-value {
  color: var(--danger);
}

.expired-card .stat-trend {
  background: var(--danger-light);
  color: var(--danger);
}

.unknown-card::before {
  background: var(--neutral);
}

.unknown-card .stat-icon {
  background: var(--neutral-light);
  color: var(--neutral);
}

.unknown-card .stat-value {
  color: var(--neutral);
}

.unknown-card .stat-trend {
  background: var(--neutral-light);
  color: var(--neutral);
}

/* ===================================================================
   Enhanced Card Components (matching details page)
   =================================================================== */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  transition: box-shadow var(--transition-normal);
  margin-bottom: var(--space-2xl);
}

.card:hover {
  box-shadow: var(--shadow-medium);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--border);
  background-color: var(--bg2);
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }
}

.card-title {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: var(--fs-18);
  font-weight: var(--font-weight-semibold);
  margin: 0;
  color: var(--text);
}

.card-title svg {
  color: var(--brand);
  flex-shrink: 0;
}

.priority-card .card-title svg {
  color: var(--warning);
}

.card-body {
  padding: var(--space-xl);
}

@media (max-width: 640px) {
  .card-body {
    padding: var(--space-lg);
  }
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--success);
  font-size: var(--fs-14);
  font-weight: var(--font-weight-medium);
}

.status-indicator svg {
  flex-shrink: 0;
}

.status-text {
  font-weight: var(--font-weight-medium);
}

/* ===================================================================
   Enhanced Search Toolbar (matching subcontractors page)
   =================================================================== */

.search-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .search-toolbar {
    width: 100%;
  }
}

.search-group {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex: 1;
}

@media (max-width: 640px) {
  .search-group {
    flex-direction: column;
    width: 100%;
    gap: var(--space-md);
  }
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  max-width: 320px;
}

@media (max-width: 640px) {
  .search-input-wrapper {
    max-width: none;
    width: 100%;
  }
}

.search-icon {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: var(--space-md) var(--space-lg) var(--space-md) 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: var(--fs-14);
  background: var(--panel);
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ===================================================================
   Enhanced Table Design (matching other pages)
   =================================================================== */

.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--panel);
}

.priority-table,
.roster-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 600px;
  background: var(--panel);
}

.priority-table thead,
.roster-table thead {
  background: var(--bg2);
  position: sticky;
  top: 0;
  z-index: 10;
}

.priority-table th,
.roster-table th {
  padding: var(--space-lg) var(--space-xl);
  text-align: left;
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-14);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.th-content {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.th-content svg {
  color: var(--muted);
  flex-shrink: 0;
}

.priority-table td,
.roster-table td {
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.priority-row:hover td,
.roster-row:hover td {
  background-color: #fafcff;
}

.priority-row:nth-child(even) td,
.roster-row:nth-child(even) td {
  background-color: #fcfdff;
}

.priority-row:nth-child(even):hover td,
.roster-row:nth-child(even):hover td {
  background-color: #f0f7ff;
}

/* ===================================================================
   Enhanced Status System
   =================================================================== */

.status-cell {
  min-width: 140px;
}

.status-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-lg);
  font-size: var(--fs-14);
  font-weight: var(--font-weight-medium);
  text-transform: capitalize;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Status badge variants */
.status-valid {
  background-color: var(--success-light);
  color: var(--success);
  border-color: var(--success);
}

.status-valid .status-dot {
  background-color: var(--success);
}

.status-warning {
  background-color: var(--warning-light);
  color: var(--warning);
  border-color: var(--warning);
}

.status-warning .status-dot {
  background-color: var(--warning);
}

.status-danger {
  background-color: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger);
}

.status-danger .status-dot {
  background-color: var(--danger);
}

.status-neutral {
  background-color: var(--neutral-light);
  color: var(--neutral);
  border-color: var(--neutral);
}

.status-neutral .status-dot {
  background-color: var(--neutral);
}

/* ===================================================================
   Enhanced Info Triggers
   =================================================================== */

.info-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.info-trigger:hover {
  color: var(--brand);
  background-color: var(--bg2);
}

.info-trigger:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.info-trigger.header-info {
  margin-left: var(--space-xs);
}

/* ===================================================================
   Enhanced Links and Text
   =================================================================== */

.name-cell {
  font-weight: var(--font-weight-medium);
  min-width: 200px;
}

.subcontractor-link {
  color: var(--brand);
  text-decoration: none;
  font-weight: var(--font-weight-semibold);
  transition: color var(--transition-fast);
}

.subcontractor-link:hover {
  color: var(--brand-600);
  text-decoration: underline;
}

.date-cell {
  font-size: var(--fs-14);
  color: var(--text);
  min-width: 120px;
}

.date-cell time {
  font-weight: var(--font-weight-medium);
}

.text-muted {
  color: var(--muted);
  font-style: italic;
}

/* ===================================================================
   Enhanced Empty States
   =================================================================== */

.empty-row {
  display: contents;
}

.empty-cell {
  padding: var(--space-3xl) var(--space-xl);
  text-align: center;
  border: none;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
}

.empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--bg2), var(--border));
  border-radius: 50%;
  color: var(--muted);
}

.empty-state h4 {
  font-size: var(--fs-18);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  margin: 0;
}

.empty-state p {
  color: var(--muted);
  margin: 0;
  max-width: 300px;
  text-align: center;
}

.empty-state a {
  color: var(--brand);
  text-decoration: none;
  font-weight: var(--font-weight-medium);
  transition: color var(--transition-fast);
}

.empty-state a:hover {
  color: var(--brand-600);
  text-decoration: underline;
}

/* ===================================================================
   Enhanced Pagination (matching other pages)
   =================================================================== */

.pagination-container {
  margin-top: var(--space-xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border);
}

.pagination-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-lg);
  flex-wrap: wrap;
}

.pagination-btn {
  min-width: 100px;
}

.pagination-btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.pagination-btn[aria-disabled="true"]:hover {
  transform: none;
  box-shadow: none;
}

.pagination-info {
  color: var(--muted);
  font-size: var(--fs-14);
  text-align: center;
}

.pagination-info strong {
  color: var(--text);
  font-weight: var(--font-weight-semibold);
}

/* ===================================================================
   Enhanced Button System (matching other pages)
   =================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: var(--fs-14);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--panel);
  color: var(--text);
  min-height: 40px;
  font-family: inherit;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
  text-decoration: none;
}

.btn:active {
  transform: translateY(0);
}

.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn:disabled:hover {
  transform: none;
  box-shadow: none;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.btn-primary:hover {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: white;
}

.btn-secondary {
  background: var(--bg2);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--border);
}

/* ===================================================================
   Enhanced Popover System (Contextual)
   =================================================================== */
.popover {
  position: absolute;
  z-index: 2000;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-large);
  width: 100%;
  max-width: 280px;
  padding: var(--space-lg);
  font-size: var(--fs-14);
  line-height: 1.5;
  color: var(--text);
  opacity: 0;
  transform: translateY(4px);
  visibility: hidden;
  transition: opacity var(--transition-normal), transform var(--transition-normal), visibility var(--transition-normal);
}

.popover.visible {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

.popover-arrow {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--panel);
  transform: rotate(45deg);
  border: 1px solid var(--border);
}

/* ===================================================================
   Mobile Responsive Tables
   =================================================================== */

@media (max-width: 700px) {
  .table-container {
    border: none;
    background: transparent;
    overflow: visible;
  }

  .priority-table,
  .roster-table {
    min-width: 0;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 var(--space-md);
    background: transparent;
  }

  .priority-table thead,
  .roster-table thead {
    display: none;
  }

  .priority-table tbody,
  .roster-table tbody {
    display: block;
  }

  .priority-row,
  .roster-row {
    display: grid;
    grid-template-columns: 1fr;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
    transition: all var(--transition-normal);
  }

  .priority-row:hover,
  .roster-row:hover {
    box-shadow: var(--shadow-medium);
    border-color: var(--brand);
  }

  .priority-row:hover td,
  .roster-row:hover td,
  .priority-row:nth-child(even) td,
  .roster-row:nth-child(even) td,
  .priority-row:nth-child(even):hover td,
  .roster-row:nth-child(even):hover td {
    background: transparent;
  }

  .priority-table td,
  .roster-table td {
    display: grid;
    grid-template-columns: 120px 1fr;
    align-items: center;
    border: 0;
    padding: var(--space-md) 0;
    gap: var(--space-md);
  }

  .priority-table td + td,
  .roster-table td + td {
    border-top: 1px dashed var(--border);
    padding-top: var(--space-md);
  }

  .priority-table td::before,
  .roster-table td::before {
    content: attr(data-label);
    font-weight: var(--font-weight-semibold);
    color: var(--muted);
    font-size: var(--fs-12);
    text-transform: uppercase;
    letter-spacing: 0.025em;
  }

  .status-wrapper {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }

  .pagination-nav {
    flex-direction: column;
    gap: var(--space-md);
  }

  .pagination-info {
    order: -1;
  }
}

/* ===================================================================
   Responsive Design Enhancements
   =================================================================== */

/* Mobile adjustments */
@media (max-width: 640px) {
  .page-header {
    margin-bottom: var(--space-xl);
  }

  .page-title {
    font-size: 1.5rem;
  }

  .stats-grid {
    gap: var(--space-md);
  }

  .stat-card {
    padding: var(--space-lg);
  }

  .stat-value {
    font-size: 1.5rem;
  }
}

/* Tablet adjustments */
@media (min-width: 641px) and (max-width: 1023px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Large screen optimizations */
@media (min-width: 1200px) {
  .page-title {
    font-size: 2.25rem;
  }

  .priority-table td:first-child,
  .roster-table td:first-child,
  .priority-table th:first-child,
  .roster-table th:first-child {
    width: 260px;
  }
}

/* Reduced motion accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .card,
  .stat-card,
  .status-badge,
  .btn {
    border-width: 2px;
  }
}

/* ===================================================================
   Utility Classes
   =================================================================== */

.visually-hidden,
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
/*
   Enhanced "All clear!" text
*/
.status-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--success);
  font-size: var(--fs-14);
  font-weight: var(--font-weight-medium);
  white-space: nowrap; /* Add this line */
}

.status-indicator .status-text {
  font-size: var(--fs-16);
  font-weight: var(--font-weight-semibold);
  color: var(--success);
}
/*
   Style for the clickable stat cards to give them a hover effect.
*/
.stat-card-link {
    text-decoration: none;
    display: block;
    color: inherit;
    border-radius: var(--radius-xl); /* Match the card's border radius */
}

.stat-card-link:hover .stat-card,
.stat-card-link:focus-visible .stat-card {
    border-color: var(--brand);
    box-shadow: var(--shadow-medium);
    transform: translateY(-2px);
}

.stat-card-link:focus-visible {
    outline: none; /* The card's border will serve as the focus indicator */
}

/*
  Styles for the "Dashboard Guide" link in the page header
*/
.page-actions {
  margin-top: var(--space-md);
}

.page-actions .info-trigger {
  /* Override the fixed size from the base .info-trigger class */
  width: auto;
  height: auto;
  border-radius: var(--radius-lg);
  padding: var(--space-sm) var(--space-md);

  /* Adjust alignment and spacing for the text */
  justify-content: flex-start;
  gap: var(--space-sm);

  /* Style the link-like appearance */
  color: var(--brand);
  font-weight: var(--font-weight-medium);
  font-size: var(--fs-14);
}

.page-actions .info-trigger:hover {
  background-color: var(--bg2);
  text-decoration: underline;
}

/* Modal stays hidden only when the [hidden] attribute is present */
.popover-overlay[hidden] { display: none; }

/* When not hidden OR explicitly .is-open, render it */
.popover-overlay:not([hidden]),
.popover-overlay.is-open {
  display: flex;                 /* center the content */
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  z-index: 3000;
}

/* Panel sizing for the "wide" guide modal */
.popover-overlay .popover-content {
  background: #fff;
  max-width: 720px;
  width: min(90vw, 720px);
  max-height: 85vh;
  overflow: auto;
  border-radius: 12px;
  padding: 1rem;
  outline: none; /* focus lands here */
}

/* Modal hidden only when [hidden] is present */
.popover-overlay[hidden] { display: none !important; }

/* When visible, render above everything and block interaction behind it */
.popover-overlay:not([hidden]),
.popover-overlay.is-open {
  display: flex !important;
  position: fixed;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.5);
  z-index: 9999; /* higher than any popovers, headers, or backdrops */
  pointer-events: auto;
}

.popover-overlay[hidden] { display: none !important; }

  .popover-overlay.is-open {
    display: flex !important;
    position: fixed !important;
    inset: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(0,0,0,0.5) !important;
    z-index: 2147483647 !important; /* win any stacking contest */
    pointer-events: auto !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .popover-overlay .popover-content {
    background: #fff !important;
    color: #111 !important;
    width: min(90vw, 720px) !important;
    max-width: 720px !important;
    max-height: 85vh !important;
    overflow: auto !important;
    -webkit-overflow-scrolling: touch !important; /* smooth iOS scrolling */
    border-radius: 12px !important;
    padding: 20px !important;
    box-shadow: 0 24px 48px rgba(0,0,0,.16), 0 2px 6px rgba(0,0,0,.10) !important;
  }

  /* The overlay must never block clicks when closed */
  .popover-overlay { pointer-events: none !important; }

  .popover-overlay[hidden] {
    display: none !important;
  }

  /* When open, it's visible and interactive, above small popovers */
  .popover-overlay.is-open {
    display: flex !important;
    position: fixed !important;
    inset: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(0,0,0,0.5) !important;
    z-index: 3000 !important;       /* popovers use 2000 */
    pointer-events: auto !important; /* only eat clicks while open */
    opacity: 1 !important;
    visibility: visible !important;
  }

  /* Small popover layering stays below the modal but above the page */
  .popover { z-index: 2000; }

  /* ===================================================================
     Modal Dialog Body Styling
     =================================================================== */

  .popover-overlay .popover-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border);
  }

  .popover-overlay .popover-title {
    font-size: var(--fs-18);
    font-weight: var(--font-weight-semibold);
    margin: 0;
  }

  .popover-overlay .popover-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    color: var(--muted);
    transition: all var(--transition-fast);
  }

  .popover-overlay .popover-close:hover {
    color: var(--text);
    background-color: var(--bg2);
  }

  .popover-overlay .popover-body h4 {
    color: var(--text);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-md);
  }

  .popover-overlay .popover-body ul {
    list-style: none; /* This removes the black dots */
    padding: 0;
    margin: 0 0 var(--space-lg) 0;
  }

  .popover-overlay .popover-body li {
    display: flex; /* This aligns the badge and text on the same line */
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) 0;
  }

  .popover-overlay .popover-body hr {
    border: none;
    height: 1px;
    background: var(--border);
    margin: var(--space-lg) 0;
  }

  .popover-overlay .popover-body p {
    color: var(--muted);
    line-height: 1.6;
  }

  /* ===================================================================
     Stat Card Trend Icons
     =================================================================== */

  .stat-trend {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
  }

  .stat-trend.positive {
    color: var(--success);
  }

  .stat-trend.warning {
    color: var(--warning);
  }

  .stat-trend.danger {
    color: var(--danger);
  }

  .stat-trend.neutral {
    color: var(--neutral);
  }
/* Add this to your dashboard.css file */

.stat-card-link.active-filter .stat-card {
    /* Make the border more prominent */
    border-color: var(--brand); /* Use brand color for active border */
    border-width: 2px;

    /* Optional: Slightly different background or shadow */
    background-color: #f5f8ff; /* A very light blue tint */
    box-shadow: var(--shadow-medium); /* Use a slightly stronger shadow */

    /* Ensure padding adjusts for the thicker border */
    padding: calc(var(--space-xl) - 1px); /* Adjust padding */
}

/* Ensure hover effect doesn't override active state border */
.stat-card-link.active-filter:hover .stat-card {
    border-color: var(--brand);
}

/* Add focus state for accessibility */
.stat-card-link.active-filter:focus-visible .stat-card {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}