/* Layout only: selectpicker and Bootstrap controls use the shared screener styles. */
.d2-discovery-filters { display: flex; align-items: start; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; padding: 12px 0 16px; border-bottom: 1px solid var(--site-border); }
.d2 .d2-discovery-fields { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 540px; min-width: 0; }
.d2-discovery-fields > div { flex: 1 1 160px; min-width: 0; max-width: 300px; }
.d2 .d2-discovery-fields .bootstrap-select { width: 100% !important; }
.d2-discovery-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.d2-discovery-actions .btn { white-space: nowrap; }
.d2-screener-heading > div > p { margin-top: 6px; max-width: 660px; font-size: .8rem; }
.d2-screener-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px; font-size: .8rem; }
.d2-screener-tools > a { white-space: nowrap; }
.d2-discovery-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 24px 32px; }
.d2-screeners[data-view="expanded"] .d2-discovery-grid { grid-template-columns: minmax(0,1fr); }
.d2-screeners .d2-expanded-only { display: none; }
.d2-expanded-table { display: none; }
.d2-screeners[data-view="expanded"] .d2-expanded-table { display: block; }
.d2-screeners[data-view="expanded"] .d2-compact-table { display: none; }
.d2-screener-scroll { height: auto; max-height: none; overflow-x: auto; overflow-y: hidden; padding-bottom: 1px; }
.d2-discovery-card { min-width: 0; padding: 0; }
.d2-discovery-card h3 { margin: 0; }
.d2-discovery-card header { padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--site-border); }
.d2-discovery-card header > p { color: var(--site-muted); font-size: .8rem; line-height: 1.4; margin-top: 6px; }
.d2-compact-table .table { margin: 0; font-size: .875rem; }
.d2-compact-table .table th { padding: 8px 0; border-color: var(--site-border); color: var(--site-muted); font-size: .8rem; font-weight: 600; white-space: nowrap; }
.d2-compact-table .table td { padding: 12px 0; border-color: var(--site-border); vertical-align: middle; }
.d2-compact-table .table td:first-child { padding-right: 12px; }
.d2-compact-table .table th + th, .d2-compact-table .table td + td { padding-left: 16px; }
.d2-compact-table .table td:last-child { white-space: nowrap; }
.d2-compact-table .issuer-link { font-size: .875rem; }
.d2-empty-screeners { margin-top: 16px; padding: 14px 18px; border: 1px solid var(--site-border); border-radius: 8px; color: var(--site-muted); font-size: .8rem; }
.d2-empty-screeners summary { cursor: pointer; color: var(--site-text); }
.d2-empty-screeners > div { margin-top: 12px; }
.d2-empty-screeners p + p { margin-top: 6px; }
.d2-empty-screeners-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 14px; }
.d2-snapshot-status { padding: 24px; background: var(--site-surface-soft); border-radius: 8px; color: var(--site-muted); font-size: .85rem; }
@media(max-width:767px) { .d2 .d2-discovery-fields { flex-basis: 100%; } .d2-discovery-fields > div { flex-basis: 100%; max-width: none; } .d2-discovery-grid { grid-template-columns: 1fr; } .d2-screener-heading { align-items: start; } .d2-discovery-card { padding: 0; } }
.d2-compact-table .table td.d2-buy-text { color: #24623b; }
.d2-compact-table .table td.d2-sell-text { color: #a12f42; }
[data-bs-theme="dark"] .d2-compact-table .table td.d2-buy-text { color: #a1dfb3; }
[data-bs-theme="dark"] .d2-compact-table .table td.d2-sell-text { color: #ffb0bd; }

/* Expanded uses the same analyticstable markup and Bootstrap spacing as the
   Earnings/Tracker previews. Only layout and preview-sort behavior live here. */
/* Keep horizontal overflow for narrow screens, without a nested vertical scroller.
   The extra pixel accommodates collapsed table borders at fractional zoom. */
.d2-expanded-table { min-width: 0; height: auto; max-height: none; overflow-x: auto; overflow-y: hidden; padding-bottom: 1px; }
.d2-expanded-table .activity-signal-row[data-episode-id]:hover,
.d2-expanded-table .activity-signal-row[data-episode-id]:focus {
    background-color: var(--site-surface-soft);
    box-shadow: inset 0 0 0 1px var(--site-border);
}
.d2-expanded-table .analyticstable { margin-bottom: 0; }
/* The shared signal table gives plain headers a fixed grey; match linked headers. */
.d2-expanded-table .activity-signal-results-table thead th { color: var(--site-text); }
.d2-expanded-table .analyticstable thead th a { pointer-events: none; cursor: default; }
.d2-expanded-table .analyticstable thead .bi-arrow-up,
.d2-expanded-table .analyticstable thead .bi-arrow-down,
.d2-expanded-table .analyticstable thead .bi-arrow-down-up { display: none; }
@media(max-width:767px) {
    /* The shared signals partial includes mobile card rules. These full-table
       previews keep every column available in a contained horizontal scroller. */
    .d2 .d2-expanded-table .analyticstable { display: table; width: 100%; min-width: 1000px; }
    .d2 .d2-expanded-table .analyticstable thead { display: table-header-group; }
    .d2 .d2-expanded-table .analyticstable tbody { display: table-row-group; width: auto; }
    .d2 .d2-expanded-table .analyticstable tr { display: table-row; width: auto; }
    .d2 .d2-expanded-table .analyticstable td { display: table-cell !important; width: auto; }
    .d2 .d2-expanded-table .activity-signal-row td::before { display: none; }
    .d2 .d2-expanded-table .activity-signal-row { border: 0; border-radius: 0; padding: 0; }
    .d2 .d2-expanded-table .activity-signal-row td { padding: .25rem; border-bottom: 1px solid var(--site-border); text-align: center !important; }
    .d2 .d2-expanded-table .activity-signal-row .activity-signal-description-cell,
    .d2 .d2-expanded-table .activity-signal-row .activity-signal-company-cell { text-align: left !important; }
}

/* Tooltips are appended to body, so scope by the Bootstrap custom class. */
[data-bs-theme="dark"] .d2-screener-tooltip {
    --bs-tooltip-bg: var(--site-surface-muted);
    --bs-tooltip-color: var(--site-text);
    --bs-tooltip-opacity: 1;
}
[data-bs-theme="dark"] .d2-screener-tooltip .tooltip-inner {
    border: 1px solid var(--site-border);
    box-shadow: 0 4px 12px rgb(0 0 0 / 25%);
}

/* Initial results reserve space; filter refreshes retain the existing tables. */
#d2-snapshot-results[aria-busy="true"]:has(> .d2-snapshot-status) { min-height: 24rem; }
#d2-snapshot-results[aria-busy="true"] .d2-discovery-grid { opacity: .55; pointer-events: none; }
