/* Партнёрская программа VKService. Стили ограничены контейнером .referral. */
.referral {
    --referral-primary: var(--color-primary, #6756c8);
    --referral-ink: var(--color-text-primary, #15182b);
    --referral-muted: var(--color-text-secondary, #697087);
    --referral-border: var(--color-border, #e2e5ee);
    --referral-surface: var(--color-surface, #fff);
    --referral-shadow: 0 8px 24px rgba(25, 30, 54, .04);
    width: 100%;
    min-width: 0;
    color: var(--referral-ink);
}

.referral *,
.referral *::before,
.referral *::after {
    box-sizing: border-box;
}

.referral__heading {
    margin-bottom: 22px;
}

.referral__heading--back {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.referral__heading h1 {
    margin: 0 0 6px;
    color: var(--referral-ink);
    font-size: clamp(23px, 2.5vw, 31px);
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -.025em;
}

.referral__heading p,
.referral__history-heading p {
    margin: 0;
    color: var(--referral-muted);
    font-size: 13px;
    line-height: 1.6;
}

.referral__hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 174px;
    margin-bottom: 16px;
    padding: 26px 32px;
    color: #fff;
    background: linear-gradient(112deg, #5146a7 0%, #6556c9 60%, #8271dc 100%);
    border-radius: 15px;
    overflow: hidden;
    position: relative;
}

.referral__hero::after {
    position: absolute;
    width: 350px;
    height: 350px;
    right: -195px;
    top: -220px;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 50%;
    content: '';
    pointer-events: none;
}

.referral__hero-copy {
    position: relative;
    z-index: 1;
    min-width: 0;
}

.referral__hero-kicker {
    display: block;
    margin-bottom: 11px;
    color: rgba(255, 255, 255, .8);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .075em;
    text-transform: uppercase;
}

.referral__hero h2 {
    margin: 0 0 11px;
    color: #fff;
    font-size: clamp(22px, 2.4vw, 28px);
    font-weight: 800;
    line-height: 1.22;
    letter-spacing: -.02em;
}

.referral__hero p {
    max-width: 600px;
    margin: 0;
    color: rgba(255, 255, 255, .91);
    font-size: 12px;
    line-height: 1.6;
}

.referral__hero-icon {
    position: relative;
    z-index: 1;
    flex: 0 0 106px;
    width: 106px;
    height: 106px;
    display: grid;
    place-items: center;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 50%;
    background: rgba(255, 255, 255, .13);
}

.referral__hero-icon svg {
    width: 58px;
    height: 58px;
}

.referral__top-grid,
.referral__levels,
.referral__tools-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.referral__top-grid,
.referral__metrics {
    margin-bottom: 16px;
}

.referral__card,
.referral__metric,
.referral__step,
.referral__level,
.referral__history,
.referral__referrals {
    min-width: 0;
    background: var(--referral-surface);
    border: 1px solid var(--referral-border);
    border-radius: 14px;
    box-shadow: var(--referral-shadow);
}

.referral__card {
    padding: 20px;
}

.referral__card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 15px;
}

.referral__card-heading h2 {
    margin: 0 0 5px;
    color: var(--referral-ink);
    font-size: 15px;
    font-weight: 750;
    line-height: 1.4;
}

.referral__card-heading p {
    margin: 0;
    color: var(--referral-muted);
    font-size: 12px;
    line-height: 1.5;
}

.referral__small-icon {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    color: var(--referral-primary);
}

.referral__copy-field {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 6px;
    border: 1px solid var(--referral-border);
    border-radius: 10px;
    background: #f8f9fd;
}

.referral__copy-field input {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    height: 38px;
    padding: 0 8px;
    border: 0;
    outline: 0;
    color: #3d4564;
    background: transparent;
    font-size: 13px;
    text-overflow: ellipsis;
}

.referral__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 0 0 auto;
    min-height: 39px;
    padding: 9px 14px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: #fff;
    color: var(--referral-ink);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.25;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.referral__button:focus-visible,
.referral__copy-field:focus-within,
.referral__referrals summary:focus-visible {
    outline: 2px solid var(--referral-primary);
    outline-offset: 2px;
}

.referral__button:hover {
    color: var(--referral-ink);
    text-decoration: none;
}

.referral__button--primary {
    color: #fff;
    background: var(--referral-primary);
}

.referral__button--primary:hover,
.referral__button--primary:focus-visible {
    color: #fff;
    background: #5949b8;
}

.referral__button--copied {
    background: #22804e;
}

.referral__button--copied:hover {
    background: #22804e;
}

.referral__button--soft {
    background: #efedff;
    color: var(--referral-primary);
}

.referral__button--soft:hover {
    background: #e4dfff;
    color: #5144ba;
}

.referral__button--outline {
    border-color: #dbe0ef;
}

.referral__button--outline:hover:not(:disabled) {
    border-color: #aa9cf2;
    background: #f7f5ff;
    color: var(--referral-primary);
}

.referral__button:disabled {
    color: #9aa2b7;
    background: #f5f6f9;
    border-color: #e7e9f0;
    cursor: not-allowed;
}

.referral__share-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
}

.referral__share-row > span {
    color: var(--referral-muted);
    font-size: 11px;
    font-weight: 650;
}

.referral__share-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.referral__button--share {
    min-height: 34px;
    padding: 7px 11px;
    color: #5949b8;
    background: #f4f2ff;
    font-size: 11px;
}

.referral__button--share:hover {
    color: #5144ba;
    background: #e9e4ff;
}

.referral__copy-message {
    display: block;
    min-height: 16px;
    margin-top: 7px;
    color: #227c4d;
    font-size: 11px;
    line-height: 1.4;
}

.referral__balance-value {
    display: block;
    margin: 0 0 14px;
    font-size: 30px;
    line-height: 1.2;
    letter-spacing: -.025em;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.referral__balance-card > small {
    display: block;
    margin-top: 12px;
    color: var(--referral-muted);
    font-size: 11px;
    line-height: 1.5;
}

.referral__metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.referral__metric {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-height: 121px;
    padding: 19px;
}

.referral__metric > span:not(.referral__metric-icon) {
    color: var(--referral-muted);
    font-size: 11px;
}

.referral__metric strong {
    font-size: 25px;
    font-weight: 800;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.referral__metric strong.referral__metric-money {
    font-size: clamp(18px, 1.8vw, 25px);
}

.referral__section--results {
    margin-top: 17px;
}

.referral__metric strong.referral__metric-level {
    font-size: 20px;
}

.referral__metric small {
    color: var(--referral-muted);
    font-size: 11px;
}

.referral__metric-icon svg {
    width: 17px;
    height: 17px;
}

.referral__metric-icon {
    position: absolute;
    top: 14px;
    right: 15px;
    width: 29px;
    height: 29px;
    display: grid;
    place-items: center;
    background: #efedff;
    border-radius: 9px;
    color: var(--referral-primary);
}

.referral__section {
    margin: 21px 0 0;
}

.referral__section-title {
    margin: 0 0 12px;
    color: var(--referral-ink);
    font-size: 16px;
    font-weight: 800;
    line-height: 1.35;
}

.referral__steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.referral__step {
    min-height: 137px;
    padding: 19px;
}

.referral__step > span {
    display: grid;
    place-items: center;
    width: 29px;
    height: 29px;
    margin-bottom: 14px;
    color: var(--referral-primary);
    background: #efedff;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 800;
}

.referral__step strong {
    display: block;
    margin-bottom: 7px;
    color: var(--referral-ink);
    font-size: 12px;
    font-weight: 750;
}

.referral__step p {
    margin: 0;
    color: var(--referral-muted);
    font-size: 11px;
    line-height: 1.55;
}

.referral__level {
    position: relative;
    min-height: 160px;
    padding: 20px;
}

.referral__level--current {
    border-color: #9c8cf8;
    background: #fcfbff;
    box-shadow: 0 6px 20px rgba(103, 86, 200, .07);
}

.referral__level-head,
.referral__history-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.referral__level h3 {
    margin: 0;
    color: var(--referral-ink);
    font-size: 13px;
    font-weight: 800;
}

.referral__tag {
    display: inline-flex;
    align-items: center;
    padding: 6px 9px;
    color: var(--referral-primary);
    background: #eeeaff;
    border-radius: 30px;
    font-size: 10px;
    font-weight: 750;
    white-space: nowrap;
}

.referral__tag--muted {
    color: #767e98;
    background: #f0f1f5;
}

.referral__level-rates {
    display: flex;
    gap: 33px;
    margin: 18px 0 12px;
}

.referral__level-rates div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.referral__level-rates strong {
    color: var(--referral-primary);
    font-size: 27px;
    font-weight: 800;
    line-height: 1;
}

.referral__level-rates span,
.referral__level p {
    color: var(--referral-muted);
    font-size: 11px;
    line-height: 1.5;
}

.referral__level p {
    margin: 0;
}

.referral__progress-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
}

.referral__progress-info strong {
    color: #42476c;
    font-size: 11px;
    font-weight: 750;
}

.referral__progress-info span {
    color: var(--referral-primary);
    font-size: 12px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.referral__level-progress {
    height: 7px;
    margin: 9px 0 11px;
    overflow: hidden;
    background: #e6e4f3;
    border-radius: 99px;
}

.referral__level-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--referral-primary);
}

.referral__tools-grid {
    align-items: stretch;
    margin-top: 15px;
}

.referral__tools-grid > .referral__card {
    display: flex;
    flex-direction: column;
}

.referral__promo .referral__card-heading,
.referral__activation .referral__card-heading {
    min-height: 50px;
}

.referral__promo-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 5px;
}

.referral__promo-item {
    min-width: 0;
    overflow: hidden;
    border: 1px solid #e7e9f3;
    border-radius: 11px;
    background: #fff;
    transition: transform 160ms ease, border-color 160ms ease;
}

.referral__promo-item:hover {
    transform: translateY(-2px);
    border-color: #b7aaf3;
}

.referral__promo-image {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 3 / 4;
    min-width: 0;
    padding: 6px;
    overflow: hidden;
    background: #f8f9fd;
    text-decoration: none;
}

.referral__promo-image img {
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    object-fit: contain;
    object-position: center;
}

.referral__promo-view {
    position: absolute;
    right: 7px;
    bottom: 8px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 7px;
    border-radius: 6px;
    color: #fff;
    background: rgba(21, 24, 43, .78);
    font-size: 10px;
    font-weight: 700;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 160ms ease, transform 160ms ease;
}

.referral__promo-image:hover .referral__promo-view,
.referral__promo-image:focus-visible .referral__promo-view {
    opacity: 1;
    transform: none;
}

.referral__promo-download {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 7px;
    border-top: 1px solid #e7e9f3;
    color: var(--referral-primary);
    font-size: 11px;
    font-weight: 750;
    text-decoration: none;
}

.referral__promo-download:hover {
    background: #f6f4ff;
    color: #5144ba;
    text-decoration: none;
}

.referral__promo > small {
    margin-top: 10px;
    color: var(--referral-muted);
    font-size: 10px;
}

.referral__activation-list {
    display: flex;
    flex-direction: column;
    margin-top: 0;
}

.referral__activation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid #edf0f5;
}

.referral__activation-item:last-child {
    border-bottom: 0;
}

.referral__activation-description {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.referral__activation-description strong {
    color: var(--referral-ink);
    font-size: 12px;
    font-weight: 750;
}

.referral__activation-description span {
    color: var(--referral-muted);
    font-size: 11px;
}

.referral__activation-description small {
    color: #c05257;
    font-size: 10px;
}

.referral__activation-form {
    margin: 0;
}

.referral__activation-shortfall {
    flex: 0 1 auto;
    max-width: 155px;
    color: #a45259;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
    text-align: right;
}

.referral__history {
    padding: 0;
    overflow: hidden;
}

.referral__history-heading {
    padding: 18px 20px;
}

.referral__history-heading .referral__section-title {
    margin-bottom: 5px;
}

.referral__table-scroll {
    width: 100%;
    min-width: 0;
    overflow-x: auto;
}

.referral__table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
    font-size: 12px;
}

.referral__table th,
.referral__table td {
    padding: 13px 18px;
    border-bottom: 1px solid #edf0f5;
    text-align: left;
    vertical-align: middle;
}

.referral__table th {
    color: #777f99;
    background: #f8f9fc;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.referral__table tbody tr:last-child td {
    border-bottom: 0;
}

.referral__table td {
    color: #353d58;
    overflow-wrap: anywhere;
}

.referral__table td a {
    color: var(--referral-primary);
    font-weight: 650;
}

.referral__status {
    display: inline-flex;
    padding: 5px 9px;
    border: 1px solid #e6e9f2;
    border-radius: 99px;
    background: #f8f9fc;
    color: #5d6680;
    font-size: 11px;
}

.referral__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 32px 15px;
    color: #8b93aa;
    text-align: center;
}

.referral__empty--history {
    padding: 34px 20px 38px;
    border-top: 1px solid #f1f2f6;
    background: linear-gradient(180deg, #fff, #fcfcff);
}

.referral__empty-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin-bottom: 5px;
    border-radius: 15px;
    color: var(--referral-primary);
    background: #efedff;
}

.referral__empty-icon i {
    font-size: 23px;
}

.referral__empty > i {
    font-size: 28px;
    color: #a2a9c1;
}

.referral__empty strong {
    color: #536079;
    font-size: 12px;
}

.referral__empty span,
.referral__table-empty {
    color: #8b93aa;
    font-size: 11px;
}

.referral__referrals {
    margin-top: 15px;
    overflow: hidden;
}

.referral__referrals summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 17px 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 750;
    list-style: none;
}

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

.referral__referrals summary > span {
    display: flex;
    align-items: center;
    gap: 10px;
}

.referral__referrals summary > span > i {
    color: var(--referral-primary);
}

.referral__referrals summary small {
    color: var(--referral-muted);
    font-size: 11px;
}

.referral__referrals[open] summary > i {
    transform: rotate(180deg);
}

.referral__pagination {
    display: flex;
    justify-content: center;
    padding: 16px 20px;
    border-top: 1px solid #edf0f5;
}

.referral__pagination .pagination {
    margin: 0;
}

.referral__pagination .page-link {
    border-color: #e0e4ef;
    color: var(--referral-primary);
}

.referral__pagination .page-item.active .page-link {
    background: var(--referral-primary);
    border-color: var(--referral-primary);
    color: #fff;
}

.referral__history--full {
    margin-top: 8px;
}

@media (max-width: 980px) {
    .referral__top-grid,
    .referral__tools-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .referral__promo-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .referral__hero {
        min-height: 156px;
        padding: 22px;
    }

    .referral__hero-icon {
        flex-basis: 76px;
        width: 76px;
        height: 76px;
    }

    .referral__hero-icon svg {
        width: 43px;
        height: 43px;
    }

    .referral__top-grid,
    .referral__levels,
    .referral__tools-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .referral__metrics,
    .referral__steps {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .referral__promo-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .referral__history-heading {
        flex-wrap: wrap;
    }
}

@media (max-width: 640px) {
    /* Операции читаются как карточки вместо прокручиваемой таблицы. */
    .referral__history .referral__table-scroll {
        overflow: visible;
    }

    .referral__history .referral__table,
    .referral__history .referral__table tbody {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .referral__history .referral__table thead {
        display: none;
    }

    .referral__history .referral__table tbody {
        padding: 0 12px 14px;
    }

    .referral__history .referral__table tbody tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: end;
        gap: 8px 12px;
        margin-top: 10px;
        padding: 13px 14px;
        border: 1px solid var(--referral-border);
        border-radius: 12px;
        background: #fff;
    }

    .referral__history .referral__table td {
        display: block;
        min-width: 0;
        padding: 0;
        border: 0;
    }

    .referral__history .referral__table td:first-child {
        grid-column: 1 / -1;
        color: var(--referral-muted);
        font-size: 11px;
        line-height: 1.4;
    }

    .referral__history .referral__table td:nth-child(2) {
        grid-column: 1;
        color: var(--referral-ink);
        font-size: 16px;
        font-weight: 750;
        line-height: 1.25;
    }

    .referral__history .referral__table td:nth-child(2)::before {
        display: block;
        margin-bottom: 4px;
        color: var(--referral-muted);
        font-size: 10px;
        font-weight: 500;
        content: 'Сумма';
    }

    .referral__history .referral__table td:nth-child(3) {
        grid-column: 2;
        justify-self: end;
        max-width: 145px;
        text-align: right;
    }

    .referral__history .referral__status {
        max-width: 100%;
        overflow-wrap: anywhere;
        text-align: center;
    }

    .referral__history .referral__table tbody tr.referral__history-empty-row {
        display: block;
        padding: 0;
        border: 0;
        background: transparent;
    }

    .referral__history .referral__table tbody tr.referral__history-empty-row td {
        display: block;
    }

    .referral__history .referral__table tbody tr.referral__history-empty-row td::before {
        content: none;
    }
}

@media (max-width: 480px) {
    .referral__heading,
    .referral__heading--back {
        flex-wrap: wrap;
    }

    .referral__hero {
        align-items: flex-start;
        min-height: 170px;
        padding: 22px 18px;
    }

    .referral__hero-icon {
        flex-basis: 52px;
        width: 52px;
        height: 52px;
    }

    .referral__hero-icon svg {
        width: 30px;
        height: 30px;
    }

    .referral__hero h2 {
        font-size: 20px;
    }

    .referral__hero p {
        font-size: 11px;
    }

    .referral__card,
    .referral__level,
    .referral__step {
        padding: 16px;
    }

    .referral__metrics,
    .referral__steps {
        gap: 10px;
    }

    .referral__metric {
        min-height: 116px;
        padding: 15px;
    }

    .referral__metric:last-child {
        grid-column: 1 / -1;
    }

    .referral__metric strong.referral__metric-level {
        font-size: 18px;
    }

    .referral__share-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .referral__share-actions {
        width: 100%;
    }

    .referral__share-actions .referral__button {
        flex: 1 1 0;
        min-width: 0;
    }

    .referral__copy-field {
        flex-direction: column;
        align-items: stretch;
    }

    .referral__copy-field input {
        min-height: 40px;
    }

    .referral__copy-field .referral__button {
        width: 100%;
    }

    .referral__card-heading .referral__button {
        padding: 8px 10px;
        font-size: 11px;
    }

    .referral__promo-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .referral__table th,
    .referral__table td {
        padding: 11px 13px;
    }

    .referral__table {
        min-width: 440px;
    }

    .referral__referrals .referral__table {
        min-width: 620px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .referral__button,
    .referral__promo-item,
    .referral__promo-view {
        transition: none;
    }
}
