* {
    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;
}

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

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

@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;
    }
}

/* 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;
    margin-bottom: 30px;
    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;
}

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

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