:root {
            --primary-blue: #0b2149;
            --navy-sidebar: #0b1727;
            --text-dark: #0f172a;
            --text-muted: #64748b;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
            -webkit-tap-highlight-color: transparent;
        }

        html, body {
            width: 100%;
            max-width: 100%;
            background: #f8fafc;
            color: var(--text-dark);
            min-height: 100vh;
            overflow-x: hidden;
        }

        .dashboard-app-layout {
            display: flex;
            width: 100%;
            min-height: 100vh;
            position: relative;
        }

        /* Top Header */
        .dashboard-header {
            position: sticky;
            top: 0;
            z-index: 990;
            background: #ffffff;
            padding: 12px 20px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1px solid rgba(16, 52, 120, 0.08);
            box-shadow: 0 2px 10px rgba(16, 52, 120, 0.04);
            width: 100%;
        }

        .header-brand-wrap {
            display: flex;
            align-items: center;
            gap: 10px;
            text-decoration: none;
            min-width: 0;
        }

        .header-logo-icon {
            width: 36px;
            height: 36px;
            border-radius: 10px;
            object-fit: cover;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        }

        .brand-text-block {
            display: flex;
            flex-direction: column;
        }

        .brand-logo-title {
            font-size: 15px;
            font-weight: 900;
            line-height: 1.15;
            letter-spacing: -0.3px;
        }

        .brand-logo-title .text-digital { color: #0084ff; }
        .brand-logo-title .text-scratch { color: #ff1a75; }
        .brand-logo-title .text-design { color: #0070e0; }

        .brand-tagline-row {
            display: flex;
            gap: 4px;
            font-size: 8.5px;
            font-weight: 700;
            letter-spacing: 0.2px;
            margin-top: 1px;
        }

        .brand-tagline-row .tag-c { color: #5c6b7e; }
        .brand-tagline-row .tag-e { color: #5c6b7e; }
        .brand-tagline-row .tag-r { color: #5c6b7e; }
        .brand-tagline-row .tag-g { color: #5c6b7e; }

        .header-actions-right {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .header-profile-btn {
            background: none;
            border: none;
            cursor: pointer;
            padding: 2px;
            border-radius: 999px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .header-profile-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: linear-gradient(135deg, #8327db 0%, #6012b8 100%);
            color: #ffffff;
            font-size: 13.5px;
            font-weight: 800;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 2px 8px rgba(131, 39, 219, 0.35);
        }

        /* Sidebar & Mobile Off-canvas */
        .slide-bar-drawer {
            width: 255px;
            min-width: 255px;
            background: var(--navy-sidebar);
            display: flex;
            flex-direction: column;
            overflow-y: auto;
            border-right: 1px solid rgba(255, 255, 255, 0.07);
            box-shadow: 4px 0 20px rgba(7, 22, 48, 0.15);
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            z-index: 99999;
        }

        .slide-bar-header {
            padding: 22px 18px 18px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.08);
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .slide-user-profile-wrap {
            display: flex;
            align-items: center;
            gap: 12px;
            min-width: 0;
        }

        .slide-user-avatar {
            width: 44px;
            height: 44px;
            border-radius: 12px;
            background: linear-gradient(135deg, #ff5722 0%, #ff8a00 100%);
            color: #ffffff;
            display: flex;
            align-items: center;
            justify-content: center;
            font-weight: 800;
            font-size: 17px;
            box-shadow: 0 4px 12px rgba(255, 87, 34, 0.3);
            flex-shrink: 0;
        }

        .slide-user-info {
            overflow: hidden;
        }

        .slide-user-name {
            font-size: 14px;
            font-weight: 800;
            color: #ffffff;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .slide-user-id {
            font-size: 11px;
            font-weight: 700;
            color: #38bdf8;
            margin-top: 2px;
        }

        .slide-close-btn {
            background: rgba(255, 255, 255, 0.08);
            border: none;
            color: #ffffff;
            width: 32px;
            height: 32px;
            border-radius: 50%;
            display: none;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-size: 15px;
            flex-shrink: 0;
        }

        .slide-bar-backdrop {
            position: fixed;
            inset: 0;
            background: rgba(4, 15, 36, 0.6);
            backdrop-filter: blur(3px);
            z-index: 99998;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s ease;
        }

        .slide-bar-backdrop.open {
            opacity: 1;
            pointer-events: auto;
        }

        .slide-nav-menu {
            display: flex;
            flex-direction: column;
            padding: 14px 10px;
            gap: 4px;
            flex: 1;
        }

        .slide-nav-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 11px 14px;
            border-radius: 12px;
            color: #94a3b8;
            text-decoration: none;
            font-size: 13.5px;
            font-weight: 700;
            transition: all 0.15s ease;
            cursor: pointer;
            border: none;
            background: none;
            width: 100%;
            text-align: left;
        }

        .slide-nav-item svg {
            width: 18px;
            height: 18px;
            flex-shrink: 0;
        }

        .slide-nav-item:hover {
            background: rgba(255, 255, 255, 0.05);
            color: #ffffff;
        }

        .slide-nav-item.active {
            background: linear-gradient(90deg, #ff5722 0%, #ff8a00 100%);
            color: #ffffff;
            box-shadow: 0 4px 12px rgba(255, 87, 34, 0.35);
        }

        .slide-nav-item.logout {
            margin-top: auto;
            color: #f87171;
            border-top: 1px solid rgba(255, 255, 255, 0.06);
            border-radius: 0;
            padding-top: 16px;
        }

        .slide-nav-item.logout:hover {
            background: rgba(248, 113, 113, 0.1);
            color: #fca5a5;
        }

        /* Collapsible Privacy Subnav */
        .slide-nav-group {
            display: flex;
            flex-direction: column;
            width: 100%;
        }

        .slide-nav-toggle {
            justify-content: flex-start;
            position: relative;
        }

        .slide-collapse-icon {
            margin-left: auto;
            font-size: 16px;
            font-weight: 800;
            line-height: 1;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 22px;
            height: 22px;
            border-radius: 6px;
            background: rgba(255, 255, 255, 0.08);
            color: #94a3b8;
            transition: all 0.2s ease;
        }

        .slide-nav-group.open .slide-collapse-icon {
            background: rgba(255, 255, 255, 0.18);
            color: #ffffff;
        }

        .slide-subnav-menu {
            display: flex;
            flex-direction: column;
            gap: 2px;
            padding-left: 20px;
            margin-top: 4px;
            margin-bottom: 4px;
            border-left: 2px solid rgba(255, 255, 255, 0.12);
            margin-left: 24px;
        }

        .slide-subnav-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 12px;
            border-radius: 8px;
            color: #94a3b8;
            text-decoration: none;
            font-size: 13px;
            font-weight: 600;
            transition: all 0.15s ease;
        }

        .slide-subnav-item:hover {
            color: #ffffff;
            background: rgba(255, 255, 255, 0.06);
        }

        .slide-subnav-item.active {
            color: #ffffff;
            background: rgba(249, 87, 34, 0.2);
            font-weight: 700;
        }

        .subnav-dot {
            font-size: 14px;
            line-height: 1;
            opacity: 0.6;
        }

        /* Main Content */
        .main-content-panel {
            flex: 1;
            min-width: 0;
            display: flex;
            flex-direction: column;
            background: #f8fafc;
            min-height: 100vh;
        }

        /* Hero Banner */
        .referral-banner {
            background: linear-gradient(135deg, #1e40af 0%, #2563eb 60%, #0284c7 100%);
            color: #ffffff;
            padding: 24px 28px;
            position: relative;
            overflow: hidden;
            box-shadow: 0 4px 20px rgba(234, 88, 12, 0.15);
        }

        .referral-banner-wrap {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 20px;
            position: relative;
            z-index: 2;
        }

        .referral-badge {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            background: rgba(255, 255, 255, 0.2);
            backdrop-filter: blur(8px);
            padding: 4px 12px;
            border-radius: 9999px;
            font-size: 11px;
            font-weight: 800;
            letter-spacing: 0.5px;
            text-transform: uppercase;
            margin-bottom: 8px;
        }

        .referral-title {
            font-size: 26px;
            font-weight: 900;
            letter-spacing: -0.5px;
            line-height: 1.2;
            margin-bottom: 6px;
        }

        .referral-sub {
            font-size: 13.5px;
            color: rgba(255, 255, 255, 0.92);
            font-weight: 500;
            line-height: 1.4;
            max-width: 580px;
        }

        .bonus-round-card {
            background: rgba(255, 255, 255, 0.15);
            backdrop-filter: blur(12px);
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 18px;
            padding: 14px 20px;
            text-align: center;
            flex-shrink: 0;
        }

        .bonus-percent {
            font-size: 28px;
            font-weight: 900;
            color: #ffffff;
            line-height: 1;
        }

        .bonus-percent-label {
            font-size: 10px;
            font-weight: 800;
            letter-spacing: 0.5px;
            text-transform: uppercase;
            color: #fef08a;
            margin-top: 4px;
        }

        /* Content Body */
        .referral-content-body {
            padding: 24px 28px 100px;
            display: flex;
            flex-direction: column;
            gap: 20px;
            max-width: 1100px;
            width: 100%;
            margin: 0 auto;
        }

        /* Referral Share Box Card */
        .referral-share-card {
            background: #ffffff;
            border-radius: 20px;
            padding: 24px;
            border: 1px solid #e2e8f0;
            box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
            display: flex;
            flex-direction: column;
            gap: 16px;
        }

        .share-card-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            flex-wrap: wrap;
            gap: 10px;
        }

        .share-card-title {
            font-size: 17px;
            font-weight: 800;
            color: #0f172a;
        }

        .share-card-pill {
            background: #ecfdf5;
            color: #059669;
            font-size: 11.5px;
            font-weight: 800;
            padding: 4px 12px;
            border-radius: 9999px;
            border: 1px solid #a7f3d0;
        }

        .code-actions-row {
            display: flex;
            align-items: center;
            gap: 14px;
            flex-wrap: wrap;
        }

        .code-display-box {
            flex: 1;
            min-width: 220px;
            background: #f8fafc;
            border: 2px dashed #cbd5e1;
            border-radius: 14px;
            padding: 12px 18px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
        }

        .code-label-group {
            display: flex;
            flex-direction: column;
        }

        .code-label {
            font-size: 10.5px;
            font-weight: 700;
            color: #64748b;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .code-value {
            font-size: 22px;
            font-weight: 900;
            color: #ea580c;
            letter-spacing: 1.5px;
            font-family: monospace;
        }

        .btn-copy-code {
            background: #ea580c;
            color: #ffffff;
            border: none;
            padding: 10px 18px;
            border-radius: 10px;
            font-size: 13px;
            font-weight: 800;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 6px;
            transition: all 0.2s;
            box-shadow: 0 4px 12px rgba(234, 88, 12, 0.25);
            flex-shrink: 0;
        }

        .btn-copy-code:hover { background: #c2410c; }
        .btn-copy-code:active { transform: scale(0.96); }

        .btn-share-wa {
            background: #25d366;
            color: #ffffff;
            border: none;
            padding: 14px 22px;
            border-radius: 12px;
            font-size: 14px;
            font-weight: 800;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            gap: 8px;
            transition: all 0.2s;
            box-shadow: 0 4px 14px rgba(37, 211, 102, 0.3);
            text-decoration: none;
            flex-shrink: 0;
        }

        .btn-share-wa:hover { background: #1ebc57; }
        .btn-share-wa:active { transform: scale(0.96); }

        .btn-share-wa svg {
            width: 20px;
            height: 20px;
        }

        /* 4 Referral KPI Stat Cards */
        .referral-stats-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 14px;
        }

        .stat-card {
            background: #ffffff;
            border: 1px solid #e2e8f0;
            border-radius: 16px;
            padding: 16px;
            display: flex;
            align-items: center;
            gap: 12px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.03);
        }

        .stat-icon {
            width: 44px;
            height: 44px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            flex-shrink: 0;
        }

        .stat-icon.orange { background: #ffedd5; color: #ea580c; }
        .stat-icon.green { background: #dcfce7; color: #16a34a; }
        .stat-icon.purple { background: #f3e8ff; color: #7c3aed; }
        .stat-icon.blue { background: #e0f2fe; color: #0284c7; }

        .stat-meta {
            min-width: 0;
        }

        .stat-label {
            font-size: 11.5px;
            font-weight: 700;
            color: #64748b;
            margin-bottom: 2px;
        }

        .stat-value {
            font-size: 22px;
            font-weight: 900;
            color: #0f172a;
            line-height: 1;
        }

        /* How It Works Steps */
        .how-card {
            background: #ffffff;
            border-radius: 20px;
            padding: 22px 24px;
            border: 1px solid #e2e8f0;
            box-shadow: 0 2px 10px rgba(0,0,0,0.03);
        }

        .how-title {
            font-size: 16px;
            font-weight: 800;
            color: #0f172a;
            margin-bottom: 16px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .how-steps-grid {
            display: grid;
            grid-template-columns: repeat(3, 1fr);
            gap: 16px;
        }

        .how-step-item {
            background: #f8fafc;
            border-radius: 14px;
            padding: 16px;
            border: 1px solid #edf2f7;
            position: relative;
        }

        .step-number {
            width: 26px;
            height: 26px;
            border-radius: 50%;
            background: #ea580c;
            color: #ffffff;
            font-size: 12px;
            font-weight: 800;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 10px;
        }

        .step-title {
            font-size: 13.5px;
            font-weight: 800;
            color: #0f172a;
            margin-bottom: 4px;
        }

        .step-desc {
            font-size: 11.5px;
            color: #64748b;
            line-height: 1.4;
        }

        /* Referral Activity Table / Card */
        .activity-card {
            background: #ffffff;
            border-radius: 20px;
            padding: 22px 24px;
            border: 1px solid #e2e8f0;
            box-shadow: 0 2px 10px rgba(0,0,0,0.03);
        }

        .activity-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 16px;
        }

        .activity-title {
            font-size: 16px;
            font-weight: 800;
            color: #0f172a;
        }

        .empty-history-box {
            text-align: center;
            padding: 32px 16px;
            color: #64748b;
        }

        .empty-icon {
            font-size: 36px;
            margin-bottom: 8px;
        }

        .empty-text {
            font-size: 14px;
            font-weight: 700;
            color: #0f172a;
        }

        .empty-sub {
            font-size: 12px;
            color: #94a3b8;
            margin-top: 4px;
        }

        /* Fixed Bottom Nav Bar */
        .bottom-nav-bar {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            width: 100%;
            background: #ffffff;
            border-top: 1px solid rgba(16, 52, 120, 0.09);
            box-shadow: 0 -4px 18px rgba(11, 33, 73, 0.08);
            display: flex;
            align-items: center;
            justify-content: space-around;
            padding: 7px 6px 9px;
            z-index: 998;
        }

        .bottom-tab-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 2px;
            text-decoration: none;
            cursor: pointer;
            background: none;
            border: none;
            outline: none;
            position: relative;
            padding: 0 4px;
        }

        .tab-icon-circle {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #ffffff;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
            transition: transform 0.15s ease;
        }

        .bottom-tab-item:active .tab-icon-circle { transform: scale(0.92); }
        .tab-icon-circle.home { background: linear-gradient(135deg, #ff4d29 0%, #ff7a00 100%); }
        .tab-icon-circle.unscratched { background: linear-gradient(135deg, #0099ff 0%, #0066cc 100%); }
        .tab-icon-circle.scratched { background: linear-gradient(135deg, #ff7e1d 0%, #f74d1a 100%); }
        .tab-icon-circle.customers { background: linear-gradient(135deg, #0ca872 0%, #059669 100%); }
        .tab-icon-circle.profile { background: linear-gradient(135deg, #8327db 0%, #c026d3 100%); }

        .tab-icon-circle svg { width: 20px; height: 20px; }

        .tab-text-label {
            font-size: 10.5px;
            font-weight: 800;
            color: #0b2149;
            line-height: 1;
        }

        /* Media Queries */
        @media (min-width: 1024px) {
            .slide-bar-drawer {
                position: sticky;
                top: 0;
                height: 100vh;
                transform: none !important;
            }
            .bottom-nav-bar { display: none !important; }
            .slide-close-btn { display: none !important; }
            .header-profile-btn { display: none !important; }
        }

        @media (max-width: 1023px) {
            .slide-bar-drawer {
                position: fixed;
                top: 0;
                left: 0;
                width: 285px;
                max-width: 82vw;
                height: 100%;
                z-index: 99999;
                transform: translateX(-100%);
                box-shadow: 4px 0 20px rgba(0, 0, 0, 0.35);
                overflow-y: auto;
            }

            .slide-bar-drawer.open { transform: translateX(0); }
            .slide-close-btn { display: flex; }

            .referral-stats-grid {
                grid-template-columns: repeat(2, 1fr);
            }

            .how-steps-grid {
                grid-template-columns: repeat(3, 1fr);
            }
        }

        @media (max-width: 680px) {
            .dashboard-header { padding: 10px 14px; }
            .header-logo-icon { width: 32px; height: 32px; }
            .brand-logo-title { font-size: 14px; }

            .referral-banner {
                padding: 16px 14px;
            }

            .referral-banner-wrap {
                flex-direction: column;
                align-items: flex-start;
                gap: 12px;
            }

            .referral-title {
                font-size: 20px;
            }

            .referral-sub {
                font-size: 12px;
            }

            .bonus-round-card {
                width: 100%;
                display: flex;
                align-items: center;
                justify-content: space-between;
                padding: 10px 16px;
            }

            .bonus-percent { font-size: 22px; }

            .referral-content-body {
                padding: 14px 12px 90px;
                gap: 14px;
            }

            .referral-share-card {
                padding: 16px 14px;
                gap: 12px;
            }

            .code-actions-row {
                flex-direction: column;
                align-items: stretch;
            }

            .code-display-box {
                width: 100%;
            }

            .btn-share-wa {
                width: 100%;
                justify-content: center;
            }

            .referral-stats-grid {
                grid-template-columns: repeat(2, 1fr);
                gap: 8px;
            }

            .stat-card {
                padding: 12px 10px;
                gap: 10px;
            }

            .stat-icon {
                width: 36px;
                height: 36px;
                font-size: 16px;
            }

            .stat-label { font-size: 10px; }
            .stat-value { font-size: 18px; }

            .how-steps-grid {
                grid-template-columns: 1fr;
                gap: 10px;
            }
        }

.referral-history-table { width:100%; border-collapse:collapse; white-space:nowrap; font-size:14px; }
.referral-history-table th, .referral-history-table td { text-align:left; padding:14px; border-bottom:1px solid #e5e7eb; }
.referral-history-table th { background:#f8fafc; }
#referralLoadMessage { padding:12px; color:#b45309; }

/* Referral summaries stay together in one flexible row. */
.referral-stats-grid { display: flex; flex-wrap: nowrap; gap: 14px; }
.referral-stats-grid .stat-card { flex: 1 1 0; min-width: 0; }
.bonus-percent-label { color: #dbeafe; }
.code-value { color: #1d4ed8; }
.btn-copy-code { background: #2563eb; box-shadow: 0 4px 12px rgba(37, 99, 235, .25); }
.btn-copy-code:hover { background: #1d4ed8; }
.step-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.step-heading .step-number { flex-shrink: 0; margin-bottom: 0; background: #2563eb; }
.step-heading .step-title { margin-bottom: 0; }
@media (max-width: 680px) {
    .referral-stats-grid { gap: 8px; }
    .referral-stats-grid .stat-card { flex-direction: column; align-items: flex-start; padding: 12px 8px; gap: 8px; }
    .referral-stats-grid .stat-label { font-size: 11px; line-height: 1.35; }
    .how-card { padding: 18px 14px; }
}
