:root {
  --bg: #07080c;
  --bg-2: #0c0e15;
  --panel: rgba(255, 255, 255, 0.025);
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #e8ecf1;
  --muted: #7c8595;
  --accent: #5ee7df;
  --accent-2: #8b5cf6;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #fb7185;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

.bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(94, 231, 223, 0.10), transparent 60%),
    radial-gradient(700px 400px at 90% 10%, rgba(139, 92, 246, 0.10), transparent 60%),
    linear-gradient(var(--bg), var(--bg-2));
}
.bg::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 0%, black 30%, transparent 75%);
}

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 28px 40px 8px;
  max-width: 1200px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 {
  margin: 0; font-size: 18px; font-weight: 600; letter-spacing: 0.22em;
}
.brand h1 span { color: var(--accent); }
.dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--muted);
  box-shadow: 0 0 0 0 rgba(94,231,223,0.4);
}
.dot.active { background: var(--accent); animation: pulse 2.4s infinite; }
.dot.paused { background: var(--warn); }
.dot.halted { background: var(--bad); }
.dot.running { background: var(--accent-2); animation: pulse 0.9s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(94,231,223,0.45); }
  70% { box-shadow: 0 0 0 10px rgba(94,231,223,0); }
  100% { box-shadow: 0 0 0 0 rgba(94,231,223,0); }
}
.pill {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 5px 10px; border: 1px solid var(--line-2); border-radius: 999px; color: var(--muted);
}
.pill.live { color: var(--bad); border-color: rgba(251,113,133,0.4); }
.pill.paper { color: var(--accent); border-color: rgba(94,231,223,0.4); }
.pill.active { color: var(--good); border-color: rgba(52,211,153,0.4); }
.pill.paused { color: var(--warn); border-color: rgba(251,191,36,0.4); }
.pill.halted { color: var(--bad); border-color: rgba(251,113,133,0.5); background: rgba(251,113,133,0.08); }
.clock { text-align: right; }
.label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); }

/* ---------- layout ---------- */
main { max-width: 1200px; margin: 0 auto; padding: 16px 40px 40px; display: grid; gap: 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .top, main { padding-left: 20px; padding-right: 20px; }
  .hero { grid-template-columns: 1fr !important; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px;
  backdrop-filter: blur(8px);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.card h2 { margin: 0; font-size: 12px; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }

/* ---------- hero ---------- */
.hero {
  display: grid; grid-template-columns: 1.3fr 1fr; gap: 18px;
  padding: 28px 30px;
  background: linear-gradient(135deg, rgba(94,231,223,0.06), rgba(139,92,246,0.05) 60%, transparent);
  border: 1px solid var(--line);
  border-radius: 20px;
}
.equity { font-size: 64px; font-weight: 500; line-height: 1; margin: 10px 0 8px; letter-spacing: -0.02em; }
.equity small { font-size: 22px; color: var(--muted); margin-left: 6px; }
.delta { font-size: 14px; color: var(--muted); }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.hero-side { display: grid; gap: 16px; align-content: start; }
.stat .mono { font-size: 22px; margin-top: 4px; }
.stat .mono.small { font-size: 14px; color: var(--text); }
.bar { height: 3px; background: var(--line-2); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.6s ease; }
.bar-fill.warn { background: linear-gradient(90deg, var(--good), var(--warn), var(--bad)); }

/* ---------- chart ---------- */
.chart-card svg { width: 100%; height: 220px; display: block; }
.chart-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; }

/* ---------- positions ---------- */
.positions { display: grid; gap: 12px; }
.pos {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 14px; align-items: center;
  padding: 14px; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(255,255,255,0.015);
}
.pos .sym {
  font-family: var(--mono); font-weight: 600; font-size: 15px;
  width: 56px; height: 56px; display: grid; place-items: center;
  border-radius: 12px; border: 1px solid var(--line-2);
  color: var(--accent);
}
.pos .sym.out { color: var(--muted); border-style: dashed; }
.pos .meta { display: grid; gap: 6px; }
.pos .row { display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; }
.pos .value { font-size: 20px; }
.pos .tag { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--muted); }
.pos .tag.in { color: var(--good); border-color: rgba(52,211,153,0.4); }
.pos .tag.out { color: var(--muted); }
.pos .sub { font-size: 12px; color: var(--muted); }
.pos .weight { text-align: right; }
.pos .weight .mono { font-size: 16px; }
.pos .wbar { width: 90px; height: 3px; background: var(--line-2); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.pos .wbar div { height: 100%; background: var(--accent); }

/* ---------- controls ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  padding: 10px 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line-2); background: rgba(255,255,255,0.04); color: var(--text);
  transition: all 0.15s ease;
}
.btn:hover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(94,231,223,0.12); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.btn.primary { background: var(--accent); color: #04110f; border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(251,113,133,0.5); color: var(--bad); }
.btn.danger:hover { box-shadow: 0 0 0 3px rgba(251,113,133,0.15); border-color: var(--bad); }
.controls + .hint { margin: 12px 0 0; line-height: 1.5; }
.action { font-size: 12px; color: var(--muted); margin-top: 12px; min-height: 16px; }
.action.ok { color: var(--good); }
.action.err { color: var(--bad); }
.rules { display: grid; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.rules div { display: flex; justify-content: space-between; font-size: 13px; }
.rules .mono { color: var(--text); }

/* ---------- tables / logs ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table td { padding: 9px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .side { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; }
.table .side.buy { color: var(--good); }
.table .side.sell { color: var(--bad); }
.table .side.failed { color: var(--warn); }
.table .when { color: var(--muted); font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.table .why { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); font-size: 13px; padding: 10px 0; }
.log { list-style: none; margin: 0; padding: 0; font-size: 12px; max-height: 320px; overflow: auto; }
.log li { padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--muted); display: grid; grid-template-columns: 118px 1fr; gap: 10px; }
.log li:last-child { border-bottom: 0; }
.log li .when { color: var(--muted); opacity: 0.7; }
.log li.warn { color: var(--warn); }
.log li.error { color: var(--bad); }
.log li.info .msg { color: var(--text); opacity: 0.85; }

.foot {
  max-width: 1200px; margin: 0 auto; padding: 0 40px 30px;
  display: flex; justify-content: space-between; font-size: 11px; color: var(--muted);
}
.err { color: var(--bad); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(4,5,8,0.7); display: grid; place-items: center; z-index: 10; backdrop-filter: blur(4px); }
.modal-box { width: min(440px, 92vw); background: #0e1119; border: 1px solid var(--line-2); border-radius: 16px; padding: 22px 24px; }
.modal-box h3 { margin: 0 0 8px; font-size: 15px; }
.modal-box p { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
