.momentum-stocks-container {
    margin: 20px 0;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.momentum-title {
    color: #2c3e50;
    margin-bottom: 10px;
    text-align: center;
}

.momentum-description {
    color: #7f8c8d;
    margin-bottom: 20px;
    text-align: center;
}

#momentum-filter-form {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
}

#momentum-filter-form label {
    font-weight: 600;
    margin-bottom: 5px;
    display: block;
    color: #495057;
}

#momentum-filter-form .form-select,
#momentum-filter-form .btn {
    height: 38px;
}

#momentum-refresh-btn {
    min-width: 120px;
}

.momentum-loading-spinner {
    text-align: center;
    padding: 30px;
}

#momentum-stocks-table {
    font-size: 14px;
    table-layout: fixed;
    width: 100%;
}

/* Allow column headers to wrap */
#momentum-stocks-table th {
    font-weight: 600;
    padding: 10px 4px;
    text-align: center; /* All headers center aligned */
    white-space: normal !important;
    word-wrap: break-word;
    line-height: 1.2;
    height: auto;
    min-height: 40px;
    vertical-align: middle;
}

#momentum-stocks-table td {
    vertical-align: middle;
    padding: 8px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 0;
    line-height: 1.2;
}

/* Company - LEFT ALIGNED */
#momentum-stocks-table th:nth-child(1), /* Company Header */
#momentum-stocks-table td:nth-child(1) {
    width: 20%;
    text-align: left !important; /* Force left alignment */
}

/* Sector - LEFT ALIGNED */
#momentum-stocks-table th:nth-child(2), /* Sector Header */
#momentum-stocks-table td:nth-child(2) {
    width: 12%;
    text-align: left !important; /* Force left alignment */
}

/* ALL OTHER COLUMNS - CENTER ALIGNED */
#momentum-stocks-table th:nth-child(3), /* Price */
#momentum-stocks-table td:nth-child(3) {
    width: 8%;
    text-align: center !important; /* Center aligned */
    font-family: 'Courier New', monospace;
}

#momentum-stocks-table th:nth-child(4), /* Change % */
#momentum-stocks-table td:nth-child(4) {
    width: 8%;
    text-align: center !important; /* Center aligned */
    font-family: 'Courier New', monospace;
}

#momentum-stocks-table th:nth-child(5), /* Volume */
#momentum-stocks-table td:nth-child(5) {
    width: 8%;
    text-align: center !important; /* Center aligned */
    font-family: 'Courier New', monospace;
}

#momentum-stocks-table th:nth-child(6), /* Vol Change % */
#momentum-stocks-table td:nth-child(6) {
    width: 8%;
    text-align: center !important; /* Center aligned */
    font-family: 'Courier New', monospace;
}

#momentum-stocks-table th:nth-child(7), /* Signal */
#momentum-stocks-table td:nth-child(7) {
    width: 12%;
    text-align: center !important; /* Center aligned */
}

#momentum-stocks-table th:nth-child(8), /* RSI */
#momentum-stocks-table td:nth-child(8) {
    width: 7%;
    text-align: center !important; /* Center aligned */
    font-family: 'Courier New', monospace;
}

#momentum-stocks-table th:nth-child(9), /* MACD */
#momentum-stocks-table td:nth-child(9) {
    width: 7%;
    text-align: center !important; /* Center aligned */
    font-family: 'Courier New', monospace;
}

#momentum-stocks-table th:nth-child(10), /* Signal Line */
#momentum-stocks-table td:nth-child(10) {
    width: 7%;
    text-align: center !important; /* Center aligned */
    font-family: 'Courier New', monospace;
}

#momentum-stocks-table th:nth-child(11), /* Histogram */
#momentum-stocks-table td:nth-child(11) {
    width: 7%;
    text-align: center !important; /* Center aligned */
    font-family: 'Courier New', monospace;
}

/* EMA Proximity columns - CENTER ALIGNED */
#momentum-stocks-table th:nth-child(12), /* EMA20 */
#momentum-stocks-table td:nth-child(12),
#momentum-stocks-table th:nth-child(13), /* EMA9/26 */
#momentum-stocks-table td:nth-child(13),
#momentum-stocks-table th:nth-child(14), /* EMA10/20 */
#momentum-stocks-table td:nth-child(14),
#momentum-stocks-table th:nth-child(15) { /* EMA26/50 */
    width: 6%;
    text-align: center !important; /* Center aligned */
    font-family: 'Courier New', monospace;
}

/* Signal badge styling - centered */
#momentum-stocks-table .badge {
    font-size: 0.75em;
    padding: 3px 6px;
    border-radius: 10px;
    white-space: nowrap;
    display: inline-block;
    max-width: 95%;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    margin: 0 auto; /* Center badges */
}

/* Company link styling - left aligned */
.stock-link {
    color: #2c3e50;
    text-decoration: none;
    transition: color 0.2s;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    text-align: left; /* Left aligned */
}

.stock-link:hover {
    color: #3498db;
    text-decoration: underline;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#momentum-stats {
    margin-top: 15px;
    font-size: 0.9em;
    text-align: center;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .mobile-hidden {
        display: none !important;
    }
    
    .mobile-visible {
        display: block !important;
    }
    
    #momentum-filter-form .table {
        width: 100% !important;
    }
    
    #momentum-filter-form td {
        display: block;
        width: 100%;
        margin-bottom: 10px;
    }
    
    #momentum-filter-form .btn {
        width: 100%;
        margin-top: 10px;
    }
    
    #momentum-stocks-table {
        font-size: 12px;
    }
    
    #momentum-stocks-table th,
    #momentum-stocks-table td {
        padding: 6px 3px;
        font-size: 11px;
    }
    
    /* Mobile column visibility with alignment */
    #momentum-stocks-table th:nth-child(1), /* Company - LEFT */
    #momentum-stocks-table td:nth-child(1) {
        width: 28%;
        display: table-cell;
        text-align: left !important;
    }
    
    #momentum-stocks-table th:nth-child(2), /* Sector - LEFT */
    #momentum-stocks-table td:nth-child(2) {
        width: 20%;
        display: table-cell;
        text-align: left !important;
    }
    
    #momentum-stocks-table th:nth-child(3), /* Price - CENTER */
    #momentum-stocks-table td:nth-child(3) {
        width: 15%;
        display: table-cell;
        text-align: center !important;
    }
    
    #momentum-stocks-table th:nth-child(4), /* Change % - CENTER */
    #momentum-stocks-table td:nth-child(4) {
        width: 15%;
        display: table-cell;
        text-align: center !important;
    }
    
    /* Hide these columns on mobile */
    #momentum-stocks-table th:nth-child(5),
    #momentum-stocks-table td:nth-child(5),
    #momentum-stocks-table th:nth-child(6),
    #momentum-stocks-table td:nth-child(6),
    #momentum-stocks-table th:nth-child(8),
    #momentum-stocks-table td:nth-child(8),
    #momentum-stocks-table th:nth-child(n+9),
    #momentum-stocks-table td:nth-child(n+9) {
        display: none;
    }
    
    /* Signal column on mobile - CENTER */
    #momentum-stocks-table th:nth-child(7),
    #momentum-stocks-table td:nth-child(7) {
        width: 22%;
        display: table-cell;
        text-align: center !important;
    }
    
    /* Allow headers to wrap on mobile */
    #momentum-stocks-table th {
        font-size: 11px;
        padding: 8px 2px;
        min-height: 35px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    /* Tablet view adjustments */
    #momentum-stocks-table {
        font-size: 13px;
    }
    
    #momentum-stocks-table th,
    #momentum-stocks-table td {
        padding: 8px 4px;
    }
    
    /* Hide EMA proximity columns on tablet */
    #momentum-stocks-table th:nth-child(n+12),
    #momentum-stocks-table td:nth-child(n+12) {
        display: none;
    }
    
    /* Adjust widths for tablet with alignment */
    #momentum-stocks-table th:nth-child(1), /* LEFT */
    #momentum-stocks-table td:nth-child(1) {
        width: 22%;
        text-align: left !important;
    }
    
    #momentum-stocks-table th:nth-child(2), /* LEFT */
    #momentum-stocks-table td:nth-child(2) {
        width: 14%;
        text-align: left !important;
    }
    
    #momentum-stocks-table th:nth-child(7), /* Signal - CENTER */
    #momentum-stocks-table td:nth-child(7) {
        width: 15%;
        text-align: center !important;
    }
    
    #momentum-stocks-table th:nth-child(8), /* RSI - CENTER */
    #momentum-stocks-table td:nth-child(8) {
        width: 6%;
        text-align: center !important;
    }
    
    /* Smaller headers on tablet */
    #momentum-stocks-table th {
        font-size: 13px;
        min-height: 45px;
    }
}

@media (min-width: 769px) {
    .mobile-hidden {
        display: table-cell !important;
    }
    
    .mobile-visible {
        display: none !important;
    }
    
    #momentum-filter-form .table {
        margin: 0 auto;
    }
    
    #momentum-filter-form td {
        padding: 0 10px;
    }
}

/* Table borderless styling for form */
#momentum-filter-form .table-borderless {
    border: none;
}

#momentum-filter-form .table-borderless td {
    border: none;
    padding: 5px 10px;
}

#momentum-filter-form .align-middle {
    vertical-align: middle;
}

/* Force single line for data cells only */
#momentum-stocks-table td {
    white-space: nowrap !important;
    line-height: 1.2 !important;
}

/* Allow headers to wrap */
#momentum-stocks-table th {
    white-space: normal !important;
    word-break: break-word;
}

/* Specific column header adjustments */
#momentum-stocks-table th:nth-child(6) { /* Vol Change % */
    font-size: 0.9em;
    padding-top: 12px;
}

#momentum-stocks-table th:nth-child(10) { /* Signal Line */
    font-size: 0.9em;
    padding-top: 12px;
}

/* Small headers for EMA columns */
#momentum-stocks-table th:nth-child(12),
#momentum-stocks-table th:nth-child(13),
#momentum-stocks-table th:nth-child(14),
#momentum-stocks-table th:nth-child(15) {
    font-size: 0.85em;
}

/* Ensure numeric cells display properly when centered */
.numeric-cell {
    font-family: 'Courier New', monospace;
    text-align: center !important;
}

/* Force specific alignment for left-aligned columns */
.left-align {
    text-align: left !important;
}

.center-align {
    text-align: center !important;
}

/* Highlight row styling */
#momentum-stocks-table tr.highlight-row {
    background-color: rgba(144, 238, 144, 0.2) !important; /* Light green background */
    border-left: 4px solid #28a745 !important; /* Green left border */
    border-right: 2px solid #28a745 !important; /* Green right border */
    font-weight: 600; /* Bold text */
}

#momentum-stocks-table tr.highlight-row:hover {
    background-color: rgba(144, 238, 144, 0.3) !important; /* Slightly darker on hover */
}

#momentum-stocks-table tr.highlight-row td {
    position: relative;
}

/* Add a subtle shadow to highlight rows */
#momentum-stocks-table tr.highlight-row {
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.2);
}

/* Highlight count in stats */
.highlight-count {
    color: #28a745;
    font-weight: bold;
    background-color: rgba(40, 167, 69, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #28a745;
}

/* Tooltip for highlighted rows */
#momentum-stocks-table tr.highlight-row:hover:after {
    content: attr(title);
    position: absolute;
    left: 10px;
    top: -30px;
    background: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}

/* =========================================== */
/* 3-LINE TREND DISPLAY STYLES */
/* =========================================== */

/* Trend value on first line */
.trend-value {
    font-family: 'Courier New', monospace;
    font-size: 0.95em;
    line-height: 1.1;
    white-space: nowrap;
    text-align: center;
    color: inherit !important;
    margin-bottom: 2px;
}

/* Trend arrow on second line */
.trend-arrow {
    font-size: 1.3em !important;
    font-weight: bold !important;
    line-height: 1 !important;
    text-align: center !important;
    min-height: 18px !important;
    cursor: help !important;
    display: block !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
    margin: 2px 0 !important;
}

/* Trend difference on third line with smaller font */
.trend-difference {
    font-family: 'Courier New', monospace;
    font-size: 0.75em !important; /* Smaller font for difference */
    line-height: 1 !important;
    text-align: center !important;
    white-space: nowrap;
    margin-top: 1px !important;
    opacity: 0.85; /* Slightly transparent */
}

/* Colored trend arrows */
#momentum-stocks-table .trend-arrow.trend-up {
    color: #28a745 !important; /* Green for uptrend */
}

#momentum-stocks-table .trend-arrow.trend-down {
    color: #dc3545 !important; /* Red for downtrend */
}

#momentum-stocks-table .trend-arrow.trend-neutral {
    color: #6c757d !important; /* Gray for neutral */
}

/* Colored trend differences */
#momentum-stocks-table .trend-difference.trend-up {
    color: #28a745 !important; /* Green for positive difference */
}

#momentum-stocks-table .trend-difference.trend-down {
    color: #dc3545 !important; /* Red for negative difference */
}

#momentum-stocks-table .trend-difference.trend-neutral {
    color: #6c757d !important; /* Gray for neutral */
}

/* EMA/MACD cells with 3-line support */
.ema-cell, .macd-cell {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 55px !important; /* Increased height for 3 lines */
    padding: 4px 2px !important;
    background: transparent !important;
}

/* Ensure trend elements don't inherit background colors */
.ema-cell .trend-arrow,
.ema-cell .trend-difference,
.macd-cell .trend-arrow,
.macd-cell .trend-difference {
    background: transparent !important;
}

/* Adjust column heights for 3-line display */
#momentum-stocks-table td {
    padding: 6px 4px !important;
    vertical-align: middle !important;
}

/* Adjust specific columns for 3-line trend display */
#momentum-stocks-table td:nth-child(9), /* MACD */
#momentum-stocks-table td:nth-child(10), /* Signal Line */
#momentum-stocks-table td:nth-child(11), /* Histogram */
#momentum-stocks-table td:nth-child(12), /* EMA20 */
#momentum-stocks-table td:nth-child(13), /* EMA9/26 */
#momentum-stocks-table td:nth-child(14), /* EMA10/20 */
#momentum-stocks-table td:nth-child(15) { /* EMA26/50 */
    height: 65px !important; /* Increased height for 3 lines */
}

/* Adjust column widths for trend display */
#momentum-stocks-table th:nth-child(9), /* MACD */
#momentum-stocks-table td:nth-child(9),
#momentum-stocks-table th:nth-child(10), /* Signal Line */
#momentum-stocks-table td:nth-child(10),
#momentum-stocks-table th:nth-child(11), /* Histogram */
#momentum-stocks-table td:nth-child(11),
#momentum-stocks-table th:nth-child(12), /* EMA20 */
#momentum-stocks-table td:nth-child(12),
#momentum-stocks-table th:nth-child(13), /* EMA9/26 */
#momentum-stocks-table td:nth-child(13),
#momentum-stocks-table th:nth-child(14), /* EMA10/20 */
#momentum-stocks-table td:nth-child(14),
#momentum-stocks-table th:nth-child(15) { /* EMA26/50 */
    width: 7% !important; /* Slightly wider to accommodate 3 lines */
    text-align: center !important;
    font-family: 'Courier New', monospace;
}

/* Price and RSI cells - single line */
.price-cell, .rsi-cell {
    line-height: 1.2;
    padding: 8px 4px !important;
}

/* Responsive adjustments for 3-line layout */
@media (max-width: 768px) {
    .trend-value {
        font-size: 0.85em;
    }
    
    .trend-arrow {
        font-size: 1.1em !important;
    }
    
    .trend-difference {
        font-size: 0.7em !important;
    }
    
    .ema-cell, .macd-cell {
        min-height: 45px !important;
    }
    
    #momentum-stocks-table td:nth-child(9),
    #momentum-stocks-table td:nth-child(10),
    #momentum-stocks-table td:nth-child(11),
    #momentum-stocks-table td:nth-child(12),
    #momentum-stocks-table td:nth-child(13),
    #momentum-stocks-table td:nth-child(14),
    #momentum-stocks-table td:nth-child(15) {
        height: 55px !important;
        font-size: 0.8em;
    }
}

/* Ensure highlight rows work with 3-line layout */
#momentum-stocks-table tr.highlight-row .ema-cell,
#momentum-stocks-table tr.highlight-row .macd-cell {
    background-color: transparent !important;
}

/* Center align all content in trend cells */
.ema-cell > span, .macd-cell > span {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    background: transparent !important;
}

/* Prevent text overflow for trend displays */
.ema-cell span, .macd-cell span {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}