* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #0a0e17;
    color: #e1e5eb;
    line-height: 1.6;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    padding: 30px 0;
    border-bottom: 1px solid #1e2738;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, #00d4aa, #0099ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: #6b7280;
    margin-top: 8px;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: linear-gradient(145deg, #151b28, #1a2235);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #252d3d;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.card.qualified {
    border-color: #00d4aa;
    background: linear-gradient(145deg, #0d1f1a, #152520);
}

.card-label {
    font-size: 0.875rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-value {
    font-size: 2rem;
    font-weight: 700;
    margin-top: 8px;
    color: #fff;
}

.card.qualified .card-value {
    color: #00d4aa;
}

/* Filters */
.filters {
    display: flex;
    gap: 30px;
    align-items: center;
    padding: 16px 24px;
    background: #151b28;
    border-radius: 10px;
    margin-bottom: 30px;
}

.filters label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #9ca3af;
    cursor: pointer;
}

.filters select {
    background: #1a2235;
    border: 1px solid #252d3d;
    color: #e1e5eb;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
}

.filters input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #00d4aa;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 30px;
    margin-bottom: 30px;
    align-items: start;
}

/* Strategies Panel */
.strategies-panel {
    background: #151b28;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #252d3d;
    display: flex;
    flex-direction: column;
    height: fit-content;
    max-height: calc(100vh - 250px);
}

.strategies-panel .table-wrapper {
    flex: 1;
    overflow-y: auto;
    margin-top: 10px;
}

.strategies-panel .table-wrapper::-webkit-scrollbar {
    width: 8px;
}

.strategies-panel .table-wrapper::-webkit-scrollbar-track {
    background: #1a2235;
    border-radius: 4px;
}

.strategies-panel .table-wrapper::-webkit-scrollbar-thumb {
    background: #353d4d;
    border-radius: 4px;
}

.strategies-panel .table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #454d5d;
}

.strategies-panel h2 {
    margin-bottom: 20px;
    color: #fff;
    font-size: 1.25rem;
}

#strategies-table {
    width: 100%;
    border-collapse: collapse;
}

#strategies-table th,
#strategies-table td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid #252d3d;
}

#strategies-table th {
    color: #6b7280;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    background: #151b28;
}

#strategies-table tbody tr {
    cursor: pointer;
    transition: background 0.2s;
}

#strategies-table tbody tr:hover {
    background: #1a2235;
}

#strategies-table tbody tr.selected {
    background: #1e3a5f;
    border-left: 3px solid #0099ff;
}

#strategies-table .strategy-number {
    font-weight: 700;
    color: #0099ff;
    text-align: center;
    min-width: 40px;
}

#strategies-table th:first-child {
    text-align: center;
    width: 50px;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.qualified {
    background: rgba(0, 212, 170, 0.15);
    color: #00d4aa;
}

.status-badge.testing {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
}

.status-badge.rejected {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Chart Panel */
.chart-panel {
    background: #151b28;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #252d3d;
}

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

.chart-header h2 {
    color: #fff;
    font-size: 1.25rem;
}

.chart-controls {
    display: flex;
    gap: 12px;
}

.chart-controls select {
    background: #1a2235;
    border: 1px solid #252d3d;
    color: #e1e5eb;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
}

#chart-container {
    height: 400px;
    background: #0d1117;
    border-radius: 8px;
    overflow: hidden;
}

.legend {
    display: flex;
    gap: 24px;
    margin-top: 16px;
    padding: 12px;
    background: #1a2235;
    border-radius: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: #9ca3af;
}

.legend-item .marker {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-item.buy .marker {
    background: #00d4aa;
}

.legend-item.sell .marker {
    background: #ef4444;
}

.legend-item.exit .marker {
    background: #ffc107;
}

.trade-details {
    margin-top: 20px;
    padding: 16px;
    background: #1a2235;
    border-radius: 8px;
}

.trade-details h3 {
    font-size: 1rem;
    color: #fff;
    margin-bottom: 12px;
}

#trade-info {
    color: #6b7280;
    font-size: 0.875rem;
}

.trade-details.highlighted {
    animation: highlightPulse 0.5s ease;
}

@keyframes highlightPulse {
    0% { background: #1a2235; }
    50% { background: #2a3a55; border-color: #00d4aa; }
    100% { background: #1a2235; }
}

.trade-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #252d3d;
}

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

.trade-detail-row.highlight {
    background: rgba(0, 212, 170, 0.1);
    margin: 4px -8px;
    padding: 8px;
    border-radius: 4px;
    border-bottom: none;
}

.trade-detail-row .label {
    color: #6b7280;
    font-weight: 500;
}

.trade-detail-row .value {
    color: #fff;
    font-weight: 600;
}

.trade-detail-row .value.win {
    color: #00d4aa;
}

.trade-detail-row .value.loss {
    color: #ef4444;
}

.trade-detail-row .value.direction-long {
    color: #00d4aa;
}

.trade-detail-row .value.direction-short {
    color: #ef4444;
}

.trade-detail-row .value.positive {
    color: #00d4aa;
}

.trade-detail-row .value.negative {
    color: #ef4444;
}

.trade-detail-row .value.stop-loss {
    color: #ef4444;
}

.trade-detail-row .value.take-profit {
    color: #00d4aa;
}

.trade-detail-row .value.exit-reason {
    color: #f59e0b;
    font-style: italic;
}

/* Trade detail sections */
.trade-detail-section {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #252d3d;
}

.trade-detail-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.trade-detail-section.highlight-section {
    background: rgba(0, 212, 170, 0.05);
    margin: 8px -12px;
    padding: 12px;
    border-radius: 8px;
    border-bottom: none;
}

.trade-detail-section .trade-detail-row {
    border-bottom: none;
    padding: 4px 0;
}

.trade-detail-subtitle {
    font-size: 0.75rem;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px dashed #374151;
}

/* Strategy Details */
.strategy-details {
    background: #151b28;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #252d3d;
    margin-bottom: 30px;
}

.strategy-details h2 {
    margin-bottom: 20px;
    color: #fff;
    font-size: 1.25rem;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.detail-section {
    padding: 20px;
    background: #1a2235;
    border-radius: 8px;
}

.detail-section h3 {
    color: #00d4aa;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.detail-section p,
.detail-section li {
    color: #9ca3af;
    font-size: 0.9rem;
}

.detail-section ul {
    list-style: none;
    padding-left: 0;
}

.detail-section li {
    padding: 6px 0;
    padding-left: 20px;
    position: relative;
}

.detail-section li::before {
    content: '>';
    position: absolute;
    left: 0;
    color: #00d4aa;
}

#best-symbols {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.symbol-tag {
    display: inline-block;
    padding: 4px 12px;
    background: #252d3d;
    border-radius: 20px;
    font-size: 0.8rem;
    color: #e1e5eb;
}

.symbol-tag.top {
    background: rgba(0, 212, 170, 0.2);
    color: #00d4aa;
    border: 1px solid #00d4aa;
}

/* Equity Curve */
.equity-curve-section {
    background: #151b28;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #252d3d;
}

.equity-curve-section h2 {
    margin-bottom: 20px;
    color: #fff;
    font-size: 1.25rem;
}

#equity-chart {
    height: 300px;
    background: #0d1117;
    border-radius: 8px;
    overflow: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #0a0e17;
}

::-webkit-scrollbar-thumb {
    background: #252d3d;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3a4556;
}

/* Navigation Container */
.nav-container {
    position: relative;
    margin-bottom: 30px;
}

/* Hamburger Button - hidden on desktop */
.hamburger {
    display: none;
    background: #151b28;
    border: 1px solid #252d3d;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    flex-direction: column;
    gap: 5px;
    width: 48px;
    height: 48px;
    align-items: center;
    justify-content: center;
    z-index: 101;
}

.hamburger-line {
    display: block;
    width: 22px;
    height: 2px;
    background: #e1e5eb;
    border-radius: 2px;
    transition: transform 0.3s, opacity 0.3s;
}

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

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

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

/* Responsive */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .strategies-panel {
        max-height: 400px;
    }

    .trades-tab-layout {
        grid-template-columns: 1fr;
    }

    .trades-chart-section {
        min-height: 400px;
    }

    /* Horizontally scrollable tabs on tablet */
    .nav-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .nav-tab {
        flex: none;
        white-space: nowrap;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 1.75rem;
    }

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

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    /* Hamburger visible on phone */
    .hamburger {
        display: flex;
    }

    /* Nav tabs become dropdown menu */
    .nav-tabs {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        z-index: 100;
        background: #151b28;
        border: 1px solid #252d3d;
        border-radius: 12px;
        padding: 8px;
        box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    }

    .nav-tabs.open {
        display: flex;
    }

    .nav-tab {
        flex: none;
        text-align: left;
        padding: 14px 20px;
        min-height: 48px;
        font-size: 1rem;
    }

    /* Summary cards: 2 per row on tablet/phone */
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .card {
        padding: 16px;
    }

    .card-value {
        font-size: 1.5rem;
    }

    /* Container padding */
    .container {
        padding: 12px;
    }

    header {
        padding: 20px 0;
        margin-bottom: 20px;
    }

    /* Chart container fixed height on mobile */
    #chart-container {
        height: 300px;
    }

    #equity-chart {
        height: 250px;
    }

    /* Strategy details full width */
    .strategy-details {
        padding: 16px;
    }

    .details-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* Table horizontal scroll */
    .strategies-panel .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .backtest-signals-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

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

    /* Prevent tables from shrinking */
    #strategies-table,
    .backtest-signals-table,
    .trades-table,
    .orders-table,
    .opt-history-table {
        min-width: 600px;
    }

    /* Sticky first column for trade tables */
    .trades-table th:first-child,
    .trades-table td:first-child {
        position: sticky;
        left: 0;
        z-index: 2;
        background: #1a2235;
    }

    .trades-table thead th:first-child {
        background: #1a2235;
        z-index: 3;
    }

    .trades-table tbody tr.selected td:first-child {
        background: #252d3d;
    }

    /* Orders table scroll */
    .orders-section {
        padding: 16px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Optimization table scroll */
    .optimization-history {
        padding: 16px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Touch-friendly buttons: 44px minimum */
    .btn,
    .btn-refresh,
    .btn-primary,
    .btn-secondary,
    .pagination-btn {
        min-height: 44px;
        padding: 10px 16px;
        font-size: 0.95rem;
    }

    .trades-pagination {
        gap: 8px;
    }

    .pagination-btn {
        min-width: 44px;
        height: 44px;
    }

    /* Touch-friendly form elements */
    .filters select,
    .chart-controls select,
    .trades-filters select,
    .debug-controls select,
    #broker-order-mode {
        min-height: 44px;
        padding: 10px 12px;
        font-size: 0.95rem;
    }

    .filters input[type="checkbox"],
    .broker-checkbox input[type="checkbox"] {
        width: 22px;
        height: 22px;
    }

    /* Font size bump for readability */
    body {
        font-size: 16px;
    }

    #strategies-table th,
    #strategies-table td {
        padding: 10px 6px;
        font-size: 0.85rem;
    }

    .backtest-signals-table td,
    .backtest-signals-table th {
        padding: 10px 8px;
    }

    /* Legend wrap on mobile */
    .legend {
        flex-wrap: wrap;
        gap: 12px;
    }

    /* Filters stacking */
    .filters {
        gap: 16px;
        padding: 12px 16px;
    }

    .trades-filters {
        flex-direction: column;
        width: 100%;
    }

    .trades-filters select {
        width: 100%;
    }

    /* Debug controls */
    .debug-controls {
        flex-wrap: wrap;
        gap: 12px;
    }

    .debug-log {
        font-size: 0.8rem;
        max-height: 400px;
    }

    /* Optimization cards */
    .optimization-summary-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .opt-card {
        padding: 14px;
        gap: 10px;
    }

    .opt-card-icon {
        font-size: 1.5rem;
    }

    .opt-card-value {
        font-size: 1.2rem;
    }

    /* Latest optimization metrics stack */
    .latest-opt-metrics {
        grid-template-columns: 1fr;
    }

    /* Backtest header wrap */
    .backtest-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

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

    /* Tab header wrap */
    .tab-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .tab-actions {
        width: 100%;
        justify-content: space-between;
    }

    /* Chart panel padding */
    .chart-panel {
        padding: 16px;
    }

    .strategies-panel {
        padding: 16px;
        max-height: none;
    }

    /* Recent trades panel */
    .recent-trades-header {
        padding: 12px 16px;
    }

    /* Bot status */
    .live-status-grid {
        grid-template-columns: 1fr;
    }

    .bot-status-card {
        padding: 16px;
    }

    /* Broker checkboxes already handled at 768px */
    .broker-selection-panel {
        padding: 16px;
    }

    .broker-actions {
        flex-direction: column;
    }

    .broker-mode-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    #broker-order-mode {
        width: 100%;
    }

    /* Trade detail row */
    .trade-detail-row {
        font-size: 0.9rem;
    }

    /* Equity curve section */
    .equity-curve-section {
        padding: 16px;
    }

    /* Trades chart */
    #trades-chart-container {
        min-height: 280px;
    }

    .trades-chart-section {
        padding: 16px;
    }

    .trades-table-section {
        padding: 16px;
    }
}

/* Very small phones */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.35rem;
    }

    .subtitle {
        font-size: 0.85rem;
    }

    /* 1 card per row on very small screens */
    .summary-cards {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .card {
        padding: 14px;
    }

    .card-value {
        font-size: 1.3rem;
    }

    /* Optimization cards 1 per row */
    .optimization-summary-cards {
        grid-template-columns: 1fr;
    }

    /* Chart height smaller */
    #chart-container {
        height: 260px;
    }

    #equity-chart {
        height: 220px;
    }

    /* Params grid single column */
    .params-grid {
        grid-template-columns: 1fr;
    }

    .opt-details-grid {
        grid-template-columns: 1fr;
    }

    /* Even smaller padding */
    .container {
        padding: 8px;
    }

    .chart-panel,
    .strategies-panel,
    .strategy-details,
    .equity-curve-section {
        padding: 12px;
        border-radius: 8px;
    }
}

/* Win rate colors */
.win-rate-high { color: #00d4aa; }
.win-rate-medium { color: #ffc107; }
.win-rate-low { color: #ef4444; }

/* P-value colors */
.p-value-good { color: #00d4aa; }
.p-value-marginal { color: #ffc107; }
.p-value-bad { color: #ef4444; }

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    gap: 4px;
    background: #151b28;
    padding: 6px;
    border-radius: 12px;
    border: 1px solid #252d3d;
}

.nav-tab {
    flex: 1;
    padding: 12px 24px;
    background: transparent;
    border: none;
    color: #6b7280;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.nav-tab:hover {
    color: #e1e5eb;
    background: #1a2235;
}

.nav-tab.active {
    background: linear-gradient(135deg, #00d4aa20, #0099ff20);
    color: #00d4aa;
    border: 1px solid #00d4aa40;
}

/* Live card */
.card.live-card {
    border-color: #0099ff;
    background: linear-gradient(145deg, #0d1a2a, #152535);
}

.card.live-card .card-value {
    color: #0099ff;
}

/* Tab content */
.tab-content {
    margin-bottom: 30px;
}

.tab-content h2 {
    margin-bottom: 20px;
    color: #fff;
    font-size: 1.5rem;
}

/* Live Status */
.live-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.bot-status-card {
    background: #151b28;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #252d3d;
}

.bot-status-card.active {
    border-color: #00d4aa;
}

.bot-status-card.inactive {
    border-color: #6b7280;
    opacity: 0.7;
}

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

.bot-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fff;
}

.bot-status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-dot.running {
    background: #00d4aa;
    box-shadow: 0 0 10px #00d4aa50;
}

.status-dot.stopped {
    background: #6b7280;
    animation: none;
}

.status-dot.error {
    background: #ef4444;
    box-shadow: 0 0 10px #ef444450;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.bot-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.bot-stat {
    padding: 10px;
    background: #1a2235;
    border-radius: 6px;
}

.bot-stat-label {
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
}

.bot-stat-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #e1e5eb;
}

.connection-status {
    background: #151b28;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #252d3d;
}

.connection-status h3 {
    color: #fff;
    margin-bottom: 16px;
}

.status-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #252d3d;
}

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

.status-label {
    color: #6b7280;
}

.status-indicator {
    font-weight: 600;
}

.status-indicator.online {
    color: #00d4aa;
}

.status-indicator.offline {
    color: #ef4444;
}

/* Orders */
.orders-section {
    background: #151b28;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #252d3d;
    margin-bottom: 20px;
}

.orders-section h3 {
    color: #fff;
    margin-bottom: 16px;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
}

.orders-table th,
.orders-table td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid #252d3d;
}

.orders-table th {
    color: #6b7280;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.orders-table td {
    color: #e1e5eb;
}

.orders-table .no-data {
    text-align: center;
    color: #6b7280;
    font-style: italic;
}

.orders-table .buy {
    color: #00d4aa;
}

.orders-table .sell {
    color: #ef4444;
}

.orders-table .profit {
    color: #00d4aa;
}

.orders-table .loss {
    color: #ef4444;
}

.btn {
    background: linear-gradient(135deg, #00d4aa, #0099ff);
    border: none;
    color: #fff;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s;
}

.btn:hover {
    opacity: 0.9;
}

.btn.danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.btn.secondary {
    background: #252d3d;
}

/* Debug Log */
.debug-controls {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
    padding: 12px;
    background: #151b28;
    border-radius: 8px;
}

.debug-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #9ca3af;
}

.debug-controls select {
    background: #1a2235;
    border: 1px solid #252d3d;
    color: #e1e5eb;
    padding: 6px 12px;
    border-radius: 4px;
}

.debug-log {
    background: #0d1117;
    border: 1px solid #252d3d;
    border-radius: 8px;
    padding: 16px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    max-height: 500px;
    overflow-y: auto;
}

.log-entry {
    padding: 4px 0;
    border-bottom: 1px solid #1e2738;
    white-space: pre-wrap;
    word-break: break-all;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.error {
    color: #ef4444;
}

.log-entry.warn {
    color: #ffc107;
}

.log-entry.info {
    color: #0099ff;
}

.log-entry.trade {
    color: #00d4aa;
}

.log-entry.order {
    color: #a855f7;
}

.log-timestamp {
    color: #6b7280;
    margin-right: 8px;
}

.no-data {
    color: #6b7280;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* Broker Selection Panel */
.broker-selection-panel {
    background: #151b28;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #252d3d;
    margin-bottom: 24px;
}

.broker-selection-panel h3 {
    color: #fff;
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.broker-description {
    color: #6b7280;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.broker-checkboxes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.broker-checkbox-group {
    background: #1a2235;
    border-radius: 10px;
    padding: 16px;
    border: 1px solid #252d3d;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.broker-checkbox-group:has(input:checked) {
    border-color: #00d4aa;
    box-shadow: 0 0 10px rgba(0, 212, 170, 0.1);
}

.broker-checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    margin-bottom: 12px;
}

.broker-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #00d4aa;
    cursor: pointer;
}

.broker-name {
    font-weight: 600;
    color: #fff;
    flex: 1;
}

.broker-status {
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 500;
}

.broker-status.connected {
    background: rgba(0, 212, 170, 0.15);
    color: #00d4aa;
}

.broker-status.disconnected {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.broker-details {
    display: flex;
    gap: 16px;
    padding-left: 32px;
}

.broker-detail {
    font-size: 0.8rem;
    color: #6b7280;
}

.broker-detail span {
    color: #9ca3af;
}

.broker-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.btn-primary {
    background: linear-gradient(135deg, #00d4aa, #0099ff);
}

.btn-secondary {
    background: #252d3d;
}

.broker-mode-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid #252d3d;
}

.mode-label {
    color: #6b7280;
    font-size: 0.9rem;
}

#broker-order-mode {
    background: #1a2235;
    border: 1px solid #252d3d;
    color: #e1e5eb;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
}

#broker-order-mode:focus {
    outline: none;
    border-color: #00d4aa;
}

/* Responsive broker checkboxes */
@media (max-width: 768px) {
    .broker-checkboxes {
        grid-template-columns: 1fr;
    }

    .broker-details {
        flex-direction: column;
        gap: 4px;
    }

    .broker-actions {
        flex-direction: column;
    }
}

/* Tab Header with Refresh */
.tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #252d3d;
}

.tab-header h2 {
    margin: 0;
}

.tab-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.last-updated {
    color: #6b7280;
    font-size: 0.85rem;
}

.btn-refresh {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #252d3d;
    border: 1px solid #353d4d;
    color: #e1e5eb;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-refresh:hover {
    background: #303848;
    border-color: #00d4aa;
}

.btn-refresh:active {
    transform: scale(0.98);
}

.btn-refresh.loading {
    opacity: 0.7;
    pointer-events: none;
}

.btn-refresh.loading .refresh-icon {
    animation: spin 1s linear infinite;
}

.refresh-icon {
    font-size: 1.1rem;
    display: inline-block;
}

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

/* Backtest Signals Panel */
.backtest-signals-panel {
    margin-top: 20px;
    background: linear-gradient(145deg, #151b28, #1a2235);
    border-radius: 12px;
    border: 1px solid #252d3d;
    overflow: hidden;
}

.backtest-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #252d3d;
    background: #0d1117;
}

.backtest-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #e1e5eb;
}

.backtest-summary {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.summary-stat {
    font-size: 0.85rem;
    color: #9ca3af;
}

.summary-stat strong {
    color: #e1e5eb;
    margin-left: 4px;
}

.summary-stat.win strong {
    color: #00d4aa;
}

.summary-stat.loss strong {
    color: #ef4444;
}

.backtest-signals-table-wrapper {
    max-height: 300px;
    overflow-y: auto;
}

.backtest-signals-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.backtest-signals-table thead {
    position: sticky;
    top: 0;
    background: #151b28;
    z-index: 1;
}

.backtest-signals-table th {
    padding: 10px 12px;
    text-align: left;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #252d3d;
}

.backtest-signals-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #1e2738;
    color: #e1e5eb;
}

.backtest-signals-table tbody tr:hover {
    background: rgba(0, 212, 170, 0.05);
}

.backtest-signals-table .long {
    color: #00d4aa;
}

.backtest-signals-table .short {
    color: #ef4444;
}

.backtest-signals-table .pnl-positive {
    color: #00d4aa;
    font-weight: 600;
}

.backtest-signals-table .pnl-negative {
    color: #ef4444;
    font-weight: 600;
}

.backtest-signals-table .result-win {
    background: rgba(0, 212, 170, 0.15);
    color: #00d4aa;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.backtest-signals-table .result-loss {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.backtest-signals-table .result-stop {
    background: rgba(239, 68, 68, 0.25);
    color: #ff6b6b;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Scrollbar styling for backtest table */
.backtest-signals-table-wrapper::-webkit-scrollbar {
    width: 8px;
}

.backtest-signals-table-wrapper::-webkit-scrollbar-track {
    background: #1a2235;
}

.backtest-signals-table-wrapper::-webkit-scrollbar-thumb {
    background: #353d4d;
    border-radius: 4px;
}

.backtest-signals-table-wrapper::-webkit-scrollbar-thumb:hover {
    background: #454d5d;
}

/* Pagination Styles */
.pagination-container {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #252d3d;
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    color: #6b7280;
    font-size: 0.85rem;
}

.pagination-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}

.pagination-btn {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a2235;
    border: 1px solid #252d3d;
    color: #9ca3af;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: #252d3d;
    color: #e1e5eb;
    border-color: #353d4d;
}

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

.pagination-btn.active {
    background: linear-gradient(135deg, #00d4aa, #0099ff);
    border-color: transparent;
    color: #fff;
    font-weight: 600;
}

/* Responsive pagination */
@media (max-width: 768px) {
    .pagination {
        flex-direction: column;
        align-items: stretch;
    }

    .pagination-info {
        text-align: center;
    }

    .pagination-controls {
        justify-content: center;
    }
}

/* Recent Trades Panel */
.recent-trades-panel {
    margin-top: 20px;
    background: linear-gradient(145deg, #151b28, #1a2235);
    border-radius: 12px;
    border: 1px solid #252d3d;
    overflow: hidden;
}

.recent-trades-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid #252d3d;
    background: #0d1117;
}

.recent-trades-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #e1e5eb;
}

.recent-trades-count {
    font-size: 0.8rem;
    color: #6b7280;
    background: #1a2235;
    padding: 4px 10px;
    border-radius: 12px;
}

.recent-trades-list {
    max-height: 320px;
    overflow-y: auto;
    padding: 8px;
}

.recent-trade-item {
    background: #1a2235;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 8px;
    border-left: 3px solid #252d3d;
    transition: all 0.2s;
}

.recent-trade-item:last-child {
    margin-bottom: 0;
}

.recent-trade-item:hover {
    background: #1e2738;
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.recent-trade-item.win {
    border-left-color: #00d4aa;
}

.recent-trade-item.loss {
    border-left-color: #ef4444;
}

.trade-main {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.trade-symbol {
    font-weight: 600;
    color: #fff;
    font-size: 0.95rem;
}

.trade-direction {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.trade-direction.long {
    background: rgba(0, 212, 170, 0.15);
    color: #00d4aa;
}

.trade-direction.short {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.trade-date {
    font-size: 0.8rem;
    color: #6b7280;
    margin-left: auto;
}

.trade-details-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.trade-prices {
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: #9ca3af;
}

.entry-price, .exit-price {
    display: inline-block;
}

.trade-pnl {
    font-weight: 600;
    font-size: 0.9rem;
}

.trade-pnl.win {
    color: #00d4aa;
}

.trade-pnl.loss {
    color: #ef4444;
}

/* Scrollbar for recent trades */
.recent-trades-list::-webkit-scrollbar {
    width: 6px;
}

.recent-trades-list::-webkit-scrollbar-track {
    background: #1a2235;
}

.recent-trades-list::-webkit-scrollbar-thumb {
    background: #353d4d;
    border-radius: 3px;
}

.recent-trades-list::-webkit-scrollbar-thumb:hover {
    background: #454d5d;
}

/* ============================================
   OPTIMIZATION TAB
   ============================================ */

#tab-optimization {
    padding-bottom: 40px;
}

#tab-optimization h2 {
    color: #fff;
    margin-bottom: 8px;
}

.tab-description {
    color: #6b7280;
    font-size: 0.95rem;
    margin-bottom: 24px;
}

/* Optimization Summary Cards */
.optimization-summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

@media (max-width: 900px) {
    .optimization-summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

.opt-card {
    background: linear-gradient(145deg, #151b28, #1a2235);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #252d3d;
    display: flex;
    align-items: center;
    gap: 16px;
}

.opt-card-icon {
    font-size: 2rem;
    opacity: 0.8;
}

.opt-card-label {
    font-size: 0.8rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.opt-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
}

.opt-card-value.trend.positive {
    color: #00d4aa;
}

.opt-card-value.trend.negative {
    color: #ef4444;
}

/* Latest Optimization Section */
.optimization-latest {
    background: #151b28;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #252d3d;
    margin-bottom: 24px;
}

.optimization-latest h3 {
    color: #fff;
    margin-bottom: 20px;
    font-size: 1.1rem;
}

.latest-opt-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.latest-opt-section {
    background: #1a2235;
    border-radius: 10px;
    padding: 16px;
}

.opt-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.opt-section-header h4 {
    color: #9ca3af;
    font-size: 0.9rem;
    font-weight: 500;
}

.opt-status-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
}

.opt-status-badge.applied {
    background: rgba(0, 212, 170, 0.15);
    color: #00d4aa;
}

.opt-status-badge.rejected {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.opt-status-badge.pending {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

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

.opt-detail {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.opt-detail .label {
    font-size: 0.8rem;
    color: #6b7280;
}

.opt-detail .value {
    color: #e1e5eb;
    font-weight: 500;
}

.opt-detail.rejection .value {
    color: #ef4444;
}

/* Metrics Sections */
.latest-opt-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

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

.metrics-section {
    background: #1a2235;
    border-radius: 10px;
    padding: 16px;
    border: 1px solid #252d3d;
}

.metrics-section h4 {
    color: #9ca3af;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metrics-section.validation {
    border-color: #00d4aa;
    background: linear-gradient(145deg, #0d1f1a, #152520);
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #252d3d;
}

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

.metric-row.highlight {
    background: rgba(0, 212, 170, 0.05);
    margin: 0 -8px;
    padding: 8px;
    border-radius: 6px;
}

.metric-label {
    color: #6b7280;
    font-size: 0.85rem;
}

.metric-value {
    color: #fff;
    font-weight: 600;
}

.metric-value.good {
    color: #00d4aa;
}

.metric-value.warning {
    color: #fbbf24;
}

.metric-value.bad {
    color: #ef4444;
}

/* Parameters Section */
.latest-opt-params {
    background: #1a2235;
    border-radius: 10px;
    padding: 16px;
}

.latest-opt-params h4 {
    color: #9ca3af;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.param-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px;
    background: #151b28;
    border-radius: 6px;
}

.param-name {
    font-size: 0.75rem;
    color: #6b7280;
}

.param-value {
    color: #00d4aa;
    font-weight: 600;
    font-size: 1.1rem;
}

/* Optimization History Table */
.optimization-history {
    background: #151b28;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #252d3d;
    margin-bottom: 24px;
}

.optimization-history h3 {
    color: #fff;
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.opt-history-table {
    width: 100%;
    border-collapse: collapse;
}

.opt-history-table th {
    text-align: left;
    padding: 12px;
    color: #6b7280;
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #252d3d;
}

.opt-history-table td {
    padding: 12px;
    border-bottom: 1px solid #1e2738;
    color: #e1e5eb;
}

.opt-history-table tr:hover {
    background: #1a2235;
}

.opt-history-table tr.applied td:first-child {
    border-left: 3px solid #00d4aa;
}

.opt-history-table tr.rejected td:first-child {
    border-left: 3px solid #ef4444;
}

/* Optimization Chart Section */
.optimization-chart-section {
    background: #151b28;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #252d3d;
}

.optimization-chart-section h3 {
    color: #fff;
    margin-bottom: 16px;
    font-size: 1.1rem;
}

#optimization-chart {
    width: 100%;
    height: 200px;
}

/* ==========================================
   Recent Trades Tab Styles
   ========================================== */

.trades-tab-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    min-height: 600px;
}

.trades-table-section {
    background: linear-gradient(145deg, #151b28, #1a2235);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #252d3d;
    display: flex;
    flex-direction: column;
}

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

.trades-header h2 {
    color: #fff;
    font-size: 1.3rem;
    margin: 0;
}

.trades-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.trades-filters select {
    background: #1a2235;
    border: 1px solid #252d3d;
    color: #e1e5eb;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
}

.trades-filters select:hover {
    border-color: #00d4aa;
}

.trades-table-wrapper {
    flex: 1;
    overflow-y: auto;
    max-height: 450px;
}

.trades-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.trades-table thead {
    position: sticky;
    top: 0;
    background: #1a2235;
    z-index: 1;
}

.trades-table th {
    text-align: left;
    padding: 10px 8px;
    color: #9ca3af;
    font-weight: 500;
    border-bottom: 1px solid #252d3d;
    white-space: nowrap;
}

.trades-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #1e2738;
    color: #e1e5eb;
}

.trades-table tbody tr {
    cursor: pointer;
    transition: all 0.2s;
}

.trades-table tbody tr:hover {
    background: #1e2738;
}

.trades-table tbody tr.selected {
    background: #252d3d;
    box-shadow: inset 3px 0 0 #00d4aa;
}

.trades-table .direction-long {
    color: #00d4aa;
    font-weight: 600;
}

.trades-table .direction-short {
    color: #ef4444;
    font-weight: 600;
}

.trades-table .pnl-positive {
    color: #00d4aa;
    font-weight: 600;
}

.trades-table .pnl-negative {
    color: #ef4444;
    font-weight: 600;
}

.trades-table .result-win {
    background: rgba(0, 212, 170, 0.15);
    color: #00d4aa;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.trades-table .result-loss {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.trades-table .signal-source {
    color: #9ca3af;
    font-size: 0.8rem;
}

.trades-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #252d3d;
}

#trades-page-info {
    color: #9ca3af;
    font-size: 0.9rem;
}

.trades-chart-section {
    background: linear-gradient(145deg, #151b28, #1a2235);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #252d3d;
    display: flex;
    flex-direction: column;
}

.trades-chart-section .chart-header {
    margin-bottom: 12px;
}

.trades-chart-section .chart-header h3 {
    color: #fff;
    font-size: 1.1rem;
    margin: 0;
}

#trades-chart-container {
    flex: 1;
    min-height: 300px;
    background: #0d1117;
    border-radius: 8px;
}

.selected-trade-details {
    margin-top: 16px;
    padding: 16px;
    background: #1a2235;
    border-radius: 8px;
    border: 1px solid #252d3d;
}

.selected-trade-details h4 {
    color: #fff;
    font-size: 1rem;
    margin-bottom: 12px;
}

#selected-trade-info {
    color: #9ca3af;
    font-size: 0.9rem;
    line-height: 1.6;
}

#selected-trade-info .trade-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #252d3d;
}

#selected-trade-info .trade-detail-row:last-child {
    border-bottom: none;
}

#selected-trade-info .trade-detail-label {
    color: #6b7280;
}

#selected-trade-info .trade-detail-value {
    color: #e1e5eb;
    font-weight: 500;
}

/* Trades layout responsive handled in main media queries above */

/* ============================================
   Rankings Tab
   ============================================ */

.rankings-filter {
    display: flex;
    gap: 20px;
    align-items: center;
    padding: 10px 0;
    margin-bottom: 15px;
}

.rankings-filter label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #a0aec0;
    font-size: 14px;
}

.rankings-filter select {
    background: #1a2235;
    color: #e1e5eb;
    border: 1px solid #2d3748;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
}

.rankings-section {
    margin-bottom: 30px;
}

.rankings-section h3 {
    color: #e1e5eb;
    margin-bottom: 10px;
    font-size: 16px;
    border-bottom: 1px solid #2d3748;
    padding-bottom: 8px;
}

.rankings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.rankings-table thead th {
    background: #1a2235;
    color: #a0aec0;
    padding: 8px 6px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 1;
    white-space: nowrap;
}

.rankings-table tbody td {
    padding: 6px;
    border-bottom: 1px solid #1a2235;
    color: #cbd5e0;
    white-space: nowrap;
}

.rankings-table tbody tr:hover {
    background: #1a2235;
}

.rankings-table tbody tr.live-row {
    background: rgba(0, 210, 106, 0.05);
}

.rankings-table tbody tr.live-row:hover {
    background: rgba(0, 210, 106, 0.1);
}

.live-badge {
    display: inline-block;
    background: #00d26a;
    color: #000;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    vertical-align: middle;
}

.wr-high { color: #00d26a; font-weight: 600; }
.wr-mid { color: #f6c343; font-weight: 500; }
.wr-low { color: #ff6b6b; }

.pf-high { color: #00d26a; font-weight: 600; }
.pf-mid { color: #f6c343; }
.pf-low { color: #ff6b6b; }

.positive { color: #00d26a; }
.negative { color: #ff6b6b; }

.tickers-cell {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
    color: #8899aa;
}

.notes-cell {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
    color: #8899aa;
}

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

.tab-header h2 {
    margin: 0;
}

@media (max-width: 768px) {
    .rankings-table {
        font-size: 10px;
    }
    .rankings-table thead th,
    .rankings-table tbody td {
        padding: 4px 3px;
    }
    .rankings-filter {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* ============================================
   SEASONALITY TAB
   ============================================ */

#tab-seasonality {
    padding-bottom: 40px;
}

#tab-seasonality h2 {
    color: #fff;
    margin-bottom: 8px;
}

/* Controls */
.seasonality-controls {
    display: flex;
    gap: 20px;
    align-items: center;
    padding: 16px 24px;
    background: #151b28;
    border-radius: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.seasonality-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #9ca3af;
}

.seasonality-controls select {
    background: #1a2235;
    border: 1px solid #252d3d;
    color: #e1e5eb;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
}

.seasonality-controls select:hover {
    border-color: #00d4aa;
}

/* Summary Cards */
.seasonality-summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.season-card {
    background: linear-gradient(145deg, #151b28, #1a2235);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #252d3d;
    text-align: center;
}

.season-card-label {
    font-size: 0.8rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.season-card-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
}

/* Degradation Alerts */
.degradation-alerts {
    background: #151b28;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #ef444440;
    margin-bottom: 24px;
}

.degradation-alerts h3 {
    color: #ef4444;
    margin-bottom: 12px;
    font-size: 1rem;
}

.degradation-alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.degradation-alert:last-child {
    margin-bottom: 0;
}

.degradation-alert.alert-high {
    background: rgba(239, 68, 68, 0.15);
    border-left: 3px solid #ef4444;
}

.degradation-alert.alert-medium {
    background: rgba(251, 191, 36, 0.1);
    border-left: 3px solid #fbbf24;
}

.degradation-alert.alert-low {
    background: rgba(107, 114, 128, 0.1);
    border-left: 3px solid #6b7280;
}

.alert-icon {
    font-weight: 700;
    font-size: 0.8rem;
    min-width: 30px;
}

.alert-high .alert-icon { color: #ef4444; }
.alert-medium .alert-icon { color: #fbbf24; }
.alert-low .alert-icon { color: #6b7280; }

.alert-period {
    color: #e1e5eb;
    font-weight: 600;
    min-width: 80px;
}

.alert-message {
    color: #9ca3af;
}

/* Chi-Square Section */
.chi-square-section {
    background: #151b28;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #252d3d;
    margin-bottom: 24px;
}

.chi-square-section h3 {
    color: #fff;
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.chi-square-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.chi-card {
    background: #1a2235;
    border-radius: 10px;
    padding: 16px;
    border: 1px solid #252d3d;
}

.chi-card.significant {
    border-color: #00d4aa;
    background: linear-gradient(145deg, #0d1f1a, #152520);
}

.chi-card.not-significant {
    border-color: #374151;
}

.chi-card-label {
    font-size: 0.85rem;
    color: #9ca3af;
    font-weight: 600;
    margin-bottom: 8px;
}

.chi-card-stat {
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 4px;
}

.chi-card-pvalue {
    font-size: 0.85rem;
    color: #e1e5eb;
    font-weight: 500;
    margin-bottom: 8px;
}

.chi-card-verdict {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 4px;
    display: inline-block;
}

.chi-card-verdict.sig {
    background: rgba(0, 212, 170, 0.15);
    color: #00d4aa;
}

.chi-card-verdict.not-sig {
    background: rgba(107, 114, 128, 0.15);
    color: #6b7280;
}

/* Heatmap Section */
.seasonality-heatmap-section {
    background: #151b28;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #252d3d;
    margin-bottom: 24px;
}

.seasonality-heatmap-section h3 {
    color: #fff;
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.heatmap-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.heatmap-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    min-width: 600px;
}

.heatmap-table th {
    padding: 8px 6px;
    color: #6b7280;
    font-weight: 500;
    font-size: 0.7rem;
    text-align: center;
    border-bottom: 1px solid #252d3d;
}

.heatmap-row-label {
    color: #9ca3af;
    font-weight: 600;
    padding: 8px 10px;
    text-align: left;
    white-space: nowrap;
}

.heatmap-cell {
    text-align: center;
    padding: 8px 4px;
    border-radius: 4px;
    cursor: default;
    position: relative;
    min-width: 50px;
}

.heatmap-cell.empty {
    color: #374151;
    background: transparent;
}

.heatmap-val {
    display: block;
    font-weight: 600;
    color: #fff;
    font-size: 0.75rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.heatmap-count {
    display: block;
    font-size: 0.6rem;
    color: rgba(255,255,255,0.6);
    margin-top: 2px;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    justify-content: center;
}

.legend-gradient {
    width: 150px;
    height: 12px;
    border-radius: 6px;
}

.legend-label {
    font-size: 0.75rem;
    color: #6b7280;
}

/* Bar Chart Sections */
.seasonality-bar-section {
    background: #151b28;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #252d3d;
    margin-bottom: 24px;
}

.seasonality-bar-section h3 {
    color: #fff;
    margin-bottom: 16px;
    font-size: 1.1rem;
}

.bar-chart-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bar-label {
    min-width: 50px;
    font-size: 0.85rem;
    color: #9ca3af;
    font-weight: 500;
    text-align: right;
}

.bar-track {
    flex: 1;
    height: 24px;
    background: #1a2235;
    border-radius: 4px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}

.bar-fill.bar-positive {
    background: linear-gradient(90deg, #00d4aa, #00d4aa99);
}

.bar-fill.bar-negative {
    background: linear-gradient(90deg, #ef4444, #ef444499);
}

.bar-value {
    min-width: 60px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #e1e5eb;
    text-align: right;
}

.bar-trades {
    min-width: 35px;
    font-size: 0.75rem;
    color: #6b7280;
    text-align: right;
}

/* Rolling Table Section */
.seasonality-rolling-section {
    background: #151b28;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #252d3d;
    margin-bottom: 24px;
}

.seasonality-rolling-section h3 {
    color: #fff;
    margin-bottom: 16px;
    font-size: 1.1rem;
}

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

.rolling-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.rolling-table th {
    text-align: left;
    padding: 10px 12px;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #252d3d;
}

.rolling-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #1e2738;
    color: #e1e5eb;
}

.rolling-table tbody tr:hover {
    background: rgba(0, 212, 170, 0.05);
}

.rolling-table .pnl-positive {
    color: #00d4aa;
    font-weight: 600;
}

.rolling-table .pnl-negative {
    color: #ef4444;
    font-weight: 600;
}

/* Responsive Seasonality */
@media (max-width: 900px) {
    .seasonality-summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .seasonality-summary-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .seasonality-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .seasonality-controls select {
        width: 100%;
        min-height: 44px;
    }

    .chi-square-grid {
        grid-template-columns: 1fr;
    }

    .heatmap-table {
        font-size: 0.7rem;
    }

    .heatmap-cell {
        min-width: 40px;
        padding: 6px 2px;
    }

    .bar-label {
        min-width: 40px;
        font-size: 0.8rem;
    }

    .seasonality-bar-section,
    .seasonality-heatmap-section,
    .seasonality-rolling-section,
    .chi-square-section {
        padding: 16px;
    }

    .rolling-table {
        min-width: 600px;
    }
}

@media (max-width: 480px) {
    .seasonality-summary-cards {
        grid-template-columns: 1fr;
    }

    .season-card {
        padding: 14px;
    }

    .season-card-value {
        font-size: 1.2rem;
    }
}
