:root {
    --ink: #101828;
    --muted: #667085;
    --line: rgba(20, 35, 65, 0.12);
    --white: #ffffff;
    --blue: #2558e8;
    --cyan: #0ea5e9;
    --teal: #10b981;
    --green: #16a34a;
    --gold: #f59e0b;
    --violet: #7c3aed;
    --rose: #e11d48;
    --shadow: 0 24px 70px rgba(16, 24, 40, 0.16);
}

* { box-sizing: border-box; }

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: #eef4ff;
}

button,
input,
textarea {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

.hidden { display: none !important; }
.affiliate-shell { height: 100svh; min-height: 620px; }

.boot-loader {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 50% 45%, #ffffff 0, #eef4ff 38%, #ddeaff 100%);
}

.boot-loader img {
    width: 62px;
    height: 62px;
    animation: logoFloat 900ms ease-in-out infinite alternate;
}

.affiliate-booting .affiliate-auth,
.affiliate-booting .affiliate-dashboard {
    visibility: hidden;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    color: var(--ink);
    text-decoration: none;
    font-weight: 900;
    letter-spacing: 0;
}

.brand-mark img {
    width: 42px;
    height: 42px;
    filter: drop-shadow(0 12px 20px rgba(37, 88, 232, 0.2));
}

.brand-animated img {
    animation: logoFloat 1.6s ease-in-out infinite alternate;
}

.affiliate-auth {
    height: 100svh;
    min-height: 620px;
    display: grid;
    place-items: center;
    padding: clamp(0.8rem, 2vw, 1.5rem);
    background:
        linear-gradient(135deg, rgba(37, 88, 232, 0.18), transparent 36%),
        linear-gradient(315deg, rgba(16, 185, 129, 0.18), transparent 34%),
        #eef4ff;
}

.auth-stage {
    width: min(1060px, 100%);
    height: min(720px, calc(100svh - 2rem));
    min-height: 590px;
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(360px, 430px);
    gap: clamp(0.8rem, 2vw, 1.2rem);
}

.program-intro,
.auth-panel,
.notice,
.ref-box,
.stat-card,
.wallet-card,
.panel {
    border: 1px solid rgba(255, 255, 255, 0.58);
    background: rgba(255, 255, 255, 0.78);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.program-intro {
    position: relative;
    overflow: hidden;
    border-radius: 24px;
    padding: clamp(1.2rem, 3vw, 2rem);
    display: grid;
    grid-template-rows: auto 1fr auto;
}

.program-intro::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 72% 24%, rgba(124, 58, 237, 0.18), transparent 24%),
        radial-gradient(circle at 20% 78%, rgba(14, 165, 233, 0.2), transparent 26%);
}

.program-intro::after {
    content: "";
    position: absolute;
    right: -70px;
    bottom: -90px;
    width: 270px;
    height: 270px;
    border-radius: 48px;
    transform: rotate(18deg);
    background: linear-gradient(135deg, rgba(37, 88, 232, 0.2), rgba(16, 185, 129, 0.22));
}

.program-intro > * {
    position: relative;
    z-index: 1;
}

.intro-copy {
    align-self: center;
    animation: riseIn 520ms ease both;
}

.eyebrow {
    display: inline-flex;
    color: #2446a8;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.intro-copy h1 {
    max-width: 620px;
    margin: 0.6rem 0 0;
    font-size: clamp(2rem, 4.2vw, 3.65rem);
    line-height: 1.03;
    letter-spacing: 0;
    font-weight: 950;
}

.intro-copy h1 span {
    display: inline-block;
    color: transparent;
    background: linear-gradient(100deg, #163d9f, #0ea5e9, #10b981, #163d9f);
    background-size: 220% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    animation: headlineShimmer 5s ease-in-out infinite;
}

.intro-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.65rem;
}

.intro-metrics div {
    min-height: 92px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.68);
    padding: 0.9rem;
    display: grid;
    align-content: end;
}

.intro-metrics strong {
    color: #1f3f96;
    font-size: 1.22rem;
}

.intro-metrics span {
    margin-top: 0.1rem;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.25;
}

.auth-panel {
    border-radius: 24px;
    padding: clamp(0.85rem, 1.7vw, 1.15rem);
    align-self: stretch;
    overflow: hidden;
    animation: riseIn 620ms ease both;
}

.tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.42rem;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: rgba(236, 243, 255, 0.92);
    padding: 0.32rem;
    margin-bottom: 0.72rem;
}

.tab {
    min-height: 38px;
    border-radius: 12px;
    background: transparent;
    color: var(--muted);
    font-weight: 900;
}

.tab.active {
    color: #183d9b;
    background: var(--white);
    box-shadow: 0 10px 24px rgba(16, 24, 40, 0.1);
}

.auth-form {
    display: grid;
    gap: 0.58rem;
}

label {
    display: grid;
    gap: 0.26rem;
    color: #344054;
    font-size: 0.78rem;
    font-weight: 850;
}

input,
textarea {
    width: 100%;
    min-height: 40px;
    border: 1px solid rgba(20, 35, 65, 0.14);
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--ink);
    padding: 0.62rem 0.72rem;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

textarea {
    min-height: 64px;
    resize: none;
}

input:focus,
textarea:focus {
    border-color: rgba(37, 88, 232, 0.65);
    background: var(--white);
    box-shadow: 0 0 0 4px rgba(37, 88, 232, 0.12);
}

.url-head,
.dash-head,
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.url-head span {
    color: #344054;
    font-size: 0.78rem;
    font-weight: 900;
}

.url-head button,
.ghost-btn,
.ref-box button {
    min-height: 36px;
    border-radius: 12px;
    border: 1px solid rgba(37, 88, 232, 0.18);
    background: var(--white);
    color: #1f3f96;
    padding: 0.45rem 0.68rem;
    font-weight: 900;
}

.side-actions {
    display: grid;
    gap: 0.55rem;
}

.url-fields {
    display: grid;
    gap: 0.48rem;
}

.primary-btn,
.withdraw-form button {
    min-height: 43px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--blue), var(--teal));
    color: var(--white);
    padding: 0.72rem 0.9rem;
    font-weight: 950;
    box-shadow: 0 16px 30px rgba(37, 88, 232, 0.25);
}

.primary-btn.is-loading,
.withdraw-form button.is-loading {
    opacity: 0.82;
    cursor: wait;
}

.primary-btn.is-loading::after,
.withdraw-form button.is-loading::after {
    content: "";
    width: 0.9rem;
    height: 0.9rem;
    margin-left: 0.5rem;
    display: inline-block;
    vertical-align: -0.12rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 720ms linear infinite;
}

.message {
    min-height: 1rem;
    margin: 0.58rem 0 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.message.error { color: var(--rose); }
.message.success { color: var(--green); }

.affiliate-toast {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 50;
    max-width: min(360px, calc(100vw - 2rem));
    border: 1px solid rgba(20, 35, 65, 0.1);
    border-radius: 16px;
    background: #ffffff;
    color: #1f2937;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.16);
    padding: 0.85rem 1rem;
    font-size: 0.9rem;
    font-weight: 850;
    line-height: 1.35;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: opacity 180ms ease, transform 180ms ease;
}

.affiliate-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.affiliate-toast.success {
    border-color: rgba(16, 185, 129, 0.28);
    color: #047857;
}

.affiliate-toast.error {
    border-color: rgba(225, 29, 72, 0.22);
    color: #be123c;
}

.affiliate-dashboard {
    height: 100svh;
    min-height: 620px;
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr);
    background:
        radial-gradient(circle at 16% 18%, rgba(37, 88, 232, 0.12), transparent 28%),
        radial-gradient(circle at 88% 78%, rgba(16, 185, 129, 0.14), transparent 30%),
        #eef4ff;
}

.side {
    min-width: 0;
    border-right: 1px solid rgba(20, 35, 65, 0.1);
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(18px);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.brand-mark.compact {
    max-width: 100%;
}

.brand-mark.compact img {
    width: 35px;
    height: 35px;
    flex: 0 0 auto;
}

.brand-mark.compact span {
    min-width: 0;
    display: grid;
    line-height: 1.05;
}

.brand-mark.compact strong {
    font-size: 0.92rem;
    white-space: nowrap;
}

.brand-mark.compact small {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.main {
    min-width: 0;
    min-height: 0;
    padding: clamp(0.75rem, 1.6vw, 1.1rem);
}

.notice {
    max-width: 720px;
    border-radius: 24px;
    padding: 1.4rem;
}

.notice h1 {
    margin: 0.25rem 0 0;
    font-size: clamp(2rem, 4vw, 3.2rem);
    letter-spacing: 0;
}

.notice p {
    margin: 0.45rem 0 0;
    color: var(--muted);
}

.dashboard-grid {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(260px, 330px);
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 0.72rem;
}

.dash-head {
    grid-column: 1 / -1;
    min-width: 0;
    position: relative;
}

.dash-user-block {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.dash-head h1 {
    margin: 0.2rem 0 0;
    font-size: clamp(1.45rem, 2.5vw, 2.2rem);
    line-height: 1.05;
    letter-spacing: 0;
}

.affiliate-title-row {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    min-width: 0;
}

.affiliate-title-row h1 {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.promo-asset-btn {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: 13px;
    border: 1px solid rgba(37, 88, 232, 0.18);
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 12px 28px rgba(37, 88, 232, 0.12);
    font-size: 1.1rem;
    line-height: 1;
}

.promo-asset-card {
    grid-column: 1 / -1;
    border: 1px solid rgba(20, 35, 65, 0.1);
    border-radius: 20px;
    background:
        linear-gradient(135deg, rgba(37, 88, 232, 0.1), rgba(16, 185, 129, 0.1)),
        rgba(255, 255, 255, 0.86);
    box-shadow: 0 18px 42px rgba(16, 24, 40, 0.1);
    padding: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.promo-asset-card strong {
    display: block;
    margin-top: 0.16rem;
    font-size: 1rem;
}

.promo-asset-card button {
    min-height: 40px;
    flex: 0 0 auto;
    border-radius: 13px;
    background: linear-gradient(135deg, var(--blue), var(--teal));
    color: var(--white);
    padding: 0.55rem 0.85rem;
    font-weight: 900;
}

.ref-box {
    min-width: min(420px, 44vw);
    max-width: 100%;
    border-radius: 18px;
    padding: 0.75rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.25rem 0.65rem;
    align-items: center;
}

.ref-box span,
.stat-card span,
.wallet-card span {
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.72rem;
    font-weight: 950;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ref-box span {
    grid-column: 1 / -1;
    color: var(--muted);
}

.ref-box strong {
    min-width: 0;
    color: #1d2939;
    font-size: 0.86rem;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.72rem;
}

.stat-card {
    min-width: 0;
    min-height: 92px;
    border-radius: 20px;
    padding: 0.85rem;
    display: grid;
    align-content: space-between;
    overflow: hidden;
}

.stat-card strong {
    color: var(--white);
    font-size: clamp(1.15rem, 2vw, 1.55rem);
    line-height: 1.05;
    overflow-wrap: anywhere;
}

.stat-card.blue { background: linear-gradient(135deg, #2558e8, #0ea5e9); }
.stat-card.teal { background: linear-gradient(135deg, #0f766e, #14b8a6); }
.stat-card.green { background: linear-gradient(135deg, #15803d, #22c55e); }
.stat-card.gold { background: linear-gradient(135deg, #b45309, #f59e0b); }
.stat-card.violet { background: linear-gradient(135deg, #6d28d9, #a855f7); }

.wallet-card {
    grid-column: 2;
    grid-row: 3;
    min-height: 0;
    border-radius: 24px;
    padding: 1rem;
    color: var(--white);
    background:
        linear-gradient(145deg, rgba(21, 42, 116, 0.96), rgba(37, 88, 232, 0.9) 52%, rgba(16, 185, 129, 0.92));
    display: grid;
    gap: 0.75rem;
    align-content: start;
}

.wallet-main {
    display: grid;
    gap: 0.2rem;
}

.wallet-main strong {
    font-size: clamp(2rem, 3.5vw, 3rem);
    line-height: 1;
    overflow-wrap: anywhere;
}

.wallet-mini {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
}

.wallet-mini div {
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.12);
    padding: 0.72rem;
    display: grid;
    gap: 0.2rem;
}

.wallet-mini strong {
    font-size: 1.05rem;
    overflow-wrap: anywhere;
}

.withdraw-form {
    display: grid;
    gap: 0.55rem;
}

.withdraw-form input {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.95);
}

.withdraw-form button {
    background: var(--white);
    color: #1f3f96;
    box-shadow: none;
}

.panel {
    min-width: 0;
    min-height: 0;
    border-radius: 24px;
    padding: 0.85rem;
    overflow: hidden;
}

.settings-panel {
    grid-column: 1 / -1;
    grid-row: 2 / 4;
    align-self: stretch;
}

.settings-form {
    max-width: 560px;
    display: grid;
    gap: 0.8rem;
    margin-top: 1rem;
}

.settings-form small {
    color: var(--muted);
    font-size: 0.75rem;
}

input.locked,
input:disabled {
    color: #667085;
    background: rgba(226, 232, 240, 0.75);
    cursor: not-allowed;
}

.panel h2 {
    margin: 0;
    font-size: 1rem;
    letter-spacing: 0;
}

.withdrawals-panel {
    grid-column: 1;
    grid-row: 3;
    max-height: 100%;
}

.leads-panel {
    grid-column: 1;
    grid-row: 3;
    align-self: start;
    max-height: calc(50% - 0.35rem);
}

.withdrawals-panel {
    align-self: end;
    max-height: calc(50% - 0.35rem);
}

.compact-list {
    min-height: 0;
    display: grid;
    gap: 0.48rem;
    margin-top: 0.62rem;
    overflow: auto;
    scrollbar-width: thin;
}

.list-row {
    min-width: 0;
    border: 1px solid rgba(20, 35, 65, 0.08);
    border-radius: 16px;
    background: rgba(248, 251, 255, 0.88);
    padding: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
}

.list-row div {
    min-width: 0;
}

.list-row strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-row span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lead-row {
    align-items: flex-start;
}

.lead-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.35rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    min-height: 24px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #475569;
    padding: 0.2rem 0.52rem;
    font-size: 0.72rem;
    font-style: normal;
    font-weight: 900;
    text-transform: capitalize;
    white-space: nowrap;
}

.badge.approved { color: #047857; background: #d1fae5; }
.badge.pending { color: #9a5b00; background: #fef3c7; }
.badge.rejected { color: #be123c; background: #ffe4e6; }
.empty-row {
    color: var(--muted);
    padding: 0.8rem;
    border-radius: 16px;
    background: rgba(248, 251, 255, 0.88);
}

@keyframes riseIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes logoFloat {
    from { transform: translateY(0) scale(0.96); }
    to { transform: translateY(-5px) scale(1); }
}

@keyframes headlineShimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 1180px) {
    .auth-stage {
        grid-template-columns: minmax(0, 0.85fr) minmax(340px, 410px);
    }

    .stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .stat-card {
        min-height: 78px;
    }
}

@media (max-width: 900px) {
    html,
    body {
        overflow: auto;
    }

    .affiliate-shell,
    .affiliate-auth,
    .affiliate-dashboard {
        height: auto;
        min-height: 100svh;
    }

    .auth-stage {
        height: auto;
        min-height: 0;
        grid-template-columns: 1fr;
    }

    .program-intro {
        min-height: 260px;
        gap: 1.5rem;
    }

    .intro-copy h1 {
        font-size: clamp(2rem, 8vw, 3.4rem);
    }

    .affiliate-dashboard {
        grid-template-columns: 1fr;
    }

    .side {
        position: sticky;
        top: 0;
        z-index: 4;
        flex-direction: row;
        align-items: center;
        padding: 0.8rem;
    }

    .affiliate-dashboard:has(.settings-panel:not(.hidden)) {
        align-content: start;
    }

    .affiliate-dashboard:has(.settings-panel:not(.hidden)) .main {
        padding-top: 0.45rem;
    }

    .dashboard-grid:has(.settings-panel:not(.hidden)) {
        gap: 0;
    }

    .side-actions {
        display: flex;
        gap: 0.45rem;
    }

    .dashboard-grid {
        height: auto;
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .dash-head,
    .stats,
    .wallet-card,
    .withdrawals-panel,
    .leads-panel,
    .settings-panel {
        grid-column: 1;
        grid-row: auto;
    }

    .ref-box {
        min-width: 0;
        width: 100%;
    }

    .stats {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .stat-card {
        min-height: 82px;
        padding: 0.72rem;
    }

    .stat-card.blue,
    .stat-card.teal,
    .stat-card.green {
        grid-column: span 2;
    }

    .stat-card.gold,
    .stat-card.violet {
        grid-column: span 3;
    }

    .withdrawals-panel,
    .leads-panel {
        max-height: none;
        align-self: auto;
    }
}

@media (max-width: 560px) {
    .affiliate-auth,
    .main {
        padding: 0.7rem;
    }

    .program-intro,
    .auth-panel,
    .wallet-card,
    .panel {
        border-radius: 18px;
    }

    .intro-metrics,
    .dash-head,
    .list-row {
        flex-direction: column;
        align-items: stretch;
    }

    .lead-badges {
        justify-content: flex-start;
    }
}

/* Premium affiliate dashboard refresh */
.affiliate-dashboard {
    height: auto;
    min-height: 100svh;
    display: block;
    background: #f7f8fc;
}

.affiliate-dashboard svg {
    width: 1.25em;
    height: 1.25em;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.35;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.side {
    width: 100%;
    max-width: 1024px;
    margin: 0 auto;
    min-height: 120px;
    border-right: 0;
    border-bottom: 1px solid #e5e7eb;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.04);
    backdrop-filter: blur(18px);
    padding: 1.75rem 2.4rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.brand-mark.compact {
    gap: 1rem;
}

.brand-mark.compact img {
    width: 58px;
    height: 58px;
    border-radius: 20px;
    box-shadow: 0 16px 30px rgba(124, 58, 237, 0.22);
}

.brand-mark.compact strong {
    color: #111827;
    font-size: 1.9rem;
    line-height: 1;
    font-weight: 900;
}

.brand-mark.compact small {
    margin-top: 0.18rem;
    color: #6b7280;
    font-size: 1rem;
    line-height: 1;
    font-weight: 900;
    letter-spacing: 0.11em;
}

.side-actions {
    display: flex;
    gap: 1.25rem;
}

.ghost-btn {
    min-height: 68px;
    border: 1px solid #d7dce8;
    border-radius: 16px;
    background: #ffffff;
    color: #7c3aed;
    padding: 0 1.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 1.35rem;
    font-weight: 850;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}

.main {
    width: 100%;
    max-width: 1024px;
    margin: 0 auto;
    min-height: 0;
    padding: 1.9rem 2.4rem 1.4rem;
}

.dashboard-grid {
    height: auto;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-rows: auto;
    gap: 1.5rem;
}

.dash-head {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 1rem;
}

.dash-user-block {
    min-width: 0;
}

.dash-head .eyebrow {
    color: #7c3aed;
    font-size: 1.05rem;
    font-weight: 900;
    letter-spacing: 0.13em;
}

.affiliate-title-row {
    margin-top: 0.55rem;
}

.affiliate-title-row h1 {
    color: #111827;
    font-size: clamp(2.35rem, 5vw, 2.625rem);
    line-height: 1;
    font-weight: 900;
}

.promo-asset-btn {
    width: 74px;
    height: 74px;
    border: 1px solid #dfe3ed;
    border-radius: 20px;
    background: #ffffff;
    color: #7c3aed;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
    display: grid;
    place-items: center;
    font-size: 1rem;
}

.promo-asset-btn svg {
    width: 2.1rem;
    height: 2.1rem;
}

.ref-box {
    grid-column: 1 / -1;
    width: 100%;
    min-width: 0;
    border: 0;
    border-radius: 24px;
    background: #ffffff;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    padding: 1.85rem 2rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem;
}

.ref-box span {
    grid-column: 1 / -1;
    color: #6b7280;
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: 0.09em;
}

.ref-box strong {
    color: #111827;
    font-size: clamp(1.15rem, 2.6vw, 1.75rem);
    font-weight: 850;
    line-height: 1.2;
}

.ref-box button {
    min-height: 72px;
    border: 2px solid #7c3aed;
    border-radius: 18px;
    background: #ffffff;
    color: #7c3aed;
    padding: 0 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.7rem;
    font-size: 1.45rem;
    font-weight: 900;
}

.stats {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 1.35rem;
}

.stat-card {
    min-height: 158px;
    border: 0;
    border-radius: 24px;
    background: #ffffff !important;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    padding: 2rem;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 1.25rem;
    align-content: center;
    align-items: center;
}

.stat-card.blue,
.stat-card.teal,
.stat-card.green {
    grid-column: span 2;
}

.stat-card.gold,
.stat-card.violet {
    grid-column: span 3;
    min-height: 152px;
    border: 1px solid transparent;
}

.stat-card.gold { border-color: #bbf7d0; }
.stat-card.violet { border-color: #e9d5ff; }

.stat-card i {
    grid-row: 1 / 3;
    width: 78px;
    height: 78px;
    border-radius: 22px;
    display: grid;
    place-items: center;
}

.stat-card i svg {
    width: 2.2rem;
    height: 2.2rem;
}

.stat-card.blue i { color: #2563eb; background: #eef2ff; }
.stat-card.teal i { color: #06b6d4; background: #ecfeff; }
.stat-card.green i { color: #22c55e; background: #ecfdf5; }
.stat-card.gold i { color: #22c55e; background: #dcfce7; border-radius: 50%; }
.stat-card.violet i { color: #7c3aed; background: #f3e8ff; border-radius: 50%; }

.stat-card span {
    color: #667085;
    font-size: 1rem;
    font-weight: 850;
    letter-spacing: 0;
}

.stat-card strong {
    margin-top: 0.35rem;
    font-size: 2.35rem;
    line-height: 1;
    font-weight: 900;
}

.stat-card.blue strong { color: #2563eb; }
.stat-card.teal strong { color: #06b6d4; }
.stat-card.green strong { color: #22c55e; }
.stat-card.gold strong { color: #22c55e; }
.stat-card.violet strong { color: #7c3aed; }

.wallet-card {
    grid-column: 1 / -1;
    grid-row: auto;
    border: 0;
    border-radius: 32px;
    background: linear-gradient(135deg, #312eed 0%, #5b21b6 50%, #8b5cf6 100%);
    box-shadow: 0 28px 60px rgba(91, 33, 182, 0.24);
    padding: 1.9rem 2rem 1.35rem;
    color: #ffffff;
    display: grid;
    gap: 1.35rem;
}

.wallet-card span {
    color: rgba(255, 255, 255, 0.92);
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: 0.04em;
}

.wallet-main strong {
    margin-top: 0.35rem;
    color: #ffffff;
    font-size: clamp(4rem, 8vw, 4.5rem);
    line-height: 0.95;
    font-weight: 900;
}

.wallet-mini {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.wallet-mini div {
    min-height: 98px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    padding: 1.1rem 1.25rem;
}

.wallet-mini strong {
    color: #ffffff;
    font-size: 1.65rem;
    font-weight: 900;
}

.withdraw-form {
    display: grid;
    gap: 1rem;
}

.withdraw-form input {
    min-height: 68px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 18px;
    background: #ffffff;
    color: #111827;
    padding: 0 1.65rem;
    font-size: 1.4rem;
}

.withdraw-form button {
    min-height: 70px;
    border: 1px solid rgba(255, 255, 255, 0.36);
    border-radius: 18px;
    background: linear-gradient(90deg, #5b21b6, #7c3aed, #8b5cf6);
    color: #ffffff;
    box-shadow: 0 18px 42px rgba(124, 58, 237, 0.32);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    font-size: 1.3rem;
    font-weight: 900;
}

.withdrawals-panel {
    grid-column: 1 / -1;
    grid-row: auto;
    align-self: auto;
    max-height: none;
    border: 0;
    border-radius: 24px;
    background: #ffffff;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
    padding: 1.45rem 2rem;
}

.panel h2 {
    color: #111827;
    font-size: 1.55rem;
    font-weight: 900;
}

.compact-list {
    margin-top: 0.75rem;
    overflow: visible;
}

.empty-row {
    background: transparent;
    color: #8a91a3;
    padding: 0;
    font-size: 1.35rem;
}

.leads-panel {
    display: none;
}

.promo-asset-card {
    border: 0;
    border-radius: 24px;
    background: #ffffff;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

@media (max-width: 900px) {
    html,
    body {
        overflow: auto;
    }

    .affiliate-dashboard {
        min-height: 100svh;
    }

    .side {
        position: static;
        padding: 1.65rem 1.5rem;
        min-height: 120px;
    }

    .main {
        padding: 1.75rem 1.5rem 1.4rem;
    }

    .dashboard-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 1.35rem;
    }

    .dash-head,
    .stats,
    .wallet-card,
    .withdrawals-panel,
    .settings-panel,
    .promo-asset-card {
        grid-column: 1 / -1;
    }

    .dash-head {
        grid-template-columns: 1fr auto;
    }

    .ref-box {
        grid-column: 1 / -1;
    }
}

@media (max-width: 680px) {
    .side {
        padding: 1.35rem 1rem;
    }

    .brand-mark.compact img {
        width: 52px;
        height: 52px;
    }

    .brand-mark.compact strong {
        font-size: 1.55rem;
    }

    .brand-mark.compact small {
        font-size: 0.82rem;
    }

    .side-actions {
        gap: 0.55rem;
    }

    .ghost-btn {
        min-height: 54px;
        border-radius: 15px;
        padding: 0 0.9rem;
        font-size: 1rem;
        gap: 0.45rem;
    }

    .ghost-btn svg {
        width: 1.2rem;
        height: 1.2rem;
    }

    .main {
        padding: 1.25rem 1rem;
    }

    .dash-head {
        grid-template-columns: 1fr auto;
        align-items: end;
    }

    .affiliate-title-row h1 {
        font-size: 2.625rem;
    }

    .promo-asset-btn {
        width: 74px;
        height: 74px;
    }

    .ref-box {
        padding: 1.55rem 2rem;
    }

    .ref-box button {
        min-height: 72px;
        padding: 0 1.35rem;
    }

    .stat-card.blue,
    .stat-card.teal,
    .stat-card.green {
        grid-column: span 2;
    }

    .stat-card.gold,
    .stat-card.violet {
        grid-column: span 3;
    }

    .stat-card {
        min-height: 156px;
        padding: 1.75rem;
        grid-template-columns: auto minmax(0, 1fr);
    }

    .stat-card i {
        width: 78px;
        height: 78px;
    }

    .stat-card span {
        font-size: 0.95rem;
    }

    .stat-card strong {
        font-size: 2.2rem;
    }

    .wallet-card {
        padding: 1.9rem 2rem 1.35rem;
    }
}

@media (max-width: 430px) {
    .side {
        gap: 0.75rem;
    }

    .side-actions {
        flex-shrink: 0;
    }

    .ghost-btn span {
        display: none;
    }

    .ghost-btn {
        width: 52px;
        padding: 0;
        justify-content: center;
    }

    .affiliate-title-row h1 {
        font-size: 2.25rem;
    }

    .promo-asset-btn {
        width: 58px;
        height: 58px;
        border-radius: 18px;
    }

    .ref-box {
        padding: 1.3rem;
        grid-template-columns: 1fr;
    }

    .ref-box button {
        width: 100%;
    }

    .stat-card {
        min-height: 130px;
        padding: 1rem;
        grid-template-columns: 1fr;
        gap: 0.55rem;
    }

    .stat-card i {
        width: 56px;
        height: 56px;
        border-radius: 18px;
    }

    .stat-card i svg {
        width: 1.65rem;
        height: 1.65rem;
    }

    .stat-card span {
        font-size: 0.78rem;
    }

    .stat-card strong {
        font-size: 1.85rem;
    }

    .wallet-card {
        padding: 1.4rem;
    }

    .wallet-mini {
        gap: 0.8rem;
    }

    .wallet-mini div {
        padding: 0.9rem;
    }
}

/* Responsive density fix: keep the current palette, reduce oversized layout, and show leads. */
html,
body {
    overflow: auto;
}

.affiliate-dashboard {
    min-height: 100svh;
}

.side {
    max-width: 1180px;
    min-height: 72px;
    padding: 0.8rem 1.25rem;
}

.brand-mark.compact {
    gap: 0.72rem;
}

.brand-mark.compact img {
    width: 42px;
    height: 42px;
    border-radius: 14px;
}

.brand-mark.compact strong {
    font-size: 1.18rem;
}

.brand-mark.compact small {
    font-size: 0.72rem;
    letter-spacing: 0.08em;
}

.side-actions {
    gap: 0.65rem;
}

.ghost-btn {
    min-height: 42px;
    border-radius: 12px;
    padding: 0 0.9rem;
    gap: 0.45rem;
    font-size: 0.9rem;
}

.main {
    max-width: 1180px;
    padding: 1rem 1.25rem 1.25rem;
}

.dashboard-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 0.85rem;
}

.dash-head {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
    align-items: center;
    gap: 0.85rem;
}

.dash-head .eyebrow {
    font-size: 0.74rem;
    letter-spacing: 0.11em;
}

.affiliate-title-row {
    margin-top: 0.25rem;
    justify-content: flex-start;
}

.affiliate-title-row h1 {
    font-size: clamp(1.45rem, 2.2vw, 2rem);
}

.promo-asset-btn {
    width: 42px;
    height: 42px;
    border-radius: 13px;
}

.promo-asset-btn svg {
    width: 1.25rem;
    height: 1.25rem;
}

.ref-box {
    grid-column: auto;
    border-radius: 18px;
    padding: 0.8rem 0.9rem;
    gap: 0.45rem 0.65rem;
}

.ref-box span {
    font-size: 0.72rem;
}

.ref-box strong {
    font-size: 0.88rem;
}

.ref-box button {
    min-height: 42px;
    border-width: 1px;
    border-radius: 13px;
    padding: 0 0.85rem;
    gap: 0.42rem;
    font-size: 0.9rem;
}

.stats {
    grid-column: 1 / 9;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.75rem;
}

.stat-card {
    min-height: 94px;
    border-radius: 18px;
    padding: 0.85rem;
    column-gap: 0.75rem;
}

.stat-card.blue,
.stat-card.teal,
.stat-card.green {
    grid-column: span 2;
}

.stat-card.gold,
.stat-card.violet {
    grid-column: span 3;
    min-height: 94px;
}

.stat-card i {
    width: 44px;
    height: 44px;
    border-radius: 14px;
}

.stat-card i svg {
    width: 1.35rem;
    height: 1.35rem;
}

.stat-card span {
    font-size: 0.72rem;
}

.stat-card strong {
    margin-top: 0.18rem;
    font-size: clamp(1.25rem, 2vw, 1.7rem);
}

.wallet-card {
    grid-column: 9 / -1;
    grid-row: 2 / 4;
    border-radius: 22px;
    padding: 1rem;
    gap: 0.8rem;
}

.wallet-card span {
    font-size: 0.74rem;
}

.wallet-main strong {
    margin-top: 0.18rem;
    font-size: clamp(2.25rem, 4.5vw, 3.2rem);
}

.wallet-mini {
    gap: 0.55rem;
}

.wallet-mini div {
    min-height: 68px;
    border-radius: 15px;
    padding: 0.65rem;
}

.wallet-mini strong {
    font-size: 1.05rem;
}

.withdraw-form {
    gap: 0.55rem;
}

.withdraw-form input,
.withdraw-form button {
    min-height: 46px;
    border-radius: 14px;
    font-size: 0.9rem;
}

.withdraw-form input {
    padding: 0 0.85rem;
}

.withdraw-form button {
    gap: 0.45rem;
}

.withdrawals-panel,
.leads-panel,
.promo-asset-card {
    border-radius: 20px;
    padding: 0.9rem;
}

.withdrawals-panel {
    grid-column: 1 / 5;
}

.leads-panel {
    display: block;
    grid-column: 5 / 9;
    grid-row: auto;
    align-self: auto;
    max-height: none;
    border: 0;
    background: #ffffff;
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
}

.panel h2 {
    font-size: 1.05rem;
}

.compact-list {
    display: grid;
    gap: 0.45rem;
    margin-top: 0.55rem;
    overflow: auto;
    max-height: 260px;
}

.list-row {
    border-radius: 14px;
    padding: 0.58rem 0.65rem;
    gap: 0.55rem;
}

.list-row strong {
    font-size: 0.88rem;
}

.list-row span {
    font-size: 0.73rem;
}

.badge {
    min-height: 22px;
    padding: 0.16rem 0.48rem;
    font-size: 0.68rem;
}

.empty-row {
    padding: 0.55rem 0;
    font-size: 0.88rem;
}

.promo-asset-card {
    grid-column: 1 / -1;
    padding: 0.85rem 0.95rem;
}

.settings-panel {
    grid-column: 1 / -1;
    grid-row: auto;
}

@media (max-width: 980px) {
    .side,
    .main {
        max-width: 760px;
    }

    .dash-head {
        grid-template-columns: 1fr;
    }

    .stats,
    .wallet-card,
    .withdrawals-panel,
    .leads-panel {
        grid-column: 1 / -1;
        grid-row: auto;
    }

    .wallet-card {
        grid-template-columns: minmax(0, 1fr) minmax(220px, 0.8fr);
        align-items: start;
    }

    .wallet-mini,
    .withdraw-form {
        grid-column: 2;
    }
}

@media (max-width: 680px) {
    .side {
        min-height: 64px;
        padding: 0.75rem 0.9rem;
    }

    .brand-mark.compact img {
        width: 38px;
        height: 38px;
    }

    .brand-mark.compact strong {
        font-size: 1.05rem;
    }

    .brand-mark.compact small {
        font-size: 0.66rem;
    }

    .ghost-btn {
        min-height: 40px;
        padding: 0 0.72rem;
        font-size: 0.84rem;
    }

    .main {
        padding: 0.8rem 0.9rem 1rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 0.7rem;
    }

    .affiliate-title-row {
        justify-content: space-between;
    }

    .affiliate-title-row h1 {
        font-size: 1.65rem;
    }

    .ref-box {
        grid-template-columns: 1fr auto;
    }

    .stats {
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: 0.55rem;
    }

    .stat-card {
        min-height: 98px;
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-rows: auto auto;
        align-content: center;
        align-items: center;
        column-gap: 0.5rem;
        padding: 0.62rem;
    }

    .stat-card.blue,
    .stat-card.teal,
    .stat-card.green {
        grid-column: span 2;
    }

    .stat-card.gold,
    .stat-card.violet {
        grid-column: span 3;
        min-height: 108px;
    }

    .stat-card i,
    .stat-card.gold i,
    .stat-card.violet i {
        grid-row: 1 / 3;
    }

    .stat-card i {
        width: 40px;
        height: 40px;
        border-radius: 12px;
    }

    .stat-card i svg {
        width: 1.02rem;
        height: 1.02rem;
    }

    .stat-card span {
        font-size: 0.6rem;
        line-height: 1.15;
    }

    .stat-card strong {
        font-size: 1.22rem;
    }

    .wallet-card {
        grid-template-columns: 1fr;
    }

    .wallet-mini,
    .withdraw-form {
        grid-column: auto;
    }

    .wallet-main strong {
        font-size: 2.4rem;
    }

    .compact-list {
        max-height: none;
    }
}

@media (max-width: 430px) {
    .side-actions {
        gap: 0.4rem;
    }

    .ghost-btn {
        width: 42px;
        min-height: 40px;
        border-radius: 12px;
    }

    #backToDashboardBtn {
        width: auto;
        min-width: 92px;
        padding: 0 0.75rem;
        white-space: nowrap;
    }

    .settings-panel .panel-head {
        align-items: center;
        gap: 0.55rem;
    }

    .promo-asset-btn {
        width: 42px;
        height: 42px;
        border-radius: 13px;
    }

    .ref-box {
        padding: 0.8rem;
    }

    .ref-box button {
        width: auto;
        min-height: 40px;
        font-size: 0.84rem;
    }

    .stat-card,
    .stat-card.blue,
    .stat-card.teal,
    .stat-card.green,
    .stat-card.gold,
    .stat-card.violet {
        min-height: 78px;
        grid-template-columns: auto minmax(0, 1fr);
        grid-template-rows: auto auto;
        align-content: center;
        align-items: center;
        column-gap: 0.42rem;
        padding: 0.52rem;
    }

    .stat-card.blue,
    .stat-card.teal,
    .stat-card.green {
        grid-column: span 2;
    }

    .stat-card.gold,
    .stat-card.violet {
        grid-column: span 3;
    }

    .stat-card i {
        width: 30px;
        height: 30px;
        border-radius: 10px;
    }

    .stat-card i svg {
        width: 0.88rem;
        height: 0.88rem;
    }

    .stat-card span {
        font-size: 0.52rem;
    }

    .stat-card strong {
        font-size: 1.02rem;
    }

    .wallet-mini {
        grid-template-columns: 1fr 1fr;
    }

    .lead-row,
    .list-row {
        align-items: stretch;
    }

    .lead-badges {
        justify-content: flex-start;
    }
}
