* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
}

@media (max-width: 768px) {
    body {
        padding: 5px;
    }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 20px;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
        border-radius: 5px;
    }
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 16px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    position: relative;
    border-bottom: 2px solid #667eea;
}

header h1 {
    color: #333;
    font-size: 28px;
    margin: 0;
    flex: 1 1 200px;
    min-width: 0;
    line-height: 1.25;
}

/* Khối nút bên phải: không bị co / đè bởi tiêu đề dài */
header .main-header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: auto;
}

/* Chỉ link .btn là con trực tiếp của header (nếu có) mới absolute — không áp vào nút trong .main-header-actions */
header > a.btn { position: absolute; right: 0; }

@media (max-width: 768px) {
    header {
        margin-bottom: 15px;
        padding-bottom: 10px;
    }
    
    header h1 {
        font-size: 20px;
        flex-basis: 100%;
    }

    header .main-header-actions {
        margin-left: 0;
        width: 100%;
        justify-content: flex-start;
    }
}

/* ===== XAUUSD Price Bar ===== */
.xau-price-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 1px solid #d4af37;
    border-radius: 8px;
    padding: 10px 20px;
    margin-bottom: 16px;
    color: #fff;
}
.xau-price-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}
.xau-label {
    font-weight: 700;
    font-size: 16px;
    color: #d4af37;
    letter-spacing: 1px;
}
.xau-bid, .xau-ask, .xau-spread {
    font-size: 14px;
    color: #cbd5e0;
}
.xau-bid strong { color: #48bb78; font-size: 16px; }
.xau-ask strong { color: #fc8181; font-size: 16px; }
.xau-spread strong { color: #a0aec0; font-size: 15px; }
.xau-price-right { font-size: 12px; color: #718096; }

@media (max-width: 768px) {
    .xau-price-bar { flex-direction: column; gap: 6px; padding: 8px 12px; }
    .xau-price-left { gap: 12px; }
}

/* ===== Accounts Panel (full width) ===== */
.accounts-panel { margin-bottom: 20px; }
.accounts-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}
.accounts-panel-header h2 { margin-bottom: 0; }
.accounts-panel-header .account-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.account-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 10px;
}

@media (max-width: 768px) {
    .account-list {
        grid-template-columns: 1fr;
    }
}

.main-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 15px;
        margin-bottom: 20px;
    }
}

.panel {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #dee2e6;
}

.panel h2 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 20px;
}

@media (max-width: 768px) {
    .panel {
        padding: 15px;
    }
    
    .panel h2 {
        font-size: 18px;
        margin-bottom: 10px;
    }
}

.account-controls {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.account-item {
    background: white;
    padding: 12px;
    border-radius: 5px;
    border: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.account-item.connected {
    border-color: #28a745;
    background: #d4edda;
}

.account-item.disconnected {
    border-color: #dc3545;
    background: #f8d7da;
}

.account-info {
    flex: 1;
}

.account-name {
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.account-details {
    font-size: 12px;
    color: #666;
}

.account-actions {
    display: flex;
    gap: 5px;
}

.trading-inputs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 15px;
}

.symbol-lot-sl-tp-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .symbol-lot-sl-tp-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .form-group-inline {
        flex-direction: column;
        align-items: stretch;
        min-width: 100%;
    }
    
    .form-group-inline label {
        min-width: auto;
        margin-bottom: 5px;
    }
    
    .input-small {
        width: 100%;
        min-width: 100%;
    }
}

.form-group-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 150px;
}

.form-group-inline label {
    min-width: 45px;
    font-weight: 600;
    color: #495057;
    font-size: 14px;
    white-space: nowrap;
}

.input-small {
    flex: 1;
    min-width: 100px;
    padding: 6px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.input-compact {
    width: 110px;
    padding: 6px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.sl-tp-inputs .form-group-inline {
    min-width: auto;
    flex: 0 0 auto;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.form-group input,
.form-group select {
    padding: 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

@media (max-width: 768px) {
    .form-group input,
    .form-group select {
        padding: 12px;
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
    }
}

.form-group.symbol-lot-sl-tp-row {
    flex-direction: row;
    align-items: flex-end;
}

.price-display {
    grid-column: 1 / -1;
    display: flex;
    gap: 15px;
    align-items: center;
    padding: 10px;
    background: #e9ecef;
    border-radius: 5px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .price-display {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 12px;
    }
    
    .price-display span {
        display: flex;
        justify-content: space-between;
        padding: 5px 0;
    }
}

.price-display span {
    font-weight: 600;
}

#bidPrice {
    color: #dc3545;
}

#askPrice {
    color: #28a745;
}

.trading-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .trading-buttons {
        flex-direction: column;
        gap: 8px;
    }
    
    .trading-buttons .btn {
        width: 100%;
    }
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
    .btn {
        padding: 12px 16px;
        font-size: 16px;
        min-height: 44px; /* Minimum touch target size */
    }
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-warning {
    background: #ffc107;
    color: #333;
}

.btn-info {
    background: #17a2b8;
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-small {
    padding: 5px 10px;
    font-size: 12px;
}
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }

@media (max-width: 768px) {
    .btn-small {
        padding: 8px 12px;
        font-size: 14px;
        min-height: 36px;
    }
}

.sl-tp-controls,
.trend-panel {
    background: white;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 15px;
    border: 1px solid #dee2e6;
}

.sl-tp-controls h3,
.trend-panel h3 {
    margin-bottom: 10px;
    color: #495057;
    font-size: 16px;
}

.trend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.trend-header h3 {
    margin: 0;
}

.trend-controls {
    margin-bottom: 10px;
}

.trend-controls .form-group-inline {
    min-width: auto;
    flex: 0 0 auto;
}

.trend-results-container {
    margin-top: 10px;
}

.sl-tp-inputs {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.sl-tp-inputs .form-group-inline {
    flex: 0 0 auto;
}

.positions-panel {
    margin-top: 30px;
}

.positions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.positions-header h2 {
    margin: 0;
    color: #495057;
}

@media (max-width: 768px) {
    .positions-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .positions-header h2 {
        margin-bottom: 0;
    }
}

#positionsTable {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

@media (max-width: 768px) {
    .positions-panel {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    #positionsTable {
        min-width: 800px;
        font-size: 12px;
    }
    
    #positionsTable th,
    #positionsTable td {
        padding: 8px 4px;
        font-size: 11px;
    }
}

#positionsTable th,
#positionsTable td {
    padding: 10px;
    text-align: center;
    border: 1px solid #dee2e6;
}

#positionsTable th {
    background: #667eea;
    color: white;
    font-weight: 600;
}

#positionsTable tr:nth-child(even) {
    background: #f8f9fa;
}

#positionsTable tr:hover {
    background: #e9ecef;
}

.profit-positive {
    color: #28a745;
    font-weight: bold;
}

.profit-negative {
    color: #dc3545;
    font-weight: bold;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 15% auto;
    padding: 30px;
    border-radius: 10px;
    width: 500px;
    max-width: 90%;
    position: relative;
}

#addAccountModal .modal-content {
    max-height: 85vh;
    overflow-y: auto;
}

.modal-large {
    width: 800px;
    max-width: 95%;
    max-height: 85vh;
    overflow-y: auto;
    margin: 5% auto;
}

@media (max-width: 768px) {
    .modal-content {
        margin: 10% auto;
        padding: 20px;
        width: 95%;
        max-width: 95%;
    }
    
    .modal-large {
        width: 95%;
    }
}

.stats-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
}

.stats-controls label {
    font-weight: 600;
}

.stats-controls select {
    padding: 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.stats-summary {
    margin-bottom: 20px;
}

.stats-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.summary-item label {
    font-size: 12px;
    color: #666;
    font-weight: 600;
}

.summary-item span {
    font-size: 18px;
    font-weight: bold;
}

.stats-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin-bottom: 15px;
    border-bottom: 2px solid #dee2e6;
}

.stats-tab {
    padding: 8px 14px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #6c757d;
    transition: all 0.3s;
    white-space: nowrap;
}

.stats-tab:hover {
    color: #495057;
    background: #f8f9fa;
}

.stats-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.stats-tab-content {
    margin-top: 15px;
}

.stats-table-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 5px;
}

#statsTable {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

#statsTable th,
#statsTable td,
#closedDealsTable th,
#closedDealsTable td {
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid #dee2e6;
}

#statsTable th,
#closedDealsTable th {
    background: #667eea;
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

#statsTable tr:hover,
#closedDealsTable tr:hover {
    background: #f8f9fa;
}

/* Monthly Stats Table - Enhanced Styling */
#statsMonthlyTable {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-radius: 8px;
    overflow: hidden;
}

#statsMonthlyTable thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

#statsMonthlyTable th {
    padding: 16px 12px;
    text-align: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#statsMonthlyTable th:first-child {
    border-top-left-radius: 8px;
}

#statsMonthlyTable th:last-child {
    border-top-right-radius: 8px;
}

#statsMonthlyTable tbody tr {
    transition: all 0.3s ease;
    border-bottom: 1px solid #e9ecef;
}

#statsMonthlyTable tbody tr:nth-child(even) {
    background: #f8f9fa;
}

#statsMonthlyTable tbody tr:nth-child(odd) {
    background: white;
}

#statsMonthlyTable tbody tr:hover {
    background: linear-gradient(90deg, #e3f2fd 0%, #f3e5f5 100%);
    transform: scale(1.01);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
    cursor: pointer;
}

#statsMonthlyTable td {
    padding: 14px 12px;
    text-align: center;
    font-size: 14px;
    border: none;
    vertical-align: middle;
}

#statsMonthlyTable td:first-child {
    font-weight: 600;
    color: #495057;
    font-size: 15px;
    text-align: left;
    padding-left: 20px;
    position: relative;
}

#statsMonthlyTable td:first-child::before {
    content: '📅';
    margin-right: 8px;
    font-size: 16px;
}

#statsMonthlyTable td:nth-child(2) {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

#statsMonthlyTable td:nth-child(3) {
    font-size: 13px;
    font-weight: 500;
}

#statsMonthlyTable td:nth-child(4) {
    font-weight: 600;
    color: #495057;
    font-size: 15px;
}

#statsMonthlyTable td:nth-child(5),
#statsMonthlyTable td:nth-child(6) {
    font-weight: 600;
    font-size: 14px;
}

#statsMonthlyTable .profit-positive {
    color: #28a745;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(40, 167, 69, 0.2);
}

#statsMonthlyTable .profit-negative {
    color: #dc3545;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(220, 53, 69, 0.2);
}

#statsMonthlyTable tbody tr:first-child {
    border-top: 2px solid #667eea;
}

#statsMonthlyTable tbody tr:last-child {
    border-bottom: none;
}

/* Monthly Stats Container */
#statsMonthlyTableContainer {
    max-height: 500px;
    overflow-y: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    background: white;
}

#statsMonthlyTableContainer::-webkit-scrollbar {
    width: 8px;
}

#statsMonthlyTableContainer::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#statsMonthlyTableContainer::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
}

#statsMonthlyTableContainer::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5568d3 0%, #653a8f 100%);
}

@media (max-width: 768px) {
    #statsMonthlyTable {
        font-size: 12px;
    }
    
    #statsMonthlyTable th {
        padding: 12px 8px;
        font-size: 11px;
    }
    
    #statsMonthlyTable td {
        padding: 10px 6px;
        font-size: 12px;
    }
    
    #statsMonthlyTable td:first-child {
        padding-left: 12px;
        font-size: 13px;
    }
    
    #statsMonthlyTable td:first-child::before {
        font-size: 14px;
        margin-right: 4px;
    }
    
    #statsMonthlyTable td:nth-child(2) {
        font-size: 14px;
    }
}

#closedDealsTable {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 13px;
}

@media (max-width: 768px) {
    #closedDealsTable {
        font-size: 11px;
    }
    
    #closedDealsTable th,
    #closedDealsTable td {
        padding: 6px 4px;
    }
}

/* Open Positions Table in Stats Modal */
#openPositionsTableContainer {
    max-height: 500px;
    overflow-y: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    background: white;
}

#openPositionsTableContainer::-webkit-scrollbar {
    width: 8px;
}

#openPositionsTableContainer::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#openPositionsTableContainer::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
}

#openPositionsTable {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-radius: 8px;
    overflow: hidden;
}

#openPositionsTable thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

#openPositionsTable th {
    padding: 14px 10px;
    text-align: center;
    color: white;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#openPositionsTable tbody tr {
    transition: all 0.2s ease;
    border-bottom: 1px solid #e9ecef;
}

#openPositionsTable tbody tr:nth-child(even) {
    background: #f8f9fa;
}

#openPositionsTable tbody tr:nth-child(odd) {
    background: white;
}

#openPositionsTable tbody tr:hover {
    background: linear-gradient(90deg, #e3f2fd 0%, #f3e5f5 100%);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.12);
}

#openPositionsTable td {
    padding: 12px 10px;
    text-align: center;
    font-size: 13px;
    border: none;
    vertical-align: middle;
}

#openPositionsTable td:first-child {
    font-weight: 600;
    color: #495057;
    font-size: 12px;
    font-family: monospace;
}

#openPositionsTable td:nth-child(3) {
    font-weight: 700;
    font-size: 12px;
}

#openPositionsTable td:nth-child(8) {
    font-size: 14px;
    font-weight: 700;
}

#openPositionsTable .profit-positive {
    color: #28a745;
    font-weight: 700;
}

#openPositionsTable .profit-negative {
    color: #dc3545;
    font-weight: 700;
}

#openPositionsTable .open-positions-total-row {
    background: linear-gradient(90deg, #f0f2ff 0%, #f5f0ff 100%) !important;
    border-top: 2px solid #667eea;
}

#openPositionsTable .open-positions-total-row:hover {
    background: linear-gradient(90deg, #e8ebff 0%, #ede5ff 100%) !important;
    box-shadow: none;
}

@media (max-width: 768px) {
    #openPositionsTable {
        font-size: 11px;
    }

    #openPositionsTable th {
        padding: 10px 6px;
        font-size: 10px;
    }

    #openPositionsTable td {
        padding: 8px 5px;
        font-size: 11px;
    }
}

@media (max-width: 768px) {
    .stats-summary-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 10px;
    }
    
    .summary-item span {
        font-size: 16px;
    }
    
    .stats-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .stats-controls select,
    .stats-controls .btn {
        width: 100%;
    }
}

/* Detailed Stats Styles */
.detailed-stats-container {
    padding: 15px;
}

.detailed-stats-loading {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 16px;
}

.detailed-stats-content {
    display: block;
}

.detailed-stats-columns {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.detailed-stats-column {
    background: white;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.detailed-stats-column h3 {
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
    color: #333;
    font-size: 18px;
}

.detailed-stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #e9ecef;
}

.detailed-stat-item:last-child {
    border-bottom: none;
}

.detailed-stat-item label {
    font-size: 13px;
    color: #666;
    font-weight: 500;
    flex: 1;
}

.detailed-stat-item span {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    text-align: right;
    flex: 1;
}

.detailed-stat-item .profit-positive {
    color: #28a745;
}

.detailed-stat-item .profit-negative {
    color: #dc3545;
}

@media (max-width: 1024px) {
    .detailed-stats-columns {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .detailed-stats-columns {
        padding: 10px;
        gap: 15px;
    }
    
    .detailed-stats-column {
        padding: 15px;
    }
    
    .detailed-stats-column h3 {
        font-size: 16px;
        margin-bottom: 15px;
    }
    
    .detailed-stat-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .detailed-stat-item label {
        font-size: 12px;
    }
    
    .detailed-stat-item span {
        font-size: 13px;
        text-align: left;
    }
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 15px;
    top: 10px;
}

.close:hover {
    color: #000;
}

.trend-results {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
}

.trend-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    border-bottom: 1px solid #dee2e6;
}

.trend-item:last-child {
    border-bottom: none;
}

.signal-buy {
    color: #28a745;
    font-weight: bold;
}

.signal-sell {
    color: #dc3545;
    font-weight: bold;
}

.signal-wait {
    color: #ffc107;
    font-weight: bold;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Login Modal Styles */
#loginModal {
    display: flex !important;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    background-color: rgba(0, 0, 0, 0.7);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

#loginModal .modal-content {
    max-width: 400px;
    width: 90%;
    margin: 0 auto;
    text-align: center;
    position: relative;
    padding: 40px 30px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

#loginModal h2 {
    margin-bottom: 25px;
    color: #333;
    font-size: 24px;
}

#loginModal .form-group {
    margin-bottom: 20px;
    text-align: left;
}

#loginModal .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

#loginModal input[type="password"] {
    width: 100%;
    padding: 12px 15px;
    font-size: 16px;
    border: 2px solid #ced4da;
    border-radius: 6px;
    box-sizing: border-box;
    transition: border-color 0.3s;
}

#loginModal input[type="password"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#loginModal .btn {
    width: 100%;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    margin-top: 10px;
    min-height: 48px;
}

#loginError {
    text-align: center;
    font-size: 14px;
    margin-top: 15px;
    padding: 10px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    color: #721c24;
}

@media (max-width: 768px) {
    #loginModal .modal-content {
        width: 95%;
        padding: 30px 20px;
    }
    
    #loginModal h2 {
        font-size: 20px;
    }
}

@media (max-width: 768px) {
    .account-controls {
        flex-direction: column;
    }
    
    .account-controls .btn {
        width: 100%;
    }
    
    .account-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .account-actions {
        width: 100%;
    }
    
    .account-actions .btn {
        flex: 1;
    }
    
    .sl-tp-inputs {
        flex-direction: column;
        align-items: stretch;
    }
    
    .sl-tp-inputs .form-group-inline {
        width: 100%;
    }
    
    .input-compact {
        width: 100%;
    }
    
    .trend-controls .form-group-inline {
        flex-direction: column;
        align-items: stretch;
    }
    
    .trend-controls .btn {
        width: 100%;
        margin-top: 10px;
    }
}

/* Positions Filter Dropdown Styles */
.filter-dropdown-container {
    position: relative;
    display: inline-block;
}

.filter-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 250px;
    max-width: 350px;
    max-height: 400px;
    overflow-y: auto;
}

.filter-header {
    padding: 10px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8f9fa;
    border-radius: 6px 6px 0 0;
    flex-wrap: wrap;
}

.filter-header label {
    flex: 1;
    min-width: 120px;
}

.btn-tiny {
    padding: 4px 8px;
    font-size: 11px;
    min-height: auto;
    line-height: 1.2;
}

.filter-checkbox-list {
    padding: 8px;
    max-height: 320px;
    overflow-y: auto;
}

.filter-checkbox-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
    user-select: none;
}

.filter-checkbox-item:hover {
    background-color: #f0f0f0;
}

.filter-checkbox-item input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.filter-checkbox-item span {
    flex: 1;
    font-size: 13px;
    color: #333;
}

.filter-checkbox-item:first-child {
    font-weight: bold;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 4px;
}

.filter-checkbox-item:first-child:hover {
    background-color: transparent;
}

#btnToggleFilter {
    position: relative;
}

#btnToggleFilter.active {
    background-color: #667eea;
    color: white;
}

#btnToggleFilter.active span:last-child {
    transform: rotate(180deg);
    transition: transform 0.2s;
}

/* Scrollbar styling for filter dropdown */
.filter-checkbox-list::-webkit-scrollbar {
    width: 6px;
}

.filter-checkbox-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.filter-checkbox-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.filter-checkbox-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ========== Account Type Badges ========== */
.badge-usd {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.65em;
    font-weight: 700;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: #fff;
    vertical-align: middle;
    margin-left: 4px;
    letter-spacing: 0.5px;
}

.badge-cent {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.65em;
    font-weight: 700;
    background: linear-gradient(135deg, #ed8936 0%, #dd6b20 100%);
    color: #fff;
    vertical-align: middle;
    margin-left: 4px;
    letter-spacing: 0.5px;
}

/* ========== Aggregate Stats Panel ========== */
.aggregate-stats-panel {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    padding: 20px;
    margin-top: 20px;
}

.aggregate-stats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.aggregate-stats-header h2 {
    margin: 0;
    font-size: 1.2em;
    color: #2d3748;
}

.aggregate-stats-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.aggregate-stats-controls label {
    font-size: 0.9em;
    color: #4a5568;
    font-weight: 500;
}

.aggregate-stats-controls select {
    padding: 5px 10px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 0.9em;
    background: #fff;
}

/* Aggregate Summary */
.agg-summary {
    margin-bottom: 16px;
}

.agg-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.agg-summary-item {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.agg-summary-item label {
    display: block;
    font-size: 0.78em;
    color: #718096;
    margin-bottom: 4px;
    font-weight: 500;
}

.agg-summary-item span {
    font-size: 1.05em;
    font-weight: 700;
}

.agg-summary-accounts {
    background: linear-gradient(135deg, #ebf8ff 0%, #e6fffa 100%);
    border-color: #bee3f8;
}

/* Aggregate Tabs */
.agg-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0;
}

.agg-tab {
    padding: 8px 18px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    color: #718096;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.agg-tab:hover {
    color: #4a5568;
    background: #f7fafc;
}

.agg-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
}

/* Aggregate Tables */
.agg-table-container {
    max-height: 500px;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.agg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.agg-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.agg-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.88em;
    white-space: nowrap;
}

.agg-table th:first-child {
    border-radius: 8px 0 0 0;
}

.agg-table th:last-child {
    border-radius: 0 8px 0 0;
}

.agg-table td {
    padding: 9px 14px;
    border-bottom: 1px solid #edf2f7;
    white-space: nowrap;
}

.agg-table tbody tr:hover {
    background: #f0f4ff;
}

.agg-table tbody tr:nth-child(even) {
    background: #fafbfc;
}

.agg-table tbody tr:nth-child(even):hover {
    background: #f0f4ff;
}

.agg-table-container::-webkit-scrollbar {
    width: 6px;
}

.agg-table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.agg-table-container::-webkit-scrollbar-thumb {
    background: #a0aec0;
    border-radius: 3px;
}

.agg-table-container::-webkit-scrollbar-thumb:hover {
    background: #718096;
}

@media (max-width: 768px) {
    .aggregate-stats-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .agg-summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .agg-tabs {
        flex-wrap: wrap;
    }
    .agg-tab {
        padding: 6px 12px;
        font-size: 0.85em;
    }
}

