/* PriceToWorth screener results v4
   Relevant-columns + richer-context layout with centered comparison data,
   sticky Rank/Company identity columns, a sticky horizontal navigation bar,
   a vertically sticky synchronized header row, visible overflow cues,
   keyboard-focus support, and the existing mobile card transformation. */

.stock-screeners-hero h1 small {
    font-size: .58em;
    font-weight: 700;
    color: #667085;
    white-space: nowrap;
}

.ptw-screener-overview {
    margin: 16px 0 14px;
    border: 1px solid #e4e9f0;
    border-radius: 14px;
    background: #fff;
    overflow: hidden;
}

.ptw-screener-overview__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e8edf3;
}

.ptw-screener-overview__summary > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.ptw-screener-overview__summary strong {
    color: #172033;
    font-size: .96rem;
    line-height: 1.45;
}

.ptw-screener-overview__summary span {
    color: #667085;
    font-size: .82rem;
}

.ptw-screener-overview__freshness {
    text-align: right;
    flex: 0 0 auto;
}

.ptw-screener-methodology {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0;
}

.ptw-screener-methodology > div {
    min-width: 0;
    padding: 14px 16px;
    border-right: 1px solid #edf0f4;
}

.ptw-screener-methodology > div:last-child {
    border-right: 0;
}

.ptw-screener-methodology span {
    display: block;
    margin-bottom: 5px;
    color: #667085;
    font-size: .76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.ptw-screener-methodology strong {
    display: block;
    color: #344054;
    font-size: .88rem;
    font-weight: 700;
    line-height: 1.55;
}

.ptw-screener-filter-note {
    margin: 0;
    padding: 10px 16px 12px;
    border-top: 1px solid #edf0f4;
    color: #667085;
    background: #fffdf5;
    font-size: .82rem;
    line-height: 1.55;
}

.ptw-screener-speculative-note {
    margin: 0;
    padding: 11px 16px;
    border-top: 1px solid #f1dfad;
    color: #6d5210;
    background: #fffbeb;
    font-size: .82rem;
    line-height: 1.55;
}

/* ===== Result table shell ===== */

.ptw-screener-results {
    --ptw-rank-column: 56px;
    --ptw-company-column: 230px;
    --ptw-sticky-top: 8px;
    --ptw-scroll-tools-stack: 0px;
    margin-top: 14px;
    background: transparent;
}

.ptw-screener-scroll-tools[hidden] {
    display: none !important;
}

.ptw-screener-scroll-tools {
    position: sticky;
    top: var(--ptw-sticky-top);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    padding: 8px 10px;
    border: 1px solid #dbe3ec;
    border-radius: 10px;
    background: rgba(248, 250, 252, .96);
    box-shadow: 0 8px 18px rgba(16, 24, 40, .07);
    backdrop-filter: blur(8px);
}

.ptw-screener-scroll-tools__hint {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    margin: 0;
    color: #475467;
    font-size: .78rem;
    font-weight: 700;
    line-height: 1.35;
}

.ptw-screener-scroll-tools__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
    border: 1px solid #d9e2ec;
    border-radius: 999px;
    background: #fff;
    color: #175cd3;
    font-size: .9rem;
    line-height: 1;
}

.ptw-screener-scroll-tools__touch {
    display: none;
}

.ptw-screener-scroll-tools__buttons {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.ptw-screener-scroll-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid #d0d9e5;
    border-radius: 8px;
    background: #fff;
    color: #1d4f91;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease, color .15s ease, transform .15s ease;
}

.ptw-screener-scroll-button:hover:not(:disabled) {
    border-color: #9fb7d3;
    background: #f1f6fb;
    color: #123d70;
    transform: translateY(-1px);
}

.ptw-screener-scroll-button:focus-visible {
    outline: 3px solid rgba(23, 92, 211, .2);
    outline-offset: 2px;
}

.ptw-screener-scroll-button:disabled {
    opacity: .38;
    cursor: default;
    transform: none;
}

.ptw-screener-sticky-head {
    position: sticky;
    top: calc(var(--ptw-sticky-top) + var(--ptw-scroll-tools-stack));
    z-index: 46;
    background: #f7f9fc;
}

.ptw-screener-head-viewport {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid #dce3eb;
    border-bottom-color: #d7dee7;
    border-radius: 14px 14px 0 0;
    background: #f7f9fc;
    box-shadow: 0 6px 12px rgba(16, 24, 40, .04);
}

.ptw-screener-scroll-frame {
    position: relative;
    border: 1px solid #e4e9f0;
    border-top: 0;
    border-radius: 0 0 14px 14px;
    background: #fff;
    overflow: hidden;
}

/* A right-edge fade is only shown while more columns exist off-screen. */
.ptw-screener-scroll-frame::after {
    content: "";
    position: absolute;
    z-index: 12;
    top: 0;
    right: 0;
    bottom: 10px;
    width: 34px;
    pointer-events: none;
    opacity: 0;
    background: linear-gradient(to left, rgba(22, 34, 51, .13), rgba(22, 34, 51, 0));
    transition: opacity .16s ease;
}

.ptw-screener-results.can-scroll-right .ptw-screener-scroll-frame::after {
    opacity: 1;
}

.ptw-screener-scroll-viewport {
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    scrollbar-color: #98a2b3 #eef2f6;
}

.ptw-screener-scroll-viewport:focus-visible {
    outline: 3px solid rgba(23, 92, 211, .18);
    outline-offset: -3px;
}

.ptw-screener-scroll-viewport::-webkit-scrollbar {
    height: 10px;
}

.ptw-screener-scroll-viewport::-webkit-scrollbar-track {
    background: #eef2f6;
    border-radius: 999px;
}

.ptw-screener-scroll-viewport::-webkit-scrollbar-thumb {
    background: #98a2b3;
    border: 2px solid #eef2f6;
    border-radius: 999px;
}

.ptw-screener-scroll-viewport::-webkit-scrollbar-thumb:hover {
    background: #7f8b9a;
}

/* ===== Desktop/tablet grid ===== */

.ptw-screener-results__head,
.ptw-screener-result {
    display: grid;
    grid-template-columns:
        var(--ptw-rank-column)
        minmax(var(--ptw-company-column), 1.8fr)
        minmax(78px, .62fr)
        minmax(82px, .64fr)
        repeat(var(--ptw-result-metric-columns, 4), minmax(104px, 1fr));
    align-items: stretch;
    min-width: var(--ptw-table-min-width, 880px);
}

.ptw-screener-results__head {
    background: #f7f9fc;
    border-bottom: 0;
}

.ptw-screener-results__head > span {
    display: flex;
    align-items: center;
    min-width: 0;
    padding: 10px 8px;
    color: #475467;
    font-size: .73rem;
    font-weight: 800;
    line-height: 1.3;
    border-right: 1px solid #edf0f4;
}

.ptw-screener-results__head > span:last-child {
    border-right: 0;
}

.ptw-screener-results__head-rank,
.ptw-screener-results__head-data {
    justify-content: center;
    text-align: center;
}

.ptw-screener-results__head-company {
    justify-content: flex-start;
    text-align: left;
}

.ptw-company-search__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 4px 6px;
    border: 0;
    border-radius: 7px;
    color: #344054;
    background: transparent;
    font: inherit;
    cursor: text;
}

.ptw-company-search__toggle:hover,
.ptw-company-search__toggle:focus-visible {
    color: #0d5f91;
    background: #eaf4fb;
}

.ptw-company-search__toggle:focus-visible,
.ptw-company-search__field input:focus-visible,
.ptw-company-search-mobile input:focus-visible {
    outline: 2px solid rgba(13, 95, 145, .28);
    outline-offset: 1px;
}

.ptw-company-search__field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 26px;
    align-items: center;
    width: 100%;
    border: 1px solid #9fbdd0;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.ptw-company-search__field[hidden] { display: none !important; }
.ptw-company-search__field input,
.ptw-company-search-mobile input {
    min-width: 0;
    width: 100%;
    border: 0;
    color: #182230;
    background: transparent;
    font-size: .76rem;
}
.ptw-company-search__field input { padding: 7px 6px; }
.ptw-company-search__field button,
.ptw-company-search-mobile button {
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    color: #667085;
    background: transparent;
    font-size: 1.1rem;
    cursor: pointer;
}
.ptw-company-search__field button:hover,
.ptw-company-search-mobile button:hover { color: #b42318; background: #fef3f2; }
.ptw-company-search-mobile { display: none; }
.ptw-company-search__status {
    margin: 0;
    padding: 7px 12px;
    border-bottom: 1px solid #e8edf3;
    color: #0d5f91;
    background: #f5faff;
    font-size: .78rem;
    font-weight: 700;
}
.ptw-company-search__status[hidden] { display: none; }
.ptw-screener-result[hidden] { display: none !important; }
.ptw-speculative-badge {
    display: inline-flex;
    margin-top: 6px;
    padding: 2px 7px;
    border: 1px solid #ead9ad;
    border-radius: 999px;
    color: #795a0a;
    background: #fffbeb;
    font-size: .65rem;
    font-weight: 800;
    letter-spacing: .02em;
}
.ptw-screener-result.is-speculative { background: #fffdf7; }

.ptw-screener-result {
    border-bottom: 1px solid #edf0f4;
    background: #fff;
}

.ptw-screener-result:last-child {
    border-bottom: 0;
}

.ptw-screener-result > div {
    min-width: 0;
    padding: 11px 8px;
    border-right: 1px solid #f0f2f5;
}

.ptw-screener-result > div:last-child {
    border-right: 0;
}

.ptw-screener-result__rank,
.ptw-screener-result__base,
.ptw-screener-result__metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.ptw-screener-result__rank {
    color: #667085;
    font-size: .8rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.ptw-screener-result__company {
    text-align: left;
}

.ptw-screener-result__company h2 {
    margin: 0 0 4px;
    font-size: .88rem;
    font-weight: 800;
    line-height: 1.38;
}

.ptw-screener-result__company h2 a {
    color: #182230;
    text-decoration: none;
}

.ptw-screener-result__company h2 a:hover {
    text-decoration: underline;
}

.ptw-screener-result__company p {
    margin: 0;
    color: #667085;
    font-size: .73rem;
    line-height: 1.38;
}

.ptw-screener-result__company .ptw-rank-rationale {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed #e4e9f0;
}

.ptw-rank-rationale__trigger {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 20px;
    align-items: start;
    gap: 6px;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #526174;
    font: inherit;
    font-size: .68rem;
    line-height: 1.42;
    text-align: left;
    cursor: help;
}

.ptw-rank-rationale__summary {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
}

.ptw-rank-rationale__trigger strong {
    color: #067f73;
    font-weight: 800;
}

.ptw-rank-rationale__icon {
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    margin-top: 1px;
    border: 1px solid #84cbc2;
    border-radius: 999px;
    background: #effcf9;
    color: #067f73;
    font-size: .66rem;
    font-weight: 900;
    line-height: 1;
    transition: color .15s ease, background-color .15s ease, border-color .15s ease, transform .15s ease;
}

.ptw-rank-rationale__trigger:hover .ptw-rank-rationale__icon,
.ptw-rank-rationale__trigger[aria-expanded="true"] .ptw-rank-rationale__icon {
    border-color: #067f73;
    background: #067f73;
    color: #fff;
    transform: translateY(-1px);
}

.ptw-rank-rationale__trigger:focus-visible {
    outline: 2px solid rgba(6, 127, 115, .32);
    outline-offset: 3px;
    border-radius: 4px;
}

.ptw-rank-popover {
    position: fixed;
    z-index: 10050;
    width: min(390px, calc(100vw - 24px));
    padding: 14px 15px 15px;
    border: 1px solid #9bd9d1;
    border-radius: 12px;
    background: #fff;
    color: #344054;
    box-shadow: 0 18px 48px rgba(15, 35, 56, .22), 0 3px 10px rgba(15, 35, 56, .1);
    font-size: .78rem;
    line-height: 1.55;
}

.ptw-rank-popover[hidden] {
    display: none;
}

.ptw-rank-popover__eyebrow {
    display: block;
    margin-bottom: 6px;
    color: #067f73;
    font-size: .67rem;
    font-weight: 900;
    letter-spacing: .055em;
    text-transform: uppercase;
}

.ptw-rank-popover p {
    margin: 0;
}

.ptw-rank-popover::before {
    content: "";
    position: absolute;
    left: var(--ptw-rank-arrow-left, 28px);
    width: 10px;
    height: 10px;
    border: solid #9bd9d1;
    background: #fff;
    transform: rotate(45deg);
}

.ptw-rank-popover[data-placement="bottom"]::before {
    top: -6px;
    border-width: 1px 0 0 1px;
}

.ptw-rank-popover[data-placement="top"]::before {
    bottom: -6px;
    border-width: 0 1px 1px 0;
}

.ptw-screener-result__base {
    color: #344054;
    font-size: .8rem;
    font-weight: 700;
    overflow-wrap: anywhere;
    font-variant-numeric: tabular-nums;
}

.ptw-screener-result__metric {
    gap: 4px;
    font-variant-numeric: tabular-nums;
}

.ptw-screener-result__metric .screener-value {
    max-width: 100%;
    white-space: normal;
    text-align: center;
    align-self: center;
}

.ptw-screener-result__metric small {
    display: block;
    width: 100%;
    color: #667085;
    font-size: .69rem;
    line-height: 1.3;
    text-align: center;
}

.ptw-screener-empty {
    padding: 24px 18px;
    color: #667085;
    text-align: center;
    font-size: .92rem;
}

/* Keep rank and company visible while comparison columns move horizontally. */
@media (min-width: 768px) {
    .ptw-screener-results__head-rank,
    .ptw-screener-result__rank {
        position: sticky;
        left: 0;
    }

    .ptw-screener-results__head-company,
    .ptw-screener-result__company {
        position: sticky;
        left: var(--ptw-rank-column);
    }

    .ptw-screener-results__head-rank {
        z-index: 10;
        background: #f7f9fc;
    }

    .ptw-screener-results__head-company {
        z-index: 9;
        background: #f7f9fc;
    }

    .ptw-screener-result__rank {
        z-index: 8;
        background: #fff;
    }

    .ptw-screener-result__company {
        z-index: 7;
        background: #fff;
    }

    .ptw-screener-results.is-scrollable:not(.is-at-start) .ptw-screener-results__head-company,
    .ptw-screener-results.is-scrollable:not(.is-at-start) .ptw-screener-result__company {
        box-shadow: 10px 0 14px -13px rgba(16, 24, 40, .55);
    }
}

/* ===== Mobile card transformation ===== */

@media (max-width: 767.98px) {
    .stock-screeners-hero h1 small {
        display: block;
        margin-top: 4px;
        white-space: normal;
    }

    .ptw-screener-overview__summary {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .ptw-screener-overview__freshness {
        text-align: left;
    }

    .ptw-screener-methodology {
        grid-template-columns: 1fr;
    }

    .ptw-screener-methodology > div {
        border-right: 0;
        border-bottom: 1px solid #edf0f4;
    }

    .ptw-screener-methodology > div:last-child {
        border-bottom: 0;
    }

    .ptw-screener-scroll-tools {
        display: none !important;
    }

    .ptw-screener-sticky-head {
        display: none;
    }

    .ptw-screener-scroll-frame {
        border: 0;
        border-radius: 0;
        background: transparent;
        overflow: visible;
    }

    .ptw-company-search-mobile {
        display: block;
        margin-bottom: 10px;
        padding: 10px;
        border: 1px solid #dce5ee;
        border-radius: 12px;
        background: #f8fafc;
    }
    .ptw-company-search-mobile label > span:first-child {
        display: block;
        margin-bottom: 5px;
        color: #475467;
        font-size: .74rem;
        font-weight: 800;
    }
    .ptw-company-search-mobile__control {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 30px;
        align-items: center;
        border: 1px solid #b9cad8;
        border-radius: 9px;
        background: #fff;
    }
    .ptw-company-search-mobile input { padding: 9px 10px; font-size: .84rem; }

    .ptw-screener-scroll-frame::after {
        display: none;
    }

    .ptw-screener-scroll-viewport {
        overflow: visible;
        outline: 0;
    }

    .ptw-screener-results__head {
        display: none;
    }

    .ptw-screener-results__body {
        display: grid;
        gap: 12px;
    }

    .ptw-screener-result {
        min-width: 0;
        display: grid;
        grid-template-columns: 68px minmax(0, 1fr);
        border: 1px solid #e4e9f0;
        border-radius: 14px;
        background: #fff;
        overflow: hidden;
    }

    .ptw-screener-result > div {
        padding: 10px 12px;
        border-right: 0;
        border-bottom: 1px solid #f0f2f5;
    }

    .ptw-screener-result__rank {
        position: static;
        grid-column: 1;
        grid-row: 1;
        align-items: center;
        justify-content: center;
        text-align: center;
        background: #f8fafc;
        border-right: 1px solid #edf0f4 !important;
    }

    .ptw-screener-result__company {
        position: static;
        grid-column: 2;
        grid-row: 1;
        text-align: left;
        background: #fff;
        box-shadow: none !important;
    }

    .ptw-screener-result__company .ptw-rank-rationale {
        margin-top: 5px;
        padding-top: 5px;
    }

    .ptw-rank-rationale__summary {
        -webkit-line-clamp: 3;
    }

    .ptw-rank-popover {
        width: min(360px, calc(100vw - 20px));
    }

    .ptw-screener-result__base,
    .ptw-screener-result__metric {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: minmax(110px, .8fr) minmax(0, 1.2fr);
        align-items: center;
        gap: 10px;
        text-align: left;
    }

    .ptw-screener-result__base::before,
    .ptw-screener-result__metric::before {
        content: attr(data-label);
        color: #667085;
        font-size: .76rem;
        font-weight: 700;
    }

    .ptw-screener-result__metric .screener-value,
    .ptw-screener-result__metric small {
        grid-column: 2;
        justify-self: start;
        text-align: left;
    }

    .ptw-screener-result__metric small {
        margin-top: -6px;
    }

    .ptw-screener-result > div:last-child {
        border-bottom: 0;
    }
}

@media (hover: none), (pointer: coarse) {
    .ptw-screener-scroll-tools__desktop {
        display: none;
    }

    .ptw-screener-scroll-tools__touch {
        display: inline;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ptw-screener-scroll-button,
    .ptw-screener-scroll-frame::after {
        transition: none;
    }
}
