* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

:root {
    --bg-primary: linear-gradient(135deg, #f5f7fa 0%, #e4e8f0 100%);
    --bg-secondary: white;
    --text-primary: #333;
    --text-secondary: #777;
    --accent-color: #6a11cb;
    --accent-gradient: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    --brand-gradient: linear-gradient(135deg, #3498db 0%, #2c3e50 100%);
    --header-bg: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    --sidebar-bg: linear-gradient(180deg, #2c3e50 0%, #3498db 100%);
    --card-bg: white;
    --card-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    --border-color: #e0e0e0;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

[data-theme="dark"] {
    --bg-primary: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --bg-secondary: #2d3748;
    --text-primary: #e2e8f0;
    --text-secondary: #a0aec0;
    --accent-color: #9f7aea;
    --accent-gradient: linear-gradient(135deg, #9f7aea 0%, #667eea 100%);
    --header-bg: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
    --sidebar-bg: linear-gradient(180deg, #1a202c 0%, #2d3748 100%);
    --card-bg: #2d3748;
    --card-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    --border-color: #4a5568;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    height: -webkit-fill-available;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    transition: all 0.3s ease;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
    overflow-x: hidden;
}

/* Authentication Container */
.auth-container {
    width: 100%;
    max-width: 450px;
    background: var(--bg-secondary);
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
    transition: all 0.3s ease;
    margin: auto;
}

.auth-header {
    background: var(--header-bg);
    color: white;
    padding: 30px 20px;
    text-align: center;
}

.auth-header h1 {
    font-size: 1.8rem;
    font-weight: 500;
    margin-bottom: 15px;
}

.auth-header p {
    opacity: 0.9;
    font-size: 0.95rem;
}

.auth-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.auth-tab {
    flex: 1;
    padding: 15px 10px;
    text-align: center;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.auth-tab.active {
    color: var(--accent-color);
    border-bottom: 3px solid var(--accent-color);
}

.auth-form {
    padding: 25px 20px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 14px 15px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s;
    background: var(--bg-secondary);
    color: var(--text-primary);
    -webkit-appearance: none;
}

.form-control:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(106, 17, 203, 0.15);
    outline: none;
}

.btn {
    position: relative;
    display: block;
    width: 100%;
    padding: 15px;
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    overflow: hidden;
}

.btn:hover, .btn:active {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(106, 17, 203, 0.3);
}

.form-footer {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.form-footer a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}

.form-footer a:hover {
    text-decoration: underline;
}

.forgot-password {
    text-align: right;
    margin-top: -10px;
    margin-bottom: 20px;
}

.forgot-password a {
    color: var(--accent-color);
    text-decoration: none;
    font-size: 0.9rem;
}

.hidden {
    display: none !important;
}

.login-logo {
    width: 60px;
    height: 60px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin: 0 auto 15px;
    background: rgba(255, 255, 255, 0.2);
}

/* Dashboard Styles */
.dashboard {
    display: none;
    width: 100%;
    min-height: 100vh;
    flex-direction: column;
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    background: var(--sidebar-bg);
    color: white;
    transition: left 0.3s ease;
    z-index: 1000;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
    padding-top: var(--safe-top);
    -webkit-overflow-scrolling: touch;
}

.sidebar.open {
    left: 0;
}

.sidebar-header {
    padding: 25px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.sidebar-title {
    font-size: 18px;
    font-weight: 600;
    flex: 1;
    text-align: center;
}

.close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.3s;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.close-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

.menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-item {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: all 0.3s;
    border-left: 4px solid transparent;
    text-decoration: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
    min-height: 56px;
}

.menu-item:active {
    background: rgba(255, 255, 255, 0.15);
}

.menu-item.active {
    background: rgba(255, 255, 255, 0.15);
    border-left-color: #e74c3c;
}

.menu-item.logout {
    margin-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
}

.menu-text {
    font-size: 16px;
    font-weight: 500;
    flex: 1;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.brand-logo {
    width: 40px;
    height: 35px;
    background: var(--brand-gradient);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
}

.overlay.open {
    opacity: 1;
    visibility: visible;
}

.container {
    width: 100%;
    background: var(--bg-secondary);
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    transition: all 0.3s ease;
    flex: 1;
}

.header {
    background: var(--header-bg);
    color: white;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-top: calc(20px + var(--safe-top));
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.menu-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s ease;
    width: 44px;
    height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.menu-btn:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.95);
}

/* Theme Toggle Styles */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 44px;
    height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.theme-toggle:active {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0.95);
}

.theme-icon {
    font-size: 1.3rem;
}

.welcome-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.header-logo {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.welcome-text h1 {
    font-size: 1.6rem;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.3;
}

.user-type {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
}

.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    width: 100%;
}

.sales-section, .wallet-section, .earnings-section {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
    position: relative;
}

.sales-label, .wallet-label, .earnings-label {
    font-size: 0.85rem;
    margin-bottom: 5px;
    opacity: 0.9;
    color: white;
}

.sales-amount, .wallet-amount, .earnings-amount {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.2;
    color: white;
}

/* Wallet section with plus icon */
.wallet-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
    font-size: 1.1rem;
    opacity: 0.8;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

.wallet-icon:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Earnings section - only arrow is clickable */
.earnings-section {
    cursor: default;
}

/* Earnings arrow as link */
.earnings-arrow-link {
    position: absolute;
    top: 10px;
    right: 10px;
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.2s ease;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

.earnings-arrow-link:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(2px);
}

.earnings-arrow {
    font-size: 0.9rem;
}

.content {
    padding: 25px 20px;
    padding-bottom: calc(25px + var(--safe-bottom));
}

.section-title {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    line-height: 1.3;
}

.section-title i {
    color: var(--accent-color);
}

.network-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.network-card {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--card-shadow);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
    text-decoration: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
    min-height: 90px;
}

.network-card:active {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    border-color: var(--accent-color);
}

.network-logo {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-primary);
}

.network-logo img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.network-info {
    flex: 1;
    min-width: 0;
}

.network-name {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 4px;
    line-height: 1.3;
}

.network-tagline {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
}

.referral-section {
    background: var(--bg-primary);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    margin-top: 20px;
}

.referral-title {
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.referral-link {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    gap: 10px;
}

.link-text {
    color: var(--accent-color);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    text-align: left;
    font-size: 0.9rem;
}

.copy-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.copy-btn:active {
    background: #5a0db9;
}

.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
}

/* Special Offers Section */
.special-offers {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

/* Responsive Breakpoints */
@media screen and (max-width: 1200px) {
    .network-cards {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media screen and (max-width: 992px) {
    body {
        padding: 15px;
    }
    
    .auth-container {
        border-radius: 15px;
    }
    
    .network-cards {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

@media screen and (max-width: 768px) {
    body {
        padding: 10px;
        align-items: flex-start;
        min-height: 100vh;
    }
    
    .auth-container {
        margin-top: 10px;
        max-width: 100%;
    }
    
    .auth-header {
        padding: 25px 15px;
    }
    
    .auth-form {
        padding: 20px 15px;
    }
    
    .auth-tab {
        padding: 12px 8px;
        font-size: 0.9rem;
    }
    
    .form-control {
        padding: 16px 15px;
        font-size: 16px;
    }
    
    .btn {
        padding: 16px;
    }
    
    .dashboard {
        height: 100vh;
        overflow: hidden;
    }
    
    .container {
        border-radius: 0;
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    
    .header {
        padding: 20px 15px;
        gap: 15px;
    }
    
    .content {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: calc(30px + var(--safe-bottom));
    }
    
    .network-cards {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .network-card {
        padding: 18px;
    }
    
    .stats-section {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .sales-section, .wallet-section, .earnings-section {
        padding: 15px 12px;
    }
    
    .sidebar {
        width: 85%;
        max-width: 320px;
        left: -100%;
    }
    
    .sidebar.open {
        left: 0;
    }
}

@media screen and (max-width: 480px) {
    .auth-header h1 {
        font-size: 1.5rem;
    }
    
    .auth-header p {
        font-size: 0.9rem;
    }
    
    .login-logo {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .header-logo {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
    
    .welcome-text h1 {
        font-size: 1.4rem;
    }
    
    .section-title {
        font-size: 1.1rem;
    }
    
    .network-name {
        font-size: 1rem;
    }
    
    .network-tagline {
        font-size: 0.85rem;
    }
    
    .form-group label {
        font-size: 0.9rem;
    }
    
    .form-control {
        padding: 14px;
    }
    
    .referral-section {
        padding: 15px;
    }
    
    .referral-title {
        font-size: 1rem;
    }
    
    .link-text {
        font-size: 0.8rem;
    }
    
    .copy-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}

@media screen and (max-width: 360px) {
    .auth-header {
        padding: 20px 12px;
    }
    
    .auth-form {
        padding: 18px 12px;
    }
    
    .auth-tab {
        font-size: 0.85rem;
        padding: 10px 6px;
    }
    
    .menu-item {
        padding: 14px 15px;
        min-height: 50px;
    }
    
    .menu-text {
        font-size: 0.95rem;
    }
    
    .network-card {
        padding: 15px;
    }
    
    .network-logo {
        width: 45px;
        height: 45px;
    }
    
    .content {
        padding: 20px 15px;
    }
}

@media screen and (orientation: landscape) and (max-height: 600px) {
    .auth-container {
        max-height: 90vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .dashboard {
        height: 100vh;
    }
    
    .content {
        padding-bottom: 20px;
    }
    
    .header {
        padding: 15px;
    }
    
    .welcome-section {
        flex-direction: row;
        text-align: left;
        gap: 15px;
    }
    
    .header-logo {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .welcome-text h1 {
        font-size: 1.3rem;
        margin-bottom: 5px;
    }
    
    .user-type {
        font-size: 0.8rem;
        padding: 4px 12px;
    }
}

@media (prefers-contrast: high) {
    .btn, .menu-btn, .theme-toggle, .close-btn {
        border: 2px solid currentColor;
    }
    
    .form-control {
        border-width: 2px;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media screen and (orientation: landscape) {
    html {
        -webkit-text-size-adjust: none;
    }
}