/* ============================================
   Screener table + filter bar
   ============================================ */

/* --- Compound Legend (collapsible + slider) --- */
.compound-legend {
  background: var(--color-canvas-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-6);
  overflow: hidden;
}

.compound-legend__toggle {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  text-align: left;
}

.compound-legend__toggle:hover {
  background: var(--color-canvas-elevated);
}

.compound-legend__title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-gold);
}

.compound-legend__summary {
  margin-left: auto;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.compound-legend__summary--hidden {
  display: none;
}

.compound-legend__chevron {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  flex-shrink: 0;
}

.compound-legend__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: 0 var(--space-4) var(--space-4);
}

.compound-legend--collapsed .compound-legend__body {
  display: none;
}

/* Slider */
.compound-slider {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
}

.compound-slider__label {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  white-space: nowrap;
  min-width: 80px;
}

.compound-slider__wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.compound-slider__input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--color-canvas-elevated);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
}

.compound-slider__input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-gold);
  border: 2px solid var(--color-canvas);
  box-shadow: 0 0 6px var(--color-gold-glow);
  cursor: pointer;
}

.compound-slider__input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-gold);
  border: 2px solid var(--color-canvas);
  cursor: pointer;
}

.compound-slider__ticks {
  display: flex;
  justify-content: space-between;
  padding: 0 2px;
}

.compound-slider__tick {
  font-size: 10px;
  color: var(--color-text-faint);
}

.compound-slider__tick--active {
  color: var(--color-gold);
  font-weight: var(--weight-bold);
}

.compound-slider__value {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--color-gold);
  min-width: 50px;
  text-align: center;
}

/* Visual milestone bar */
.compound-legend__visual {
  position: relative;
}

.compound-vis__header {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-bottom: var(--space-2);
}

.compound-bar {
  position: relative;
  height: 48px;
  margin-bottom: var(--space-2);
}

.compound-bar__track {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--color-canvas-elevated);
  border-radius: var(--radius-full);
}

.compound-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-gain), var(--color-gold));
  border-radius: var(--radius-full);
}

.compound-bar__milestone {
  position: absolute;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translateX(-50%);
}

.compound-bar__marker {
  width: 2px;
  height: 12px;
  background: var(--color-text-faint);
  border-radius: 1px;
  margin-bottom: 2px;
}

.compound-bar__label {
  font-size: 9px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.compound-bar__trades {
  font-size: 9px;
  color: var(--color-text-faint);
  position: absolute;
  bottom: 100%;
  margin-bottom: 2px;
  white-space: nowrap;
}

/* Paths (aspirational vs realistic) */
.compound-legend__paths {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  align-items: flex-start;
}

.compound-legend__path {
  flex: 1;
}

.compound-legend__path-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.compound-legend__path-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.compound-legend__path-sublabel {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

.compound-legend__rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.compound-legend__row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.compound-legend__row--detail {
  padding-left: var(--space-1);
}

.compound-legend__pct {
  font-size: var(--text-sm);
  color: var(--color-gain);
  font-weight: var(--weight-medium);
  min-width: 120px;
}

.compound-legend__arrow {
  color: var(--color-text-faint);
  font-size: var(--text-xs);
}

.compound-legend__trades {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.compound-legend__detail {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

.compound-legend__divider {
  width: 100%;
  height: 1px;
  background: var(--color-border);
}

.compound-legend__footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  text-align: center;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border-subtle);
}

.compound-legend__goal {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-gold);
}

.compound-legend__note {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-style: italic;
}

@media (min-width: 769px) {
  .compound-legend__toggle {
    padding: var(--space-4) var(--space-6);
  }

  .compound-legend__body {
    padding: 0 var(--space-6) var(--space-5);
  }

  .compound-legend__paths {
    flex-direction: row;
    gap: var(--space-6);
  }

  .compound-legend__divider {
    width: 1px;
    height: auto;
    align-self: stretch;
  }

  .compound-legend__footer {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }

  .compound-slider {
    flex-direction: row;
    align-items: center;
    gap: var(--space-4);
  }

  .compound-slider__value {
    text-align: right;
  }
}

/* Filter area */
.screener-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.screener-filters {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.screener-stats {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-left: auto;
}

/* Table container — mobile: card layout by default */
.screener-table-wrap {
  border: none;
  background: transparent;
}

/* Table — mobile: block/card layout */
.screener-table {
  width: 100%;
  font-size: var(--text-sm);
}

.screener-table,
.screener-table thead,
.screener-table tbody,
.screener-table tr,
.screener-table th,
.screener-table td {
  display: block;
}

.screener-table thead {
  display: none;
}

.screener-table tr {
  background: var(--color-canvas-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.screener-table tbody tr:hover {
  background: var(--color-canvas-elevated);
}

.screener-table td {
  padding: var(--space-1) 0;
  border-bottom: none;
  white-space: normal;
  vertical-align: middle;
}

.screener-table td::before {
  content: attr(data-label);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: var(--space-2);
}

/* Column-specific styles */
.col-ticker {
  font-family: var(--font-mono);
  font-weight: var(--weight-bold);
  color: var(--color-text);
  min-width: 70px;
}

.col-name {
  color: var(--color-text-muted);
  max-width: none;
}

.col-sector {
  color: var(--color-text-faint);
  font-size: var(--text-xs);
}

.col-tier {
  min-width: 90px;
}

.col-confidence {
  min-width: 100px;
}

.col-confidence__inner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.col-confidence__value {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  min-width: 28px;
}

.col-confidence__bar {
  flex: 1;
  min-width: 40px;
}

.col-price {
  font-family: var(--font-mono);
  text-align: right;
  min-width: 80px;
}

.col-change {
  font-family: var(--font-mono);
  font-weight: var(--weight-medium);
  text-align: right;
  min-width: 70px;
}

.col-diamond {
  width: 32px;
  text-align: center;
}

.col-entry-zone {
  width: 24px;
  text-align: center;
}

.entry-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-gold);
  box-shadow: 0 0 6px var(--color-gold);
}

/* Desktop: standard table layout */
@media (min-width: 769px) {
  .screener-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-canvas-raised);
  }

  .screener-table,
  .screener-table thead,
  .screener-table tbody,
  .screener-table tr,
  .screener-table th,
  .screener-table td {
    display: revert;
  }

  .screener-table thead {
    display: revert;
  }

  .screener-table th {
    position: sticky;
    top: 0;
    z-index: var(--z-base);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-faint);
    background: var(--color-canvas-raised);
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
  }

  .screener-table th:hover {
    color: var(--color-text-muted);
  }

  .screener-table th--sorted {
    color: var(--color-gold);
  }

  .screener-table th .sort-arrow {
    margin-left: var(--space-1);
    font-size: 10px;
    opacity: 0.5;
  }

  .screener-table th--sorted .sort-arrow {
    opacity: 1;
  }

  .screener-table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border-subtle);
    vertical-align: middle;
    white-space: nowrap;
  }

  .screener-table td::before {
    content: none;
  }

  .screener-table tr {
    background: none;
    border: none;
    border-radius: 0;
    padding: 0;
    margin-bottom: 0;
  }

  .screener-table tbody tr:hover {
    background: var(--color-canvas-elevated);
  }

  .screener-table tbody tr:last-child td {
    border-bottom: none;
  }

  .col-name {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* --- Sector Heatmap --- */
.heatmap-section {
  margin-bottom: var(--space-6);
}

.heatmap-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.heatmap-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
}

.heatmap-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  transition: border-color var(--transition-fast);
  cursor: default;
}

.heatmap-card:hover {
  border-color: var(--color-text-faint);
}

.heatmap-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.heatmap-card__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.heatmap-regime {
  font-size: 9px;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 1px var(--space-2);
  border-radius: var(--radius-full);
}

.heatmap-regime--range {
  color: var(--color-gold);
  background: var(--color-gold-faint);
}

.heatmap-regime--trend {
  color: var(--color-chart-line);
  background: var(--color-chart-line-faint);
}

.heatmap-regime--neutral {
  color: var(--color-text-faint);
  background: var(--color-text-muted-faint);
}

.heatmap-card__change {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  margin-bottom: var(--space-2);
}

.heatmap-card__meta {
  display: flex;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-bottom: var(--space-3);
}

.heatmap-card__movers {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.heatmap-mover {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

@media (max-width: 480px) {
  .heatmap-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Compliance Shifts --- */
.shift-section {
  margin-bottom: var(--space-6);
}

.shift-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.shift-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
}

.shift-list {
  display: flex;
  gap: var(--space-3);
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: var(--space-1);
}

.shift-list::-webkit-scrollbar {
  display: none;
}

.shift-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  white-space: nowrap;
  cursor: pointer;
  transition: border-color var(--transition-fast);
  flex-shrink: 0;
}

.shift-item:hover {
  border-color: var(--color-text-faint);
}

.shift-item--new {
  background: var(--color-gain-faint);
  border-color: var(--color-gain-border);
}

.shift-item--decay {
  background: var(--color-loss-faint);
  border-color: var(--color-loss-border);
}

.shift-icon {
  font-size: var(--text-sm);
}

.shift-item--new .shift-icon {
  color: var(--color-gain);
}

.shift-item--decay .shift-icon {
  color: var(--color-loss);
}

.shift-ticker {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--color-text);
}

.shift-name {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.shift-label {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}
