/* Trade Monitor — mobile-first dark theme, spec 3.4.3 */

:root {
  --bg:        #0f0f11;
  --surface:   #1a1a1f;
  --surface2:  #22222a;
  --border:    #2e2e38;
  --text:      #e4e4e8;
  --muted:     #6b6b7a;
  --accent:    #9c8cff;
  --positive:  #34d399;
  --negative:  #f87171;
  --neutral:   #6b6b7a;
  --buy-bg:    #0d2b1a;
  --sell-bg:   #2b0d0d;
  --buy-text:  #34d399;
  --sell-text: #f87171;
  --dot-green: #22c55e;
  --dot-yellow:#eab308;
  --dot-red:   #ef4444;
  font-size: 16px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:      #f4f4f8;
    --surface: #ffffff;
    --surface2:#f0f0f5;
    --border:  #d1d1da;
    --text:    #1a1a1f;
    --muted:   #6b6b7a;
  }
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  line-height: 1.5;
  min-height: 100dvh;
}

/* ---------- Header ---------- */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
#header h1 { font-size: 1rem; font-weight: 700; letter-spacing: .04em; color: var(--accent); }
#header-right { display: flex; align-items: center; gap: 10px; }
#last-updated { font-size: .7rem; color: var(--muted); }

#conn-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--dot-green);
  flex-shrink: 0;
  transition: background .2s;
}
#conn-dot.yellow { background: var(--dot-yellow); }
#conn-dot.red    { background: var(--dot-red); }

/* ---------- Account tabs ---------- */
#account-tabs {
  display: flex;
  overflow-x: auto;
  gap: 4px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
#account-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  flex-shrink: 0;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--muted);
  font-size: .8rem;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  transition: all .15s;
  white-space: nowrap;
}
.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- Main content ---------- */
main { padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.card-title {
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
  margin-bottom: 10px;
}

/* ---------- Live status card ---------- */
#live-card.basket-open { border-color: var(--border); }

.direction-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 4px;
  font-weight: 700;
  font-size: .85rem;
  margin-bottom: 10px;
}
.direction-badge.buy  { background: var(--buy-bg);  color: var(--buy-text); }
.direction-badge.sell { background: var(--sell-bg); color: var(--sell-text); }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}
.stat { display: flex; flex-direction: column; gap: 1px; }
.stat-label { font-size: .68rem; color: var(--muted); }
.stat-value { font-size: .92rem; font-weight: 600; }

.pnl-large {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
  margin: 8px 0;
}
.positive { color: var(--positive); }
.negative { color: var(--negative); }
.neutral  { color: var(--neutral); }

/* ---------- Level ladder ---------- */
.ladder { margin-top: 10px; }
.ladder-title { font-size: .68rem; color: var(--muted); margin-bottom: 4px; }
.ladder-row {
  display: flex;
  gap: 8px;
  font-size: .78rem;
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
}
.ladder-row:last-child { border-bottom: none; }
.ladder-level { color: var(--accent); width: 28px; flex-shrink: 0; font-weight: 600; }
.ladder-price { flex: 1; }
.ladder-lot   { color: var(--muted); }

/* ---------- Risk card ---------- */
.risk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.pause-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 8px;
  border-radius: 4px;
  background: #3d1010;
  color: var(--negative);
  font-size: .72rem;
}

/* ---------- History table ---------- */
.history-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .78rem;
  min-width: 480px;
}
th {
  text-align: left;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
td { padding: 7px 8px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr.expandable { cursor: pointer; }
tr.expandable:hover td { background: var(--surface2); }
tr.detail-row td { background: var(--surface2); font-size: .74rem; }

/* ---------- Charts ---------- */
.chart-wrap {
  position: relative;
  height: 180px;
}

/* ---------- Placeholder ---------- */
.placeholder {
  color: var(--muted);
  font-size: .85rem;
  text-align: center;
  padding: 20px 0;
}

/* ---------- 2-column on wider screens ---------- */
@media (min-width: 768px) {
  main { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
  #live-card, #history-card, #equity-card, #dd-card { grid-column: 1 / -1; }
  #live-card { grid-column: 1; }
  #risk-card  { grid-column: 2; }
  #history-card { grid-column: 1 / -1; }
  #equity-card  { grid-column: 1; }
  #dd-card      { grid-column: 2; }
}

/* ---------- Tap targets ---------- */
button, .tab-btn { min-height: 44px; min-width: 44px; }
