/* ========================================
   Market Summary Cards & Category Headers
   ======================================== */

.market-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.market-summary-card {
    background: var(--card-bg);
    border-radius: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    position: relative;
}

.market-summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    opacity: 0.8;
    transition: all 0.3s;
}

.market-summary-card.crypto-summary::before {
    background: linear-gradient(90deg, #f59e0b, #fb923c);
}

.market-summary-card.stocks-summary::before {
    background: linear-gradient(90deg, #059669, #10b981);
}

.market-summary-card.commodities-summary::before {
    background: linear-gradient(90deg, #8b5cf6, #a78bfa);
}

.market-summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.15));
}

.market-summary-card:hover::before {
    height: 5px;
}

.summary-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px;
    cursor: pointer;
    user-select: none;
}

.summary-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s;
}

.crypto-summary .summary-icon {
    background: linear-gradient(135deg, #f59e0b 0%, #fb923c 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.3);
}

.stocks-summary .summary-icon {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(5, 150, 105, 0.3);
}

.commodities-summary .summary-icon {
    background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
    color: white;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
}

.summary-icon i {
    width: 26px;
    height: 26px;
}

.summary-info {
    flex: 1;
}

.summary-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.summary-count {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin: 0;
}

.summary-toggle {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.summary-toggle:hover {
    background: var(--bg-tertiary);
    transform: scale(1.1);
}

.summary-toggle i {
    width: 20px;
    height: 20px;
    transition: transform 0.3s;
}

.summary-toggle[aria-expanded="true"] i {
    transform: rotate(180deg);
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 16px;
    padding: 0 24px 24px 24px;
    border-top: 1px solid var(--border-color);
    margin-top: -1px;
    padding-top: 20px;
}

.summary-stat {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.summary-stat .stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.summary-stat .stat-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.summary-stat .stat-value.positive {
    color: #059669;
}

.summary-stat .stat-value.negative {
    color: #dc2626;
}

/* Market Category Headers */
.market-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
    margin: 40px 0 24px 0;
    border-bottom: 2px solid var(--border-color);
}

.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    color: white;
    box-shadow: var(--shadow-md);
}

.category-badge.crypto {
    background: linear-gradient(135deg, #f59e0b 0%, #fb923c 100%);
}

.category-badge.stocks {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
}

.category-badge.commodities {
    background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%);
}

.category-badge i {
    width: 20px;
    height: 20px;
}

.category-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

.update-time {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 8px 14px;
    background: var(--bg-secondary);
    border-radius: 10px;
}

.update-time i {
    width: 14px;
    height: 14px;
}

/* Market Section Visibility */
.market-section {
    transition: all 0.4s ease-out;
    max-height: 5000px;
    overflow: hidden;
}

.market-section:not(.active) {
    max-height: 0;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

.market-section.active {
    opacity: 1;
    animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Market Summary */
@media (max-width: 768px) {
    .market-summary-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .summary-header {
        padding: 20px;
    }
    
    .summary-stats {
        grid-template-columns: repeat(2, 1fr);
        padding: 0 20px 20px 20px;
    }
    
    .market-category-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

/* ========================================
   Compact Metrics Table
   ======================================== */

.market-metrics-table {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 24px;
}

.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.metrics-row.single {
    grid-template-columns: 1fr;
}

.metrics-row.stocks-list {
    grid-template-columns: 1fr;
}

.metric-cell {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.metric-cell:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-color);
}

.metric-cell.featured {
    background: linear-gradient(135deg, var(--card-bg), var(--bg-secondary));
}

.metric-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.metric-icon.crypto {
    background: linear-gradient(135deg, #f59e0b, #fb923c);
    color: white;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.metric-icon.stocks {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.metric-icon.commodities {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}

.metric-icon.sentiment {
    background: linear-gradient(135deg, #ec4899, #f472b6);
    color: white;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.25);
}

.metric-icon.volatility {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    color: white;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.metric-icon i {
    width: 22px;
    height: 22px;
}

.metric-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.metric-unit {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 2px;
}

.metric-change {
    font-size: 14px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 8px;
    font-variant-numeric: tabular-nums;
}

.metric-change.positive {
    background: linear-gradient(135deg, rgba(5, 150, 105, 0.15), rgba(16, 185, 129, 0.2));
    color: #059669;
}

.metric-change.negative {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.15), rgba(239, 68, 68, 0.2));
    color: #dc2626;
}

/* Fear & Greed Display */
.fg-display {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 8px;
}

.fg-value {
    font-size: 32px;
    font-weight: 900;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.fg-class {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 6px 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.fg-bar {
    flex: 1;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.fg-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #ef4444 0%, #f59e0b 35%, #eab308 50%, #22c55e 75%, #10b981 100%);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Stocks List */
.stocks-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.stocks-header i {
    width: 20px;
    height: 20px;
    color: #059669;
}

.stocks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.stock-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.stock-item:hover {
    transform: translateX(4px);
    border-color: #059669;
}

.stock-symbol {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 60px;
}

.stock-price {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
    flex: 1;
    text-align: right;
}

.stock-change {
    font-size: 13px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    font-variant-numeric: tabular-nums;
    min-width: 70px;
    text-align: right;
}

.stock-change.positive {
    background: rgba(5, 150, 105, 0.15);
    color: #059669;
}

.stock-change.negative {
    background: rgba(220, 38, 38, 0.15);
    color: #dc2626;
}

/* Responsive Metrics Table */
@media (max-width: 1024px) {
    .metrics-row {
        grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    }
}

@media (max-width: 768px) {
    .metrics-row {
        grid-template-columns: 1fr;
    }

    .metric-cell {
        padding: 16px;
    }

    .metric-value {
        font-size: 20px;
    }

    .fg-display {
        flex-direction: column;
        align-items: flex-start;
    }

    .stocks-grid {
        grid-template-columns: 1fr;
    }

    .heatmap-detail-panel {
        max-height: 70vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {
    .market-metrics-table .metrics-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

/* ========================================
   Premium Stock Market Design
   ======================================== */

/* Performance Banner */
.stock-performance-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--card-bg), var(--bg-secondary));
    border-radius: 16px;
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.performance-indicator {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    border-radius: 12px;
    transition: all 0.3s;
}

.performance-indicator.bullish {
    background: linear-gradient(135deg, rgba(5, 150, 105, 0.15), rgba(16, 185, 129, 0.2));
    border: 2px solid rgba(5, 150, 105, 0.3);
}

.performance-indicator.bearish {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.15), rgba(239, 68, 68, 0.2));
    border: 2px solid rgba(220, 38, 38, 0.3);
}

.performance-indicator.neutral {
    background: linear-gradient(135deg, rgba(100, 116, 139, 0.15), rgba(148, 163, 184, 0.2));
    border: 2px solid rgba(100, 116, 139, 0.3);
}

.indicator-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.bullish .indicator-icon {
    background: linear-gradient(135deg, #059669, #10b981);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.bearish .indicator-icon {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.neutral .indicator-icon {
    background: linear-gradient(135deg, #64748b, #94a3b8);
}

.indicator-icon i {
    width: 20px;
    height: 20px;
}

.indicator-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.indicator-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.indicator-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
}

.performance-stats {
    display: flex;
    gap: 12px;
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.stat-pill i {
    width: 16px;
    height: 16px;
    color: #059669;
}

/* Indices Grid */
.indices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.index-card {
    position: relative;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 16px;
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.index-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.index-card.positive::before {
    background: linear-gradient(90deg, #059669, #10b981);
}

.index-card.negative::before {
    background: linear-gradient(90deg, #dc2626, #ef4444);
}

.index-card.neutral::before {
    background: linear-gradient(90deg, #64748b, #94a3b8);
}

.index-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(99, 102, 241, 0.3);
}

.index-card.major {
    border-width: 2px;
}

.index-card.major::before {
    height: 5px;
}

.index-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.index-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    color: #059669;
}

.index-icon i {
    width: 18px;
    height: 18px;
}

.index-badge {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 4px 10px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.index-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.index-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.index-description {
    font-size: 12px;
    color: var(--text-muted);
}

.index-price {
    font-size: 28px;
    font-weight: 900;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    margin-bottom: 8px;
}

.index-change {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 12px;
}

.index-card.positive .index-change {
    background: rgba(5, 150, 105, 0.15);
    color: #059669;
}

.index-card.negative .index-change {
    background: rgba(220, 38, 38, 0.15);
    color: #dc2626;
}

.index-change i {
    width: 14px;
    height: 14px;
}

.index-sparkline {
    height: 40px;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    align-items: flex-end;
}

.sparkline-bar {
    flex: 1;
    border-radius: 3px;
    transition: all 0.4s;
}

.index-card.positive .sparkline-bar {
    background: linear-gradient(180deg, #10b981, #059669);
}

.index-card.negative .sparkline-bar {
    background: linear-gradient(180deg, #ef4444, #dc2626);
}

.index-card.vix .sparkline-bar {
    background: linear-gradient(180deg, #f59e0b, #d97706);
}

/* VIX Special Styling */
.index-card.vix.high::before {
    background: linear-gradient(90deg, #dc2626, #ef4444);
}

.index-card.vix.medium::before {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.index-card.vix.low::before {
    background: linear-gradient(90deg, #059669, #10b981);
}

.vix-indicator {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
}

.index-card.vix.high .vix-indicator {
    background: rgba(220, 38, 38, 0.15);
    color: #dc2626;
}

.index-card.vix.medium .vix-indicator {
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
}

.index-card.vix.low .vix-indicator {
    background: rgba(5, 150, 105, 0.15);
    color: #059669;
}

/* Premium Stocks Table */
.stocks-table-container {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px;
    border-bottom: 2px solid var(--border-color);
    background: linear-gradient(135deg, var(--card-bg), var(--bg-secondary));
}

.header-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #059669, #10b981);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.header-icon i {
    width: 22px;
    height: 22px;
}

.header-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
}

.header-subtitle {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.view-toggle {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.view-toggle:hover {
    background: var(--bg-secondary);
    border-color: #059669;
    color: #059669;
}

.view-toggle.active {
    background: linear-gradient(135deg, #059669, #10b981);
    border-color: transparent;
    color: white;
}

.view-toggle i,
.view-toggle svg {
    width: 18px;
    height: 18px;
}

.view-toggle svg {
    display: block;
}

.stocks-table {
    display: flex;
    flex-direction: column;
}

.stocks-table.grid-view .table-row {
    display: grid;
    grid-template-columns: 50px 2fr 1fr 1fr 1fr;
}

.stocks-table.list-view .table-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
}

.stocks-table.list-view .table-head {
    display: none;
}

.stocks-table.list-view .stock-row {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 8px;
}

.stocks-table.list-view .stock-row:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.table-row {
    display: grid;
    grid-template-columns: 50px 2fr 1fr 1fr 1fr;
    align-items: center;
    gap: 16px;
    padding: 18px 24px;
    transition: all 0.2s;
}

.table-head {
    background: var(--bg-secondary);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

.stock-row {
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.stock-row:last-child {
    border-bottom: none;
}

.stock-row:hover {
    background: var(--bg-secondary);
    transform: translateX(4px);
}

.col-rank {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    text-align: center;
}

.col-symbol {
    display: flex;
}

.symbol-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.symbol-code {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-primary);
}

.symbol-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.col-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.col-change {
    display: flex;
}

.change-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.change-badge.positive {
    background: rgba(5, 150, 105, 0.15);
    color: #059669;
}

.change-badge.negative {
    background: rgba(220, 38, 38, 0.15);
    color: #dc2626;
}

.change-badge.neutral {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

.change-badge i {
    width: 14px;
    height: 14px;
}

.col-trend {
    display: flex;
    justify-content: flex-end;
}

.mini-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 32px;
}

.chart-bar {
    width: 6px;
    border-radius: 3px 3px 0 0;
    transition: all 0.3s;
}

.chart-bar.positive {
    background: linear-gradient(180deg, #10b981, #059669);
}

.chart-bar.negative {
    background: linear-gradient(180deg, #ef4444, #dc2626);
}

.stock-row:hover .chart-bar {
    opacity: 0.8;
}

/* Responsive Stock Market */
@media (max-width: 1024px) {
    .indices-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .table-row {
        grid-template-columns: 40px 2fr 1fr 1fr 80px;
        gap: 12px;
    }
}

@media (max-width: 768px) {
    .stock-performance-banner {
        flex-direction: column;
        gap: 16px;
    }
    
    .indices-grid {
        grid-template-columns: 1fr;
    }
    
    .table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .table-row {
        grid-template-columns: 30px 2fr 1fr;
        padding: 14px 16px;
    }
    
    .col-change,
    .col-trend {
        display: none;
    }
    
    .table-head .col-change,
    .table-head .col-trend {
        display: none;
    }
}

/* ========================================
   Premium Dashboard Design System with Dark Mode
   ======================================== */

:root {
    /* Gradients */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --danger-gradient: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    
    /* Light Mode Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --border-color: rgba(148, 163, 184, 0.2);
    --card-bg: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.2);
}

/* ========================================
   Dark Mode Theme
   ======================================== */
[data-theme="dark"] {
    /* Dark Mode Colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: rgba(148, 163, 184, 0.2);
    --card-bg: #1e293b;
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    
    /* Enhanced Shadows for Dark Mode */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.8);
}

/* ========================================
   Dashboard Tab Navigation - Premium Style
   ======================================== */
.dashboard-tab-nav {
    position: sticky;
    top: 0;
    z-index: 90;
    margin: -20px -20px 36px -20px;
    padding: 16px 20px 0;
    background: transparent;
}

.dashboard-tab-nav::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(148, 163, 184, 0.2), transparent);
}

.tab-nav-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    max-width: 1400px;
    margin: 0 auto;
    padding-bottom: 8px;
    scrollbar-width: none;
}

.tab-nav-container::-webkit-scrollbar {
    display: none;
}

.tab-nav-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(15, 23, 42, 0.6);
    color: rgba(226, 232, 240, 0.85);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: all 0.25s ease, flex-direction 0.3s ease, gap 0.25s ease, padding 0.25s ease;
    position: relative;
    white-space: nowrap;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
}

.tab-nav-item:hover {
    background: rgba(129, 140, 248, 0.18);
    color: #f8fafc;
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.35);
    border-color: rgba(129, 140, 248, 0.35);
}

.tab-nav-item:active {
    transform: translateY(0);
}

.tab-nav-item:focus-visible {
    outline: 2px solid rgba(129, 140, 248, 0.6);
    outline-offset: 2px;
}

.tab-nav-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: rgba(102, 126, 234, 0.6);
    color: #ffffff;
    box-shadow: 
        0 12px 24px rgba(102, 126, 234, 0.35),
        0 6px 12px rgba(0, 0, 0, 0.15);
}

.tab-nav-item.active .tab-icon,
.tab-nav-item.active .tab-label {
    color: #ffffff;
}

.tab-icon {
    width: 20px;
    height: 20px;
    transition: color 0.25s ease, transform 0.25s ease;
    flex-shrink: 0;
}

.tab-label {
    font-size: 15px;
    transition: color 0.25s ease, font-size 0.25s ease;
}

/* Tab notification badge */
.tab-nav-item .tab-badge {
    position: absolute;
    top: 8px;
    right: 12px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    font-size: 10px;
    font-weight: 700;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
        0 2px 8px rgba(239, 68, 68, 0.5),
        0 0 0 2px rgba(255, 255, 255, 0.3);
    animation: badge-pulse 2s ease-in-out infinite;
    pointer-events: none;
}

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

/* Tab Content */
.tab-content {
    display: none;
    animation: fadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
        filter: blur(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .tab-nav-item,
    .tab-nav-item .tab-badge {
        transition: none !important;
        animation: none !important;
    }
}

/* Responsive Tab Navigation */
@media (max-width: 768px) {
    .dashboard-tab-nav {
        margin: -20px -16px 32px -16px;
        padding: 0 16px;
    }
    
    .tab-nav-container {
        gap: 8px;
    }
    
    .tab-nav-item {
        padding: 12px 18px;
        font-size: 14px;
        gap: 6px;
        min-height: 44px;
    }
    
    .tab-icon {
        width: 18px;
        height: 18px;
    }
    
    .tab-label {
        font-size: 13px;
    }
    
    .tab-nav-item .tab-badge {
        top: 6px;
        right: 8px;
        min-width: 16px;
        height: 16px;
        font-size: 9px;
    }
}

@media (max-width: 480px) {
    .dashboard-tab-nav {
        margin: -20px -12px 24px -12px;
        padding: 0 12px;
    }
    
    .tab-nav-container {
        gap: 6px;
        justify-content: space-between;
    }
    
    .tab-nav-item {
        flex-direction: column !important;
        align-items: center;
        justify-content: center;
        padding: 10px 8px;
        min-height: 44px;
        gap: 4px;
        flex: 1;
        min-width: 0;
    }
    
    .tab-label {
        display: block !important;
        font-size: 11px;
        font-weight: 500;
        letter-spacing: 0.02em;
        line-height: 1.2;
        text-align: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    
    .tab-icon {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
    }
    
    .tab-nav-item .tab-badge {
        top: 4px;
        right: 4px;
        min-width: 14px;
        height: 14px;
        font-size: 8px;
        padding: 0 3px;
    }
    
    .tab-nav-item:hover {
        transform: translateY(-1px);
    }
    
    .tab-nav-item.active {
        box-shadow: 
            0 8px 16px rgba(102, 126, 234, 0.35),
            0 4px 8px rgba(0, 0, 0, 0.15),
            inset 0 0 20px rgba(102, 126, 234, 0.2);
    }
}

/* Very small screens - ensure labels remain visible */
@media (max-width: 360px) {
    .tab-nav-item {
        padding: 8px 6px;
        min-height: 44px;
    }
    
    .tab-label {
        font-size: 10px;
    }
    
    .tab-icon {
        width: 16px;
        height: 16px;
    }
}

/* ========================================
   Premium Section Styles
   ======================================== */
.overview-section {
    padding: 32px;
    border-radius: 24px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: 
        var(--shadow-lg),
        inset 0 1px 0 var(--glass-border);
    position: relative;
    overflow: hidden;
}

.overview-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, 
        rgba(102, 126, 234, 0.8),
        rgba(139, 92, 246, 0.8),
        rgba(168, 85, 247, 0.8)
    );
    border-radius: 24px 24px 0 0;
}

.section-header.enhanced {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 24px;
    padding: 28px 32px;
    margin-bottom: 32px;
    border-radius: 28px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.22), rgba(168, 85, 247, 0.14));
    border: 1px solid rgba(129, 140, 248, 0.35);
    box-shadow: 0 20px 40px rgba(15, 23, 42, 0.35);
    overflow: hidden;
}

.section-header.enhanced::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.28), transparent 60%);
    opacity: 0.6;
    pointer-events: none;
}

.section-header.enhanced > * {
    position: relative;
    z-index: 1;
}

.section-header.enhanced .section-icon {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #c084fc 100%);
    box-shadow: 0 16px 30px rgba(99, 102, 241, 0.35);
    position: relative;
    flex-shrink: 0;
}

.section-header.enhanced .section-icon::after {
    content: '';
    position: absolute;
    inset: 8px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(6px);
}

.section-header.enhanced .section-icon i,
.section-header.enhanced .section-icon svg {
    width: 26px;
    height: 26px;
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 3px 6px rgba(15, 23, 42, 0.35));
}

.section-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.section-subtitle {
    font-size: 15px;
    font-weight: 500;
    color: rgba(226, 232, 240, 0.75);
    letter-spacing: 0.02em;
}

.section-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.section-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(15, 23, 42, 0.55);
    color: rgba(226, 232, 240, 0.9);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.section-tag i,
.section-tag svg {
    width: 14px;
    height: 14px;
}

.section-tag:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(15, 23, 42, 0.25);
}

.section-tag.live {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(16, 185, 129, 0.18));
    border-color: rgba(16, 185, 129, 0.4);
    color: #d1fae5;
}

.section-tag.data {
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.2), rgba(99, 102, 241, 0.16));
    border-color: rgba(99, 102, 241, 0.35);
    color: #e0e7ff;
}

.section-tag.insight {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.22), rgba(250, 204, 21, 0.18));
    border-color: rgba(250, 204, 21, 0.45);
    color: #fef3c7;
}

.section-tag.api {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.22), rgba(37, 99, 235, 0.18));
    border-color: rgba(59, 130, 246, 0.45);
    color: #dbeafe;
}

.section-tag.fallback {
    background: linear-gradient(135deg, rgba(244, 114, 182, 0.22), rgba(236, 72, 153, 0.18));
    border-color: rgba(236, 72, 153, 0.45);
    color: #fce7f3;
}

@media (max-width: 900px) {
    .section-header.enhanced {
        gap: 20px;
        padding: 24px 26px;
    }
}

@media (max-width: 640px) {
    .section-header.enhanced {
        flex-direction: column;
        align-items: flex-start;
        padding: 24px;
    }
    
    .section-header.enhanced .section-icon {
        width: 56px;
        height: 56px;
    }
    
    .section-tags {
        gap: 8px;
    }
}

/* Premium Market Cards */
.grid {
    gap: 20px;
}

.enhanced-card {
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-color) !important;
    box-shadow: 
        var(--shadow-lg),
        0 1px 0 var(--glass-border) inset !important;
}

.enhanced-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: linear-gradient(180deg, var(--glass-bg), transparent 50%);
    pointer-events: none;
}


.enhanced-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 
        var(--shadow-xl),
        0 2px 0 var(--glass-border) inset !important;
}

.enhanced-card:hover::after {
    opacity: 1;
    animation: shimmer 2s linear infinite;
}

@keyframes shimmer {
    to {
        transform: rotate(360deg);
    }
}

/* Card Value Animation */
.card-value {
    font-variant-numeric: tabular-nums;
    transition: all 0.3s;
}

.enhanced-card:hover .card-value {
    transform: scale(1.05);
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    /* Tab navigation styles are handled in the main responsive section above */
    /* Removed duplicate tab-nav-item, tab-label, and tab-icon styles to prevent conflicts */

    .quick-stats-banner {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 16px;
    }

    .quick-stats-banner .stat-item {
        flex-direction: column;
        text-align: center;
        padding: 16px;
    }

    .quick-stats-banner .stat-icon {
        width: 48px;
        height: 48px;
    }

    .quick-stats-banner .stat-value {
        font-size: 18px;
    }
}

@media (max-width: 640px) {
    /* Tab navigation styles are handled in the main responsive section above */
    /* Removed duplicate tab-nav-item styles to prevent conflicts */

    .quick-stats-banner {
        grid-template-columns: 1fr;
    }

    .section-title {
        font-size: 18px;
    }
}

/* ========================================
   Premium Loading & Animation States
   ======================================== */
.analysis-loading-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    color: #10b981;
    font-size: 14px;
}

.loading-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-top: 2px solid #667eea;
    border-right: 2px solid #764ba2;
    border-radius: 50%;
    animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

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

/* Pulse Animation for Live Data */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(0.98);
    }
}

.stat-value[data-live="true"] {
    animation: pulse 2s ease-in-out infinite;
}

/* Gradient Text Animation */
@keyframes gradient-shift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

.animated-gradient-text {
    background: linear-gradient(90deg, #667eea, #764ba2, #667eea);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradient-shift 3s ease infinite;
}

/* Floating Animation for Icons */
@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-4px);
    }
}

.stat-icon {
    animation: float 3s ease-in-out infinite;
}

.stat-item:nth-child(1) .stat-icon {
    animation-delay: 0s;
}

.stat-item:nth-child(2) .stat-icon {
    animation-delay: 0.2s;
}

.stat-item:nth-child(3) .stat-icon {
    animation-delay: 0.4s;
}

.stat-item:nth-child(4) .stat-icon {
    animation-delay: 0.6s;
}

/* Skeleton Loading State */
@keyframes skeleton-loading {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        rgba(226, 232, 240, 0.6) 25%,
        rgba(241, 245, 249, 0.8) 50%,
        rgba(226, 232, 240, 0.6) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 8px;
}

/* Glow Effect on Hover */
.glow-on-hover {
    transition: all 0.3s;
}

.glow-on-hover:hover {
    box-shadow: 
        0 0 20px rgba(102, 126, 234, 0.4),
        0 0 40px rgba(102, 126, 234, 0.2);
}

/* Smooth Number Counter Animation */
@keyframes count-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stat-value.updating {
    animation: count-up 0.4s ease-out;
}

.loading-text {
    font-size: 12px;
    color: #6b7280;
}

/* ========================================
   Premium Background & Container
   ======================================== */
.dashboard-container {
    position: relative;
    background: var(--bg-primary);
    min-height: 100vh;
    transition: background 0.3s ease;
}

/* Light mode background */
:root:not([data-theme="dark"]) .dashboard-container {
    background: 
        radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.03) 0%, transparent 50%),
        linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}

{#/* Dark mode background */#}
{#[data-theme="dark"] .dashboard-container {#}
{#    background: #}
{#        radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.08) 0%, transparent 50%),#}
{#        radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),#}
{#        linear-gradient(180deg, #0f172a 0%, #1e293b 100%);#}
{#}#}

.dashboard-container::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(rgba(102, 126, 234, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(102, 126, 234, 0.02) 1px, transparent 1px);
    background-size: 50px 50px;
    pointer-events: none;
    z-index: 0;
}

/* Dark mode grid */
[data-theme="dark"] .dashboard-container::before {
    background-image: 
        linear-gradient(rgba(102, 126, 234, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(102, 126, 234, 0.06) 1px, transparent 1px);
    opacity: 0.5;
}

/* Smooth Scroll Behavior */
html {
    scroll-behavior: smooth;
}

/* Selection Style */
::selection {
    background: rgba(102, 126, 234, 0.3);
    color: var(--text-primary);
}

[data-theme="dark"] ::selection {
    background: rgba(102, 126, 234, 0.5);
    color: #f1f5f9;
}

/* ========================================
   Enhanced Change Indicators
   ======================================== */
.change-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
    transition: all 0.3s;
}

.change-indicator.positive {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(5, 150, 105, 0.15));
    color: #059669;
    box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.2);
}

.change-indicator.negative {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(220, 38, 38, 0.15));
    color: #dc2626;
    box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.2);
}

.change-indicator.neutral {
    background: rgba(100, 116, 139, 0.1);
    color: #64748b;
    box-shadow: inset 0 0 0 1px rgba(100, 116, 139, 0.2);
}

/* ========================================
   Tooltip Enhancements
   ======================================== */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.95);
    color: white;
    font-size: 12px;
    font-weight: 500;
    border-radius: 8px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(15, 23, 42, 0.95);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
}

[data-tooltip]:hover::after,
[data-tooltip]:hover::before {
    opacity: 1;
}

/* ========================================
   Focus Visible Improvements
   ======================================== */
*:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
    border-radius: 4px;
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 4px;
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .dashboard-tab-nav,
    .quick-stats-banner .stat-icon,
    .section-icon {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}

/* Analysis Status Styles */
.analysis-status-container {
    margin-bottom: 1.5rem;
}

.analysis-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 12px;
    border: 1px solid;
    transition: all 0.3s ease;
}

.analysis-status.success {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border-color: #10b981;
    color: #065f46;
}

.analysis-status.error {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-color: #ef4444;
    color: #991b1b;
}

.analysis-status.warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-color: #f59e0b;
    color: #92400e;
}

.status-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.status-content {
    flex: 1;
}

.status-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.status-message {
    font-size: 13px;
    opacity: 0.9;
    margin-bottom: 8px;
}

.status-actions {
    display: flex;
    gap: 8px;
}

.btn.small {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

.btn.small i {
    width: 14px;
    height: 14px;
}

/* Symbol Analysis Error States */
.symbol-analysis-error {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border: 1px solid #ef4444;
    color: #991b1b;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
}

.symbol-analysis-error .error-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    color: #ef4444;
}

.symbol-analysis-error .error-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.symbol-analysis-error .error-message {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 16px;
}

.symbol-analysis-error .retry-button {
    background: #ef4444;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.symbol-analysis-error .retry-button:hover {
    background: #dc2626;
}

/* No Analysis Available Styles */
.no-analysis-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
    padding: 40px 20px;
}

.no-analysis-message {
    text-align: center;
    max-width: 500px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 1px solid #cbd5e1;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.no-analysis-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    color: #64748b;
}

.no-analysis-title {
    font-size: 20px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 12px;
}

.no-analysis-description {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 24px;
    line-height: 1.6;
}

.no-analysis-description ul {
    text-align: left;
    margin: 12px 0;
    padding-left: 20px;
}

.no-analysis-description li {
    margin-bottom: 4px;
}

.no-analysis-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ========================================
   Heatmap Styles - TradingView Style Design
   ======================================== */

/* Container */
/* Container */
.heatmap-container {
    padding: 0 !important;
    overflow: hidden;
    background: #1e293b;
}

.heatmap-main {
    width: 100%;
    display: flex;
    flex-direction: column;
    background: #1e293b;
    min-height: 0;
    overflow: hidden;
}

/* Header with title and action buttons */
.heatmap-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    background: #1e293b;
}

.heatmap-title {
    font-size: 20px;
    font-weight: 700;
    color: #f8fafc;
    margin: 0;
}

.heatmap-header-actions {
    display: flex;
    gap: 8px;
}

.header-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(30, 41, 59, 0.6);
    color: #cbd5e1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.header-action-btn:hover {
    background: rgba(99, 102, 241, 0.3);
    border-color: rgba(129, 140, 248, 0.4);
    color: #eef2ff;
}

.header-action-btn i {
    width: 16px;
    height: 16px;
}

/* Compact Toolbar */
.heatmap-toolbar-compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    background: #1e293b;
    flex-wrap: wrap;
}

.toolbar-category-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.category-btn {
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(30, 41, 59, 0.6);
    color: #cbd5e1;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.category-btn:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: rgba(129, 140, 248, 0.4);
    color: #eef2ff;
}

.category-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

.toolbar-controls-group {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.control-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.control-item label {
    font-size: 11px;
    color: rgba(203, 213, 225, 0.7);
    font-weight: 500;
}

.control-select {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(30, 41, 59, 0.6);
    color: #f8fafc;
    font-size: 12px;
    cursor: pointer;
    min-width: 100px;
}

.control-select:focus {
    outline: none;
    border-color: #3b82f6;
}

.control-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(30, 41, 59, 0.6);
    color: #cbd5e1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-top: 18px;
}

.control-btn:hover {
    background: rgba(99, 102, 241, 0.3);
    border-color: rgba(129, 140, 248, 0.4);
    color: #eef2ff;
}

.control-btn i {
    width: 16px;
    height: 16px;
}

.toolbar-left {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    flex: 1 1 320px;
    position: relative;
    z-index: 5;
}

.toolbar-center {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 1 auto;
    position: relative;
    z-index: 5;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: flex-end;
    position: relative;
    z-index: 5;
}

.status-group {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* Toolbar Search Box */
.toolbar-search {
    position: relative;
    flex: 0 1 200px;
}

.toolbar-search-input {
    padding: 6px 10px 6px 30px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.6);
    color: #f8fafc;
    font-size: 12px;
    width: 100%;
    transition: all 0.2s ease;
}

.toolbar-search-input::placeholder {
    color: rgba(148, 163, 184, 0.5);
}

.toolbar-search-input:focus {
    outline: none;
    border-color: rgba(129, 140, 248, 0.6);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
    background: rgba(30, 41, 59, 0.8);
}

.toolbar-search-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: rgba(148, 163, 184, 0.5);
    pointer-events: none;
}

/* Main Search Box */
.search-box {
    position: relative;
    flex: 1 1 280px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: rgba(148, 163, 184, 0.7);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 12px 14px 12px 42px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.75);
    color: #f8fafc;
    font-size: 14px;
    transition: all 0.2s ease;
}

.search-input::placeholder {
    color: rgba(148, 163, 184, 0.6);
}

.search-input:focus {
    outline: none;
    border-color: rgba(129, 140, 248, 0.6);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
    background: rgba(30, 41, 59, 0.9);
}

.search-results-badge {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.9), rgba(129, 140, 248, 0.9));
    color: white;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.35);
    pointer-events: none;
}

.badge-count {
    display: inline-block;
}

.sort-dropdown {
    position: relative;
}

.sort-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: rgba(148, 163, 184, 0.7);
    pointer-events: none;
}

.sort-select {
    padding: 12px 16px 12px 40px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.75);
    color: #f8fafc;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    z-index: 2;
}

.sort-select:focus {
    outline: none;
    border-color: rgba(129, 140, 248, 0.6);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.grouping-control {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.grouping-control label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: rgba(148, 163, 184, 0.7);
    letter-spacing: 0.08em;
}

.grouping-select {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(15, 23, 42, 0.75);
    color: #f8fafc;
    font-size: 13px;
    cursor: pointer;
    position: relative;
    z-index: 2;
}

.grouping-select:focus {
    outline: none;
    border-color: rgba(129, 140, 248, 0.6);
}

.range-control {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.range-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: rgba(148, 163, 184, 0.7);
    margin-right: 6px;
}

.range-btn {
    padding: 6px 14px;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: rgba(226, 232, 240, 0.8);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    z-index: 2;
    pointer-events: auto;
}

.range-btn:hover:not(:disabled) {
    background: rgba(99, 102, 241, 0.25);
    color: #eef2ff;
}

.range-btn.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.8), rgba(129, 140, 248, 0.8));
    color: white;
    box-shadow: 0 6px 12px rgba(99, 102, 241, 0.35);
}

.range-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Quick Filters Row */
.heatmap-filters-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
    background: rgba(15, 23, 42, 0.3);
    flex-wrap: wrap;
}

.quick-filters {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.15);
}

.quick-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: transparent;
    color: rgba(226, 232, 240, 0.75);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.quick-filter-chip i {
    width: 14px;
    height: 14px;
}

.quick-filter-chip:hover {
    background: rgba(99, 102, 241, 0.2);
    color: #c7d2fe;
    border-color: rgba(129, 140, 248, 0.3);
}

.quick-filter-chip.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.75), rgba(129, 140, 248, 0.75));
    color: white;
    border-color: rgba(129, 140, 248, 0.6);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.heatmap-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-icon {
    width: 14px;
    height: 14px;
    color: #34d399;
}

.status-text {
    font-size: 12px;
    font-weight: 600;
    color: #22c55e;
}

.heatmap-status[data-state="loading"] {
    background: rgba(59, 130, 246, 0.18);
    border-color: rgba(59, 130, 246, 0.24);
}

.heatmap-status[data-state="loading"] .status-icon {
    color: #60a5fa;
}

.heatmap-status[data-state="loading"] .status-text {
    color: #bfdbfe;
}

.heatmap-status[data-state="error"] {
    background: rgba(248, 113, 113, 0.18);
    border-color: rgba(248, 113, 113, 0.28);
}

.heatmap-status[data-state="error"] .status-icon {
    color: #f87171;
}

.heatmap-status[data-state="error"] .status-text {
    color: #fecaca;
}

.heatmap-status[data-state="fallback"] {
    background: rgba(251, 191, 36, 0.18);
    border-color: rgba(251, 191, 36, 0.28);
}

.heatmap-status[data-state="fallback"] .status-icon {
    color: #f59e0b;
}

.heatmap-status[data-state="fallback"] .status-text {
    color: #fcd34d;
}

.heatmap-status[data-state="empty"] {
    background: rgba(148, 163, 184, 0.18);
    border-color: rgba(148, 163, 184, 0.24);
}

.heatmap-status[data-state="empty"] .status-icon {
    color: rgba(226, 232, 240, 0.75);
}

.heatmap-status[data-state="empty"] .status-text {
    color: rgba(226, 232, 240, 0.75);
}

.refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid rgba(129, 140, 248, 0.3);
    background: rgba(129, 140, 248, 0.12);
    color: #c7d2fe;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-btn:hover {
    border-color: rgba(129, 140, 248, 0.6);
    background: rgba(99, 102, 241, 0.22);
    color: #eef2ff;
}

.refresh-btn i {
    width: 16px;
    height: 16px;
}

.refresh-btn.loading i {
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Stats Summary Bar */
.stats-summary {
    display: flex;
    gap: 16px;
    padding: 10px 20px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    background: rgba(15, 23, 42, 0.4);
    align-items: center;
    flex-wrap: wrap;
}

.stats-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #94a3b8;
}

.stats-value {
    font-weight: 700;
    color: #f1f5f9;
    font-variant-numeric: tabular-nums;
}

.stats-badge {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.stats-badge.green {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.stats-badge.red {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.stats-badge.grey {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
}

/* Stats Row (existing cards) */
.heatmap-stats-row {
    display: grid;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.stat-card {
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 18px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.35);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.12), transparent 55%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover::after {
    opacity: 1;
}

.stat-card.positive::after {
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.18), transparent 55%);
    opacity: 1;
}

.stat-card.negative::after {
    background: linear-gradient(135deg, rgba(248, 113, 113, 0.18), transparent 55%);
    opacity: 1;
}

.stat-card.positive .stat-value {
    color: #34d399;
}

.stat-card.negative .stat-value {
    color: #f87171;
}

.stat-label {
    font-size: 12px;
    font-weight: 600;
    color: rgba(148, 163, 184, 0.75);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.stat-value {
    font-size: 20px;
    font-weight: 800;
    color: #f8fafc;
}

.stat-note {
    font-size: 12px;
    color: rgba(148, 163, 184, 0.7);
}

.stat-pair {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(15, 23, 42, 0.65);
}

.stat-badge.positive {
    color: #4ade80;
}

.stat-badge.negative {
    color: #f87171;
}

/* Gradient Legend Bar */
.heatmap-legend-gradient {
    padding: 12px 20px;
    border-top: 1px solid rgba(148, 163, 184, 0.1);
    background: #1e293b;
}

.legend-gradient-bar {
    position: relative;
    height: 24px;
    background: linear-gradient(to right, #800f2f 0%, #a4161a 16%, #d90429 33%, #495057 50%, #52b788 67%, #40916c 83%, #2d6a4f 100%);
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
}

.legend-mark {
    font-size: 10px;
    color: #1e293b;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

/* Heatmap Grid - Viewport-Locked Finviz Style */
.heatmap-grid {
    padding: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    height: calc(100vh - 280px);
    min-height: 400px;
    max-height: 720px;
    background: #1e293b;
    overflow-y: auto;
    overflow-x: hidden;
    align-content: flex-start;
}

.heatmap-sector {
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 200px;
    max-height: 100%;
    overflow: hidden;
}

.sector-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    background: rgba(15, 23, 42, 0.5);
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    margin-bottom: 2px;
    flex-shrink: 0;
}

.sector-title {
    font-size: 11px;
    font-weight: 600;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sector-title::after {
    content: '';
}

.sector-meta {
    font-size: 10px;
    color: rgba(203, 213, 225, 0.6);
    white-space: nowrap;
}

.sector-change {
    font-weight: 700;
}

.sector-change.positive {
    color: #4ade80;
}

.sector-change.negative {
    color: #f87171;
}

.sector-change.flat {
    color: rgba(203, 213, 225, 0.85);
}

.heatmap-sector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
    grid-auto-rows: minmax(36px, 48px);
    gap: 2px;
    padding: 0;
    flex: 1;
    overflow: hidden;
}

.heatmap-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 3px 2px;
    border-radius: 3px;
    color: #f8fafc;
    cursor: pointer;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.08);
    transition: all 0.15s ease;
    outline: none;
    min-height: 36px;
}

.heatmap-tile:hover,
.heatmap-tile:focus-visible {
    transform: scale(1.04);
    z-index: 10;
    border-color: rgba(148, 163, 184, 0.3);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), inset 0 0 20px rgba(255, 255, 255, 0.1);
}

.heatmap-tile .tile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    width: 100%;
    overflow: hidden;
}

.heatmap-tile .label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    text-align: center;
    line-height: 1.1;
}

.heatmap-tile .tile-price {
    font-size: 9px;
    opacity: 0.85;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    display: none; /* hidden by default, shown on large tiles via JS */
}

/* Show price only on tiles that span multiple rows */
.heatmap-tile[style*="span 2"] .tile-price,
.heatmap-tile[style*="span 3"] .tile-price {
    display: block;
}

.heatmap-tile .change-badge {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.2);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.heatmap-tile .change-badge.positive {
    color: #22c55e;
    background: rgba(34, 197, 94, 0.15);
}

.heatmap-tile .change-badge.negative {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
}

.heatmap-tile .sub {
    font-size: 10px;
    opacity: 0.85;
    margin-top: 2px;
    max-width: 95%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tile-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 10px;
    color: rgba(241, 245, 249, 0.85);
}

.tile-meta span {
    white-space: nowrap;
}

/* Finviz-style Color Scale */
.bg-strong-pos {
    background: #2d6a4f;
}

.bg-pos {
    background: #40916c;
}

.bg-pos-light {
    background: #52b788;
}

.bg-pos-med {
    background: #74c69d;
}

.bg-flat {
    background: #495057;
}

.bg-neg-light {
    background: #e5383b;
}

.bg-neg-med {
    background: #d90429;
}

.bg-neg {
    background: #a4161a;
}

.bg-strong-neg {
    background: #800f2f;
}

/* Loading Skeleton Animation */
.heatmap-skeleton {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
}

.heatmap-skeleton .skeleton-tile {
    height: 64px;
    border-radius: 6px;
    background: linear-gradient(90deg, rgba(51, 65, 85, 0.4) 0%, rgba(71, 85, 105, 0.6) 50%, rgba(51, 65, 85, 0.4) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Error Message */
.heatmap-error-message {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 22px;
    margin: 24px;
    border-radius: 18px;
    background: rgba(127, 29, 29, 0.25);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fecaca;
    box-shadow: 0 10px 24px rgba(127, 29, 29, 0.25);
}

.heatmap-error-message .error-icon {
    width: 30px;
    height: 30px;
    color: #fca5a5;
    flex-shrink: 0;
}

.error-content {
    flex: 1;
}

.error-title {
    font-size: 15px;
    font-weight: 700;
    color: #fecaca;
    margin-bottom: 6px;
}

.error-text {
    font-size: 13px;
    color: rgba(254, 202, 202, 0.85);
}

/* Detail Panel */
.heatmap-detail-panel {
    margin: 24px;
    padding: 24px;
    border-radius: 18px;
    background: rgba(15, 23, 42, 0.82);
    border: 1px solid rgba(148, 163, 184, 0.16);
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.45);
    color: #e2e8f0;
}

.detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.detail-title-group {
    flex: 1;
}

.detail-symbol {
    font-size: 24px;
    font-weight: 800;
    color: #f8fafc;
    margin: 0 0 4px 0;
}

.detail-name {
    font-size: 14px;
    color: rgba(148, 163, 184, 0.75);
    margin: 0;
}

.detail-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(51, 65, 85, 0.4);
    color: #e2e8f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.detail-close:hover {
    background: rgba(99, 102, 241, 0.45);
    transform: scale(1.1);
}

.detail-close i {
    width: 18px;
    height: 18px;
}

.detail-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.detail-stat {
    padding: 16px;
    border-radius: 14px;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(148, 163, 184, 0.18);
}

.detail-stat-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: rgba(148, 163, 184, 0.7);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.detail-stat-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: #f8fafc;
}

.detail-meta {
    margin-top: 16px;
    font-size: 13px;
    color: rgba(148, 163, 184, 0.7);
}

.detail-actions {
    margin-top: 16px;
    display: flex;
    gap: 8px;
}

.detail-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    background: #3b82f6;
    color: white;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.detail-view-btn:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Stats Bar */
.heatmap-stats-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 20px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    background: rgba(15, 23, 42, 0.4);
    flex-wrap: wrap;
    overflow-x: auto;
}

.heatmap-stats-bar .stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.heatmap-stats-bar .stat-label {
    font-size: 11px;
    color: rgba(148, 163, 184, 0.7);
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
}

.heatmap-stats-bar .stat-value {
    font-size: 12px;
    font-weight: 700;
    color: #f1f5f9;
    font-variant-numeric: tabular-nums;
}

.heatmap-stats-bar .stat-highlight {
    font-size: 11px;
}

.heatmap-stats-bar .stat-badges {
    display: inline-flex;
    gap: 4px;
}

/* Quick Filters */
.heatmap-quick-filters {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
    background: rgba(15, 23, 42, 0.3);
    flex-wrap: wrap;
}

/* Search Control in Toolbar */
.search-control {
    flex-direction: row !important;
}

.search-input-wrapper {
    position: relative;
    width: 180px;
}

.search-input-wrapper .search-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: rgba(148, 163, 184, 0.5);
    pointer-events: none;
}

.search-input-wrapper .search-input {
    width: 100%;
    padding: 6px 10px 6px 28px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.6);
    color: #f8fafc;
    font-size: 12px;
}

.search-input-wrapper .search-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.search-input-wrapper .search-results-badge {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(99, 102, 241, 0.8);
    color: white;
    padding: 1px 6px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
}

/* Detail Action Button */
.detail-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    background: #3b82f6;
    color: white;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.detail-action-btn:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    color: white;
    text-decoration: none;
}

.detail-action-btn i {
    width: 16px;
    height: 16px;
}

/* Responsive Design */

/* Laptop screens */
@media (max-width: 1200px) {
    .heatmap-grid {
        height: calc(100vh - 260px);
        max-height: 600px;
    }

    .heatmap-sector {
        min-width: 160px;
    }

    .heatmap-sector-grid {
        grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
        grid-auto-rows: minmax(32px, 42px);
    }

    .heatmap-tile .label {
        font-size: 9px;
    }

    .heatmap-tile .change-badge {
        font-size: 8px;
        padding: 1px 3px;
    }
}

@media (max-width: 992px) {
    .heatmap-grid {
        height: calc(100vh - 240px);
        max-height: 500px;
    }

    .heatmap-sector {
        min-width: 140px;
    }
}

/* Tablet / small laptop */
@media (max-width: 768px) {
    .heatmap-grid {
        height: auto;
        max-height: 60vh;
        flex-direction: column;
    }

    .heatmap-sector {
        flex: 1 1 100% !important;
        max-width: 100% !important;
        max-height: none;
    }

    /* Show only top 4 sectors on mobile, collapse rest */
    .heatmap-sector:nth-child(n+5) {
        display: none;
    }

    .heatmap-sector-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        grid-auto-rows: minmax(34px, 44px);
    }

    .heatmap-toolbar-compact {
        flex-direction: column;
        gap: 8px;
        padding: 8px 12px;
    }

    .toolbar-category-group {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        padding-bottom: 4px;
    }

    .heatmap-stats-bar {
        gap: 8px;
        padding: 6px 12px;
    }

    .heatmap-stats-bar .stat-item {
        flex-direction: column;
        gap: 1px;
    }

    .heatmap-quick-filters {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding: 6px 12px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .search-input-wrapper {
        width: 140px;
    }

    .quick-filter-chip span {
        display: none;
    }

    .quick-filter-chip {
        padding: 6px 8px;
    }
}

/* Mobile */
@media (max-width: 640px) {
    .heatmap-grid {
        max-height: 55vh;
    }

    .heatmap-sector:nth-child(n+4) {
        display: none;
    }

    .heatmap-sector-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        grid-auto-rows: minmax(40px, 52px);
    }

    .heatmap-tile {
        min-height: 38px;
        padding: 3px 2px;
    }

    .heatmap-tile .label {
        font-size: 10px;
    }

    .heatmap-tile .change-badge {
        font-size: 9px;
        padding: 1px 3px;
    }

    .heatmap-tile .tile-price {
        display: none !important;
    }

    .heatmap-header {
        padding: 10px 12px;
    }

    .heatmap-title {
        font-size: 16px;
    }

    .toolbar-controls-group {
        width: 100%;
    }

    .toolbar-controls-group .control-item {
        flex: 1 1 0;
        min-width: 0;
    }

    .toolbar-controls-group .control-select {
        min-width: 0;
        width: 100%;
        font-size: 11px;
    }

    .heatmap-detail-panel {
        margin: 12px;
        padding: 16px;
    }

    .detail-symbol {
        font-size: 18px;
    }

    .detail-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .detail-stat {
        padding: 10px;
    }

    .detail-stat-value {
        font-size: 15px;
    }
}

/* Small phone (iPhone SE / 12 mini / 13 mini / 14) */
@media (max-width: 480px) {
    /* Prevent horizontal overflow at the root */
    .heatmap-container {
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* Reduce stacked body/container padding impact */
    .heatmap-main {
        overflow-x: hidden;
    }

    /* Tighter header */
    .heatmap-header {
        padding: 8px 10px;
    }

    .heatmap-title {
        font-size: 15px;
    }

    /* Hide export/settings on tiny screens — keep fullscreen only */
    #heatmap-export,
    #heatmap-settings {
        display: none;
    }

    /* Compact toolbar */
    .heatmap-toolbar-compact {
        padding: 6px 8px;
        gap: 6px;
    }

    .toolbar-category-group {
        gap: 4px;
        padding-bottom: 2px;
    }

    .category-btn {
        padding: 5px 10px;
        font-size: 11px;
    }

    .toolbar-controls-group {
        gap: 6px;
        width: 100%;
    }

    .control-item label {
        font-size: 10px;
    }

    .control-select {
        padding: 5px 8px;
        font-size: 11px;
        min-width: 0;
    }

    .control-btn {
        margin-top: 14px;
    }

    .search-input-wrapper {
        width: 100%;
    }

    .search-control {
        flex: 1 1 100% !important;
    }

    /* Compress stats bar — grid layout for wrapping */
    .heatmap-stats-bar {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 4px 8px;
        padding: 6px 8px;
        overflow-x: hidden;
    }

    .heatmap-stats-bar .stat-item {
        flex-direction: row;
        gap: 4px;
        font-size: 11px;
        min-width: 0;
    }

    .heatmap-stats-bar .stat-label {
        font-size: 10px;
    }

    .heatmap-stats-bar .stat-value {
        font-size: 11px;
    }

    /* Hide lower-priority stats on tiny screens */
    .heatmap-stats-bar .stat-item:nth-child(n+7) {
        display: none;
    }

    /* Compact quick filters */
    .heatmap-quick-filters {
        padding: 4px 8px;
        gap: 4px;
    }

    .quick-filter-chip {
        padding: 5px 6px;
        font-size: 11px;
    }

    /* THE KEY FIX: 2-column grid for readability */
    .heatmap-grid {
        padding: 2px;
        gap: 2px;
        max-height: 52vh;
        min-height: 280px;
    }

    .heatmap-sector {
        min-width: 0 !important;
    }

    /* Only show top 3 sectors */
    .heatmap-sector:nth-child(n+4) {
        display: none;
    }

    .heatmap-sector-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-rows: minmax(44px, 56px);
        gap: 2px;
    }

    /* Touch-friendly readable tiles */
    .heatmap-tile {
        min-height: 44px;
        padding: 4px 3px;
        border-radius: 4px;
    }

    .heatmap-tile .label {
        font-size: 11px;
        font-weight: 700;
    }

    .heatmap-tile .change-badge {
        font-size: 10px;
        padding: 2px 5px;
        border-radius: 3px;
    }

    .heatmap-tile .sub {
        display: none;
    }

    .heatmap-tile .tile-price {
        display: none !important;
    }

    /* Sector headers tighter */
    .sector-header {
        padding: 3px 6px;
    }

    .sector-title {
        font-size: 10px;
    }

    /* Compact legend */
    .heatmap-legend-gradient {
        padding: 8px 8px;
    }

    .legend-gradient-bar {
        height: 20px;
        padding: 0 4px;
    }

    .legend-mark {
        font-size: 9px;
    }

    /* Hide every other legend mark for space */
    .legend-mark:nth-child(2),
    .legend-mark:nth-child(4),
    .legend-mark:nth-child(6) {
        visibility: hidden;
    }

    /* Error and detail panel tighter */
    .heatmap-error-message {
        margin: 8px;
        padding: 14px;
        border-radius: 12px;
    }

    .heatmap-detail-panel {
        margin: 8px;
        padding: 12px;
        border-radius: 12px;
    }

    .detail-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .detail-stat {
        padding: 8px;
        border-radius: 8px;
    }

    .detail-stat-label {
        font-size: 10px;
    }

    .detail-stat-value {
        font-size: 14px;
    }

    .detail-symbol {
        font-size: 18px;
    }

    .detail-name {
        font-size: 12px;
    }
}
