/* Leaderboard and referral pages. */

.px-page {
    width: min(var(--pm-shell-width), calc(100% - (var(--pm-shell-gutter) * 2)));
    margin: 0 auto;
    padding: 28px 0 72px;
}

.px-kicker {
    margin: 0;
    color: var(--pm-green);
    font-size: 12px;
    font-weight: var(--pm-weight-semibold);
    letter-spacing: .1em;
    text-transform: uppercase;
}

.px-control {
    border: 1px solid var(--pm-line);
    border-radius: var(--pm-radius-sm);
    background: var(--pm-control-bg);
    color: var(--pm-text);
}

.px-search {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 9px;
    color: var(--pm-text-muted);
}

.px-search svg {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
}

.px-search input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--pm-text);
    font-size: 13px;
}

.px-search input::placeholder {
    color: var(--pm-text-muted);
}

/* Leaderboard */

.lb-top {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}

.lb-top h1,
.rf-title-line h1 {
    margin: 5px 0 0;
    color: var(--pm-text);
    font-size: 30px;
    font-weight: var(--pm-weight-semibold);
    line-height: 1.1;
}

.lb-category {
    position: relative;
}

.lb-category__button {
    display: inline-flex;
    height: 42px;
    min-width: 168px;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 0 13px;
    cursor: pointer;
    font-size: 12px;
    font-weight: var(--pm-weight-semibold);
    transition: border-color var(--pm-duration-fast) ease,
                background-color var(--pm-duration-fast) ease;
}

.lb-category__button:hover,
.lb-category.is-open .lb-category__button {
    border-color: var(--pm-green-border);
    background: var(--pm-surface-raised);
}

.lb-category__button svg {
    width: 17px;
    height: 17px;
    fill: currentColor;
    transition: transform var(--pm-duration-normal) var(--pm-ease-emphasized);
}

.lb-category.is-open .lb-category__button svg {
    transform: rotate(180deg);
}

.lb-category__menu {
    position: absolute;
    z-index: 30;
    top: calc(100% + 7px);
    right: 0;
    display: grid;
    width: 190px;
    gap: 2px;
    padding: 6px;
    border: 1px solid var(--pm-line);
    border-radius: var(--pm-radius-md);
    background: var(--pm-popover-bg);
    box-shadow: var(--pm-shadow-popover);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-5px) scale(.98);
    transform-origin: top right;
    transition: opacity var(--pm-duration-normal) ease,
                transform var(--pm-duration-normal) var(--pm-ease-emphasized);
}

.lb-category.is-open .lb-category__menu {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.lb-category__menu button {
    height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--pm-text-secondary);
    cursor: pointer;
    font-size: 12px;
    text-align: left;
}

.lb-category__menu button:hover {
    background: var(--pm-surface-hover);
    color: var(--pm-text);
}

.lb-category__menu button.is-active {
    background: var(--pm-green-soft);
    color: var(--pm-green);
}

.lb-tabs {
    display: inline-flex;
    gap: 2px;
    margin-top: 24px;
    padding: 3px;
    border-radius: var(--pm-radius-sm);
    background: var(--pm-control-bg);
}

.lb-tabs button {
    min-width: 86px;
    height: 34px;
    padding: 0 13px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--pm-text-secondary);
    cursor: pointer;
    font-size: 12px;
    font-weight: var(--pm-weight-medium);
    transition: background-color var(--pm-duration-fast) ease,
                color var(--pm-duration-fast) ease;
}

.lb-tabs button:hover {
    color: var(--pm-text);
}

.lb-tabs button.is-active {
    background: var(--pm-green-soft);
    color: var(--pm-green);
}

.lb-board {
    margin-top: 16px;
    overflow: hidden;
    border-top: 1px solid var(--pm-line);
    border-bottom: 1px solid var(--pm-line);
}

.lb-toolbar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    gap: 20px;
    align-items: center;
    padding: 12px 10px;
    border-bottom: 1px solid var(--pm-line-soft);
}

.lb-toolbar .px-search {
    height: 38px;
    padding: 0 11px;
    border: 1px solid var(--pm-line);
    border-radius: var(--pm-radius-sm);
    background: var(--pm-control-bg);
    transition: border-color var(--pm-duration-fast) ease,
                background-color var(--pm-duration-fast) ease;
}

.lb-toolbar .px-search:focus-within {
    border-color: var(--pm-green-border);
    background: var(--pm-surface-raised);
}

.lb-sort {
    display: flex;
    align-items: center;
    gap: 4px;
}

.lb-sort > span {
    width: 1px;
    height: 20px;
    background: var(--pm-line);
}

.lb-sort button {
    position: relative;
    height: 36px;
    padding: 0 14px;
    border: 0;
    background: transparent;
    color: var(--pm-text-secondary);
    cursor: pointer;
    font-size: 12px;
    font-weight: var(--pm-weight-medium);
}

.lb-sort button::after {
    position: absolute;
    right: 14px;
    bottom: 0;
    left: 14px;
    height: 2px;
    border-radius: 2px;
    background: var(--pm-green);
    content: "";
    opacity: 0;
    transform: scaleX(.45);
    transition: opacity var(--pm-duration-normal) ease,
                transform var(--pm-duration-normal) var(--pm-ease-emphasized);
}

.lb-sort button:hover,
.lb-sort button.is-active {
    color: var(--pm-text);
}

.lb-sort button.is-active::after {
    opacity: 1;
    transform: scaleX(1);
}

.lb-table__head,
.lb-row {
    display: grid;
    grid-template-columns: 44px minmax(260px, 1fr) 190px 190px;
    gap: 14px;
    align-items: center;
}

.lb-table__head {
    min-height: 38px;
    padding: 0 12px;
    color: var(--pm-text-muted);
    font-size: 12px;
    font-weight: var(--pm-weight-semibold);
    letter-spacing: .05em;
    text-transform: uppercase;
}

.lb-table__head span:nth-child(n + 3) {
    text-align: right;
}

.lb-row {
    min-height: 72px;
    padding: 9px 12px;
    border-top: 1px solid var(--pm-line-soft);
    color: inherit;
    text-decoration: none;
    transition: background-color var(--pm-duration-fast) ease;
}

.lb-row:hover {
    background: var(--pm-surface-hover);
}

.lb-row__rank {
    color: var(--pm-text-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.lb-row__user {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 11px;
}

.lb-row__avatar,
.lb-row__fallback {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    overflow: hidden;
    border-radius: 50%;
    background: var(--pm-surface-subtle);
}

.lb-row__avatar {
    object-fit: cover;
}

.lb-row__fallback {
    display: grid;
    place-items: center;
    color: var(--pm-green);
    font-size: 14px;
    font-weight: var(--pm-weight-semibold);
}

.lb-row__user-main {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
}

.lb-row__name {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 6px;
}

.lb-row__name > span:first-child {
    overflow: hidden;
    color: var(--pm-text);
    font-size: 13px;
    font-weight: var(--pm-weight-semibold);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-row__badge {
    display: grid;
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    place-items: center;
    border-radius: 50%;
    background: var(--pm-green);
    color: var(--pm-text-on-brand);
    font-size: 12px;
    font-weight: var(--pm-weight-bold);
}

.lb-row__wallet {
    overflow: hidden;
    color: var(--pm-text-muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-row__metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: var(--pm-text);
    font-size: 13px;
    font-weight: var(--pm-weight-semibold);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.lb-row__metric small {
    color: var(--pm-text-muted);
    font-size: 12px;
    font-weight: var(--pm-weight-regular);
}

.lb-row__metric.is-positive {
    color: var(--pm-green);
}

.lb-row__metric.is-negative {
    color: var(--pm-red);
}

.lb-rows.is-loading {
    padding: 2px 12px 12px;
}

.lb-skeleton {
    height: 62px;
    margin-top: 8px;
    border-radius: var(--pm-radius-sm);
    background: linear-gradient(100deg, var(--pm-surface-subtle) 25%, var(--pm-surface-hover) 43%, var(--pm-surface-subtle) 62%);
    background-size: 220% 100%;
    animation: lbShimmer 1.35s linear infinite;
}

@keyframes lbShimmer {
    to { background-position-x: -220%; }
}

.lb-empty {
    display: grid;
    min-height: 300px;
    place-items: center;
    padding: 32px;
    color: var(--pm-text-muted);
    font-size: 13px;
    text-align: center;
}

/* Referrals */

.rf-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
    gap: 32px;
    align-items: center;
    padding: 8px 0 26px;
    border-bottom: 1px solid var(--pm-line-soft);
}

.rf-title-line {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rf-title-line h1 {
    margin: 0;
}

.rf-boost {
    display: inline-flex;
    height: 23px;
    align-items: center;
    padding: 0 8px;
    border-radius: var(--pm-radius-pill);
    background: var(--pm-green-soft);
    color: var(--pm-green);
    font-size: 12px;
    font-weight: var(--pm-weight-semibold);
    letter-spacing: .06em;
    text-transform: uppercase;
}

.rf-hero__copy > p {
    max-width: 590px;
    margin: 10px 0 0;
    color: var(--pm-text-secondary);
    font-size: 13px;
}

.rf-hero__copy > p strong {
    color: var(--pm-text);
    font-weight: var(--pm-weight-semibold);
}

.rf-user {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: 18px;
    color: var(--pm-text);
    font-size: 12px;
    font-weight: var(--pm-weight-medium);
}

.rf-avatar {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 50%;
    background: var(--pm-green-soft);
    color: var(--pm-green);
    font-size: 12px;
    font-weight: var(--pm-weight-semibold);
}

.rf-link-card {
    padding: 14px;
    border: 1px solid var(--pm-line);
    border-radius: var(--pm-radius-md);
    background: var(--pm-surface);
}

.rf-link-card > label {
    display: block;
    margin-bottom: 8px;
    color: var(--pm-text-muted);
    font-size: 12px;
    font-weight: var(--pm-weight-medium);
}

.rf-link-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px;
}

.rf-link-field input {
    width: 100%;
    min-width: 0;
    height: 40px;
    padding: 0 11px;
    border: 1px solid var(--pm-line);
    border-radius: var(--pm-radius-sm);
    outline: 0;
    background: var(--pm-control-bg);
    color: var(--pm-text-secondary);
    font-size: 12px;
}

.rf-link-field button {
    display: inline-flex;
    height: 40px;
    align-items: center;
    gap: 6px;
    padding: 0 13px;
    border: 1px solid var(--pm-green);
    border-radius: var(--pm-radius-sm);
    background: var(--pm-green);
    color: var(--pm-text-on-brand);
    cursor: pointer;
    font-size: 12px;
    font-weight: var(--pm-weight-semibold);
    transition: background-color var(--pm-duration-fast) ease,
                border-color var(--pm-duration-fast) ease;
}

.rf-link-field button:hover {
    border-color: var(--pm-green-hover);
    background: var(--pm-green-hover);
}

.rf-link-field button svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.rf-panel {
    border: 1px solid var(--pm-line);
    border-radius: var(--pm-radius-lg);
    background: var(--pm-surface);
    box-shadow: var(--pm-shadow-card);
}

.rf-chart-card {
    margin-top: 20px;
    overflow: hidden;
}

.rf-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-bottom: 1px solid var(--pm-line-soft);
}

.rf-stats article {
    position: relative;
    display: flex;
    min-height: 88px;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 16px 20px;
}

.rf-stats article + article {
    border-left: 1px solid var(--pm-line-soft);
}

.rf-stats article.is-accent::after {
    position: absolute;
    right: 20px;
    bottom: -1px;
    left: 20px;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: var(--pm-green);
    content: "";
}

.rf-stats span {
    color: var(--pm-text-muted);
    font-size: 12px;
}

.rf-stats strong {
    color: var(--pm-text);
    font-size: 22px;
    font-weight: var(--pm-weight-semibold);
    line-height: 1.1;
}

.rf-stats article.is-accent strong {
    color: var(--pm-green);
}

.rf-chart-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 20px 22px 0;
}

.rf-chart-head h2,
.rf-faq__head h2 {
    margin: 4px 0 0;
    color: var(--pm-text);
    font-size: 18px;
    font-weight: var(--pm-weight-semibold);
}

.rf-range {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border-radius: var(--pm-radius-sm);
    background: var(--pm-control-bg);
}

.rf-range button {
    min-width: 38px;
    height: 29px;
    padding: 0 8px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--pm-text-muted);
    cursor: pointer;
    font-size: 12px;
    font-weight: var(--pm-weight-semibold);
}

.rf-range button:hover {
    color: var(--pm-text);
}

.rf-range button.is-active {
    background: var(--pm-green-soft);
    color: var(--pm-green);
}

.rf-chart {
    position: relative;
    min-height: 295px;
    padding: 6px 20px 30px;
}

.rf-chart svg {
    display: block;
    width: 100%;
    height: 238px;
    overflow: visible;
}

.rf-chart__grid path {
    fill: none;
    stroke: var(--pm-line-soft);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.rf-chart__area {
    fill: url(#rfLineFill);
}

.rf-chart__line {
    fill: none;
    stroke: var(--pm-green);
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
}

.rf-chart__dot {
    fill: var(--pm-surface);
    stroke: var(--pm-green);
    stroke-width: 3;
    vector-effect: non-scaling-stroke;
}

.rf-chart__axis {
    position: absolute;
    right: 30px;
    bottom: 26px;
    left: 30px;
    display: flex;
    justify-content: space-between;
    color: var(--pm-text-muted);
    font-size: 12px;
}

.rf-chart > small {
    position: absolute;
    right: 22px;
    bottom: 7px;
    color: var(--pm-text-muted);
    font-size: 11px;
}

.rf-bottom {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, .78fr);
    gap: 16px;
    margin-top: 16px;
}

.rf-list,
.rf-faq {
    min-height: 390px;
    overflow: hidden;
}

.rf-tabs {
    display: flex;
    gap: 22px;
    padding: 0 18px;
    border-bottom: 1px solid var(--pm-line-soft);
}

.rf-tabs button {
    position: relative;
    height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--pm-text-secondary);
    cursor: pointer;
    font-size: 12px;
    font-weight: var(--pm-weight-medium);
}

.rf-tabs button::after {
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: var(--pm-green);
    content: "";
    opacity: 0;
    transform: scaleX(.5);
    transition: opacity var(--pm-duration-normal) ease,
                transform var(--pm-duration-normal) var(--pm-ease-emphasized);
}

.rf-tabs button:hover,
.rf-tabs button.is-active {
    color: var(--pm-text);
}

.rf-tabs button.is-active::after {
    opacity: 1;
    transform: scaleX(1);
}

.rf-empty {
    display: none;
    min-height: 330px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    text-align: center;
}

.rf-empty.is-active {
    display: flex;
    animation: rfContentIn 260ms var(--pm-ease-emphasized);
}

@keyframes rfContentIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.rf-empty-icon {
    display: grid;
    width: 52px;
    height: 52px;
    place-items: center;
    margin-bottom: 13px;
    border-radius: 14px;
    background: var(--pm-green-soft);
    color: var(--pm-green);
}

.rf-empty-icon svg {
    width: 27px;
    height: 27px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.rf-empty strong {
    color: var(--pm-text);
    font-size: 13px;
    font-weight: var(--pm-weight-semibold);
}

.rf-empty > span:last-child {
    max-width: 330px;
    margin-top: 5px;
    color: var(--pm-text-muted);
    font-size: 12px;
}

.rf-faq {
    padding: 18px;
}

.rf-faq__head {
    margin-bottom: 8px;
}

.rf-faq details {
    border-bottom: 1px solid var(--pm-line-soft);
}

.rf-faq details:last-child {
    border-bottom: 0;
}

.rf-faq summary {
    position: relative;
    padding: 14px 24px 14px 0;
    color: var(--pm-text);
    cursor: pointer;
    font-size: 12px;
    font-weight: var(--pm-weight-medium);
    list-style: none;
}

.rf-faq summary::-webkit-details-marker {
    display: none;
}

.rf-faq summary::before,
.rf-faq summary::after {
    position: absolute;
    top: 50%;
    right: 2px;
    width: 10px;
    height: 1px;
    background: var(--pm-text-muted);
    content: "";
    transition: transform var(--pm-duration-normal) var(--pm-ease-emphasized);
}

.rf-faq summary::after {
    transform: rotate(90deg);
}

.rf-faq details[open] summary::after {
    transform: rotate(0);
}

.rf-faq details[open] summary {
    color: var(--pm-green);
}

.rf-faq details p {
    margin: -3px 0 14px;
    color: var(--pm-text-secondary);
    font-size: 12px;
    line-height: 1.55;
}

html.is-dark .rf-panel,
html.is-dark .rf-link-card {
    background: var(--pm-surface);
}

@media (max-width: 900px) {
    .lb-table__head,
    .lb-row {
        grid-template-columns: 36px minmax(220px, 1fr) 150px 150px;
    }

    .rf-hero {
        grid-template-columns: 1fr;
        gap: 22px;
    }

    .rf-link-card {
        max-width: 620px;
    }

    .rf-bottom {
        grid-template-columns: 1fr;
    }

    .rf-list,
    .rf-faq {
        min-height: auto;
    }
}

@media (max-width: 720px) {
    .px-page {
        width: calc(100% - 24px);
        padding: 18px 0 54px;
    }

    .lb-top h1,
    .rf-title-line h1 {
        font-size: 25px;
    }

    .lb-top {
        align-items: stretch;
        flex-direction: column;
        gap: 16px;
    }

    .lb-category__button,
    .lb-category {
        width: 100%;
    }

    .lb-category__menu {
        right: auto;
        left: 0;
        width: 100%;
        transform-origin: top center;
    }

    .lb-tabs {
        display: flex;
        width: 100%;
    }

    .lb-tabs button {
        min-width: 0;
        flex: 1;
    }

    .lb-toolbar {
        grid-template-columns: 1fr;
        gap: 9px;
        padding: 10px 0;
    }

    .lb-sort {
        justify-content: stretch;
    }

    .lb-sort button {
        flex: 1;
    }

    .lb-table__head {
        display: none;
    }

    .lb-row {
        grid-template-columns: 28px minmax(0, 1fr) auto;
        grid-template-areas:
            "rank user profit"
            "rank user volume";
        gap: 4px 9px;
        min-height: 76px;
        padding: 9px 2px;
    }

    .lb-row__rank {
        grid-area: rank;
    }

    .lb-row__user {
        grid-area: user;
    }

    .lb-row__metric:nth-of-type(1) {
        grid-area: profit;
        align-self: end;
    }

    .lb-row__metric:nth-of-type(2) {
        grid-area: volume;
        align-self: start;
        color: var(--pm-text-secondary);
    }

    .lb-row__metric {
        font-size: 12px;
    }

    .lb-row__metric small {
        display: none;
    }

    .lb-row__avatar,
    .lb-row__fallback {
        width: 38px;
        height: 38px;
        flex-basis: 38px;
    }

    .rf-hero {
        padding-top: 0;
    }

    .rf-stats {
        grid-template-columns: 1fr;
    }

    .rf-stats article {
        min-height: 66px;
        padding: 12px 16px;
    }

    .rf-stats article + article {
        border-top: 1px solid var(--pm-line-soft);
        border-left: 0;
    }

    .rf-stats article.is-accent::after {
        top: 12px;
        right: auto;
        bottom: 12px;
        left: 0;
        width: 2px;
        height: auto;
    }

    .rf-chart-head {
        padding: 16px 14px 0;
    }

    .rf-chart {
        min-height: 250px;
        padding-right: 8px;
        padding-left: 8px;
    }

    .rf-chart svg {
        height: 195px;
    }

    .rf-chart__axis {
        right: 18px;
        left: 18px;
    }

    .rf-panel {
        border-radius: var(--pm-radius-md);
    }
}

@media (max-width: 460px) {
    .px-page {
        width: calc(100% - 18px);
    }

    .rf-link-field {
        grid-template-columns: 1fr;
    }

    .rf-link-field button {
        justify-content: center;
    }

    .rf-chart-head {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
    }

    .rf-range {
        width: 100%;
    }

    .rf-range button {
        flex: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .lb-skeleton,
    .rf-empty.is-active {
        animation: none;
    }
}
