@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap");

/* =============================================
   DESIGN TOKENS
   ============================================= */
:root {
    --primary: #1235AE;
    --primary-dark: #0d2880;
    --primary-light: #dde5f9;
    --primary-50: #eef1fc;
    --bg: #f0f4fb;
    --surface: #ffffff;
    --border: #dde5f9;
    --border-focus: #8fa8e8;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --success: #10b981;
    --success-light: #d1fae5;
    --success-text: #065f46;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --warning-text: #92400e;
    --danger: #ef4444;
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 3px rgba(18, 53, 174, 0.07), 0 2px 8px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 20px rgba(18, 53, 174, 0.12), 0 2px 8px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 10px 40px rgba(18, 53, 174, 0.16), 0 4px 16px rgba(15, 23, 42, 0.08);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =============================================
   RESET & BASE
   ============================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Plus Jakarta Sans", "Lexend", sans-serif;
    overflow-x: hidden;
    background-color: var(--bg);
    font-weight: 400;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

img {
    width: 100%;
    display: block;
}

a {
    color: var(--primary);
    text-decoration: none;
}

/* =============================================
   TYPOGRAPHY
   ============================================= */
h1 {
    font-size: 34px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.3;
    letter-spacing: -0.02em;
    margin-bottom: 12px;
}

h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* =============================================
   FORM ELEMENTS — BASE
   ============================================= */
input,
textarea {
    display: block;
    font-family: inherit;
    width: 100%;
    padding: 13px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    cursor: text;
    outline: none;
    transition: var(--transition);
    background: var(--surface);
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 400;
}

button {
    display: block;
    font-family: inherit;
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    outline: none;
    transition: var(--transition);
    font-size: 15px;
}

input:focus,
textarea:focus {
    border-color: var(--primary);
    background-color: var(--primary-50);
    box-shadow: 0 0 0 4px rgba(18, 53, 174, 0.1);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

select {
    width: 100%;
    padding: 13px 44px 13px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--surface);
    font-size: 15px;
    font-family: inherit;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: var(--transition);
    cursor: pointer;
    color: var(--text-primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231235AE' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 18px;
    font-weight: 400;
}

select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px rgba(18, 53, 174, 0.1);
    background-color: var(--primary-50);
}

select option {
    color: var(--text-primary);
    font-weight: 400;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 7px;
    font-size: 13.5px;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

/* =============================================
   INPUT ICON WRAPPER
   ============================================= */
.input-wrapper {
    position: relative;
}

.input-wrapper .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 15px;
    pointer-events: none;
    z-index: 1;
    line-height: 1;
}

.input-wrapper input,
.input-wrapper select {
    padding-left: 44px;
}

/* Show/hide password */
.toggle-pw {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 16px;
    background: none;
    border: none;
    width: auto;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
    transition: var(--transition);
    line-height: 1;
}

.toggle-pw:hover {
    opacity: 1;
}

/* =============================================
   AFFILIATE SPLIT LAYOUT (login + registration)
   ============================================= */
.affiliate {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg);
}

.form {
    width: 50%;
    min-height: 100vh;
    background-color: var(--surface);
    padding: 56px 72px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Accent top border — solid brand color */
.form::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary);
}

/* Subtle corner decoration */
.form::after {
    content: '';
    position: absolute;
    bottom: -60px;
    right: -60px;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(18, 53, 174, 0.04) 0%, transparent 70%);
    pointer-events: none;
}

/* =============================================
   FORM BUTTON (CTA)
   ============================================= */
.form button[type="submit"],
.form button:not(.toggle-pw):not(.btn-logout) {
    background: var(--primary);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.01em;
    transition: var(--transition);
    cursor: pointer;
    color: #fff;
    border: none;
    box-shadow: 0 4px 18px rgba(18, 53, 174, 0.3);
    position: relative;
    overflow: hidden;
    margin-top: 8px;
}

.form button[type="submit"]:hover,
.form button:not(.toggle-pw):not(.btn-logout):hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(18, 53, 174, 0.4);
}

.form button[type="submit"]:active,
.form button:not(.toggle-pw):not(.btn-logout):active {
    transform: translateY(0);
    box-shadow: 0 4px 18px rgba(18, 53, 174, 0.3);
}

/* =============================================
   FORM STRUCTURE
   ============================================= */
.form .form-control {
    margin-bottom: 18px;
}

.form-header {
    margin-bottom: 32px;
}

.form-header .subtitle {
    color: var(--text-muted);
    font-size: 16px;
    margin-top: 8px;
    line-height: 1.6;
}

.form-note {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

/* =============================================
   LOGO ROW
   ============================================= */
.logo {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 32px;
    margin-bottom: 48px;
    padding-bottom: 32px;
    border-bottom: 1px solid var(--border);
}

.logo a {
    width: 28%;
    max-width: 120px;
    transition: var(--transition);
    filter: grayscale(15%) opacity(0.85);
    flex-shrink: 0;
}

.logo a:hover {
    filter: none;
    transform: translateY(-2px);
}

/* =============================================
   THUMB (HERO SIDE)
   ============================================= */
.thumb {
    width: 50%;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.thumb::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(18, 53, 174, 0.72);
    z-index: 1;
}

.thumb img,
.thumb2 img {
    height: 100%;
    width: 100%;
    object-fit: cover;
}

.thumb .hero-text {
    position: absolute;
    bottom: 56px;
    left: 48px;
    right: 48px;
    z-index: 2;
    color: white;
}

.thumb .hero-text h2 {
    font-size: 34px;
    font-weight: 800;
    color: white;
    margin-bottom: 16px;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.thumb .hero-text p {
    font-size: 15.5px;
    color: rgba(255, 255, 255, 0.82);
    line-height: 1.7;
    margin-bottom: 0;
}

.hero-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
}

.hero-badge {
    background: rgba(255, 255, 255, 0.18);
    color: white;
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: inline-block;
}

/* =============================================
   LOADING SPINNER
   ============================================= */
svg {
    width: 3.25em;
    transform-origin: center;
    animation: rotate4 2s linear infinite;
}

circle {
    fill: none;
    stroke: var(--primary);
    stroke-width: 2.5;
    stroke-dasharray: 1, 200;
    stroke-dashoffset: 0;
    stroke-linecap: round;
    animation: dash4 1.5s ease-in-out infinite;
}

@keyframes rotate4 {
    100% { transform: rotate(360deg); }
}

@keyframes dash4 {
    0% { stroke-dasharray: 1, 200; stroke-dashoffset: 0; }
    50% { stroke-dasharray: 90, 200; stroke-dashoffset: -35px; }
    100% { stroke-dashoffset: -125px; }
}

/* Full-screen loading overlay */
.loading {
    position: fixed;
    inset: 0;
    background-color: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 9999;
}

.loading-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.loading.active {
    opacity: 1;
    pointer-events: all;
}

/* Inline loading (within page) */
.loading2 {
    text-align: center;
    padding: 48px 24px;
    opacity: 0;
    transform: translateY(-12px);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    display: none;
}

.loading2.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    display: block;
}

.loading2 svg {
    width: 2.5em;
    display: block;
    margin: 0 auto 12px;
}

.loading2-label {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 8px;
}

/* =============================================
   404 & THANK YOU PAGES
   ============================================= */
.page404 {
    max-width: 480px;
    margin: 0 auto;
    padding: 80px 24px;
    text-align: center;
}

.page404 h1 {
    font-size: 32px;
    margin-bottom: 16px;
    color: var(--primary);
    letter-spacing: -0.02em;
}

.page404 p {
    color: var(--text-secondary);
    font-size: 17px;
    margin-bottom: 28px;
    line-height: 1.7;
}

.page404 .thank {
    width: 64%;
    margin: 0 auto 32px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.page404 .logo {
    justify-content: center;
    border: none;
    padding: 0;
    margin-top: 36px;
    margin-bottom: 0;
    gap: 32px;
}

.page404 .logo a {
    width: 25%;
    max-width: 100px;
}

/* Back button */
.btn-back {
    display: inline-block;
    padding: 12px 28px;
    background: var(--primary);
    color: white;
    text-decoration: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 15px;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(18, 53, 174, 0.3);
    margin-top: 8px;
    width: auto;
}

.btn-back:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(18, 53, 174, 0.4);
    color: white;
}

/* Thank you page card */
.thank-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    animation: floatUp 0.6s ease-out both;
}

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

/* =============================================
   RESPONSIVE — SPLIT LAYOUT
   ============================================= */
@media (max-width: 991px) {
    .affiliate {
        display: block;
    }

    .form {
        width: 100%;
        min-height: 100vh;
        padding: 48px 36px;
        justify-content: flex-start;
        padding-top: 48px;
    }

    .thumb {
        display: none;
    }

    .page404 {
        width: 90%;
    }
}

@media (max-width: 575px) {
    .form {
        padding: 36px 20px;
    }

    h1 { font-size: 24px; }

    .logo {
        margin-bottom: 32px;
        padding-bottom: 24px;
    }
}

/* =============================================
   TABLES
   ============================================= */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}

th, td {
    padding: 13px 16px;
    text-align: left;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--primary);
    color: white;
    font-weight: 600;
    font-size: 12.5px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

td {
    font-weight: 400;
    color: var(--text-primary);
    vertical-align: middle;
}

tbody tr {
    transition: background-color 0.15s ease;
}

tbody tr:hover {
    background-color: var(--primary-50);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* =============================================
   AFFILIATE DASHBOARD LAYOUT
   ============================================= */
.affiliate-page {
    display: block;
    background: var(--bg);
    min-height: 100vh;
}

.affiliate .table-container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 36px 40px 60px;
}

.affiliate .thumb2 {
    display: none;
}

/* HEADER BAR */
.affiliate-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    padding: 20px 24px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    gap: 16px;
}

.affiliate-header .brand-logos {
    display: flex;
    gap: 16px;
    align-items: center;
}

.affiliate-header .brand-logos a {
    display: block;
    width: 100px;
    transition: var(--transition);
    filter: grayscale(10%);
    opacity: 0.85;
}

.affiliate-header .brand-logos a:hover {
    filter: none;
    opacity: 1;
    transform: translateY(-1px);
}

.affiliate-header .brand-logos img {
    width: 100%;
}

.affiliate-user {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.affiliate-user .user-info {
    text-align: right;
}

.affiliate-user .user-info .label {
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.affiliate-user .user-info .name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 2px;
}

/* Logout button */
.btn-logout {
    padding: 8px 18px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    width: auto;
    display: inline-block;
    white-space: nowrap;
}

.btn-logout:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: #fff5f5;
}

/* SECTION CARDS */
.section-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 24px;
    overflow: hidden;
    transition: var(--transition);
}

.section-card:hover {
    box-shadow: var(--shadow-md);
}

.section-card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--bg);
}

.section-card-header .icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(18, 53, 174, 0.25);
}

.section-card-header h1 {
    font-size: 17px;
    margin-bottom: 0;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.section-card-body {
    overflow-x: auto;
}

/* =============================================
   AFFILIATE PAGE — h1 & h2 overrides
   ============================================= */
.affiliate h1 {
    margin-bottom: 0;
    font-size: 17px;
}

.affiliate h2 {
    margin-bottom: 0;
}

.rank-title {
    margin-bottom: 24px;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* =============================================
   RANK BADGES — solid colors
   ============================================= */
.Bronze {
    background: #cd7f32;
    padding: 3px 12px;
    font-size: 12px;
    border-radius: 100px;
    color: #fff;
    font-weight: 700;
    display: inline-block;
    letter-spacing: 0.02em;
}

.Silver {
    background: #8d9aa8;
    padding: 3px 12px;
    font-size: 12px;
    border-radius: 100px;
    color: white;
    font-weight: 700;
    display: inline-block;
    letter-spacing: 0.02em;
}

.Gold {
    background: #d4900a;
    padding: 3px 12px;
    font-size: 12px;
    border-radius: 100px;
    color: white;
    font-weight: 700;
    display: inline-block;
    letter-spacing: 0.02em;
}

.Platinum {
    background: #5b5ea6;
    padding: 3px 12px;
    font-size: 12px;
    border-radius: 100px;
    color: white;
    font-weight: 700;
    display: inline-block;
    letter-spacing: 0.02em;
}

/* =============================================
   PAYMENT STATUS
   ============================================= */
.payment-status {
    padding: 4px 12px;
    font-weight: 600;
    font-size: 12px;
    border-radius: 100px;
    display: inline-block;
    letter-spacing: 0.01em;
}

.done {
    background-color: var(--success-light);
    color: var(--success-text);
}

.pending {
    background-color: var(--warning-light);
    color: var(--warning-text);
}

/* =============================================
   TABLE SPECIAL ROWS
   ============================================= */
.month-header {
    background: var(--primary-light) !important;
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 13px;
    letter-spacing: 0.01em;
}

.month-header:hover {
    background: var(--primary-light) !important;
}

.total-month {
    background: var(--primary-50) !important;
}

.total-month td {
    font-weight: 700;
    color: var(--primary-dark);
}

.total-month:hover {
    background: var(--primary-50) !important;
}

/* =============================================
   MONTH NAV (keeptrack)
   ============================================= */
.month-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.month-nav span {
    flex: 1;
    text-align: center;
    background: var(--primary-light);
    padding: 11px 20px;
    border-radius: 100px;
    color: var(--primary-dark);
    font-weight: 700;
    font-size: 15px;
    border: 1px solid rgba(18, 53, 174, 0.2);
}

.month-nav button {
    background: var(--surface);
    padding: 11px 20px;
    cursor: pointer;
    border: 1.5px solid var(--border);
    color: var(--primary);
    font-weight: 600;
    border-radius: var(--radius-sm);
    font-size: 14px;
    width: auto;
    transition: var(--transition);
    flex-shrink: 0;
}

.month-nav button:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

/* =============================================
   KOC SECTION (keeptrack page)
   ============================================= */
#koc-body {
    background-color: var(--bg);
    min-height: 100vh;
}

.koc-section {
    max-width: 960px;
    margin: 0 auto;
    padding: 40px 24px 60px;
}

.koc-section > .koc-page-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--border);
}

.koc-section > .koc-page-header h1 {
    font-size: 30px;
    margin-bottom: 0;
    font-weight: 800;
}

.koc-page-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(18, 53, 174, 0.3);
}

.box-koc {
    margin-bottom: 20px;
}

.content-koc {
    background: var(--surface);
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-slow);
}

.content-koc:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.content-koc table {
    margin-top: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.content-koc .infor {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    gap: 8px 28px;
    font-size: 14px;
    color: var(--text-secondary);
}

.content-koc .infor li {
    display: flex;
    align-items: center;
    gap: 6px;
}

.content-koc .infor span {
    font-weight: 700;
    color: var(--text-primary);
}

.content-koc .total {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    list-style: none;
    gap: 28px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-secondary);
}

.content-koc .total li {
    display: flex;
    align-items: center;
    gap: 8px;
}

.content-koc .total span {
    font-weight: 800;
    color: var(--primary);
    font-size: 17px;
    letter-spacing: -0.02em;
}

/* =============================================
   RESPONSIVE — DASHBOARD & KOC
   ============================================= */
@media (max-width: 991px) {
    .affiliate .table-container {
        padding: 24px 16px 40px;
    }

    .affiliate-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .affiliate-user {
        width: 100%;
        justify-content: space-between;
    }

    .affiliate-user .user-info {
        text-align: left;
    }

    .koc-section {
        padding: 24px 16px 40px;
    }
}

@media (max-width: 575px) {
    .affiliate-header {
        padding: 16px;
    }

    .section-card-header {
        padding: 16px;
    }

    .content-koc {
        padding: 18px 16px;
    }

    .content-koc .total {
        flex-direction: column;
        align-items: flex-end;
        gap: 8px;
    }

    th, td {
        padding: 10px 12px;
        font-size: 13px;
    }
}