:root {
    --bg: #0f172a;
    --card: #020617;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --green: #22c55e;
    --red: #ef4444;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
}

header {
    background: var(--card);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: 1.2rem;
}

#connectionStatus.online {
    color: var(--green);
}

#connectionStatus.offline {
    color: var(--red);
}

main {
    padding: 1rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.card {
    background: var(--card);
    padding: 1rem;
    border-radius: 8px;
}

.card h3 {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.card p {
    margin: 0;
    font-size: 1.4rem;
    font-weight: bold;
}

.chart-card {
    margin-top: 1rem;
}

.table-card {
    margin-top: 1rem;
}

canvas {
    width: 100% !important;
    height: 300px !important;
}

/* ===== TABLE ===== */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

thead {
    background: #020617;
}

th,
td {
    padding: 0.6rem;
    text-align: center;
    border-bottom: 1px solid #1e293b;
}

th {
    color: var(--muted);
    font-weight: 600;
}

tr.win td.result {
    color: var(--green);
    font-weight: bold;
}

tr.loss td.result {
    color: var(--red);
    font-weight: bold;
}

@media (max-width: 600px) {
    canvas {
        height: 240px !important;
    }
}

/* ===== RESULT VISUAL ===== */
tr.win {
    background: rgba(34, 197, 94, 0.06);
}

tr.loss {
    background: rgba(239, 68, 68, 0.06);
}

td.result {
    font-weight: bold;
}

td.result.tp::before {
    content: "✅ ";
}

td.result.stop::before {
    content: "❌ ";
}

/* ===== PNL CARD ===== */
#pnl.positive {
    color: var(--green);
}

#pnl.negative {
    color: var(--red);
}

/* ===== TRADE SUMMARY ===== */
#tradeSummary {
    font-size: 0.75rem;
    margin-left: 0.5rem;
    color: var(--muted);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* ===== BADGE ===== */
.badge {
    font-size: 0.65rem;
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-weight: bold;
    letter-spacing: 0.05em;
}

.badge.paper {
    background: #334155;
    color: #e5e7eb;
}

.badge.real {
    background: #16a34a;
    color: #ecfdf5;
}

/* ===== CONSOLE LOGS ===== */
.console-card {
    margin-top: 1rem;
    background: #000 !important;
    /* Fundo preto para parecer terminal */
    border: 1px solid #1e293b;
}

.log-console {
    height: 250px;
    overflow-y: auto;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.8rem;
    color: #34d399;
    /* Verde esmeralda */
    padding: 0.5rem;
    line-height: 1.4;
    display: flex;
    flex-direction: column;
}

.log-line {
    border-bottom: 1px solid #111;
    padding: 2px 0;
    white-space: pre-wrap;
}

.log-line.error {
    color: var(--red);
}