* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* ================= THEME VARIABLES ================= */
:root {
    /* Light Theme (Default) */
    --primary: #4361ee;
    --secondary: #3f37c9;
    --accent: #4895ef;
    --success: #2ecc71;
    --dark: #1e293b;
    --light: #f8fafc;
    --gray: #64748b;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #3498db;
    
    --gradient-bg: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    --gradient-card: linear-gradient(145deg, rgba(255,255,255,0.95), rgba(255,255,255,0.85));
    
    /* Glassmorphism */
    --glass-header: rgba(255, 255, 255, 0.88);
    --glass-content: rgba(255, 255, 255, 0.8);
    --glass-card: rgba(255, 255, 255, 0.75);
    --glass-nav: rgba(255, 255, 255, 0.92);
    
    /* Borders & Shadows */
    --border-glass: rgba(255, 255, 255, 0.6);
    --border-subtle: rgba(0, 0, 0, 0.05);
    --border-input: rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.15);
    
    --transition-fast: all 0.25s cubic-bezier(0.165, 0.84, 0.44, 1);
    --transition: all 0.35s cubic-bezier(0.165, 0.84, 0.44, 1);
    --transition-slow: all 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
    
    --border-radius-sm: 12px;
    --border-radius: 16px;
    --border-radius-lg: 24px;
    --border-radius-full: 9999px;
    
    --safe-area-top: env(safe-area-inset-top);
    --safe-area-bottom: env(safe-area-inset-bottom);
    --safe-area-left: env(safe-area-inset-left);
    --safe-area-right: env(safe-area-inset-right);
}

/* ================= DARK THEME ================= */
.dark {
    --primary: #60a5fa;
    --secondary: #818cf8;
    --accent: #38bdf8;
    --success: #34d399;
    --dark: #f1f5f9;       /* Light text for readability */
    --light: #0f172a;      /* Dark background base */
    --gray: #94a3b8;
    --danger: #f87171;
    --warning: #fbbf24;
    --info: #38bdf8;
    
    /* Deep, rich dark gradient for the body background */
    --gradient-bg: linear-gradient(135deg, #020617 0%, #0f172a 100%);
    --gradient-card: linear-gradient(
        145deg,
        rgba(15,23,42,.95),
        rgba(2,6,23,.95)
    );
    
    /* Dark glassmorphism */
    
    --glass-nav: rgba(15, 23, 42, 0.9);
    --glass-content: rgba(15,23,42,.9);
    --glass-card: rgba(15,23,42,.85);
    --glass-header: rgba(2,6,23,.9);

    
    --border-glass: rgba(148, 163, 184, 0.15);
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-input: rgba(255, 255, 255, 0.1);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.7);

    /* Modal Dark Overrides */
    --modal-bg: #0f172a;
    --modal-text: #f8fafc;
    --modal-subtext: #94a3b8;
    --modal-indicator: #334155;
    --modal-close: #64748b;
    --modal-close-hover: #f8fafc;
    --modal-btn-grad: linear-gradient(135deg, #2563eb, #1d4ed8);
    --modal-btn-sec-grad: linear-gradient(135deg, #475569, #334155);
}

/* Auto-detect system preference (optional) */
@media (prefers-color-scheme: dark) {
    :root:not(.light) {
        --primary: #60a5fa; --secondary: #818cf8; --accent: #38bdf8; --success: #34d399;
        --dark: #f1f5f9; --light: #0f172a; --gray: #94a3b8; --danger: #f87171; --warning: #fbbf24; --info: #38bdf8;
        --gradient-bg: linear-gradient(135deg, #020617 0%, #0f172a 100%);
        --gradient-card: linear-gradient(145deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.6));
        --glass-header: rgba(15, 23, 42, 0.85); --glass-content: rgba(30, 41, 59, 0.7);
        --glass-card: rgba(30, 41, 59, 0.6); --glass-nav: rgba(15, 23, 42, 0.9);
        --border-glass: rgba(148, 163, 184, 0.15); --border-subtle: rgba(255, 255, 255, 0.08); --border-input: rgba(255, 255, 255, 0.1);
        --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5); --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.6); --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.7);
    }
}

/* ================= BASE STYLES ================= */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gradient-bg);
    color: var(--dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-bottom: calc(var(--safe-area-bottom) + 80px);
    padding-top: var(--safe-area-top);
    background-attachment: fixed;
    transition: background 0.4s ease, color 0.4s ease;
}

body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0) 70%);
    z-index: -1;
    animation: rotate 35s linear infinite;
    pointer-events: none;
    transition: background 0.4s ease;
}

.dark body::before {
    background: radial-gradient(circle, rgba(96, 165, 250, 0.05) 0%, rgba(255,255,255,0) 70%);
}

body.dark {
    background: linear-gradient(135deg, #020617 0%, #0f172a 100%) !important;
}

.dark body,
body.dark {
    background-color: #020617 !important;
    background-image: linear-gradient(
        135deg,
        #020617 0%,
        #0f172a 100%
    ) !important;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ================= HEADER STYLES ================= */
.dashboard-header {
    display: flex;
    flex-direction: column;
    padding: calc(12px + var(--safe-area-top)) 16px 12px;
    background: var(--glass-header);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    margin-bottom: 24px;
    transition: var(--transition);
}

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

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

.user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-pic-container {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(45deg, var(--primary), var(--accent));
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
}

.dark .profile-pic-container {
    box-shadow: 0 4px 12px rgba(96, 165, 250, 0.3);
}

.profile-pic {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.user span {
    font-weight: 500;
    color: var(--dark);
    font-size: 1.05rem;
}

.user strong {
    color: var(--primary);
    font-weight: 700;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--border-radius-full);
    background: var(--glass-card);
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
    box-shadow: var(--shadow-sm);
    color: var(--gray);
    flex-shrink: 0;
}

.icon-btn:active {
    transform: scale(0.95);
    background: var(--glass-content);
}

.icon-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.4);
}

.dark .icon-btn:hover {
    box-shadow: 0 4px 12px rgba(96, 165, 250, 0.4);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    transition: var(--transition-fast);
}

.down-balance-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-top: 1px solid var(--border-input);
}

.balance-info p {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gray);
    font-size: 0.95rem;
    margin-bottom: 8px;
}

.balance-info h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--dark);
    margin: 0;
}

.icon-with-circle-animation {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--gradient-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(67, 97, 238, 0.4);
}

.dark .icon-with-circle-animation {
    box-shadow: 0 8px 25px rgba(96, 165, 250, 0.3);
}

.icon-with-circle-animation::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 70%);
    animation: rotate 20s linear infinite;
}

.icon-with-circle-animation svg {
    width: 32px;
    height: 32px;
    fill: white;
}

/* ================= MAIN CONTENT ================= */
.content {
    background: var(--gradient-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 28px 24px;
    position: relative;
    overflow: hidden;
    margin-bottom: 20px;
    border: 1px solid var(--border-glass);
    transition: var(--transition);
}

.content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(67, 97, 238, 0.03) 0%, rgba(255,255,255,0) 70%);
    z-index: -1;
    animation: rotate 45s linear infinite reverse;
}

/* ================= PAGE HEADER ================= */
.page-header {
    margin-bottom: 28px;
    text-align: center;
}

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(to right, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.subtitle {
    color: var(--gray);
    font-size: 1.05rem;
    line-height: 1.5;
}

/* ================= ACTION CARDS ================= */
.action-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.action-card {
    background: var(--glass-card);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    color: var(--dark);
    transition: var(--transition);
    gap: 12px;
}

.action-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    background: var(--glass-content);
}

.action-card svg {
    width: 32px;
    height: 32px;
    fill: var(--primary);
}

.action-card span {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--dark);
}

/* ================= BOTTOM NAVIGATION ================= */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: var(--glass-nav);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 10px 8px calc(10px + var(--safe-area-bottom));
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
    z-index: 200;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    transition: var(--transition-fast);
}

.dark .bottom-nav {
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--gray);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    padding: 8px 4px;
    position: relative;
    transition: var(--transition-fast);
    flex: 1;
    max-width: 90px;
    border-radius: var(--border-radius-sm);
    -webkit-tap-highlight-color: transparent;
}

.nav-item.active {
    color: var(--primary);
    background: rgba(67, 97, 238, 0.08);
}

.dark .nav-item.active {
    background: rgba(96, 165, 250, 0.15);
}

.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 24px;
    height: 3px;
    background: var(--primary);
    border-radius: 2px;
}

.nav-item svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    transition: var(--transition-fast);
}

.nav-item:hover svg, 
.nav-item.active svg {
    transform: scale(1.1);
}

.nav-item.active svg {
    fill: var(--primary);
}

/* ================= PARTICLES ================= */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: -1;
}

.particle {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    animation: float 15s infinite linear;
}

.dark .particle {
    background: rgba(96, 165, 250, 0.3);
}

@keyframes float {
    0% {
        transform: translateY(0) translateX(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(-100vh) translateX(100px) rotate(720deg);
        opacity: 0;
    }
}

/* ================= TOAST NOTIFICATION ================= */
.toast {
    position: fixed;
    bottom: calc(90px + var(--safe-area-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(255, 255, 255, 0.95);
    color: var(--dark);
    padding: 14px 24px;
    border-radius: 50px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    font-weight: 500;
    transition: transform 0.3s ease, opacity 0.3s ease;
    max-width: 85%;
    text-align: center;
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-input);
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: var(--primary);
}

.toast.success {
    background: rgba(46, 204, 113, 0.95);
    color: white;
}

.toast.success svg {
    fill: white;
}

.toast.error {
    background: rgba(231, 76, 60, 0.95);
    color: white;
}

.toast.error svg {
    fill: white;
}

/* ================= ANIMATIONS ================= */
@keyframes haptic {
    0% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    50% { transform: translateX(2px); }
    75% { transform: translateX(-2px); }
    100% { transform: translateX(0); }
}

.haptic-feedback {
    animation: haptic 0.15s ease-in-out;
}

/* ================= RESPONSIVE DESIGN ================= */
@media (max-width: 767px) {
    .dashboard-header {
        padding: calc(8px + var(--safe-area-top)) 12px 8px;
        margin-bottom: 20px;
    }
    
    .top-header {
        margin-bottom: 12px;
    }
    
    .user span {
        font-size: 1rem;
    }
    
    .balance-info h1 {
        font-size: 1.6rem;
    }
    
    .icon-with-circle-animation {
        width: 50px;
        height: 50px;
    }
    
    .icon-with-circle-animation svg {
        width: 28px;
        height: 28px;
    }
    
    .content {
        padding: 20px 16px;
    }
    
    .page-header h1 {
        font-size: 1.7rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .action-cards {
        grid-template-columns: 1fr;
    }
    
    .action-card {
        padding: 16px;
        flex-direction: row;
        justify-content: flex-start;
        text-align: left;
        gap: 16px;
    }
    
    .action-card svg {
        width: 28px;
        height: 28px;
    }
    
    .action-card span {
        font-size: 1rem;
    }
    
    .bottom-nav {
        padding: 8px 4px calc(8px + var(--safe-area-bottom)) 4px;
    }
    
    .nav-item {
        gap: 2px;
        font-size: 0.65rem;
        padding: 6px 3px;
    }
    
    .nav-item svg {
        width: 22px;
        height: 22px;
    }
}

@media (min-width: 768px) {
    .dashboard-header {
        padding: calc(16px + var(--safe-area-top)) 24px 16px;
        border-radius: 0 0 28px 28px;
        margin-bottom: 28px;
    }
    
    .user span {
        font-size: 1.1rem;
    }
    
    .balance-info h1 {
        font-size: 2rem;
    }
    
    .icon-with-circle-animation {
        width: 70px;
        height: 70px;
    }
    
    .icon-with-circle-animation svg {
        width: 36px;
        height: 36px;
    }
    
    .content {
        padding: 32px 28px;
        border-radius: var(--border-radius-lg);
    }
    
    .page-header h1 {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1.05rem;
    }
    
    .action-cards {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
    
    .action-card {
        padding: 24px;
    }
    
    .action-card svg {
        width: 36px;
        height: 36px;
    }
    
    .action-card span {
        font-size: 1rem;
    }
    
    .bottom-nav {
        max-width: 720px;
        left: 50%;
        transform: translateX(-50%);
        margin: 0 auto;
        padding: 12px 16px calc(12px + var(--safe-area-bottom));
        border-radius: 24px;
        box-shadow: 0 -6px 25px rgba(0, 0, 0, 0.15);
    }
    
    .nav-item {
        font-size: 0.8rem;
        gap: 6px;
        padding: 10px 8px;
        max-width: 110px;
    }
    
    .nav-item svg {
        width: 26px;
        height: 26px;
    }
}

@media (min-width: 1024px) {
    .content {
        padding: 40px 36px;
    }
    
    .page-header h1 {
        font-size: 2.2rem;
    }
    
    .action-cards {
        grid-template-columns: repeat(5, 1fr);
        gap: 24px;
    }
    
    .action-card {
        padding: 28px;
    }
    
    .bottom-nav {
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        max-width: none;
        border-radius: 0;
        bottom: 0;
        padding: 12px 24px;
    }

    .nav-item {
        flex: 1;
        max-width: none;
    }
    
    .nav-item svg {
        width: 28px;
        height: 28px;
    }
}
