:root {
  --bg: #0b0e14;
  --panel: #12161f;
  --panel2: #171c27;
  --border: #232a38;
  --text: #e5e9f0;
  --muted: #8b93a7;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --blue: #3b82f6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }

.tag {
  font-size: 10px; font-weight: 700; letter-spacing: .5px;
  background: #134e2a; color: #4ade80; padding: 3px 8px; border-radius: 999px;
}
.tag.live { background: #4a1219; color: #fca5a5; }

.hstat { display: flex; align-items: center; gap: 14px; }
.conn { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #f59e0b; display: inline-block; }
.dot.ok { background: var(--green); }
.dot.err { background: var(--red); }

nav#tabs { display: flex; gap: 6px; padding: 10px 16px 0; background: var(--panel); border-bottom: 1px solid var(--border); }
nav#tabs button {
  background: transparent; border: none; color: var(--muted);
  padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  border-bottom: 2px solid transparent;
}
nav#tabs button.active { color: var(--text); border-bottom-color: var(--blue); }
nav#tabs button:hover { color: var(--text); }

main { padding: 16px; max-width: 1240px; margin: 0 auto; }
.tab { display: none; }
.tab.active { display: block; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px; }
.c-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 5px; }
.c-value { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.c-sub { color: var(--muted); font-size: 11px; margin-top: 3px; }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.panel h2 { margin: 0 0 8px; font-size: 14px; font-weight: 700; }
.panel-head h2 { margin: 0; }

.grid2 { display: grid; grid-template-columns: minmax(320px, 1fr) 1.4fr; gap: 14px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 980px) { .grid2 { grid-template-columns: 1fr; } }

.note { color: var(--muted); font-size: 12px; margin: 6px 0 10px; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 5px; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .5px; padding: 7px 8px; border-bottom: 1px solid var(--border);
}
.tbl td { padding: 8px; border-bottom: 1px solid rgba(35, 42, 56, .55); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: none; }
.empty { color: var(--muted); text-align: center; padding: 14px 8px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.pos { color: var(--green); font-weight: 600; }
.neg { color: var(--red); font-weight: 600; }
.warn { color: var(--amber); font-weight: 600; }
.muted { color: var(--muted); }

.chip {
  display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 7px;
  border-radius: 999px; letter-spacing: .3px;
}
.chip.buy { background: #0e2f1d; color: #4ade80; }
.chip.sell { background: #3b1216; color: #fca5a5; }
.chip.info { background: #122647; color: #93c5fd; }
.chip.bemode { background: #103046; color: #7dd3fc; }
.chip.trail { background: #2a2145; color: #c4b5fd; }
.chip.sl { background: #3b1216; color: #fca5a5; }

/* buttons + inputs */
.btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: #33405a; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #2f6fe0; }
.btn.danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
.btn.danger:hover { background: #a51d1d; }
.btn.good { background: #15803d; border-color: #15803d; color: #fff; }
.btn.small { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link { background: none; border: none; color: var(--blue); cursor: pointer; text-decoration: underline; padding: 0; font-size: inherit; }

.txt {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 11px; font-size: 13px; width: 150px;
}
.txt.small-in { width: 70px; }
.txt:focus, .btn:focus { outline: 1px solid var(--blue); }

select.txt { width: 100%; }

.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-actions.pad { margin-bottom: 12px; padding: 0 2px; }

/* forms */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 14px; }
@media (max-width: 700px) { .form { grid-template-columns: 1fr; } }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form input[type="number"], .form input[type="text"], .form input[type="password"], .form select {
  background: var(--panel2); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 13px;
}
.form .chk { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }
.form .chk input { width: 16px; height: 16px; accent-color: var(--blue); }

.steps { color: var(--muted); font-size: 13px; line-height: 1.7; padding-left: 20px; }
.steps a { color: var(--blue); }

/* banners */
.banner { padding: 11px 14px; border-radius: 10px; margin: 0 0 14px; font-size: 13px; line-height: 1.6; }
.banner.info { background: #122647; border: 1px solid #1e3a8a; color: #bfdbfe; }
.banner.error { background: #3b1216; border: 1px solid #7f1d1d; color: #fecaca; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.hidden { display: none !important; }

/* events feed */
.feed { display: flex; flex-direction: column; gap: 3px; max-height: 420px; overflow-y: auto; }
.feed .ev { display: flex; gap: 8px; align-items: baseline; padding: 4px 2px; border-bottom: 1px solid rgba(35, 42, 56, .4); font-size: 12.5px; }
.feed .ev .t { color: var(--muted); font-variant-numeric: tabular-nums; flex: 0 0 62px; }
.feed .ev .m { flex: 1; word-break: break-word; white-space: normal; }
.ev.success .m { color: #86efac; }
.ev.error .m { color: #fca5a5; }
.ev.warn .m { color: #fcd34d; }

/* toast */
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #1f2937; border: 1px solid var(--border); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 13px; opacity: 0;
  transition: all .25s ease; z-index: 50; max-width: 80vh; box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.error { background: #450a0a; border-color: #b91c1c; }
.toast.success { background: #052e16; border-color: #15803d; }

/* auth overlay */
.overlay {
  position: fixed; inset: 0; background: rgba(5, 8, 14, .82); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.auth-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 26px; width: min(400px, 92vw);
}
.auth-card h2 { margin: 0 0 6px; }
.auth-card .txt { width: 100%; margin: 10px 0 4px; }
