:root {
    --bg: #0d1224;
    --surface: #161b30;
    --border: #283054;
    --fg: #e7e9f0;
    --muted: #8a8fa3;
    --up: #22c55e;
    --down: #ef4444;
    --be: #94a3b8;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
}

header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

h1 { margin: 0; font-size: 1.5rem; letter-spacing: 0.02em; }

h2 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin: 0 0 0.75rem;
    font-weight: 600;
}

section { margin-bottom: 2rem; }

.muted { color: var(--muted); font-size: 0.85rem; }
code {
    background: var(--surface);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.85em;
}

/* ---------- Stats grid ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-bottom: 2rem;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
}
.stat .label {
    font-size: 0.7rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.stat .value {
    font-size: 1.4rem;
    font-weight: 600;
    margin-top: 0.25rem;
    font-variant-numeric: tabular-nums;
}
.stat .sub {
    margin-top: 0.25rem;
    font-size: 0.75rem;
}
.value.up { color: var(--up); }
.value.down { color: var(--down); }

/* ---------- Open trade card ---------- */
.trade-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}
.card-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.pair { font-weight: 700; font-size: 1.2rem; letter-spacing: 0.02em; }

.side, .outcome {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.side.long, .outcome.win { background: rgba(34, 197, 94, 0.15); color: var(--up); }
.side.short, .outcome.loss { background: rgba(239, 68, 68, 0.15); color: var(--down); }
.outcome.breakeven { background: rgba(148, 163, 184, 0.15); color: var(--be); }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.4rem 1rem;
    font-variant-numeric: tabular-nums;
}
.card-grid .label {
    color: var(--muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-right: 0.4rem;
}
.note {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    font-style: italic;
    color: var(--muted);
}

/* ---------- Empty state ---------- */
.empty {
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    text-align: center;
    color: var(--muted);
}

/* ---------- Closed trades table ---------- */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}
th, td {
    padding: 0.55rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
th {
    background: rgba(255, 255, 255, 0.02);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    font-weight: 600;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

td.r { font-weight: 600; }
td.r.up { color: var(--up); }
td.r.down { color: var(--down); }

.note-cell {
    color: var(--muted);
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- Footer ---------- */
footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    text-align: center;
}

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
    main { padding: 1rem; }
    header { flex-direction: column; align-items: flex-start; gap: 0.25rem; }
    .stats { grid-template-columns: 1fr 1fr; }
    th, td { padding: 0.4rem 0.55rem; }
    .note-cell { max-width: 100px; }
    .pair { font-size: 1.05rem; }
}
