:root {
    --bg: #0a0e1a;
    --bg2: #111827;
    --bg3: #1a2236;
    --border: #1f2d45;
    --accent: #00d4aa;
    --accent2: #3b82f6;
    --red: #ef4444;
    --green: #10b981;
    --yellow: #f59e0b;
    --text: #e2e8f0;
    --text2: #94a3b8;
    --text3: #64748b;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 220px;
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-logo {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo .icon { font-size: 28px; }
.sidebar-logo h1 { font-size: 16px; font-weight: 700; color: var(--accent); line-height: 1.2; }
.sidebar-logo small { color: var(--text3); font-size: 11px; }

.nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 20px;
    color: var(--text2);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 13px;
}
.nav a:hover, .nav a.active {
    background: var(--bg3);
    color: var(--accent);
}
.nav a .nav-icon { font-size: 18px; width: 22px; text-align: center; }
.nav-section { padding: 10px 20px 4px; font-size: 10px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 1px; margin-top: 8px; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text3);
}

/* MAIN CONTENT */
.main { margin-left: 220px; padding: 24px; min-height: 100vh; }

.page { display: none; }
.page.active { display: block; }

/* HEADER */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-title { font-size: 22px; font-weight: 700; }
.page-subtitle { color: var(--text2); font-size: 13px; margin-top: 2px; }

/* CARDS */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.card-icon { font-size: 22px; }

.stat-value { font-size: 28px; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.stat-sub { font-size: 12px; color: var(--text2); }
.stat-change { font-size: 13px; font-weight: 600; margin-top: 8px; }

.positive { color: var(--green); }
.negative { color: var(--red); }
.neutral { color: var(--text2); }

/* PLATFORM CARDS */
.platform-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: border-color 0.2s;
}
.platform-card.running { border-color: var(--green); }
.platform-card.running::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--green);
}

.platform-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.platform-name { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.platform-name .emoji { font-size: 24px; }

.status-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.running { background: var(--green); animation: pulse 2s infinite; }
.status-dot.stopped { background: var(--text3); }

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

.platform-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.p-stat label { font-size: 11px; color: var(--text3); }
.p-stat value { display: block; font-size: 15px; font-weight: 600; }

/* BUTTONS */
.btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: #00b894; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* TABLE */
.table-wrap {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
}
.table-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}
.table-title { font-size: 15px; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
thead th {
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.15s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg3); }
tbody td { padding: 12px 16px; font-size: 13px; }

/* BADGE */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-green { background: rgba(16,185,129,0.15); color: var(--green); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-yellow { background: rgba(245,158,11,0.15); color: var(--yellow); }
.badge-blue { background: rgba(59,130,246,0.15); color: var(--accent2); }
.badge-gray { background: var(--bg3); color: var(--text2); }

/* FORM */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.form-input {
    width: 100%;
    padding: 9px 12px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--accent); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* TABS */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.tab {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text2);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* NEWS */
.news-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.news-item:last-child { border-bottom: none; }
.news-sentiment {
    width: 8px;
    min-width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 5px;
}
.news-title { font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.news-meta { font-size: 11px; color: var(--text3); }

/* LOGS */
.log-entry { padding: 6px 12px; border-bottom: 1px solid var(--border); font-size: 12px; display: flex; gap: 10px; font-family: monospace; }
.log-entry:last-child { border-bottom: none; }
.log-time { color: var(--text3); min-width: 70px; }
.log-level { min-width: 50px; font-weight: 600; }
.log-level.info { color: var(--accent2); }
.log-level.warn { color: var(--yellow); }
.log-level.error { color: var(--red); }
.log-level.debug { color: var(--text3); }

/* TOAST */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 20px;
    font-size: 13px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 250px;
}
.toast.success { border-left: 4px solid var(--green); }
.toast.error { border-left: 4px solid var(--red); }
.toast.info { border-left: 4px solid var(--accent2); }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

/* MODAL */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 500;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    width: 480px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close { cursor: pointer; color: var(--text2); font-size: 20px; line-height: 1; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* CHART */
.chart-container { height: 200px; position: relative; margin-top: 12px; }

/* LOGIN PAGE */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 20% 50%, rgba(0,212,170,0.05) 0%, transparent 60%),
                radial-gradient(ellipse at 80% 20%, rgba(59,130,246,0.05) 0%, transparent 60%),
                var(--bg);
}
.login-box {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    width: 360px;
    text-align: center;
}
.login-box .logo { font-size: 48px; margin-bottom: 12px; }
.login-box h1 { font-size: 22px; font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.login-box p { color: var(--text2); font-size: 13px; margin-bottom: 28px; }
.login-box .btn { width: 100%; justify-content: center; padding: 12px; font-size: 14px; }

/* BUDGET INDICATOR */
.budget-bar {
    height: 6px;
    background: var(--bg3);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}
.budget-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--accent);
    transition: width 0.5s ease;
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* TOGGLE SWITCH (Config API) */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer; inset: 0;
    background: var(--bg3); border-radius: 24px; transition: .3s;
}
.toggle-slider:before {
    position: absolute; content: ""; height: 18px; width: 18px;
    left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .3s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); }

/* INPUT FOCUS (Config API) */
#tab-apiconfig-binance input:focus,
#tab-apiconfig-saxo input:focus,
#tab-apiconfig-boursorama input:focus { border-color: var(--accent) !important; outline: none; }
