/* ——— Finance screener tables ——— */

.finance-page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.35rem 0.15rem 0.15rem;
}

.finance-page-title {
    margin: 0;
    font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.65rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #2f3b4a;
    line-height: 1.25;
}

.finance-page-subtitle {
    margin-top: 0.35rem;
    font-size: 0.9rem;
    color: #8494a7;
    max-width: 42rem;
    line-height: 1.45;
}

.theme-dark .finance-page-title {
    color: #e7eaf0;
}

.theme-dark .finance-page-subtitle {
    color: #8b96a8;
}

.finance-screener-panel {
    background: var(--bs-card-bg, #fff);
    border: 1px solid #e5e9ef;
    border-radius: 0.9rem;
    box-shadow: 0 8px 24px rgba(47, 59, 74, 0.06);
    padding: 0.65rem 0.75rem 0.9rem;
    margin-bottom: 1.5rem;
    /* visible so sticky / FixedHeader thead is not clipped */
    overflow: visible;
}

.theme-dark .finance-screener-panel {
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

.finance-screener-table {
    margin: 0 !important;
    border-collapse: separate;
    border-spacing: 0;
}

/* Primary header row — solid slate, high contrast */
.finance-screener-table thead tr:first-child th {
    background: #334155 !important;
    color: #f8fafc !important;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    border: 0 !important;
    border-bottom: 2px solid #1e293b !important;
    padding: 0.75rem 0.55rem !important;
    vertical-align: middle;
    position: sticky;
    top: 0;
    z-index: 3;
    box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.06);
}

/* Two-line metric headers — narrower columns */
.finance-screener-table thead tr:first-child th.th-wrap {
    white-space: normal !important;
    min-width: 4.25rem;
    max-width: 6.75rem;
    width: 5.5rem;
    line-height: 1.25;
    font-size: 0.82rem;
    padding: 0.6rem 0.4rem !important;
    text-align: center;
}

.finance-screener-table thead tr:first-child th.th-wrap .th-sub {
    display: inline-block;
    margin-top: 0.15rem;
    font-size: 0.76rem;
    font-weight: 700;
    opacity: 0.95;
}

/* Wider company name column */
.finance-screener-table thead tr:first-child th.col-company-name,
.finance-screener-table tbody td.col-company-name,
.finance-screener-table tbody td.cell-name {
    min-width: 15rem;
    width: 18%;
    max-width: 24rem;
    white-space: normal !important;
    line-height: 1.35;
}

/* Company metrics — cool blue */
.finance-screener-table thead tr:first-child th.col-metric-company {
    background: #3b5b84 !important;
    border-bottom-color: #2a4466 !important;
}

.finance-screener-table tbody td.col-metric-company {
    background-color: rgba(59, 130, 246, 0.07);
}

/* Sector metrics — soft teal */
.finance-screener-table thead tr:first-child th.col-metric-sector {
    background: #2f6a5f !important;
    border-bottom-color: #214f46 !important;
}

.finance-screener-table tbody td.col-metric-sector {
    background-color: rgba(16, 185, 129, 0.07);
}

.finance-screener-table.table-striped > tbody > tr:nth-of-type(odd) > td.col-metric-company {
    background-color: rgba(59, 130, 246, 0.11);
}

.finance-screener-table.table-striped > tbody > tr:nth-of-type(odd) > td.col-metric-sector {
    background-color: rgba(16, 185, 129, 0.11);
}

.finance-screener-table tbody tr:hover > td.col-metric-company {
    background-color: rgba(59, 130, 246, 0.16) !important;
}

.finance-screener-table tbody tr:hover > td.col-metric-sector {
    background-color: rgba(16, 185, 129, 0.16) !important;
}

.theme-dark .finance-screener-table thead tr:first-child th.col-metric-company {
    background: #2f4a6e !important;
}

.theme-dark .finance-screener-table thead tr:first-child th.col-metric-sector {
    background: #24574e !important;
}

.theme-dark .finance-screener-table tbody td.col-metric-company {
    background-color: rgba(96, 165, 250, 0.1);
}

.theme-dark .finance-screener-table tbody td.col-metric-sector {
    background-color: rgba(52, 211, 153, 0.1);
}

.finance-screener-table thead tr:first-child th:first-child {
    border-start-start-radius: 0.35rem;
}

.finance-screener-table thead tr:first-child th:last-child {
    border-start-end-radius: 0.35rem;
}

/* DataTables sort affordance on dark header */
.finance-screener-table.dataTable thead tr:first-child th.sorting,
.finance-screener-table.dataTable thead tr:first-child th.sorting_asc,
.finance-screener-table.dataTable thead tr:first-child th.sorting_desc,
.finance-screener-table.dataTable thead tr:first-child th.sorting_asc_disabled,
.finance-screener-table.dataTable thead tr:first-child th.sorting_desc_disabled {
    color: #f8fafc !important;
    background-image: none !important;
    cursor: pointer;
}

.finance-screener-table.dataTable thead tr:first-child th.sorting:hover,
.finance-screener-table.dataTable thead tr:first-child th.sorting_asc:hover,
.finance-screener-table.dataTable thead tr:first-child th.sorting_desc:hover {
    background: #3f4f66 !important;
}

.finance-screener-table.dataTable thead tr:first-child th.sorting::after,
.finance-screener-table.dataTable thead tr:first-child th.sorting_asc::after,
.finance-screener-table.dataTable thead tr:first-child th.sorting_desc::after {
    content: "";
    display: inline-block;
    width: 0;
    height: 0;
    margin-inline-start: 0.4rem;
    vertical-align: middle;
    opacity: 0.55;
    border-inline-start: 4px solid transparent;
    border-inline-end: 4px solid transparent;
}

.finance-screener-table.dataTable thead tr:first-child th.sorting::after {
    border-block-start: 5px solid rgba(248, 250, 252, 0.65);
    opacity: 0.35;
    transform: translateY(1px);
}

.finance-screener-table.dataTable thead tr:first-child th.sorting_asc::after {
    border-block-end: 5px solid #ffffff;
    opacity: 1;
}

.finance-screener-table.dataTable thead tr:first-child th.sorting_desc::after {
    border-block-start: 5px solid #ffffff;
    opacity: 1;
}

.finance-screener-table th.fair-price-col .fair-price-col-hint {
    color: rgba(248, 250, 252, 0.72) !important;
}

.finance-screener-table th.fair-price-col .fair-price-header-info {
    color: #93c5fd !important;
}

/* Filter / second header row */
.finance-screener-table thead tr:nth-child(2) th {
    background: #f1f5f9 !important;
    border: 0 !important;
    border-bottom: 1px solid #e2e8f0 !important;
    padding: 0.45rem 0.4rem !important;
    vertical-align: middle;
}

.finance-screener-table thead tr:nth-child(2) th input.form-control {
    background: #fff;
    border-color: #d0d7e2;
    color: #334155;
    font-size: 0.75rem;
    min-height: 1.85rem;
}

.theme-dark .finance-screener-table thead tr:first-child th {
    background: #1e2433 !important;
    color: #eef2ff !important;
    border-bottom-color: #0f1420 !important;
}

.theme-dark .finance-screener-table.dataTable thead tr:first-child th.sorting:hover,
.theme-dark .finance-screener-table.dataTable thead tr:first-child th.sorting_asc:hover,
.theme-dark .finance-screener-table.dataTable thead tr:first-child th.sorting_desc:hover {
    background: #2a3347 !important;
}

.theme-dark .finance-screener-table thead tr:nth-child(2) th {
    background: #171b26 !important;
    border-bottom-color: rgba(255, 255, 255, 0.06) !important;
}

.theme-dark .finance-screener-table thead tr:nth-child(2) th input.form-control {
    background: #12151e;
    border-color: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

.finance-screener-table tbody td {
    font-size: 0.95rem;
    padding: 0.65rem 0.65rem !important;
    vertical-align: middle !important;
    border-color: #eef1f5 !important;
    color: #334155;
}

/* Keep FixedHeader floating clone styled like the in-table thead */
table.fixedHeader-floating.finance-screener-table thead tr:first-child th,
table.fixedHeader-locked.finance-screener-table thead tr:first-child th {
    background: #334155 !important;
    color: #f8fafc !important;
}

.theme-dark .finance-screener-table tbody td {
    border-color: rgba(255, 255, 255, 0.05) !important;
    color: #d5dbe8;
}

.finance-screener-table.table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-bg-type: #f8fafc;
}

.theme-dark .finance-screener-table.table-striped > tbody > tr:nth-of-type(odd) > * {
    --bs-table-bg-type: rgba(255, 255, 255, 0.025);
}

.finance-screener-table tbody tr {
    transition: background-color 0.12s ease;
}

.finance-screener-table tbody tr:hover > * {
    --bs-table-bg-state: #eef4fb;
}

.theme-dark .finance-screener-table tbody tr:hover > * {
    --bs-table-bg-state: rgba(148, 163, 184, 0.12);
}

.finance-screener-table .finance-select-col {
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    text-align: center !important;
    vertical-align: middle !important;
    padding-left: 0.35rem !important;
    padding-right: 0.35rem !important;
}

.finance-screener-table .finance-select-col .form-check-input {
    float: none;
    margin: 0;
    width: 1.1rem;
    height: 1.1rem;
    cursor: pointer;
}

.finance-screener-table.dataTable thead .finance-select-col,
.finance-screener-table.dataTable tbody .finance-select-col {
    display: table-cell !important;
    visibility: visible !important;
}

.finance-screener-table .cell-name {
    font-weight: 600;
    color: #1e293b;
}

.theme-dark .finance-screener-table .cell-name {
    color: #e8edf7;
}

.finance-screener-table .finance-num,
.finance-screener-table td.finance-num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
    text-align: center !important;
    white-space: nowrap;
    color: #334155;
    letter-spacing: 0.01em;
}

.theme-dark .finance-screener-table .finance-num {
    color: #d5dbe8;
}

.finance-screener-table .finance-num.is-empty,
.finance-screener-table .finance-muted {
    color: #94a3b8 !important;
}

.finance-sector-tag {
    display: inline-block;
    max-width: 11rem;
    padding: 0.22rem 0.6rem;
    border-radius: 0.4rem;
    background: #eef2f7;
    color: #475569;
    border: 1px solid #e2e8f0;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.theme-dark .finance-sector-tag {
    background: rgba(148, 163, 184, 0.12);
    color: #cbd5e1;
    border-color: rgba(148, 163, 184, 0.2);
}

/* Symbol links — quiet chip, not loud purple */
.finance-screener-table tbody td:nth-child(2) a {
    display: inline-block;
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.03em;
    padding: 0.22rem 0.55rem;
    border-radius: 0.4rem;
    background: #f1f5f9;
    color: #0f172a !important;
    border: 1px solid #dbe3ee;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.finance-screener-table tbody td:nth-child(2) a:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
    color: #0f172a !important;
    transform: none;
    box-shadow: none;
}

.theme-dark .finance-screener-table tbody td:nth-child(2) a {
    background: rgba(148, 163, 184, 0.12);
    color: #f1f5f9 !important;
    border-color: rgba(148, 163, 184, 0.22);
}

.theme-dark .finance-screener-table tbody td:nth-child(2) a:hover {
    background: rgba(148, 163, 184, 0.2);
}

.finance-screener-table th.fair-price-col {
    min-width: 9.5rem;
    vertical-align: middle;
}

.finance-screener-table th.fair-price-col .fair-price-col-title {
    white-space: nowrap;
}

.finance-screener-table th.fair-price-col .fair-price-header-info {
    cursor: help;
    font-size: 1.05rem;
    margin-inline-start: 0.15rem;
    vertical-align: -1px;
}

.finance-screener-table th.fair-price-col .fair-price-col-hint {
    font-size: 0.68rem;
    line-height: 1.25;
    margin-top: 0.15rem;
    white-space: normal;
}

.finance-screener-table .fair-price.badge {
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    padding: 0.35em 0.65em;
    background: #f8fafc !important;
    color: #0f172a !important;
    border: 1px solid #e2e8f0;
}

.popover.fair-price-header-popover {
    max-width: min(22rem, 92vw);
}

.popover.fair-price-header-popover .popover-body {
    font-size: 0.875rem;
    line-height: 1.55;
    text-align: start;
}

/* Company detail */
.finance-company-hero {
    border: 1px solid #e5e9ef;
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: 0 10px 28px rgba(47, 59, 74, 0.08);
}

.finance-company-hero .card-header {
    background: #334155;
    border: 0;
    padding: 1.25rem 1.5rem;
}

.finance-company-hero .card-header h2 {
    margin: 0;
    font-size: clamp(1.2rem, 1rem + 0.8vw, 1.6rem);
    font-weight: 700;
}

.finance-company-hero .card-body {
    padding: 1.35rem 1.5rem 1.5rem;
}

.finance-metric-card {
    border: 1px solid #e5e9ef;
    border-radius: 0.85rem;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(47, 59, 74, 0.05);
}

.finance-metric-card .card-header {
    background: #f8fafc;
    border-bottom: 1px solid #e5e9ef;
    font-size: 0.95rem;
    color: #334155;
    padding: 0.85rem 1rem;
}

.theme-dark .finance-metric-card {
    border-color: rgba(255, 255, 255, 0.08);
}

.theme-dark .finance-metric-card .card-header {
    background: #1e2433;
    color: #e2e8f0;
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

.finance-metric-card table th {
    font-weight: 550;
    color: #64748b;
    font-size: 0.84rem;
}

.finance-metric-card table td {
    font-variant-numeric: tabular-nums;
    text-align: end;
    font-weight: 600;
    color: #1e293b;
    font-size: 0.88rem;
}

.theme-dark .finance-metric-card table th {
    color: #94a3b8;
}

.theme-dark .finance-metric-card table td {
    color: #e2e8f0;
}

/* Compact finance filter + watchlist actions on one row */
.page-toolbar-finance .page-toolbar-body-finance {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.65rem 0.75rem;
}

.page-toolbar-finance .toolbar-field-symbol {
    flex: 0 1 220px;
    min-width: 180px;
    max-width: 240px;
}

.page-toolbar-finance .toolbar-field-symbol .bootstrap-select,
.page-toolbar-finance .toolbar-field-symbol .bootstrap-select > .dropdown-toggle {
    width: 220px !important;
    max-width: 100%;
}

.page-toolbar-finance .finance-toolbar-divider {
    width: 1px;
    align-self: stretch;
    min-height: 2.25rem;
    margin: 0 0.15rem;
    background: rgba(105, 108, 255, 0.18);
}

.page-toolbar-finance .finance-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.45rem 0.55rem;
    margin-inline-start: auto;
}

.page-toolbar-finance .finance-toolbar-actions .toolbar-field-inline {
    margin-bottom: 0;
}

.page-toolbar-finance .finance-selection-badge {
    font-size: 0.8rem;
    align-self: center;
    white-space: nowrap;
}

@media (max-width: 991.98px) {
    .page-toolbar-finance .finance-toolbar-actions {
        margin-inline-start: 0;
        width: 100%;
    }

    .page-toolbar-finance .finance-toolbar-divider {
        display: none;
    }
}

@media (max-width: 767.98px) {
    .finance-screener-panel {
        padding: 0.45rem;
        border-radius: 0.65rem;
    }

    .finance-page-header {
        padding-inline: 0.15rem;
    }

    .finance-screener-table thead tr:first-child th,
    .finance-screener-table tbody td {
        font-size: 0.76rem;
        padding: 0.5rem 0.4rem !important;
    }

    .page-toolbar-finance .toolbar-field-symbol {
        flex: 1 1 100%;
        max-width: 100%;
    }
}
