.top-movers__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    /* Reserve room on the right for the corner-pinned info trigger. */
    padding-right: var(--space-6);
}

.top-movers__header-controls {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

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

.top-movers__toolbar-fields {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.top-movers__filter-field {
    display: inline-flex;
    align-items: center;
}

.top-movers__filter-input {
    height: var(--control-height-sm);
    min-width: 240px;
    padding: 0 var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text-base);
    font: inherit;
    font-size: var(--font-size-control);
}

.top-movers__filter-input::placeholder {
    color: var(--color-text-subtle);
}

.top-movers__filter-input:focus-visible {
    outline: var(--focus-ring-width) solid var(--color-accent);
    outline-offset: var(--focus-ring-offset);
    border-color: transparent;
}

/* Fixed width so short labels don't shrink the trigger; floor fits the
   longest option ("Exchanged") plus the chevron. */
.top-movers__direction-dropdown .dropdown__trigger {
    min-width: 8rem;
}

.top-movers__clear-slot {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
}

.top-movers__clear-slot:empty {
    display: none;
}

.top-movers__clear {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    height: var(--control-height-sm);
    padding: 0 var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-pill);
    background: var(--color-bg);
    color: var(--color-text-muted);
    font: inherit;
    font-size: var(--font-size-control);
    cursor: pointer;
}

.top-movers__clear:hover,
.top-movers__clear:focus-visible {
    color: var(--color-text-strong);
    border-color: var(--color-border-strong);
}

.top-movers__clear:focus-visible {
    outline: var(--focus-ring-width) solid var(--color-accent);
    outline-offset: var(--focus-ring-offset);
}

.top-movers__clear-glyph {
    font-size: 0.85em;
    line-height: 1;
}

.top-movers__table {
    overflow-x: auto;
}

/* table-layout: fixed pins each column so toggling Compact/Detailed
   (which adds the operator name) never reflows the grid. */
.top-movers__grid {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
    table-layout: fixed;
}

.top-movers__grid th,
.top-movers__grid td {
    text-align: left;
    padding: var(--space-3) var(--space-3);
    border-bottom: 1px solid var(--color-divider);
    font-size: var(--font-size-sm);
    vertical-align: middle;
}

.top-movers__grid th {
    font-weight: var(--font-weight-medium);
    color: var(--color-text-uppercase);
    text-transform: uppercase;
    letter-spacing: var(--letter-uppercase-tight);
    font-size: var(--font-size-xs);
    white-space: nowrap;
}

.top-movers__grid td.top-movers__empty {
    padding: var(--space-5) var(--space-3);
    text-align: center;
    border-bottom: 0;
}

.top-movers__sort-button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 0;
    background: none;
    border: 0;
    color: inherit;
    font: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    cursor: pointer;
}

.top-movers__sort-button:hover {
    color: var(--color-text-strong);
}

.top-movers__sort-button:focus-visible {
    outline: var(--focus-ring-width) solid var(--color-accent);
    outline-offset: var(--focus-ring-offset);
    border-radius: 2px;
}

.top-movers__sort-label--short {
    display: none;
}

.top-movers__sort-chevron {
    color: inherit;
    flex-shrink: 0;
    /* block strips the inline-baseline offset SVGs inherit. */
    display: block;
}

.top-movers__grid th.top-movers__rank {
    width: 4%;
}

.top-movers__grid th.top-movers__asn {
    width: 34%;
}

.top-movers__grid th.top-movers__num {
    width: 16%;
}

.top-movers__grid th.top-movers__direction {
    width: 46%;
}

.top-movers__grid th.top-movers__rank,
.top-movers__grid td.top-movers__rank,
.top-movers__grid th.top-movers__num,
.top-movers__grid td.top-movers__num {
    text-align: right;
}

.top-movers__grid th.top-movers__num,
.top-movers__grid td.top-movers__num {
    padding-right: var(--space-5);
}

.top-movers__rank {
    color: var(--color-text-subtle);
    font-variant-numeric: tabular-nums;
}

.top-movers__num {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.asn-cell {
    display: inline-flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    line-height: var(--line-snug);
}

.asn-cell__num {
    color: var(--color-text-strong);
    font-weight: var(--font-weight-medium);
    font-variant-numeric: tabular-nums;
}

.asn-cell__name {
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    overflow-wrap: anywhere;
}

.top-movers__grid--no-names .asn-cell__name {
    display: none;
}

/* Flex on the inner span, not the <td>: flex on a cell makes browsers
   ignore the fixed-layout width and collapse the column to content. */
.top-movers__direction-inner {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.top-movers__arrow {
    color: var(--color-text-subtle);
    font-size: var(--font-size-base);
    line-height: 1;
    flex-shrink: 0;
    cursor: help;
}

.top-movers__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-top: var(--space-3);
}

.top-movers__page-size {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.top-movers__pagination {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    margin-left: auto;
}

.top-movers__page {
    height: var(--control-height-sm);
    min-width: var(--control-height-sm);
    padding: 0 var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text-base);
    font: inherit;
    font-size: var(--font-size-control);
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}

.top-movers__page:hover {
    border-color: var(--color-border-strong);
}

.top-movers__page:focus-visible {
    outline: var(--focus-ring-width) solid var(--color-accent);
    outline-offset: var(--focus-ring-offset);
}

.top-movers__page.is-active {
    background: var(--color-accent);
    color: var(--color-on-fill);
    border-color: var(--color-accent);
}

.top-movers__page-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--control-height-sm);
    color: var(--color-text-subtle);
    user-select: none;
}

/* Coarse-pointer hit-area growth without nudging layout. */
@media (pointer: coarse) {
    .top-movers__sort-button,
    .top-movers__page {
        position: relative;
    }

    .top-movers__sort-button::before,
    .top-movers__page::before {
        content: "";
        position: absolute;
        inset: -8px;
    }
}

@media (max-width: 720px) {
    .top-movers__header {
        align-items: flex-start;
    }
    .top-movers__header-controls {
        width: 100%;
        justify-content: space-between;
        gap: var(--space-2);
    }
    .top-movers__toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .top-movers__toolbar-fields {
        width: 100%;
    }
    .top-movers__filter-field {
        flex: 1;
    }
    .top-movers__filter-input {
        min-width: 0;
        width: 100%;
        /* 16px floor stops iOS Safari auto-zooming on focus. */
        font-size: var(--font-size-base);
    }
    .top-movers__clear-slot {
        margin-left: 0;
        align-self: flex-end;
    }
    .top-movers__footer {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-2);
    }
    .top-movers__page-size {
        justify-content: space-between;
    }
    .top-movers__pagination {
        margin-left: 0;
        justify-content: center;
        flex-wrap: wrap;
    }
    .top-movers__grid th,
    .top-movers__grid td {
        padding: var(--space-2);
    }
}

/* Below 640px the grid reflows into one card per row; the header
   collapses into a compact sort bar so sorting survives on touch. */
@media (max-width: 640px) {
    .top-movers__table {
        overflow-x: visible;
    }

    .top-movers__grid {
        display: block;
        min-width: 0;
    }

    .top-movers__grid thead,
    .top-movers__grid tbody {
        display: block;
    }

    .top-movers__grid thead tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: var(--space-2) var(--space-4);
        padding: 0 0 var(--space-2);
        border-bottom: 1px solid var(--color-border);
    }

    .top-movers__grid thead th {
        padding: 0;
        border: 0;
        white-space: nowrap;
    }

    /* Name the columns to out-specify the per-column width rules above,
       so each sort chip shrinks to its label. */
    .top-movers__grid thead th.top-movers__rank,
    .top-movers__grid thead th.top-movers__asn,
    .top-movers__grid thead th.top-movers__num,
    .top-movers__grid thead th.top-movers__direction {
        width: auto;
    }

    .top-movers__grid thead th.top-movers__rank {
        display: none;
    }

    .top-movers__grid thead th.top-movers__num {
        padding-right: 0;
    }

    .top-movers__sort-label--full {
        display: none;
    }

    .top-movers__sort-label--short {
        display: inline;
    }

    .top-movers__grid thead .top-movers__sort-button.is-active {
        color: var(--color-accent);
    }

    .top-movers__grid tbody tr {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "as share"
            "direction direction";
        column-gap: var(--space-3);
        row-gap: var(--space-2);
        padding: var(--space-3) 0;
        border-bottom: 1px solid var(--color-divider);
    }

    .top-movers__grid tbody td {
        display: block;
        width: auto;
        padding: 0;
        border: 0;
    }

    .top-movers__grid tbody td.top-movers__rank {
        display: none;
    }

    .top-movers__grid tbody td.top-movers__asn {
        grid-area: as;
    }

    .top-movers__grid tbody td.top-movers__num {
        grid-area: share;
        text-align: right;
        font-weight: var(--font-weight-semibold);
        color: var(--color-text-strong);
    }

    .top-movers__grid tbody td.top-movers__direction {
        grid-area: direction;
        font-size: var(--font-size-xs);
        color: var(--color-text-muted);
    }

    .top-movers__grid tbody td.top-movers__direction--inactive {
        color: var(--color-text-subtle);
    }
}
