/* ─────────────────────────────────────────────────────────────────────────────
   CryptoPlatform — Professional Trading UI
   ───────────────────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

/* ── Design Tokens ─────────────────────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg:        #f4f7fb;
  --bg-s:      #ffffff;
  --bg-s2:     #ffffff;
  --bg-s3:     #f1f5f9;
  --bg-input:  #ffffff;

  /* Borders */
  --bd:        #dbe3ee;
  --bd2:       #c6d1df;
  --bd3:       #93a2b8;

  /* Text */
  --tx:        #172033;
  --tx2:       #5e6a80;
  --tx3:       #9aa5b6;

  /* Accent */
  --blue:      #315eea;
  --blue2:     #244bd1;
  --indigo:    #6b55df;
  --cyan:      #089fc0;
  --purple:    #7f56d9;

  /* Trading */
  --green:     #078760;
  --green-bg:  rgba(7,135,96,.1);
  --green-bd:  rgba(7,135,96,.25);
  --red:       #d92d52;
  --red-bg:    rgba(217,45,82,.1);
  --red-bd:    rgba(217,45,82,.25);
  --yellow:    #b77900;
  --orange:    #db6b1f;

  /* Sidebar */
  --sidebar:   220px;

  /* Radius */
  --r:         10px;
  --r2:        8px;
  --r3:        6px;
  --r4:        4px;
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  background: var(--bg);
  color: var(--tx);
  min-height: 100vh;
  display: flex;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bd2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--bd3); }

/* ═══════════════════════════════════════════════════════════════════════════════
   AUTH SCREEN
   ═══════════════════════════════════════════════════════════════════════════════ */
#auth-screen {
  width: 100%; min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  position: relative; overflow: hidden;
}

/* Animated background grid */
#auth-screen::before {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--bd) 1px, transparent 1px),
    linear-gradient(90deg, var(--bd) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: .45;
}

/* Glow orbs */
#auth-screen::after {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(79,115,255,.12) 0%, transparent 70%);
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  pointer-events: none;
}

.login-card {
  position: relative; z-index: 10;
  background: rgba(255,255,255,.9);
  backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid var(--bd2);
  border-radius: 16px;
  padding: 44px 40px;
  width: 400px;
  box-shadow: 0 24px 80px rgba(15,23,42,.14), 0 0 0 1px rgba(49,94,234,.08);
}

.login-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 28px;
}
.login-logo-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, #4f73ff, #7c5ff5);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.login-logo-text { font-size: 20px; font-weight: 700; color: var(--tx); }
.login-logo-text span { background: linear-gradient(90deg, #4f73ff, #7c5ff5); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.login-tagline { color: var(--tx2); font-size: 13px; margin-bottom: 32px; }

.login-card .form-group { margin-bottom: 14px; }
.login-card .form-label {
  display: block; margin-bottom: 6px;
  font-size: 11px; font-weight: 600; color: var(--tx2); text-transform: uppercase; letter-spacing: .6px;
}
.login-card .form-input {
  width: 100%; background: var(--bg-input);
  border: 1px solid var(--bd); border-radius: var(--r2);
  color: var(--tx); padding: 11px 14px;
  font-size: 14px; font-family: inherit; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.login-card .form-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79,115,255,.15);
}

#login-error {
  background: var(--red-bg); border: 1px solid var(--red-bd);
  border-radius: var(--r3); padding: 9px 12px;
  color: var(--red); font-size: 12px; margin-bottom: 12px; display: none;
}

.btn-login {
  width: 100%; padding: 12px;
  background: linear-gradient(135deg, var(--blue), var(--indigo));
  color: #fff; border: none; border-radius: var(--r2);
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: opacity .2s, transform .1s;
  letter-spacing: .2px;
}
.btn-login:hover { opacity: .9; }
.btn-login:active { transform: scale(.99); }

/* ═══════════════════════════════════════════════════════════════════════════════
   APP LAYOUT
   ═══════════════════════════════════════════════════════════════════════════════ */
#app { display: flex; width: 100%; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar); min-height: 100vh;
  background: var(--bg-s);
  border-right: 1px solid var(--bd);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; z-index: 200;
}

.sidebar-brand {
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--bd);
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
}

.env-switch {
  margin: 0 16px 14px;
  padding: 10px;
  border: 1px solid var(--bd);
  border-radius: 10px;
  background: var(--bg-s2);
}
.env-switch-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--tx2);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .5px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.env-mode-label {
  color: var(--blue);
}
.env-mode-label.live {
  color: var(--green);
}
.env-switch-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.env-switch-btn {
  border: 1px solid var(--bd);
  background: var(--bg-s3);
  color: var(--tx2);
  border-radius: 8px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  padding: 7px 8px;
  text-transform: uppercase;
}
.env-switch-btn.active[data-env="demo"] {
  border-color: rgba(49,94,234,.45);
  background: rgba(49,94,234,.12);
  color: var(--blue);
}
.env-switch-btn.active[data-env="live"] {
  border-color: rgba(7,135,96,.45);
  background: rgba(7,135,96,.12);
  color: var(--green);
}
.brand-icon {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--blue), var(--indigo));
  display: flex; align-items: center; justify-content: center;
}
.brand-icon svg { width: 18px; height: 18px; fill: #fff; }
.brand-name { font-size: 15px; font-weight: 700; color: var(--tx); }
.brand-sub  { font-size: 9px; font-weight: 500; color: var(--tx2); letter-spacing: .5px; text-transform: uppercase; margin-top: 1px; }

/* Nav */
.sidebar-nav { padding: 12px 8px; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r2);
  cursor: pointer; color: var(--tx2); font-weight: 500;
  transition: background .15s, color .15s;
  margin-bottom: 2px; position: relative;
}
.nav-item:hover { background: var(--bg-s2); color: var(--tx); }
.nav-item.active {
  background: rgba(79,115,255,.1);
  color: var(--blue);
}
.nav-item.active::before {
  content: ''; position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 2px; border-radius: 2px;
  background: linear-gradient(180deg, var(--blue), var(--indigo));
  margin-left: -2px;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-label { font-size: 13px; }

/* Sidebar ticker */
.sidebar-ticker {
  padding: 12px 16px;
  border-top: 1px solid var(--bd);
  border-bottom: 1px solid var(--bd);
}
.ticker-label { font-size: 10px; color: var(--tx3); font-weight: 600; letter-spacing: .6px; text-transform: uppercase; margin-bottom: 4px; }
.ticker-price { font-family: 'JetBrains Mono', monospace; font-size: 16px; font-weight: 600; color: var(--tx); transition: color .3s; }
.ticker-price.flash-up   { color: var(--green) !important; }
.ticker-price.flash-down { color: var(--red) !important; }
.ticker-change { font-size: 11px; margin-top: 2px; }

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--blue), var(--indigo));
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12px; font-weight: 600; color: var(--tx); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--tx2); }
.logout-btn {
  background: none; border: none; cursor: pointer;
  color: var(--tx3); padding: 4px; border-radius: 4px;
  transition: color .15s;
}
.logout-btn:hover { color: var(--red); }
.logout-btn svg { width: 14px; height: 14px; display: block; }

/* WS status */
.ws-indicator {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--tx3); flex-shrink: 0;
  transition: background .3s;
}
.ws-indicator.connected { background: var(--green); box-shadow: 0 0 6px var(--green); }

/* ── Main content ──────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar); flex: 1;
  min-height: 100vh; display: flex; flex-direction: column;
  min-width: 0;
}

/* Top bar */
.topbar {
  height: 56px; padding: 0 24px;
  background: var(--bg-s);
  border-bottom: 1px solid var(--bd);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-page { font-size: 15px; font-weight: 700; color: var(--tx); }
.topbar-sep { color: var(--tx3); }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.topbar-btc {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-s2); border: 1px solid var(--bd);
  border-radius: var(--r2); padding: 6px 12px;
}
.topbar-btc-label { font-size: 10px; color: var(--tx2); font-weight: 600; letter-spacing: .4px; }
.topbar-btc-price {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; font-weight: 600; color: var(--tx);
  transition: color .3s;
}
.topbar-btc-price.flash-up   { color: var(--green); }
.topbar-btc-price.flash-down { color: var(--red); }
.topbar-clock { font-size: 12px; color: var(--tx2); font-variant-numeric: tabular-nums; }

/* Page content */
.page-wrap { padding: 24px; flex: 1; min-width: 0; max-width: 100%; overflow-x: hidden; }

/* ── Pages ──────────────────────────────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

.page-header { margin-bottom: 24px; }
.page-header-row { display: flex; align-items: center; justify-content: space-between; }
.page-title { font-size: 18px; font-weight: 700; color: var(--tx); }
.page-sub { font-size: 12px; color: var(--tx2); margin-top: 3px; }

/* ═══════════════════════════════════════════════════════════════════════════════
   COMPONENTS
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Card */
.card {
  background: var(--bg-s2);
  border: 1px solid var(--bd);
  border-radius: var(--r);
  padding: 18px 20px;
}
.card + .card { margin-top: 16px; }

.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 11px; font-weight: 700; color: var(--tx2);
  text-transform: uppercase; letter-spacing: .7px;
}

/* KPI stat card */
.stat-card {
  background: var(--bg-s2); border: 1px solid var(--bd);
  border-radius: var(--r); padding: 18px 20px;
  position: relative; overflow: hidden;
  transition: border-color .2s;
}
.stat-card:hover { border-color: var(--bd2); }
.stat-card::before {
  content: ''; position: absolute;
  top: 0; left: 0; bottom: 0; width: 2px;
}
.stat-card.accent-blue::before   { background: linear-gradient(180deg, var(--blue), var(--indigo)); }
.stat-card.accent-green::before  { background: linear-gradient(180deg, var(--green), #00a87a); }
.stat-card.accent-yellow::before { background: linear-gradient(180deg, var(--yellow), var(--orange)); }
.stat-card.accent-purple::before { background: linear-gradient(180deg, var(--purple), var(--indigo)); }

.stat-icon {
  width: 36px; height: 36px; border-radius: var(--r2);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.blue   { background: rgba(79,115,255,.12); color: var(--blue); }
.stat-icon.green  { background: rgba(0,211,149,.12);  color: var(--green); }
.stat-icon.yellow { background: rgba(255,184,0,.12);  color: var(--yellow); }
.stat-icon.purple { background: rgba(155,109,255,.12);color: var(--purple); }

.stat-label { font-size: 11px; color: var(--tx2); font-weight: 500; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--tx); line-height: 1; font-variant-numeric: tabular-nums; }
.stat-sub   { font-size: 11px; color: var(--tx2); margin-top: 6px; }

/* Grids */
.g4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.g3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.g2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (max-width: 1200px) { .g4 { grid-template-columns: repeat(2,1fr); } }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 20px;
  font-size: 10px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
  white-space: nowrap;
}
.b-green  { background: var(--green-bg);  color: var(--green); border: 1px solid var(--green-bd); }
.b-red    { background: var(--red-bg);    color: var(--red);   border: 1px solid var(--red-bd); }
.b-blue   { background: rgba(79,115,255,.1); color: var(--blue);  border: 1px solid rgba(79,115,255,.25); }
.b-gray   { background: rgba(107,115,148,.1); color: var(--tx2); border: 1px solid rgba(107,115,148,.2); }
.b-yellow { background: rgba(255,184,0,.1); color: var(--yellow); border: 1px solid rgba(255,184,0,.2); }
.b-indigo { background: rgba(155,109,255,.1); color: var(--purple); border: 1px solid rgba(155,109,255,.2); }

/* Status dot */
.dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  display: inline-block; vertical-align: middle;
}
.dot-green { background: var(--green); animation: pulse-green 2s infinite; }
.dot-red   { background: var(--red); }
.dot-gray  { background: var(--tx3); }
@keyframes pulse-green {
  0%,100% { box-shadow: 0 0 0 0 rgba(0,211,149,.4); }
  50%      { box-shadow: 0 0 0 4px rgba(0,211,149,0); }
}

/* ── Side pill (long/short) ──────────────────────────────────────────────────── */
.side-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 4px;
  font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase;
}
.side-long  { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-bd); }
.side-short { background: var(--red-bg);   color: var(--red);   border: 1px solid var(--red-bd); }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--r2); border: none;
  font-family: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all .15s; text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--indigo));
  color: #fff; box-shadow: 0 2px 12px rgba(79,115,255,.25);
}
.btn-primary:hover { opacity: .9; box-shadow: 0 4px 16px rgba(79,115,255,.35); }

.btn-success {
  background: var(--green-bg); color: var(--green);
  border: 1px solid var(--green-bd);
}
.btn-success:hover { background: rgba(0,211,149,.18); }

.btn-danger {
  background: var(--red-bg); color: var(--red);
  border: 1px solid var(--red-bd);
}
.btn-danger:hover { background: rgba(255,61,107,.18); }

.btn-ghost {
  background: var(--bg-s3); color: var(--tx); border: 1px solid var(--bd);
}
.btn-ghost:hover { border-color: var(--bd2); color: var(--tx); }

.btn-icon {
  background: var(--bg-s3); color: var(--tx2); border: 1px solid var(--bd);
  padding: 7px; border-radius: var(--r2);
}
.btn-icon:hover { color: var(--tx); border-color: var(--bd2); }
.btn-icon svg { width: 14px; height: 14px; display: block; }

.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-sm { padding: 5px 12px; font-size: 11px; }

/* ── Exchange tabs (Bots page) ───────────────────────────────────────────────── */
.ex-tabs {
  display: flex; gap: 6px; margin-bottom: 20px;
  overflow-x: auto; padding-bottom: 2px;
}
.ex-tabs::-webkit-scrollbar { height: 3px; }

.ex-tab {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 16px; border-radius: var(--r);
  cursor: pointer; flex-shrink: 0;
  background: var(--bg-s2); border: 1px solid var(--bd);
  transition: border-color .15s, background .15s;
  min-width: 148px;
}
.ex-tab:hover { border-color: var(--bd2); }
.ex-tab.active {
  background: rgba(79,115,255,.08);
  border-color: var(--blue);
  box-shadow: 0 0 0 1px rgba(79,115,255,.15);
}

.ex-tab-top { display: flex; align-items: center; gap: 8px; }
.ex-tab-logo { font-size: 18px; line-height: 1; }
.ex-tab-info { flex: 1; min-width: 0; }
.ex-tab-name {
  font-size: 12px; font-weight: 700; color: var(--tx);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ex-tab-mode { font-size: 9px; color: var(--tx2); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }

.ex-tab-price {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px; font-weight: 700; color: var(--tx);
  transition: color .3s; margin-top: 4px;
}
.ex-tab-price.no-price { color: var(--tx3); font-size: 11px; font-family: inherit; font-weight: 400; }
.ex-tab-price.flash-up   { color: var(--green); }
.ex-tab-price.flash-down { color: var(--red); }

.ex-tab-status { margin-top: 3px; }

/* No exchange connected empty state */
.no-exchange-state {
  text-align: center; padding: 60px 24px;
  background: var(--bg-s2); border: 1px dashed var(--bd2);
  border-radius: var(--r);
}
.no-exchange-state .empty-icon { font-size: 42px; margin-bottom: 14px; opacity: .5; }
.no-exchange-state .empty-title { font-size: 16px; font-weight: 700; color: var(--tx2); margin-bottom: 6px; }
.no-exchange-state .empty-sub   { font-size: 13px; color: var(--tx3); line-height: 1.6; }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block; margin-bottom: 6px;
  font-size: 10px; font-weight: 700; color: var(--tx2);
  text-transform: uppercase; letter-spacing: .6px;
}
.form-input, .form-select {
  width: 100%; background: var(--bg-input);
  border: 1px solid var(--bd); border-radius: var(--r2);
  color: var(--tx); padding: 9px 12px;
  font-size: 13px; font-family: inherit; outline: none;
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
}
.form-input:focus, .form-select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79,115,255,.12);
}
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7394' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px;
}
.form-select option { background: #fff; color: var(--tx); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: 10px; color: var(--tx2); margin-top: 4px; }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 1px solid var(--bd); }
th {
  padding: 9px 12px; text-align: left;
  font-size: 10px; font-weight: 700; color: var(--tx2);
  text-transform: uppercase; letter-spacing: .6px;
  white-space: nowrap;
}
td {
  padding: 10px 12px; font-size: 12px;
  border-bottom: 1px solid var(--bd);
  color: var(--tx); white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(49,94,234,.04); }
.text-right { text-align: right; }
.text-green { color: var(--green); }
.text-red   { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-muted { color: var(--tx2); }
.mono { font-family: 'JetBrains Mono', monospace; }
.skeleton {
  animation: skeleton-pulse 1.15s ease-in-out infinite;
  background: linear-gradient(90deg, var(--bg-s3) 25%, #e8eef6 38%, var(--bg-s3) 63%);
  background-size: 400% 100%;
  border-radius: var(--r3);
  display: block;
}
.skeleton-line {
  height: 12px;
  width: 100%;
}
.skeleton-card {
  background: var(--bg-s2);
  border: 1px solid var(--bd);
  border-radius: var(--r2);
  padding: 14px;
}
.skeleton-stack {
  display: grid;
  gap: 10px;
}
.skeleton-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.skeleton-row td {
  padding: 14px 10px;
}
@keyframes skeleton-pulse {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

/* Empty state */
.empty-row td {
  text-align: center; padding: 32px;
  color: var(--tx2); font-size: 12px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   DASHBOARD
   ═══════════════════════════════════════════════════════════════════════════════ */

/* Exchange status cards */
.exchange-strip {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.ex-card {
  background: var(--bg-s3); border: 1px solid var(--bd);
  border-radius: var(--r2); padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  transition: border-color .2s;
}
.ex-card:hover { border-color: var(--bd2); }
.ex-logo {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.ex-info { flex: 1; min-width: 0; }
.ex-name { font-size: 13px; font-weight: 600; color: var(--tx); }
.ex-mode { font-size: 10px; color: var(--tx2); margin-top: 1px; }
.ex-status { margin-left: auto; }

/* Bot summary row */
.bot-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-s3); border: 1px solid var(--bd);
  border-radius: var(--r2); padding: 12px 16px;
  margin-bottom: 8px; transition: border-color .2s;
}
.bot-row:hover { border-color: var(--bd2); }
.bot-row:last-child { margin-bottom: 0; }
.bot-row-left { display: flex; align-items: center; gap: 10px; }
.bot-strategy-icon {
  width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   P&NL
   ═══════════════════════════════════════════════════════════════════════════════ */
.pnl-filter {
  width: 190px;
}
.pnl-position-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.pnl-status-tags {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.pnl-status-tag {
  background: var(--bg-s3);
  border: 1px solid var(--bd);
  border-radius: 20px;
  color: var(--tx2);
  cursor: pointer;
  font-family: inherit;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .4px;
  padding: 5px 10px;
  text-transform: uppercase;
  transition: all .15s;
}
.pnl-status-tag:hover {
  border-color: var(--bd2);
  color: var(--tx);
}
.pnl-status-tag.active {
  background: rgba(79,115,255,.14);
  border-color: rgba(79,115,255,.38);
  color: var(--blue);
}
.pnl-account-grid.hidden {
  display: none;
}
.pnl-year-pill {
  background: var(--bg-s2);
  border: 1px solid var(--bd);
  border-radius: var(--r2);
  color: var(--tx);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 800;
  min-width: 72px;
  padding: 8px 12px;
  text-align: center;
}
.pnl-calendar-toolbar {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}
.pnl-calendar-legend {
  align-items: center;
  color: var(--tx2);
  display: inline-flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11px;
  font-weight: 700;
}
.pnl-calendar-legend span {
  align-items: center;
  display: inline-flex;
  gap: 5px;
}
.legend-dot {
  border-radius: 999px;
  display: inline-block;
  height: 8px;
  width: 8px;
}
.legend-dot.green { background: var(--green); }
.legend-dot.red { background: var(--red); }
.legend-dot.gray { background: var(--tx3); }
.pnl-month-grid {
  margin-bottom: 18px;
}
.pnl-heatmap-card {
  background: var(--bg-s2);
  border: 1px solid var(--bd);
  border-radius: var(--r2);
  overflow: hidden;
  padding: 14px;
}
.pnl-heatmap-head {
  align-items: center;
  color: var(--tx);
  display: flex;
  font-size: 13px;
  justify-content: space-between;
  margin-bottom: 14px;
}
.pnl-heatmap-months {
  color: var(--tx2);
  display: grid;
  font-size: 12px;
  gap: 5px;
  grid-template-columns: repeat(53, 16px);
  margin: 0 0 8px 0;
  min-width: 850px;
  width: max-content;
}
.pnl-heatmap-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}
.pnl-heatmap-grid {
  display: grid;
  grid-auto-flow: column;
  grid-template-rows: repeat(7, 16px);
  gap: 5px;
  min-width: 850px;
  width: max-content;
}
.pnl-heatday {
  background: #ebedf0;
  border: 1px solid #d9dee5;
  border-radius: 4px;
  cursor: pointer;
  height: 16px;
  padding: 0;
  width: 16px;
}
.pnl-heatday-out {
  opacity: .28;
}
.pnl-heatday:disabled {
  cursor: default;
}
.pnl-heatday.selected {
  box-shadow: 0 0 0 2px var(--blue);
}
.pnl-heatday.skeleton {
  background: linear-gradient(90deg, var(--bg-s3) 25%, #e8eef6 38%, var(--bg-s3) 63%);
  background-size: 400% 100%;
}
.pnl-heat-profit-1 { background: #9be9a8; border-color: #7ddc8e; }
.pnl-heat-profit-2 { background: #40c463; border-color: #31ad52; }
.pnl-heat-profit-3 { background: #30a14e; border-color: #278a42; }
.pnl-heat-profit-4 { background: #216e39; border-color: #1b5b30; }
.pnl-heat-loss-1 { background: #ffb3b8; border-color: #ff9aa2; }
.pnl-heat-loss-2 { background: #ff6b75; border-color: #f25560; }
.pnl-heat-loss-3 { background: #d73a49; border-color: #bf2f3d; }
.pnl-heat-loss-4 { background: #86181d; border-color: #6f1217; }
.pnl-heat-legend {
  align-items: center;
  display: inline-flex;
  gap: 5px;
}
.pnl-heat-legend i {
  background: #ebedf0;
  border: 1px solid #d9dee5;
  border-radius: 4px;
  display: inline-block;
  height: 14px;
  width: 14px;
}
.pnl-positions-card {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  width: 100%;
}
.pnl-positions-wrap {
  display: block;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  position: relative;
  width: 100%;
  -webkit-overflow-scrolling: touch;
}
.pnl-positions-table {
  min-width: 2200px;
  table-layout: auto;
  width: max-content;
}
.pnl-positions-table th,
.pnl-positions-table td {
  background: var(--bg-s2);
  max-width: 220px;
  min-width: 112px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pnl-positions-table th:nth-child(1),
.pnl-positions-table td:nth-child(1) {
  left: 0;
  max-width: 100px;
  min-width: 100px;
  position: sticky;
  width: 100px;
  z-index: 3;
}
.pnl-positions-table th:nth-child(2),
.pnl-positions-table td:nth-child(2) {
  left: 100px;
  max-width: 140px;
  min-width: 140px;
  position: sticky;
  width: 140px;
  z-index: 3;
}
.pnl-positions-table th:nth-child(3),
.pnl-positions-table td:nth-child(3) {
  left: 240px;
  max-width: 96px;
  min-width: 96px;
  position: sticky;
  width: 96px;
  z-index: 3;
}
.pnl-positions-table th:nth-child(4),
.pnl-positions-table td:nth-child(4) {
  left: 336px;
  max-width: 190px;
  min-width: 170px;
  position: sticky;
  width: 190px;
  z-index: 3;
}
.pnl-positions-table th:nth-child(4),
.pnl-positions-table td:nth-child(4) {
  box-shadow: 10px 0 14px rgba(15,23,42,.08);
}
.pnl-positions-table th {
  z-index: 4;
}
.pnl-positions-table thead th:nth-child(-n+4) {
  z-index: 5;
}
.pnl-positions-table tbody tr:hover td {
  background: rgba(49,94,234,.04);
}
.pnl-positions-table .empty-row td {
  position: static;
  width: auto;
  box-shadow: none;
}
.pnl-positions-table th:nth-child(5),
.pnl-positions-table td:nth-child(5) {
  min-width: 140px;
}
.pnl-positions-table th:nth-child(7),
.pnl-positions-table td:nth-child(7),
.pnl-positions-table th:nth-child(8),
.pnl-positions-table td:nth-child(8) {
  min-width: 130px;
}
.pnl-positions-table th:nth-child(11),
.pnl-positions-table td:nth-child(11),
.pnl-positions-table th:nth-child(12),
.pnl-positions-table td:nth-child(12),
.pnl-positions-table th:nth-child(13),
.pnl-positions-table td:nth-child(13),
.pnl-positions-table th:nth-child(14),
.pnl-positions-table td:nth-child(14),
.pnl-positions-table th:nth-child(15),
.pnl-positions-table td:nth-child(15) {
  min-width: 140px;
}
.pnl-positions-table th:nth-last-child(-n+2),
.pnl-positions-table td:nth-last-child(-n+2) {
  min-width: 170px;
}
#page-pnl {
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}
.pnl-account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(460px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.pnl-account-card {
  background: var(--bg-s2);
  border: 1px solid var(--bd);
  border-radius: var(--r);
  padding: 16px;
}
.pnl-account-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.pnl-account-name {
  color: var(--tx);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
}
.pnl-account-sub {
  color: var(--tx2);
  font-size: 10px;
  margin-top: 2px;
}
.pnl-account-section-title {
  color: var(--tx2);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .6px;
  margin: 12px 0 7px;
  text-transform: uppercase;
}
.pnl-account-section-title:first-of-type {
  margin-top: 0;
}
.pnl-account-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.pnl-account-metrics div {
  background: var(--bg-s3);
  border: 1px solid var(--bd);
  border-radius: var(--r2);
  padding: 9px;
}
.pnl-account-metrics span,
.pnl-account-metrics small {
  display: block;
  color: var(--tx2);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.pnl-account-metrics strong {
  display: block;
  color: var(--tx);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  margin-top: 4px;
}
.pnl-account-metrics small {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  margin-top: 3px;
}
.wallet-metrics-inline strong {
  font-size: 13px;
}
.wallet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.wallet-card {
  background: var(--bg-s3);
  border: 1px solid var(--bd);
  border-radius: var(--r2);
  padding: 14px;
}
.wallet-card.wallet-error {
  border-color: var(--red-bd);
  background: var(--red-bg);
}
.wallet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.wallet-name { color: var(--tx); font-size: 13px; font-weight: 700; text-transform: uppercase; }
.wallet-sub { color: var(--tx2); font-size: 10px; margin-top: 2px; }
.wallet-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.wallet-metrics div {
  background: var(--bg-s2);
  border: 1px solid var(--bd);
  border-radius: var(--r3);
  padding: 8px;
}
.wallet-metrics span {
  display: block;
  color: var(--tx2);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 3px;
}
.wallet-metrics strong {
  color: var(--tx);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}
.wallet-error-text {
  color: var(--red);
  font-size: 11px;
  line-height: 1.4;
  word-break: break-word;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   ERROR LOGS
   ═══════════════════════════════════════════════════════════════════════════════ */
.logs-filters {
  display: flex; gap: 10px; align-items: flex-end;
}
.logs-filters > div { width: 150px; }
.logs-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.logs-action-tags {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 720px;
}
.log-action-tag {
  background: var(--bg-s3);
  border: 1px solid var(--bd);
  border-radius: 20px;
  color: var(--tx2);
  cursor: pointer;
  font-family: inherit;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .4px;
  padding: 5px 10px;
  text-transform: uppercase;
  transition: all .15s;
  white-space: nowrap;
}
.log-action-tag:hover {
  border-color: var(--bd2);
  color: var(--tx);
}
.log-action-tag.active {
  background: rgba(79,115,255,.14);
  border-color: rgba(79,115,255,.38);
  color: var(--blue);
}
.logs-pager {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.log-message {
  max-width: 520px;
  white-space: normal;
  word-break: break-word;
}
.bot-strategy-icon.scalping { background: rgba(79,115,255,.15); }
.bot-strategy-icon.breakout { background: rgba(0,211,149,.15); }
.bot-strategy-icon.all_in_one { background: rgba(127,86,217,.15); }

.bot-subaccount-list {
  display: grid;
  gap: 10px;
}
.bot-subaccount-group {
  border: 1px solid var(--bd);
  background: var(--bg-s2);
  border-radius: var(--r2);
  padding: 10px;
}
.bot-subaccount-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--tx);
}
.bot-subaccount-options {
  display: grid;
  gap: 7px;
}
.bot-subaccount-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border: 1px solid var(--bd);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--bg-s3);
  color: var(--tx);
}
.bot-subaccount-option.selected {
  border-color: var(--blue);
  background: rgba(49, 94, 234, .08);
}
.bot-subaccount-option input {
  accent-color: var(--blue);
}
.bot-subaccount-option span {
  display: grid;
  gap: 2px;
}
.bot-subaccount-option small {
  color: var(--tx2);
  font-family: var(--mono);
  font-size: 10px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   INVITE MEMBERS
   ═══════════════════════════════════════════════════════════════════════════════ */
.members-layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.member-password-box {
  margin-top: 16px;
  background: var(--bg-s3);
  border: 1px solid var(--bd);
  border-radius: var(--r2);
  padding: 12px;
}
.member-password-label {
  color: var(--tx2);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 8px;
}
.member-password-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.member-password-row code {
  flex: 1;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--bd);
  border-radius: var(--r3);
  padding: 8px;
  color: var(--tx);
  font-family: 'JetBrains Mono', monospace;
  overflow: auto;
}
.member-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   INTEGRATIONS
   ═══════════════════════════════════════════════════════════════════════════════ */
.int-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }

.int-card {
  background: var(--bg-s2); border: 1px solid var(--bd);
  border-radius: var(--r); padding: 22px;
  transition: border-color .2s, box-shadow .2s;
  position: relative; overflow: hidden;
}
.int-card:hover { border-color: var(--bd2); box-shadow: 0 4px 24px rgba(15,23,42,.1); }
.int-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
}
.int-card.delta-card::before   { background: linear-gradient(90deg, #ff6b1a, #ff9a50); }
.int-card.okx-card::before     { background: linear-gradient(90deg, #e0e0e0, #9a9aaa); }
.int-card.binance-card::before { background: linear-gradient(90deg, #f0b90b, #ffd74f); }

.int-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.int-logo-wrap { display: flex; align-items: center; gap: 12px; }
.int-logo {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.int-logo.delta   { background: rgba(255,107,26,.1); }
.int-logo.okx     { background: rgba(224,224,224,.06); }
.int-logo.binance { background: rgba(240,185,11,.1); }

.int-name { font-size: 15px; font-weight: 700; color: var(--tx); }
.int-desc { font-size: 11px; color: var(--tx2); margin-top: 2px; }
.int-mode-badge { margin-top: 4px; }

.int-divider { border: none; border-top: 1px solid var(--bd); margin: 14px 0; }
.int-desc-text { font-size: 12px; color: var(--tx2); line-height: 1.5; margin-bottom: 14px; }

.int-error {
  background: var(--red-bg); border: 1px solid var(--red-bd);
  border-radius: var(--r2); padding: 8px 10px;
  font-size: 11px; color: var(--red);
  margin-bottom: 12px; word-break: break-all;
}
.int-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════════════════════════════════
   STRATEGY BOTS
   ═══════════════════════════════════════════════════════════════════════════════ */
.bots-layout {
  display: block;
  width: 100%;
}

/* Chart card */
.chart-card {
  background: var(--bg-s2); border: 1px solid var(--bd);
  border-radius: var(--r); overflow: hidden;
}
.chart-topbar {
  padding: 14px 18px 0;
  display: flex; align-items: flex-start; justify-content: space-between;
}
.chart-pair { font-size: 15px; font-weight: 700; color: var(--tx); }
.chart-exch { font-size: 10px; color: var(--tx2); margin-top: 2px; }
.chart-live-block { text-align: right; }
.chart-price {
  font-family: 'JetBrains Mono', monospace;
  font-size: 20px; font-weight: 700; color: var(--tx);
  transition: color .3s;
}
.chart-price.flash-up   { color: var(--green); }
.chart-price.flash-down { color: var(--red); }
.chart-change { font-size: 11px; margin-top: 2px; color: var(--tx2); }

.test-order-bar {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--bd);
  flex-wrap: wrap;
}
.test-order-field {
  display: flex; flex-direction: column; gap: 4px;
}
.test-order-field span {
  color: var(--tx2); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px;
}
.test-order-field .form-input {
  width: 110px; padding: 6px 8px; font-size: 12px;
}

.chart-indicators {
  display: flex; gap: 16px; padding: 10px 18px;
  border-bottom: 1px solid var(--bd);
  flex-wrap: wrap;
}
.ci { display: flex; align-items: center; gap: 4px; font-size: 10px; }
.ci-label { color: var(--tx2); font-weight: 600; letter-spacing: .3px; }
.ci-val { font-family: 'JetBrains Mono', monospace; font-weight: 600; }
.ci-val.bull { color: var(--green); }
.ci-val.bear { color: var(--red); }
.ci-val.neutral { color: var(--tx); }

#tv-chart { height: 360px; }

/* Bot cards list */
.bot-card {
  background: var(--bg-s2); border: 1px solid var(--bd);
  border-radius: var(--r); padding: 16px;
  margin-bottom: 12px; transition: border-color .2s;
}
.bot-card:hover { border-color: var(--bd2); }
.bot-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.bot-card-name { font-size: 14px; font-weight: 700; color: var(--tx); display: flex; align-items: center; gap: 8px; }
.bot-running-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green);
  animation: pulse-green 2s infinite; flex-shrink: 0;
}

.bot-metrics {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-bottom: 12px;
}
.bot-metric {
  background: var(--bg-s3); border: 1px solid var(--bd);
  border-radius: var(--r2); padding: 8px 10px;
}
.bot-metric-label { font-size: 9px; color: var(--tx2); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; }
.bot-metric-val { font-size: 13px; font-weight: 700; color: var(--tx); font-variant-numeric: tabular-nums; }
.bot-metric-sub { color: var(--tx2); font-size: 10px; margin-top: 3px; }

/* Indicator chips */
.ind-chips { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 12px; }
.ind-chip {
  background: var(--bg-s3); border: 1px solid var(--bd);
  border-radius: var(--r3); padding: 3px 7px;
  font-size: 10px; color: var(--tx2);
}
.ind-chip strong { color: var(--tx); font-weight: 600; }

/* Active position display */
.pos-open {
  background: var(--bg-s3); border: 1px solid var(--bd);
  border-radius: var(--r2); padding: 10px 12px;
  margin-bottom: 12px;
}
.pos-open-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.pos-open-title { font-size: 10px; color: var(--tx2); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.pos-details { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.pos-detail { font-size: 10px; }
.pos-detail-label { color: var(--tx2); margin-bottom: 1px; }
.pos-detail-val { font-family: 'JetBrains Mono', monospace; font-weight: 600; color: var(--tx); font-size: 11px; }

.bot-actions { display: flex; gap: 8px; }

.bot-settings-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.28);
  opacity: 0; pointer-events: none;
  transition: opacity .18s;
  z-index: 350;
}
.bot-settings-backdrop.open { opacity: 1; pointer-events: auto; }
.bot-settings-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(420px, 100vw);
  background: var(--bg-s);
  border-left: 1px solid var(--bd);
  padding: 16px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform .2s ease;
  z-index: 360;
  box-shadow: -18px 0 50px rgba(15,23,42,.16);
}
.bot-settings-panel.open { transform: translateX(0); }
.bot-settings-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.bot-settings-title { color: var(--tx); font-size: 15px; font-weight: 700; }
.bot-settings-sub { color: var(--tx2); font-size: 11px; margin-top: 2px; }
.rules-status-card {
  background: var(--bg-s3);
  border: 1px solid var(--bd);
  border-radius: var(--r2);
  color: var(--tx2);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 12px;
  padding: 12px;
}
.rules-toggle-row {
  align-items: flex-start;
  background: var(--bg-s2);
  border: 1px solid var(--bd);
  border-radius: var(--r2);
  cursor: pointer;
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  padding: 12px;
}
.rules-toggle-row input {
  margin-top: 2px;
}
.rules-toggle-row strong,
.rules-toggle-row small {
  display: block;
}
.rules-toggle-row strong {
  color: var(--tx);
  font-size: 13px;
}
.rules-toggle-row small {
  color: var(--tx2);
  font-size: 11px;
  line-height: 1.45;
  margin-top: 3px;
}
.rules-day-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.rules-day {
  background: var(--bg-s3);
  border: 1px solid var(--bd);
  border-radius: var(--r2);
  color: var(--tx2);
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  padding: 9px 0;
}
.rules-day.active {
  background: var(--green-bg);
  border-color: var(--green-bd);
  color: var(--green);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   BACKTEST
   ═══════════════════════════════════════════════════════════════════════════════ */
.bt-file-pill {
  background: var(--bg-s2);
  border: 1px solid var(--bd);
  border-radius: var(--r2);
  color: var(--tx2);
  font-size: 11px;
  font-weight: 700;
  padding: 7px 10px;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bt-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.bt-layout {
  display: block;
  width: 100%;
}
.bt-right { min-width: 0; }
.bt-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.bt-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 14px;
}
.bt-mini-grid div {
  background: var(--bg-s3);
  border: 1px solid var(--bd);
  border-radius: var(--r2);
  padding: 9px 10px;
  min-width: 0;
}
.bt-mini-grid span {
  display: block;
  color: var(--tx2);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 4px;
}
.bt-mini-grid strong {
  display: block;
  color: var(--tx);
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#bt-chart { height: 420px; }
.bt-log {
  height: 150px;
  overflow: auto;
  background: var(--bg-s3);
  border: 1px solid var(--bd);
  border-radius: var(--r2);
}
.bt-log-line {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 8px;
  padding: 7px 9px;
  border-bottom: 1px solid var(--bd);
  font-size: 11px;
}
.bt-log-line:last-child { border-bottom: 0; }
.bt-log-line span {
  color: var(--tx2);
  font-family: 'JetBrains Mono', monospace;
}
.bt-log-line strong {
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
}
.bt-pager {
  display: flex;
  align-items: center;
  gap: 8px;
}
tr.bt-active-row td { background: rgba(79,115,255,.08); }
.bt-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s;
  z-index: 350;
}
.bt-panel-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.bt-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(430px, 100vw);
  background: var(--bg-s);
  border-left: 1px solid var(--bd);
  padding: 16px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform .2s ease;
  z-index: 360;
  box-shadow: -18px 0 50px rgba(15,23,42,.16);
}
.bt-panel.open { transform: translateX(0); }
.bt-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.bt-panel-title {
  color: var(--tx);
  font-size: 15px;
  font-weight: 700;
}
.bt-panel-sub {
  color: var(--tx2);
  font-size: 11px;
  margin-top: 2px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   BOT MONITOR
   ═══════════════════════════════════════════════════════════════════════════════ */
.monitor-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px auto;
  gap: 12px;
  align-items: end;
}
.monitor-live-toggle {
  padding-bottom: 14px;
}
.monitor-table {
  min-width: 1320px;
}
.monitor-table td {
  vertical-align: top;
}
.monitor-pairs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 390px;
}
.monitor-pairs span {
  background: var(--bg-s3);
  border: 1px solid var(--bd);
  border-radius: var(--r3);
  color: var(--tx);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 4px 6px;
}
.monitor-pairs b {
  color: var(--tx2);
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 800;
  margin-right: 4px;
}
.monitor-position {
  display: grid;
  gap: 4px;
}
.monitor-message {
  min-width: 220px;
  white-space: normal;
}
.monitor-error-row td {
  background: var(--red-bg);
}
.risk-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.risk-summary-card {
  background: var(--bg-s2);
  border: 1px solid var(--bd);
  border-radius: var(--r2);
  padding: 14px;
}
.risk-summary-card span {
  color: var(--tx2);
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .4px;
  text-transform: uppercase;
}
.risk-summary-card strong {
  color: var(--tx);
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 24px;
  margin-top: 8px;
}
.risk-monitor-table {
  min-width: 1450px;
}
.risk-open-table {
  min-width: 1180px;
}
.risk-reasons {
  max-width: 180px;
  white-space: normal;
}
.risk-rule-panel .form-hint {
  margin-top: 4px;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   BOTS UPLOADER
   ═══════════════════════════════════════════════════════════════════════════════ */
.uploader-layout {
  display: grid;
  grid-template-columns: minmax(360px, 460px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.pine-editor {
  min-height: 280px;
  resize: vertical;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.55;
}
.uploader-exchange-list,
.uploader-actions,
.upload-actions,
.upload-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.uploader-actions {
  margin-top: 16px;
}
.uploader-exchange-chip {
  align-items: center;
  background: var(--bg-s3);
  border: 1px solid var(--bd);
  border-radius: var(--r2);
  cursor: pointer;
  display: inline-flex;
  gap: 7px;
  padding: 7px 10px;
}
.uploader-exchange-chip input {
  accent-color: var(--blue);
}
.uploader-exchange-chip span {
  color: var(--tx);
  font-size: 11px;
  font-weight: 800;
}
.uploader-exchange-chip small {
  color: var(--tx2);
  font-size: 10px;
  text-transform: uppercase;
}
.upload-list {
  display: grid;
  gap: 12px;
}
.upload-card {
  background: var(--bg-s3);
  border: 1px solid var(--bd);
  border-radius: var(--r2);
  padding: 14px;
}
.upload-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.upload-name {
  color: var(--tx);
  font-size: 14px;
  font-weight: 700;
}
.upload-sub {
  color: var(--tx2);
  font-size: 11px;
  margin-top: 3px;
}
.upload-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.upload-metrics div {
  background: var(--bg-s2);
  border: 1px solid var(--bd);
  border-radius: var(--r3);
  padding: 8px;
}
.upload-metrics span {
  color: var(--tx2);
  display: block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .4px;
  text-transform: uppercase;
}
.upload-metrics strong {
  color: var(--tx);
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  margin-top: 3px;
}
.upload-preview {
  color: var(--tx2);
  font-size: 11px;
  line-height: 1.5;
  margin-top: 8px;
  overflow-wrap: anywhere;
}
.uploader-empty {
  color: var(--tx2);
  font-size: 12px;
  padding: 28px;
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SETTINGS
   ═══════════════════════════════════════════════════════════════════════════════ */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; max-width: 860px; }
.settings-card { background: var(--bg-s2); border: 1px solid var(--bd); border-radius: var(--r); padding: 22px; }
.settings-card-title { font-size: 14px; font-weight: 700; color: var(--tx); margin-bottom: 4px; }
.settings-card-sub { font-size: 12px; color: var(--tx2); margin-bottom: 20px; }
.settings-info-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--bd); }
.settings-info-row:last-child { border-bottom: none; }
.settings-info-label { font-size: 12px; color: var(--tx2); }
.settings-info-val { font-size: 12px; font-weight: 600; color: var(--tx); }

/* ═══════════════════════════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════════════════════════ */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,42,.36); backdrop-filter: blur(4px);
  z-index: 1000; align-items: center; justify-content: center;
  animation: fadeIn .15s ease;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-s2); border: 1px solid var(--bd2);
  border-radius: 14px; padding: 0;
  width: 480px; max-width: 95vw; max-height: 92vh;
  overflow-y: auto; box-shadow: 0 32px 80px rgba(15,23,42,.18);
  animation: slideUp .2s ease;
}
.modal-header {
  padding: 20px 24px 16px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--bd);
}
.modal-title { font-size: 15px; font-weight: 700; color: var(--tx); }
.modal-close {
  background: var(--bg-s3); border: 1px solid var(--bd);
  border-radius: 6px; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--tx2); transition: all .15s;
}
.modal-close:hover { color: var(--tx); border-color: var(--bd2); }
.modal-close svg { width: 14px; height: 14px; }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--bd);
  display: flex; gap: 10px; justify-content: flex-end;
}

@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Section label separator ─────────────────────────────────────────────────── */
.section-sep {
  font-size: 10px; font-weight: 700; color: var(--tx2);
  text-transform: uppercase; letter-spacing: .7px;
  padding: 6px 0; margin-bottom: 10px;
  border-bottom: 1px solid var(--bd);
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════════════════════════════════════════ */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--bg-s2); border: 1px solid var(--bd2);
  border-radius: 10px; padding: 12px 16px;
  font-size: 13px; color: var(--tx);
  animation: toastIn .2s ease;
  max-width: 320px;
  box-shadow: 0 8px 32px rgba(15,23,42,.14);
}
.toast-icon {
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px; font-size: 10px; font-weight: 700;
}
.toast-success .toast-icon { background: var(--green-bg); color: var(--green); }
.toast-error   .toast-icon { background: var(--red-bg);   color: var(--red); }
.toast-info    .toast-icon { background: rgba(79,115,255,.12); color: var(--blue); }
.toast-msg { line-height: 1.4; }
@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* Delta-style exchange position rows */
.delta-positions-table th,
.delta-positions-table td {
  white-space: nowrap;
  vertical-align: middle;
}
.delta-positions-table th {
  color: var(--tx2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.delta-positions-table th:not(.delta-check-col) {
  text-decoration: underline dashed;
  text-underline-offset: 6px;
  text-decoration-thickness: 1px;
}
.delta-positions-table td {
  font-size: 13px;
}
.delta-check-col {
  width: 34px;
  text-align: center;
}
.delta-check {
  align-items: center;
  background: #8b6cf6;
  border-radius: 4px;
  color: #fff;
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  height: 20px;
  justify-content: center;
  line-height: 1;
  width: 20px;
}
.delta-symbol-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.delta-side-line {
  width: 2px;
  height: 22px;
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
}
.delta-side-line.side-long { background: var(--green); }
.delta-side-line.side-short { background: var(--red); }
.delta-symbol-current {
  color: var(--tx3);
  font-size: 9px;
  line-height: 1;
  margin-bottom: 3px;
}
.delta-tpsl {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
}
.delta-tpsl-add {
  background: var(--bg-s3);
  border: 1px solid var(--bd);
  border-radius: var(--r3);
  color: var(--indigo);
  cursor: default;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
}
.delta-toggle {
  align-items: center;
  background: var(--bd3);
  border-radius: 999px;
  display: inline-flex;
  height: 18px;
  padding: 2px;
  width: 34px;
}
.delta-toggle span {
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(15,23,42,.2);
  display: block;
  height: 14px;
  transition: transform .15s;
  width: 14px;
}
.delta-toggle.on {
  background: var(--green);
}
.delta-toggle.on span {
  transform: translateX(16px);
}
.delta-share {
  color: var(--indigo);
  font-size: 17px;
  line-height: 1;
}
.delta-action-close {
  align-items: center;
  background: transparent;
  border: 1px solid var(--red-bd);
  border-radius: var(--r3);
  color: var(--red);
  cursor: pointer;
  display: inline-flex;
  font-size: 18px;
  font-weight: 700;
  height: 30px;
  justify-content: center;
  line-height: 1;
  width: 50px;
}
.delta-action-close:hover {
  background: var(--red-bg);
}

/* ── Misc utils ─────────────────────────────────────────────────────────────── */
.mb-16 { margin-bottom: 16px; }
.mb-12 { margin-bottom: 12px; }
.mt-16 { margin-top: 16px; }
.flex  { display: flex; }
.flex-c { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }

/* Empty state */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--tx2);
}
.empty-icon { font-size: 36px; margin-bottom: 12px; opacity: .5; }
.empty-title { font-size: 14px; font-weight: 600; color: var(--tx2); margin-bottom: 4px; }
.empty-sub { font-size: 12px; color: var(--tx3); }
.empty-link { color: var(--blue); text-decoration: none; font-weight: 500; }
.empty-link:hover { text-decoration: underline; }

/* Skeleton loading */
.skel {
  background: linear-gradient(90deg, var(--bg-s2) 25%, var(--bg-s3) 50%, var(--bg-s2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r2);
  display: inline-block;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

@media (max-width: 1100px) {
  .bt-layout { grid-template-columns: 1fr; }
  .bt-file-pill { max-width: 100%; }
  .members-layout { grid-template-columns: 1fr; }
  .pnl-account-grid { grid-template-columns: 1fr; }
  .pnl-account-metrics { grid-template-columns: repeat(2, 1fr); }
  .uploader-layout { grid-template-columns: 1fr; }
  .monitor-filters { grid-template-columns: 1fr; }
  .monitor-live-toggle { padding-bottom: 0; }
  .risk-summary-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .page-header-row {
    align-items: flex-start;
    gap: 12px;
    flex-direction: column;
  }
  .risk-summary-grid { grid-template-columns: 1fr; }
  .bt-mini-grid { grid-template-columns: 1fr; }
  #bt-chart { height: 340px; }
  .pnl-account-metrics { grid-template-columns: 1fr; }
  .upload-metrics { grid-template-columns: repeat(2, 1fr); }
}
