/* ===========================
   Mobile Responsive Styles
=========================== */

/* --- Mobile filter/sort bar (transaction cards): hidden on desktop --- */
.mobile-filter-container {
    display: none;
}

.mobile-filter-pill {
    font-size: 0.85rem;
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--border-ui);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    white-space: nowrap;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.mobile-filter-pill:hover {
    background-color: var(--bg-hover);
    border-color: var(--brand-purple);
    color: var(--brand-purple);
}

.mobile-filter-pill-active {
    border-color: var(--brand-purple) !important;
    color: var(--brand-purple) !important;
    box-shadow: 0 0 0 1px var(--brand-purple);
}

/* Filter labels: use theme secondary text for legibility in both themes */
.mobile-filter-label {
    color: var(--text-secondary) !important;
    font-weight: 500;
    font-size: 0.9rem;
}

/* --- Top-panel Offcanvas for mobile filters --- */
.mobile-filter-offcanvas {
    border-bottom-left-radius: 16px !important;
    border-bottom-right-radius: 16px !important;
    max-height: 70vh !important;
    height: auto !important;
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-bottom: 2px solid var(--brand-purple) !important;
}

.mobile-filter-offcanvas .offcanvas-header {
    padding: 16px 20px 8px !important;
    border-bottom: 1px solid var(--border-ui);
}

.mobile-filter-offcanvas .offcanvas-header .offcanvas-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-primary) !important;
}

.mobile-filter-offcanvas .offcanvas-header .btn-close {
    opacity: 0.7;
}

.mobile-filter-offcanvas .offcanvas-body {
    padding: 16px 20px 24px !important;
    overflow: visible !important;
}

.mobile-filter-bar {
    padding: 0;
}

.mobile-filter-dropdown .Select-control,
.mobile-filter-dropdown .Select-multi-value-wrapper {
    min-height: 40px;
    font-size: 0.9rem;
}

.mobile-filter-clear-btn {
    font-size: 0.9rem;
    padding: 10px 20px;
    border-radius: 10px;
    border: 1px solid var(--border-ui);
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    width: 100%;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.mobile-filter-clear-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--brand-purple);
}

/* Mobile Breakpoint: max-width: 768px */
@media (max-width: 768px) {
    /* Show mobile filter pill button above transaction cards */
    .mobile-filter-container {
        display: block;
    }
    /* ============================================================
       HORIZONTAL OVERFLOW PREVENTION
       ============================================================ */
    
    /* Remove min-width constraint on cards for small screens */
    .metric-card {
        min-width: 0 !important;
        max-width: 100%; /* Default: fit viewport */
    }
    
    /* Exception: Heatmap and other scrollable cards can exceed viewport width */
    .heatmap-scrollable {
        max-width: none !important; /* Allow card to be wider than viewport */
        overflow-x: auto !important; /* Enable horizontal scrolling */
        -webkit-overflow-scrolling: touch; /* Smooth iOS scrolling */
    }
    
    /* Ensure all containers respect viewport width.
       Use clip instead of hidden: clip prevents horizontal overflow
       without creating a scroll container, so overflow-y stays visible
       and dropdown menus can escape vertically. */
    .main-container,
    .page-content,
    .page-container {
        max-width: 100vw;
        overflow-x: clip !important;
    }
    
    /* Ensure box-sizing on key containers (targeted, not wildcard) */
    .metric-card,
    .card-body,
    .transaction-card,
    .dbc .card-body {
        box-sizing: border-box;
    }
    
    /* Ensure charts and graphs don't cause overflow */
    .dash-graph,
    .dcc-graph {
        max-width: 100% !important;
        overflow-x: clip !important;
    }
    
    /* Allow Plotly charts to be wider than container if needed (for horizontal scroll) */
    .js-plotly-plot {
        max-width: none !important; /* Allow chart to be its natural width */
        overflow-x: visible !important; /* Don't clip the chart */
    }
    
    /* Ensure card bodies handle overflow properly */
    .card-body,
    .dbc .card-body {
        max-width: 100% !important;
        overflow-x: auto !important; /* Allow scrolling instead of clipping */
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }
    
    /* ============================================================
       HORIZONTAL SCROLLING FOR WIDE CHARTS
       ============================================================ */
    
    /* Chart containers that need horizontal scrolling */
    .metric-card .card-body:has(.js-plotly-plot),
    div[style*="overflowX"] {
        /* Smooth momentum scrolling */
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        
        /* Visible scrollbar on mobile for discoverability */
        scrollbar-width: thin;
        scrollbar-color: rgba(180, 100, 255, 0.5) transparent;
        
        /* Ensure content doesn't get cut off at edges */
        padding-right: 10px;
    }
    
    /* Prevent scrollable containers from being overflow:hidden by parent */
    div[style*="overflowX: auto"],
    div[style*="overflowX: 'auto'"] {
        overflow-x: auto !important; /* Override any parent overflow hidden */
    }
    
    /* Webkit scrollbar styling for Chrome/Safari */
    .metric-card .card-body:has(.js-plotly-plot)::-webkit-scrollbar,
    div[style*="overflowX"]::-webkit-scrollbar {
        height: 6px;
    }
    
    .metric-card .card-body:has(.js-plotly-plot)::-webkit-scrollbar-track,
    div[style*="overflowX"]::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .metric-card .card-body:has(.js-plotly-plot)::-webkit-scrollbar-thumb,
    div[style*="overflowX"]::-webkit-scrollbar-thumb {
        background: rgba(180, 100, 255, 0.5);
        border-radius: 3px;
    }
    
    .metric-card .card-body:has(.js-plotly-plot)::-webkit-scrollbar-thumb:hover,
    div[style*="overflowX"]::-webkit-scrollbar-thumb:hover {
        background: rgba(180, 100, 255, 0.7);
    }
    
    /* ============================================================
       CHART INTERACTION CONTROL - Single Tap to Activate
       ============================================================ */
    
    /* Disable pointer events on all charts by default to allow scrolling */
    .js-plotly-plot,
    .dash-graph .js-plotly-plot {
        pointer-events: none !important;
        transition: all 0.3s ease;
    }
    
    /* Active state - enable interactions and show visual feedback */
    .chart-active .js-plotly-plot,
    .chart-active.dash-graph .js-plotly-plot {
        pointer-events: auto !important;
        border: 2px solid var(--brand-purple) !important;
        border-radius: 8px !important;
        box-shadow: 0 0 0 4px rgba(180, 100, 255, 0.2) !important;
    }
    
    /* Visual hint for tappable charts */
    .js-plotly-plot::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.2s ease;
    }
    
    /* Show hint briefly when chart is touched but not active */
    .chart-touched .js-plotly-plot::after {
        content: '👆 Tap to interact';
        background: rgba(0, 0, 0, 0.8);
        color: white;
        padding: 8px 16px;
        border-radius: 20px;
        font-size: 14px;
        opacity: 1;
        z-index: 1000;
    }
    
    /* ============================================================
       DATE PICKER Z-INDEX FIX
       ============================================================ */
    
    /* Ensure date picker dropdown appears above all cards */
    .SingleDatePicker_picker,
    .DateRangePicker_picker {
        z-index: 9999 !important;
        position: absolute !important;
    }
    
    .DayPicker,
    .CalendarDay,
    .DayPicker_portal {
        z-index: 9999 !important;
    }
    
    /* Ensure date picker container creates a positioning context */
    .SingleDatePicker,
    .DateRangePicker {
        position: relative !important;
        z-index: 1 !important;
    }

    /* ============================================================
       MODAL DROPDOWNS - RESPONSIVE FLEX LAYOUT
       ============================================================ */
    
    /* Stack modal flex rows on mobile */
    .modal-body > div > div[style*="display: flex"] {
        flex-direction: column !important;
    }
    
    /* Ensure flex children take full width on mobile */
    .modal-body > div > div[style*="display: flex"] > div {
        width: 100% !important;
    }
    
    /* ============================================================
       GLOBAL MOBILE MODAL RULES (lg/xl modals)
       ============================================================ */
    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl {
        max-width: 100vw !important;
        margin: 0 !important;
        height: 100vh !important;
    }
    .modal-dialog.modal-lg .modal-content,
    .modal-dialog.modal-xl .modal-content {
        height: 100vh !important;
        border-radius: 0 !important;
    }
    .modal-dialog.modal-lg .modal-header,
    .modal-dialog.modal-xl .modal-header {
        padding: 10px 12px !important;
    }
    .modal-dialog.modal-lg .modal-body,
    .modal-dialog.modal-xl .modal-body {
        padding: 10px 12px !important;
        max-height: calc(100vh - 140px) !important;
        overflow-y: auto !important;
    }
    .modal-dialog.modal-lg .modal-footer,
    .modal-dialog.modal-xl .modal-footer {
        padding: 10px 12px !important;
        flex-direction: column !important;
        gap: 8px !important;
    }
    .modal-dialog.modal-lg .modal-footer .btn,
    .modal-dialog.modal-xl .modal-footer .btn {
        width: 100% !important;
        min-height: 48px !important;
    }
    
    /* Bulk Editor custom modal: full-screen sheet on mobile (overrides inline styles) */
    .bulk-editor-modal-content,
    [id$="bulk-editor-modal-content"] {
        width: 100% !important;
        max-width: 100vw !important;
        border-radius: 0 !important;
        top: 0 !important;
        left: 0 !important;
        transform: none !important;
        height: 100vh !important;
        max-height: 100vh !important;
    }
    .bulk-editor-modal-content .ag-root-wrapper,
    [id$="bulk-editor-modal-content"] .ag-root-wrapper {
        height: 300px !important;
    }

    /* Sidebar Mobile Styles */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    /* Page Content Mobile - Optimize Horizontal Space */
    .page-content {
        margin-left: 0;
        padding: 10px 12px 20px 12px !important; /* Reduced side padding from 20px to 12px */
    }
    
    /* Make all columns full-width on mobile for maximum horizontal space */
    .page-content .col-12,
    .page-content [class*="col-"] {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Optimize Date Picker for Horizontal Space */
    .DateRangePickerInput {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .DateRangePickerInput__withBorder {
        padding: 6px 10px !important; /* Reduced padding */
        font-size: 13px !important; /* Slightly smaller font */
    }
    
    /* ============================================================
       SHARED CARD REORDERING SYSTEM (Dashboard + Expenses Pages)
       ============================================================ */
    
    /* Make page-content a flex container to enable reordering */
    .dashboard-page-content,
    .expenses-page-content,
    .savings-page-content,
    .ai-insights-page-content,
    .tax-calculators-page-content,
    .simulation-page-content,
    .calendar-page-content,
    .upload-page-content,
    .raw-data-page-content,
    .user-settings-page-content,
    .support-page-content {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important; /* Consistent minimal spacing between all cards */
    }
    
    /* Space for fixed bottom tab bar */
    .dashboard-page-content,
    .expenses-page-content,
    .savings-page-content,
    .ai-insights-page-content,
    .tax-calculators-page-content,
    .simulation-page-content,
    .calendar-page-content,
    .upload-page-content,
    .raw-data-page-content,
    .user-settings-page-content,
    .support-page-content {
        padding-bottom: 72px !important;
    }
    /* Upload/Raw-Data: allow scrolling so grid is always visible on small screens */
    .upload-page-content,
    .raw-data-page-content {
        min-height: 100% !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        padding-bottom: 0 !important;
    }
    
    /* ============================================================
       DASHBOARD-SPECIFIC: Compact page header (same pattern as Income)
       ============================================================ */
    .dashboard-page-content .last-transaction-date {
        font-size: 13px !important;
        margin: 0 !important;
        padding: 0 0 0 8px !important;
        font-weight: 600 !important;
    }
    
    .dashboard-page-content .row.mb-4.align-items-center {
        flex-wrap: wrap !important;
        align-items: center !important;
        margin-bottom: 8px !important;
        gap: 8px !important;
        overflow: visible !important;
    }
    
    .dashboard-page-content .row.mb-4.align-items-center > [class*="col-"]:first-child {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: baseline !important;
        gap: 0 8px !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .dashboard-page-content .row.mb-4 .page-header {
        font-size: 1.25rem !important;
        margin-bottom: 0 !important;
        white-space: nowrap !important;
    }
    
    .dashboard-page-content .row.mb-4.align-items-center > [class*="col-"]:last-child {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        margin-top: 0 !important;
        overflow: visible !important;
    }
    
    .dashboard-page-content .row.mb-4 .d-flex {
        width: 100% !important;
        justify-content: flex-start !important;
    }
    
    .dashboard-page-content .DateRangePickerInput {
        flex-direction: row !important;
        align-items: center !important;
        gap: 6px !important;
        width: 100% !important;
        max-width: 100% !important;
        justify-content: flex-start !important;
    }
    
    .dashboard-page-content .DateRangePickerInput_arrow {
        transform: none !important;
        margin: 0 2px !important;
    }
    
    .dashboard-page-content .DateInput_input {
        font-size: 12px !important;
        padding: 6px 10px !important;
        min-width: 0 !important;
    }
    
    .dashboard-page-content .DateRangePicker {
        width: 100% !important;
        justify-content: flex-start !important;
    }
    
    /* ============================================================
       EXPENSES-SPECIFIC: Compact page header (same pattern as Dashboard/Income)
       ============================================================ */
    .expenses-page-content .last-transaction-date {
        font-size: 13px !important;
        margin: 0 !important;
        padding: 0 0 0 8px !important;
        font-weight: 600 !important;
    }
    
    .expenses-page-content .row.mb-4.align-items-center {
        flex-wrap: wrap !important;
        align-items: center !important;
        margin-bottom: 8px !important;
        gap: 8px !important;
        overflow: visible !important;
    }
    
    .expenses-page-content .row.mb-4.align-items-center > [class*="col-"]:first-child {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: baseline !important;
        gap: 0 8px !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .expenses-page-content .row.mb-4 .page-header {
        font-size: 1.25rem !important;
        margin-bottom: 0 !important;
        white-space: nowrap !important;
    }
    
    .expenses-page-content .row.mb-4.align-items-center > [class*="col-"]:last-child {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        margin-top: 0 !important;
        overflow: visible !important;
    }
    
    .expenses-page-content .row.mb-4 .d-flex {
        width: 100% !important;
        justify-content: flex-start !important;
    }
    
    .expenses-page-content .DateRangePickerInput {
        flex-direction: row !important;
        align-items: center !important;
        gap: 6px !important;
        width: 100% !important;
        max-width: 100% !important;
        justify-content: flex-start !important;
    }
    
    .expenses-page-content .DateRangePickerInput_arrow {
        transform: none !important;
        margin: 0 2px !important;
    }
    
    .expenses-page-content .DateInput_input {
        font-size: 12px !important;
        padding: 6px 10px !important;
        min-width: 0 !important;
    }
    
    .expenses-page-content .DateRangePicker {
        width: 100% !important;
        justify-content: flex-start !important;
    }
    
    /* ============================================================
       SAVINGS-SPECIFIC: Compact page header (same pattern as Dashboard/Income/Expenses)
       ============================================================ */
    .savings-page-content .last-transaction-date {
        font-size: 13px !important;
        margin: 0 !important;
        padding: 0 0 0 8px !important;
        font-weight: 600 !important;
    }
    
    .savings-page-content .row.mb-4.align-items-center {
        flex-wrap: wrap !important;
        align-items: center !important;
        margin-bottom: 8px !important;
        gap: 8px !important;
        overflow: visible !important;
    }
    
    .savings-page-content .row.mb-4.align-items-center > [class*="col-"]:first-child {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: baseline !important;
        gap: 0 8px !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .savings-page-content .row.mb-4 .page-header {
        font-size: 1.25rem !important;
        margin-bottom: 0 !important;
        white-space: nowrap !important;
    }
    
    .savings-page-content .row.mb-4.align-items-center > [class*="col-"]:last-child {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        margin-top: 0 !important;
        overflow: visible !important;
    }
    
    .savings-page-content .row.mb-4 .d-flex {
        width: 100% !important;
        justify-content: flex-start !important;
    }
    
    .savings-page-content .DateRangePickerInput {
        flex-direction: row !important;
        align-items: center !important;
        gap: 6px !important;
        width: 100% !important;
        max-width: 100% !important;
        justify-content: flex-start !important;
    }
    
    .savings-page-content .DateRangePickerInput_arrow {
        transform: none !important;
        margin: 0 2px !important;
    }
    
    .savings-page-content .DateInput_input {
        font-size: 12px !important;
        padding: 6px 10px !important;
        min-width: 0 !important;
    }
    
    .savings-page-content .DateRangePicker {
        width: 100% !important;
        justify-content: flex-start !important;
    }
    
    /* ============================================================
       AI-INSIGHTS-SPECIFIC: Compact page header (same pattern as Dashboard/Income/Expenses/Savings)
       ============================================================ */
    .ai-insights-page-content .last-transaction-date {
        font-size: 13px !important;
        margin: 0 !important;
        padding: 0 0 0 8px !important;
        font-weight: 600 !important;
    }
    
    .ai-insights-page-content .row.mb-4.align-items-center {
        flex-wrap: wrap !important;
        align-items: center !important;
        margin-bottom: 8px !important;
        gap: 8px !important;
        overflow: visible !important;
    }
    
    .ai-insights-page-content .row.mb-4.align-items-center > [class*="col-"]:first-child {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: baseline !important;
        gap: 0 8px !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .ai-insights-page-content .row.mb-4 .page-header {
        font-size: 1.25rem !important;
        margin-bottom: 0 !important;
        white-space: nowrap !important;
    }
    
    .ai-insights-page-content .row.mb-4.align-items-center > [class*="col-"]:last-child {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        margin-top: 0 !important;
        overflow: visible !important;
    }
    
    .ai-insights-page-content .row.mb-4 .d-flex {
        width: 100% !important;
        justify-content: flex-start !important;
    }
    
    .ai-insights-page-content .DateRangePickerInput {
        flex-direction: row !important;
        align-items: center !important;
        gap: 6px !important;
        width: 100% !important;
        max-width: 100% !important;
        justify-content: flex-start !important;
    }
    
    .ai-insights-page-content .DateRangePickerInput_arrow {
        transform: none !important;
        margin: 0 2px !important;
    }
    
    .ai-insights-page-content .DateInput_input {
        font-size: 12px !important;
        padding: 6px 10px !important;
        min-width: 0 !important;
    }
    
    .ai-insights-page-content .DateRangePicker {
        width: 100% !important;
        justify-content: flex-start !important;
    }
    
    /* ============================================================
       SHARED: EXPLICIT ORDERING HIERARCHY FOR ALL ELEMENTS
       ============================================================ */
    
    /* 1. Mobile nav / bottom tab bar wrapper - stay at top */
    .dashboard-page-content > div:first-child,
    .expenses-page-content > div:first-child,
    .income-page-content > div:first-child,
    .savings-page-content > div:first-child,
    .ai-insights-page-content > div:first-child,
    .dashboard-page-content > .mobile-nav-tabs,
    .dashboard-page-content > #mobile-nav-tabs,
    .expenses-page-content > .mobile-nav-tabs,
    .expenses-page-content > #mobile-nav-tabs,
    .income-page-content > .mobile-nav-tabs,
    .income-page-content > #mobile-nav-tabs,
    .savings-page-content > .mobile-nav-tabs,
    .savings-page-content > #mobile-nav-tabs,
    .ai-insights-page-content > .mobile-nav-tabs,
    .ai-insights-page-content > #mobile-nav-tabs,
    .tax-calculators-page-content > div:first-child,
    .tax-calculators-page-content > .mobile-nav-tabs,
    .tax-calculators-page-content > #mobile-nav-tabs,
    .simulation-page-content > div:first-child,
    .simulation-page-content > .mobile-nav-tabs,
    .simulation-page-content > #mobile-nav-tabs,
    .calendar-page-content > div:first-child,
    .calendar-page-content > .mobile-nav-tabs,
    .calendar-page-content > #mobile-nav-tabs,
    .upload-page-content > div:first-child,
    .upload-page-content > .mobile-nav-tabs,
    .upload-page-content > #mobile-nav-tabs,
    .raw-data-page-content > div:first-child,
    .raw-data-page-content > .mobile-nav-tabs,
    .raw-data-page-content > #mobile-nav-tabs,
    .user-settings-page-content > div:first-child,
    .user-settings-page-content > .mobile-nav-tabs,
    .user-settings-page-content > #mobile-nav-tabs,
    .support-page-content > div:first-child,
    .support-page-content > .mobile-nav-tabs,
    .support-page-content > #mobile-nav-tabs {
        order: -10 !important;
        flex-shrink: 0 !important;
        min-height: fit-content !important;
    }
    
    /* Tax & Calculators: keep header row visible and match other pages' compact header size */
    .tax-calculators-page-content > .row:has(.page-header) {
        display: flex !important;
        flex-shrink: 0 !important;
        min-height: fit-content !important;
        margin-bottom: 8px !important;
    }
    .tax-calculators-page-content .page-header {
        font-size: 1.25rem !important;
        margin-bottom: 4px !important;
        white-space: nowrap !important;
    }
    .tax-calculators-page-content > .row:has(.page-header) .mb-4 {
        margin-bottom: 0 !important;
        font-size: 0.875rem !important;
        line-height: 1.35 !important;
    }
    
    /* 2. Page Header (Title + Date Picker) - Second from top */
    .dashboard-page-content > .row:has(.page-header),
    .expenses-page-content > .row:has(.page-header),
    .savings-page-content > .row:has(.page-header),
    .ai-insights-page-content > .row:has(.page-header),
    .tax-calculators-page-content > .row:has(.page-header),
    .calendar-page-content > .row:has(.page-header) {
        order: -5 !important;
        flex-shrink: 0 !important;
    }
    /* Simulation: header row order + compact header to match other pages */
    .simulation-page-content > .row:has(.page-header) {
        order: -5 !important;
        flex-shrink: 0 !important;
        margin-bottom: 8px !important;
    }
    .simulation-page-content .page-header {
        font-size: 1.25rem !important;
        margin-bottom: 4px !important;
        white-space: nowrap !important;
    }
    .simulation-page-content > .row:has(.page-header) .mb-4 {
        margin-bottom: 0 !important;
        font-size: 0.875rem !important;
        line-height: 1.35 !important;
    }
    
    /* Simulation: prevent flex children (rows/cards) from shrinking so cards keep natural size */
    .simulation-page-content > * {
        flex-shrink: 0 !important;
    }
    
    /* Calendar: compact header + mode toggle; prevent content shrinking */
    .calendar-page-content > .row:has(.page-header) {
        margin-bottom: 8px !important;
    }
    .calendar-page-content .page-header {
        font-size: 1.25rem !important;
        margin-bottom: 4px !important;
        white-space: nowrap !important;
    }
    .calendar-page-content .page-subtitle {
        font-size: 0.875rem !important;
        line-height: 1.35 !important;
    }
    .calendar-page-content > * {
        flex-shrink: 0 !important;
    }
    
    /* Upload: compact header + ordering to match other pages (scoped to upload only) */
    .upload-page-content > .upload-header-row {
        order: -5 !important;
        flex-shrink: 0 !important;
        margin-bottom: 8px !important;
    }
    .upload-page-content .upload-header-row .page-header {
        font-size: 1.25rem !important;
        margin-bottom: 4px !important;
        white-space: nowrap !important;
    }
    .upload-page-content .upload-header-row .last-transaction-date {
        font-size: 13px !important;
        margin: 0 !important;
        padding: 0 0 0 8px !important;
        font-weight: 600 !important;
    }
    /* Upload: prevent flex children from shrinking (except grid area which flexes to fill space) */
    .upload-page-content > *:not(#upload-grid-container) {
        flex-shrink: 0 !important;
    }
    
    /* Raw Data: compact header + ordering to match other pages (scoped to raw-data only) */
    .raw-data-page-content > .raw-data-header-row {
        order: -5 !important;
        flex-shrink: 0 !important;
        margin-bottom: 8px !important;
    }
    .raw-data-page-content .raw-data-header-row .page-header {
        font-size: 1.25rem !important;
        margin-bottom: 4px !important;
        white-space: nowrap !important;
    }
    .raw-data-page-content .raw-data-header-row .last-transaction-date {
        font-size: 13px !important;
        margin: 0 !important;
        padding: 0 0 0 8px !important;
        font-weight: 600 !important;
    }
    /* Raw Data: prevent flex children from shrinking (except grid area which flexes to fill space) */
    .raw-data-page-content > *:not(#rawdata-grid-area) {
        flex-shrink: 0 !important;
    }
    
    /* User Settings: compact header + ordering to match other pages (scoped to user-settings only) */
    .user-settings-page-content > div:has(.page-header) {
        order: -5 !important;
        flex-shrink: 0 !important;
        margin-bottom: 8px !important;
    }
    .user-settings-page-content .page-header {
        font-size: 1.25rem !important;
        margin-bottom: 4px !important;
        white-space: nowrap !important;
    }
    /* User Settings: prevent flex children from shrinking */
    .user-settings-page-content > * {
        flex-shrink: 0 !important;
    }
    
    /* Settings: compact header to match other pages (scoped to settings only) */
    .settings-page-content > .settings-header-row {
        order: -5 !important;
        flex-shrink: 0 !important;
        margin-bottom: 8px !important;
    }
    .settings-page-content .settings-header-row .page-header {
        font-size: 1.25rem !important;
        margin-bottom: 4px !important;
        white-space: nowrap !important;
    }
    
    /* Support: prevent content shrinking */
    .support-page-content > * {
        flex-shrink: 0 !important;
    }
    
    /* 3. Metrics Row or First Row */
    .dashboard-page-content > .mb-4,
    .expenses-page-content > .mb-4 {
        order: 5 !important;
        flex-shrink: 0 !important;
    }
    
    /* Dashboard metrics: 2x2 grid for Income, Expenses, Savings, Financial Health; checklist full width below (do not apply to header row) */
    .dashboard-page-content > .mb-4:not(:has(.page-header)) {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    .dashboard-page-content > .mb-4:not(:has(.page-header)) > *:nth-child(5) {
        grid-column: 1 / -1 !important; /* Financial Checklist spans full width */
    }
    
    /* Make visualization/card rows use display:contents to flatten hierarchy */
    .dashboard-page-content > .g-2,
    .dashboard-page-content > .g-2 + br + .row,
    .expenses-page-content > .mb-4 + .row {
        display: contents !important;
    }
    
    /* Hide br between visualization rows */
    .dashboard-page-content > .g-2 + br {
        display: none !important;
    }
    
    /* ============================================================
       DASHBOARD-SPECIFIC: Chart Card Reordering
       ============================================================ */
    
    /* 4. Sankey chart - First chart (after metrics) */
    .dashboard-page-content .col-12:has(#expand-btn-sankey) {
        order: 10 !important;
    }
    
    /* Increase Sankey chart card and chart height on mobile */
    .dashboard-page-content .col-12:has(#expand-btn-sankey) .metric-card {
        height: 600px !important;
    }
    
    .dashboard-page-content .col-12:has(#expand-btn-sankey) #sankey-chart {
        height: 550px !important;
    }
    
    .dashboard-page-content .col-12:has(#expand-btn-sankey) .chart {
        height: 550px !important;
    }
    
    /* 5. Transactions - Second chart (moved up from row 2) */
    .dashboard-page-content .col-12:has(#expand-btn-transactions) {
        order: 20 !important;
        margin-bottom: 0 !important; /* Remove margin, gap handles spacing */
        height: auto !important; /* Let card size naturally based on content */
    }
    
    /* Allow card to grow up to max height based on content */
    .dashboard-page-content .col-12:has(#expand-btn-transactions) .metric-card {
        max-height: 600px !important;
        height: auto !important;
    }
    
    .dashboard-page-content .col-12:has(#expand-btn-transactions) #top-transactions-grid {
        height: 550px !important;
    }
    
    /* 6. Budget chart - Third chart (moved down from row 1) */
    .dashboard-page-content .col-12:has(#expand-btn-budget) {
        order: 30 !important;
    }
    
    /* 7. Daily Spending - Fourth chart (stays last) */
    .dashboard-page-content .col-12:has(#expand-btn-spending) {
        order: 40 !important;
    }
    
    /* ============================================================
       EXPENSES-SPECIFIC: Chart Card Reordering
       ============================================================ */
    
    /* 4. Expenses Pie Chart - First card (stays first) */
    .expenses-page-content .col-12:has(#expand-btn-expenses-pie) {
        order: 10 !important;
    }
    
    /* 5. All Filtered Transactions - Second card (moved up from row 2) */
    .expenses-page-content .col-12:has(#expand-btn-expenses-trends) {
        order: 20 !important;
    }
    
    /* 6. Category Insights - Third card (moved down from row 1) */
    .expenses-page-content .col-12:has(#expand-btn-expenses-insights) {
        order: 30 !important;
        height: 450px !important;
        max-height: 450px !important;
        margin-bottom: 0 !important; /* Remove margin, gap handles spacing */
    }
    
    .expenses-page-content .col-12:has(#expand-btn-expenses-insights) .metric-card {
        height: 450px !important;
        max-height: 450px !important;
        overflow: hidden !important;
        margin-bottom: 0 !important;
    }
    
    /* Add padding inside scrollable area so content doesn't touch bottom */
    #category-insights {
        padding-bottom: 20px !important;
    }
    
    /* 7. Expenses vs Budget - Fourth card (stays last) */
    .expenses-page-content .col-12:has(#expand-btn-expenses-budget) {
        order: 40 !important;
    }
    
    /* ============================================================
       INCOME-SPECIFIC: Page Layout & Card Reordering
       ============================================================ */
    
    /* Make income page content a flex container for reordering */
    .income-page-content {
        display: flex !important;
        flex-direction: column !important;
        gap: 15px !important;
        padding-bottom: 72px !important; /* Space for fixed bottom tab bar */
    }
    
    /* Prevent flex children from shrinking so chart cards keep natural height */
    .income-page-content > * {
        flex-shrink: 0 !important;
    }
    
    /* Page header second from top */
    .income-page-content > .row:has(.page-header) {
        order: -5 !important;
        flex-shrink: 0 !important;
    }
    
    /* INCOME-SPECIFIC: Compact page header - row 1: Income + short "Last uploaded" text; row 2: date picker full width */
    .income-page-content .last-transaction-date {
        font-size: 13px !important;
        margin: 0 !important;
        padding: 0 0 0 8px !important;
        font-weight: 600 !important;
    }
    
    /* Header row wraps: first col = title + subtitle on one line, second col = date picker on its own row */
    .income-page-content .row.mb-4.align-items-center {
        flex-wrap: wrap !important;
        align-items: center !important;
        margin-bottom: 8px !important;
        gap: 8px !important;
    }
    
    /* First column: title + "Last uploaded" on same row */
    .income-page-content .row.mb-4.align-items-center > [class*="col-"]:first-child {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: baseline !important;
        gap: 0 8px !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .income-page-content .row.mb-4 .page-header {
        font-size: 1.25rem !important;
        margin-bottom: 0 !important;
        white-space: nowrap !important;
    }
    
    /* Second column: date picker on its own full-width row (no cut off) */
    .income-page-content .row.mb-4.align-items-center > [class*="col-"]:last-child {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        margin-top: 0 !important;
        overflow: visible !important;
    }
    
    /* Allow calendar dropdown to overflow header row */
    .income-page-content .row.mb-4.align-items-center {
        overflow: visible !important;
    }
    
    .income-page-content .row.mb-4 .d-flex {
        width: 100% !important;
        justify-content: flex-start !important;
    }
    
    .income-page-content .DateRangePickerInput {
        flex-direction: row !important;
        align-items: center !important;
        gap: 6px !important;
        width: 100% !important;
        max-width: 100% !important;
        justify-content: flex-start !important;
    }
    
    .income-page-content .DateRangePickerInput_arrow {
        transform: none !important;
        margin: 0 2px !important;
    }
    
    .income-page-content .DateInput_input {
        font-size: 12px !important;
        padding: 6px 10px !important;
        min-width: 0 !important;
    }
    
    .income-page-content .DateRangePicker {
        width: 100% !important;
        justify-content: flex-start !important;
    }
    
    /* Flatten the main row AND the left column to allow individual card reordering */
    .income-page-content > .row:not(:has(.page-header)) {
        display: contents !important;
    }
    
    /* Flatten the left col that wraps both time + pie charts */
    .income-page-content .col-12.col-lg-6:has(#expand-btn-income-pie) {
        display: contents !important;
    }
    
    /* Hide the <br> between time and pie cards */
    .income-page-content .col-12.col-lg-6:has(#expand-btn-income-pie) > br {
        display: none !important;
    }
    
    /* 1. Income Pie chart first */
    .income-page-content .metric-card:has(#expand-btn-income-pie) {
        order: 10 !important;
        width: 100% !important;
        flex-shrink: 0 !important;
        min-height: fit-content !important;
    }
    
    /* 2. Income by Time chart second */
    .income-page-content .metric-card:has(#expand-btn-income-time) {
        order: 20 !important;
        width: 100% !important;
        flex-shrink: 0 !important;
        min-height: fit-content !important;
    }
    
    /* 3. Income Transactions third */
    .income-page-content .col-12:has(#expand-btn-income-transactions) {
        order: 30 !important;
        height: auto !important;
    }
    
    .income-page-content .col-12:has(#expand-btn-income-transactions) .metric-card {
        height: auto !important;
        max-height: 600px !important;
    }
    
    /* Chart overlays stay at end */
    .income-page-content > .chart-overlay,
    .income-page-content > div:has(.chart-overlay) {
        order: 100 !important;
    }

    /* ============================================================
       SHARED: OVERLAYS AND OTHER ELEMENTS
       ============================================================ */
    
    /* Chart Overlays - Stay at bottom */
    .dashboard-page-content > .chart-overlay,
    .expenses-page-content > .chart-overlay,
    .income-page-content > .chart-overlay {
        order: 100 !important;
    }
    
    /* Catch-all for any other direct children (safety net) */
    .dashboard-page-content > *:not(.mobile-nav-tabs):not(#mobile-nav-tabs):not([class*="col-"]):not(.mb-4):not(.g-2):not(.row):not(br):not(.chart-overlay),
    .expenses-page-content > *:not(.mobile-nav-tabs):not(#mobile-nav-tabs):not([class*="col-"]):not(.mb-4):not(.g-2):not(.row):not(br):not(.chart-overlay) {
        order: 0 !important;
    }
    
    /* Mobile Navigation Tabs */
    .mobile-nav-tabs {
        display: flex;
        gap: 8px;
        padding: 12px 0;
        overflow-x: auto;
        margin-bottom: 16px;
        border-bottom: 1px solid var(--gray-200);
        background-color: var(--bg-primary);
        position: relative;
        z-index: 100;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .mobile-nav-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .mobile-nav-tab {
        text-decoration: none;
        color: var(--text-primary);
        padding: 8px 12px;
        border-radius: 6px;
        background-color: var(--bg-secondary);
        border: 1px solid var(--gray-300);
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 80px;
        text-align: center;
        transition: all 0.2s ease;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 12px;
        font-weight: 500;
    }
    
    .mobile-nav-tab:hover {
        background-color: var(--brand-purple-light);
        color: var(--brand-purple);
        transform: translateY(-1px);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .mobile-nav-tab.active {
        background-color: var(--brand-purple);
        color: white;
        border-color: var(--brand-purple);
        box-shadow: 0 2px 4px rgba(174, 79, 254, 0.3);
    }
    
    .mobile-nav-tab.active:hover {
        background-color: var(--brand-purple-hover);
        color: white;
    }
    
    /* ============================================================
       MOBILE BOTTOM TAB BAR
       ============================================================ */
    
    .mobile-bottom-tab-bar {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 56px;
        background-color: var(--bg-secondary);
        border-top: 1px solid var(--gray-200);
        z-index: 1050;
        justify-content: space-around;
        align-items: center;
        padding: 0;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
    }

    .bottom-tab-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        height: 56px;
        min-height: 44px;
        min-width: 44px;
        text-decoration: none;
        color: var(--text-secondary);
        font-size: 10px;
        gap: 2px;
        transition: color 0.2s ease;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        cursor: pointer;
        border: none;
        background: none;
        padding: 4px 0;
    }
    
    .bottom-tab-item.active {
        color: var(--brand-purple);
    }
    
    .bottom-tab-item.active i {
        color: var(--brand-purple);
    }
    
    /* More button: reset default button styles to match tab links */
    .mobile-bottom-tab-bar button.bottom-tab-item {
        border: none;
        background: none;
        font-family: inherit;
        cursor: pointer;
        color: inherit;
        -webkit-tap-highlight-color: transparent;
    }
    
    .mobile-bottom-tab-bar button.bottom-tab-item.active {
        color: var(--brand-purple);
    }
    
    /* "More" menu overlay */
    .more-menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1040;
    }
    
    .more-menu-overlay.active {
        display: block !important;
    }
    
    .more-menu-sheet {
        position: fixed;
        bottom: 56px;
        bottom: calc(56px + env(safe-area-inset-bottom, 0px));
        left: 0;
        right: 0;
        background-color: var(--bg-primary);
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        max-height: 70vh;
        overflow-y: auto;
        z-index: 1041;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        padding-bottom: 8px;
    }
    
    .more-menu-handle {
        display: flex;
        justify-content: center;
        padding: 12px 0 8px 0;
    }
    
    .more-menu-handle-bar {
        width: 36px;
        height: 4px;
        background-color: var(--gray-300);
        border-radius: 2px;
    }
    
    .more-menu-content {
        display: flex;
        flex-direction: column;
        padding: 0 16px;
    }
    
    .more-menu-item {
        display: flex;
        align-items: center;
        gap: 16px;
        padding: 14px 12px;
        text-decoration: none;
        color: var(--text-primary);
        border-radius: 10px;
        transition: background-color 0.15s ease;
        min-height: 44px;
        -webkit-tap-highlight-color: transparent;
    }
    
    .more-menu-item:hover,
    .more-menu-item:active {
        background-color: var(--bg-secondary);
        text-decoration: none;
        color: var(--text-primary);
    }
    
    .more-menu-item.active {
        background-color: var(--brand-purple-light, #f3e8ff);
        color: var(--brand-purple);
    }
    
    .more-menu-item.active i {
        color: var(--brand-purple);
    }
    
    /* Chart Mobile Styles */
    .js-plotly-plot .legend {
        display: none !important;
    }
    
    .chart {
        width: 100% !important;
        height: 350px !important;
    }
    
    /* Optimize Card Padding for Horizontal Space */
    .metric-card {
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding: 12px !important; /* Reduced from default, optimized for mobile */
    }
    
    .metric-card .card-body {
        padding: 8px !important; /* Reduced from 10px for more horizontal space */
    }
    
    /* Simulation results card needs minimal padding for graphs */
    .simulation-page-content .metric-card .card-body {
        padding: 4px !important; /* Minimal padding for simulation graphs and tabs */
    }
    
    .metric-card .card-body .chart {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .js-plotly-plot {
        width: 100% !important;
        height: 100% !important;
    }
    
    .chart-container-primary,
    .chart-container-secondary {
        padding: 5px !important;
    }
    
    /* Insight Cards Mobile */
    /* Category Insights - Force full width and prevent overflow */
    .insight-cards-container {
        flex-direction: column !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }
    
    /* Prevent charts in category insights from causing card growth */
    #category-insights .dcc-graph,
    #category-insights .dash-graph,
    #category-insights .js-plotly-plot {
        max-height: 60px !important;
        overflow: hidden !important;
    }
    
    .insight-cards-container > div {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin-bottom: 16px !important;
        box-sizing: border-box !important;
    }
    
    .insight-cards-container > div:last-child {
        margin-bottom: 0 !important;
    }
    
    /* Override any inline width styles on insight cards */
    .insight-cards-container > div[style*="width"] {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Expenses Trends Card Mobile */
    #expenses-trends-card {
        height: auto !important;
        min-height: 400px !important;
    }
    
    #expenses-trends-card-body {
        padding: 10px !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    #expenses-trends-card .expenses-tab-header {
        font-size: 1rem !important;
        padding: 8px 12px !important;
    }
    
    #expenses-trends-card #all-expenses-grid {
        height: 250px !important;
    }
    
    #expenses-trends-card #expenses-line-chart {
        height: 300px !important;
    }
    
    #expenses-trends-card .transaction-totals {
        margin-bottom: 8px !important;
        font-size: 12px !important;
    }
    
    #expenses-trends-card .transaction-totals-container {
        padding: 5px 10px !important;
        margin-bottom: 5px !important;
    }
    
    #expenses-trends-card .transaction-totals-container > div {
        font-size: 12px !important;
        margin: 0 2px !important;
    }
    
    /* Optimize Transaction Totals Pills for Horizontal Space */
    .transaction-totals-container {
        padding: 8px 12px !important; /* Reduced padding for more horizontal space */
    }
    
    .transaction-totals-container > div {
        padding: 6px 10px !important; /* More compact pills */
        font-size: 12px !important; /* Minimum readable font size */
        margin: 0 3px !important; /* Reduced margin between pills */
    }
    
    /* Transaction Display Mobile */
    #desktop-transactions-container {
        display: none !important;
    }
    
    #top-transactions-cards {
        display: block !important;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        max-height: 550px !important;
        max-width: 100% !important;
        overflow-y: auto !important;
        overflow-x: clip !important;
        box-sizing: border-box !important;
    }
    
    #top-transactions-cards::-webkit-scrollbar {
        width: 4px;
    }
    
    #top-transactions-cards::-webkit-scrollbar-thumb {
        background: var(--border-secondary);
        border-radius: 2px;
    }
    
    /* Transaction Cards Mobile */
    .transaction-card {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        margin-bottom: 12px !important;
    }
    
    .transaction-card:hover {
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    }
    
    .transaction-card:active {
        transform: translateY(0);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Optimize Transaction Cards for Horizontal Space */
    .transaction-card {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .transaction-card .card-content {
        min-height: 60px !important;
        padding: 12px 12px !important;
        align-items: center !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Optimize Row Spacing for Horizontal Space.
       Use clip instead of hidden to prevent scroll container creation. */
    .page-content .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
        max-width: 100% !important;
        overflow-x: clip !important;
    }
    
    .page-content .row > [class*="col-"] {
        padding-left: 0 !important;
        padding-right: 0 !important;
        max-width: 100% !important;
        overflow-x: clip !important;
    }
    
    /* Ensure Bootstrap rows don't cause overflow */
    .row {
        margin-left: 0 !important;
        margin-right: 0 !important;
        max-width: 100% !important;
    }
    
    [class*="col-"] {
        max-width: 100% !important;
        overflow-x: clip !important;
    }
    
    /* Transaction Typography Mobile */
    .transaction-date {
        font-size: 14px !important;
        font-weight: 500 !important;
        min-width: 65px !important;
    }
    
    .transaction-amount {
        font-size: 16px !important;
        min-width: 80px !important;
    }
    
    .transaction-desc,
    .transaction-category {
        max-width: none !important;
        text-align: center !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        hyphens: auto !important;
        line-height: 1.3 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }
    
    .transaction-desc {
        font-size: 15px !important;
        font-weight: bold !important;
        margin-bottom: 2px !important;
    }
    
    .transaction-category {
        font-size: 12px !important;
        font-weight: bold !important;
        -webkit-line-clamp: 1 !important;
    }
    
    /* Overlay Responsive Display */
    #transactions-grid-overlay {
        display: none !important;
    }
    #transactions-cards-overlay {
        display: block !important;
    }
    
    #income-desktop-transactions-container {
        display: none !important;
    }
    #income-transactions-cards {
        display: block !important;
        max-width: 100% !important;
        overflow-x: clip !important;
        box-sizing: border-box !important;
    }
    
    #income-transactions-grid-overlay {
        display: none !important;
    }
    #income-transactions-cards-overlay {
        display: block !important;
    }
    
    #expenses-desktop-transactions-container {
        display: none !important;
    }
    #expenses-transactions-cards {
        display: block !important;
        max-width: 100% !important;
        overflow-x: clip !important;
        box-sizing: border-box !important;
    }
    
    #all-expenses-grid-overlay {
        display: none !important;
    }
    #expenses-transactions-cards-overlay {
        display: block !important;
    }
    
    #simulation-desktop-results-container {
        display: none !important;
    }
    #simulation-results-cards {
        display: block !important;
    }
}

/* Very Small Screens: max-width: 480px */
@media (max-width: 480px) {
    .transaction-card .card-content {
        padding: 12px 16px !important;
        align-items: center !important;
    }
    
    .transaction-date {
        min-width: 65px !important;
        font-size: 14px !important;
        font-weight: 500 !important;
        line-height: 1.2 !important;
    }
    
    .transaction-amount {
        min-width: 80px !important;
        font-size: 16px !important;
    }
    
    .transaction-desc,
    .transaction-category {
        max-width: none !important;
    }
    
    .transaction-desc {
        font-size: 14px !important;
    }
    
    .transaction-category {
        font-size: 12px !important;
    }
    
    .transaction-middle {
        min-height: 44px !important;
        justify-content: flex-start !important;
        align-items: center !important;
        padding-top: 2px !important;
    }
    
    .transaction-desc {
        -webkit-line-clamp: 2 !important;
        display: -webkit-box !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        text-align: center !important;
    }
    
    .transaction-category {
        -webkit-line-clamp: 1 !important;
        display: -webkit-box !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        text-align: center !important;
        font-weight: bold !important;
    }
}

/* Small Height Screens */
@media (max-height: 600px) {
    .mobile-nav-tabs {
        display: none;
    }
}

/* Very Small Containers */
@media (max-width: 320px) {
    .stacked-card-header {
        font-size: 12px;
        padding: 6px 10px;
    }
    
    .net-worth-value {
        font-size: 16px;
    }
    
    .savings-value,
    .return-value,
    .amount-needed-value {
        font-size: 11px;
    }
    
    .stacked-card-content {
        padding: 10px;
    }
}

/* Authentication Pages Mobile Styles */
@media (max-width: 768px) {
    /* Hide the right side branding section on mobile */
    .auth-image-container {
        display: none !important;
    }
    
    /* Make the form take full width on mobile */
    .auth-form {
        width: 100% !important;
        padding: 30px 20px !important;
    }
    
    /* Adjust auth card for mobile */
    .auth-card {
        width: 95% !important;
        max-width: 400px !important;
        height: auto !important;
        min-height: 600px !important;
    }
    
    /* Adjust main container for mobile */
    .auth-bg-curves {
        display: none !important;
    }
}

/* Very Small Screens: max-width: 480px */
@media (max-width: 480px) {
    .auth-form {
        padding: 20px 15px !important;
    }
    
    .auth-card {
        width: 98% !important;
        margin: 10px !important;
    }
}

/* ============================================================
   SIMULATION PAGE MOBILE OPTIMIZATIONS
   ============================================================ */
@media (max-width: 768px) {
    /* Optimize simulation input card spacing */
    .simulation-input {
        margin-bottom: 1rem !important;
    }
    
    /* Ensure tabs take full width and minimize padding */
    .nav-tabs {
        width: 100% !important;
        margin: 0 !important;
    }
    
    .simulation-page-content .nav-tabs .nav-link {
        padding: 8px 4px !important; /* Reduce tab padding on mobile */
        font-size: 0.85rem !important; /* Slightly smaller text for better fit */
    }
    
    .simulation-page-content .tab-content {
        padding: 0 !important; /* Remove tab content padding */
    }
    
    /* Optimize slider labels and marks for mobile */
    .rc-slider {
        margin-bottom: 2rem !important;
    }
}

/* Narrow Container Optimization */
@media (max-width: 300px) {
    .stacked-projection-card {
        margin-bottom: 8px;
    }
    
    .two-column-metrics {
        gap: 4px;
    }
    
    .metric-label,
    .metric-label-small {
        font-size: 9px;
    }
} 