/* ===== Реферальная система (admin) ===== */
.ref-page {
    --ref-ink: #101828;
    --ref-text: #344054;
    --ref-muted: #667085;
    --ref-soft: #98a2b3;
    --ref-line: #eaecf0;
    --ref-bg: #f8fafc;
    --ref-violet: #7c3aed;
    --ref-violet-soft: #f4f0ff;
}

/* KPIs */
.ref-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 1rem;
}

.ref-kpi {
    --k: var(--ref-violet);
    --k-soft: var(--ref-violet-soft);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid var(--ref-line);
    border-radius: 14px;
    background: #fff;
}

.ref-kpi--green { --k: #079455; --k-soft: #ecfdf3; }
.ref-kpi--amber { --k: #dc6803; --k-soft: #fffaeb; }
.ref-kpi--blue { --k: #2563eb; --k-soft: #eff6ff; }

.ref-kpi__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: var(--k-soft);
    color: var(--k);
    font-size: 15px;
}

.ref-kpi__icon i {
    display: inline-flex;
    line-height: 1;
}

.ref-kpi > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ref-kpi b {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 19px;
    font-weight: 800;
    line-height: 1.1;
    color: var(--ref-ink);
    font-variant-numeric: tabular-nums;
}

.ref-kpi b small {
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--k-soft);
    font-size: 11px;
    font-weight: 700;
    color: var(--k);
}

.ref-kpi span {
    overflow: hidden;
    font-size: 11.5px;
    color: var(--ref-muted);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ref-kpi span em {
    margin-left: 4px;
    font-style: normal;
    font-weight: 700;
    color: #079455;
}

/* Layout */
.ref-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 310px;
    gap: 1.25rem;
    align-items: start;
}

.ref-aside {
    position: sticky;
    top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.ref-count-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 26px;
    padding: 0 8px;
    border: 1px solid #e9d7fe;
    border-radius: 999px;
    background: var(--ref-violet-soft);
    font-size: 12px;
    font-weight: 700;
    color: #6d28d9;
    font-variant-numeric: tabular-nums;
}

/* Toolbar */
.ref-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.ref-toolbar .adm-seg {
    max-width: 100%;
}

.ref-toolbar__right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    min-width: 0;
}

.ref-toolbar .adm-search {
    width: 230px;
    min-width: 0;
}

.ref-focus {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 220px;
    height: 32px;
    padding: 0 4px 0 10px;
    border: 1px solid #ddd6fe;
    border-radius: 999px;
    background: var(--ref-violet-soft);
    font-size: 12px;
    font-weight: 700;
    color: #5b21b6;
}

.ref-focus[hidden] {
    display: none;
}

.ref-focus > i {
    display: inline-flex;
    font-size: 11px;
    line-height: 1;
}

.ref-focus > span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

#adm-page .ref-focus button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #6d28d9;
    font-size: 14px;
    cursor: pointer;
}

#adm-page .ref-focus button:hover {
    background: var(--ref-violet);
    color: #fff;
}

.ref-focus button i {
    display: inline-flex;
    line-height: 1;
}

/* Table */
.ref-table {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--ref-line);
    border-radius: 14px;
    overflow: hidden;
}

.ref-thead,
.ref-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr) 82px 84px 138px;
    align-items: center;
    gap: 12px;
    padding: 0 14px;
}

.ref-thead {
    height: 34px;
    border-bottom: 1px solid var(--ref-line);
    background: var(--ref-bg);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ref-soft);
}

.ref-row {
    min-height: 62px;
    padding-top: 9px;
    padding-bottom: 9px;
    border-bottom: 1px solid #f2f4f7;
    background: #fff;
    transition: background 0.12s ease;
}

.ref-row:last-of-type {
    border-bottom: 0;
}

.ref-row:hover {
    background: #fcfcfd;
}

.ref-row[hidden] {
    display: none;
}

.ref-row.is-focus-hit .ref-person--a .ref-person__link b {
    color: #5b21b6;
}

/* Person */
.ref-person {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.ref-person__link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}

a.ref-person__link:hover b {
    color: var(--ref-violet);
}

.ref-person__body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ref-person__body b {
    overflow: hidden;
    font-size: 13px;
    font-weight: 700;
    color: var(--ref-ink);
    white-space: nowrap;
    text-overflow: ellipsis;
    transition: color 0.12s ease;
}

.ref-person__body small {
    overflow: hidden;
    font-size: 11.5px;
    color: var(--ref-muted);
    white-space: nowrap;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
}

#adm-page .ref-multi {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 22px;
    padding: 0 7px;
    border: 1px solid #ddd6fe;
    border-radius: 999px;
    background: var(--ref-violet-soft);
    font-size: 11px;
    font-weight: 700;
    color: #6d28d9;
    flex-shrink: 0;
    margin-left: auto;
    cursor: pointer;
}

#adm-page .ref-multi:hover {
    border-color: var(--ref-violet);
    background: var(--ref-violet);
    color: #fff;
}

.ref-multi i {
    display: inline-flex;
    font-size: 10px;
    line-height: 1;
}

.ref-avatar {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    overflow: hidden;
    border-radius: 50%;
    background: var(--av, #7c3aed);
    font-size: 13px;
    font-weight: 800;
    color: #fff;
}

.ref-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ref-avatar--sm {
    width: 30px;
    height: 30px;
    font-size: 12px;
}

.ref-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--ref-violet-soft);
    color: var(--ref-violet);
    font-size: 13px;
}

.ref-arrow i {
    display: inline-flex;
    line-height: 1;
}

/* Cells */
.ref-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ref-date b {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ref-text);
    font-variant-numeric: tabular-nums;
}

.ref-date small {
    font-size: 11px;
    color: var(--ref-soft);
    font-variant-numeric: tabular-nums;
}

.ref-reward {
    gap: 3px;
}

.ref-reward span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 700;
    color: var(--ref-soft);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.ref-reward span i {
    display: inline-flex;
    font-size: 10px;
    line-height: 1;
}

.ref-reward span.is-paid {
    color: #067647;
}

.ref-state {
    align-items: flex-start;
    gap: 4px;
}

.ref-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.ref-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.ref-status--done {
    background: #ecfdf3;
    color: #067647;
}

.ref-status--wait {
    background: #f2f4f7;
    color: #475467;
}

.ref-status--stuck {
    background: #fffaeb;
    color: #b54708;
}

.ref-order {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--ref-muted);
    text-decoration: none;
    white-space: nowrap;
}

a.ref-order {
    color: var(--ref-violet);
}

a.ref-order:hover {
    text-decoration: underline;
}

.ref-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 2.5rem 1rem;
    font-size: 13px;
    font-weight: 600;
    color: var(--ref-soft);
}

.ref-empty[hidden] {
    display: none;
}

.ref-empty i {
    display: inline-flex;
    font-size: 20px;
    line-height: 1;
}

.ref-empty--sm {
    padding: 1.25rem 1rem;
}

/* Top referrers */
.ref-top {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

#adm-page .ref-top__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 8px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease;
}

#adm-page .ref-top__item:hover {
    background: var(--ref-bg);
}

#adm-page .ref-top__item.is-active {
    border-color: #ddd6fe;
    background: var(--ref-violet-soft);
}

.ref-top__rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #f2f4f7;
    font-size: 11px;
    font-weight: 800;
    color: var(--ref-muted);
}

.ref-top__rank.is-1 { background: #fef0c7; color: #b54708; }
.ref-top__rank.is-2 { background: #eaecf0; color: #344054; }
.ref-top__rank.is-3 { background: #fbe8dc; color: #9c4221; }

.ref-top__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.ref-top__body b {
    overflow: hidden;
    font-size: 13px;
    font-weight: 700;
    color: var(--ref-ink);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.ref-top__body small {
    font-size: 11px;
    color: var(--ref-muted);
    white-space: nowrap;
}

.ref-top__earned {
    flex-shrink: 0;
    font-size: 12.5px;
    font-weight: 800;
    color: #067647;
    font-variant-numeric: tabular-nums;
}

.ref-top__earned.is-zero {
    color: var(--ref-soft);
}

/* Settings */
.ref-settings {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ref-settings .skl-card__head {
    margin-bottom: 0;
}

.ref-switch {
    padding: 10px 12px;
    border: 1px solid var(--ref-line);
    border-radius: 12px;
    background: var(--ref-bg);
}

.ref-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ref-affix {
    position: relative;
}

.ref-affix > span {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: 600;
    color: var(--ref-soft);
    pointer-events: none;
}

#adm-page .ref-affix .adm-input {
    padding-right: 64px;
}

@media (max-width: 1500px) {
    .ref-thead,
    .ref-row {
        gap: 10px;
        padding-right: 12px;
        padding-left: 12px;
    }

    .ref-avatar {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
}

@media (max-width: 1200px) {
    .ref-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .ref-aside {
        position: static;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: start;
    }
}

@media (max-width: 900px) {
    .ref-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ref-aside {
        grid-template-columns: minmax(0, 1fr);
    }

    .ref-thead {
        display: none;
    }

    .ref-row {
        grid-template-columns: minmax(0, 1fr) 22px minmax(0, 1fr);
        row-gap: 8px;
    }

    .ref-date {
        grid-column: 1;
    }

    .ref-reward {
        grid-column: 3;
    }

    .ref-state {
        flex-direction: row;
        align-items: center;
        gap: 8px;
        grid-column: 1 / -1;
    }

    .ref-toolbar__right {
        width: 100%;
        margin-left: 0;
    }

    .ref-toolbar .adm-search {
        flex: 1;
        width: auto;
    }
}
