* {
    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 {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #667eea;
}

header h1 {
    color: #333;
    font-size: 28px;
}

@media (max-width: 768px) {
    header {
        margin-bottom: 15px;
        padding-bottom: 10px;
    }
    
    header h1 {
        font-size: 20px;
    }
}

.main-content {
    display: grid;
    grid-template-columns: 0.7fr 1.6fr;
    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-list {
    max-height: 400px;
    overflow-y: auto;
}

.account-item {
    background: white;
    padding: 12px;
    margin-bottom: 10px;
    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;
}

@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;
}

.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;
    gap: 10px;
    margin-bottom: 15px;
    border-bottom: 2px solid #dee2e6;
}

.stats-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #6c757d;
    transition: all 0.3s;
}

.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;
}

#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;
    }
}

@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;
}

