/* ============================================
   FundVault — Screener Page Styles
   ============================================ */

.screener-page .page-title {
  margin-bottom: var(--sp-2);
}

.screener-page .page-subtitle {
  margin-top: 0;
  margin-bottom: var(--sp-6);
}

.screener-search-bar {
  margin-bottom: var(--sp-6);
}

.screener-search-bar .search-input {
  font-size: var(--fs-15);
  padding: var(--sp-5) var(--sp-5) var(--sp-5) 44px;
}
.screener-search-bar .search-icon {
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
}

.category-pills {
  display: flex;
  gap: var(--sp-3);
  overflow-x: auto;
  padding-bottom: var(--sp-2);
}

.prebuilt-screens {
  display: flex;
  gap: var(--sp-2);
  overflow-x: auto;
  padding-bottom: var(--sp-2);
}

.prebuilt-btn {
  white-space: nowrap;
  font-size: var(--fs-12);
}

/* Screener full-bleed two-pane layout (filters flush to the far left) */
.page-content.screener-page.screener-fullbleed {
  max-width: none;
  padding: 0;
  display: grid;
  grid-template-columns: var(--filter-width, 320px) minmax(0, 1fr);
  align-items: start;
  position: relative;
}

/* Draggable divider between the filter rail and the results (desktop only) */
.filter-resizer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--filter-width, 320px);
  width: 11px;
  margin-left: -6px;
  z-index: 6;
  cursor: col-resize;
}
.filter-resizer::before {   /* the divider line */
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 5px;
  width: 1px;
  background: var(--border-light);
  transition: background 0.15s, width 0.15s, left 0.15s;
}
.filter-resizer:hover::before,
.filter-resizer.dragging::before {
  background: var(--text-link);
  width: 3px;
  left: 4px;
}
.filter-resizer::after {     /* grip handle, stays centred in the viewport */
  content: '';
  position: sticky;
  top: calc(50vh - 18px);
  display: block;
  margin: 0 auto;
  width: 5px;
  height: 36px;
  border-radius: 3px;
  background: var(--border-default);
  transition: background 0.15s;
}
.filter-resizer:hover::after,
.filter-resizer.dragging::after { background: var(--text-link); }

.screener-main {
  padding: var(--sp-6) var(--sp-7);
  min-width: 0;
}

/* Filter rail pinned to the extreme left edge, full height */
.screener-fullbleed .filter-sidebar {
  position: sticky;
  top: calc(var(--ticker-height) + var(--nav-height));
  height: calc(100vh - var(--ticker-height) - var(--nav-height));
  overflow-y: auto;
  padding: var(--sp-5) var(--sp-5) var(--sp-7);
  background: var(--bg-white);
  border-right: 1px solid var(--border-light);
  border-radius: 0;
  box-shadow: none;
}

.filter-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.filter-sidebar-header h4 {
  font-size: var(--fs-15);
  font-weight: var(--fw-bold);
  color: var(--text-brand);
}

.btn-clear-filters {
  font-size: var(--fs-12);
  color: var(--text-link);
  font-weight: var(--fw-medium);
  cursor: pointer;
  background: none;
  border: none;
  padding: 2px 4px;
  border-radius: var(--radius-xs);
  transition: all var(--transition-fast);
}

.btn-clear-filters:hover {
  background: var(--bg-selected-light);
}

.filter-group {
  margin-bottom: var(--sp-4);
}

.filter-group:last-child {
  margin-bottom: 0;
}

.filter-title {
  font-size: var(--fs-12);
  font-weight: var(--fw-bold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--sp-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

/* Collapsible filter sections (quick grid-rows height animation) */
.filter-title::after {
  content: '';
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  background: center / 13px 13px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a0b0' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  transition: transform 0.18s ease;
}
.filter-group.collapsed .filter-title::after { transform: rotate(-90deg); }
.filter-title:hover { color: var(--text-brand); }

.fg-wrap {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.18s ease;
}
.filter-group.collapsed .fg-wrap { grid-template-rows: 0fr; }
.fg-body {
  overflow: hidden;
  min-height: 0;
}

.filter-options {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.filter-options .checkbox-wrapper {
  font-size: var(--fs-13);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.filter-count {
  color: var(--text-tertiary);
  font-size: var(--fs-12);
}

/* Category accordion (expandable sub-categories) */
.cat-accordion {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.cat-block { border-radius: var(--radius-sm); }
.cat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
}
.cat-parent {
  font-size: var(--fs-13);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex: 1;
  min-width: 0;
}
.cat-toggle {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: var(--fs-12);
  padding: 2px 4px;
  line-height: 1;
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}
.cat-block.open .cat-toggle { transform: rotate(180deg); }
.cat-subs {
  display: none;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-2) 0 var(--sp-3) var(--sp-6);
  max-height: 260px;
  overflow-y: auto;
}
.cat-block.open .cat-subs { display: flex; }
.cat-sub {
  font-size: var(--fs-12);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.filter-slider-values {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-12);
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
  font-weight: var(--fw-medium);
}

/* ── Dual-range filter (AUM / Expense) ── */
.range-dual { padding-top: var(--sp-2); }

.range-dual-slider {
  position: relative;
  height: 18px;
  margin-bottom: var(--sp-4);
}
.range-dual-track {
  position: absolute;
  left: 0; right: 0;
  top: 7px;
  height: 4px;
  background: var(--border-light);
  border-radius: var(--radius-full);
}
.range-dual-fill {
  position: absolute;
  top: 0;
  height: 100%;
  background: var(--bg-dark);
  border-radius: var(--radius-full);
}
.range-dual input[type="range"] {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 18px;
  margin: 0;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}
.range-dual input[type="range"]::-webkit-slider-runnable-track {
  -webkit-appearance: none;
  height: 18px;
  background: transparent;
}
.range-dual input[type="range"]::-moz-range-track { height: 18px; background: transparent; }
.range-dual input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  pointer-events: auto;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--bg-white);
  border: 2px solid var(--bg-dark);
  box-shadow: var(--shadow-flat);
  cursor: pointer;
  margin-top: 1px;
}
.range-dual input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--bg-white);
  border: 2px solid var(--bg-dark);
  cursor: pointer;
}

.range-dual-inputs {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.range-dual-inputs .rd-num {
  flex: 1;
  min-width: 0;
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: var(--fs-13);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.range-dual-inputs .rd-num:focus {
  outline: none;
  border-color: var(--color-blue);
}
.range-dual-inputs .rd-to { font-size: var(--fs-12); color: var(--text-tertiary); }

.range-presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
}
.range-preset {
  padding: var(--sp-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.range-preset:hover { border-color: var(--text-secondary); color: var(--text-brand); }
.range-preset.active {
  background: var(--bg-dark);
  border-color: var(--bg-dark);
  color: var(--text-white);
}

/* Results panel */
.screener-results {
  padding: 0;
}

.screener-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border-light);
}

.results-count {
  font-size: var(--fs-14);
  color: var(--text-secondary);
  font-weight: var(--fw-semibold);
}

.sort-select {
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: var(--fs-13);
  color: var(--text-primary);
  background: var(--bg-white);
  cursor: pointer;
}

/* Export to Excel button */
.export-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--color-up, #12a150);
  border-radius: var(--radius-sm);
  font-size: var(--fs-13);
  font-weight: var(--fw-semibold);
  color: var(--color-up-dark, #0f7a3d);
  background: var(--bg-white);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-fast), box-shadow var(--transition-fast);
}
.export-btn svg { width: 15px; height: 15px; }
.export-btn:hover {
  background: rgba(18, 161, 80, 0.08);
  box-shadow: 0 1px 4px rgba(18, 161, 80, 0.15);
}
.export-btn:active { transform: translateY(0.5px); }

.sparkline-cell {
  display: block;
}

/* Mobile filter drawer controls — hidden on desktop */
.mobile-filter-btn { display: none; }
.filter-drawer-close { display: none; }
.filter-backdrop { display: none; }

/* Medium screens: single column, sidebar stacks above results */
@media (max-width: 1024px) and (min-width: 769px) {
  .page-content.screener-page.screener-fullbleed {
    grid-template-columns: 1fr;
  }
  .filter-resizer { display: none; }
  .screener-fullbleed .filter-sidebar {
    position: static;
    height: auto;
    overflow-y: visible;
    border-right: none;
    border-bottom: 1px solid var(--border-light);
  }
  .screener-main { padding: var(--sp-5); }
}

/* Phones: results first, filters live in an off-canvas drawer */
@media (max-width: 768px) {
  .page-content.screener-page.screener-fullbleed {
    grid-template-columns: 1fr;
  }
  .filter-resizer { display: none; }
  .screener-main { padding: var(--sp-5) var(--sp-4) var(--sp-7); }

  /* "Filters" button shown under the title */
  .mobile-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    margin: var(--sp-4) 0 var(--sp-5);
    padding: var(--sp-3) var(--sp-5);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-full);
    background: var(--bg-white);
    color: var(--text-primary);
    font-size: var(--fs-13);
    font-weight: var(--fw-semibold);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
  }
  .mobile-filter-btn svg { width: 15px; height: 15px; }

  /* Sidebar → left drawer */
  .screener-fullbleed .filter-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 86vw; max-width: 330px;
    height: 100dvh;
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    border-right: 1px solid var(--border-light);
    box-shadow: var(--shadow-popup);
    padding: var(--sp-5) var(--sp-5) var(--sp-8);
  }
  .screener-fullbleed.filters-open .filter-sidebar { transform: translateX(0); }

  .filter-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(8, 15, 30, 0.45);
    z-index: 1000;
  }
  .screener-fullbleed.filters-open .filter-backdrop { display: block; }

  .filter-drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px; height: 30px;
    border: none;
    background: var(--bg-subtle, #f1f4f9);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: var(--fs-14);
    cursor: pointer;
  }

  .category-pills { flex-wrap: nowrap; }
  .prebuilt-screens { flex-wrap: wrap; }

  /* Results header: stack count above the export/sort controls */
  .screener-results-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-4);
  }
  .screener-results-header .results-count { white-space: nowrap; }
  .screener-results-header > .d-flex { width: 100%; }
  .export-btn { flex: 1; justify-content: center; }
  .sort-select { flex: 1; }

  /* The wide fund table scrolls horizontally inside its card (page doesn't) */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .data-table { min-width: 720px; }
}
