/* ============ REFERRAL PAGE ============ */
.referral-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* ХЕДЕР */
.referral-header {
    text-align: center;
    margin-bottom: 24px;
}
.referral-title {
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 8px;
    color: #1a1a1a;
}
.referral-title i {
    color: #00AAFF;
    margin-right: 8px;
}
.referral-subtitle {
    font-size: 15px;
    color: #666;
    margin: 0;
    line-height: 1.5;
}
.referral-subtitle b { color: #1a1a1a; }

/* БАЛАНС */
.referral-balance-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    background: linear-gradient(135deg, #00AAFF 0%, #0088cc 100%);
    border-radius: 16px;
    margin-bottom: 20px;
    color: #fff;
    flex-wrap: wrap;
}
.referral-balance-info { display: flex; flex-direction: column; gap: 4px; }
.referral-balance-label {
    font-size: 13px;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.referral-balance-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
}
.referral-balance-value small {
    font-size: 16px;
    font-weight: 400;
    opacity: 0.85;
}
.referral-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
}
.referral-btn-outline {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
}
.referral-btn-outline:hover {
    background: rgba(255,255,255,0.25);
    color: #fff;
    text-decoration: none;
}

/* ССЫЛКА */
.referral-link-card {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    margin-bottom: 20px;
}
.referral-card-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 8px;
    color: #1a1a1a;
}
.referral-card-title i { color: #00AAFF; margin-right: 6px; }
.referral-card-hint {
    font-size: 13px;
    color: #666;
    margin: 0 0 16px;
    line-height: 1.5;
}

.referral-link-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.referral-link-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    background: #fafafa;
    color: #1a1a1a;
    min-width: 0;
}
.referral-link-input:focus { outline: none; border-color: #00AAFF; }

.referral-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: #00AAFF;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.referral-copy-btn:hover { background: #0088cc; }
.referral-copy-btn.copied { background: #00A046; }

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

/* СТАТИСТИКА */
.referral-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}
.referral-stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.referral-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
}
.referral-stat-l1 .referral-stat-icon { background: #e8f4ff; color: #00AAFF; }
.referral-stat-l2 .referral-stat-icon { background: #fff8e6; color: #cc8800; }
.referral-stat-l3 .referral-stat-icon { background: #f0e8ff; color: #7c3aed; }
.referral-stat-total .referral-stat-icon { background: #e8f9ed; color: #00A046; font-size: 20px; }

.referral-stat-info { display: flex; flex-direction: column; }
.referral-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.1;
}
.referral-stat-label {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}
.referral-stat-rate {
    font-size: 11px;
    color: #00AAFF;
    font-weight: 600;
    margin-top: 2px;
}

/* СЕКЦИИ */
.referral-section {
    background: #fff;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    margin-bottom: 20px;
}
.referral-section-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 16px;
    color: #1a1a1a;
}
.referral-section-title i { color: #00AAFF; margin-right: 6px; }

/* ДРУЗЬЯ */
.referral-level-group { margin-bottom: 20px; }
.referral-level-group:last-child { margin-bottom: 0; }
.referral-level-title {
    font-size: 14px;
    font-weight: 700;
    color: #666;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.referral-level-rate {
    background: #f0f8ff;
    color: #00AAFF;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 8px;
    font-weight: 700;
}

.referral-friends-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.referral-friend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    transition: background 0.15s;
}
.referral-friend-item:hover { background: #f8f8f8; }

.referral-friend-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    overflow: hidden;
    background: #FFC107;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: #1a1a1a;
    flex-shrink: 0;
}
.referral-friend-avatar img { width: 100%; height: 100%; object-fit: cover; }
.referral-friend-info { flex: 1; min-width: 0; }
.referral-friend-name {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
}
.referral-friend-date {
    font-size: 12px;
    color: #999;
}

/* ИСТОРИЯ */
.referral-history { display: flex; flex-direction: column; gap: 4px; }
.referral-history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    transition: background 0.15s;
}
.referral-history-item:hover { background: #f8f8f8; }
.referral-history-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}
.referral-history-plus .referral-history-icon { background: #e8f9ed; color: #00A046; }
.referral-history-minus .referral-history-icon { background: #ffe8e8; color: #FF4053; }

.referral-history-info { flex: 1; min-width: 0; }
.referral-history-desc {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.referral-history-date {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
}
.referral-history-amount {
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}
.referral-history-plus .referral-history-amount { color: #00A046; }
.referral-history-minus .referral-history-amount { color: #FF4053; }

/* ПУСТОЕ */
.referral-empty {
    text-align: center;
    padding: 60px 20px;
    background: #fff;
    border-radius: 16px;
    color: #999;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.referral-empty i { font-size: 64px; color: #ddd; }
.referral-empty h3 {
    font-size: 18px;
    color: #666;
    margin: 20px 0 8px;
}
.referral-empty p { font-size: 14px; margin: 0; }
.referral-empty b { color: #1a1a1a; }

/* АДАПТИВ */
@media (max-width: 576px) {
    .referral-page { padding: 16px 12px; }
    .referral-title { font-size: 22px; }
    .referral-balance-card { flex-direction: column; align-items: stretch; }
    .referral-link-row { flex-direction: column; }
    .referral-copy-btn { justify-content: center; }
    .referral-stats { grid-template-columns: 1fr 1fr; }
    .referral-stat-value { font-size: 18px; }
    .referral-stat-icon { width: 38px; height: 38px; font-size: 16px; }
}

/* ПОДСКАЗКА ПРИ КОПИРОВАНИИ */
.referral-copy-hint {
    font-size: 12px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #f0f8ff;
    border-radius: 8px;
    margin-top: 4px;
}
.referral-copy-hint i {
    color: #00AAFF;
    flex-shrink: 0;
}

/* ПРЕВЬЮ ТЕКСТА (сворачиваемое) */
.referral-preview-toggle {
    margin-top: 12px;
    border-top: 1px solid #f0f0f0;
    padding-top: 12px;
}

.referral-preview-toggle summary {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #00AAFF;
    cursor: pointer;
    list-style: none;
    padding: 4px 0;
    user-select: none;
}
.referral-preview-toggle summary::-webkit-details-marker { display: none; }
.referral-preview-toggle summary:hover { color: #0088cc; }

.referral-preview-arrow {
    margin-left: auto;
    transition: transform 0.2s;
    font-size: 12px;
}
.referral-preview-toggle[open] .referral-preview-arrow {
    transform: rotate(180deg);
}

.referral-preview-bubble {
    background: #f0f8ff;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    padding: 14px 16px;
    margin-top: 10px;
    font-size: 13px;
    line-height: 1.5;
    color: #1a1a1a;
    white-space: pre-wrap;
    word-wrap: break-word;
    position: relative;
}
.referral-preview-bubble::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 12px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-bottom-color: #f0f8ff;
    border-top: 0;
}
.referral-preview-bubble b {
    color: #00AAFF;
}