/**
 * HFA Mobile - Premium Investment App Design
 * Inspired by: Robinhood, Trading212, Yahoo Finance
 * 
 * Design Principles:
 * - Mobile-first, touch-friendly
 * - Clean white space with focused content
 * - Bottom navigation for thumb-friendly access
 * - Card-based, swipeable sections
 * - Smooth animations and micro-interactions
 * - Progressive disclosure (hide empty states)
 */

/* ═══════════════════════════════════════════════════════════════════════════
   DESKTOP DEFAULT - Hide mobile-only elements
   ═══════════════════════════════════════════════════════════════════════════ */

/* Mobile bottom navigation - hidden on desktop (>768px), shown on mobile via @media below */
.mobile-bottom-nav {
    display: none !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE OVERRIDES - Active below 768px
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    
    /* ─────────────────────────────────────────────────────────────────────
       ROOT & BODY
       ───────────────────────────────────────────────────────────────────── */
    
    :root {
        --mobile-nav-height: 64px;
        --mobile-header-height: 56px;
        --mobile-card-radius: 16px;
        --mobile-spacing: 16px;
        --mobile-tap-target: 48px;
        --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    }
    
    /* CRITICAL FIX: Override all body classes that lock viewport */
    html {
        overflow-x: hidden !important;
        overflow-y: auto !important;
        height: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    body,
    body.bloomberg-terminal,
    body.hfa-pro,
    body.sidebar-expanded {
        overflow-x: hidden !important;
        overflow-y: auto !important;
        height: auto !important;
        min-height: 100vh !important;
        -webkit-overflow-scrolling: touch !important;
        padding-bottom: 120px !important; /* Ensure bottom content visible above fixed nav */
        position: relative !important;
        touch-action: pan-y !important; /* Enable vertical touch scrolling */
    }
    
    /* CRITICAL FIX: Terminal container must allow scroll */
    .terminal-container {
        height: auto !important;
        min-height: calc(100vh - 40px) !important;
        overflow: visible !important;
        display: flex !important;
        flex-direction: column !important;
    }
    
    /* CRITICAL FIX: Terminal grid must be vertical flow */
    .terminal-grid {
        flex: 1 1 auto !important;
        overflow: visible !important;
        display: flex !important;
        flex-direction: column !important;
        min-height: 0 !important;
    }
    
    /* Smooth scrolling everywhere */
    * {
        scroll-behavior: smooth;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       GLOBAL: NO INTERNAL SCROLL - Page scrolls, boxes expand
       Override inline styles that cause clipping
       ───────────────────────────────────────────────────────────────────── */
    
    .panel-content[style*="overflow"],
    .panel[style*="overflow"],
    div[style*="overflow-y: auto"],
    div[style*="overflow: hidden"] {
        overflow: visible !important;
        max-height: none !important;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       HIDE DESKTOP SIDEBAR
       ───────────────────────────────────────────────────────────────────── */
    
    .terminal-sidebar,
    .sidebar,
    .terminal-functions {
        display: none !important;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       BLOOMBERG TERMINAL - Status Bar & Ticker Strip
       ───────────────────────────────────────────────────────────────────── */
    
    .terminal-status-bar {
        position: relative !important;
        height: auto !important;
        min-height: 44px !important;
        padding: 8px 12px !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    
    /* Show search on mobile - full width row */
    .terminal-status-bar .status-center {
        display: block !important;
        order: 3 !important;
        width: 100% !important;
        flex-basis: 100% !important;
        margin-top: 4px !important;
    }
    
    /* Mobile stock search styles */
    .stock-search-wrapper {
        max-width: 100% !important;
        width: 100% !important;
    }
    
    .stock-search-input {
        font-size: 16px !important; /* Prevents iOS zoom */
        padding: 10px 42px 10px 36px !important;
        border-radius: 8px !important;
    }
    
    .stock-search-kbd {
        display: none !important; /* Hide keyboard shortcut on mobile */
    }
    
    .stock-search-dropdown {
        border-radius: 8px !important;
        max-height: 50vh !important;
    }
    
    .search-result-item {
        padding: 12px !important; /* Larger tap targets */
        min-height: 48px !important;
    }
    
    .ticker-strip {
        display: none !important;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       MAIN CONTAINER - Full width
       ───────────────────────────────────────────────────────────────────── */
    
    .terminal-container,
    .app-container {
        flex-direction: column !important;
        min-height: 100vh !important;
        height: auto !important;
        margin-top: 0 !important;
    }
    
    .terminal-main,
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding-bottom: calc(var(--mobile-nav-height) + var(--safe-area-bottom) + 60px) !important;
        overflow: visible !important;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       CRITICAL: PANEL-GRID - Bloomberg Dashboard Fix
       Convert from CSS Grid to Flexbox column for mobile scroll
       ───────────────────────────────────────────────────────────────────── */
    
    .panel-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        padding: 8px !important;
        overflow: visible !important;
        height: auto !important;
        min-height: auto !important;
        /* Reset all grid properties */
        grid-template-columns: unset !important;
        grid-template-rows: unset !important;
    }
    
    /* Reset all panel grid positioning */
    .panel-grid > .terminal-panel,
    .watchlist-panel,
    .chart-panel,
    .signals-panel,
    .analytics-panel,
    .stats-panel,
    .ranked-panel,
    .news-panel,
    .indicators-panel,
    .heatmap-panel {
        grid-column: unset !important;
        grid-row: unset !important;
        width: 100% !important;
        min-height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }
    
    /* Panel ordering for mobile dashboard */
    .panel-grid > .chart-panel { order: 1 !important; min-height: 280px !important; }
    .panel-grid > .stats-panel { order: 2 !important; }
    .panel-grid > .signals-panel { order: 3 !important; display: flex !important; }
    .panel-grid > .watchlist-panel { order: 4 !important; }
    .panel-grid > .ranked-panel { order: 5 !important; display: flex !important; }
    .panel-grid > .analytics-panel { order: 6 !important; display: flex !important; }
    .panel-grid > .news-panel { order: 7 !important; display: flex !important; }
    .panel-grid > .heatmap-panel { order: 8 !important; }
    .panel-grid > .indicators-panel { order: 9 !important; }
    
    /* Terminal panels - full width cards */
    .terminal-panel {
        border-radius: 8px !important;
        overflow: visible !important;
        flex-shrink: 0 !important;
    }
    
    .terminal-panel .panel-body {
        overflow: visible !important;
        max-height: none !important;
    }
    
    .terminal-panel .panel-body.scrollable {
        overflow: visible !important;
        max-height: none !important;
    }
    
    /* Exception: Chart body MUST have constrained height to prevent infinite growth */
    .terminal-panel .panel-body.chart-body {
        overflow: hidden !important;
        max-height: 450px !important;
    }
    
    /* Ensure panel workspace also has bottom padding for scrolling past nav */
    .panel-workspace {
        padding-bottom: calc(var(--mobile-nav-height) + var(--safe-area-bottom) + 80px) !important;
    }
    
    /* Screener and data tables need extra padding at bottom */
    .terminal-panel.full-width,
    .terminal-panel:last-child {
        margin-bottom: calc(var(--mobile-nav-height) + var(--safe-area-bottom) + 20px);
    }
    
    /* Pagination footer needs to be visible above nav */
    .panel-footer,
    .pagination-footer,
    .screener-footer {
        margin-bottom: calc(var(--mobile-nav-height) + var(--safe-area-bottom) + 16px);
        padding-bottom: 16px;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       STATS GRID - Responsive for mobile
       ───────────────────────────────────────────────────────────────────── */
    
    .stats-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        height: auto !important;
    }
    
    .stat-cell {
        padding: 12px 8px !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border-subtle) !important;
    }
    
    .stat-cell:nth-child(odd) {
        border-right: 1px solid var(--border-subtle) !important;
    }
    
    .stat-value {
        font-size: 20px !important;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       COMMAND LINE - Hide on mobile (use nav instead)
       ───────────────────────────────────────────────────────────────────── */
    
    .command-line {
        display: none !important;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       MOBILE HEADER - Sticky, clean
       ───────────────────────────────────────────────────────────────────── */
    
    .terminal-header,
    .main-header {
        position: sticky;
        top: 0;
        left: 0;
        right: 0;
        height: var(--mobile-header-height);
        padding: 0 var(--mobile-spacing);
        background: var(--bg-primary);
        border-bottom: 1px solid var(--border-subtle);
        z-index: 100;
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    /* Mobile Logo */
    .mobile-logo {
        font-size: 24px;
        font-weight: 800;
        color: var(--accent-primary);
        letter-spacing: -1px;
    }
    
    /* Search bar - expands on focus */
    .header-search,
    .command-trigger {
        flex: 1;
        max-width: none !important;
        height: 40px;
        background: var(--bg-tertiary);
        border-radius: 12px;
        border: none;
        transition: all 0.2s ease;
    }
    
    .header-search input,
    .command-trigger {
        height: 100%;
        font-size: 15px;
        padding: 0 16px;
    }
    
    .header-search input::placeholder {
        color: var(--text-tertiary);
    }
    
    /* Hide non-essential header items */
    .header-breadcrumb,
    .header-time,
    .data-status,
    .header-status {
        display: none !important;
    }
    
    .header-actions {
        display: flex;
        gap: 8px;
    }
    
    /* Profile icon button */
    .mobile-profile-btn {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: var(--bg-tertiary);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       BOTTOM NAVIGATION - Horizontally Scrollable Full Navigation
       Shows ALL menu items from desktop with touch-friendly scrolling
       ───────────────────────────────────────────────────────────────────── */
    
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(var(--mobile-nav-height) + var(--safe-area-bottom));
        padding-bottom: var(--safe-area-bottom);
        background: var(--bg-secondary, #f8fafc);
        border-top: 1px solid var(--border-subtle, #e2e8f0);
        z-index: 1000;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        /* Horizontal scroll container - !important to override desktop hide rule */
        display: flex !important;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        /* Hide scrollbar but keep functionality */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .mobile-bottom-nav::-webkit-scrollbar {
        display: none;
    }
    
    /* Scroll fade indicators on edges */
    .mobile-bottom-nav::before,
    .mobile-bottom-nav::after {
        content: '';
        position: sticky;
        top: 0;
        bottom: 0;
        width: 24px;
        min-width: 24px;
        flex-shrink: 0;
        pointer-events: none;
        z-index: 10;
    }
    
    .mobile-bottom-nav::before {
        left: 0;
        background: linear-gradient(to right, var(--bg-secondary, #f8fafc) 0%, transparent 100%);
    }
    
    .mobile-bottom-nav::after {
        right: 0;
        background: linear-gradient(to left, var(--bg-secondary, #f8fafc) 0%, transparent 100%);
    }
    
    /* Nav items container for proper spacing */
    .mobile-nav-scroll {
        display: flex;
        align-items: center;
        gap: 4px;
        padding: 8px 12px;
        min-width: max-content;
    }
    
    /* When no wrapper exists, style direct children */
    .mobile-bottom-nav > a.mobile-nav-item:first-of-type {
        margin-left: 8px;
    }
    
    .mobile-bottom-nav > a.mobile-nav-item:last-of-type {
        margin-right: 8px;
    }
    
    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-width: 56px;
        min-height: var(--mobile-tap-target);
        padding: 8px 10px;
        color: var(--text-tertiary, #6e7681);
        text-decoration: none;
        transition: all 0.15s ease;
        border-radius: 10px;
        flex-shrink: 0;
        scroll-snap-align: start;
    }
    
    .mobile-nav-item:hover,
    .mobile-nav-item:active {
        background: var(--bg-hover, #f8fafc);
        text-decoration: none;
    }
    
    .mobile-nav-item.active {
        color: var(--accent-primary, #f78166);
        background: rgba(247, 129, 102, 0.1);
    }
    
    .mobile-nav-item .nav-icon {
        font-size: 20px;
        line-height: 1;
        margin-bottom: 2px;
    }
    
    .mobile-nav-item .nav-label {
        font-size: 9px;
        font-weight: 600;
        letter-spacing: 0.1px;
        white-space: nowrap;
        max-width: 48px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Active indicator - underline style for scrollable nav */
    .mobile-nav-item.active::after {
        content: '';
        position: absolute;
        bottom: 4px;
        left: 50%;
        transform: translateX(-50%);
        width: 20px;
        height: 3px;
        background: var(--accent-primary, #f78166);
        border-radius: 2px;
    }
    
    .mobile-nav-item {
        position: relative;
    }
    
    /* Nav divider for visual grouping */
    .mobile-nav-divider {
        width: 1px;
        height: 32px;
        background: var(--border-subtle, #e2e8f0);
        margin: 0 4px;
        flex-shrink: 0;
    }
    
    /* Alert badge on mobile nav */
    .mobile-nav-item .nav-badge {
        position: absolute;
        top: 4px;
        right: 4px;
        min-width: 16px;
        height: 16px;
        background: var(--negative, #f85149);
        color: white;
        font-size: 9px;
        font-weight: 700;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 4px;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       PANEL WORKSPACE - Vertical Stack
       ───────────────────────────────────────────────────────────────────── */
    
    .panel-workspace {
        display: flex !important;
        flex-direction: column;
        gap: var(--mobile-spacing);
        padding: var(--mobile-spacing);
        background: var(--bg-terminal);
        grid-template-columns: none !important;
        grid-template-rows: none !important;
        height: auto !important;
    }

    /* Override inline max-height on scrollable panels so content isn't clipped behind bottom nav */
    .panel-body.scrollable,
    .panel-body[style*="max-height"] {
        max-height: none !important;
        overflow: visible !important;
    }

    .terminal-panel.full-width {
        height: auto !important;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       CARDS - Modern rounded design (AUTO-EXPAND, NO CLIPPING)
       ───────────────────────────────────────────────────────────────────── */
    
    .panel,
    .card,
    .stat-card {
        background: var(--bg-primary);
        border-radius: var(--mobile-card-radius);
        border: 1px solid var(--border-subtle);
        overflow: visible !important; /* NO CLIPPING - show all content */
        grid-column: span 1 !important;
        grid-row: span 1 !important;
        max-height: none !important;
        height: auto !important;
    }
    
    .panel-header,
    .card-header {
        height: auto;
        padding: 16px;
        background: transparent;
        border-bottom: 1px solid var(--border-subtle);
    }
    
    .panel-title,
    .card-header h2 {
        font-size: 15px;
        font-weight: 700;
        text-transform: none;
        letter-spacing: -0.3px;
        color: var(--text-primary);
    }
    
    .panel-content,
    .card-body {
        padding: 16px;
    }
    
    .panel-footer {
        padding: 12px 16px;
        background: var(--bg-secondary);
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       DASHBOARD CARDS - AUTO-EXPAND (NO INTERNAL SCROLL, NO CLIPPING)
       Page scrolls vertically, but each box shows 100% of its content
       ───────────────────────────────────────────────────────────────────── */
    
    /* ALL panel content: NO max-height, NO internal scroll, AUTO-EXPAND */
    .panel .panel-content {
        padding: 16px;
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    /* Watchlist card */
    .panel:has(.watchlist-compact),
    .panel[data-panel="watchlist"],
    #watchlist-panel {
        min-height: 120px;
    }
    
    .panel:has(.watchlist-compact) .panel-content,
    .panel[data-panel="watchlist"] .panel-content,
    #watchlist-panel .panel-content {
        min-height: 80px;
    }
    
    /* Top Stocks / Score section */
    .panel:has(#top-ranked-table),
    .panel[data-panel="top-ranked"],
    #top-ranked-panel,
    .panel:has(.score-display),
    .panel[data-panel="scores"] {
        min-height: 120px;
    }
    
    /* Indicators card */
    .panel:has(.indicator-grid),
    .panel:has(#indicator-palette),
    .panel[data-panel="indicators"],
    #indicators-panel {
        min-height: 100px;
    }
    
    .panel:has(.indicator-grid) .panel-content,
    .panel:has(#indicator-palette) .panel-content,
    .panel[data-panel="indicators"] .panel-content,
    #indicators-panel .panel-content {
        min-height: 60px;
        padding: 16px;
    }
    
    /* Investment Thesis card - AUTO-EXPAND to show ALL buttons */
    .panel:has(#thesis-container),
    .panel[data-panel="thesis"],
    #thesis-panel {
        min-height: 200px;
    }
    
    .panel:has(#thesis-container) .panel-content,
    .panel[data-panel="thesis"] .panel-content,
    #thesis-panel .panel-content,
    #thesis-container {
        min-height: 150px;
        /* NO max-height, NO overflow - show ALL content including buttons */
    }
    
    /* Market News card */
    .panel:has(.news-feed),
    .panel[data-panel="news"],
    #news-panel {
        min-height: 120px;
    }
    
    /* Empty states */
    .panel .empty-state {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: inherit;
        padding: 24px 16px;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       PORTFOLIO SUMMARY - Hero Stats
       ───────────────────────────────────────────────────────────────────── */
    
    .mobile-hero-stats {
        padding: 24px var(--mobile-spacing);
        background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-terminal) 100%);
    }
    
    .mobile-portfolio-value {
        font-size: 40px;
        font-weight: 800;
        letter-spacing: -1.5px;
        line-height: 1.1;
        margin-bottom: 8px;
    }
    
    .mobile-portfolio-change {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        font-size: 16px;
        font-weight: 600;
        padding: 6px 12px;
        border-radius: 20px;
    }
    
    .mobile-portfolio-change.positive {
        color: var(--positive);
        background: var(--positive-bg);
    }
    
    .mobile-portfolio-change.negative {
        color: var(--negative);
        background: var(--negative-bg);
    }
    
    .portfolio-summary {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 16px;
        border: 0 !important;
    }
    
    .summary-item {
        text-align: left;
        padding: 12px;
        background: var(--bg-secondary);
        border-radius: 12px;
    }
    
    .summary-value {
        font-size: 20px !important;
        font-weight: 700;
    }
    
    .summary-label {
        font-size: 11px;
        color: var(--text-tertiary);
        margin-top: 4px;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       WATCHLIST - Compact cards
       ───────────────────────────────────────────────────────────────────── */
    
    .watchlist-compact {
        padding: 0;
    }
    
    .watchlist-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 16px;
        border-bottom: 1px solid var(--border-subtle);
        min-height: var(--mobile-tap-target);
        cursor: pointer;
        transition: background 0.15s ease;
        grid-template-columns: none;
    }
    
    .watchlist-item:active {
        background: var(--bg-hover);
    }
    
    .watchlist-item:last-child {
        border-bottom: none;
    }
    
    .watchlist-item .ticker {
        font-size: 16px;
        font-weight: 700;
        color: var(--text-primary);
        min-width: 60px;
    }
    
    .watchlist-item .name {
        flex: 1;
        font-size: 13px;
        color: var(--text-secondary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .watchlist-item .price {
        font-size: 16px;
        font-weight: 600;
        text-align: right;
    }
    
    .watchlist-item .change {
        font-size: 13px;
        font-weight: 600;
        min-width: 60px;
        text-align: right;
    }
    
    /* Mini chart sparkline */
    .watchlist-sparkline {
        width: 50px;
        height: 24px;
        flex-shrink: 0;
    }
    
    /* Empty watchlist - Better onboarding */
    .watchlist-empty {
        padding: 40px 24px;
        text-align: center;
    }
    
    .watchlist-empty-icon {
        font-size: 48px;
        margin-bottom: 16px;
        opacity: 0.5;
    }
    
    .watchlist-empty-title {
        font-size: 18px;
        font-weight: 600;
        margin-bottom: 8px;
        color: var(--text-primary);
    }
    
    .watchlist-empty-desc {
        font-size: 14px;
        color: var(--text-secondary);
        margin-bottom: 20px;
        line-height: 1.5;
    }
    
    .watchlist-empty-btn {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 14px 24px;
        background: var(--accent-primary);
        color: #fff;
        border-radius: 12px;
        font-size: 15px;
        font-weight: 600;
        text-decoration: none;
        transition: transform 0.15s ease, box-shadow 0.15s ease;
    }
    
    .watchlist-empty-btn:active {
        transform: scale(0.97);
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       CHART - Full width
       ───────────────────────────────────────────────────────────────────── */
    
    .chart-container {
        min-height: 280px;
        max-height: 400px !important; /* Prevent infinite growth */
        margin: 0 -16px;
        border-radius: 0;
        overflow: hidden !important;
    }
    
    /* Chart title bar */
    .mobile-chart-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px;
    }
    
    .mobile-stock-info {
        display: flex;
        align-items: center;
        gap: 12px;
    }
    
    .mobile-stock-logo {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        background: var(--bg-tertiary);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        font-weight: 700;
    }
    
    .mobile-stock-ticker {
        font-size: 20px;
        font-weight: 700;
    }
    
    .mobile-stock-name {
        font-size: 13px;
        color: var(--text-secondary);
    }
    
    .mobile-stock-price {
        text-align: right;
    }
    
    .mobile-price-value {
        font-size: 22px;
        font-weight: 700;
    }
    
    .mobile-price-change {
        font-size: 14px;
        font-weight: 600;
    }
    
    /* Timeframe pills - Horizontal scroll */
    .timeframe-selector {
        display: flex;
        gap: 8px;
        padding: 12px 16px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        background: transparent;
    }
    
    .timeframe-selector::-webkit-scrollbar {
        display: none;
    }
    
    .timeframe-btn {
        flex-shrink: 0;
        padding: 10px 18px;
        background: var(--bg-tertiary);
        border: none;
        border-radius: 20px;
        font-size: 14px;
        font-weight: 600;
        color: var(--text-secondary);
        min-height: var(--mobile-tap-target);
        transition: all 0.2s ease;
    }
    
    .timeframe-btn.active {
        background: var(--accent-primary);
        color: #fff;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       INDICATORS - Horizontal scroll chips
       ───────────────────────────────────────────────────────────────────── */
    
    .indicator-palette,
    #indicator-palette {
        padding: 12px 0;
    }
    
    .indicator-grid {
        display: flex !important;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0 16px;
        scrollbar-width: none;
        grid-template-columns: none !important;
    }
    
    .indicator-grid::-webkit-scrollbar {
        display: none;
    }
    
    .indicator-item {
        flex-shrink: 0;
        padding: 10px 16px;
        border-radius: 20px;
        min-height: 40px;
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    .indicator-item .name {
        white-space: nowrap;
    }
    
    .indicator-item .desc {
        display: none;
    }
    
    /* Active indicator chip */
    .indicator-item.active {
        background: var(--accent-blue);
        color: #fff;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       TOP RANKED - Swipeable cards
       ───────────────────────────────────────────────────────────────────── */
    
    #top-ranked-table {
        display: block;
    }
    
    #top-ranked-table thead {
        display: none;
    }
    
    #top-ranked-table tbody {
        display: flex;
        flex-direction: column;
    }
    
    #top-ranked-table tr {
        display: flex;
        align-items: center;
        padding: 14px 16px;
        border-bottom: 1px solid var(--border-subtle);
        gap: 12px;
    }
    
    #top-ranked-table td {
        padding: 0;
        border: none;
    }
    
    #top-ranked-table .cell-ticker {
        font-size: 16px;
        font-weight: 700;
        min-width: 70px;
    }
    
    #top-ranked-table .cell-number {
        flex: 1;
    }
    
    .score-pill {
        padding: 6px 14px;
        border-radius: 16px;
        font-size: 14px;
    }
    
    .risk-indicator {
        padding: 6px 12px;
        border-radius: 12px;
        font-size: 11px;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       INVESTMENT THESIS - Collapsible
       ───────────────────────────────────────────────────────────────────── */
    
    #thesis-container {
        padding: 16px;
    }
    
    .thesis-card {
        border-radius: var(--mobile-card-radius);
        padding: 20px;
    }
    
    .thesis-header {
        flex-direction: column;
        gap: 16px;
    }
    
    .thesis-factors {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .factor-group {
        padding: 16px;
        border-radius: 12px;
    }
    
    /* Investment Thesis - AUTO-EXPAND (show ALL buttons and content) */
    #thesis-container {
        min-height: 150px;
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
        display: flex;
        flex-direction: column;
    }
    
    #thesis-container .empty-state {
        padding: 40px 24px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
    }
    
    #thesis-container .empty-state-icon {
        font-size: 64px;
        margin-bottom: 16px;
        animation: pulse-glow 2s ease-in-out infinite;
    }
    
    @keyframes pulse-glow {
        0%, 100% { 
            opacity: 0.8;
            transform: scale(1);
        }
        50% { 
            opacity: 1;
            transform: scale(1.05);
        }
    }
    
    #thesis-container .empty-state-title {
        font-size: 18px;
        font-weight: 600;
        color: var(--text-primary);
        margin-bottom: 8px;
    }
    
    #thesis-container .empty-state-desc {
        font-size: 14px;
        line-height: 1.5;
        color: var(--text-secondary);
        max-width: 300px;
        text-align: center;
        margin-bottom: 20px;
    }
    
    #thesis-container .empty-state-action .btn {
        padding: 12px 24px;
        font-size: 15px;
    }
    
    /* Thesis Card - AUTO-EXPAND for all content */
    #thesis-container .thesis-card {
        min-height: 150px;
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
        padding: 20px;
    }
    
    #thesis-container .thesis-summary {
        font-size: 15px;
        line-height: 1.6;
        margin-top: 16px;
    }
    
    /* Thesis action buttons - ensure fully visible */
    #thesis-container .thesis-actions,
    #thesis-container .btn-group,
    #thesis-container .action-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        margin-top: 16px;
        overflow: visible !important;
    }
    
    /* Collapsible sections */
    .mobile-collapsible {
        overflow: hidden;
    }
    
    .mobile-collapsible-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px;
        cursor: pointer;
        min-height: var(--mobile-tap-target);
    }
    
    .mobile-collapsible-icon {
        transition: transform 0.2s ease;
    }
    
    .mobile-collapsible.open .mobile-collapsible-icon {
        transform: rotate(180deg);
    }
    
    .mobile-collapsible-content {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    
    .mobile-collapsible.open .mobile-collapsible-content {
        max-height: 1000px;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       NEWS FEED - Card style
       ───────────────────────────────────────────────────────────────────── */
    
    .news-feed {
        gap: 0;
    }
    
    .news-item {
        padding: 16px;
        border-bottom: 1px solid var(--border-subtle);
        gap: 12px;
    }
    
    .news-item:last-child {
        border-bottom: none;
    }
    
    .news-time {
        font-size: 12px;
        width: auto;
        min-width: auto;
    }
    
    .news-headline {
        font-size: 15px;
        line-height: 1.4;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       DATA TABLES & TERMINAL TABLES - Mobile optimized with horizontal scroll
       ───────────────────────────────────────────────────────────────────── */
    
    /* Wrapper for horizontal scroll */
    .panel-body:has(.data-table),
    .panel-body:has(.terminal-table),
    .card-body:has(.data-table) {
        overflow-x: auto !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: touch;
        max-height: none !important;
    }
    
    .data-table,
    .terminal-table {
        min-width: 500px; /* Ensure horizontal scroll triggers */
        width: 100%;
    }
    
    .data-table th,
    .data-table td,
    .terminal-table th,
    .terminal-table td {
        padding: 10px 8px !important;
        font-size: 12px !important;
        white-space: nowrap;
    }
    
    .data-table th,
    .terminal-table th {
        font-size: 10px !important;
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--bg-secondary, var(--bg-panel-header, #1a1a1a)) !important;
    }
    
    .data-table thead,
    .terminal-table thead {
        position: sticky;
        top: 0;
        z-index: 10;
        background: var(--bg-secondary, var(--bg-panel-header, #f1f5f9)) !important;
    }
    
    /* Terminal table specific */
    .terminal-table.mini th,
    .terminal-table.mini td {
        padding: 6px !important;
        font-size: 11px !important;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       COMMAND PALETTE - Full screen modal
       ───────────────────────────────────────────────────────────────────── */
    
    .command-palette {
        padding: 0;
        align-items: flex-start;
    }
    
    .command-dialog {
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        border: none;
    }
    
    .command-input-wrapper {
        padding: 16px;
    }
    
    .command-input {
        font-size: 17px;
    }
    
    .command-results {
        max-height: calc(100vh - 70px);
    }
    
    .command-item {
        padding: 14px 16px;
        min-height: var(--mobile-tap-target);
    }
    
    .command-item-shortcut {
        display: none;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       EMPTY STATES - Better onboarding
       ───────────────────────────────────────────────────────────────────── */
    
    .empty-state {
        padding: 48px 24px;
    }
    
    .empty-state-icon {
        font-size: 56px;
        margin-bottom: 20px;
    }
    
    .empty-state-title {
        font-size: 20px;
        margin-bottom: 8px;
    }
    
    .empty-state-desc {
        font-size: 15px;
        line-height: 1.5;
        max-width: 280px;
    }
    
    .empty-state-action {
        margin-top: 24px;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       BUTTONS - Touch friendly
       ───────────────────────────────────────────────────────────────────── */
    
    .btn {
        min-height: var(--mobile-tap-target);
        padding: 14px 24px;
        border-radius: 12px;
        font-size: 15px;
        font-weight: 600;
    }
    
    .btn-sm {
        min-height: 40px;
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .btn-primary {
        background: var(--accent-primary);
    }
    
    .btn-primary:active {
        transform: scale(0.97);
    }
    
    .panel-btn {
        width: 36px;
        height: 36px;
        border-radius: 10px;
        font-size: 16px;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       FORM ELEMENTS - Touch friendly
       ───────────────────────────────────────────────────────────────────── */
    
    .form-group input,
    .form-group select,
    .form-group textarea,
    .filter-select,
    .filter-input,
    .input {
        min-height: var(--mobile-tap-target);
        padding: 14px 16px;
        font-size: 16px; /* Prevents iOS zoom */
        border-radius: 12px;
        /* Ensure proper contrast on mobile */
        background-color: var(--bg-card, #1e293b);
        color: var(--text-primary, #f1f5f9);
        border: 1px solid var(--border-color, #334155);
    }
    
    /* Select dropdown specific styling for mobile */
    .form-group select,
    .filter-select,
    select {
        appearance: none;
        -webkit-appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 14px center;
        padding-right: 40px;
    }
    
    .form-group select option,
    .filter-select option,
    select option {
        background-color: var(--bg-card, #1e293b);
        color: var(--text-primary, #f1f5f9);
    }
    
    .form-group label {
        font-size: 14px;
        margin-bottom: 8px;
    }
    
    /* Password field with toggle */
    .password-field-wrapper {
        position: relative;
    }
    
    .password-field-wrapper input {
        padding-right: 52px;
    }
    
    .password-toggle {
        position: absolute;
        right: 4px;
        top: 50%;
        transform: translateY(-50%);
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--text-tertiary);
        cursor: pointer;
        font-size: 20px;
        border-radius: 10px;
        transition: color 0.15s ease;
    }
    
    .password-toggle:hover,
    .password-toggle:active {
        color: var(--text-primary);
        background: var(--bg-hover);
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       AUTH PAGES - Mobile optimized (LIGHT THEME)
       HIGH CONTRAST FIX - 2026-09-02
       All colors ensure WCAG AA compliance on white background
       ───────────────────────────────────────────────────────────────────── */
    
    .auth-page {
        padding: 20px !important;
        min-height: 100vh !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%) !important;
    }
    
    .auth-container {
        width: 100% !important;
        max-width: 400px !important;
        padding: 0 !important;
        margin: 0 auto !important;
        box-sizing: border-box !important;
    }
    
    .auth-box {
        padding: 28px 20px !important;
        border-radius: var(--mobile-card-radius) !important;
        background: #ffffff !important;
        border: 1px solid #e2e8f0 !important;
        color: #1e293b !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .auth-header {
        text-align: center !important;
    }
    
    /* CRITICAL: Logo - Dark slate, highly readable */
    .auth-logo,
    .auth-box .auth-logo,
    .auth-header .auth-logo,
    h1.auth-logo {
        font-size: clamp(1.8rem, 8vw, 2.5rem) !important;
        text-align: center !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        color: #1e293b !important;  /* Dark slate - HIGH CONTRAST */
        -webkit-text-fill-color: #1e293b !important;
        font-weight: 800 !important;
    }
    
    .auth-tagline,
    .auth-header .auth-tagline,
    .auth-box .auth-tagline {
        font-size: 14px !important;
        color: #64748b !important;  /* Medium gray */
        text-align: center !important;
    }
    
    .auth-form {
        text-align: center !important;
    }
    
    /* CRITICAL: Form title - Almost black */
    .auth-form h2,
    .auth-box h2,
    form.auth-form h2 {
        font-size: 24px !important;
        margin-bottom: 24px !important;
        color: #0f172a !important;  /* Almost black - HIGHEST CONTRAST */
        -webkit-text-fill-color: #0f172a !important;
        font-weight: 600 !important;
    }
    
    .auth-form .form-group {
        text-align: left !important;
        margin-bottom: 20px !important;
    }
    
    /* CRITICAL: Labels - Dark gray, readable */
    .auth-form .form-group label,
    .auth-form label,
    .auth-box label {
        color: #374151 !important;  /* Dark gray - HIGH CONTRAST */
        -webkit-text-fill-color: #374151 !important;
        font-weight: 500 !important;
        font-size: 14px !important;
    }
    
    /* CRITICAL: Inputs - White background, dark text */
    .auth-form .form-group input,
    .auth-form input,
    .auth-box input {
        width: 100% !important;
        max-width: 100% !important;
        background: #ffffff !important;  /* Pure white */
        border: 1px solid #d1d5db !important;  /* Visible border */
        color: #1e293b !important;  /* Dark text */
        -webkit-text-fill-color: #1e293b !important;
        box-sizing: border-box !important;
        font-size: 16px !important;
    }
    
    .auth-form .form-group input::placeholder,
    .auth-form input::placeholder {
        color: #9ca3af !important;
        -webkit-text-fill-color: #9ca3af !important;
    }
    
    .auth-form .form-group input:focus,
    .auth-form input:focus {
        background: #ffffff !important;
        border-color: #3b82f6 !important;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
    }
    
    .auth-form .btn-primary,
    .auth-box .btn-primary {
        width: 100% !important;
        background: #3b82f6 !important;
        color: #ffffff !important;
        -webkit-text-fill-color: #ffffff !important;
    }
    
    .auth-footer,
    .auth-box .auth-footer,
    p.auth-footer {
        text-align: center !important;
        color: #64748b !important;  /* Medium gray */
    }
    
    .auth-footer a {
        color: #3b82f6 !important;  /* Blue link */
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       ANIMATIONS & MICRO-INTERACTIONS
       ───────────────────────────────────────────────────────────────────── */
    
    /* Page transitions */
    .mobile-page-enter {
        opacity: 0;
        transform: translateX(20px);
    }
    
    .mobile-page-enter-active {
        opacity: 1;
        transform: translateX(0);
        transition: opacity 0.2s ease, transform 0.2s ease;
    }
    
    /* Pull to refresh indicator */
    .mobile-refresh-indicator {
        position: fixed;
        top: var(--mobile-header-height);
        left: 50%;
        transform: translateX(-50%) translateY(-100%);
        padding: 12px 24px;
        background: var(--bg-secondary);
        border-radius: 20px;
        font-size: 13px;
        color: var(--text-secondary);
        box-shadow: 0 4px 20px rgba(0,0,0,0.3);
        transition: transform 0.2s ease;
        z-index: 50;
    }
    
    .mobile-refresh-indicator.visible {
        transform: translateX(-50%) translateY(16px);
    }
    
    /* Tap highlight */
    .mobile-tap-highlight {
        -webkit-tap-highlight-color: transparent;
        position: relative;
        overflow: hidden;
    }
    
    .mobile-tap-highlight::after {
        content: '';
        position: absolute;
        inset: 0;
        background: var(--text-primary);
        opacity: 0;
        transition: opacity 0.15s ease;
        pointer-events: none;
    }
    
    .mobile-tap-highlight:active::after {
        opacity: 0.1;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       TOAST NOTIFICATIONS
       ───────────────────────────────────────────────────────────────────── */
    
    .alert-toast {
        bottom: calc(var(--mobile-nav-height) + var(--safe-area-bottom) + 16px);
        left: var(--mobile-spacing);
        right: var(--mobile-spacing);
        max-width: none;
        border-radius: var(--mobile-card-radius);
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       FILTERS - Horizontal scroll
       ───────────────────────────────────────────────────────────────────── */
    
    .filters-bar {
        padding: 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Panel controls (SAVE, PRESETS, EXPORT buttons) */
    .panel-controls {
        gap: 6px;
        flex-wrap: wrap;
    }
    
    .ctrl-btn {
        font-size: 10px;
        padding: 6px 10px;
        min-height: 32px;
    }
    
    /* Hide text on very small screens, show only icons */
    @media (max-width: 400px) {
        .ctrl-btn {
            padding: 6px 8px;
        }
    }
    
    .filters-form,
    .screener-filters {
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        padding-bottom: 4px;
    }
    
    .filter-group {
        flex-shrink: 0;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       SCORE DISPLAY - Larger touch targets
       ───────────────────────────────────────────────────────────────────── */
    
    .score-circle {
        width: 120px;
        height: 120px;
        font-size: 40px;
    }
    
    .score-label {
        font-size: 14px;
    }
    
    .score-item {
        padding: 12px 0;
        grid-template-columns: 100px 1fr 50px;
    }
    
    .score-bar {
        height: 10px;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       STOCK DETAIL PAGE
       ───────────────────────────────────────────────────────────────────── */
    
    .stock-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 12px;
        width: 100%;
    }
    
    .stock-action-buttons {
        display: flex;
        gap: 8px;
        width: 100%;
    }
    
    .stock-action-buttons .btn {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        padding: 12px 8px;
        min-height: 44px;
        font-size: 13px;
        white-space: nowrap;
    }
    
    .stock-action-buttons .btn span:first-child {
        font-size: 16px;
    }
    
    /* Stock page action buttons - subtle compact style on mobile */
    .stock-page .stock-actions {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
    }
    
    .stock-page .stock-action-btn {
        padding: 6px 10px !important;
        font-size: 0.75rem !important;
        border-radius: 6px !important;
        background: transparent !important;
        border: 1px solid #e2e8f0 !important;
        color: #64748b !important;
    }
    
    .stock-page .stock-action-btn:hover,
    .stock-page .stock-action-btn:active {
        background: #f1f5f9 !important;
        border-color: #94a3b8 !important;
        color: #475569 !important;
    }
    
    /* Hide button text on very small screens, show only icon */
    @media (max-width: 480px) {
        .stock-page .stock-action-btn .watchlist-text,
        .stock-page .stock-action-btn span:not(.watchlist-icon):last-child {
            display: none;
        }
        
        .stock-page .stock-action-btn {
            padding: 8px 10px !important;
            min-width: 40px !important;
        }
    }
    
    /* Make buttons wrap into a row */
    .page-header {
        flex-direction: column;
        gap: 12px;
    }
    
    .stock-header-bar {
        flex-direction: column;
        padding: 20px var(--mobile-spacing);
        gap: 16px;
    }
    
    .stock-identity {
        width: 100%;
    }
    
    .stock-price-display {
        width: 100%;
        justify-content: space-between;
    }
    
    .stock-metrics {
        width: 100%;
        margin: 0;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
    
    .metric {
        text-align: center;
        padding: 12px;
        background: var(--bg-secondary);
        border-radius: 12px;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       SECTION VISIBILITY - Hide empty, show helpful states
       ───────────────────────────────────────────────────────────────────── */
    
    /* Auto-hide empty sections */
    .panel:has(.watchlist-compact:empty),
    .panel:has(.news-feed:empty) {
        display: none;
    }
    
    /* Or show onboarding state */
    .panel:has(.empty-state) .panel-actions {
        display: none;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       WATCHLISTS PAGE - Mobile Fix
       ───────────────────────────────────────────────────────────────────── */
    
    .watchlists-container {
        display: flex !important;
        flex-direction: column !important;
        grid-template-columns: unset !important;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        padding: 8px !important;
    }
    
    .watchlist-sidebar {
        display: none !important;
    }
    
    .watchlist-main {
        display: flex !important;
        flex-direction: column !important;
        overflow: visible !important;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        gap: 8px !important;
    }
    
    .stocks-panel {
        flex: unset !important;
        min-height: auto !important;
        height: auto !important;
        max-height: none !important;
    }
    
    .stocks-panel .panel-body,
    .stocks-panel .panel-body.scrollable {
        overflow: visible !important;
        overflow-x: auto !important;
        max-height: none !important;
        height: auto !important;
    }
    
    .watchlist-header-panel,
    .add-stock-panel,
    .chart-panel {
        flex-shrink: 0 !important;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       iOS SAFARI - Touch Scrolling & Momentum Fixes
       ───────────────────────────────────────────────────────────────────── */
    
    /* Enable momentum scrolling on all scrollable areas */
    html {
        -webkit-overflow-scrolling: touch;
        overflow-x: hidden;
        overflow-y: auto !important;
        height: auto !important;
    }
    
    /* Ensure touch events work properly - CRITICAL for scrolling */
    .terminal-container,
    .terminal-grid,
    .panel-grid,
    .panel-body,
    .terminal-content-area,
    .app-container,
    .content-area {
        touch-action: pan-y !important;
        -webkit-overflow-scrolling: touch !important;
        overflow: visible !important;
    }
    
    /* Reset any fixed heights that block scrolling */
    .terminal-container,
    .terminal-grid,
    .terminal-content-area {
        height: auto !important;
        max-height: none !important;
        min-height: 0 !important;
    }
    
    /* GPU acceleration for fixed elements (iOS smooth scroll) */
    .terminal-status-bar,
    .mobile-bottom-nav {
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       BLOOMBERG TERMINAL - Additional Mobile Fixes
       ───────────────────────────────────────────────────────────────────── */
    
    /* Signals split layout on mobile */
    .signals-split {
        display: flex !important;
        flex-direction: row !important;
        gap: 8px !important;
        height: auto !important;
    }
    
    .signal-section {
        flex: 1 !important;
        min-width: 0 !important;
        overflow: visible !important;
    }
    
    /* Thesis container - ensure all content visible */
    #thesis-container {
        padding: 12px !important;
        overflow: visible !important;
        max-height: none !important;
    }
    
    #thesis-container .thesis-card {
        overflow: visible !important;
    }
    
    #thesis-container .thesis-factors {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    #thesis-container .thesis-actions {
        flex-wrap: wrap !important;
        margin-top: 12px !important;
    }
    
    /* Heatmap - responsive grid */
    .heatmap-mini {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 4px !important;
    }
    
    .hm-cell {
        padding: 8px 4px !important;
        font-size: 11px !important;
        text-align: center !important;
    }
    
    /* ─────────────────────────────────────────────────────────────────────
       MARKET LIGHT PAGE - Table Overflow Fixes (2026-09-02)
       Decision Matrix & JONTE Tables - Bloomberg/Refinitiv quality
       ───────────────────────────────────────────────────────────────────── */
    
    /* Global: Prevent body horizontal overflow */
    html, body {
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
    
    /* Card containers - contain overflow properly */
    .card,
    .card.rounded-xl {
        max-width: 100% !important;
        overflow-x: hidden !important;
    }
    
    /* Decision Matrix Table - Horizontal Scroll */
    .decision-matrix {
        display: block !important;
        width: 100% !important;
        min-width: 420px !important;
        font-size: 11px !important;
    }
    
    .decision-matrix th,
    .decision-matrix td {
        padding: 8px 6px !important;
        white-space: nowrap !important;
        min-width: 55px !important;
    }
    
    .decision-matrix th:first-child,
    .decision-matrix td:first-child {
        min-width: 80px !important;
        position: sticky !important;
        left: 0 !important;
        background: var(--bg-primary, #ffffff) !important;
        z-index: 5 !important;
    }
    
    /* Wrapper for Decision Matrix - Horizontal scroll container */
    .card:has(.decision-matrix) {
        overflow-x: auto !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Visual scroll indicator for Decision Matrix */
    .card:has(.decision-matrix)::after {
        content: '← scroll →';
        display: block;
        text-align: center;
        font-size: 10px;
        color: var(--text-muted, #94a3b8);
        padding: 6px 0;
        background: linear-gradient(to right, 
            transparent 0%, 
            rgba(37, 99, 235, 0.08) 20%,
            rgba(37, 99, 235, 0.08) 80%,
            transparent 100%
        );
        margin-top: 8px;
        border-radius: 4px;
    }
    
    /* JONTE Tables Container - Horizontal Scroll */
    .jonte-table-container {
        overflow-x: auto !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: touch !important;
        max-width: 100% !important;
        margin: 0 -8px !important;
        padding: 0 8px !important;
    }
    
    /* JONTE Table Styling for Mobile */
    .jonte-table {
        min-width: 480px !important;
        width: max-content !important;
        font-size: 11px !important;
    }
    
    .jonte-table th,
    .jonte-table td {
        padding: 6px 8px !important;
        white-space: nowrap !important;
    }
    
    /* First column (rank) - sticky */
    .jonte-table th:first-child,
    .jonte-table td:first-child {
        position: sticky !important;
        left: 0 !important;
        background: var(--bg-primary, #ffffff) !important;
        z-index: 5 !important;
        min-width: 28px !important;
    }
    
    /* Second column (ticker) - sticky */
    .jonte-table th:nth-child(2),
    .jonte-table td:nth-child(2) {
        position: sticky !important;
        left: 28px !important;
        background: var(--bg-primary, #ffffff) !important;
        z-index: 5 !important;
        min-width: 70px !important;
    }
    
    /* Name column - truncate but show on hover/tooltip */
    .jonte-table td.truncate {
        max-width: 100px !important;
    }
    
    /* Top JONTE-ranked stocks table in grid */
    .card:has(table):has(th:contains("Score")),
    .card:has(.overflow-x-auto) {
        overflow-x: auto !important;
        overflow-y: visible !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    /* Generic table wrapper with overflow-x-auto class */
    .overflow-x-auto {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        max-width: 100% !important;
    }
    
    /* Ensure all tables inside cards can scroll */
    .card table,
    .rounded-xl table {
        min-width: max-content !important;
    }
    
    /* Small hint under scrollable tables */
    .jonte-table-container::after {
        content: '← swipe →';
        display: block;
        text-align: center;
        font-size: 9px;
        color: var(--text-muted, #94a3b8);
        padding: 4px 0 0;
        opacity: 0.7;
    }
    
    /* Score comparison tooltip positioning fix for mobile */
    .score-comparison {
        display: inline-flex !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
    }
    
    .comparison-tooltip,
    .score-tooltip {
        left: auto !important;
        right: 0 !important;
        transform: none !important;
        max-width: calc(100vw - 32px) !important;
    }
    
    .comparison-tooltip::after,
    .score-tooltip::after {
        left: auto !important;
        right: 12px !important;
        transform: none !important;
    }
    
    /* Grid layout fix for index tables on mobile */
    .grid.grid-cols-1.md\\:grid-cols-2 {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
    }
    
    /* Market Light specific page fixes */
    .market-light-content {
        max-width: 100vw !important;
        overflow-x: hidden !important;
        padding: 0 8px !important;
    }
    
    .market-light-content .card {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Gauge container responsive */
    .gauge-container {
        max-width: 260px !important;
        margin: 0 auto !important;
    }
    
    .gauge-score-number {
        font-size: 40px !important;
    }
    
    .gauge-status-badge {
        padding: 8px 16px !important;
        font-size: 14px !important;
    }
    
}

/* ═══════════════════════════════════════════════════════════════════════════
   SMALL PHONES (< 375px)
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 374px) {
    :root {
        --mobile-spacing: 12px;
    }
    
    .mobile-portfolio-value {
        font-size: 32px;
    }
    
    .portfolio-summary {
        grid-template-columns: 1fr;
    }
    
    .stock-metrics {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .timeframe-btn {
        padding: 8px 14px;
        font-size: 13px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   LANDSCAPE PHONE
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) and (orientation: landscape) {
    :root {
        --mobile-nav-height: 52px;
        --mobile-header-height: 48px;
    }
    
    .mobile-portfolio-value {
        font-size: 28px;
    }
    
    .chart-container {
        min-height: 200px;
        max-height: 350px !important; /* Prevent infinite growth on small screens */
    }
    
    .portfolio-summary {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   DARK MODE FINE-TUNING
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) and (prefers-color-scheme: dark) {
    .panel,
    .card {
        box-shadow: 0 1px 3px rgba(0,0,0,0.4);
    }
    
    .mobile-bottom-nav {
        background: rgba(22, 27, 34, 0.95);
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   iOS SAFE AREAS
   ═══════════════════════════════════════════════════════════════════════════ */

@supports (padding: max(0px)) {
    @media (max-width: 768px) {
        .mobile-bottom-nav {
            padding-bottom: max(var(--safe-area-bottom), 8px);
        }
        
        .terminal-main,
        .main-content {
            padding-bottom: calc(var(--mobile-nav-height) + max(var(--safe-area-bottom), 34px) + 60px);
        }
        
        .panel-workspace {
            padding-bottom: calc(var(--mobile-nav-height) + max(var(--safe-area-bottom), 34px) + 40px) !important;
        }
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   AUTH PAGE MOBILE FIX - Ensure visibility on all mobile devices
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .auth-page .form-group label {
        color: #f1f5f9 !important;
    }
    
    .auth-page .form-group input {
        background: #0f172a !important;
        border: 1px solid #334155 !important;
        color: #f1f5f9 !important;
    }
    
    .auth-page .btn-primary {
        background: #3b82f6 !important;
        color: white !important;
    }
    
    .auth-page h2,
    .auth-page .auth-header h1 {
        color: #f1f5f9 !important;
    }
    
    .auth-page .auth-logo {
        color: #3b82f6 !important;
    }
    
    .auth-page .auth-tagline,
    .auth-page .auth-footer {
        color: #94a3b8 !important;
    }
    
    .auth-page a {
        color: #3b82f6 !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   DATA QUALITY DASHBOARD - Mobile Tab Wrapping
   ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    /* Data Quality tabs - wrap to multiple rows instead of horizontal scroll */
    .dq-tabs {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
        overflow-x: visible !important;
        padding: 12px 0 !important;
    }
    
    .dq-tab {
        flex: 1 1 calc(50% - 4px) !important;  /* Two per row */
        min-width: 140px !important;
        text-align: center !important;
        justify-content: center !important;
        padding: 10px 12px !important;
        font-size: 12px !important;
    }
    
    /* Ensure badges stay inline */
    .dq-tab .badge {
        margin-left: 4px !important;
    }
}

/* Extra small screens - stack tabs vertically */
@media (max-width: 480px) {
    .dq-tabs {
        flex-direction: column !important;
    }
    
    .dq-tab {
        flex: 1 1 100% !important;
        width: 100% !important;
        min-width: unset !important;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE TOOLTIPS - Touch-friendly tooltip system
   ═══════════════════════════════════════════════════════════════════════════ */

/* Elements with tooltips get visual indicator on touch devices */
@media (pointer: coarse), (hover: none) {
    .has-mobile-tooltip {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Subtle indicator that element is tappable */
    .has-mobile-tooltip::after {
        content: '';
        position: absolute;
        bottom: -2px;
        left: 0;
        right: 0;
        height: 1px;
        background: currentColor;
        opacity: 0.2;
        pointer-events: none;
    }
    
    /* Only add indicator to inline elements */
    span.has-mobile-tooltip,
    abbr.has-mobile-tooltip,
    .help-icon.has-mobile-tooltip {
        position: relative;
        text-decoration-style: dotted;
        text-decoration-line: underline;
        text-decoration-color: currentColor;
        text-decoration-thickness: 1px;
        text-underline-offset: 2px;
    }
    
    span.has-mobile-tooltip::after,
    abbr.has-mobile-tooltip::after,
    .help-icon.has-mobile-tooltip::after {
        display: none;
    }
}

/* Mobile tooltip popup */
.mobile-tooltip {
    position: fixed;
    z-index: 10000;
    background: var(--bg-tooltip, #1e293b);
    color: var(--text-tooltip, #f8fafc);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    max-width: min(90vw, 320px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.1);
    word-wrap: break-word;
    pointer-events: auto;
    
    /* Animation */
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.mobile-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.mobile-tooltip.hiding {
    opacity: 0;
    transform: translateY(-4px);
}

/* Arrow indicator - when above element */
.mobile-tooltip:not(.tooltip-below):not(.tooltip-fixed)::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--bg-tooltip, #1e293b);
}

/* Arrow indicator - when below element */
.mobile-tooltip.tooltip-below::after {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid var(--bg-tooltip, #1e293b);
}

/* Fixed bottom position (no arrow) */
.mobile-tooltip.tooltip-fixed::after {
    display: none;
}

/* Light theme support */
@media (prefers-color-scheme: light) {
    .mobile-tooltip {
        background: #1e293b;
        color: #f8fafc;
    }
    
    .mobile-tooltip:not(.tooltip-below):not(.tooltip-fixed)::after {
        border-top-color: #1e293b;
    }
    
    .mobile-tooltip.tooltip-below::after {
        border-bottom-color: #1e293b;
    }
}

/* Force dark tooltip regardless of theme for better visibility */
body.light-theme .mobile-tooltip,
body[data-theme="light"] .mobile-tooltip {
    background: #1e293b;
    color: #f8fafc;
}

body.light-theme .mobile-tooltip:not(.tooltip-below):not(.tooltip-fixed)::after,
body[data-theme="light"] .mobile-tooltip:not(.tooltip-below):not(.tooltip-fixed)::after {
    border-top-color: #1e293b;
}

body.light-theme .mobile-tooltip.tooltip-below::after,
body[data-theme="light"] .mobile-tooltip.tooltip-below::after {
    border-bottom-color: #1e293b;
}

/* ─────────────────────────────────────────────────────────────────────
   MARKET LIGHT - Block Scores Mobile Fix
   Fix: Progress bars and values were being cut off at screen edge
   ───────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    /* Container padding to prevent edge cutoff */
    .market-light-content {
        padding: 0 8px;
        box-sizing: border-box;
    }

    .market-light-content .card {
        padding: 16px !important;
        box-sizing: border-box;
        overflow: visible;
    }

    /* Block score rows - flex layout with constrained widths */
    .market-light-content .space-y-4 > div {
        width: 100%;
        box-sizing: border-box;
    }

    .market-light-content .space-y-4 .flex.justify-between {
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        width: 100%;
        align-items: flex-start;
    }

    /* Score label - truncate long text */
    .market-light-content .space-y-4 .text-secondary {
        flex: 1;
        min-width: 0;
        font-size: 0.8rem;
        line-height: 1.3;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Score value - fixed width, no shrink */
    .market-light-content .space-y-4 .font-mono {
        flex: 0 0 auto;
        min-width: 36px;
        text-align: right;
        font-size: 0.9rem;
    }

    /* Score bar wrapper - constrained width */
    .market-light-content .score-bar-wrapper {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Legend - wrap on mobile */
    .market-light-content .border-t .flex.justify-between {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px 16px;
        text-align: center;
    }

    .market-light-content .border-t .flex.justify-between > span {
        white-space: nowrap;
        font-size: 0.75rem;
    }
}

/* Extra small screens (< 480px) */
@media (max-width: 480px) {
    .market-light-content .space-y-4 .text-secondary {
        font-size: 0.75rem;
    }
    
    .market-light-content .space-y-4 .font-mono {
        font-size: 0.85rem;
        min-width: 32px;
    }
    
    .market-light-content .border-t .flex.justify-between > span {
        font-size: 0.7rem;
    }
}

/* ─────────────────────────────────────────────────────────────────────
   MARKET LIGHT - JONTE Tables Mobile Fix
   Fix: Table columns cut off on mobile viewport (SIGNAL column etc.)
   Solution: Horizontal scroll + compact styling
   Added: 2026-09-02
   ───────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    /* JONTE Table Container - Horizontal scroll wrapper */
    .jonte-table-container {
        overflow-x: auto;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        margin: 0 -8px;
        padding: 0 8px;
        scroll-snap-type: x proximity;
    }
    
    /* Hide scrollbar but keep functionality */
    .jonte-table-container::-webkit-scrollbar {
        height: 4px;
    }
    
    .jonte-table-container::-webkit-scrollbar-track {
        background: rgba(0, 0, 0, 0.05);
        border-radius: 2px;
    }
    
    .jonte-table-container::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.2);
        border-radius: 2px;
    }
    
    /* JONTE Table - Prevent wrapping */
    .jonte-table {
        min-width: 420px;
        width: 100%;
        border-collapse: collapse;
    }
    
    /* Card containers for index tables need horizontal scroll */
    .market-light-content .grid > .card {
        overflow: visible;
    }
    
    /* Table wrapper with horizontal scroll */
    .market-light-content .card > table,
    .market-light-content .overflow-x-auto > table {
        min-width: 100%;
    }
    
    /* Make all JONTE tables scroll horizontally */
    .market-light-content .card:has(table) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Or wrap tables in scrollable container */
    .market-light-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    
    .market-light-content table thead,
    .market-light-content table tbody {
        display: table;
        width: 100%;
        table-layout: auto;
    }
    
    /* Compact table styling */
    .market-light-content table th,
    .market-light-content table td {
        padding: 6px 4px !important;
        font-size: 0.75rem !important;
        white-space: nowrap;
    }
    
    /* Header row - smaller text */
    .market-light-content table thead tr th {
        font-size: 0.65rem !important;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.3px;
    }
    
    /* Ticker column - keep prominent */
    .market-light-content table td:nth-child(2) a {
        font-size: 0.8rem !important;
        font-weight: 700 !important;
    }
    
    /* Name column - truncate with ellipsis */
    .market-light-content table td:nth-child(3) {
        max-width: 80px !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Score and Delta columns - compact */
    .market-light-content table td:nth-child(4),
    .market-light-content table td:nth-child(5) {
        font-size: 0.7rem !important;
    }
    
    /* Signal column - make badges compact */
    .market-light-content table td:nth-child(6) {
        font-size: 0.65rem !important;
        padding: 4px 2px !important;
    }
    
    .market-light-content table td:nth-child(6) a,
    .market-light-content table td:last-child a {
        font-size: 0.65rem !important;
        white-space: nowrap;
    }
    
    /* Score comparison tooltips - position better on mobile */
    .market-light-content .score-comparison {
        display: inline-flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 2px;
    }
    
    .market-light-content .score-comparison-value {
        font-size: 0.55rem !important;
        padding: 1px 3px !important;
    }
    
    /* Score tooltip wrapper - adjust for mobile */
    .market-light-content .score-tooltip-wrapper .score-tooltip {
        min-width: 150px;
        font-size: 0.7rem;
    }
    
    /* Decision matrix table - also needs mobile fix */
    .market-light-content .decision-matrix {
        font-size: 0.7rem !important;
    }
    
    .market-light-content .decision-matrix th,
    .market-light-content .decision-matrix td {
        padding: 6px 3px !important;
        font-size: 0.65rem !important;
    }
    
    /* Excluded stocks notice - compact */
    .market-light-content .border-t.pt-2 {
        font-size: 0.65rem !important;
    }
    
    /* Index card headers - more compact */
    .market-light-content h3.flex.items-center {
        font-size: 0.95rem !important;
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .market-light-content h3 .text-2xl {
        font-size: 1.25rem !important;
        margin-right: 4px !important;
    }
    
    .market-light-content h3 .text-sm {
        display: none; /* Hide "Swedish Large Cap" etc. on mobile */
    }
}

/* Extra small screens (< 480px) - even more compact */
@media (max-width: 480px) {
    /* Hide delta column on very small screens */
    .market-light-content table th:nth-child(5),
    .market-light-content table td:nth-child(5) {
        display: none !important;
    }
    
    /* Even smaller text */
    .market-light-content table th,
    .market-light-content table td {
        padding: 4px 3px !important;
        font-size: 0.68rem !important;
    }
    
    /* Name column - even shorter */
    .market-light-content table td:nth-child(3) {
        max-width: 60px !important;
    }
    
    /* Hide comparison scores on very small screens */
    .market-light-content .score-comparison-value {
        display: none !important;
    }
    
    /* Decision matrix - abbreviate headers */
    .market-light-content .decision-matrix th:nth-child(2)::after { content: "80+"; }
    .market-light-content .decision-matrix th:nth-child(3)::after { content: "70s"; }
    .market-light-content .decision-matrix th:nth-child(4)::after { content: "60s"; }
    .market-light-content .decision-matrix th:nth-child(5)::after { content: "<60"; }
}

/* ─────────────────────────────────────────────────────────────────────
   MARKET LIGHT - MA200 Breakout Signals Mobile Fix
   Fix: Price values cut off on right side on mobile
   Solution: Flex layout with truncating name, fixed date/price
   Added: 2026-09-02
   ───────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    /* MA200 Breakout card containers */
    .market-light-content .rounded-lg[style*="positive"],
    .market-light-content .rounded-lg[style*="negative"] {
        padding: 12px !important;
    }
    
    /* Header styling */
    .market-light-content .rounded-lg h3 {
        font-size: 0.95rem !important;
        margin-bottom: 10px !important;
    }
    
    .market-light-content .rounded-lg h3 .text-sm {
        display: none; /* Hide "(buy signals)" etc. on mobile */
    }
    
    /* Breakout row - flex container with proper spacing */
    .market-light-content .rounded-lg .space-y-2 > div {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 8px 0 !important;
        gap: 8px !important;
        flex-wrap: nowrap !important;
    }
    
    /* Left section: Ticker + Name */
    .market-light-content .rounded-lg .space-y-2 > div > div:first-child {
        flex: 1 1 auto !important;
        min-width: 0 !important; /* Allow shrinking */
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        overflow: hidden !important;
    }
    
    /* Ticker - keep prominent, no shrink */
    .market-light-content .rounded-lg .space-y-2 > div > div:first-child a {
        flex: 0 0 auto !important;
        font-size: 0.85rem !important;
        font-weight: 700 !important;
    }
    
    /* Stock name - truncate with ellipsis */
    .market-light-content .rounded-lg .space-y-2 > div > div:first-child span {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        font-size: 0.75rem !important;
        margin-left: 4px !important;
    }
    
    /* Right section: Date + Price - no shrink */
    .market-light-content .rounded-lg .space-y-2 > div > div:last-child {
        flex: 0 0 auto !important;
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        white-space: nowrap !important;
        font-size: 0.8rem !important;
    }
    
    /* Date styling */
    .market-light-content .rounded-lg .space-y-2 > div > div:last-child span:first-child {
        font-size: 0.7rem !important;
    }
    
    /* Price styling - keep visible */
    .market-light-content .rounded-lg .space-y-2 > div > div:last-child span:last-child {
        font-size: 0.8rem !important;
        font-weight: 600 !important;
        min-width: 50px !important;
        text-align: right !important;
    }
    
    /* Breakout info text at bottom */
    .market-light-content .rounded-lg + p,
    .market-light-content > p.text-xs {
        font-size: 0.65rem !important;
        line-height: 1.4 !important;
    }
}

/* Extra small screens (< 480px) - stack layout */
@media (max-width: 480px) {
    /* Breakout rows - stack on very small screens */
    .market-light-content .rounded-lg .space-y-2 > div {
        flex-wrap: wrap !important;
        padding: 6px 0 !important;
    }
    
    /* Left section: full width on first row */
    .market-light-content .rounded-lg .space-y-2 > div > div:first-child {
        flex: 1 0 100% !important;
        margin-bottom: 2px !important;
    }
    
    /* Right section: align right on second row */
    .market-light-content .rounded-lg .space-y-2 > div > div:last-child {
        flex: 1 0 100% !important;
        justify-content: flex-end !important;
    }
    
    /* Stock name - allow more space when stacked */
    .market-light-content .rounded-lg .space-y-2 > div > div:first-child span {
        max-width: none !important;
    }
}

/* ─────────────────────────────────────────────────────────────────────
   MARKET LIGHT - MA200 Breakout Signals Mobile Fix
   Fix: Prices cut off on right side of breakout lists
   Added: 2026-09-02
   ───────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    /* MA200 Breakout section - card padding */
    .market-light-content .card:has(.space-y-2) {
        padding: 12px !important;
    }
    
    /* Breakout list items - flex row with truncation */
    .market-light-content .space-y-2 > .flex.justify-between {
        gap: 8px;
        flex-wrap: nowrap;
        padding-bottom: 8px !important;
    }
    
    /* Left side - ticker and name */
    .market-light-content .space-y-2 > .flex.justify-between > div:first-child {
        flex: 1;
        min-width: 0; /* Allow truncation */
        display: flex;
        align-items: center;
        gap: 6px;
    }
    
    /* Ticker - keep visible */
    .market-light-content .space-y-2 > .flex.justify-between > div:first-child a {
        flex-shrink: 0;
        font-size: 0.8rem !important;
    }
    
    /* Company name - truncate */
    .market-light-content .space-y-2 > .flex.justify-between > div:first-child span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.7rem !important;
        margin-left: 4px !important;
    }
    
    /* Right side - date and price - never shrink */
    .market-light-content .space-y-2 > .flex.justify-between > div:last-child {
        flex-shrink: 0;
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 0.75rem !important;
    }
    
    /* Price value - ensure visible */
    .market-light-content .space-y-2 > .flex.justify-between > div:last-child span:last-child {
        font-weight: 600;
        min-width: 50px;
        text-align: right;
    }
    
    /* Breakout section headers */
    .market-light-content .rounded-lg h3 {
        font-size: 0.9rem !important;
        flex-wrap: wrap;
    }
    
    .market-light-content .rounded-lg h3 span {
        display: none; /* Hide "(buy signals)" etc. on mobile */
    }
}

/* Extra small screens - stack layout */
@media (max-width: 400px) {
    /* Stack breakout items vertically */
    .market-light-content .space-y-2 > .flex.justify-between {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 4px;
    }
    
    /* Left side - full width */
    .market-light-content .space-y-2 > .flex.justify-between > div:first-child {
        width: 100%;
    }
    
    /* Right side - align right, full width */
    .market-light-content .space-y-2 > .flex.justify-between > div:last-child {
        width: 100%;
        justify-content: flex-end;
        font-size: 0.7rem !important;
    }
}

/* ─────────────────────────────────────────────────────────────────────
   MARKET LIGHT - About JONTE Info Box Mobile Fix
   Fix: "About JONTE Market Light" section text cut off at right edge
   Issue: Bullet points and tooltips extend past mobile viewport
   Solution: Constrain box width, reduce list padding, wrap text
   Added: 2026-09-02
   ───────────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    /* About section card - constrain to viewport */
    .market-light-content .card:has(.prose) {
        padding: 15px !important;
        margin: 10px 0 !important;
        box-sizing: border-box !important;
        max-width: 100% !important;
        overflow: visible !important;
    }
    
    /* Prose container - prevent overflow */
    .market-light-content .prose {
        max-width: 100% !important;
        padding: 0 !important;
        box-sizing: border-box !important;
        overflow-wrap: break-word !important;
        word-wrap: break-word !important;
        word-break: break-word !important;
        hyphens: auto !important;
    }
    
    /* Bullet lists - reduce left padding to fit mobile */
    .market-light-content .prose ul,
    .market-light-content .prose ol,
    .market-light-content .list-disc,
    .market-light-content .list-inside {
        padding-left: 20px !important;
        margin: 8px 0 !important;
        list-style-position: outside !important;
    }
    
    /* List items - proper wrapping and spacing */
    .market-light-content .prose li,
    .market-light-content .list-disc li {
        margin-bottom: 10px !important;
        line-height: 1.5 !important;
        padding-left: 4px !important;
        overflow-wrap: break-word !important;
        word-wrap: break-word !important;
    }
    
    /* Paragraphs in prose - proper spacing */
    .market-light-content .prose p {
        margin: 10px 0 !important;
        line-height: 1.6 !important;
        overflow-wrap: break-word !important;
    }
    
    /* Strong text - ensure it wraps */
    .market-light-content .prose strong {
        display: inline !important;
    }
    
    /* Tooltips within prose - prevent overflow */
    .market-light-content .prose .tip {
        display: inline !important;
        word-break: normal !important;
    }
    
    /* Tooltip popup - constrain width on mobile */
    .market-light-content .prose .tip::after {
        max-width: calc(100vw - 60px) !important;
        width: auto !important;
        white-space: normal !important;
        left: auto !important;
        right: -10px !important;
        transform: none !important;
    }
    
    /* About section header */
    .market-light-content .card:has(.prose) h2 {
        font-size: 1rem !important;
        margin-bottom: 12px !important;
    }
}

/* Extra small screens (< 480px) - more compact */
@media (max-width: 480px) {
    .market-light-content .card:has(.prose) {
        padding: 12px !important;
        margin: 8px 0 !important;
    }
    
    .market-light-content .prose {
        font-size: 0.8rem !important;
    }
    
    .market-light-content .prose ul,
    .market-light-content .prose ol {
        padding-left: 16px !important;
    }
    
    .market-light-content .prose li {
        margin-bottom: 8px !important;
        line-height: 1.45 !important;
    }
    
    /* Smaller font for list items */
    .market-light-content .prose li {
        font-size: 0.78rem !important;
    }
    
    /* Header even smaller */
    .market-light-content .card:has(.prose) h2 {
        font-size: 0.9rem !important;
    }
}
