:root {
    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
    --gold-primary: #D4AF37;
    --gold-hover: #B8941F;
    --gold-light: #E6C866;
    --gold-dark: #9A7A1A;
    --gold-glow: rgba(212, 175, 55, 0.3);
    --gold-glow-light: rgba(212, 175, 55, 0.1);

    /* app layout sizes (can be tuned) */
    /* app-header-height now derives from --base-height (fallback 64px) so header and content offsets stay in sync */
    --app-header-height: calc(var(--base-height, 64px) + env(safe-area-inset-top)); /* default header height */
    --bottom-nav-height: calc(56px + env(safe-area-inset-bottom)); /* default bottom nav height */
    /* fixed filter card height - tweak if you want a different visual size */
    --filter-height: 72px; /* keeps the filter card a fixed, predictable size */
}

/* Better touch targets */
.mobile-btn, button, [role="button"] {
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
}

/* Gold theme styles */
.gold-button {
    background: linear-gradient(135deg, var(--gold-primary) 0%, var(--gold-light) 100%);
    box-shadow: 0 4px 15px var(--gold-glow-light);
}

.gold-button:hover {
    background: linear-gradient(135deg, var(--gold-hover) 0%, var(--gold-primary) 100%);
    box-shadow: 0 10px 25px var(--gold-glow);
}

.gold-link {
    color: var(--gold-primary);
}

.gold-link:hover {
    color: var(--gold-light);
}

.gold-input:focus {
    box-shadow: 0 0 0 3px var(--gold-glow-light);
    border-color: var(--gold-primary);
}

.gold-divider {
    background: linear-gradient(90deg, var(--gold-primary) 0%, var(--gold-light) 100%);
}

.gold-icon {
    color: var(--gold-primary);
}

/* Loading spinner */
.loader {
    border-top-color: #f59e0b;
    -webkit-animation: spinner 1.5s linear infinite;
    animation: spinner 1.5s linear infinite;
}

@-webkit-keyframes spinner {
    0% { -webkit-transform: rotate(0deg); }
    100% { -webkit-transform: rotate(360deg); }
}

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

/* ===== Prevent body scrolling and overscroll (iOS) ===== */
html, body {
    height: 100%;
    overflow-y: hidden;            /* 禁止整个页面垂直滚动 */
    overscroll-behavior: none;     /* 禁止 iOS 橡皮筋回弹 */
    -webkit-overflow-scrolling: auto;
    /* Prevent mobile browsers from auto-adjusting text size which can trigger zoom */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* Make a dedicated scrollable content region; use this on your main/content container */
.app-content {
    position: absolute;
    top: var(--app-header-height);
    bottom: var(--bottom-nav-height);
    left: 0;
    right: 0;
    overflow-y: auto;                     /* 内容内部可滚动 */
    -webkit-overflow-scrolling: touch;    /* iOS 平滑滚动 */
    overscroll-behavior: contain;         /* 避免内容滚动触发 body 回弹 */
    box-sizing: border-box;
    padding: 1rem; /* keep the same p-4 spacing by default; individual pages can override */
}

/* Helper: when a page places a fixed filter under the header, shift the content down accordingly */
.app-content--with-fixed-filter {
    top: calc(var(--app-header-height) + var(--filter-height));
}

/* Fixed filter card styles: positioned below the header, fixed size, inner area scrolls */
.filter-card {
    position: fixed !important;
    top: var(--app-header-height);
    left: 0;
    right: 0;
    z-index: 35; /* sits below header (z-index:40) and well below app-nav (nav.js sets 99999) */
    box-sizing: border-box;
    padding: 0.5rem;
    background: linear-gradient(180deg, #E0F6FF 0%, #B0E0E6 100%);
}

/* Reduce filter height on smaller screens so it fits better */
@media (max-width: 480px) {
    /* If a page needs extra bottom padding for FAB / nav overlap, add a helper */
    .app-content--with-padding-bottom{
        padding-bottom: calc(var(--bottom-nav-height) + 1rem);
    }

    /* Safe area insets for notched devices */
    .safe-top {
        padding-top: env(safe-area-inset-top);
    }
    .safe-bottom {
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Standardized app header to match Expenses page and reserve space for notched devices */
    .app-header {
        /* Base height matches the visual size of expenses header (p-4 ~ 16px padding + content) */
        --base-height: 64px; /* fallback */
        height: calc(var(--base-height) + env(safe-area-inset-top));
        min-height: calc(56px + env(safe-area-inset-top));
        display: block;
        position: fixed; /* make header fixed at top so it doesn't move when content scrolls */
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        z-index: 40;
        padding-left: 1rem; /* keep some horizontal padding like p-4 */
        padding-right: 1rem;
        background-repeat: no-repeat;
        /* Prevent touch-driven panning on the header itself (keeps it fixed on mobile keyboards) */
        touch-action: none;
        -webkit-user-drag: none;
        -webkit-user-select: none;
        user-select: none;
    }

    /* Inner container inside header — ensure content sits towards the bottom so text/buttons are lower */
    .app-header > .header-inner {
        height: var(--base-height);
        display: flex;
        /* Keep return/back button size as-is; align other header content vertically center with the back button */
        align-items: center; /* center content vertically so title and actions align with back-btn */
        justify-content: space-between;
        gap: 0.5rem;
    }

    /* Reset previous bottom padding — titles and actions should vertically center with back button */
    .app-header .header-content {
        padding-bottom: 6px;
    }

    /* Make sure buttons inside header are vertically aligned to the lower area */
    .app-header button,
    .app-header .header-actions > * {
        align-self: flex-end;
        /* Ensure interactive controls inside header remain selectable/clickable */
        -webkit-user-select: auto;
        user-select: auto;
    }

    /* Header alignment helpers: ensure back icon, title, and action buttons share consistent sizing and vertical alignment */
    .app-header .header-left {
        display: flex;
        align-items: center; /* center content vertically within the header content area */
        gap: 0.5rem;
    }

    /* Back button / back link */
    .app-header .back-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        min-width: 44px;
        border-radius: 8px;
        box-sizing: border-box;
        padding: 6px;
        color: inherit;
        text-decoration: none;
    }

    /* Header title to align with back button */
    .app-header .header-title {
        display: inline-flex;
        align-items: center;
        height: 44px;
        line-height: 1;
        padding-top: 2px; /* small nudge so text visually centers with icon */
    }

    /* Action buttons on the right (add / logout) */
    .app-header .header-action-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        height: 44px;
        min-width: 44px;
        padding: 6px 10px;
        border-radius: 8px;
        box-sizing: border-box;
    }

    /* Ensure svg icons inside these controls scale consistently */
    .app-header .back-btn svg,
    .app-header .header-action-btn svg,
    .app-header .header-title svg {
        width: 20px;
        height: 20px;
    }

    /* Responsive adjustments: smaller height on tight screens, larger on tablets */
    @media (max-width: 480px) {
        :root {
            --base-height: 56px;
        }
        .app-header { min-height: calc(52px + env(safe-area-inset-top)); }
    }

    @media (min-width: 769px) {
        :root {
            --base-height: 72px;
        }
        .app-header { min-height: calc(64px + env(safe-area-inset-top)); }
    }

    /* Mobile-first responsive design */
    @media (max-width: 768px) {
        input, select, textarea {
            font-size: 16px !important;
        }
        .container {
            padding-left: 1rem;
            padding-right: 1rem;
        }
        
        .mobile-stack {
            flex-direction: column;
        }
        
        .mobile-btn {
            min-height: 44px;
            min-width: 44px;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .mobile-chart {
            height: 200px !important;
        }
        
        .mobile-input {
            font-size: 16px;
            padding: 12px;
        }

        /* Mobile-specific input sizing to prevent iOS auto-zoom when focusing inputs */
        /* Ensure interactive form inputs are at least 16px on mobile to avoid auto-zoom */
        #app-select-modal input[type="search"],
        #app-select-modal input,
        .app-content input,
        .app-content textarea,
        .app-content select,
        input.mobile-input,
        .mobile-input {
            font-size: 16px !important;
            line-height: 1.2 !important;
            -webkit-text-size-adjust: 100% !important;
        }

        /* If the select modal panel uses small inputs, ensure the padding/height is comfortable */
        #app-select-modal .w-full {
            padding-top: 10px !important;
            padding-bottom: 10px !important;
        }
    }

    /* Touch-friendly styles */
    .swipe-item {
        touch-action: pan-y;
    }

    /* Duolingo-style Animations */
    .duolingo-bounce {
        animation: duolingoBounce 0.6s ease-in-out;
    }

    .duolingo-success {
        animation: duolingoSuccess 1.2s ease-out;
    }

    .duolingo-celebration {
        animation: duolingoCelebration 2s ease-out;
    }

    .duolingo-progress-bounce {
        animation: duolingoProgressBounce 0.8s ease-in-out infinite alternate;
    }

    .duolingo-upload-pulse {
        animation: duolingoUploadPulse 1.5s ease-in-out infinite;
    }

    .duolingo-receipt-scan {
        animation: duolingoReceiptScan 2s ease-in-out infinite;
    }

    .duolingo-completion-fireworks {
        animation: duolingoCompletionFireworks 3s ease-out;
    }

    /* Keyframe Animations */
    @keyframes duolingoBounce {
        0% { transform: scale(1); }
        25% { transform: scale(1.1); }
        50% { transform: scale(0.95); }
        75% { transform: scale(1.05); }
        100% { transform: scale(1); }
    }

    @keyframes duolingoSuccess {
        0% { 
            transform: scale(1) rotate(0deg);
            opacity: 1;
        }
        25% { 
            transform: scale(1.2) rotate(5deg);
            opacity: 0.9;
        }
        50% { 
            transform: scale(1.1) rotate(-3deg);
            opacity: 1;
        }
        75% { 
            transform: scale(1.15) rotate(2deg);
            opacity: 0.95;
        }
        100% { 
            transform: scale(1) rotate(0deg);
            opacity: 1;
        }
    }

    @keyframes duolingoCelebration {
        0% { 
            transform: scale(1) translateY(0);
            box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
        }
        20% { 
            transform: scale(1.3) translateY(-10px);
            box-shadow: 0 8px 25px rgba(212, 175, 55, 0.5);
        }
        40% { 
            transform: scale(1.1) translateY(-5px);
            box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
        }
        60% { 
            transform: scale(1.2) translateY(-8px);
            box-shadow: 0 7px 22px rgba(212, 175, 55, 0.45);
        }
        80% { 
            transform: scale(1.05) translateY(-2px);
            box-shadow: 0 5px 18px rgba(212, 175, 55, 0.35);
        }
        100% { 
            transform: scale(1) translateY(0);
            box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
        }
    }

    @keyframes duolingoProgressBounce {
        0% { 
            transform: translateY(0) scale(1);
            opacity: 0.8;
        }
        100% { 
            transform: translateY(-5px) scale(1.05);
            opacity: 1;
        }
    }

    @keyframes duolingoUploadPulse {
        0% { 
            transform: scale(1);
            box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.4);
        }
        50% { 
            transform: scale(1.05);
            box-shadow: 0 0 0 10px rgba(212, 175, 55, 0.1);
        }
        100% { 
            transform: scale(1);
            box-shadow: 0 0 0 0 rgba(212, 175, 55, 0);
        }
    }

    @keyframes duolingoReceiptScan {
        0% { 
            transform: translateX(-100%) rotate(-5deg);
            opacity: 0;
        }
        25% { 
            transform: translateX(-50%) rotate(-2deg);
            opacity: 0.7;
        }
        50% { 
            transform: translateX(0%) rotate(0deg);
            opacity: 1;
        }
        75% { 
            transform: translateX(50%) rotate(2deg);
            opacity: 0.7;
        }
        100% { 
            transform: translateX(100%) rotate(5deg);
            opacity: 0;
        }
    }

    @keyframes duolingoCompletionFireworks {
        0% { 
            transform: scale(1) rotate(0deg);
            opacity: 1;
        }
        10% { 
            transform: scale(1.4) rotate(10deg);
            opacity: 0.9;
        }
        20% { 
            transform: scale(1.2) rotate(-5deg);
            opacity: 1;
        }
        30% { 
            transform: scale(1.5) rotate(8deg);
            opacity: 0.8;
        }
        40% { 
            transform: scale(1.1) rotate(-3deg);
            opacity: 1;
        }
        50% { 
            transform: scale(1.3) rotate(6deg);
            opacity: 0.9;
        }
        60% { 
            transform: scale(1.05) rotate(-2deg);
            opacity: 1;
        }
        70% { 
            transform: scale(1.2) rotate(4deg);
            opacity: 0.95;
        }
        80% { 
            transform: scale(1.1) rotate(-1deg);
            opacity: 1;
        }
        90% { 
            transform: scale(1.15) rotate(2deg);
            opacity: 0.98;
        }
        100% { 
            transform: scale(1) rotate(0deg);
            opacity: 1;
        }
    }

    /* Animated progress bar */
    .duolingo-progress-bar {
        position: relative;
        overflow: hidden;
        background: linear-gradient(90deg, #E0F6FF 0%, #B0E0E6 100%);
        border-radius: 10px;
    }

    .duolingo-progress-bar::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.6), transparent);
        animation: duolingoProgressShimmer 2s ease-in-out infinite;
    }

    @keyframes duolingoProgressShimmer {
        0% { left: -100%; }
        100% { left: 100%; }
    }

    /* 3D Owl character */
    .duolingo-bird {
        position: relative;
        width: 80px;
        height: 80px;
        margin: 0 auto;
    }

    .duolingo-bird-body {
        width: 60px;
        height: 60px;
        background: linear-gradient(135deg, #8BC34A 0%, #689F38 50%, #558B2F 100%);
        border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
        position: relative;
        animation: duolingoBirdWalking 2s ease-in-out infinite;
        border: 2px solid #2E7D32;
        box-shadow: 
            0 6px 12px rgba(0, 0, 0, 0.3),
            inset 0 2px 4px rgba(255, 255, 255, 0.3),
            inset 0 -2px 4px rgba(0, 0, 0, 0.2);
    }

    .duolingo-bird-eyes {
        position: absolute;
        top: 15px;
        left: 50%;
        transform: translateX(-50%);
        width: 30px;
        height: 20px;
    }

    .duolingo-bird-eye {
        position: absolute;
        top: 0;
        width: 12px;
        height: 12px;
        background: white;
        border-radius: 50%;
        animation: duolingoBirdBlink 4s ease-in-out infinite;
        border: 2px solid #2E7D32;
        box-shadow: 
            inset 0 2px 4px rgba(0, 0, 0, 0.1),
            0 2px 4px rgba(0, 0, 0, 0.2);
    }

    .duolingo-bird-eye.left {
        left: 0;
    }

    .duolingo-bird-eye.right {
        right: 0;
    }

    .duolingo-bird-pupil {
        position: absolute;
        top: 2px;
        left: 2px;
        width: 8px;
        height: 8px;
        background: #2E7D32;
        border-radius: 50%;
        animation: duolingoBirdFocus 3s ease-in-out infinite;
    }

    .duolingo-bird-beak {
        position: absolute;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        width: 0;
        height: 0;
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
        border-top: 6px solid #FF8C00;
        filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    }

    .duolingo-bird-wing {
        position: absolute;
        top: 25px;
        right: -8px;
        width: 20px;
        height: 25px;
        background: linear-gradient(135deg, #689F38 0%, #558B2F 100%);
        border-radius: 50% 20% 50% 20%;
        animation: duolingoBirdWingWalk 1.5s ease-in-out infinite;
        border: 2px solid #2E7D32;
        box-shadow: 
            0 3px 6px rgba(0, 0, 0, 0.2),
            inset 0 1px 2px rgba(255, 255, 255, 0.2);
    }

    .duolingo-bird-tail {
        position: absolute;
        bottom: 15px;
        left: -10px;
        width: 15px;
        height: 20px;
        background: linear-gradient(135deg, #689F38 0%, #558B2F 100%);
        border-radius: 20% 50% 20% 50%;
        border: 2px solid #2E7D32;
        animation: duolingoBirdTailWalk 2s ease-in-out infinite;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    }

    .duolingo-bird-feet {
        position: absolute;
        bottom: -8px;
        left: 50%;
        transform: translateX(-50%);
        width: 20px;
        height: 8px;
    }

    .duolingo-bird-foot {
        position: absolute;
        width: 8px;
        height: 6px;
        background: #FF8C00;
        border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
        border: 1px solid #E65100;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }

    .duolingo-bird-foot.left {
        left: 2px;
        animation: duolingoBirdStepWalk 1s ease-in-out infinite;
    }

    .duolingo-bird-foot.right {
        right: 2px;
        animation: duolingoBirdStepWalk 1s ease-in-out infinite 0.5s;
    }

    /* Feather details on belly */
    .duolingo-bird-body::before {
        content: '';
        position: absolute;
        bottom: 15px;
        left: 50%;
        transform: translateX(-50%);
        width: 20px;
        height: 8px;
        background: linear-gradient(135deg, #8BC34A 0%, #689F38 100%);
        border-radius: 10px;
        opacity: 0.7;
    }

    .duolingo-bird-body::after {
        content: '';
        position: absolute;
        bottom: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 15px;
        height: 6px;
        background: linear-gradient(135deg, #8BC34A 0%, #689F38 100%);
        border-radius: 8px;
        opacity: 0.5;
    }

    /* Owl GIF Container */
    .owl-gif-container {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 120px;
        height: 120px;
        margin: 0 auto;
    }

    .owl-gif-processing {
        width: 100px;
        height: 100px;
        object-fit: contain;
        animation: owlGifBounce 1.5s ease-in-out infinite;
    }

    /* Blue owl for page reloads */
    .owl-gif-blue {
        filter: hue-rotate(200deg) saturate(1.8) brightness(1.2) contrast(1.1);
    }

    /* Flying owl GIF animation */
    .owl-gif-flying {
        position: fixed;
        top: 50%;
        left: -150px;
        z-index: 9999;
        width: 200px;
        height: 200px;
        animation: owlGifFlyAcross 4s ease-in-out forwards;
        pointer-events: none;
    }

    .owl-gif-flying img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    /* Screen covering flying animation */
    .owl-gif-screen-cover {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        z-index: 10000;
        background: linear-gradient(135deg, #E0F6FF 0%, #B0E0E6 100%);
        display: flex;
        justify-content: center;
        align-items: center;
        animation: owlGifScreenFly 3s ease-in-out forwards;
        pointer-events: none;
    }

    .owl-gif-screen-cover img {
        width: 300px;
        height: 300px;
        object-fit: contain;
        animation: owlGifScreenBounce 0.5s ease-in-out infinite;
    }


    @keyframes duolingoBirdWalking {
        0%, 100% { 
            transform: translateY(0) translateX(0) scale(1);
        }
        25% { 
            transform: translateY(-2px) translateX(1px) scale(1.01);
        }
        50% { 
            transform: translateY(-4px) translateX(0) scale(1.02);
        }
        75% { 
            transform: translateY(-1px) translateX(-1px) scale(1.005);
        }
    }

    @keyframes duolingoBirdHeadBob {
        0%, 100% { 
            transform: translateX(-50%) translateY(0) rotate(0deg);
        }
        25% { 
            transform: translateX(-50%) translateY(-1px) rotate(1deg);
        }
        50% { 
            transform: translateX(-50%) translateY(-2px) rotate(0deg);
        }
        75% { 
            transform: translateX(-50%) translateY(-1px) rotate(-1deg);
        }
    }

    @keyframes duolingoBirdBlink {
        0%, 90%, 100% { 
            height: 8px;
        }
        95% { 
            height: 2px;
        }
    }

    @keyframes duolingoBirdWingWalk {
        0%, 100% { 
            transform: rotate(0deg) scaleY(1);
        }
        25% { 
            transform: rotate(-10deg) scaleY(0.95);
        }
        50% { 
            transform: rotate(-5deg) scaleY(1.05);
        }
        75% { 
            transform: rotate(-12deg) scaleY(0.98);
        }
    }

    @keyframes duolingoBirdTailWalk {
        0%, 100% { 
            transform: rotate(0deg);
        }
        25% { 
            transform: rotate(3deg);
        }
        50% { 
            transform: rotate(-2deg);
        }
        75% { 
            transform: rotate(4deg);
        }
    }

    @keyframes duolingoBirdStepWalk {
        0%, 100% { 
            transform: translateY(0) rotate(0deg);
        }
        50% { 
            transform: translateY(-2px) rotate(2deg);
        }
    }

    @keyframes duolingoBirdLook {
        0%, 100% { 
            transform: translateX(0);
        }
        25% { 
            transform: translateX(1px);
        }
        75% { 
            transform: translateX(-1px);
        }
    }

    @keyframes duolingoBirdTailWork {
        0%, 100% { 
            transform: rotate(0deg);
        }
        40% { 
            transform: rotate(5deg);
        }
        70% { 
            transform: rotate(-3deg);
        }
    }

    @keyframes duolingoBirdFocus {
        0%, 100% { 
            transform: translateX(0);
        }
        50% { 
            transform: translateX(1px);
        }
    }

    @keyframes duolingoBirdStepWork {
        0%, 100% { 
            transform: translateY(0);
        }
        50% { 
            transform: translateY(-1px);
        }
    }

    @keyframes duolingoBirdStep {
        0%, 100% { 
            transform: translateY(0);
        }
        50% { 
            transform: translateY(-2px);
        }
    }

    /* Mobile app style progress container */
    .duolingo-mobile-progress {
        position: relative;
        background: linear-gradient(135deg, #E0F6FF 0%, #B0E0E6 100%);
        border-radius: 20px;
        padding: 20px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
        border: 2px solid rgba(212, 175, 55, 0.2);
    }

    .duolingo-mobile-progress::before {
        content: '';
        position: absolute;
        top: -2px;
        left: -2px;
        right: -2px;
        bottom: -2px;
        background: linear-gradient(45deg, #D4AF37, #F4D03F, #D4AF37);
        border-radius: 22px;
        z-index: -1;
        animation: duolingoBorderGlow 2s ease-in-out infinite;
    }

    @keyframes duolingoBorderGlow {
        0%, 100% { 
            opacity: 0.3;
        }
        50% { 
            opacity: 0.8;
        }
    }

    /* Bird character states */
    .duolingo-bird-happy {
        animation: duolingoBirdHappy 1s ease-out;
    }

    .duolingo-bird-working {
        animation: duolingoBirdWorking 2s ease-in-out infinite;
    }

    .duolingo-bird-success {
        animation: duolingoBirdSuccess 1.5s ease-out;
    }

    @keyframes duolingoBirdHappy {
        0% { transform: scale(1) rotate(0deg); }
        25% { transform: scale(1.2) rotate(5deg); }
        50% { transform: scale(1.1) rotate(-3deg); }
        75% { transform: scale(1.15) rotate(2deg); }
        100% { transform: scale(1) rotate(0deg); }
    }

    @keyframes duolingoBirdWorking {
        0%, 100% { 
            transform: translateY(0) scale(1);
        }
        25% { 
            transform: translateY(-5px) scale(1.05);
        }
        50% { 
            transform: translateY(-8px) scale(1.1);
        }
        75% { 
            transform: translateY(-3px) scale(1.03);
        }
    }

    @keyframes duolingoBirdSuccess {
        0% { 
            transform: scale(1) rotate(0deg);
            background: linear-gradient(135deg, #58CC02 0%, #4CAF50 100%);
        }
        20% { 
            transform: scale(1.2) rotate(5deg);
            background: linear-gradient(135deg, #4CAF50 0%, #2E7D32 100%);
        }
        40% { 
            transform: scale(1.1) rotate(-3deg);
            background: linear-gradient(135deg, #58CC02 0%, #4CAF50 100%);
        }
        60% { 
            transform: scale(1.15) rotate(2deg);
            background: linear-gradient(135deg, #4CAF50 0%, #2E7D32 100%);
        }
        80% { 
            transform: scale(1.05) rotate(-1deg);
            background: linear-gradient(135deg, #58CC02 0%, #4CAF50 100%);
        }
        100% { 
            transform: scale(1) rotate(0deg);
            background: linear-gradient(135deg, #58CC02 0%, #4CAF50 100%);
        }
    }

    /* Success checkmark animation */
    .duolingo-checkmark {
        animation: duolingoCheckmark 0.8s ease-out;
    }

    @keyframes duolingoCheckmark {
        0% { 
            transform: scale(0) rotate(45deg);
            opacity: 0;
        }
        50% { 
            transform: scale(1.2) rotate(45deg);
            opacity: 0.8;
        }
        100% { 
            transform: scale(1) rotate(45deg);
            opacity: 1;
        }
    }

    /* Scrollbar styling */
    ::-webkit-scrollbar {
        width: 6px;
    }

    ::-webkit-scrollbar-track {
        background: #111827;
    }

    ::-webkit-scrollbar-thumb {
        background: #4b5563;
        border-radius: 10px;
    }

    /* Brand typography */
    .brand-title {
        font-family: 'Orbitron', monospace;
        font-weight: 900;
        letter-spacing: -0.02em;
        text-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
    }

    .brand-subtitle {
        font-family: 'Space Grotesk', sans-serif;
        font-weight: 500;
        letter-spacing: 0.01em;
    }

    .brand-description {
        font-family: 'Space Grotesk', sans-serif;
        font-weight: 300;
        letter-spacing: 0.02em;
    }

    /* Fix jar images overlapping bottom nav */
    #plan-details-container {
        position: relative;
        z-index: 1;
    }

    /* Jar container styles */
    .jar-container {
        background-color: transparent;
        padding-top: 10px;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        position: relative;
        z-index: 1;
    }

    .jar-visuals {
        position: relative;
        width: 100px;
        height: 100px;
    }

    .jar-progress,
    .jar-image,
    .jar-text-overlay {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }

    .jar-progress {
        width: 50%;
        height: 55px;
        background-color: #374151;
        border-radius: 18px;
        overflow: hidden;
        z-index: 1;
        position: absolute;
        left: 50%;
        top: 30px;
        transform: translateX(-50%);
    }

    .jar-fill {
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        transition: height 0.5s ease-in-out;
    }

    .jar-image {
        width: 100px;
        height: 100px;
        z-index: 2;
        -webkit-user-drag: none;
        user-select: none;
        position: relative;
        z-index: 1;
    }

    .jar-text-overlay {
        z-index: 3;
        pointer-events: none;
        color: white;
        text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.8);
        width: 100%;
        text-align: center;
    }

    /* Bottom navigation active state */
    .nav-active {
        color: var(--gold-primary);
    }

    /* Mobile swipe gestures */
    .swipe-area {
        touch-action: pan-y;
    }

    /* Ensure bottom nav has highest z-index */
    nav.fixed.bottom-0 {
        z-index: 1000 !important;
        position: fixed;
    }

    /* Main content padding to prevent overlap */
    main.p-4.pb-20 {
        padding-bottom: 6rem !important; /* Extra space for bottom nav */
    }

    /* Safe area adjustment for modern phones */
    @supports (padding: max(0px)) {
        nav.fixed.bottom-0 {
            padding-bottom: env(safe-area-inset-bottom);
        }
        
        main.p-4.pb-20 {
            padding-bottom: calc(6rem + env(safe-area-inset-bottom)) !important;
        }
    }

    /* Dashboard specific styling to match the image */
    .dashboard-container {
        font-family: 'Inter', sans-serif;
        background-color: #87CEEB;
    }

    .dashboard-greeting {
        color: #2C3E50;
        font-weight: 700;
        font-size: 1.25rem;
    }

    .dashboard-subtitle {
        color: #5A6C7D;
        background-color: #B0E0E6;
        padding: 8px 12px;
        border-radius: 20px;
        font-size: 0.875rem;
        margin-top: 4px;
    }

    .spending-summary-box {
        background-color: white;
        border-radius: 12px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        padding: 16px;
    }

    .spending-label {
        background-color: #FCD34D;
        color: #1F2937;
        font-weight: 700;
        padding: 4px 12px;
        border-radius: 8px;
        display: inline-block;
        margin-bottom: 8px;
    }

    .spending-value {
        font-weight: 700;
        font-size: 1.5rem;
    }

    .spending-value.income {
        color: #059669;
    }

    .spending-value.expense {
        color: #DC2626;
    }

    .spending-value.net {
        color: #059669;
    }

    .chart-container {
        background-color: white;
        border-radius: 12px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        padding: 16px;
    }

    .calendar-container {
        background-color: #87CEEB;
        border-radius: 12px;
        padding: 16px;
    }

    .calendar-header {
        color: #2C3E50;
        font-weight: 600;
    }

    .calendar-button {
        color: #2C3E50;
        padding: 8px;
    }

    .monthly-summary {
        background-color: white;
        border-radius: 8px;
        padding: 8px;
        text-align: center;
    }

    .monthly-summary-text {
        color: #2C3E50;
        font-size: 0.875rem;
    }

    .monthly-summary-amount {
        color: #2C3E50;
        font-weight: 700;
        font-size: 1.125rem;
    }

    .spending-meter {
        background-color: #E6E6FA;
        border-radius: 12px;
        padding: 16px;
    }

    .spending-meter-header {
        background-color: #2563EB;
        color: white;
        padding: 4px 12px;
        border-radius: 8px;
        font-weight: 700;
        font-size: 1.125rem;
        display: inline-block;
        margin-bottom: 12px;
    }

    .spending-meter-content {
        color: #2C3E50;
        font-size: 0.875rem;
    }

    /* Owl flying animations */
    @keyframes owlFlyAcross {
        0% {
            left: -100px;
            transform: translateY(-50%) rotate(0deg);
        }
        20% {
            left: 20%;
            transform: translateY(-50%) rotate(5deg);
        }
        40% {
            left: 40%;
            transform: translateY(-50%) rotate(-3deg);
        }
        60% {
            left: 60%;
            transform: translateY(-50%) rotate(2deg);
        }
        80% {
            left: 80%;
            transform: translateY(-50%) rotate(-1deg);
        }
        100% {
            left: calc(100% + 100px);
            transform: translateY(-50%) rotate(0deg);
        }
    }

    @keyframes owlFlyWingFlap {
        0%, 100% {
            transform: rotate(0deg) scaleY(1);
        }
        25% {
            transform: rotate(-15deg) scaleY(0.7);
        }
        50% {
            transform: rotate(-25deg) scaleY(0.5);
        }
        75% {
            transform: rotate(-15deg) scaleY(0.7);
        }
    }

    /* Owl processing animations */
    @keyframes owlProcessingBounce {
        0%, 100% {
            transform: translateY(0) scale(1);
        }
        25% {
            transform: translateY(-8px) scale(1.05);
        }
        50% {
            transform: translateY(-12px) scale(1.1);
        }
        75% {
            transform: translateY(-8px) scale(1.05);
        }
    }

    @keyframes owlProcessingWingFlap {
        0%, 100% {
            transform: rotate(0deg) scaleY(1);
        }
        25% {
            transform: rotate(-20deg) scaleY(0.6);
        }
        50% {
            transform: rotate(-35deg) scaleY(0.3);
        }
        75% {
            transform: rotate(-20deg) scaleY(0.6);
        }
    }

    @keyframes owlProcessingEyes {
        0%, 100% {
            transform: scale(1);
        }
        25% {
            transform: scale(1.2);
        }
        50% {
            transform: scale(1.1);
        }
        75% {
            transform: scale(1.3);
        }
    }

    /* Owl GIF Animations */
    @keyframes owlGifBounce {
        0%, 100% {
            transform: translateY(0) scale(1);
        }
        25% {
            transform: translateY(-10px) scale(1.05);
        }
        50% {
            transform: translateY(-15px) scale(1.1);
        }
        75% {
            transform: translateY(-10px) scale(1.05);
        }
    }

    @keyframes owlGifFlyAcross {
        0% {
            left: -150px;
            transform: translateY(-50%) rotate(0deg) scale(1);
        }
        20% {
            left: 20%;
            transform: translateY(-50%) rotate(5deg) scale(1.1);
        }
        40% {
            left: 40%;
            transform: translateY(-50%) rotate(-3deg) scale(1.05);
        }
        60% {
            left: 60%;
            transform: translateY(-50%) rotate(2deg) scale(1.1);
        }
        80% {
            left: 80%;
            transform: translateY(-50%) rotate(-1deg) scale(1.05);
        }
        100% {
            left: calc(100% + 150px);
            transform: translateY(-50%) rotate(0deg) scale(1);
        }
    }

    @keyframes owlGifScreenFly {
        0% {
            opacity: 0;
            transform: scale(0.5);
        }
        20% {
            opacity: 1;
            transform: scale(1.2);
        }
        40% {
            opacity: 1;
            transform: scale(1);
        }
        60% {
            opacity: 1;
            transform: scale(1.1);
        }
        80% {
            opacity: 1;
            transform: scale(1);
        }
        100% {
            opacity: 0;
            transform: scale(1.5);
        }
    }

    @keyframes owlGifScreenBounce {
        0%, 100% {
            transform: translateY(0) rotate(0deg);
        }
        25% {
            transform: translateY(-20px) rotate(5deg);
        }
        50% {
            transform: translateY(-30px) rotate(0deg);
        }
        75% {
            transform: translateY(-20px) rotate(-5deg);
        }
    }

    /* Cute Character System */
    .cute-character {
        position: relative;
        display: inline-block;
        animation: characterBounce 2s ease-in-out infinite;
    }

    .cute-character-happy {
        animation: characterHappy 1.5s ease-in-out infinite;
    }

    .cute-character-working {
        animation: characterWorking 1s ease-in-out infinite;
    }

    .cute-character-celebrating {
        animation: characterCelebrating 0.8s ease-in-out infinite;
    }

    .cute-character-thinking {
        animation: characterThinking 2s ease-in-out infinite;
    }


    /* Cute Dog Character */
    .cute-dog {
        width: 40px;
        height: 40px;
        position: relative;
        margin: 0 auto;
    }

    .cute-dog-body {
        width: 30px;
        height: 25px;
        background: linear-gradient(135deg, #87CEEB 0%, #4682B4 100%);
        border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
        position: relative;
        border: 2px solid #4682B4;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .cute-dog-head {
        position: absolute;
        top: -8px;
        left: 50%;
        transform: translateX(-50%);
        width: 20px;
        height: 20px;
        background: linear-gradient(135deg, #87CEEB 0%, #4682B4 100%);
        border-radius: 50%;
        border: 2px solid #4682B4;
    }

    .cute-dog-ears {
        position: absolute;
        top: -2px;
        left: 50%;
        transform: translateX(-50%);
        width: 16px;
        height: 10px;
    }

    .cute-dog-ear {
        position: absolute;
        width: 6px;
        height: 10px;
        background: linear-gradient(135deg, #87CEEB 0%, #4682B4 100%);
        border-radius: 50% 50% 0 0;
        border: 1px solid #4682B4;
        animation: dogEarFlap 2s ease-in-out infinite;
    }

    .cute-dog-ear.left {
        left: 0;
        transform: rotate(-10deg);
    }

    .cute-dog-ear.right {
        right: 0;
        transform: rotate(10deg);
    }

    .cute-dog-eyes {
        position: absolute;
        top: 4px;
        left: 50%;
        transform: translateX(-50%);
        width: 12px;
        height: 6px;
    }

    .cute-dog-eye {
        position: absolute;
        width: 4px;
        height: 4px;
        background: #2C3E50;
        border-radius: 50%;
        animation: dogBlink 4s ease-in-out infinite;
    }

    .cute-dog-eye.left {
        left: 1px;
    }

    .cute-dog-eye.right {
        right: 1px;
    }

    .cute-dog-nose {
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 3px;
        height: 2px;
        background: #2C3E50;
        border-radius: 50%;
    }

    /* Cute Rabbit Character */
    .cute-rabbit {
        width: 40px;
        height: 40px;
        position: relative;
        margin: 0 auto;
    }

    .cute-rabbit-body {
        width: 25px;
        height: 20px;
        background: linear-gradient(135deg, #F0F8FF 0%, #E6E6FA 100%);
        border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
        position: relative;
        border: 2px solid #DDA0DD;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .cute-rabbit-head {
        position: absolute;
        top: -10px;
        left: 50%;
        transform: translateX(-50%);
        width: 18px;
        height: 18px;
        background: linear-gradient(135deg, #F0F8FF 0%, #E6E6FA 100%);
        border-radius: 50%;
        border: 2px solid #DDA0DD;
    }

    .cute-rabbit-ears {
        position: absolute;
        top: -5px;
        left: 50%;
        transform: translateX(-50%);
        width: 12px;
        height: 12px;
    }

    .cute-rabbit-ear {
        position: absolute;
        width: 4px;
        height: 12px;
        background: linear-gradient(135deg, #F0F8FF 0%, #E6E6FA 100%);
        border-radius: 50% 50% 0 0;
        border: 1px solid #DDA0DD;
        animation: rabbitEarWiggle 1.5s ease-in-out infinite;
    }

    .cute-rabbit-ear.left {
        left: 0;
        transform: rotate(-5deg);
    }

    .cute-rabbit-ear.right {
        right: 0;
        transform: rotate(5deg);
    }

    .cute-rabbit-eyes {
        position: absolute;
        top: 4px;
        left: 50%;
        transform: translateX(-50%);
        width: 10px;
        height: 6px;
    }

    .cute-rabbit-eye {
        position: absolute;
        width: 3px;
        height: 3px;
        background: #2C3E50;
        border-radius: 50%;
        animation: rabbitBlink 2.5s ease-in-out infinite;
    }

    .cute-rabbit-eye.left {
        left: 1px;
    }

    .cute-rabbit-eye.right {
        right: 1px;
    }

    .cute-rabbit-nose {
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 2px;
        height: 2px;
        background: #FF69B4;
        border-radius: 50%;
    }

    /* Character Animations */
    @keyframes characterBounce {
        0%, 100% {
            transform: translateY(0) scale(1);
        }
        50% {
            transform: translateY(-5px) scale(1.05);
        }
    }

    @keyframes characterHappy {
        0%, 100% {
            transform: translateY(0) rotate(0deg) scale(1);
        }
        25% {
            transform: translateY(-8px) rotate(2deg) scale(1.1);
        }
        50% {
            transform: translateY(-12px) rotate(0deg) scale(1.15);
        }
        75% {
            transform: translateY(-8px) rotate(-2deg) scale(1.1);
        }
    }

    @keyframes characterWorking {
        0%, 100% {
            transform: translateY(0) rotate(0deg);
        }
        25% {
            transform: translateY(-3px) rotate(1deg);
        }
        50% {
            transform: translateY(-6px) rotate(0deg);
        }
        75% {
            transform: translateY(-3px) rotate(-1deg);
        }
    }

    @keyframes characterCelebrating {
        0%, 100% {
            transform: translateY(0) rotate(0deg) scale(1);
        }
        25% {
            transform: translateY(-10px) rotate(5deg) scale(1.2);
        }
        50% {
            transform: translateY(-15px) rotate(0deg) scale(1.3);
        }
        75% {
            transform: translateY(-10px) rotate(-5deg) scale(1.2);
        }
    }

    @keyframes characterThinking {
        0%, 100% {
            transform: translateY(0) rotate(0deg);
        }
        33% {
            transform: translateY(-2px) rotate(1deg);
        }
        66% {
            transform: translateY(-4px) rotate(-1deg);
        }
    }

    @keyframes penguinBlink {
        0%, 90%, 100% {
            height: 4px;
        }
        95% {
            height: 1px;
        }
    }

    @keyframes dogBlink {
        0%, 90%, 100% {
            height: 4px;
        }
        95% {
            height: 1px;
        }
    }

    @keyframes dogEarFlap {
        0%, 100% {
            transform: rotate(0deg);
        }
        50% {
            transform: rotate(5deg);
        }
    }

    @keyframes rabbitBlink {
        0%, 90%, 100% {
            height: 3px;
        }
        95% {
            height: 1px;
        }
    }

    @keyframes rabbitEarWiggle {
        0%, 100% {
            transform: rotate(0deg);
        }
        25% {
            transform: rotate(2deg);
        }
        75% {
            transform: rotate(-2deg);
        }
    }

    /* Running Character Animation */
    @keyframes characterRun {
        0%, 100% {
            transform: translateY(-50%) translateX(0);
        }
        25% {
            transform: translateY(-60%) translateX(-2px);
        }
        50% {
            transform: translateY(-50%) translateX(0);
        }
        75% {
            transform: translateY(-40%) translateX(2px);
        }
    }

    /* Running Man Sprite Animation */
    @keyframes runLegLeft {
        0%, 50%, 100% {
            transform: rotate(15deg);
        }
        25% {
            transform: rotate(45deg);
        }
        75% {
            transform: rotate(-10deg);
        }
    }

    @keyframes runLegRight {
        0%, 50%, 100% {
            transform: rotate(-15deg);
        }
        25% {
            transform: rotate(-45deg);
        }
        75% {
            transform: rotate(10deg);
        }
    }

    @keyframes runArmLeft {
        0%, 50%, 100% {
            transform: rotate(-15deg);
        }
        25% {
            transform: rotate(-45deg);
        }
        75% {
            transform: rotate(10deg);
        }
    }

    @keyframes runArmRight {
        0%, 50%, 100% {
            transform: rotate(15deg);
        }
        25% {
            transform: rotate(45deg);
        }
        75% {
            transform: rotate(-10deg);
        }
    }

    .running-man {
        width: 36px;
        height: 36px;
        position: relative;
        animation: runBounce 0.6s ease-in-out infinite;
    }

    .running-man-head {
        width: 18px;
        height: 18px;
        background: linear-gradient(135deg, #FFDBAC 0%, #E6C296 100%);
        border-radius: 50%;
        position: absolute;
        top: 2px;
        left: 50%;
        transform: translateX(-50%);
        border: 2px solid #D4A574;
        box-shadow: 
            0 2px 4px rgba(0, 0, 0, 0.15),
            inset 0 1px 2px rgba(255, 255, 255, 0.3);
    }

    .running-man-head::before {
        content: '';
        position: absolute;
        width: 4px;
        height: 4px;
        background: #2C3E50;
        border-radius: 50%;
        top: 6px;
        left: 4px;
    }

    .running-man-head::after {
        content: '';
        position: absolute;
        width: 4px;
        height: 4px;
        background: #2C3E50;
        border-radius: 50%;
        top: 6px;
        right: 4px;
    }

    .running-man-body {
        width: 14px;
        height: 16px;
        background: linear-gradient(135deg, #5B9BD5 0%, #3D6FA6 100%);
        border-radius: 7px;
        position: absolute;
        top: 18px;
        left: 50%;
        transform: translateX(-50%);
        border: 1.5px solid #2F5F8A;
        box-shadow: 
            0 2px 4px rgba(0, 0, 0, 0.2),
            inset 0 1px 2px rgba(255, 255, 255, 0.2);
    }

    .running-man-arm-left {
        width: 12px;
        height: 22px;
        background: linear-gradient(135deg, #FFDBAC 0%, #E6C296 100%);
        border-radius: 6px 6px 3px 3px;
        position: absolute;
        top: 20px;
        left: -2px;
        transform-origin: top center;
        animation: runArmLeft 0.6s ease-in-out infinite;
        border: 1.5px solid #D4A574;
        box-shadow: 
            0 2px 4px rgba(0, 0, 0, 0.15),
            inset 0 1px 2px rgba(255, 255, 255, 0.3);
    }

    .running-man-arm-right {
        width: 12px;
        height: 22px;
        background: linear-gradient(135deg, #FFDBAC 0%, #E6C296 100%);
        border-radius: 6px 6px 3px 3px;
        position: absolute;
        top: 20px;
        right: -2px;
        transform-origin: top center;
        animation: runArmRight 0.6s ease-in-out infinite;
        border: 1.5px solid #D4A574;
        box-shadow: 
            0 2px 4px rgba(0, 0, 0, 0.15),
            inset 0 1px 2px rgba(255, 255, 255, 0.3);
    }

    .running-man-leg-left {
        width: 10px;
        height: 20px;
        background: linear-gradient(135deg, #2F4F4F 0%, #1A2F2F 100%);
        border-radius: 5px 5px 3px 3px;
        position: absolute;
        bottom: -2px;
        left: 6px;
        transform-origin: top center;
        animation: runLegLeft 0.6s ease-in-out infinite;
        border: 1.5px solid #1C2F2F;
        box-shadow: 
            0 2px 4px rgba(0, 0, 0, 0.2),
            inset 0 1px 2px rgba(255, 255, 255, 0.1);
    }

    .running-man-leg-right {
        width: 10px;
        height: 20px;
        background: linear-gradient(135deg, #2F4F4F 0%, #1A2F2F 100%);
        border-radius: 5px 5px 3px 3px;
        position: absolute;
        bottom: -2px;
        right: 6px;
        transform-origin: top center;
        animation: runLegRight 0.6s ease-in-out infinite;
        border: 1.5px solid #1C2F2F;
        box-shadow: 
            0 2px 4px rgba(0, 0, 0, 0.2),
            inset 0 1px 2px rgba(255, 255, 255, 0.1);
    }

    @keyframes runBounce {
        0%, 100% {
            transform: translateY(-50%) translateX(0) scale(1);
        }
        25% {
            transform: translateY(-58%) translateX(-1px) scale(1.02);
        }
        50% {
            transform: translateY(-50%) translateX(0) scale(1);
        }
        75% {
            transform: translateY(-42%) translateX(1px) scale(0.98);
        }
    }

    /* Budget Alert Animation */
    @keyframes alertPulse {
        0%, 100% {
            transform: translateY(-50%) scale(1);
            opacity: 1;
        }
        50% {
            transform: translateY(-50%) scale(1.2);
            opacity: 0.8;
        }
    }

    .budget-alert-icon {
        animation: alertPulse 1s ease-in-out infinite;
    }

    .bottom-nav {
        background-color: #87CEEB;
        border-radius: 12px 12px 0 0;
    }

    /* Background Jobs Indicator Styling */
    #background-jobs-indicator {
        background: linear-gradient(135deg, #E0F6FF 0%, #B0E0E6 100%) !important;
        border: 1px solid #B0E0E6 !important;
        border-radius: 16px !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
        color: #2C3E50 !important;
    }

    #background-jobs-indicator * {
        color: #2C3E50 !important;
    }

    #background-jobs-indicator .text-xs {
        color: #2C3E50 !important;
    }

    .bottom-nav-item {
        color: #2C3E50;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-decoration: none;
    }

    .bottom-nav-item.active {
        background-color: #BFDBFE;
        border-radius: 50%;
        padding: 8px;
        margin-bottom: 4px;
    }

    .bottom-nav-icon {
        width: 24px;
        height: 24px;
    }

    .bottom-nav-label {
        font-size: 0.75rem;
        margin-top: 4px;
    }

    /* Improved modal scrolling for mobile */
    .modal-content {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    /* Better touch targets for mobile */
    .mobile-touch {
        min-height: 44px;
        min-width: 44px;
    }

    /* Prevent body scroll when modal is open */
    body.modal-open {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
    }
}

.processing-indicator {
    background: linear-gradient(135deg, #E0F6FF 0%, #B0E0E6 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
                0 2px 4px -1px rgba(0, 0, 0, 0.06);
    color: #2C3E50;
    padding: 1rem;
}

.processing-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.processing-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.processing-icon {
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.owl-gif {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
}

.processing-info {
    flex: 1;
}

.processing-title {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25;
    margin: 0;
    color: #1E293B;
}

.processing-subtitle {
    font-size: 0.75rem;
    margin: 0.25rem 0 0 0;
    color: #475569;
    opacity: 0.9;
}

.processing-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end; /* aligns both to right side */
    justify-content: flex-start;
    gap: 0.25rem;
}

.status-text {
    font-size: 0.75rem;
    font-weight: 500;
    color: #1E293B;
    display: flex;
    align-items: center;
    justify-content: flex-end; /* ensure text + dot align right */
    gap: 0.375rem;
    text-align: right;
    width: 100%;
}

.status-text::before {
    content: "";
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #D4AF37 0%, #F4D03F 100%);
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.cancel-btn {
    background: none;
    border: none;
    color: #DC2626;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: underline;
    text-underline-offset: 2px;
    align-self: flex-end; /* ensures it stays right-aligned */
}

.cancel-btn:hover {
    color: #B91C1C;
    background: rgba(220, 38, 38, 0.05);
    transform: translateY(-1px);
}

.cancel-btn:active {
    transform: translateY(0);
}

.cancel-btn:focus {
    outline: 2px solid #DC2626;
    outline-offset: 2px;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

/* Responsive */
@media (max-width: 640px) {
    .processing-content {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .processing-right {
        flex-direction: column;
        align-items: flex-end;
        justify-content: flex-start;
    }
}

@media (prefers-reduced-motion: reduce) {
    .status-text::before {
        animation: none;
        opacity: 0.8;
    }
}

/* Swipe gestures for image preview */
#image-preview-container {
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.preview-item {
  scroll-snap-align: start;
  flex: 0 0 auto;
}

/* Vibration/haptic feedback */
@media (hover: none) and (pointer: coarse) {
  button:active {
    transform: scale(0.95);
    transition: transform 0.1s;
  }
}

/* Better modal for mobile */
.modal-mobile {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

/* Pull-to-refresh prevention */
.app-content {
  overscroll-behavior: none;
}

/* Hardware acceleration */
.gold-button, .mobile-btn {
  transform: translateZ(0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Reduce animations for performance */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Better image handling */
#previews img {
  max-width: 100%;
  height: auto;
  object-fit: cover;
}

/* Add to style.css for dashboard-specific improvements */
.dashboard-container {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Better safe area handling */
.dashboard-content {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Prevent layout shifts */
.dashboard-section {
  will-change: transform;
  contain: layout style paint;
}

/* Mobile-specific dashboard improvements */
@media (max-width: 768px) {
    .dashboard-section {
        margin-bottom: 1rem;
    }
    
    /* Better touch targets for calendar */
    .calendar-day {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Hide scrollbars but keep functionality */
    .scrollbar-hide {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    
    .scrollbar-hide::-webkit-scrollbar {
        display: none;
    }
    
    /* Improved chart tap targets */
    .mobile-chart {
        position: relative;
    }
    
    .chart-tap-overlay {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        pointer-events: none;
    }
}

/* Haptic feedback simulation */
@media (hover: none) and (pointer: coarse) {
    .mobile-btn:active {
        background-color: rgba(0, 0, 0, 0.1);
        transition: background-color 0.1s;
    }
}

/* Performance optimizations */
.dashboard-optimized {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Add to style.css for expenses page */
/* Swipe actions for expense items */
.expense-item {
    position: relative;
    overflow: hidden;
    touch-action: pan-y;
}

.expense-actions {
    position: absolute;
    top: 0;
    right: -120px;
    bottom: 0;
    display: flex;
    transition: right 0.3s ease;
}

.expense-item.swiping .expense-actions {
    right: 0;
}

.swipe-action {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    color: white;
    font-size: 0.8rem;
}

.swipe-action.edit { background: #3b82f6; }
.swipe-action.delete { background: #ef4444; }

/* Modal animations */
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.animate-slide-up {
    animation: slideUp 0.3s ease-out;
}

/* Pull to refresh */
.pull-to-refresh {
    transition: transform 0.2s;
}

/* Enhanced empty state */
.empty-state-enhanced {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

/* Quick filter active state */
.quick-filter.active {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    border-color: #1d4ed8;
}

.app-header {
  position: fixed;
  left: 0;
  width: 100%;
  z-index: 1000;
}

.header-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2rem; /* Adds space between greeting and categories */
}

.categories-card {
  background-color: #b0c4de; /* Optional: match your blue bubble */
  border-radius: 12px;
  padding: 10px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 400px;
}

#username-greeting {
  margin-left: 20%;
  text-align: center;
  width: 100%;
  font-size: 0.9rem; /* optional styling */
  font-weight: bold;
  color: #3b82f6;
}

/* Add to your existing CSS in auth.html */
@media (max-width: 768px) {
    #main-content {
        padding: 1rem !important;
        min-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    }
    
    .min-h-screen {
        min-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
        padding: 0.5rem !important;
    }
    
    .w-full.max-w-md {
        max-width: 100% !important;
        margin: 0 auto;
    }
    
    /* Fix button sizes for mobile */
    .mobile-btn {
        min-height: 44px !important;
        height: auto !important;
        padding: 10px 16px !important;
    }
    
    /* Ensure form container fits */
    .bg-white\/90 {
        margin: 0 0.5rem;
    }
}

/* Ensure proper scrolling on mobile */
body {
    position: relative !important;
    height: 100% !important;
    overflow-y: auto !important;
}

#main-content {
    position: relative;
    overflow-y: visible !important;
}

/* Add to style.css */
.app-content {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

.app-header {
    padding-top: env(safe-area-inset-top);
    z-index: 0;
}

/* Prevent iOS zoom on input focus */
@media screen and (max-width: 768px) {
    input, select, textarea {
        font-size: 16px !important;
    }
    
    .app-content input, 
    .app-content select, 
    .app-content textarea {
        font-size: 16px !important;
        transform: scale(1);
    }
}

/* Ensure minimum touch target size */
.mobile-btn, button, [role="button"] {
    min-height: 44px;
    min-width: 44px;
    padding: 12px 16px;
}

/* Budget category picker button */
#budget-category-btn {
    min-height: 44px;
    padding: 12px;
}

/* Base z-index hierarchy */
.app-header {
    z-index: 40;
    position: relative;
}

/* All modals should be above header */
.modal-overlay {
    z-index: 50;
}

/* Specific modal z-index values */
#add-expense-modal {
    z-index: 50;
}

#app-select-modal {
    z-index: 60;
}

/* Ensure header doesn't interfere with modals */
header.app-header {
    z-index: 40 !important;
}

/* PWA Install Prompt Styles */
#install-prompt {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

/* Animation for the prompt */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#install-prompt {
    animation: slideUp 0.3s ease-out;
}

/* Mobile optimizations */
@media (max-width: 640px) {
    #install-prompt {
        left: 2rem;
        right: 2rem;
        bottom: 2rem;
    }
}

/* Terms Modal Styles */
#terms-modal {
    backdrop-filter: blur(4px);
}

#terms-modal h4, #terms-modal h5 {
    font-family: 'Inter', sans-serif;
}

#terms-modal ul {
    list-style-type: disc;
    margin-left: 1.5rem;
}

#terms-modal li {
    margin-bottom: 0.25rem;
}

/* Smooth scrolling for modal content */
#terms-modal > div {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e0 transparent;
}

#terms-modal > div::-webkit-scrollbar {
    width: 6px;
}

#terms-modal > div::-webkit-scrollbar-track {
    background: transparent;
}

#terms-modal > div::-webkit-scrollbar-thumb {
    background-color: #cbd5e0;
    border-radius: 3px;
}

/* Toggle switch styling */
input:checked ~ .peer-checked\:bg-green-500 {
    background-color: #10B981;
}

input:checked ~ .peer-checked\:after\:translate-x-full:after {
    transform: translateX(100%);
}

/* Storage Bar Styles */
.storage-bar {
    width: 100%;
    height: 12px;
    background: #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.storage-progress {
    height: 100%;
    border-radius: 6px;
    background: linear-gradient(135deg, #10B981, #34D399);
    transition: all 0.5s ease-in-out;
    position: relative;
    min-width: 8px; /* Ensure progress is visible even at 0% */
}

/* Storage warning states */
.storage-warning .storage-progress {
    background: linear-gradient(135deg, #F59E0B, #FBBF24);
}

.storage-critical .storage-progress {
    background: linear-gradient(135deg, #EF4444, #F87171);
    animation: pulse 2s infinite;
}

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

/* Storage status indicators */
.storage-status-safe { color: #10B981; }
.storage-status-warning { color: #F59E0B; }
.storage-status-critical { color: #EF4444; }

.gold-live-glow {
    position: relative;
    display: inline-block;
    padding: 4px 12px;
    background: #D4AF37;
    color: white;
    font-size: 12px;
    font-weight: 600;
    border-radius: 9999px;
    animation: goldFlash 1.6s infinite ease-in-out;
}

@keyframes goldFlash {
    0% {
        box-shadow: 0 0 6px #D4AF37, 0 0 12px #FFEB99;
    }
    50% {
        box-shadow: 0 0 14px #FFD966, 0 0 26px #FFF2BF;
    }
    100% {
        box-shadow: 0 0 6px #D4AF37, 0 0 12px #FFEB99;
    }
}

.blue-live-glow {
    position: relative;
    display: inline-block;
    padding: 4px 12px;
    background: #001133; /* dark blue base */
    color: white;
    font-size: 12px;
    font-weight: 600;
    border-radius: 9999px;
    animation: blueFlash 1.6s infinite ease-in-out;
}

@keyframes blueFlash {
    0% {
        box-shadow: 
            0 0 6px #00f,
            0 0 12px #0ff;
    }
    50% {
        box-shadow: 
            0 0 14px #0ff,
            0 0 26px #00f;
    }
    100% {
        box-shadow:
            0 0 6px #00f,
            0 0 12px #0ff;
    }
}

.red-live-glow {
    position: relative;
    display: inline-block;
    padding: 4px 12px;
    background: #330000;
    color: white;
    font-size: 12px;
    font-weight: 600;
    border-radius: 9999px;
    animation: redFlash 1.6s infinite ease-in-out;
}

@keyframes redFlash {
    0% {
        box-shadow: 
            0 0 6px #ff0000,
            0 0 12px #ff4444;
    }
    50% {
        box-shadow: 
            0 0 16px #ff4444,
            0 0 32px #ff0000;
    }
    100% {
        box-shadow: 
            0 0 6px #ff0000,
            0 0 12px #ff4444;
    }
}
