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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

.user-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    margin-bottom: 20px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.user-name {
    color: white;
    font-weight: 600;
    font-size: 1rem;
}

.btn-logout {
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.3s;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.3);
}

.btn-danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(231, 76, 60, 0.3);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    box-shadow: 0 3px 8px rgba(231, 76, 60, 0.4);
    transform: translateY(-2px);
}

.btn-success {
    background: linear-gradient(135deg, #27ae60, #229954);
    color: white;
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(39, 174, 96, 0.3);
}

.btn-success:hover {
    background: linear-gradient(135deg, #229954, #1e8449);
    box-shadow: 0 3px 8px rgba(39, 174, 96, 0.4);
    transform: translateY(-2px);
}

header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

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

.status-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.status-card h3 {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.status-indicator {
    display: flex;
    align-items: center;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ef4444;
    margin-right: 10px;
    animation: pulse 2s infinite;
}

.status-dot.active {
    background: #10b981;
}

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

.mode-badge {
    display: inline-block;
    padding: 5px 12px;
    background: #3b82f6;
    color: white;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.price-display {
    font-size: 2rem;
    font-weight: 700;
    color: #1f2937;
}

.price-change {
    font-size: 1rem;
    margin-top: 5px;
}

.price-change.positive {
    color: #10b981;
}

.price-change.negative {
    color: #ef4444;
}

.portfolio-value {
    font-size: 2rem;
    font-weight: 700;
    color: #1f2937;
}

.profit-display {
    font-size: 1.1rem;
    margin-top: 5px;
    font-weight: 600;
}

.profit-display.positive {
    color: #10b981;
}

.profit-display.negative {
    color: #ef4444;
}

.position-status {
    font-size: 1.5rem;
    font-weight: 700;
    color: #64748b;
}

.position-status.open {
    color: #f59e0b;
}

.entry-price {
    font-size: 0.9rem;
    color: #6b7280;
    margin-top: 5px;
}

.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

.crypto-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.crypto-selector label {
    font-weight: 600;
    color: #4b5563;
}

.crypto-select {
    padding: 10px 15px;
    font-size: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    min-width: 150px;
}

.crypto-select:disabled {
    opacity: 0.5;
}

.multi-pair-panel {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.pairs-header h3 {
    color: #374151;
    margin-bottom: 15px;
}

.pairs-header #pairCount {
    color: #6b7280;
    font-size: 0.9rem;
}

.active-pairs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

.pair-card {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    padding: 15px;
    position: relative;
    transition: all 0.3s ease;
}

.pair-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.pair-card.active {
    border-color: #3b82f6;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
}

.pair-card.running {
    border-color: #10b981;
}

.pair-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.pair-card-header h4 {
    color: #1f2937;
    font-size: 1.1rem;
}

.pair-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.pair-status.running {
    background: #d1fae5;
    color: #059669;
}

.pair-status.stopped {
    background: #fee2e2;
    color: #dc2626;
}

.pair-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 0.85rem;
}

.pair-stat {
    display: flex;
    justify-content: space-between;
}

.pair-stat-label {
    color: #6b7280;
}

.pair-stat-value {
    color: #1f2937;
    font-weight: 500;
}

.pair-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.pair-actions .btn {
    flex: 1;
    padding: 8px 12px;
    font-size: 0.85rem;
}

.btn-remove-pair {
    position: absolute;
    top: 5px;
    right: 5px;
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    line-height: 1;
    border-radius: 4px;
}

.btn-remove-pair:hover {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
}

.no-pairs-message {
    text-align: center;
    color: #6b7280;
    padding: 30px;
    font-style: italic;
    cursor: not-allowed;
}

.portfolio-panel {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 2px solid #86efac;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

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

.portfolio-header h3 {
    color: #166534;
    margin: 0;
}

.portfolio-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.portfolio-stat {
    background: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.portfolio-stat .stat-label {
    display: block;
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 4px;
}

.portfolio-stat .stat-value {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1f2937;
}

.portfolio-allocations {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.allocation-bar {
    background: white;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.allocation-bar .pair-name {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 5px;
}

.allocation-bar .bar-container {
    background: #e5e7eb;
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 5px;
}

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

.allocation-bar .bar-fill.under { background: #3b82f6; }
.allocation-bar .bar-fill.target { background: #10b981; }
.allocation-bar .bar-fill.over { background: #f59e0b; }

.allocation-bar .allocation-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #6b7280;
}

.allocation-bar .drift {
    font-weight: 500;
}

.allocation-bar .drift.positive { color: #f59e0b; }
.allocation-bar .drift.negative { color: #3b82f6; }

.portfolio-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

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

.btn-sm {
    padding: 4px 12px;
    font-size: 0.8rem;
    background: #6b7280;
    color: white;
}

.btn-sm:hover {
    background: #4b5563;
}

.config-input {
    padding: 4px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.9rem;
    background: white;
    color: #1f2937;
}

.config-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.config-suffix {
    font-size: 0.85em;
    color: #6b7280;
    margin-left: 4px;
}

.btn-start {
    background: #10b981;
    color: white;
}

.btn-start:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-2px);
}

.btn-stop {
    background: #ef4444;
    color: white;
}

.btn-stop:hover:not(:disabled) {
    background: #dc2626;
    transform: translateY(-2px);
}

.dashboard {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.chart-container, .balances, .config-panel, .trades-panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.chart-container {
    height: 350px;
}

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

.chart-container h3, .balances h3, .config-panel h3, .trades-panel h3 {
    font-size: 1.1rem;
    color: #374151;
    margin-bottom: 15px;
}

.config-desc {
    font-size: 0.85rem;
    color: #6b7280;
    font-weight: 400;
    font-style: italic;
}

.balance-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #e5e7eb;
}

.balance-item:last-child {
    border-bottom: none;
}

.balance-label {
    font-weight: 600;
    color: #6b7280;
}

.balance-value {
    font-weight: 700;
    color: #1f2937;
}

.config-panel {
    margin-bottom: 20px;
}

.strategy-description {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.1), rgba(33, 150, 243, 0.1));
    border-left: 4px solid #4caf50;
    padding: 18px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.strategy-description strong {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: #1f2937;
    font-weight: 600;
}

.strategy-description p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.7;
    color: #374151;
}

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

.config-item {
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
}

.config-label {
    display: block;
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 5px;
}

.config-value {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
}

.trades-table-container {
    overflow-x: auto;
}

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

.trades-table th {
    background: #f3f4f6;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    font-size: 0.9rem;
}

.trades-table td {
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.9rem;
}

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

.trade-buy {
    color: #10b981;
    font-weight: 600;
}

.trade-sell {
    color: #ef4444;
    font-weight: 600;
}

.no-trades {
    text-align: center;
    color: #9ca3af;
    padding: 20px !important;
}

@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: 1fr;
    }
    
    .status-panel {
        grid-template-columns: 1fr;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .controls {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .crypto-selector {
        width: 100%;
        justify-content: center;
        margin-bottom: 5px;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .btn-danger {
        margin-left: 0 !important;
        margin-top: 10px;
    }
    
    .competition-stats {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .vs-section {
        order: -1;
        flex-direction: row;
    }
}

.btn-compete {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.btn-compete:hover {
    background: linear-gradient(135deg, #e083eb 0%, #e5475c 100%);
}

.btn-secondary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #556eda 0%, #663b92 100%);
}

.competition-panel {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.competition-panel h3 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #333;
}

.competition-stats {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 30px;
    margin-bottom: 25px;
}

.player-card {
    background: #f9fafb;
    border-radius: 10px;
    padding: 20px;
}

.human-card {
    border: 2px solid #10b981;
}

.bot-card {
    border: 2px solid #667eea;
}

.player-card h4 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: #333;
}

.player-stat {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e5e7eb;
}

.player-stat:last-child {
    border-bottom: none;
}

.stat-label {
    color: #666;
    font-size: 0.9rem;
}

.stat-value {
    font-weight: 600;
    color: #333;
}

.profit-positive {
    color: #10b981 !important;
}

.profit-negative {
    color: #ef4444 !important;
}

.vs-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.timer {
    font-size: 2rem;
    font-weight: 700;
    color: #667eea;
    font-family: 'Courier New', monospace;
}

.vs-badge {
    font-size: 1.5rem;
    font-weight: 700;
    color: #999;
    padding: 10px 20px;
    background: #f3f4f6;
    border-radius: 50px;
}

.winner-badge {
    font-size: 1.2rem;
    font-weight: 700;
    padding: 10px 20px;
    border-radius: 50px;
    animation: celebrate 0.5s ease-in-out;
}

.winner-human {
    background: #10b981;
    color: white;
}

.winner-bot {
    background: #667eea;
    color: white;
}

.winner-tie {
    background: #f59e0b;
    color: white;
}

@keyframes celebrate {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.manual-trading {
    background: #f9fafb;
    border-radius: 10px;
    padding: 20px;
}

.manual-trading h4 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: #333;
}

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

.trade-controls input {
    flex: 1;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
}

.trade-controls input:focus {
    outline: none;
    border-color: #667eea;
}

.btn-buy {
    background: #10b981;
}

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

.btn-sell {
    background: #ef4444;
}

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

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background: white;
    margin: 3% auto;
    padding: 20px;
    border-radius: 12px;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
}

.close:hover {
    color: #333;
}

.modal-content h2 {
    margin-bottom: 15px;
    color: #333;
}

.modal-content p {
    color: #666;
    margin-bottom: 20px;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-form label {
    font-weight: 600;
    color: #333;
}

.modal-select {
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    background: white;
}

.modal-select:focus {
    outline: none;
    border-color: #667eea;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
}

.leaderboard-content {
    max-height: 500px;
    overflow-y: auto;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.leaderboard-table th {
    background: #f3f4f6;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    font-size: 0.9rem;
}

.leaderboard-table td {
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.9rem;
}

.leaderboard-table tr.win {
    background: #d1fae5;
}

.leaderboard-table tr.loss {
    background: #fee2e2;
}

.leaderboard-table tr.tie {
    background: #fef3c7;
}

.btn-settings {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
}

.btn-settings:hover {
    background: linear-gradient(135deg, #5b6270 0%, #3b4553 100%);
}

.settings-modal {
    max-width: 500px;
}

.settings-section {
    padding: 12px 0;
    border-bottom: 1px solid #e5e7eb;
}

.settings-section:last-child {
    border-bottom: none;
}

.settings-section h4 {
    margin: 0 0 8px 0;
    color: #1f2937;
    font-size: 1rem;
}

.settings-hint {
    color: #6b7280;
    font-size: 0.9rem;
    margin: 5px 0 15px 0;
}

.settings-hint a {
    color: #667eea;
}

.trading-mode-toggle {
    display: flex;
    align-items: center;
    gap: 15px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #10b981;
    transition: .4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: #f59e0b;
}

input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

#tradingModeLabel {
    font-weight: 600;
    color: #1f2937;
}

.api-key-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
    margin-bottom: 15px;
}

.api-key-status .status-icon {
    font-size: 1.2rem;
}

.api-key-status.verified {
    background: #d1fae5;
}

.api-key-status.verified .status-text {
    color: #065f46;
}

.api-key-status.saved {
    background: #fef3c7;
}

.api-key-status.saved .status-text {
    color: #92400e;
}

.form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    margin-bottom: 3px;
    font-weight: 600;
    color: #374151;
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.api-key-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.api-key-actions .btn {
    flex: 1;
    min-width: 120px;
}

.mode-badge.live {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}
