:root {
    --bg: #eef3f8;
    --ink: #111827;
    --muted: #64748b;
    --surface: rgba(255, 255, 255, 0.88);
    --surface-solid: #ffffff;
    --line: #d8e2ee;
    --line-strong: #bdcadb;
    --blue: #2457d6;
    --blue-deep: #193a8a;
    --teal: #0f9f8f;
    --green: #16a34a;
    --amber: #b7791f;
    --red: #dc2626;
    --shadow: 0 24px 70px rgba(17, 24, 39, 0.13);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        linear-gradient(135deg, rgba(36, 87, 214, 0.14), transparent 34%),
        linear-gradient(315deg, rgba(15, 159, 143, 0.14), transparent 32%),
        var(--bg);
}

button, input, textarea {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

.hidden { display: none !important; }
.affiliate-shell { min-height: 100vh; }

.boot-loader {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    background:
        linear-gradient(135deg, rgba(36, 87, 214, 0.16), transparent 38%),
        linear-gradient(315deg, rgba(15, 159, 143, 0.15), transparent 34%),
        var(--bg);
}

.boot-loader img {
    width: 60px;
    height: 60px;
    animation: logoPulse 900ms ease-in-out infinite alternate;
}

.affiliate-booting .affiliate-auth,
.affiliate-booting .affiliate-dashboard {
    visibility: hidden;
}

.affiliate-auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
}

.auth-stage {
    width: min(1120px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1fr) 460px;
    gap: 1.5rem;
    align-items: stretch;
}

.program-intro,
.auth-panel,
.panel,
.notice,
.ref-box,
.stats div {
    border: 1px solid rgba(216, 226, 238, 0.9);
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.program-intro {
    border-radius: 18px;
    padding: 2rem;
    min-height: 640px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.program-intro::after {
    content: "";
    position: absolute;
    inset: auto -8rem -8rem auto;
    width: 22rem;
    height: 22rem;
    background: linear-gradient(135deg, rgba(36, 87, 214, 0.18), rgba(15, 159, 143, 0.12));
    transform: rotate(18deg);
    border-radius: 4rem;
}

.brand-mark {
    width: fit-content;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--ink);
    text-decoration: none;
    font-size: 1.05rem;
    font-weight: 900;
    letter-spacing: 0;
}

.brand-mark img {
    width: 42px;
    height: 42px;
    filter: drop-shadow(0 10px 18px rgba(36, 87, 214, 0.18));
}

.brand-mark.compact {
    margin: 0;
    max-width: 100%;
}

.brand-mark.compact img {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
}

.brand-mark.compact span {
    min-width: 0;
    display: grid;
    gap: 0.05rem;
    line-height: 1.05;
}

.brand-mark.compact strong {
    font-size: 0.98rem;
    white-space: nowrap;
}

.brand-mark.compact small {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.intro-copy {
    position: relative;
    z-index: 1;
    max-width: 680px;
    animation: riseIn 500ms ease both;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    color: var(--blue-deep);
    font-size: 0.76rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.intro-copy h1 {
    margin: 0.65rem 0 0;
    max-width: 740px;
    font-size: clamp(2.1rem, 5vw, 4.2rem);
    line-height: 0.98;
    letter-spacing: 0;
}

.intro-copy p {
    margin: 1rem 0 0;
    max-width: 560px;
    color: #40506a;
    font-size: 1.04rem;
    line-height: 1.7;
}

.intro-metrics {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.intro-metrics div {
    min-height: 112px;
    border: 1px solid rgba(189, 202, 219, 0.72);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.62);
    padding: 1rem;
    display: grid;
    align-content: end;
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.intro-metrics div:hover {
    transform: translateY(-3px);
    border-color: rgba(36, 87, 214, 0.4);
    background: rgba(255, 255, 255, 0.82);
}

.intro-metrics strong {
    font-size: 1.35rem;
    color: var(--blue-deep);
}

.intro-metrics span {
    margin-top: 0.2rem;
    color: var(--muted);
    font-size: 0.84rem;
    line-height: 1.35;
}

.auth-panel {
    border-radius: 18px;
    padding: 1rem;
    align-self: start;
    animation: riseIn 620ms ease both;
}

.tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    border: 1px solid var(--line);
    background: #edf3fb;
    border-radius: 12px;
    padding: 0.35rem;
    margin-bottom: 1rem;
}

.tab {
    min-height: 42px;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-weight: 900;
    transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.tab.active {
    color: var(--blue-deep);
    background: #ffffff;
    box-shadow: 0 8px 20px rgba(17, 24, 39, 0.08);
}

.auth-form {
    display: grid;
    gap: 0.85rem;
}

label {
    display: grid;
    gap: 0.38rem;
    color: #334155;
    font-size: 0.84rem;
    font-weight: 800;
}

input,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.86);
    color: var(--ink);
    padding: 0.78rem 0.85rem;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

input:focus,
textarea:focus {
    border-color: rgba(36, 87, 214, 0.72);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(36, 87, 214, 0.12);
}

textarea {
    min-height: 92px;
    resize: vertical;
}

.url-head,
.panel-head,
.dash-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.url-head span {
    color: #334155;
    font-size: 0.84rem;
    font-weight: 900;
}

.url-head button,
.ghost-btn,
.ref-box button {
    min-height: 38px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--blue-deep);
    padding: 0.55rem 0.75rem;
    font-weight: 900;
    transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.url-head button:hover,
.ghost-btn:hover,
.ref-box button:hover {
    transform: translateY(-1px);
    border-color: rgba(36, 87, 214, 0.45);
    box-shadow: 0 10px 24px rgba(36, 87, 214, 0.12);
}

.url-fields {
    display: grid;
    gap: 0.7rem;
}

.primary-btn,
.withdraw-form button {
    min-height: 46px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--blue), var(--teal));
    color: #ffffff;
    padding: 0.82rem 1rem;
    font-weight: 900;
    box-shadow: 0 14px 30px rgba(36, 87, 214, 0.24);
    transition: transform 150ms ease, box-shadow 150ms ease;
}

.primary-btn:hover,
.withdraw-form button:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 38px rgba(36, 87, 214, 0.28);
}

.message {
    min-height: 1.2rem;
    margin: 0.85rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.message.error { color: var(--red); }
.message.success { color: var(--green); }

.affiliate-dashboard {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
}

.side {
    border-right: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(18px);
    padding: 1.35rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    justify-content: space-between;
}

.main {
    padding: 1.5rem;
    overflow: auto;
}

.notice {
    max-width: 720px;
    border-radius: 18px;
    padding: 1.6rem;
    animation: riseIn 420ms ease both;
}

.notice h1,
.dash-head h1,
.panel h2 {
    margin: 0.25rem 0 0;
    letter-spacing: 0;
}

.notice h1 { font-size: clamp(2rem, 4vw, 3.4rem); }
.notice p,
.dash-head p {
    margin: 0.5rem 0 0;
    color: var(--muted);
}

.dash-head {
    align-items: stretch;
    margin-bottom: 1rem;
}

.dash-head h1 {
    font-size: clamp(1.8rem, 3vw, 2.6rem);
}

.ref-box {
    min-width: min(440px, 100%);
    border-radius: 16px;
    padding: 1rem;
    display: grid;
    gap: 0.4rem;
    box-shadow: 0 16px 42px rgba(17, 24, 39, 0.09);
}

.ref-box span,
.stats span {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ref-box strong {
    word-break: break-all;
    font-size: 0.92rem;
    line-height: 1.45;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.9rem;
    margin-bottom: 1rem;
}

.stats div {
    min-height: 112px;
    border-radius: 16px;
    padding: 1rem;
    display: grid;
    align-content: space-between;
    box-shadow: 0 16px 42px rgba(17, 24, 39, 0.08);
    transition: transform 180ms ease, border-color 180ms ease;
}

.stats div:hover {
    transform: translateY(-3px);
    border-color: rgba(36, 87, 214, 0.38);
}

.stats strong {
    font-size: 1.55rem;
    line-height: 1.1;
}

.panel {
    border-radius: 16px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 16px 42px rgba(17, 24, 39, 0.08);
}

.panel h2 {
    font-size: 1.1rem;
}

.withdraw-form {
    display: flex;
    gap: 0.5rem;
}

.withdraw-form input {
    width: 190px;
}

.table-wrap {
    overflow-x: auto;
    margin-top: 0.75rem;
}

table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 0.85rem 0.75rem;
    text-align: left;
}

th {
    color: var(--muted);
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    color: #273449;
    font-size: 0.92rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0.2rem 0.55rem;
    border-radius: 7px;
    background: #e2e8f0;
    color: #475569;
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: capitalize;
}

.badge.approved,
.badge.paid,
.badge.converted {
    color: var(--green);
    background: #dcfce7;
}

.badge.pending {
    color: var(--amber);
    background: #fef3c7;
}

.badge.rejected,
.badge.suspended {
    color: var(--red);
    background: #fee2e2;
}

@keyframes riseIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes logoPulse {
    from {
        transform: translateY(0) scale(0.96);
        opacity: 0.72;
    }
    to {
        transform: translateY(-4px) scale(1);
        opacity: 1;
    }
}

@media (max-width: 940px) {
    .auth-stage {
        grid-template-columns: 1fr;
    }

    .program-intro {
        min-height: auto;
        gap: 2rem;
    }
}

@media (max-width: 760px) {
    .affiliate-auth {
        padding: 1rem;
        align-items: start;
    }

    .program-intro,
    .auth-panel {
        border-radius: 14px;
    }

    .intro-metrics {
        grid-template-columns: 1fr;
    }

    .intro-copy h1 {
        font-size: 2rem;
        line-height: 1.05;
    }

    .affiliate-dashboard {
        grid-template-columns: 1fr;
    }

    .side {
        position: sticky;
        top: 0;
        z-index: 2;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .main {
        padding: 1rem;
    }

    .dash-head,
    .panel-head {
        flex-direction: column;
        align-items: stretch;
    }

    .withdraw-form {
        flex-direction: column;
    }

    .withdraw-form input {
        width: 100%;
    }
}
