/* ==============================================================================
   FOXY FINANCE - Responsive & Mobile PWA Styles (Android & iOS)
   ============================================================================== */

/* Desktop Default: Mobile bottom navigation, drawer, controls and FAB hidden */
.mobile-bottom-nav,
.mobile-fab-ingest,
.mobile-scroll-top-btn,
.mobile-drawer-backdrop,
.mobile-nav-drawer,
.mobile-top-bar-controls {
    display: none !important;
}

/* ----------------------------------------------------------------------------
   Tablet and Medium Displays (<= 1024px)
   ---------------------------------------------------------------------------- */
@media (max-width: 1024px) {
    .charts-row {
        flex-direction: column;
        height: auto;
    }
    
    .chart-container {
        width: 100%;
        height: 320px;
        margin-bottom: 20px;
    }

    .markets-layout {
        flex-direction: column;
        height: auto;
    }

    .markets-sidebar {
        width: 100%;
        max-height: 320px;
        overflow-y: auto;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .split-view-container {
        grid-template-columns: 1fr;
    }
}

/* ----------------------------------------------------------------------------
   Mobile Phones & Touch Devices (<= 768px) - PWA Optimized Experience
   ---------------------------------------------------------------------------- */
@media (max-width: 768px) {
    /* Prevent body background scrolling when drawer or modal is open */
    body.drawer-locked {
        overflow: hidden !important;
        touch-action: none;
    }

    .app-container {
        flex-direction: column;
    }

    /* Top Sticky App Bar for Mobile */
    .sidebar {
        position: sticky;
        top: 0;
        z-index: 1000;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        background: rgba(7, 10, 18, 0.96);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
    }

    .sidebar-header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding-top: max(10px, env(safe-area-inset-top, 0px)) !important;
        padding-bottom: 10px !important;
        padding-left: max(14px, env(safe-area-inset-left, 0px)) !important;
        padding-right: max(14px, env(safe-area-inset-right, 0px)) !important;
    }

    .sidebar-header .logo h1 {
        font-size: 1.05rem;
    }

    /* Mobile Top Bar Controls */
    .mobile-top-bar-controls {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
    }

    .mobile-quick-space-pill {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 5px 10px;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid rgba(212, 168, 83, 0.35);
        font-size: 0.72rem;
        font-weight: 700;
        color: #f8fafc;
        font-family: var(--font-mono);
        cursor: pointer;
        transition: all 0.2s;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-quick-space-pill:active {
        transform: scale(0.95);
        background: rgba(212, 168, 83, 0.15);
    }

    .mobile-theme-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.12);
        font-size: 0.95rem;
        cursor: pointer;
        color: var(--text-primary);
        transition: all 0.2s;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-theme-btn:active {
        transform: scale(0.92);
        background: rgba(255, 255, 255, 0.1);
    }

    .mobile-hamburger-btn {
        display: inline-flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        width: 36px;
        height: 36px;
        padding: 6px;
        border-radius: 8px;
        background: rgba(212, 168, 83, 0.12);
        border: 1px solid rgba(212, 168, 83, 0.35);
        cursor: pointer;
        gap: 4px;
        transition: all 0.2s;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-hamburger-btn:active {
        transform: scale(0.92);
    }

    .hamburger-line {
        width: 18px;
        height: 2px;
        background: var(--gold, #d4a853);
        border-radius: 2px;
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mobile-hamburger-btn.active .hamburger-line:nth-child(1) {
        transform: translateY(6px) rotate(45deg);
    }

    .mobile-hamburger-btn.active .hamburger-line:nth-child(2) {
        opacity: 0;
        transform: scaleX(0);
    }

    .mobile-hamburger-btn.active .hamburger-line:nth-child(3) {
        transform: translateY(-6px) rotate(-45deg);
    }

    /* Hide desktop nav links and desktop footer in phone header */
    .sidebar .nav-links {
        display: none !important;
    }

    .sidebar-footer {
        display: none !important;
    }

    /* Single-Row Clean Top Header Toolbar (Swipeable) */
    .top-header {
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
        white-space: nowrap !important;
        padding: 6px 12px !important;
        gap: 8px !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    }

    .top-header::-webkit-scrollbar {
        display: none;
    }

    .top-header .header-left,
    .top-header .header-actions {
        flex-wrap: nowrap !important;
        gap: 6px !important;
        flex-shrink: 0;
    }

    .top-header .clock {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    .top-header .connection-status-badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    .top-header .trading-spaces-segmented {
        padding: 2px;
    }

    .top-header .space-tab-btn {
        padding: 3px 8px;
        font-size: 0.72rem;
    }

    .top-header .complexity-segmented {
        padding: 2px;
    }

    .top-header .complexity-tab-btn {
        padding: 3px 8px;
        font-size: 0.72rem;
    }

    /* Content Area: prevent occlusion by Bottom Dock and handle iOS Notch */
    .content-area {
        padding: 12px 12px calc(84px + env(safe-area-inset-bottom, 0px)) 12px !important;
        overflow-x: hidden;
    }

    /* PWA Mobile Bottom Navigation Dock (Thumb-friendly) */
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(60px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: rgba(8, 12, 20, 0.96);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(212, 168, 83, 0.28);
        box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.75);
        z-index: 9999;
        align-items: center;
        justify-content: space-around;
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        height: 100%;
        color: var(--text-muted, #8a99ad);
        text-decoration: none;
        background: none;
        border: none;
        font-size: 0.68rem;
        font-weight: 500;
        letter-spacing: 0.02em;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        gap: 3px;
        -webkit-tap-highlight-color: transparent;
        cursor: pointer;
        padding: 0;
    }

    .mobile-nav-item:active {
        transform: scale(0.92);
    }

    .mobile-nav-item.active {
        color: var(--gold, #d4a853);
        font-weight: 700;
    }

    .mobile-nav-item.active .mobile-nav-icon svg {
        stroke: var(--gold, #d4a853);
        stroke-width: 2.3;
        filter: drop-shadow(0 0 8px rgba(212, 168, 83, 0.65));
        transform: translateY(-2px);
    }

    .mobile-nav-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.2s ease;
    }

    /* Off-Canvas Mobile Navigation Drawer & Backdrop */
    .mobile-drawer-backdrop {
        display: block !important;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.72);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 99998;
    }

    .mobile-drawer-backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-nav-drawer {
        display: flex !important;
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(340px, 86vw);
        max-width: 380px;
        background: #080d19;
        border-right: 1px solid rgba(212, 168, 83, 0.28);
        box-shadow: 12px 0 48px rgba(0, 0, 0, 0.85);
        transform: translateX(-105%);
        transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 99999;
        flex-direction: column;
        overflow: hidden;
    }

    .mobile-nav-drawer.open {
        transform: translateX(0);
    }

    .mobile-drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-top: max(16px, env(safe-area-inset-top, 0px));
        padding-bottom: 14px;
        padding-left: max(16px, env(safe-area-inset-left, 0px));
        padding-right: max(16px, env(safe-area-inset-right, 0px));
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        background: rgba(15, 23, 42, 0.75);
    }

    .mobile-drawer-user {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 0;
    }

    .mobile-user-avatar {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        background: linear-gradient(135deg, rgba(212,168,83,0.2), rgba(99,102,241,0.2));
        border: 1px solid rgba(212,168,83,0.4);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.25rem;
        flex-shrink: 0;
    }

    .mobile-user-meta {
        display: flex;
        flex-direction: column;
        gap: 2px;
        min-width: 0;
    }

    .mobile-user-meta strong {
        font-size: 0.92rem;
        color: #f8fafc;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-drawer-close {
        width: 38px;
        height: 38px;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.06);
        border: 1px solid var(--border);
        color: var(--text-muted);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-drawer-close:active {
        transform: scale(0.92);
        background: rgba(255, 255, 255, 0.12);
        color: #ffffff;
    }

    .mobile-drawer-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 14px 12px;
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .mobile-drawer-section {
        display: flex;
        flex-direction: column;
    }

    .mobile-section-title {
        font-size: 0.68rem;
        font-weight: 700;
        letter-spacing: 0.08em;
        color: #d4a853;
        text-transform: uppercase;
        margin-bottom: 6px;
        padding: 0 4px;
        user-select: none;
    }

    .mobile-spaces-grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        background: rgba(0, 0, 0, 0.35);
        padding: 4px;
        border-radius: 10px;
        border: 1px solid var(--border);
    }

    .mobile-space-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 8px 4px;
        border-radius: 8px;
        border: none;
        background: transparent;
        color: var(--text-muted);
        font-size: 0.72rem;
        font-weight: 600;
        gap: 4px;
        cursor: pointer;
        transition: all 0.2s;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-space-btn.active {
        background: rgba(212, 168, 83, 0.16);
        color: #f8fafc;
        border: 1px solid rgba(212, 168, 83, 0.45);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    }

    .mobile-complexity-toggle {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        background: rgba(0, 0, 0, 0.35);
        padding: 4px;
        border-radius: 10px;
        border: 1px solid var(--border);
    }

    .mobile-comp-btn {
        padding: 8px;
        border-radius: 8px;
        border: none;
        background: transparent;
        color: var(--text-muted);
        font-size: 0.76rem;
        font-weight: 600;
        text-align: center;
        cursor: pointer;
        transition: all 0.2s;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-comp-btn.active {
        background: rgba(99, 102, 241, 0.2);
        color: #818cf8;
        border: 1px solid rgba(99, 102, 241, 0.4);
    }

    .mobile-drawer-links {
        list-style: none;
        padding: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .mobile-drawer-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 12px;
        border-radius: 10px;
        text-decoration: none;
        color: var(--text-secondary);
        background: rgba(255, 255, 255, 0.02);
        border: 1px solid transparent;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-drawer-item:active,
    .mobile-drawer-item.active {
        background: rgba(212, 168, 83, 0.12);
        border-color: rgba(212, 168, 83, 0.35);
        color: #f8fafc;
    }

    .mobile-drawer-item.active .drawer-item-icon svg {
        stroke: var(--gold, #d4a853);
        filter: drop-shadow(0 0 6px rgba(212, 168, 83, 0.5));
    }

    .drawer-item-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        color: var(--gold, #d4a853);
        font-size: 1.1rem;
        flex-shrink: 0;
    }

    .drawer-item-text {
        display: flex;
        flex-direction: column;
        flex: 1;
        min-width: 0;
    }

    .drawer-item-text strong {
        font-size: 0.85rem;
        font-weight: 600;
        line-height: 1.25;
        color: inherit;
    }

    .drawer-item-title-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 6px;
    }

    .drawer-item-badge {
        font-size: 0.62rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
        padding: 2px 6px;
        border-radius: 999px;
        background: rgba(212, 168, 83, 0.15);
        color: #f3d489;
        border: 1px solid rgba(212, 168, 83, 0.35);
        line-height: 1;
        flex-shrink: 0;
    }

    .drawer-item-badge.badge-oracle {
        background: rgba(99, 102, 241, 0.2);
        color: #c7d2fe;
        border-color: rgba(99, 102, 241, 0.45);
    }

    .drawer-item-badge.badge-signals {
        background: rgba(34, 197, 94, 0.2);
        color: #86efac;
        border-color: rgba(34, 197, 94, 0.45);
    }

    .drawer-item-badge.badge-portfolio {
        background: rgba(59, 130, 246, 0.2);
        color: #93c5fd;
        border-color: rgba(59, 130, 246, 0.45);
    }

    .drawer-item-badge.badge-brokers {
        background: rgba(212, 168, 83, 0.2);
        color: #fde047;
        border-color: rgba(212, 168, 83, 0.45);
    }

    .drawer-item-icon.icon-oracle {
        color: #a5b4fc;
        background: rgba(99, 102, 241, 0.14);
        border-radius: 8px;
    }

    .drawer-item-icon.icon-signals {
        color: #4ade80;
        background: rgba(34, 197, 94, 0.14);
        border-radius: 8px;
    }

    .drawer-item-icon.icon-portfolio {
        color: #60a5fa;
        background: rgba(59, 130, 246, 0.14);
        border-radius: 8px;
    }

    .drawer-item-icon.icon-brokers {
        color: #facc15;
        background: rgba(212, 168, 83, 0.14);
        border-radius: 8px;
    }

    .drawer-item-text small {
        font-size: 0.7rem;
        color: var(--text-muted);
        line-height: 1.2;
        margin-top: 2px;
    }

    .drawer-item-arrow {
        font-size: 1.1rem;
        color: var(--text-muted);
        font-weight: 300;
        transition: transform 0.2s;
    }

    .mobile-drawer-item:active .drawer-item-arrow {
        transform: translateX(3px);
        color: var(--gold, #d4a853);
    }

    .mobile-drawer-quick-actions {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .mobile-quick-action-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        padding: 10px 12px;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.04);
        border: 1px solid var(--border);
        color: var(--text-primary);
        font-size: 0.8rem;
        font-weight: 600;
        cursor: pointer;
        text-align: center;
        transition: all 0.2s;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-quick-action-btn:active {
        transform: scale(0.97);
        background: rgba(255, 255, 255, 0.08);
    }

    .mobile-drawer-footer {
        padding-top: 12px;
        padding-left: max(16px, env(safe-area-inset-left, 0px));
        padding-right: max(16px, env(safe-area-inset-right, 0px));
        padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        background: rgba(10, 14, 23, 0.9);
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .mobile-logout-btn {
        width: 100%;
        padding: 11px;
        border-radius: 8px;
        background: rgba(239, 68, 68, 0.1);
        border: 1px solid rgba(239, 68, 68, 0.3);
        color: #f87171;
        font-size: 0.84rem;
        font-weight: 700;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        transition: all 0.2s;
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-logout-btn:active {
        transform: scale(0.97);
        background: rgba(239, 68, 68, 0.2);
    }

    .mobile-drawer-footer-note {
        font-size: 0.65rem;
        color: var(--text-muted);
        text-align: center;
    }

    /* Floating Scroll-to-Top Button */
    .mobile-scroll-top-btn {
        display: flex !important;
        position: fixed;
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
        left: 14px;
        z-index: 9990;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: rgba(15, 23, 42, 0.88);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border: 1px solid rgba(212, 168, 83, 0.35);
        color: var(--gold, #d4a853);
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
        opacity: 0;
        transform: translateY(16px);
        pointer-events: none;
        transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
        -webkit-tap-highlight-color: transparent;
    }

    .mobile-scroll-top-btn.visible {
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }

    .mobile-scroll-top-btn:active {
        transform: scale(0.92);
    }

    /* Floating Action Button (FAB) for Mobile Quick Screenshot Ingestion */
    .mobile-fab-ingest {
        display: inline-flex !important;
        position: fixed;
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
        right: 14px;
        z-index: 9995;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 8px 14px;
        min-height: 42px;
        background: linear-gradient(135deg, #f5d47a 0%, #d4a853 45%, #b8860b 100%);
        color: #0b0f19;
        font-family: inherit;
        font-size: 0.8rem;
        font-weight: 700;
        letter-spacing: 0.02em;
        border: 1px solid rgba(255, 255, 255, 0.45);
        border-radius: 9999px;
        box-shadow: 0 6px 20px rgba(212, 168, 83, 0.5), 0 2px 8px rgba(0, 0, 0, 0.6);
        cursor: pointer;
        user-select: none;
        -webkit-user-select: none;
        -webkit-tap-highlight-color: transparent;
        transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.18s ease;
        touch-action: manipulation;
    }

    .mobile-fab-ingest:hover,
    .mobile-fab-ingest:focus-visible {
        transform: translateY(-2px) scale(1.03);
        box-shadow: 0 8px 26px rgba(212, 168, 83, 0.65), 0 3px 10px rgba(0, 0, 0, 0.7);
    }

    .mobile-fab-ingest:active {
        transform: scale(0.95);
        box-shadow: 0 2px 10px rgba(212, 168, 83, 0.35);
    }

    .mobile-fab-ingest .fab-icon {
        font-size: 1.15rem;
        line-height: 1;
        display: inline-block;
        filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
    }

    .mobile-fab-ingest .fab-text {
        line-height: 1;
        white-space: nowrap;
        font-weight: 700;
    }

    /* Stack and enlarge portfolio-controls for mobile touch accessibility */
    .portfolio-controls {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        gap: 8px !important;
        margin-top: 10px !important;
    }

    .portfolio-controls > button,
    .portfolio-controls > .btn,
    .portfolio-controls > .badge,
    .portfolio-controls > div,
    .portfolio-controls #portfolio-execution-pill {
        width: 100% !important;
        min-height: 44px !important;
        justify-content: center !important;
        font-size: 0.85rem !important;
        box-sizing: border-box;
    }

    #btn-open-ingest-modal {
        background: linear-gradient(135deg, #f5d47a 0%, #d4a853 45%, #b8860b 100%) !important;
        color: #0b0f19 !important;
        font-weight: 700 !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        box-shadow: 0 4px 14px rgba(212, 168, 83, 0.35) !important;
    }

    #btn-open-qr-link-modal {
        background: rgba(56, 189, 248, 0.14) !important;
        color: #38bdf8 !important;
        font-weight: 700 !important;
        border: 1px solid rgba(56, 189, 248, 0.4) !important;
        box-shadow: 0 4px 14px rgba(56, 189, 248, 0.25) !important;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .filters-bar {
        overflow-x: auto;
        padding-bottom: 8px;
        width: 100%;
        -webkit-overflow-scrolling: touch;
    }

    /* Modal adjustments for small touch screens */
    .modal-card {
        width: 96% !important;
        max-width: 96% !important;
        max-height: 88vh !important;
        overflow-y: auto !important;
        padding: 1.1rem !important;
        margin: auto;
    }

    #modal-ingest-screenshot .modal-card,
    #modal-broker-qr-scanner .modal-card {
        padding: 1rem !important;
    }

    #modal-ingest-screenshot #ingest-dropzone,
    #modal-broker-qr-scanner #qr-dropzone {
        padding: 20px 14px !important;
    }

    /* Touch targets optimization */
    button, .btn-primary, .btn-secondary, .btn-ghost {
        min-height: 42px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Prevent auto-zoom on input focus in iOS Safari */
    input, select, textarea {
        font-size: 16px !important;
    }

    /* Touch table overflow scrolling with hint */
    .table-container, .trades-table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }
}

/* ----------------------------------------------------------------------------
   Light Theme Overrides for Mobile Navigation & PWA Controls
   ---------------------------------------------------------------------------- */
@media (max-width: 768px) {
    body.light-theme .sidebar {
        background: rgba(255, 255, 255, 0.95);
        border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    }

    body.light-theme .mobile-quick-space-pill {
        background: rgba(0, 0, 0, 0.05);
        border-color: rgba(184, 134, 11, 0.4);
        color: #1e293b;
    }

    body.light-theme .mobile-theme-btn {
        background: rgba(0, 0, 0, 0.04);
        border-color: rgba(0, 0, 0, 0.12);
    }

    body.light-theme .mobile-bottom-nav {
        background: rgba(255, 255, 255, 0.96);
        border-top: 1px solid rgba(212, 168, 83, 0.4);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    }

    body.light-theme .mobile-nav-item {
        color: #64748b;
    }

    body.light-theme .mobile-nav-item.active {
        color: #b8860b;
    }

    body.light-theme .mobile-nav-drawer {
        background: #ffffff;
        border-right: 1px solid rgba(0, 0, 0, 0.12);
        box-shadow: 10px 0 40px rgba(0, 0, 0, 0.2);
    }

    body.light-theme .mobile-drawer-header {
        background: #f8fafc;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    }

    body.light-theme .mobile-user-meta strong {
        color: #0f172a;
    }

    body.light-theme .mobile-drawer-close {
        background: rgba(0, 0, 0, 0.05);
        border-color: rgba(0, 0, 0, 0.1);
        color: #64748b;
    }

    body.light-theme .mobile-spaces-grid,
    body.light-theme .mobile-complexity-toggle {
        background: #f1f5f9;
        border-color: #e2e8f0;
    }

    body.light-theme .mobile-space-btn.active {
        background: #ffffff;
        color: #0f172a;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }

    body.light-theme .mobile-comp-btn.active {
        background: #ffffff;
        color: #4f46e5;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }

    body.light-theme .mobile-drawer-item {
        background: rgba(0, 0, 0, 0.02);
        color: #1e293b;
    }

    body.light-theme .mobile-drawer-item.active {
        background: rgba(212, 168, 83, 0.14);
        border-color: rgba(212, 168, 83, 0.4);
        color: #0f172a;
    }

    body.light-theme .drawer-item-text strong {
        color: #0f172a;
    }

    body.light-theme .mobile-quick-action-btn {
        background: #f8fafc;
        border-color: #e2e8f0;
        color: #1e293b;
    }

    body.light-theme .mobile-drawer-footer {
        background: #f8fafc;
        border-top-color: #e2e8f0;
    }

    body.light-theme .drawer-item-badge.badge-oracle {
        background: rgba(99, 102, 241, 0.12);
        color: #4338ca;
        border-color: rgba(99, 102, 241, 0.3);
    }

    body.light-theme .drawer-item-badge.badge-signals {
        background: rgba(34, 197, 94, 0.12);
        color: #15803d;
        border-color: rgba(34, 197, 94, 0.3);
    }

    body.light-theme .drawer-item-badge.badge-portfolio {
        background: rgba(59, 130, 246, 0.12);
        color: #1d4ed8;
        border-color: rgba(59, 130, 246, 0.3);
    }

    body.light-theme .drawer-item-badge.badge-brokers {
        background: rgba(184, 134, 11, 0.12);
        color: #855306;
        border-color: rgba(184, 134, 11, 0.3);
    }

    body.light-theme .mobile-scroll-top-btn {
        background: rgba(255, 255, 255, 0.95);
        color: #b8860b;
        border-color: rgba(212, 168, 83, 0.4);
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
    }
}

/* Pairs Trading & Statistical Arbitrage Scanner Styles */
.pairs-trading-container {
    transition: all 0.2s ease;
}

@media (max-width: 768px) {
    .pairs-trading-container {
        padding: 1rem !important;
        margin-top: 1rem !important;
    }

    #pairs-scanner-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    .pair-card {
        padding: 0.85rem !important;
    }

    .pair-card .btn-consult-pair-oracle {
        min-height: 42px !important;
        font-size: 13px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    #btn-refresh-pairs,
    #btn-ask-oracle-pairs {
        min-height: 42px !important;
        touch-action: manipulation;
    }
}
