.referral-code-card {
    background: linear-gradient(135deg, rgba(56, 177, 237, 0.12), rgba(255, 255, 255, 0.04));
    border: 1px solid rgba(56, 177, 237, 0.3);
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 24px;
}

.referral-code-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.referral-code-label {
    display: block;
    font-size: 0.8em;
    color: var(--text-secondary, #b0b0b0);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.referral-code-value {
    font-family: 'Courier New', monospace;
    font-size: 1.05em;
    font-weight: 600;
    color: var(--text-primary, #ffffff);
    word-break: break-all;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 6px;
    padding: 8px 12px;
    display: inline-block;
}

.referral-code-hint {
    margin: 16px 0 0;
    font-size: 0.85em;
    color: var(--text-secondary, #b0b0b0);
    line-height: 1.6;
}

.referral-code-hint strong {
    color: var(--primary-color, #38b1ed);
}

.referral-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 30px;
}

.referral-stat-card {
    background: var(--card-bg, rgba(255, 255, 255, 0.05));
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 12px;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: all 0.3s ease;
}

.referral-stat-card:hover {
    border-color: var(--primary-color, #38b1ed);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(56, 177, 237, 0.15);
}

.referral-stat-value {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--primary-color, #38b1ed);
}

.referral-stat-label {
    font-size: 0.8em;
    color: var(--text-secondary, #b0b0b0);
    margin-top: 6px;
}

.invoices-table td.credit-amount-positive {
    color: var(--success-color, #10b981);
    font-weight: 600;
}

.invoices-table td.credit-amount-negative {
    color: var(--danger-color, #ef4444);
    font-weight: 600;
}

@media (max-width: 768px) {
    .referral-stats-grid {
        grid-template-columns: 1fr;
    }
    .referral-code-row {
        flex-direction: column;
        align-items: flex-start;
    }
    .referral-code-row .btn {
        width: 100%;
    }

    /* main.container (home.css) is display:flex, making .billing-container its
       flex item — without min-width:0 its automatic minimum size is its content's
       min-content, which can force the whole page to overflow horizontally
       instead of letting inner elements wrap/scroll on their own. */
    .billing-container {
        min-width: 0;
    }
}

@media (max-width: 700px) {
    /* Stacked-card treatment (same pattern as the admin dashboard tables):
       cleaner than a horizontally-scrolling 4-column table on a phone.
       Scoped to this page's own sections so billing.html's shared use of
       .invoices-table (via billing.css) is unaffected. */
    #referred-section .invoices-table, #referred-section .invoices-table thead,
    #referred-section .invoices-table tbody, #referred-section .invoices-table th,
    #referred-section .invoices-table td, #referred-section .invoices-table tr,
    #credits-section .invoices-table, #credits-section .invoices-table thead,
    #credits-section .invoices-table tbody, #credits-section .invoices-table th,
    #credits-section .invoices-table td, #credits-section .invoices-table tr {
        display: block;
        width: 100%;
    }

    #referred-section .invoices-table thead,
    #credits-section .invoices-table thead {
        display: none;
    }

    #referred-section .invoices-table tr,
    #credits-section .invoices-table tr {
        border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
        padding: 10px 0;
    }

    #referred-section .invoices-table td,
    #credits-section .invoices-table td {
        display: grid;
        grid-template-columns: minmax(90px, auto) 1fr;
        justify-items: start;
        align-items: center;
        gap: 12px;
        padding: 4px 4px;
        border-top: none !important;
        white-space: normal !important;
        text-align: start;
    }

    #referred-section .invoices-table td::before,
    #credits-section .invoices-table td::before {
        content: attr(data-label);
        color: var(--text-secondary, #888);
        font-size: 0.72rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
}
