:root {
    --bg: #0f1117;
    --card: #1a1d27;
    --border: #2a2d3a;
    --text: #e1e4eb;
    --text-muted: #8b8fa3;
    --accent: #6366f1;
    --green: #22c55e;
    --red: #ef4444;
    --yellow: #eab308;
    --blue: #3b82f6;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--card);
}

header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-running { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-running::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); margin-right: 6px; animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.badge-stopped { background: rgba(239,68,68,0.15); color: var(--red); }

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

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

.card h2 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Control Panel */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    display: block;
}

select {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
}

select:focus { outline: 2px solid var(--accent); border-color: transparent; }

.control-buttons { display: flex; gap: 0.5rem; }

.btn {
    padding: 0.5rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-start { background: var(--green); color: #fff; }
.btn-start:hover:not(:disabled) { background: #16a34a; }
.btn-stop { background: var(--red); color: #fff; }
.btn-stop:hover:not(:disabled) { background: #dc2626; }
.btn-secondary { background: var(--accent); color: #fff; }
.btn-secondary:hover:not(:disabled) { background: #4f46e5; }

/* Grid */
.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .grid { grid-template-columns: 1fr; }
    .controls { flex-direction: column; align-items: stretch; }
    .control-group { flex-direction: column; align-items: stretch; }
    header { flex-direction: column; gap: 0.5rem; }
    main { padding: 1rem; }
}

/* Account */
.account-info {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.account-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.account-item .label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.account-item .value {
    font-size: 1.25rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.pnl-positive { color: var(--green); }
.pnl-negative { color: var(--red); }
.pnl-zero { color: var(--text-muted); }

/* Table */
.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th {
    text-align: left;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

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

.side-buy { color: var(--green); font-weight: 600; }
.side-sell { color: var(--red); font-weight: 600; }

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    font-size: 0.875rem;
}

/* Footer */
footer {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem 2rem;
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 100;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--green); color: #fff; }
.toast.error { background: var(--red); color: #fff; }
.toast.info { background: var(--blue); color: #fff; }

/* User info */
.user-info { font-size: 0.875rem; color: var(--text-muted); }
.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.75rem; background: var(--border); color: var(--text-muted); border: none; border-radius: 6px; cursor: pointer; }
.btn-sm:hover { background: var(--text-muted); color: var(--bg); }
.btn-sm-action { padding: 0.35rem 0.6rem; font-size: 0.75rem; }

.section-note {
    margin: -0.25rem 0 1rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Keys banner */
.keys-banner { border-color: var(--yellow); }
.keys-banner p { color: var(--text-muted); font-size: 0.875rem; margin-bottom: 1rem; }
.keys-form { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.keys-form input { flex: 1; min-width: 200px; padding: 0.5rem 0.75rem; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; font-size: 0.875rem; }
.keys-form input:focus { outline: 2px solid var(--accent); border-color: transparent; }
