/* ==================== MOBILE RESPONSIVE ==================== */

/* Mobile Header - thin, auto-hide on scroll */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 44px;
    background: #1F1F1B;
    border-bottom: 1px solid #2a2a2a;
    z-index: 1100;
    align-items: center;
    padding: 0 12px;
    transition: transform 0.3s ease;
}

.mobile-header.hidden {
    transform: translateY(-100%);
}

.mobile-toggle-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 6px;
}

.mobile-toggle-btn:active {
    background: #2a2a2a;
}

.mobile-session-title {
    margin-left: 12px;
    color: #888;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* Mobile sidebar overlay */
.mobile-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10050;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-sidebar-overlay.show {
    opacity: 1;
}

@media (max-width: 768px) {
    /* Show mobile header */
    .mobile-header {
        display: flex;
    }

    /* Mobile sidebar overlay */
    .mobile-sidebar-overlay {
        display: block;
        pointer-events: none;
    }

    .mobile-sidebar-overlay.show {
        pointer-events: auto;
    }

    /* Hide sidebar by default, show as drawer */
    .sidebar {
        transform: translateX(-100%);
        width: 280px !important;
        z-index: 10100;
        top: 44px !important;
        height: calc(100% - 44px) !important;
        transition: transform 0.3s ease;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    /* Hide desktop sidebar toggle on mobile */
    .sidebar .sidebar-close {
        display: none !important;
    }

    /* Sidebar expanded look when open */
    .sidebar.mobile-open .sidebar-menu {
        display: flex !important;
        flex-direction: column !important;
        padding-top: 20px !important;
    }

    .sidebar.mobile-open .menu-item {
        display: flex !important;
        flex-direction: row !important;
        width: 100% !important;
    }

    .sidebar.mobile-open .menu-item span:not(.menu-icon) {
        display: inline !important;
    }

    .sidebar.mobile-open .recent-sessions {
        display: block !important;
    }

    .sidebar.mobile-open .user-profile {
        display: flex !important;
        opacity: 1 !important;
    }

    .sidebar.mobile-open .settings-menu {
        left: 16px;
        bottom: 70px;
    }

    /* Main content adjustments */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding-top: 44px; /* Height of mobile header */
    }

    /* Chat area mobile styles */
    .chat-container {
        padding: 12px !important;
        padding-bottom: 140px !important; /* Space for fixed input */
    }

    .message {
        max-width: 100% !important;
        margin: 8px 0;
    }

    /* AI messages - avatar on top, full width content */
    .message.ai-message {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    /* Move action buttons to left on mobile */
    .ai-message-actions {
        justify-content: flex-start !important;
    }

    .message.ai-message .message-avatar {
        width: 28px;
        height: 28px;
    }

    .message.ai-message .message-content {
        width: 100%;
        max-width: 100%;
    }

    /* User messages stay compact on the right */
    .message.user-message .message-content {
        max-width: 85%;
    }

    .message-content {
        padding: 12px 16px;
    }

    /* Input container - remove padding on mobile */
    .input-container {
        padding: 0 !important;
    }

    /* Chat input fixed at bottom */
    .input-wrapper {
        position: fixed !important;
        bottom: 8px;
        left: 8px;
        right: 8px;
        max-width: calc(100% - 16px) !important;
        width: calc(100% - 16px) !important;
        margin: 0 !important;
        border-radius: 12px !important;
        border: 1px solid #2a2a2a !important;
        z-index: 100;
        box-sizing: border-box !important;
        margin-bottom: env(safe-area-inset-bottom);
    }

    .chat-input {
        max-height: 120px !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 6px 12px 6px 12px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .input-actions {
        padding: 6px 12px;
    }

    /* Hide alerts panel on mobile chat */
    .alerts-panel {
        display: none !important;
    }

    /* Welcome screen mobile */
    .welcome-container {
        padding: 20px !important;
    }

    .welcome-container h1 {
        font-size: 24px !important;
    }

    /* Welcome logo smaller on mobile */
    .welcome-logo {
        max-width: 180px !important;
    }

    /* Tables in messages - compact for mobile */
    .message-content table {
        font-size: 10px !important;
        width: 100% !important;
        table-layout: fixed;
    }

    .message-content table th,
    .message-content table td {
        padding: 4px 3px !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Code blocks scroll */
    .message-content pre {
        overflow-x: auto;
        max-width: 100%;
        font-size: 11px !important;
    }

    .message-content code {
        font-size: 11px !important;
    }

    .quick-actions {
        left: 0 !important;
        right: 0 !important;
        bottom: 100px !important;
        padding: 0 16px !important;
    }

    .quick-action-btn {
        width: 100% !important;
    }

    /* Chat navigation buttons - positioned above fixed input */
    .chat-nav-buttons {
        right: 12px !important;
        bottom: 90px !important; /* Above the fixed input wrapper */
        gap: 6px;
    }

    .chat-nav-btn {
        width: 36px;
        height: 36px;
    }

    /* Portfolio and other overlays */
    .portfolio-overlay,
    .stocks-layout,
    .etfs-layout,
    .commodities-layout,
    .forex-layout,
    .news-layout,
    .market-outlook-container,
    .watchlist-layout {
        left: 0 !important;
        width: 100% !important;
        padding-top: 56px;
    }

    /* ===== Institutional 13F — mobile ===== */
    .institutional-overlay {
        left: 0 !important;
        width: 100% !important;
        top: 44px !important;
        padding: 12px;
        padding-top: 12px;
        z-index: 1050;
    }
    .institutional-container {
        max-width: 100%;
    }
    .institutional-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .institutional-header h2 { font-size: 18px; }
    .institutional-header .header-right {
        width: 100%;
        justify-content: flex-start;
    }
    .insights-grid {
        grid-template-columns: 1fr;
    }
    .pattern-section h2 { font-size: 15px; padding: 12px 14px; }
    .pattern-section .pattern-desc { font-size: 12px; padding: 8px 14px; }
    .inst-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-height: none;
    }
    .inst-table {
        font-size: 12px;
        min-width: 800px;
    }
    .inst-table th { padding: 8px 6px; font-size: 11px; }
    .inst-table td { padding: 8px 6px; }
    /* Sticky first column (#) — narrow */
    .inst-table th:first-child,
    .inst-table td:first-child {
        position: sticky;
        left: 0;
        background: #1a1a1a;
        z-index: 4;
        width: 28px;
        min-width: 28px;
        max-width: 28px;
        text-align: center;
        padding-left: 4px !important;
        padding-right: 4px !important;
    }
    .inst-table thead th:first-child {
        background: #222;
        z-index: 5;
    }
    /* Sticky second column (Ticker) */
    .inst-table th:nth-child(2),
    .inst-table td:nth-child(2) {
        position: sticky;
        left: 28px;
        background: #1a1a1a;
        z-index: 4;
        min-width: 60px;
        box-shadow: 3px 0 6px rgba(0,0,0,0.5);
    }
    .inst-table thead th:nth-child(2) {
        background: #222;
        z-index: 5;
    }
    #pattern1Section > div:first-child {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start !important;
    }
    /* Independent scroll wrapper per table */
    .inst-table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    /* Sector & Industry tables: fit on screen, no forced min-width */
    #sectorTable .inst-table {
        min-width: unset !important;
        width: 100%;
        table-layout: fixed;
    }
    #sectorTable .inst-table th:first-child,
    #sectorTable .inst-table td:first-child {
        position: static;
        left: auto;
        width: 30%;
        min-width: unset;
        max-width: unset;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        box-shadow: none;
        text-align: left;
        padding-left: 8px !important;
        padding-right: 6px !important;
    }
    #sectorTable .inst-table th:nth-child(2),
    #sectorTable .inst-table td:nth-child(2) {
        position: static;
        left: auto;
        min-width: unset;
        box-shadow: none;
    }
    /* Industry tables inside sector grid */
    .sector-industry-grid .inst-table {
        min-width: unset !important;
        width: 100%;
        table-layout: fixed;
    }
    .sector-industry-grid .inst-table th:first-child,
    .sector-industry-grid .inst-table td:first-child {
        width: 55%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    /* Sector section: disable parent scroll, each table scrolls independently */
    #sectorTable.inst-table-wrapper {
        overflow-x: visible;
    }
    /* Industry grid: 1 column on mobile */
    .sector-industry-grid {
        grid-template-columns: 1fr !important;
    }

    /* ===== Fund Reports — mobile ===== */
    .fund-reports-overlay {
        left: 0 !important;
        width: 100% !important;
        top: 44px !important;
        padding: 12px;
        padding-top: 12px;
        z-index: 1050;
    }
    .fund-reports-container {
        max-width: 100%;
    }
    .fund-reports-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .fund-reports-header h2 { font-size: 18px; }
    .fund-reports-header .header-right {
        width: 100%;
        flex-wrap: wrap;
        gap: 8px;
    }
    .fund-selector {
        min-width: unset !important;
        width: 100%;
        font-size: 13px;
    }
    .fr-stats-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .fr-stat-item {
        min-width: unset;
        padding: 10px 12px;
    }
    .fr-stat-item .fr-stat-icon { width: 24px; height: 24px; font-size: 14px; }
    .fr-stat-item div:last-child span:first-child { font-size: 15px; }
    .fr-stat-label { font-size: 10px; }
    .fr-deriv-stats {
        grid-template-columns: 1fr 1fr;
    }
    .fr-card-body {
        padding: 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .fr-table {
        font-size: 12px;
    }
    .fr-table th, .fr-table td {
        padding: 8px 6px;
        white-space: nowrap;
    }
    /* Sticky first column */
    .fr-table th:first-child,
    .fr-table td:first-child {
        position: sticky;
        left: 0;
        background: #1a1a1a;
        z-index: 4;
        box-shadow: 3px 0 6px rgba(0,0,0,0.5);
    }
    .fr-table thead th:first-child {
        background: #222;
        z-index: 5;
    }
    .fr-help-tooltip {
        position: fixed !important;
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-width: none !important;
        z-index: 9999;
    }
    .fr-card-header { padding: 10px 12px; }
    .fr-card-title { font-size: 14px; }

    /* ===== DCF Scanner — mobile ===== */
    .scanner-overlay {
        left: 0 !important;
        width: 100% !important;
        padding: 12px;
        padding-top: 56px;
        z-index: 1050;
    }
    .scanner-container { max-width: 100%; }
    .scanner-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .scanner-header h2 { font-size: 18px; }
    .scanner-tabs { flex-wrap: wrap; }
    .scanner-tab { padding: 8px 14px; font-size: 13px; }
    .scanner-disconnects-table { font-size: 12px; min-width: 700px; }
    .scanner-disconnects-table th { padding: 8px 6px; font-size: 10px; }
    .scanner-disconnects-table td { padding: 8px 6px; }
    .scanner-article { padding: 16px; }
    .scanner-article .article-body { font-size: 14px; }
    /* ============ PORTFOLIO MOBILE ============ */

    .portfolio-overlay {
        top: 44px !important;
        height: calc(100dvh - 44px) !important;
        left: 0 !important;
        width: 100% !important;
        padding-top: 0 !important;
        padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    }

    .portfolio-fullscreen-container {
        overflow-y: auto;
        overflow-x: hidden;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    }

    /* Compact header */
    .portfolio-header {
        padding: 8px 10px !important;
        position: sticky;
        top: 0;
        z-index: 100;
        background: #1a1a1a !important;
        flex-shrink: 0;
        border-bottom: 1px solid rgba(255,255,255,0.06);
    }

    .portfolio-header-content {
        gap: 6px;
    }

    .portfolio-header-left {
        gap: 6px !important;
        flex: 1;
        min-width: 0;
    }

    /* Back button: icon only */
    .portfolio-back-btn {
        padding: 6px 8px !important;
        font-size: 0 !important;
        min-width: 32px;
    }
    .portfolio-back-btn svg {
        width: 18px;
        height: 18px;
    }

    .portfolio-title {
        font-size: 14px !important;
        min-width: 0;
        overflow: hidden;
    }

    .portfolio-name {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100px;
    }

    .portfolio-avatar {
        width: 26px !important;
        height: 26px !important;
        min-width: 26px;
        font-size: 12px !important;
    }

    .portfolio-header-right {
        gap: 4px !important;
    }

    /* Manage button: icon only */
    .portfolio-manage-btn {
        padding: 6px 8px !important;
        font-size: 0 !important;
        min-width: 32px;
    }

    /* Add Asset / Add Cash buttons: compact */
    .portfolio-add-position-btn {
        padding: 6px 8px !important;
        font-size: 11px !important;
    }

    /* Content: single column, scroll from top */
    .portfolio-content-wrapper {
        flex-direction: column !important;
        padding: 10px !important;
        gap: 12px;
        justify-content: flex-start !important;
        overflow-y: auto !important;
        height: auto !important;
    }

    .portfolio-sidebar {
        flex: none !important;
        width: 100% !important;
        margin-right: 0 !important;
        order: 1;
    }

    .portfolio-main {
        flex: none !important;
        width: 100% !important;
        order: 2;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* Summary card compact */
    .portfolio-summary-card {
        padding: 14px !important;
    }

    .summary-balance {
        font-size: 24px !important;
    }

    /* Risk summary card */
    .risk-summary-card {
        padding: 14px !important;
    }

    /* Risk dashboard compact */
    .risk-dashboard-layout {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .risk-dashboard-container {
        padding: 12px !important;
    }

    /* Allocation chart */
    .portfolio-allocation-card {
        padding: 14px !important;
    }

    /* Assets table: sticky first column + horizontal scroll */
    .assets-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 10px;
    }

    .table-header,
    .asset-row {
        grid-template-columns: 120px 70px 75px 80px 65px 85px 85px !important;
        padding: 10px 12px !important;
        width: max-content;
        min-width: 100%;
    }

    /* Sticky Asset column */
    .table-header .asset-col,
    .asset-row .asset-info {
        position: sticky;
        left: 0;
        z-index: 2;
        background: #1a1a1a;
    }

    .asset-row:hover .asset-info {
        background: #222;
    }

    /* Compact fonts for table */
    .table-col {
        font-size: 10px !important;
        letter-spacing: 0.3px !important;
    }

    .asset-info {
        gap: 8px !important;
    }

    .asset-icon {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        flex-shrink: 0 !important;
        font-size: 12px !important;
    }

    .asset-symbol {
        font-size: 11px !important;
    }

    .asset-name {
        font-size: 9px !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 70px;
    }

    .asset-row > div:not(.asset-info) {
        font-size: 12px !important;
    }

    /* Dropdown position fix */
    /* Portfolio dropdown — оставляем дефолтное поведение на мобильном */

    /* ============ POSITION DETAIL MOBILE ============ */

    /* Hide sidebar cards when position detail is open */
    .portfolio-overlay.position-detail-open .portfolio-sidebar {
        display: none !important;
    }

    /* Position detail takes full width */
    .portfolio-overlay.position-detail-open .portfolio-main {
        width: 100% !important;
    }

    /* Single column layout — only when position detail is open */
    .position-detail-open .position-detail-view {
        display: flex !important;
        flex-direction: column;
        gap: 10px;
        padding: 0 12px;
    }

    .position-detail-open .position-content,
    .position-detail-open .position-details-row {
        display: contents !important;
    }

    /* Reorder: header(0) → balance(1) → chart(2) → news(3) → transactions(4) */
    .position-detail-open .position-header {
        order: 0;
        margin: 0 -12px;
        padding: 10px 12px !important;
    }
    .position-detail-open .position-details {
        order: 1;
        width: 100% !important;
        flex: none !important;
    }
    .position-detail-open .position-chart-section {
        order: 2;
        width: 100% !important;
        padding: 0 !important;
    }
    .position-detail-open .position-news {
        order: 3;
        width: 100% !important;
        height: auto !important;
        max-height: 300px;
        border-radius: 10px;
    }
    .position-detail-open .position-transactions {
        order: 4;
        width: 100% !important;
        background: #1a1a1a;
        border: 1px solid #2a2a2a;
        border-radius: 10px;
        overflow: hidden;
        margin: 0 !important;
    }

    /* Transactions header: stack title + search vertically */
    .position-detail-open .transactions-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px;
        padding: 14px 14px 10px;
    }

    .position-detail-open .transactions-header h3 {
        font-size: 14px !important;
        margin: 0;
        text-align: left;
    }

    .position-detail-open .transactions-search {
        width: 100%;
    }

    .position-detail-open .transactions-search .search-input {
        width: 100% !important;
        font-size: 12px !important;
        padding: 8px 12px !important;
        box-sizing: border-box;
        border-radius: 8px;
        background: #111;
        border: 1px solid #333;
        color: #fff;
    }

    /* Transactions table horizontal scroll */
    .position-detail-open .transactions-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0 0 14px;
    }

    .position-detail-open .transactions-header-row,
    .position-detail-open .transaction-row {
        min-width: 550px;
    }

    .position-detail-open .transaction-col {
        font-size: 11px !important;
        padding: 8px 6px !important;
    }

    .position-detail-open .transactions-header-row .transaction-col {
        font-size: 10px !important;
        color: #888;
    }

    /* Sticky date column */
    .position-detail-open .transaction-col.date-col {
        position: sticky;
        left: 0;
        z-index: 2;
        background: #1a1a1a;
    }

    .position-detail-open .transaction-row:hover .date-col {
        background: #222;
    }

    /* Compact position header */
    .position-header {
        padding: 10px 12px !important;
        gap: 8px;
        flex-wrap: wrap;
    }

    .back-button {
        font-size: 0 !important;
        padding: 6px 8px !important;
        min-width: 32px;
    }
    .back-button svg { width: 18px; height: 18px; }

    .edit-asset-btn {
        font-size: 0 !important;
        padding: 6px 8px !important;
        min-width: 32px;
    }
    .edit-asset-btn svg { width: 18px; height: 18px; }

    .add-transaction-btn {
        font-size: 12px !important;
        padding: 6px 10px !important;
    }
    .add-transaction-btn svg { width: 16px; height: 16px; }

    .position-actions {
        gap: 6px !important;
    }

    /* Balance card: merge both into one card */
    .position-detail-open .position-card-wrapper {
        margin: 0;
        padding: 0;
        background: #1a1a1a;
        border: 1px solid #2a2a2a;
        border-radius: 10px;
        overflow: hidden;
    }

    .position-detail-open .position-balance-card {
        padding: 14px 14px 10px !important;
        border-radius: 0 !important;
        border: none !important;
        border-bottom: 1px solid #2a2a2a !important;
    }

    .position-detail-open .position-metrics {
        padding: 10px 14px 14px !important;
        border: none !important;
        background: transparent !important;
    }

    .position-balance-card h3 {
        font-size: 14px !important;
    }

    .balance-main span:first-child {
        font-size: 22px !important;
    }

    .position-metrics {
        gap: 6px !important;
    }

    .position-metrics .metric-row {
        padding: 4px 0 !important;
    }

    .position-metrics .metric-label {
        font-size: 12px !important;
    }

    .position-metrics .metric-value {
        font-size: 12px !important;
    }

    /* Chart mobile (same pattern as stock-detail) */
    .position-detail-open .portfolio-chart-container {
        min-height: unset !important;
        padding: 14px !important;
        margin: 0;
        border-radius: 10px;
    }

    .portfolio-chart {
        height: auto !important;
        display: block !important;
    }

    .portfolio-chart svg {
        display: block;
        width: 100%;
        height: auto;
    }

    .portfolio-chart-header {
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 12px !important;
    }

    .portfolio-chart-current-price {
        font-size: 18px !important;
    }

    .portfolio-chart-timeframes {
        flex-wrap: wrap;
        gap: 4px;
    }

    .portfolio-timeframe-btn {
        padding: 4px 8px !important;
        font-size: 11px !important;
    }

    /* News section compact */
    .position-detail-open .position-news {
        margin: 0;
        border-radius: 10px;
    }

    .position-news-header h3 {
        font-size: 14px !important;
    }

    /* Transactions compact */
    .position-detail-open .position-transactions {
        padding: 0 !important;
        overflow: hidden;
    }

    .transactions-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .transactions-header-row,
    .transactions-table .transaction-row {
        min-width: 500px;
    }

    .transaction-col {
        font-size: 11px !important;
    }

    .transactions-header h3 {
        font-size: 14px !important;
    }

    .transactions-search .search-input {
        font-size: 12px !important;
        padding: 6px 10px !important;
    }

    /* Modals on mobile */
    .modal-content,
    .transaction-modal .modal-content,
    .support-modal {
        width: 95% !important;
        max-width: 100% !important;
        margin: 10px;
        max-height: 90vh;
    }

    /* Settings menu on mobile */
    .settings-menu {
        position: fixed !important;
        bottom: auto !important;
        top: 56px !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        border-radius: 0 !important;
        max-height: calc(100vh - 56px);
    }

    /* User avatar & TG: hide by default on mobile */
    .user-avatar {
        display: none !important;
    }
    .tg-link-btn { display: none !important; }

    /* Mobile sidebar: scrollable menu + fixed bottom */
    .sidebar.mobile-open .sidebar-menu {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }

    .sidebar.mobile-open .chat-list {
        flex-shrink: 1;
        overflow-y: auto;
        min-height: 0;
    }

    .sidebar.mobile-open .tg-link-btn {
        display: flex !important;
        position: static;
        margin: 8px 16px 0;
        flex-shrink: 0;
    }

    .sidebar.mobile-open .user-avatar {
        display: flex !important;
        position: static;
        margin: 8px 16px 12px;
        width: calc(100% - 32px);
        flex-shrink: 0;
    }

    /* ============ NEWS MOBILE ============ */
    .news-layout {
        padding: 10px !important;
        padding-top: 50px !important;
    }

    .news-header {
        margin-bottom: 10px !important;
    }

    .news-header .news-title {
        font-size: 22px !important;
        font-weight: 700;
    }

    .news-subtitle {
        font-size: 12px !important;
    }

    .news-filters {
        gap: 6px !important;
        margin-bottom: 10px !important;
    }

    .news-filter {
        padding: 6px 12px !important;
        font-size: 12px !important;
    }

    .news-grid {
        grid-template-columns: 1fr !important;
        gap: 0 !important;
    }

    /* Hide images on mobile — text-only like SeekingAlpha */
    .news-card-image {
        display: none !important;
    }

    .news-card,
    .news-card.featured,
    .news-card.wide,
    .news-card.large {
        padding: 12px 0 !important;
        border-radius: 0 !important;
        border: none !important;
        border-bottom: 1px solid #2a2a2a !important;
        background: transparent !important;
        height: auto !important;
        min-height: unset !important;
    }

    .news-card-content {
        padding: 0 !important;
    }

    .news-card-title {
        font-size: 15px !important;
        font-weight: 600;
        line-height: 1.3;
        margin-bottom: 4px;
    }

    .news-card-excerpt {
        font-size: 13px !important;
        color: #999;
        line-height: 1.4;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .news-card-meta {
        margin-top: 6px !important;
        font-size: 11px !important;
    }

    /* ============ MARKET OVERVIEW MOBILE ============ */
    .market-charts-overview .market-cards-grid {
        grid-template-columns: 1fr 1fr !important;
    }

    .market-overview-container {
        padding: 12px !important;
        padding-top: 50px !important;
    }

    .market-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px;
    }

    .market-header h1 {
        font-size: 22px !important;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .header-actions button {
        padding: 6px 12px !important;
        font-size: 12px !important;
    }

    /* All grids to single column */
    .indices-sectors-grid,
    .sectors-grid,
    .movers-grid,
    .metrics-grid,
    .key-info-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    .section {
        padding: 15px !important;
    }

    .section h2 {
        font-size: 18px !important;
    }

    /* Tables - compact for mobile */
    .data-table {
        font-size: 11px !important;
        width: 100% !important;
        table-layout: fixed;
    }

    .data-table th,
    .data-table td {
        padding: 5px 3px !important;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .data-table th {
        font-size: 10px !important;
    }

    /* Movers */
    .mover-item {
        padding: 6px 10px !important;
    }

    /* Sentiment badges wrap */
    .sentiment-badges {
        flex-wrap: wrap;
    }

    .badge {
        font-size: 11px !important;
        padding: 4px 8px !important;
    }

    .summary {
        font-size: 14px !important;
    }

    /* News items */
    .news-title {
        font-size: 14px !important;
    }

    /* Footer */
    .market-footer {
        font-size: 12px !important;
    }

    /* ============ STOCKS PAGE MOBILE ============ */

    /*
     * Layout structure for mobile:
     * - stocks-layout: fixed full height container
     * - stocks-container: flex column, fills available space
     * - stocks-header: fixed height, can collapse
     * - stocks-table-wrapper: scrollable area (ONLY scroll container)
     */

    .stocks-layout {
        min-width: unset !important;
        padding: 54px 10px 10px 10px !important; /* Top padding for fixed header (44px + 10px) */
        height: 100vh;
        height: 100dvh; /* Dynamic viewport for iOS */
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .stocks-container {
        padding: 0 10px !important;
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    /* Header - 2 rows layout, collapses smoothly when hidden */
    .stocks-header {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 0;
        background: #121212;
        flex-shrink: 0;
        max-height: 100px;
        overflow: hidden;
        transition: max-height 0.25s ease-out, padding 0.25s ease-out, opacity 0.2s ease-out;
    }

    .stocks-header.header-hidden {
        max-height: 0;
        padding: 0;
        opacity: 0;
        pointer-events: none;
    }

    /* Table wrapper - smooth height transition */
    .stocks-table-wrapper {
        transition: max-height 0.25s ease-out;
    }

    /* When header is hidden, expand table wrapper */
    .stocks-container:has(.stocks-header.header-hidden) .stocks-table-wrapper {
        max-height: calc(100vh - 80px);
        max-height: calc(100dvh - 80px);
    }

    /* Row 1: [US ▼] [Search...] [⚙️] - same height 34px */
    .market-selector-container {
        order: 1;
        flex-shrink: 0;
    }

    .market-selector-btn {
        height: 34px;
        padding: 0 10px;
        font-size: 13px;
        display: flex;
        align-items: center;
    }

    .stocks-search-input {
        order: 2;
        flex: 1;
        min-width: 80px;
        height: 34px;
        padding: 0 10px !important;
        font-size: 14px !important;
    }

    .stocks-filter-btn {
        order: 3;
        flex-shrink: 0;
        height: 34px;
        padding: 0 10px !important;
        margin-left: 0 !important;
        font-size: 13px;
    }

    /* Row 2: Index filter buttons - same height 32px */
    .index-filter-container {
        order: 4;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .index-filter-container::-webkit-scrollbar {
        display: none;
    }

    .index-filter-btn {
        white-space: nowrap;
        flex-shrink: 0;
        height: 32px;
        padding: 0 12px;
        font-size: 13px;
    }

    /* Table wrapper - THE scroll container for both X and Y */
    .stocks-table-wrapper {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        max-height: calc(100vh - 180px);
        max-height: calc(100dvh - 180px);
    }

    .stocks-table {
        border-collapse: separate;
        border-spacing: 0;
        min-width: 600px;
    }

    /* Sticky table header */
    .stocks-table thead th {
        position: sticky;
        top: 0;
        background: #1a1a1a;
        z-index: 5;
    }

    /* FIRST COLUMNS: sticky left */
    .stocks-table th.star-col,
    .stocks-table td.star-col {
        position: sticky;
        left: 0;
        background: #121212;
        z-index: 2;
        min-width: 36px;
        width: 36px;
    }

    .stocks-table th.asset-col,
    .stocks-table td.asset-col {
        position: sticky;
        left: 36px;
        background: #121212;
        z-index: 2;
        min-width: 130px;
        box-shadow: 3px 0 6px rgba(0,0,0,0.5);
    }

    /* CORNER CELLS: sticky both directions - highest z-index */
    .stocks-table thead th.star-col {
        position: sticky;
        top: 0;
        left: 0;
        z-index: 6;
        background: #1a1a1a;
    }

    .stocks-table thead th.asset-col {
        position: sticky;
        top: 0;
        left: 36px;
        z-index: 6;
        background: #1a1a1a;
        box-shadow: 3px 0 6px rgba(0,0,0,0.5);
    }

    /* Row hover - update sticky cell backgrounds */
    .stocks-table tr:hover td.star-col,
    .stocks-table tr:hover td.asset-col {
        background: #1a1a1a;
    }

    /* Compact cells */
    .stocks-table th,
    .stocks-table td {
        padding: 12px 8px;
        font-size: 13px;
    }

    /* Asset column compact */
    .stock-asset {
        gap: 8px;
    }

    .stock-logo {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px;
    }

    .stock-details .stock-ticker {
        font-size: 13px;
    }

    .stock-details .stock-company {
        font-size: 11px;
        max-width: 90px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Hide exchange badge on mobile */
    .exchange-badge {
        display: none !important;
    }

    /* Price column */
    .stocks-table td.price-col {
        white-space: nowrap;
    }

    /* Sparkline column - compact height for mobile */
    .stocks-table td.chart-col {
        min-width: 70px;
        width: 70px;
        padding: 2px 4px !important;
    }

    .stocks-table td.chart-col svg {
        width: 60px;
        height: 24px;
    }

    /* Filter modal - fullscreen */
    .stocks-filter-modal {
        align-items: stretch !important;
    }

    .filter-modal-content {
        width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    .filter-modal-header {
        position: sticky;
        top: 0;
        background: #1a1a1a;
        z-index: 10;
        border-radius: 0;
    }

    .filter-modal-body {
        padding: 15px;
        padding-bottom: 80px; /* Space for footer */
    }

    .filter-modal-footer {
        position: fixed !important;
        bottom: 0;
        left: 0;
        right: 0;
        background: #1a1a1a;
        padding: 12px 20px !important;
        border-top: 1px solid #333;
        z-index: 10;
    }

    /* Filter chips compact */
    .filter-chips {
        gap: 6px;
    }

    .filter-chip {
        padding: 6px 10px;
        font-size: 12px;
    }

    /* Hide scroll buttons on mobile - not needed with touch */
    .table-scroll-buttons {
        display: none !important;
    }

    /* Pagination - sticky left so it doesn't scroll horizontally */
    .stocks-pagination {
        flex-direction: column;
        gap: 8px;
        padding: 10px;
        position: sticky;
        left: 0;
        width: 100vw;
        max-width: 100%;
        background: #121212;
    }

    .pagination-controls {
        justify-content: center;
        flex-wrap: wrap;
    }

    .page-btn {
        min-width: 36px;
        height: 36px;
        font-size: 13px;
    }

    #stocksCount {
        font-size: 12px;
        text-align: center;
    }

    /* ============ ETF PAGE MOBILE ============ */

    /*
     * Layout structure for mobile:
     * - etfs-layout: fixed full height container
     * - etfs-container: flex column, fills available space
     * - etfs-header: fixed height, can collapse
     * - etfs-table-wrapper: scrollable area (ONLY scroll container)
     */

    .etfs-layout {
        min-width: unset !important;
        padding: 54px 10px 10px 10px !important; /* Top padding for fixed header (44px + 10px) */
        height: 100vh;
        height: 100dvh; /* Dynamic viewport for iOS */
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .etfs-container {
        padding: 0 10px !important;
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    /* Header - collapses smoothly when hidden */
    .etfs-header {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 0;
        background: #121212;
        flex-shrink: 0;
        max-height: 80px;
        overflow: hidden;
        transition: max-height 0.25s ease-out, padding 0.25s ease-out, opacity 0.2s ease-out;
    }

    .etfs-header.header-hidden {
        max-height: 0;
        padding: 0;
        opacity: 0;
        pointer-events: none;
    }

    /* Table wrapper - smooth height transition */
    .etfs-table-wrapper {
        transition: max-height 0.25s ease-out;
    }

    /* When header is hidden, expand table wrapper */
    .etfs-container:has(.etfs-header.header-hidden) .etfs-table-wrapper {
        max-height: calc(100vh - 80px);
        max-height: calc(100dvh - 80px);
    }

    /* Header layout: [Title] [Search...] [Filter] */
    .etfs-title {
        display: none !important; /* Hide title on mobile */
    }

    .etfs-controls {
        display: flex;
        flex: 1;
        gap: 8px;
        width: 100%;
    }

    .etfs-search-input {
        flex: 1;
        min-width: 80px;
        height: 34px;
        padding: 0 10px !important;
        font-size: 14px !important;
    }

    .etfs-filter-btn {
        flex-shrink: 0;
        height: 34px;
        padding: 0 10px !important;
        font-size: 13px;
    }

    /* Table wrapper - THE scroll container for both X and Y */
    .etfs-table-wrapper {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        max-height: calc(100vh - 140px);
        max-height: calc(100dvh - 140px);
    }

    .etfs-table {
        border-collapse: separate;
        border-spacing: 0;
        min-width: 550px;
    }

    /* Sticky table header */
    .etfs-table thead th {
        position: sticky;
        top: 0;
        background: #1a1a1a;
        z-index: 5;
    }

    /* FIRST COLUMNS: sticky left */
    .etfs-table th.star-col,
    .etfs-table td.star-col {
        position: sticky;
        left: 0;
        background: #121212;
        z-index: 2;
        min-width: 36px;
        width: 36px;
    }

    .etfs-table th.asset-col,
    .etfs-table td.asset-col {
        position: sticky;
        left: 36px;
        background: #121212;
        z-index: 2;
        min-width: 130px;
        box-shadow: 3px 0 6px rgba(0,0,0,0.5);
    }

    /* CORNER CELLS: sticky both directions - highest z-index */
    .etfs-table thead th.star-col {
        position: sticky;
        top: 0;
        left: 0;
        z-index: 6;
        background: #1a1a1a;
    }

    .etfs-table thead th.asset-col {
        position: sticky;
        top: 0;
        left: 36px;
        z-index: 6;
        background: #1a1a1a;
        box-shadow: 3px 0 6px rgba(0,0,0,0.5);
    }

    /* Row hover - update sticky cell backgrounds */
    .etfs-table tr:hover td.star-col,
    .etfs-table tr:hover td.asset-col {
        background: #1a1a1a;
    }

    /* Compact cells */
    .etfs-table th,
    .etfs-table td {
        padding: 12px 8px;
        font-size: 13px;
    }

    /* Hide scroll buttons on mobile - not needed with touch */
    #etfsScrollButtons {
        display: none !important;
    }

    /* Pagination - sticky left so it doesn't scroll horizontally */
    .etfs-pagination {
        flex-direction: column;
        gap: 8px;
        padding: 10px;
        position: sticky;
        left: 0;
        width: 100vw;
        max-width: 100%;
        background: #121212;
    }

    #etfsPaginationControls {
        justify-content: center;
        flex-wrap: wrap;
    }

    #etfsCount {
        font-size: 12px;
        text-align: center;
    }

    /* Commodities & Forex mobile */
    .commodities-layout,
    .forex-layout {
        min-width: unset !important;
        padding: 54px 10px 10px 10px !important;
        height: 100vh;
        height: 100dvh;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .commodities-container,
    .forex-container {
        padding: 0 10px !important;
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    .commodities-header,
    .forex-header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 0;
        flex-shrink: 0;
    }

    .commodities-title,
    .forex-title {
        font-size: 20px !important;
        width: 100%;
    }

    .commodities-category-tabs,
    .forex-category-tabs {
        flex-wrap: wrap;
        gap: 4px;
    }

    .category-tab {
        padding: 4px 10px;
        font-size: 12px;
    }

    .commodities-table-wrapper,
    .forex-table-wrapper {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        max-height: calc(100vh - 180px);
        max-height: calc(100dvh - 180px);
    }

    .commodities-table,
    .forex-table {
        min-width: 500px;
    }

    /* Header sticky top */
    .commodities-table thead th,
    .forex-table thead th {
        position: sticky;
        top: 0;
        background: #1a1a1a;
        z-index: 5;
    }

    /* Star column: sticky left */
    .commodities-table th.star-col,
    .commodities-table td.star-col,
    .forex-table th.star-col,
    .forex-table td.star-col {
        position: sticky;
        left: 0;
        background: #121212;
        z-index: 2;
        min-width: 36px;
        width: 36px;
    }

    /* Asset column: sticky left (after star) */
    .commodities-table th.asset-col,
    .commodities-table td.asset-col,
    .forex-table th.asset-col,
    .forex-table td.asset-col {
        position: sticky;
        left: 36px;
        background: #121212;
        z-index: 2;
        min-width: 130px;
        box-shadow: 3px 0 6px rgba(0,0,0,0.5);
    }

    /* Corner cells: sticky both directions */
    .commodities-table thead th.star-col,
    .forex-table thead th.star-col {
        position: sticky;
        top: 0;
        left: 0;
        z-index: 6;
        background: #1a1a1a;
    }

    .commodities-table thead th.asset-col,
    .forex-table thead th.asset-col {
        position: sticky;
        top: 0;
        left: 36px;
        z-index: 6;
        background: #1a1a1a;
        box-shadow: 3px 0 6px rgba(0,0,0,0.5);
    }

    /* Row hover */
    .commodities-table tr:hover td.star-col,
    .commodities-table tr:hover td.asset-col,
    .forex-table tr:hover td.star-col,
    .forex-table tr:hover td.asset-col {
        background: #1a1a1a;
    }

    /* ============ WATCHLIST MOBILE ============ */

    .watchlist-section {
        padding: 54px 10px 10px 10px !important;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
    }

    .watchlist-container {
        padding: 0 !important;
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        overflow: hidden;
    }

    .watchlist-header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 0 !important;
        flex-shrink: 0;
    }

    .watchlist-header h2 {
        font-size: 18px !important;
    }

    .watchlist-add-btn {
        padding: 6px 10px !important;
        font-size: 12px !important;
    }

    .watchlist-sort-btn {
        padding: 6px 10px !important;
        font-size: 12px !important;
    }

    .watchlist-sort-label {
        font-size: 11px !important;
    }

    /* Table scrollable */
    .watchlist-table-wrapper {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        flex: 1;
        min-height: 0;
    }

    .watchlist-table {
        min-width: 600px;
    }

    .watchlist-table th {
        font-size: 10px !important;
        padding: 10px 8px !important;
    }

    .watchlist-table td {
        font-size: 12px !important;
        padding: 10px 8px !important;
    }

    /* Header sticky top */
    .watchlist-table thead th {
        position: sticky;
        top: 0;
        background: #252522;
        z-index: 5;
    }

    /* Star column: sticky left */
    .watchlist-table th:nth-child(1),
    .watchlist-table td:nth-child(1) {
        position: sticky;
        left: 0;
        background: #252522;
        z-index: 2;
        min-width: 32px;
        width: 32px;
    }

    /* Asset column: sticky left */
    .watchlist-table th:nth-child(2),
    .watchlist-table td:nth-child(2) {
        position: sticky;
        left: 32px;
        background: #252522;
        z-index: 2;
        min-width: 120px;
        box-shadow: 3px 0 6px rgba(0,0,0,0.5);
    }

    /* Corner cells */
    .watchlist-table thead th:nth-child(1) {
        z-index: 6;
    }

    .watchlist-table thead th:nth-child(2) {
        z-index: 6;
        box-shadow: 3px 0 6px rgba(0,0,0,0.5);
    }

    /* Row hover sticky cells */
    .watchlist-table tbody tr:hover td:nth-child(1),
    .watchlist-table tbody tr:hover td:nth-child(2) {
        background: #2a2a2a;
    }

    /* Compact asset cell */
    .watchlist-logo {
        width: 26px !important;
        height: 26px !important;
        min-width: 26px !important;
    }

    .watchlist-ticker {
        font-size: 12px !important;
    }

    .watchlist-company {
        font-size: 10px !important;
        max-width: 70px;
    }

    .watchlist-target-input {
        width: 70px !important;
        font-size: 12px !important;
        padding: 4px 6px !important;
    }

    /* Sort dropdown */
    .watchlist-sort-dropdown {
        right: 0;
        min-width: 100px;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .mobile-header {
        padding: 0 8px;
    }

    .chat-container {
        padding-bottom: 140px !important;
    }

    .input-wrapper {
        padding: 8px !important;
    }

    .chat-input {
        padding: 6px 12px !important;
    }

    .message-content {
        font-size: 14px;
    }

    /* ============ STOCKS PAGE EXTRA SMALL ============ */
    .stocks-layout {
        padding: 5px !important;
    }

    .stocks-container {
        padding: 0 5px !important;
        border-radius: 8px;
    }

    .stocks-header {
        gap: 8px;
        padding-top: 8px;
    }

    .stocks-search-input {
        padding: 6px 12px !important;
    }

    .stocks-filter-btn {
        padding: 6px 10px !important;
    }

    .index-filter-btn {
        padding: 5px 10px;
        font-size: 11px;
    }

    .stocks-table th,
    .stocks-table td {
        padding: 10px 6px;
        font-size: 12px;
    }

    .stocks-table th.star-col,
    .stocks-table td.star-col {
        min-width: 32px;
        width: 32px;
    }

    .stocks-table th.asset-col,
    .stocks-table td.asset-col {
        left: 32px;
        min-width: 110px;
    }

    .stocks-table thead th.asset-col {
        left: 32px;
    }

    .stock-logo {
        width: 24px !important;
        height: 24px !important;
        min-width: 24px;
    }

    .stock-details .stock-ticker {
        font-size: 12px;
    }

    .stock-details .stock-company {
        font-size: 10px;
        max-width: 75px;
    }

    .watchlist-star {
        font-size: 16px;
    }

    .page-btn {
        min-width: 32px;
        height: 32px;
        font-size: 12px;
    }

    /* Commodities & Forex: smaller sticky columns */
    .commodities-table th.star-col,
    .commodities-table td.star-col,
    .forex-table th.star-col,
    .forex-table td.star-col {
        min-width: 32px;
        width: 32px;
    }

    .commodities-table th.asset-col,
    .commodities-table td.asset-col,
    .forex-table th.asset-col,
    .forex-table td.asset-col {
        left: 32px;
        min-width: 110px;
    }

    .commodities-table thead th.asset-col,
    .forex-table thead th.asset-col {
        left: 32px;
    }

    /* ============ ETF PAGE EXTRA SMALL ============ */
    .etfs-layout {
        padding: 5px !important;
    }

    .etfs-container {
        padding: 0 5px !important;
        border-radius: 8px;
    }

    .etfs-header {
        gap: 8px;
        padding-top: 8px;
    }

    .etfs-search-input {
        padding: 6px 12px !important;
    }

    .etfs-filter-btn {
        padding: 6px 10px !important;
    }

    .etfs-table th,
    .etfs-table td {
        padding: 10px 6px;
        font-size: 12px;
    }

    .etfs-table th.star-col,
    .etfs-table td.star-col {
        min-width: 32px;
        width: 32px;
    }

    .etfs-table th.asset-col,
    .etfs-table td.asset-col {
        left: 32px;
        min-width: 110px;
    }

    .etfs-table thead th.asset-col {
        left: 32px;
    }
}
/* ==================== END MOBILE RESPONSIVE ==================== */
