:root {
  /* Color Palette - Light Mode */
  --bg-primary: #ffffff;
  --bg-secondary: #f7f7f8;
  --bg-tertiary: #f0f0f2;
  --bg-glass: rgba(255, 255, 255, 0.6);

  --accent-primary: hsl(260, 85%, 40%);
  --accent-secondary: hsl(200, 90%, 40%);
  --accent-gradient: linear-gradient(
    135deg,
    hsl(260, 85%, 40%),
    hsl(200, 90%, 40%)
  );

  --text-primary: #000000;
  --text-secondary: hsl(0, 0%, 35%);
  --text-muted: hsl(0, 0%, 55%);

  --border-color: rgba(0, 0, 0, 0.08);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.09);

  --success: hsl(140, 70%, 55%);
  --warning: hsl(40, 90%, 60%);
  --error: hsl(0, 80%, 60%);

  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
  --header-height: 63px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Poppins", Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Animated Background */
body::before {
  content: "";
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
      circle at 20% 50%,
      hsla(260, 85%, 65%, 0.15) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 80% 80%,
      hsla(200, 90%, 55%, 0.15) 0%,
      transparent 50%
    );
  animation: rotate 30s linear infinite;
  z-index: -1;
}

@keyframes rotate {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0.2rem 1rem;
  /* preserve some horizontal padding, reduce vertical */
}

/* Header */
.header {
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 0.3rem 0.9rem;
  /* reduced vertical padding */
  /* margin-bottom: 0.5rem; */
  box-shadow: var(--shadow-md);
  overflow: hidden;
  /* layout: left content + right filters */
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 80;
  /* keep header visually on top while scrolling */
}

/* Put the home icon at the extreme left of the header */
.header-left {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  justify-self: start;
  z-index: 90;
}

/* Header main left area groups home, title, stats */
.header-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0rem;
  font-size: 0.9rem; /* slightly reduced overall */
  min-width: 200px;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.header-main .title {
  font-size: 0.85rem; /* slightly larger title for clarity */
  margin: 0;
  line-height: 1;
}

.header-main .stat-item .stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
}

.header-main .stat-item .stat-value {
  font-size: 1rem;
  font-weight: 700;
}

/* Small vertical spacing between title row and stats
.header-stats {
  margin-top: 0.35rem;
} */

/* Filters area on the right */
.header-filters {
  justify-self: end;
}

.home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 8px;
  color: var(--text-primary);
  text-decoration: none;
  background: transparent;
  transition: background var(--transition-fast),
    transform var(--transition-fast);
}

.home-link svg {
  fill: var(--accent-primary);
}

.home-link:hover {
  background: var(--bg-tertiary);
  transform: translateY(-2px);
}

.header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent-gradient);
}

.header-content {
  text-align: left;
  margin-bottom: 0;
  justify-self: start;
}

.title {
  font-size: 1.8rem;
  font-weight: 600;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

/* Right side stats placement (inline within left area) */
.header-stats {
  position: relative;
  right: auto;
  top: auto;
  transform: none;
}

.title-icon {
  font-size: 1.8rem;
  filter: drop-shadow(0 0 12px hsla(260, 85%, 65%, 0.4));
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 400;
}

.stats-bar {
  display: flex;
  gap: 0rem;
  justify-content: center;
  flex-wrap: wrap;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* gap: 0.25rem; */
  padding: 0rem 0.9rem;
  /* reduce vertical height */
  /* background: var(--bg-secondary); */
  border-radius: 12px;
  /* border: 1px solid var(--border-color); */
  transition: all var(--transition-normal);
  line-height: 18px;
  margin-bottom: 5px;
}
/* 
.stat-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-primary);
} */

/* Highlight the Total Datasets stat (first stat-item) */
.stats-bar .stat-item:first-child {
  /* background: #ffffff !important; */
  color: var(--text-primary) !important;
  /* border: 1px solid var(--border-color) !important; */
  /* box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06) !important; */
}

.stats-bar .stat-item:first-child .stat-label {
  color: var(--text-secondary);
}

.stats-bar .stat-item:first-child .stat-value {
  /* Override the gradient text style for legibility on a solid background */
  background: none !important;
  -webkit-background-clip: unset !important;
  -webkit-text-fill-color: unset !important;
  background-clip: unset !important;
  color: var(--text-primary) !important;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-value {
  font-size: 1.2rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Filter Panel */
.filter-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: 24px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-lg);
}

.filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.filter-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.btn-clear {
  padding: 0.75rem 1.5rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.btn-clear:hover {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px hsla(260, 85%, 65%, 0.3);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-group label {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
}

.filter-select {
  padding: 0.75rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
  cursor: pointer;
  min-height: 100px;
}

.filter-select:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px hsla(260, 85%, 65%, 0.2);
}

.filter-select:hover {
  border-color: var(--accent-secondary);
}

.filter-select option {
  padding: 0.5rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* Filter Controls (Column Selector) */
.filter-controls {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: #ffffff !important;
  padding: 0.4rem 0.5rem;
  /* reduce vertical padding */
  border-radius: 10px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  min-width: 280px;
  /* keep original width behavior */
  position: sticky;
  top: var(--header-height);
  z-index: 1;
  margin: 3px 0px;
}

/* When filter-controls are inside the header, avoid sticky positioning */
.header .filter-controls {
  position: relative;
  top: auto;
  min-width: 260px;
}

@media (max-width: 768px) {
  .header {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .header-filters {
    justify-self: stretch;
    margin-top: 0.5rem;
  }

  .header-main {
    width: 100%;
    gap: 0.6rem;
  }

  .header-content {
    text-align: center;
  }
}

.small-label {
  color: #000000 !important;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-select.small {
  padding: 0.35rem 0.45rem;
  /* slightly less vertical padding */
  background: var(--bg-secondarycolor, white);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.88rem;
  min-height: auto;
  max-height: 140px;
  cursor: pointer;
}

.filter-select.small:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px hsla(260, 85%, 65%, 0.2);
}

.filter-select option:checked {
  background: var(--accent-primary);
}

/* Search Filters Section (Below Dataset Information) */
.search-filters-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.4rem 0;
  margin-bottom: 0.6rem;
}

.search-filters-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.filter-search-input {
  padding: 0.75rem;
  background: #ffffff;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.filter-search-input:focus {
  outline: none;
  border-color: #0066ff;
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.filter-search-input::placeholder {
  color: var(--text-muted);
}

/* Search Filters (old - keeping for backward compatibility) */
/* Table Container */
.table-container {
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0 0.5rem;
  /* reduce vertical spacing */
  box-shadow: var(--shadow-md);
  margin-top: 2px;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
  flex-wrap: wrap;
  gap: 1rem;
  box-sizing: border-box;
}

.table-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
}

.search-box {
  padding: 0.35rem 0.6rem;
  /* reduce vertical padding */
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 0.92rem;
  min-width: 300px;
  /* restore original width behavior */
  transition: all var(--transition-fast);
}

.search-box:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px hsla(260, 85%, 65%, 0.2);
}

.search-box::placeholder {
  color: var(--text-muted);
}

/* Table */
.table-wrapper {
  overflow-x: auto;
  border-radius: 16px;
  position: relative;
  /* Make table body scrollable so header rows can stick inside this container */
  overflow-y: auto;
  max-height: calc(100vh - var(--header-height) - 180px);
  /* Ensure table area keeps a stable visual height even with few or no rows */
  min-height: var(
    --table-default-height
  ); /* unified min height to avoid flicker */
  /* Keep scrollbar gutter stable so showing/hiding scrollbars doesn't shift layout */
  scrollbar-gutter: stable both-edges;
  /* Prevent parent/page scroll when interacting with table scroll */
  overscroll-behavior: contain;
}
/* Make the table header/search and filter rows sticky INSIDE the table wrapper */
:root {
  --table-header-height: 48px;
  --filter-row-height: 34px;
  --table-default-height: 320px; /* unified table min height to avoid flicker when rows change */
}

.table-header {
  position: sticky; /* sticky relative to viewport (below main header) */
  top: var(--header-height);
  z-index: 100;
  background: linear-gradient(
    rgba(255, 255, 255, 0.95),
    rgba(255, 255, 255, 0.95)
  );
  padding: 0.4rem 0.4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--table-header-height);
  box-sizing: border-box;
}

/* Filter row and column header rows should stick while scrolling the table body */
.data-table thead tr.filter-row {
  position: sticky;
  top: 0; /* stick to top of the scrollable table body */
  z-index: 99;
  background: var(--bg-secondary);
}

.data-table thead tr.header-row {
  position: sticky;
  top: var(--filter-row-height);
  z-index: 98;
  background: var(--bg-secondary);
}

/* Ensure sticky cells render above table rows and have correct borders */
.data-table thead th,
.data-table thead td {
  background: var(--bg-secondary);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--bg-tertiary);
  border-top: 3px solid var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Loading spinner container - keep height consistent with table area */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: var(
    --table-default-height
  ); /* match table min height to avoid flicker */
  color: var(--text-muted);
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.7rem;
  /* Use fixed layout so column widths are controlled by <col> or inline widths */
  table-layout: fixed;
}

/* Ensure table element itself does not collapse when there are few rows */
.table-wrapper .data-table {
  min-height: var(--table-default-height);
}
.resizer {
  position: absolute;
  top: 0;
  /* nudge handle slightly outside header to increase hit area */
  right: -6px;
  width: 20px; /* larger hit area for easier grabbing */
  height: 100%;
  cursor: col-resize;
  z-index: 9999; /* ensure handle is above other header layers */
  /* make area easier to hit on touch */
  touch-action: none;
  opacity: 0.35;
  background: transparent;
}

.resizer:hover {
  opacity: 0.8;
}

/* Ensure cell contents truncate instead of forcing column wider */
.data-table td,
.data-table th {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* Keep the table header in normal flow; only the main header and .table-header are sticky. */
  position: relative;
}

.data-table th {
  padding: 0.4rem 0.5rem;
  /* reduce vertical padding */
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--accent-primary);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
}

.data-table th:hover {
  background: var(--bg-tertiary);
  color: var(--accent-primary);
}

/* Filter Row in Table Header */
.data-table tr.filter-row {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.filter-cell {
  padding: 0.25rem 0.35rem;
  /* reduce vertical height */
  vertical-align: middle;
}

.column-filter-input {
  width: 100%;
  padding: 0.25rem 0.3rem;
  /* smaller input height */
  background: #ffffff;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.82rem;
  transition: all var(--transition-fast);
}

.column-filter-input:focus {
  outline: none;
  border-color: #0066ff;
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.column-filter-input::placeholder {
  color: var(--text-muted);
}

/* Ensure the filter row is visible and inputs align under each header */
.data-table thead tr.filter-row {
  display: table-row;
  /* explicit: ensure row is rendered */
}

.data-table thead tr.filter-row td {
  padding: 0.25rem 0.4rem;
  /* slightly smaller */
  vertical-align: middle;
}

/* Make inputs full-width and clearly visible */
.data-table thead tr.filter-row .column-filter-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.25rem 0.3rem;
  background: #fff;
  border: 1px solid var(--border-color);
}

/* Visual hint so user notices the filter row */
.data-table thead tr.filter-row td:first-child {
  border-top: 2px solid transparent;
}

.data-table th::after {
  content: " ⇅";
  opacity: 0.3;
  font-size: 0.8rem;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: all var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--bg-secondary);
  /* avoid transform scaling which causes layout shifts and scrollbar flicker */
  transform: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.data-table td {
  padding: 0.4rem 0.5rem;
  /* reduce vertical space */
  color: var(--text-secondary);
}

.data-table td a {
  color: var(--accent-secondary);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.data-table td a:hover {
  color: var(--accent-primary);
  text-decoration: underline;
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
}

.status-production {
  background: hsla(140, 70%, 55%, 0.2);
  color: var(--success);
  border: 1px solid var(--success);
}

.status-staging {
  background: hsla(40, 90%, 60%, 0.2);
  color: var(--warning);
  border: 1px solid var(--warning);
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin: 0.6rem;
  flex-wrap: wrap;
}

.pagination button {
  padding: 0.3rem 0.5rem;
  /* slightly smaller */
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 0.86rem;
}

.pagination button:hover:not(:disabled) {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  color: #fff;
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination button.active {
  background: var(--accent-gradient);
  border-color: transparent;
  color: #fff;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-secondary);
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  .title {
    font-size: 1.8rem;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .table-header {
    flex-direction: column;
    align-items: stretch;
  }

  /* Stack header and stats on small screens */
  .header {
    flex-direction: column;
    align-items: center;
  }

  .header-stats {
    margin-top: 0.8rem;
  }

  .search-box {
    min-width: 100%;
  }

  .stats-bar {
    flex-direction: column;
    gap: 1rem;
  }

  /* Ensure header stacks and stats move below the centered title on small screens */
  .header {
    flex-direction: column;
    align-items: center;
  }

  .header-stats {
    position: static;
    transform: none;
    right: auto;
    margin-top: 0.8rem;
  }
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn var(--transition-normal) ease-out;
}

/* Override Choices.js multiselect default white background inside the filter controls
   - Use dark theme variables so the multiselect matches the dashboard look
   - Adjust selected pill color for better contrast
*/
.filter-controls .choices,
.filter-controls .choices__inner,
.filter-controls .choices__list {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
  border-radius: 10px;
  border: 1px solid var(--border-color) !important;
}

.filter-controls .choices__list--multiple .choices__item {
  background: var(--bg-tertiary) !important;
  color: var(--text-primary) !important;
  border: 1px solid rgba(255, 255, 255, 0.03) !important;
}

.filter-controls .choices__input,
.filter-controls .choices__list--single .choices__item--selectable {
  color: var(--text-primary) !important;
}

.filter-controls .choices__inner:focus {
  box-shadow: 0 0 0 3px hsla(260, 85%, 65%, 0.12) !important;
}

/* Checkbox-list styling for column selector */
.filter-controls .checkbox-list {
  /* Allow the list to expand to show all items without scroll.
       Items are laid out by .checkbox-list-inner as a wrapping flex row. */
  max-height: none;
  overflow: visible;
}

.filter-controls .checkbox-list-inner {
  /* horizontal flow with wrapping so items appear side-by-side */
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  /* gap: 0.45rem; */
  align-items: center;
}

.filter-controls .checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.15rem 0.5rem;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  transition: background var(--transition-fast);
  user-select: none;
}

.filter-controls .checkbox-item {
  flex: 0 0 auto;
}

.filter-controls .checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #0066ff !important;
}

.filter-controls .checkbox-item:hover {
  background: var(--bg-tertiary);
}

.filter-controls .checkbox-item .checkbox-label {
  color: var(--text-primary);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Filter Button Group */
.filter-btn-group {
  display: flex;
  gap: 0.8rem;
  /* margin-top: 0.8rem; */
}

/* Apply Filters Button */
.btn-apply {
  flex: 1;
  display: block;
  padding: 0.5rem;
  background: var(--accent-primary);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast);
  text-align: center;
  margin-top: 0;
  /* managed by group */
}

.btn-apply:hover {
  background: var(--accent-secondary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Reset Button */
.btn-reset {
  flex: 1;
  display: block;
  padding: 0.5rem;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.btn-reset:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-muted);
}

/* ========================================= */
/* Custom Multi-Select Dropdown Styles       */
/* ========================================= */

.multi-select-container {
  position: relative;
  width: 100%;
}

.multi-select-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.multi-select-input {
  width: 100%;
  padding: 0.35rem 1.8rem 0.35rem 0.4rem;
  /* Right padding for chevron */
  background: #ffffff;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.82rem;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.multi-select-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px hsla(260, 85%, 65%, 0.1);
}

.multi-select-chevron {
  position: absolute;
  right: 0.5rem;
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.7rem;
  transition: transform var(--transition-fast);
}

.multi-select-container.open .multi-select-chevron {
  transform: rotate(180deg);
}

.multi-select-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: min(250px, 150%);
  /* Start width, but allow it to be wider than column if needed */
  max-height: 250px;
  overflow-y: auto;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  /* High z-index to appear above sticky headers (header: 80, table-header: 70) */
  margin-top: 4px;
  display: none;
  flex-direction: column;
}

.multi-select-container.open .multi-select-dropdown {
  display: flex;
}

/* Allow dropdown to be shown even when moved to body (for overlay positioning) */
.multi-select-dropdown.open {
  display: flex;
}

/* Ensure dropdown doesn't get cut off by table overflow */
/* Note: If table has overflow-x: auto, absolute positioning might be clipped. 
   We often need a fixed strategy or enough bottom padding. 
   For now, we rely on z-index and assuming table container height allows simple drop-downs. 
   If clipped, we might need a 'fixed' position strategy in JS, but let's try absolute first.
*/

.multi-select-search-part {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
  z-index: 1;
}

.multi-select-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.multi-select-item {
  padding: 0.4rem 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  transition: background var(--transition-fast);
  font-size: 0.85rem;
  color: var(--text-primary);
  user-select: none;
}

.multi-select-item:hover {
  background: var(--bg-tertiary);
}

.multi-select-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.multi-select-item span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.multi-select-footer {
  padding: 0.4rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  background: var(--bg-secondary);
  position: sticky;
  bottom: 0;
  font-size: 0.75rem;
}

.multi-select-link {
  color: var(--accent-secondary);
  text-decoration: none;
  cursor: pointer;
  font-weight: 500;
}

.multi-select-link:hover {
  text-decoration: underline;
}

/* Badge for active filter count */
.multi-select-badge {
  position: absolute;
  right: 1.6rem;
  background: var(--accent-primary);
  color: #fff;
  font-size: 0.65rem;
  padding: 0.1rem 0.3rem;
  border-radius: 99px;
  pointer-events: none;
  display: none;
}
/* {
display: block;
} */

/* Clear icon (X) replaces chevron when active */
.multi-select-clear {
  position: absolute;
  right: 0.5rem;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  display: none;
  transition: color var(--transition-fast);
}

.multi-select-clear:hover {
  color: var(--error);
}

.multi-select-container.has-value .multi-select-chevron {
  display: none;
}

.multi-select-container.has-value .multi-select-clear {
  display: block;
}

/* FIX: Proper show/hide rules */
.multi-select-dropdown {
  display: none !important;
}

.multi-select-container.open .multi-select-dropdown {
  display: flex !important;
}

/* When a dropdown is moved to the body (floating) use the .floating class */
.multi-select-dropdown.floating {
  display: flex !important;
  /* positioning (fixed) will be applied via JS when floating */
  box-shadow: var(--shadow-md);
  border-radius: 8px;
}

/* Mobile-specific tweaks */
@media (max-width: 600px) {
  /* Keep stats visible but compact on small screens */
  .header-stats {
    display: block;
    font-size: 0.8rem;
  }

  /* Slightly reduce title and stat sizes to allow everything to fit */
  .header-main .title {
    font-size: 1.05rem;
  }

  .header-main .stat-item .stat-label {
    font-size: 0.6rem;
  }

  .header-main .stat-item .stat-value {
    font-size: 0.9rem;
  }

  /* Make home link slightly smaller on very small screens */
  .home-link {
    width: 36px;
    height: 36px;
  }

  /* Ensure filters take full width under header */
  .header {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }

  .header-filters {
    justify-self: stretch;
  }

  .header .filter-controls {
    width: 100%;
    min-width: 0;
  }
}
