:root {
    --mlm-primary: #4f46e5;
    --mlm-primary-hover: #4338ca;
    --mlm-bg-surface: #ffffff;
    --mlm-bg-body: #f8fafc;
    --mlm-border: #e2e8f0;
    --mlm-text-main: #0f172a;
    --mlm-text-muted: #64748b;
    --mlm-emerald: #10b981;
    --mlm-indigo: #6366f1;
    --mlm-purple: #8b5cf6;
    --mlm-amber: #f59e0b;
    --mlm-radius: 14px;
    --mlm-shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --mlm-shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
    --mlm-shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
}

.mlm-portal-container, .mlm-login-wrapper {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--mlm-text-main);
    box-sizing: border-box;
}

.mlm-portal-container *, .mlm-login-wrapper * {
    box-sizing: border-box;
}

/* Authentication Screen */
.mlm-login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 60px 20px;
    background: linear-gradient(135deg, #f0f4ff 0%, #f9fafb 100%);
    min-height: 75vh;
}

.mlm-auth-card {
    background: var(--mlm-bg-surface);
    width: 100%;
    max-width: 440px;
    padding: 40px;
    border-radius: 20px;
    border: 1px solid var(--mlm-border);
    box-shadow: var(--mlm-shadow-lg);
    text-align: left;
}

.mlm-auth-header {
    text-align: center;
    margin-bottom: 26px;
}

.mlm-logo-badge {
    width: 52px;
    height: 52px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--mlm-primary), var(--mlm-purple));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.25);
}

.mlm-auth-header h2 {
    font-size: 24px;
    font-weight: 800;
    margin: 0 0 6px;
    color: var(--mlm-text-main);
}

.mlm-auth-header p {
    font-size: 14px;
    color: var(--mlm-text-muted);
    margin: 0;
}

.mlm-input-group {
    margin-bottom: 20px;
}

.mlm-input-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--mlm-text-main);
}

.mlm-field-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.mlm-field-with-icon svg {
    position: absolute;
    left: 14px;
    color: #94a3b8;
    pointer-events: none;
}

.mlm-field-with-icon input {
    width: 100%;
    padding: 13px 14px 13px 44px;
    border: 1.5px solid var(--mlm-border);
    border-radius: 10px;
    font-size: 14px;
    background: #ffffff;
    transition: all 0.2s ease;
}

.mlm-field-with-icon input:focus {
    outline: none;
    border-color: var(--mlm-primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.mlm-form-aux {
    margin-bottom: 24px;
}

.mlm-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--mlm-text-muted);
    cursor: pointer;
}

.mlm-submit-btn {
    width: 100%;
    padding: 14px 20px;
    background: linear-gradient(135deg, var(--mlm-primary), var(--mlm-primary-hover));
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mlm-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

/* Dashboard Portal */
.mlm-portal-container {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
}

.mlm-hero-header {
    background: var(--mlm-bg-surface);
    border: 1px solid var(--mlm-border);
    border-radius: 16px;
    padding: 24px 30px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--mlm-shadow-sm);
    flex-wrap: wrap;
    gap: 20px;
}

.mlm-user-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mlm-avatar-circle {
    width: 48px;
    height: 48px;
    background: #0f172a;
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
}

.mlm-hero-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
}

.mlm-sub-text {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--mlm-text-muted);
}

.mlm-ref-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 10px 14px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mlm-ref-badge {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--mlm-text-muted);
    letter-spacing: 0.5px;
}

.mlm-copy-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mlm-copy-wrapper input {
    background: #ffffff;
    border: 1px solid var(--mlm-border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--mlm-primary);
    width: 130px;
    text-align: center;
}

.mlm-copy-btn {
    background: var(--mlm-primary);
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.mlm-copy-btn:hover {
    background: var(--mlm-primary-hover);
}

/* KPI Cards */
.mlm-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.mlm-card {
    background: var(--mlm-bg-surface);
    border-radius: var(--mlm-radius);
    padding: 24px;
    border: 1px solid var(--mlm-border);
    box-shadow: var(--mlm-shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.mlm-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--mlm-shadow-md);
}

.mlm-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.mlm-card-1 .mlm-card-icon { background: #ecfdf5; color: var(--mlm-emerald); }
.mlm-card-2 .mlm-card-icon { background: #eef2ff; color: var(--mlm-indigo); }
.mlm-card-3 .mlm-card-icon { background: #f5f3ff; color: var(--mlm-purple); }
.mlm-card-4 .mlm-card-icon { background: #fffbeb; color: var(--mlm-amber); }

.mlm-card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--mlm-text-muted);
}

.mlm-card-value {
    font-size: 28px;
    font-weight: 800;
    margin: 8px 0 6px;
    color: var(--mlm-text-main);
}

.mlm-card-value small {
    font-size: 14px;
    color: var(--mlm-text-muted);
    font-weight: 500;
}

.mlm-card-footnote {
    font-size: 12px;
    color: #94a3b8;
}

/* Two Column Layout */
.mlm-content-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 24px;
}

@media (max-width: 900px) {
    .mlm-content-grid {
        grid-template-columns: 1fr;
    }
}

.mlm-surface-card {
    background: var(--mlm-bg-surface);
    border-radius: var(--mlm-radius);
    border: 1px solid var(--mlm-border);
    padding: 24px;
    box-shadow: var(--mlm-shadow-sm);
}

.mlm-surface-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.mlm-surface-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.mlm-tag {
    font-size: 11px;
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 6px;
    color: var(--mlm-text-muted);
    font-weight: 600;
}

/* Table */
.mlm-table-responsive {
    overflow-x: auto;
}

.mlm-modern-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.mlm-modern-table th {
    text-align: left;
    padding: 12px 14px;
    color: var(--mlm-text-muted);
    font-weight: 600;
    border-bottom: 1.5px solid var(--mlm-border);
}

.mlm-modern-table td {
    padding: 14px;
    border-bottom: 1px solid var(--mlm-border);
}

.mlm-user-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.mlm-cell-avatar {
    width: 28px;
    height: 28px;
    background: #f1f5f9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: #475569;
}

.mlm-pill-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}

.mlm-pill-badge.direct {
    background: #ecfdf5;
    color: #065f46;
}

.mlm-pill-badge.indirect {
    background: #eef2ff;
    color: #3730a3;
}

.mlm-val-positive {
    color: var(--mlm-emerald);
    font-weight: 700;
}

.mlm-date-cell {
    color: #94a3b8;
}

/* Downline Tree Structure */
.mlm-tree-container {
    background: #f8fafc;
    border-radius: 10px;
    padding: 20px;
    border: 1px dashed var(--mlm-border);
}

.mlm-tree-root {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #0f172a;
    color: #ffffff;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

.mlm-root-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
}

.mlm-tree-list, .mlm-sub-branch {
    list-style: none;
    padding-left: 20px;
    margin: 0;
}

.mlm-tree-item {
    margin: 12px 0;
    position: relative;
}

.mlm-branch-node {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: #ffffff;
    border: 1px solid var(--mlm-border);
    padding: 8px 14px;
    border-radius: 8px;
    box-shadow: var(--mlm-shadow-sm);
}

.mlm-branch-node.direct {
    border-left: 4px solid var(--mlm-emerald);
}

.mlm-branch-node.indirect {
    border-left: 4px solid var(--mlm-purple);
}

.mlm-node-icon {
    font-size: 10px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    background: #f1f5f9;
}

.mlm-node-info strong {
    display: block;
    font-size: 13px;
}

.mlm-node-info small {
    font-size: 11px;
    color: var(--mlm-text-muted);
}

/* Toast Component */
.mlm-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #0f172a;
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--mlm-shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.25s ease;
    z-index: 99999;
}

.mlm-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Common Notices */
.mlm-alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mlm-alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.mlm-alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.mlm-auth-redirect-notice {
    text-align: center;
    padding: 40px;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid var(--mlm-border);
    max-width: 450px;
    margin: 40px auto;
}

.mlm-primary-btn {
    display: inline-block;
    background: var(--mlm-primary);
    color: #ffffff !important;
    text-decoration: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 700;
    margin-top: 12px;
}