/* 0xeeTrade — Dark theme, semantic, modern */

:root {
  --bg:         #0d0f14;
  --surface:    #161b26;
  --surface2:   #1e2535;
  --border:     #2a3147;
  --text:       #e2e8f0;
  --text-muted: #7888a0;
  --accent:     #7c6af7;
  --accent2:    #38bdf8;
  --green:      #22d3a8;
  --red:        #f87171;
  --yellow:     #fbbf24;
  --radius:     8px;
  --font:       'Inter', system-ui, -apple-system, sans-serif;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

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

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ────────────────────────────────────────────────────────────────── */

.app-wrap {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

/* ── Nav ───────────────────────────────────────────────────────────────────── */

nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  height: 52px;
}

.nav-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.nav-links { display: flex; gap: 1.5rem; }

.nav-links a {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.15s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); text-decoration: none; }

.nav-status {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}
.status-dot.offline { background: var(--red); animation: none; }
.status-dot.halted  { background: var(--yellow); animation: none; }

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

/* ── Main content ──────────────────────────────────────────────────────────── */

main { padding: 1.5rem; max-width: 1400px; margin: 0 auto; width: 100%; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */

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

.card-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* ── Stats grid ────────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.neutral  { color: var(--text-muted) !important; }

/* ── Drawdown bar ──────────────────────────────────────────────────────────── */

.drawdown-bar-wrap {
  margin-top: 0.5rem;
  height: 6px;
  background: var(--surface2);
  border-radius: 99px;
  overflow: hidden;
}

.drawdown-bar {
  height: 100%;
  border-radius: 99px;
  background: var(--green);
  transition: width 0.4s ease, background 0.4s ease;
}

.drawdown-bar.warn   { background: var(--yellow); }
.drawdown-bar.danger { background: var(--red); }

/* ── Charts grid ───────────────────────────────────────────────────────────── */

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 900px) { .charts-grid { grid-template-columns: 1fr; } }

.chart-wrap { position: relative; height: 260px; }
.chart-wrap canvas { width: 100% !important; }

/* ── Position card ─────────────────────────────────────────────────────────── */

.position-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.position-field label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.position-field span {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 0.1rem;
}

.no-position {
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 1rem 0;
}

/* ── AI commentary ─────────────────────────────────────────────────────────── */

.ai-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--text);
  min-height: 56px;
}

.ai-empty { color: var(--text-muted); font-style: italic; }

/* ── Trade table ───────────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  margin-top: 0.75rem;
}

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

th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}
th:hover { color: var(--text); }

td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

tr:hover td { background: var(--surface2); }

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 99px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.badge-long   { background: rgba(34,211,168,0.15); color: var(--green); }
.badge-short  { background: rgba(248,113,113,0.15); color: var(--red); }
.badge-open   { background: rgba(56,189,248,0.15);  color: var(--accent2); }
.badge-tp     { background: rgba(34,211,168,0.15);  color: var(--green); }
.badge-sl     { background: rgba(248,113,113,0.15); color: var(--red); }
.badge-manual { background: rgba(251,191,36,0.15);  color: var(--yellow); }

/* ── Alert banner ──────────────────────────────────────────────────────────── */

.alert-banner {
  display: none;
  background: rgba(248,113,113,0.1);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.25rem;
  color: var(--red);
  font-size: 0.875rem;
  font-weight: 600;
}

.alert-banner.visible { display: block; }

/* ── Journal page ──────────────────────────────────────────────────────────── */

.journal-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.filter-btn {
  padding: 0.35rem 0.9rem;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover { border-color: var(--accent); color: var(--text); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.search-input {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--accent); }

.journal-list { display: flex; flex-direction: column; gap: 0.75rem; }

.journal-entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.journal-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.journal-ts {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.journal-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.journal-body {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.6;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.cat-SYSTEM   { background: rgba(124,106,247,0.15); color: var(--accent); }
.cat-SIGNAL   { background: rgba(34,211,168,0.15);  color: var(--green); }
.cat-DECISION { background: rgba(56,189,248,0.15);  color: var(--accent2); }
.cat-RISK     { background: rgba(248,113,113,0.15); color: var(--red); }
.cat-DEPLOY   { background: rgba(251,191,36,0.15);  color: var(--yellow); }

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

/* ── Bottom row ────────────────────────────────────────────────────────────── */

.bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 900px) { .bottom-row { grid-template-columns: 1fr; } }

section.card { margin-bottom: 1rem; }
