/* Mobile-first, dark. Designed at ~390px, scales up. */
:root {
  --bg: #0b0f14;
  --bg-card: #141a22;
  --bg-card2: #1b232e;
  --line: #24303d;
  --text: #e7edf3;
  --muted: #8a97a6;
  --green: #26d07c;
  --green-dim: #123a2a;
  --red: #ff5d6c;
  --red-dim: #3a1620;
  --accent: #4c8dff;
  --radius: 16px;
  --tap: 44px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-font-smoothing: antialiased;
}
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.muted { color: var(--muted); }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--bg-card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 22px;
  text-align: center;
}
.login-card .brand { font-size: 32px; margin-bottom: 6px; }
.login-card h1 { font-size: 20px; margin: 0 0 18px; font-weight: 600; }
.login-card input, .login-card button {
  width: 100%; height: 50px; border-radius: 12px; font-size: 16px; margin-top: 10px;
}
.login-card input {
  background: var(--bg-card2); border: 1px solid var(--line); color: var(--text);
  padding: 0 14px;
}
.login-card button {
  background: var(--accent); color: #fff; border: 0; font-weight: 600; cursor: pointer;
}
.login-card button:disabled { opacity: .6; }
.error { color: var(--red); margin: 12px 0 0; font-size: 14px; }

/* ---------- app shell ---------- */
.app { max-width: 720px; margin: 0 auto; padding: 12px 12px 84px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 2px 12px;
}
.topbar .title { font-weight: 700; font-size: 18px; }
.topbar .sub { font-size: 12px; color: var(--muted); }
.icon-btn {
  min-width: var(--tap); min-height: var(--tap); border-radius: 12px;
  background: var(--bg-card); border: 1px solid var(--line); color: var(--text);
  font-size: 14px; cursor: pointer;
}

/* ---------- summary card ---------- */
.summary {
  background: linear-gradient(160deg, #17202b, #0f151d);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.summary .label { font-size: 12px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; }
.summary .big { font-size: 34px; font-weight: 700; margin: 4px 0 2px; }
.summary .row { display: flex; gap: 10px; margin-top: 12px; }
.summary .chip {
  flex: 1; background: rgba(255,255,255,.03); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px;
}
.chip .k { font-size: 11px; color: var(--muted); }
.chip .v { font-size: 18px; font-weight: 600; margin-top: 2px; }

/* ---------- broker groups ---------- */
.cards { display: grid; gap: 18px; }
.broker-group { display: grid; gap: 10px; }
.broker-head { display: flex; align-items: baseline; justify-content: space-between;
  padding: 0 2px; border-left: 3px solid var(--accent); padding-left: 8px; }
.broker-name { font-weight: 700; font-size: 15px; letter-spacing: .01em; }
.broker-meta { font-size: 11px; color: var(--muted); }
.broker-cards { display: grid; gap: 12px; }
.status .upd { font-variant-numeric: tabular-nums; }

/* ---------- account cards ---------- */
.card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
.card .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card .name { font-weight: 600; font-size: 16px; }
.card .broker { font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.stale { background: #e6b800; }
.dot.offline { background: var(--red); }
.status { font-size: 11px; color: var(--muted); display: flex; align-items: center; }
.card .balance { font-size: 28px; font-weight: 700; margin: 10px 0 2px; }
.card .equity { font-size: 12px; color: var(--muted); }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.metric { background: var(--bg-card2); border-radius: 10px; padding: 8px 10px; }
.metric .k { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.metric .v { font-size: 15px; font-weight: 600; margin-top: 3px; }
.transfers { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line);
  font-size: 12px; color: var(--muted); }
.transfers .pos, .transfers .neg { font-weight: 600; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.pos { background: var(--green-dim); color: var(--green); }
.pill.neg { background: var(--red-dim); color: var(--red); }

/* ---------- tabs / bottom nav ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: rgba(11,15,20,.92); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; min-height: 56px; background: none; border: 0; color: var(--muted);
  font-size: 12px; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; cursor: pointer;
}
.tabbar button .ic { font-size: 18px; }
.tabbar button.active { color: var(--accent); }

.view { display: none; }
.view.active { display: block; }

/* ---------- controls ---------- */
.controls { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.controls select {
  flex: 1; min-height: var(--tap); background: var(--bg-card); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; font-size: 15px;
}
.chart-wrap { background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px; margin-bottom: 14px; }
.chart-wrap canvas { width: 100% !important; }

/* ---------- daily/monthly list (no wide tables) ---------- */
.list { display: grid; gap: 8px; }
.row-item {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 4px 10px;
}
.row-item .date { font-weight: 600; }
.row-item .sub { font-size: 12px; color: var(--muted); }
.row-item .pnl { text-align: right; font-weight: 700; }
.row-item .pct { text-align: right; font-size: 12px; }

.ops-head { font-size: 12px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .06em; margin: 14px 2px 2px; font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.updated { text-align: center; font-size: 11px; color: var(--muted); margin: 10px 0 0; }
.loading { text-align: center; color: var(--muted); padding: 20px; }

@media (min-width: 560px) {
  .broker-cards { grid-template-columns: 1fr 1fr; }
  .summary .big { font-size: 40px; }
}
