:root {
  --bg: #0A0F1C;
  --panel: #121B2E;
  --panel-2: #17233A;
  --border: #253552;
  --text: #EDF2FA;
  --muted: #8298BD;
  --positive: #1FC17E;
  --negative: #F0525B;
  --brand: #2E7FE8;
  --warning: #F2A93B;
  --special: #A06CF5;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
}

#root { min-height: 100vh; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  align-self: flex-start;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 0 20px 20px 20px;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.01em;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.sidebar-brand .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--positive);
  margin-right: 8px;
  box-shadow: 0 0 6px var(--positive);
}

.nav-item {
  padding: 10px 20px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s ease;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.nav-item.active {
  color: var(--text);
  font-weight: 600;
  border-left-color: var(--brand);
  background: rgba(46,127,232,0.10);
}

/* ---------- Sidebar realtime panel ---------- */
.sidebar-realtime {
  margin-top: auto;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
}
.sidebar-realtime-row { display: flex; align-items: center; gap: 8px; }
.sidebar-realtime-label { font-size: 13px; font-weight: 700; flex: 1; }
.sidebar-realtime-sub { font-size: 11px; color: var(--muted); margin-top: 4px; margin-left: 18px; }
.sidebar-refresh-btn { width: 100%; margin-top: 10px; justify-content: center; }
.toggle-switch-sm { transform: scale(0.8); }

/* ---------- Main ---------- */
.main {
  flex: 1;
  padding: 24px 32px;
  overflow-x: hidden;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.015em;
  margin: 0 0 4px 0;
}
.page-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 20px 0;
}

/* ---------- Cards / Stats ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}
.stat-card.clickable { cursor: pointer; transition: filter .15s ease, border-color .15s ease; }
.stat-card.clickable:hover { filter: brightness(1.18); border-color: var(--brand); }
.stat-card.tone-positive { background: linear-gradient(160deg, #123B2C, var(--panel) 65%); border-color: #1F5A42; }
.stat-card.tone-negative { background: linear-gradient(160deg, #3E1E22, var(--panel) 65%); border-color: #6B3238; }
.stat-card.tone-warning { background: linear-gradient(160deg, #3E2E12, var(--panel) 65%); border-color: #6B5024; }
.stat-card.tone-special { background: linear-gradient(160deg, #271A42, var(--panel) 65%); border-color: #4A3475; }
.stat-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  min-height: 30px;
  display: flex;
  align-items: flex-start;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.positive { color: var(--positive); }
.negative { color: var(--negative); }

/* ---------- Panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 2px solid var(--border);
  border-radius: 6px;
  padding: 18px;
  margin-bottom: 20px;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.panel-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
}

/* ---------- Toggle ---------- */
.toggle-group {
  display: inline-flex;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.toggle-btn {
  padding: 6px 14px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  background: transparent;
  border: none;
}
.toggle-btn.active {
  background: var(--brand);
  color: #fff;
}

/* ---------- Table ---------- */
.table-scroll-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table.data-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.data-table td.text { font-family: var(--font-ui); }
.data-table tr:hover { background: rgba(255,255,255,0.03); cursor: pointer; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr.pnl-row-positive { background: rgba(31,193,126,0.07); border-left: 3px solid var(--positive); }
.data-table tr.pnl-row-negative { background: rgba(240,82,91,0.07); border-left: 3px solid var(--negative); }
.data-table tr.pnl-row-positive:hover { background: rgba(31,193,126,0.14); }
.data-table tr.pnl-row-negative:hover { background: rgba(240,82,91,0.14); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge .pulse {
  width: 6px; height: 6px; border-radius: 50%;
}
.badge.connected { background: rgba(31,193,126,0.14); color: var(--positive); }
.badge.connected .pulse { background: var(--positive); box-shadow: 0 0 5px var(--positive); }
.badge.disconnected { background: rgba(130,152,189,0.14); color: var(--muted); }
.badge.disconnected .pulse { background: var(--muted); }
.badge.issue { background: rgba(242,169,59,0.14); color: var(--warning); }
.badge.issue .pulse { background: var(--warning); box-shadow: 0 0 5px var(--warning); }
.badge.open { background: rgba(46,127,232,0.14); color: var(--brand); }
.badge.buy { background: rgba(31,193,126,0.14); color: var(--positive); }
.badge.sell { background: rgba(240,82,91,0.14); color: var(--negative); }
.badge.live { background: rgba(160,108,245,0.16); color: var(--special); }
.badge.demo { background: rgba(130,152,189,0.14); color: var(--muted); }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state .title { color: var(--text); font-size: 14px; margin-bottom: 6px; font-weight: 600; }
.empty-state .sub { font-size: 12px; }

/* ---------- Forms ---------- */
.input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font-mono);
}
.input:focus { outline: none; border-color: var(--brand); }

.btn {
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.12); }
.btn.secondary {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
  font-weight: 600;
}
.btn.secondary:hover { border-color: var(--muted); filter: none; }
.btn.success { background: var(--positive); }
.btn.special { background: var(--special); }
.btn.warning { background: var(--warning); }
.btn.warning.secondary { background: transparent; border: 1.5px solid var(--warning); color: var(--warning); }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}
.login-box {
  background: linear-gradient(160deg, #16294D, var(--panel) 55%);
  border: 1px solid var(--border);
  border-top: 3px solid var(--brand);
  border-radius: 8px;
  padding: 32px;
  width: 320px;
  text-align: center;
}
.login-box h2 { margin: 0 0 6px 0; font-size: 17px; }
.login-box p { color: var(--muted); font-size: 12px; margin: 0 0 18px 0; }
.login-box .input { width: 100%; margin-bottom: 12px; }
.login-box .btn { width: 100%; }
.login-error { color: var(--negative); font-size: 12px; margin-top: 10px; }

/* ---------- Filters bar ---------- */
.filters-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ---------- Raw payload ---------- */
.raw-payload {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  background: var(--panel-2);
  padding: 8px;
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 380px;
}

.skip-reason {
  color: var(--warning);
  font-size: 11px;
}

.topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}
.topbar .logout {
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}
.topbar .logout:hover { color: var(--text); }

.back-link {
  color: var(--brand);
  font-size: 12px;
  cursor: pointer;
  margin-bottom: 12px;
  display: inline-block;
}

/* ---------- Icons ---------- */
.icon { flex-shrink: 0; vertical-align: middle; }
.nav-item { display: flex; align-items: center; gap: 10px; }
.btn { display: inline-flex; align-items: center; gap: 6px; }
.btn.icon-only { padding: 8px; }
.btn.danger { background: var(--negative); }
.btn.danger.secondary { background: transparent; border: 1.5px solid var(--negative); color: var(--negative); }
.btn.success.secondary { background: transparent; border: 1.5px solid var(--positive); color: var(--positive); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }

/* ---------- Page fade-in ---------- */
.page-fade { animation: fadeIn .25s ease; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Transitions everywhere sensible ---------- */
.stat-card, .panel, .btn, .input, .badge, .data-table tr, select.input, .kpi-card, .tm-rule-card {
  transition: background .15s ease, border-color .15s ease, transform .12s ease, box-shadow .15s ease;
}
.stat-card:hover, .kpi-card:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.25); }
.data-table tbody tr:hover { background: var(--panel-2); }
.data-table tbody tr {
  animation: rowFadeIn .3s ease backwards;
}
.data-table tbody tr:nth-child(1) { animation-delay: .02s; }
.data-table tbody tr:nth-child(2) { animation-delay: .04s; }
.data-table tbody tr:nth-child(3) { animation-delay: .06s; }
.data-table tbody tr:nth-child(4) { animation-delay: .08s; }
.data-table tbody tr:nth-child(5) { animation-delay: .10s; }
.data-table tbody tr:nth-child(6) { animation-delay: .12s; }
.data-table tbody tr:nth-child(n+7) { animation-delay: .14s; }
@keyframes rowFadeIn {
  from { opacity: 0; transform: translateX(-4px); }
  to { opacity: 1; transform: translateX(0); }
}
.kpi-row .kpi-card {
  animation: fadeIn .35s ease backwards;
}
.kpi-row .kpi-card:nth-child(1) { animation-delay: .03s; }
.kpi-row .kpi-card:nth-child(2) { animation-delay: .06s; }
.kpi-row .kpi-card:nth-child(3) { animation-delay: .09s; }
.kpi-row .kpi-card:nth-child(4) { animation-delay: .12s; }
.kpi-row .kpi-card:nth-child(5) { animation-delay: .15s; }
.kpi-row .kpi-card:nth-child(6) { animation-delay: .18s; }

/* ---------- Realtime Mode toggle switch ---------- */
.realtime-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-right: 1px solid var(--border);
  margin-right: 4px;
}
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border);
  border-radius: 20px;
  transition: background .2s ease;
}
.toggle-slider::before {
  position: absolute;
  content: "";
  height: 14px; width: 14px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform .2s ease;
}
.toggle-switch input:checked + .toggle-slider { background: var(--positive); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }
.realtime-label { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }

/* ---------- Overview realtime master toggle ---------- */
.realtime-master-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 20px;
}
.realtime-master-toggle-left { display: flex; align-items: center; gap: 12px; }
.realtime-master-toggle-title { font-size: 14px; font-weight: 700; }
.realtime-master-toggle-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- TP hover tooltip ---------- */
.tp-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  background: var(--panel);
  border: 1px solid var(--brand);
  border-radius: 6px;
  padding: 10px 12px;
  min-width: 200px;
  z-index: 50;
  box-shadow: 0 8px 20px rgba(0,0,0,0.4);
  animation: fadeIn .15s ease;
}
.tp-tooltip-title { font-size: 10px; font-weight: 700; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.tp-tooltip-row { font-size: 12px; font-family: var(--font-mono); padding: 2px 0; white-space: nowrap; }

/* ---------- Flash animation for updated values ---------- */
.value-flash {
  animation: valueFlash 0.9s ease;
  border-radius: 3px;
}
@keyframes valueFlash {
  0% { background: rgba(76,139,245,0.35); }
  100% { background: transparent; }
}

/* ---------- Ring cards (circular icon badge, modern SaaS) ---------- */
.ring-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.ring-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  animation: fadeIn .35s ease backwards;
}
.ring-row .ring-card:nth-child(1) { animation-delay: .03s; }
.ring-row .ring-card:nth-child(2) { animation-delay: .07s; }
.ring-row .ring-card:nth-child(3) { animation-delay: .11s; }
.ring-row .ring-card:nth-child(4) { animation-delay: .15s; }
.ring-row .ring-card:nth-child(5) { animation-delay: .19s; }
.ring-row .ring-card:nth-child(6) { animation-delay: .23s; }
.ring-card.clickable { cursor: pointer; }
.ring-card:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(0,0,0,0.35); border-color: var(--brand); }
.ring-card-badge {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid;
  flex-shrink: 0;
  position: relative;
}
.ring-card-pulse-dot {
  position: absolute;
  top: -1px; right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--positive);
  box-shadow: 0 0 0 2px var(--panel);
  animation: pulseGlow 1.6s infinite;
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 2px var(--panel), 0 0 0 0 rgba(31,193,126,0.55); }
  50% { box-shadow: 0 0 0 2px var(--panel), 0 0 0 6px rgba(31,193,126,0); }
}
.ring-card-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 4px;
}
.ring-card-value {
  font-family: var(--font-mono);
  font-size: 21px;
  font-weight: 700;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.icon-btn { transition: all .15s ease; }
.icon-btn:hover { transform: scale(1.08); }

/* ---------- Row action buttons ---------- */
.row-actions { display: flex; gap: 6px; }
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  display: inline-flex;
  transition: all .15s ease;
}
.icon-btn:hover { color: var(--text); border-color: var(--brand); }
.icon-btn.danger:hover { color: var(--negative); border-color: var(--negative); }
.icon-btn.success:hover { color: var(--positive); border-color: var(--positive); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(5,8,15,0.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeIn .15s ease;
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  width: 480px;
  max-width: 92vw;
  max-height: 86vh;
  overflow-y: auto;
  animation: modalIn .18s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px;
}
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Forms ---------- */
.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.form-row .input, .form-row select, .form-row textarea {
  width: 100%;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
select.input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font-ui);
}
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: 16px; height: 16px; }

/* ---------- Toggle switch (kill switch etc) ---------- */
.switch {
  position: relative;
  width: 40px; height: 22px;
  background: var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: background .2s ease;
  flex-shrink: 0;
}
.switch.on { background: var(--positive); }
.switch.danger-on { background: var(--negative); }
.switch::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s ease;
}
.switch.on::after { transform: translateX(18px); }

/* ---------- Kill switch banner ---------- */
.kill-switch-banner {
  background: rgba(255,107,107,0.12);
  border: 1px solid var(--negative);
  color: var(--negative);
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  animation: fadeIn .2s ease;
}

/* ---------- Status pill (active/paused) ---------- */
.badge.active { background: rgba(31,193,126,0.14); color: var(--positive); }
.badge.paused { background: rgba(242,169,59,0.14); color: var(--warning); }
.badge.closed { background: rgba(130,152,189,0.14); color: var(--muted); }

/* ---------- Settings key/value display + edit ---------- */
.kv-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.kv-row:last-child { border-bottom: none; }
.kv-row .k { color: var(--muted); }
.kv-row .v { font-family: var(--font-mono); }
.kv-row .v.editing { width: 55%; }
.kv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 28px;
}
.kv-grid .kv-row { padding: 9px 0; }
@media (max-width: 700px) {
  .kv-grid { grid-template-columns: 1fr; }
}

/* ---------- Section header with action ---------- */
.section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.section-header h2 { font-size: 15px; margin: 0; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 8px 14px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  transition: all .15s ease;
}
.tab.active { color: var(--text); border-bottom-color: var(--brand); }
.tab:hover { color: var(--text); }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed; bottom: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  animation: toastIn .2s ease;
}
.toast.error { border-color: var(--negative); color: var(--negative); }
.toast.success { border-color: var(--positive); color: var(--positive); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Health page dots ---------- */
.health-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.health-dot.ok { background: var(--positive); box-shadow: 0 0 6px var(--positive); }
.health-dot.bad { background: var(--negative); box-shadow: 0 0 6px var(--negative); }

/* ---------- Running trades live pulse ---------- */
.live-pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--positive);
  display: inline-block;
  animation: pulseAnim 1.4s infinite;
}
@keyframes pulseAnim {
  0% { box-shadow: 0 0 0 0 rgba(53,208,127,0.5); }
  70% { box-shadow: 0 0 0 8px rgba(53,208,127,0); }
  100% { box-shadow: 0 0 0 0 rgba(53,208,127,0); }
}

/* ---------- Interlinking (clickable names throughout the UI) ---------- */
.link-text {
  color: var(--brand);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color .15s ease, color .15s ease;
}
.link-text:hover { text-decoration-color: var(--brand); }
.link-sub {
  font-size: 12px;
  color: var(--muted);
}
.account-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .15s ease, box-shadow .18s ease;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 18px;
  background: var(--panel-2);
  animation: fadeIn .35s ease backwards;
}
.account-card:hover { border-color: var(--brand); background: var(--panel); transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,0.3); }
.account-card-badge {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid;
  flex-shrink: 0;
}
.account-card.is-live .account-card-badge { color: var(--positive); border-color: var(--positive); background: rgba(31,193,126,0.12); }
.account-card.is-demo .account-card-badge { color: var(--brand); border-color: var(--brand); background: rgba(46,127,232,0.12); }
.account-card .name { font-weight: 700; margin-bottom: 5px; font-size: 15px; }
.account-card .meta { display: flex; gap: 10px; font-size: 12px; color: var(--muted); align-items: center; flex-wrap: wrap; }
.account-card-stats { display: flex; gap: 22px; align-items: center; }
.account-card-stat { text-align: left; min-width: 76px; }
.account-card-stat-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 3px;
}
.account-card-stat-value { font-family: var(--font-mono); font-weight: 700; font-size: 15px; }
.account-card-pnl-block { text-align: right; min-width: 90px; }
.account-card-pnl-block .today { font-family: var(--font-mono); font-weight: 700; font-size: 14px; }
.account-card-pnl-block .month { font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Collapsible sections ---------- */
.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.collapsible-header:hover .panel-title { color: var(--brand); }
.collapsible-chevron {
  color: var(--muted);
  transition: transform .2s ease;
  display: inline-flex;
  transform: rotate(180deg);
}
.collapsible-chevron.open { transform: rotate(270deg); }
.collapsible-body {
  overflow: hidden;
  animation: fadeIn .2s ease;
}

/* ---------- At-a-glance sidebar summary card ---------- */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: stretch;
}
@media (max-width: 900px) {
  .detail-layout { grid-template-columns: 1fr; }
}
.glance-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--brand);
  border-radius: 6px;
  padding: 18px;
  margin-bottom: 20px;
  position: sticky;
  top: 20px;
}
.glance-card .glance-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 14px;
}
.glance-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.glance-row:last-child { border-bottom: none; }
.glance-row .glance-label { font-size: 12px; color: var(--muted); }
.glance-row .glance-value { font-family: var(--font-mono); font-weight: 700; font-size: 14px; }

/* ---------- Trade Management (modern rule builder) ---------- */
.tm-section {
  margin-bottom: 22px;
}
.tm-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.tm-section-title .tm-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.tm-sl .tm-dot { background: var(--brand); box-shadow: 0 0 6px var(--brand); }
.tm-tp .tm-dot { background: var(--positive); box-shadow: 0 0 6px var(--positive); }

.tm-rule-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel-2);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 6px;
  border-left: 3px solid var(--border);
  transition: border-color .15s ease;
}
.tm-sl .tm-rule-card { border-left-color: var(--brand); }
.tm-tp .tm-rule-card { border-left-color: var(--positive); }
.tm-rule-card:hover { border-left-color: var(--text); }

.tm-rule-flow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  flex-wrap: wrap;
}
.tm-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-mono);
}
.tm-pill.tm-pill-trigger { background: rgba(46,127,232,0.15); color: var(--brand); }
.tm-pill.tm-pill-action { background: rgba(31,193,126,0.15); color: var(--positive); }
.tm-rule-flow .tm-flow-arrow { color: var(--muted); font-size: 14px; }
.tm-inactive-tag { font-size: 11px; color: var(--warning); font-style: italic; }

.tm-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  padding: 10px 0 12px;
}

.tm-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 4px;
  transition: all .15s ease;
}
.tm-sl .tm-add-btn { color: var(--brand); }
.tm-sl .tm-add-btn:hover { border-color: var(--brand); background: rgba(46,127,232,0.06); }
.tm-tp .tm-add-btn { color: var(--positive); }
.tm-tp .tm-add-btn:hover { border-color: var(--positive); background: rgba(31,193,126,0.06); }

.tm-builder {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-top: 6px;
}
.tm-builder-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.tm-builder-field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 140px; }
.tm-builder-field.tm-narrow { flex: 0 0 90px; min-width: 90px; }
.tm-builder-field label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.tm-builder-connector {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 9px;
  flex-shrink: 0;
}

/* ---------- Account Detail KPI row ---------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: 6px;
  padding: 14px 16px;
  transition: border-color .15s ease;
}
.kpi-card.clickable { cursor: pointer; }
.kpi-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  margin-bottom: 8px;
}
.kpi-card-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kpi-card-value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
}
