:root {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --accent: #10b981;
    --accent-light: #34d399;
    --red: #f87171;
    --blue: #3b82f6;
    --border: #334155;
    --radius: 12px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ===== Header ===== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0 30px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 30px;
}

.header .logo {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header .icon {
    font-size: 40px;
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
}

.header .subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 2s infinite;
}

.dot.error {
    background: var(--red);
}

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

/* ===== Stats ===== */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

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

.stat-card h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text);
}

.stat-card .value.roi {
    color: var(--accent);
}

/* ===== Chart ===== */
.chart {
    margin-bottom: 30px;
}

.chart h2 {
    font-size: 1.2rem;
    margin-bottom: 15px;
}

.chart-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    height: 320px;
}

/* ===== Positions & Trades tables ===== */
.positions, .trades {
    margin-bottom: 30px;
}

.positions h2, .trades h2 {
    font-size: 1.2rem;
    margin-bottom: 15px;
}

.positions-table, .trades-table {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    max-height: 400px;
    overflow-y: auto;
}

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

th {
    text-align: left;
    padding: 12px 16px;
    background: #0f172a;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

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

tbody tr:hover {
    background: rgba(16, 185, 129, 0.05);
}

.pos-val {
    color: var(--text);
}

.pos-pnl-positive {
    color: var(--accent);
}

.pos-pnl-negative {
    color: var(--red);
}

.action-buy {
    color: var(--accent);
    font-weight: 600;
}

.action-sell {
    color: var(--red);
    font-weight: 600;
}

.action-hold {
    color: var(--blue);
    font-weight: 600;
}

.conf-bar {
    display: flex;
    align-items: center;
    gap: 8px;
}

.conf-bar .bar {
    flex: 1;
    max-width: 80px;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.conf-bar .bar-fill {
    height: 100%;
    background: var(--blue);
    border-radius: 3px;
}

/* ===== Footer ===== */
footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
}

/* ===== Décisions ===== */
.engine {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 10px;
    margin-left: 8px;
    vertical-align: middle;
}

.engine:empty {
    display: none;
}

.strategy {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: -8px 0 12px;
}

.num-pos { color: var(--accent); }
.num-neg { color: var(--red); }

/* ===== Mobile ===== */
.positions-table, .trades-table {
    overflow-x: auto;
}

@media (max-width: 640px) {
    .container { padding: 16px; }
    .header { flex-wrap: wrap; gap: 12px; }
    .header h1 { font-size: 1.4rem; }
    .stat-card .value { font-size: 1.4rem; }
    th, td { padding: 8px 10px; white-space: nowrap; }
}
