/* Modern Dashboard Styles */
:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-card: #1f1f1f;
    --bg-hover: #2a2a2a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --accent-primary: #3b82f6;
    --accent-success: #22c55e;
    --accent-danger: #ef4444;
    --accent-warning: #f59e0b;
    --border-color: #2d2d2d;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --primary: #3b82f6;
    --chart-grid: #2a2a2a;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(180deg, #0f0f0f 0%, #1a1a1a 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* Header */
.header {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo img {
    height: 32px;
    width: auto;
}

.header h1, .header-logo h1 {
    font-size: 20px;
    font-weight: 600;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.header .btn-primary {
    padding: 8px 16px;
    height: 34px;
    font-size: 13px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.header .btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.btn-dark {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0;
    width: 34px;
    height: 34px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-dark:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--bg-secondary);
    border-radius: 17px;
    border: 1px solid var(--border-color);
    height: 34px;
    font-size: 12px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background: var(--accent-success);
}

.status-dot.error {
    background: var(--accent-danger);
}

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

/* Header Links */
.header-links {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 8px;
}

.header-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
}

.header-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
}

.header-link svg {
    width: 18px;
    height: 18px;
}

.header-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 4px;
}


/* Focused Dashboard Layout */
.dashboard-layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
}

.card h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.stat-item {
    display: block;
    position: relative;
}

.stat-item label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: block;
}

.stat-value {
    font-size: 20px;
    font-weight: 600;
    display: inline-block;
}

.stat-value.positive {
    color: var(--success);
}

.stat-value.negative {
    color: var(--danger);
}

.stat-percent {
    font-size: 12px;
    font-weight: 500;
    margin-left: 4px;
    padding: 1px 3px;
    border-radius: 4px;
    background-color: transparent;
    display: inline-block;
}

.stat-percent.positive {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
}

.stat-percent.negative {
    color: var(--danger);
    background-color: rgba(235, 87, 87, 0.1);
}

/* General Positive/Negative Values */
.positive {
    color: var(--accent-success);
    font-weight: 500;
}

.negative {
    color: var(--accent-danger);
    font-weight: 500;
}

/* Specific Table Styles */

/* Positions Table */
#positions-table {
    min-width: 1200px;
}

#positions-table th:nth-child(1) { min-width: 100px; } /* Symbol */
#positions-table th:nth-child(2) { min-width: 60px; }  /* Side */
#positions-table th:nth-child(3) { min-width: 100px; } /* Quantity */
#positions-table th:nth-child(4) { min-width: 100px; } /* Entry Price */
#positions-table th:nth-child(5) { min-width: 100px; } /* Mark Price */
#positions-table th:nth-child(6) { min-width: 100px; } /* Liq. Price */
#positions-table th:nth-child(7) { min-width: 140px; }  /* TP */
#positions-table th:nth-child(8) { min-width: 100px; }  /* SL */
#positions-table th:nth-child(9) { min-width: 100px; } /* PNL */
#positions-table th:nth-child(10) { min-width: 80px; }  /* PNL % */
#positions-table th:nth-child(11) { min-width: 100px; } /* Margin */
#positions-table th:nth-child(12) { min-width: 80px; }  /* Leverage */

/* Symbol Performance Table */
#symbol-performance-table {
    min-width: 700px;
}

#symbol-performance-table th:nth-child(1) { min-width: 100px; } /* Symbol */
#symbol-performance-table th:nth-child(2) { min-width: 120px; } /* Total PNL */
#symbol-performance-table th:nth-child(3) { min-width: 120px; } /* Realized PNL */
#symbol-performance-table th:nth-child(4) { min-width: 100px; } /* Fees */
#symbol-performance-table th:nth-child(5) { min-width: 80px; }  /* Trades */
#symbol-performance-table th:nth-child(6) { min-width: 100px; } /* Win Rate */

/* Trades Table */
#trades-table {
    min-width: 1000px;
}

#trades-table tbody tr {
    cursor: pointer;
}

#trades-table tbody tr:hover {
    background: var(--bg-hover);
}

#trades-table th:nth-child(1) { min-width: 150px; } /* Time */
#trades-table th:nth-child(2) { min-width: 100px; } /* Symbol */
#trades-table th:nth-child(3) { min-width: 60px; }  /* Side */
#trades-table th:nth-child(4) { min-width: 100px; } /* Quantity */
#trades-table th:nth-child(5) { min-width: 100px; } /* Price */
#trades-table th:nth-child(6) { min-width: 100px; } /* PnL */
#trades-table th:nth-child(7) { min-width: 100px; } /* Commission */
#trades-table th:nth-child(8) { min-width: 100px; } /* Net PNL */
#trades-table th:nth-child(9) { min-width: 80px; }  /* Status */
#trades-table th:nth-child(10) { min-width: 100px; } /* Order Type */

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-card);
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    overflow: hidden;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    background: var(--bg-secondary);
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    color: var(--text-secondary);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
    max-height: calc(85vh - 80px);
}

/* Trade Details Styles */
.trade-details {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.trade-info, .pnl-breakdown, .related-trades, .income-details {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.trade-info h4, .pnl-breakdown h4, .related-trades h4, .income-details h4 {
    color: var(--accent-primary);
    margin-bottom: 15px;
    font-size: 16px;
    font-weight: 600;
}

/* Position Details Styles */
.position-details {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.position-details h4 {
    color: var(--accent-primary);
    margin-bottom: 15px;
    font-size: 16px;
    font-weight: 600;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.summary-item .label {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-item .value {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

.tranches-table, .orders-table, .trades-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.tranches-table thead, .orders-table thead, .trades-table thead {
    background: var(--bg-secondary);
}

.tranches-table th, .orders-table th, .trades-table th,
.tranches-table td, .orders-table td, .trades-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.tranches-table tbody tr:hover, .orders-table tbody tr:hover, .trades-table tbody tr:hover {
    background: var(--bg-hover);
}

/* Order Status Styles */
.order-status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-block;
}

.order-status.new {
    background: rgba(59, 130, 246, 0.2);
    color: var(--accent-primary);
}

.order-status.filled {
    background: rgba(34, 197, 94, 0.2);
    color: var(--accent-success);
}

.order-status.canceled, .order-status.cancelled {
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-danger);
}

.order-status.expired {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent-warning);
}

.order-status.pending {
    background: rgba(160, 160, 160, 0.2);
    color: var(--text-secondary);
}

/* Order Type Styles */
.order-type-tp {
    color: var(--accent-success);
    font-weight: 600;
}

.order-type-sl {
    color: var(--accent-danger);
    font-weight: 600;
}

.order-id {
    font-family: monospace;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Position row hover effect */
#positions-tbody tr:hover {
    background: var(--bg-hover);
    transition: background 0.2s ease;
}

.info-grid, .pnl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.info-item, .pnl-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.info-item label, .pnl-item label {
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-item span, .pnl-item span {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
}

.pnl-item span {
    font-family: 'Courier New', monospace;
}

.related-trades-table, .income-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.related-trades-table thead, .income-table thead {
    background: var(--bg-primary);
}

.related-trades-table th, .income-table th {
    padding: 10px;
    text-align: left;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.related-trades-table td, .income-table td {
    padding: 10px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(45, 45, 45, 0.5);
}

.related-trades-table tr:last-child td, .income-table tr:last-child td {
    border-bottom: none;
}

/* PNL Badge Styles */
.pnl-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.pnl-badge.positive {
    background: rgba(34, 197, 94, 0.1);
    color: var(--accent-success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.pnl-badge.negative {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Tranche PNL colors */
.tranches-table td.profit {
    color: var(--accent-success);
    font-weight: 600;
}

.tranches-table td.loss {
    color: var(--accent-danger);
    font-weight: 600;
}

/* Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
    display: flex;
    justify-content: center;
}

table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: auto;
    margin: 0 auto;
}

thead {
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    padding: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    white-space: nowrap;
}

/* Numeric column headers - right align */
th:nth-child(n+3) {
    text-align: right;
}

/* First two columns usually text - left align */
th:nth-child(1),
th:nth-child(2) {
    text-align: left;
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

/* Handle text overflow properly */
td {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Symbol and text columns can be wider */
td:nth-child(1),
td:nth-child(2) {
    max-width: 150px;
    text-align: left;
}

/* Numeric columns */
td:nth-child(n+3) {
    text-align: right;
    font-family: 'Courier New', monospace;
    min-width: 80px;
}

tbody tr {
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background: rgba(59, 130, 246, 0.1);
}

.no-data {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    width: 100%;
    display: block;
}

/* Position-specific styling */
.position-long {
    color: var(--success);
}

.position-short {
    color: var(--danger);
}

/* Liquidation Price Warnings */
.liquidation-warning {
    color: var(--danger);
    font-weight: 700;
    animation: pulse-danger 1.5s infinite;
}

.liquidation-caution {
    color: var(--warning);
    font-weight: 600;
}

@keyframes pulse-danger {
    0%, 100% {
        opacity: 1;
        text-shadow: 0 0 5px rgba(239, 68, 68, 0.5);
    }
    50% {
        opacity: 0.8;
        text-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
    }
}

/* TP/SL Price Indicators */
.tp-price {
    color: var(--success);
    font-weight: 600;
}

.tp-price.tp-near {
    color: var(--success);
    font-weight: 700;
    animation: pulse-success 1s infinite;
}

.tp-distance {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 400;
    margin-left: 4px;
}

.tp-near .tp-distance {
    color: var(--success);
    font-weight: 600;
}

.sl-price {
    color: var(--danger);
    font-weight: 600;
}

.sl-price.sl-near {
    color: var(--danger);
    font-weight: 700;
    animation: pulse-danger 1s infinite;
}

@keyframes pulse-success {
    0%, 100% {
        opacity: 1;
        text-shadow: 0 0 5px rgba(34, 197, 94, 0.5);
    }
    50% {
        opacity: 0.8;
        text-shadow: 0 0 10px rgba(34, 197, 94, 0.8);
    }
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #2563eb);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

/* Configuration Section */
.config-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.tab-content {
    display: none;
}

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

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.config-item {
    display: flex;
    flex-direction: column;
}

.config-item label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.config-input {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 4px;
    font-size: 14px;
}

.config-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Chart Container */
.chart-container {
    grid-column: span 2;
}

#volume-chart {
    max-height: 300px;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--primary);
    padding: 12px 16px;
    margin-bottom: 10px;
    border-radius: 4px;
    min-width: 300px;
    animation: slideIn 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.warning {
    border-left-color: var(--warning);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-close {
    cursor: pointer;
    color: var(--text-secondary);
    margin-left: 15px;
}

/* Large Cards - Full Width */
.positions-section,
.liquidations-section,
.trades-section,
.symbol-performance,
.config-section,
.pnl-section {
    grid-column: 1 / -1;
}

/* PNL and Account Summary cards */
.account-summary,
.pnl-summary,
.trading-stats {
    min-height: 180px;
}

/* Chart containers */
.chart-container {
    grid-column: span 2;
    min-height: 300px;
}

.chart-container canvas {
    max-height: 280px !important;
}

/* Responsive adjustments */
@media (max-width: 1400px) {
    .chart-container {
        grid-column: span 1;
    }
}

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

    .chart-container,
    .positions-section,
    .liquidations-section,
    .trades-section,
    .symbol-performance,
    .config-section {
        grid-column: span 1;
    }

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

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

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

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

/* Loading indicator */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Loading spinner */
.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--text-muted);
    border-top: 2px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Last updated timestamp */
.last-updated {
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.8;
    margin-left: 5px;
}

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

/* Status badges */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.badge-info {
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary);
}

/* Symbol Management */
.symbol-manager {
    padding: 10px 0;
}

.available-symbols-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

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

.symbol-card:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.symbol-card.configured {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--success);
}

.symbol-name {
    font-weight: 500;
    color: var(--text-primary);
}

.symbol-base {
    font-size: 12px;
    color: var(--text-secondary);
}

.symbol-actions {
    display: flex;
    gap: 5px;
}

.btn-small {
    padding: 4px 8px;
    font-size: 12px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add {
    background: var(--success);
    color: white;
}

.btn-add:hover {
    background: #059669;
}

.btn-configured {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: default;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.symbol-search-container {
    margin-bottom: 15px;
}

/* Account & Performance Overview Styles */
.account-performance-overview .card {
    min-height: 400px;
    padding: 25px;
    background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-secondary) 100%);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    animation: cardFadeIn 0.5s ease-out;
}

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

.overview-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border-color);
}

.overview-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 5px 0;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.overview-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    opacity: 0.8;
}

.overview-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Section Titles */
.section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 40px;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-success));
    border-radius: 1px;
}

/* Combined Sections - Clean and Uniform */
.balance-section,
.pnl-metrics-section {
    padding: 15px;
}

.balance-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.pnl-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.metric-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    min-height: 120px;
}

.metric-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.metric-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    margin-bottom: 8px;
    line-height: 1;
}

.metric-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    text-align: center;
}

.metric-change,
.metric-percent {
    font-size: 12px;
    font-weight: 600;
    margin-top: 4px;
    text-align: center;
}

.metric-percent.positive {
    color: var(--accent-success);
}

.metric-percent.negative {
    color: var(--accent-danger);
}



/* PNL Chart Specific */
.pnl-chart {
    max-height: 400px;
}

.pnl-chart canvas {
    max-height: 320px !important;
    width: 100% !important;
    height: auto !important;
}

/* PNL Section */
.pnl-section {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 25px;
}

.pnl-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-height: 100px;
}

.pnl-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--accent-success);
    transition: all 0.3s ease;
}

.pnl-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: var(--accent-success);
}

.pnl-item.primary::before {
    background: var(--accent-primary);
}

.pnl-item.success::before {
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-success));
}

.pnl-item.info::before {
    background: var(--accent-warning);
}

.pnl-item.neutral::before {
    background: var(--accent-info);
}

.pnl-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-align: center;
}

.pnl-content label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pnl-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    line-height: 1.2;
}

.pnl-percent {
    font-size: 13px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
}

.pnl-percent.positive {
    color: var(--accent-success);
    background: rgba(34, 197, 94, 0.15);
}

.pnl-percent.negative {
    color: var(--accent-danger);
    background: rgba(239, 68, 68, 0.15);
}

.pnl-trend {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 2px;
}

.pnl-trend.up {
    color: var(--accent-success);
}

.pnl-trend.down {
    color: var(--accent-danger);
}

.win-rate-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-primary);
    width: fit-content;
}

.win-rate-badge.excellent {
    background: rgba(34, 197, 94, 0.2);
    color: var(--accent-success);
}

.win-rate-badge.good {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent-warning);
}

.win-rate-badge.poor {
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-danger);
}

.trades-indicator {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Enhanced visual hierarchy for positive/negative values */
.positive {
    color: var(--accent-success) !important;
}

.negative {
    color: var(--accent-danger) !important;
}

/* Legacy balance styles (kept for backward compatibility) */
.balance-overview .card {
    min-height: 200px;
}

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

.old-balance-item {
    display: flex;
    flex-direction: column;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.old-balance-item label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.old-balance-value {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

.old-balance-value.positive {
    color: var(--accent-success);
}

.old-balance-value.negative {
    color: var(--accent-danger);
}

/* PNL Section */
.pnl-slice,
.pnl-analytics {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}


.pnl-trades-section .card {
    max-height: 400px;
    overflow: hidden;
}

.pnl-trades-section .table-container {
    max-height: 300px;
    overflow-y: auto;
}

/* Settings Section */
.settings-section .card {
    min-height: auto;
}

/* Settings button now handled by .btn-dark class */

/* Minimum Notional Modal Styles */
#min-notional-modal .modal-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
}

#min-notional-modal .modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#min-notional-modal .modal-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 20px;
}

#min-notional-modal .warning-text {
    color: var(--warning);
    margin-bottom: 20px;
    font-size: 14px;
}

#min-notional-modal .issues-container {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
}

#min-notional-modal .issue-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 15px;
    align-items: center;
}

#min-notional-modal .issue-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#min-notional-modal .symbol-name {
    font-size: 16px;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 5px;
}

#min-notional-modal .issue-info {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

#min-notional-modal .issue-label {
    color: var(--text-muted);
    text-align: right;
}

#min-notional-modal .issue-value {
    color: var(--text-primary);
}

#min-notional-modal .issue-value.error {
    color: var(--danger);
}

#min-notional-modal .issue-value.success {
    color: var(--success);
}

#min-notional-modal .fix-btn {
    background: var(--success);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.3s;
    white-space: nowrap;
}

#min-notional-modal .fix-btn:hover {
    background: #45a049;
}

#min-notional-modal .fix-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.6;
}

#min-notional-modal .modal-actions {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

#min-notional-modal .btn {
    padding: 10px 24px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

#min-notional-modal .btn-primary {
    background: var(--primary);
    color: white;
}

#min-notional-modal .btn-primary:hover {
    background: #0056b3;
}

#min-notional-modal .btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

#min-notional-modal .btn-secondary:hover {
    background: var(--bg-primary);
}

/* Responsive Updates */
@media (max-width: 768px) {
    /* Header responsive adjustments */
    .header {
        padding: 12px 15px;
    }

    .header h1 {
        font-size: 16px;
    }

    .header-right {
        gap: 6px;
    }

    .btn-dark {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }

    .header .btn-primary {
        height: 30px;
        padding: 6px 12px;
        font-size: 12px;
    }

    .status-indicator {
        height: 30px;
        padding: 5px 10px;
        font-size: 11px;
    }

    .last-updated {
        display: none; /* Hide on mobile to save space */
    }

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

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

    /* Make balance and pnl items stack on mobile */
    .balance-item {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    .pnl-item {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    .balance-content,
    .pnl-content {
        align-items: center;
    }

    /* Adjust section padding on mobile */
    .balance-section,
    .pnl-section {
        padding: 15px;
    }

    .overview-content {
        gap: 20px;
    }

    /* Stack divider on mobile */
    .section-divider {
        flex-direction: column;
        gap: 8px;
    }

    .account-performance-overview .card {
        padding: 15px;
    }

    .pnl-section .card {
        grid-column: span 1;
    }

    #min-notional-modal .issue-item {
        grid-template-columns: 1fr;
    }

    #min-notional-modal .fix-btn {
        width: 100%;
    }
}

/* Tablet responsive adjustments */
@media (max-width: 1024px) {
    .balance-grid,
    .pnl-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }

    .account-performance-overview .card {
        padding: 20px;
    }

    .overview-content {
        gap: 25px;
    }
}

/* ============================================
   Clickable Position Rows
   ============================================ */

/* Make position rows clickable with visual feedback */
.position-row.clickable-row {
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    position: relative;
}

.position-row.clickable-row:hover {
    background-color: rgba(139, 92, 246, 0.05);
}

/* Add a subtle left border on hover */
.position-row.clickable-row:hover td:first-child {
    border-left: 3px solid var(--purple);
    padding-left: 12px;
    transition: all 0.2s ease;
}

/* Ensure close button remains functional and prominent */
.position-row .close-position-btn {
    position: relative;
    z-index: 2;
    transition: all 0.2s ease;
}

.position-row .close-position-btn:hover {
    transform: scale(1.05);
}

/* Visual tooltip on hover (shows after brief delay) */
.position-row.clickable-row:hover::after {
    content: 'Click to view tranches & orders';
    position: absolute;
    left: 50%;
    bottom: -25px;
    transform: translateX(-50%);
    background: rgba(139, 92, 246, 0.9);
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    animation: tooltipFadeIn 0.3s ease forwards;
    animation-delay: 0.8s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

@keyframes tooltipFadeIn {
    to {
        opacity: 1;
        bottom: -20px;
    }
}

/* ============================================
   Enhanced Position Details Modal
   ============================================ */

/* Tranche table styling in modal */
.position-details .tranches-table {
    width: 100%;
    margin-top: 15px;
    border-collapse: collapse;
}

.position-details .tranches-table th {
    background: rgba(139, 92, 246, 0.1);
    color: var(--text-primary);
    padding: 10px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--purple);
}

.position-details .tranches-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Tranche ID styling */
.position-details .tranches-table td:first-child {
    font-weight: bold;
    color: var(--purple);
}

/* PNL coloring in tranches */
.position-details .profit {
    color: #10b981;
    font-weight: bold;
}

.position-details .loss {
    color: #ef4444;
    font-weight: bold;
}

/* Order status badges in modal */
.position-details .order-status {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-block;
}

/* Order prices in tranches table */
.position-details .order-price {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: block;
    margin-bottom: 2px;
}

/* Small status badges under prices */
.position-details .order-status-small {
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-block;
    margin-top: 2px;
}

.position-details .order-status.new,
.position-details .order-status.pending,
.position-details .order-status-small.new,
.position-details .order-status-small.pending {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.position-details .order-status.filled,
.position-details .order-status-small.filled {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.position-details .order-status.canceled,
.position-details .order-status-small.canceled {
    background: rgba(156, 163, 175, 0.2);
    color: #9ca3af;
    border: 1px solid rgba(156, 163, 175, 0.3);
}

/* Summary grid styling */
.position-details .summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

.position-details .summary-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.position-details .summary-item .label {
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.position-details .summary-item .value {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

.position-details .summary-item .value.positive {
    color: #10b981;
}

.position-details .summary-item .value.negative {
    color: #ef4444;
}

/* Section headers in modal */
.position-details h4 {
    color: var(--purple);
    margin-top: 25px;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.3);
    font-size: 16px;
    font-weight: 600;
}

/* Orders table in modal */
    .position-details .orders-table {
        width: 100%;
        margin-top: 10px;
    }

    .position-details .order-type-tp {
        color: #10b981;
        font-weight: bold;
    }

    .position-details .order-type-sl {
        color: #ef4444;
        font-weight: bold;
    }

/* Trade Controls Styles */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 15px 20px 15px 20px;
    background: var(--bg-secondary);
    border-radius: 8px 8px 0 0;
    border-bottom: 1px solid var(--border-color);
}

.trade-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.time-filter {
    padding: 6px 12px;
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    font-size: 13px;
    cursor: pointer;
    min-width: 140px;
    transition: all 0.2s ease;
}

.time-filter:hover {
    border-color: var(--accent-primary);
}

.time-filter:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.2);
}

.trade-count {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    padding: 4px 0;
}

.last-update {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: 4px;
    opacity: 0.8;
}

/* Responsive trade controls */
@media (max-width: 768px) {
    .trade-controls {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }

    .time-filter {
        width: 100%;
        min-width: auto;
    }

    .card-header {
        flex-direction: column;
        gap: 10px;
        padding: 15px;
    }

    .trade-count,
    .last-update {
        font-size: 12px;
    }
}

/* Ensure proper spacing for trades section */
.card.recent-trades .card-header {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.card.recent-trades .card-header + .table-container {
    margin-top: 15px;
}

/* Responsive adjustments for modal */
@media (max-width: 768px) {
    .position-details .summary-grid {
        grid-template-columns: 1fr;
    }

    .position-details .tranches-table {
        font-size: 12px;
    }

    .position-details .tranches-table th,
    .position-details .tranches-table td {
        padding: 6px;
    }
}
