:root {
  --bg: #0b1210;
  --bg2: #111a17;
  --panel: rgba(18, 28, 24, 0.92);
  --line: rgba(140, 190, 160, 0.16);
  --text: #e7f2ea;
  --muted: #8aa396;
  --mint: #3dffa8;
  --mint-dim: #1f9d6a;
  --amber: #f0c15a;
  --rose: #ff6b7a;
  --blue: #7ec8ff;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.32);
  --radius: 16px;
  --font: "IBM Plex Sans Arabic", sans-serif;
  --display: "Syne", "IBM Plex Sans Arabic", sans-serif;
  --mono: "JetBrains Mono", monospace;
  --pad-x: 1.5rem;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
html {
  margin: 0;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
html, body {
  min-height: 100%;
  max-width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}
html {
  overflow-x: clip;
}
body {
  margin: 0;
  overflow-x: clip;
  padding-bottom: calc(1rem + var(--safe-b));
  padding-top: var(--safe-t);
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(61, 255, 168, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(61, 255, 168, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 50% 20%, black 30%, transparent 80%);
  pointer-events: none;
  z-index: 0;
}
.bg-glow {
  position: fixed;
  width: min(70vw, 520px);
  height: min(70vw, 520px);
  right: -18vw;
  top: -18vw;
  background: radial-gradient(circle, rgba(61, 255, 168, 0.12), transparent 68%);
  filter: blur(8px);
  pointer-events: none;
  z-index: 0;
}

.topbar, .tabs, .layout, .footer { position: relative; z-index: 1; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem var(--pad-x) 0.45rem;
  max-width: 1400px;
  margin: 0 auto;
}
.brand { display: flex; gap: 0.85rem; align-items: center; min-width: 0; }
.brand-mark {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--mint), #0d5c40);
  color: #04110c;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.25rem;
  box-shadow: 0 0 22px rgba(61, 255, 168, 0.22);
}
.brand h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.2rem, 2.5vw, 1.5rem);
  letter-spacing: 0.02em;
  line-height: 1.15;
}
.brand p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.top-meta {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.pill {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  padding: 0.32rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-family: var(--mono);
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.pill.spot { color: #04110c; background: var(--mint); border-color: transparent; font-weight: 700; }
.pill.muted { color: var(--muted); }
.pill.on { color: #04110c; background: var(--amber); border-color: transparent; }
.pill.linked { color: #04110c; background: var(--blue); border-color: transparent; font-weight: 700; }
.pill.paper { color: #04110c; background: var(--blue); border-color: transparent; font-weight: 700; }
.pill.testnet { color: #04110c; background: var(--amber); border-color: transparent; font-weight: 700; }
.pill.live { color: #fff; background: var(--rose); border-color: transparent; font-weight: 700; }
.clock {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 0.75rem;
  margin-inline-start: 0.2rem;
}

.tabs {
  display: flex;
  gap: 0.4rem;
  padding: 0.55rem var(--pad-x) 0.15rem;
  max-width: 1400px;
  margin: 0 auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  min-height: 42px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.tab.active {
  color: #04110c;
  background: var(--mint);
  border-color: transparent;
}
.tab-panel { display: none; }
.tab-panel.active {
  display: grid;
  gap: 0.9rem;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}
.profile-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem;
  background: rgba(0,0,0,0.18);
  cursor: pointer;
  transition: border-color 0.15s ease;
  min-width: 0;
}
.profile-card:hover { border-color: rgba(61,255,168,0.4); }
.profile-card.active {
  border-color: var(--mint);
  box-shadow: inset 0 0 0 1px rgba(61,255,168,0.35);
}
.profile-card h3 {
  margin: 0 0 0.35rem;
  font-family: var(--display);
  font-size: 1rem;
}
.profile-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  width: 100%;
  min-width: 0;
}
.form-grid > *,
.profile-grid > *,
.form-grid-universe > *,
.criteria-grid > *,
.guide-grid > *,
.bt-metrics > *,
.learning-kpis > * {
  min-width: 0;
  max-width: 100%;
}
.muted { color: var(--muted); font-size: 0.75rem; }
.check {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  color: var(--text);
  font-size: 0.9rem;
  margin-top: 0.35rem;
  min-width: 0;
  max-width: 100%;
  line-height: 1.45;
}
.check input[type="checkbox"] {
  flex: 0 0 auto;
  margin-top: 0.15rem;
}
.live-confirm { color: #ffd0d5; }
.warn {
  margin-top: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  background: rgba(255,107,122,0.12);
  border: 1px solid rgba(255,107,122,0.35);
  color: #ffd0d5;
  font-size: 0.85rem;
  line-height: 1.45;
}

.layout {
  display: grid;
  gap: 1rem;
  padding: 0.85rem var(--pad-x) 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  min-width: 0;
  overflow-x: clip;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  min-width: 0;
}
.kpi span {
  color: var(--muted);
  font-size: 0.78rem;
  display: block;
  margin-bottom: 0.4rem;
}
.kpi strong {
  font-family: var(--mono);
  font-size: clamp(1.05rem, 2.2vw, 1.3rem);
  font-weight: 600;
  word-break: break-word;
}
.kpi strong.up { color: var(--mint); }
.kpi strong.down { color: var(--rose); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.95rem 1rem 1.05rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
  overflow-wrap: anywhere;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
}
.panel-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.02rem;
  font-weight: 700;
}
.panel-head small, .hint {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}
.panel-head-stack {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}
.panel-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-inline-start: auto;
}
.panel-head-actions a.btn {
  text-decoration: none;
  white-space: nowrap;
}
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.row-actions a.btn { text-decoration: none; }
.hint { margin: 0.7rem 0 0; word-break: break-word; }

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: end;
  min-width: 0;
  max-width: 100%;
}
.control-row .hint {
  flex: 1 1 100%;
  min-width: 0;
  max-width: 100%;
}
.btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 12px;
  padding: 0.62rem 0.95rem;
  min-height: 42px;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: rgba(61,255,168,0.45); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }
.btn.busy { opacity: 0.75; cursor: wait; }
.btn.primary {
  background: linear-gradient(135deg, var(--mint), var(--mint-dim));
  color: #04110c;
  border: none;
}
.btn.danger {
  background: rgba(255,107,122,0.12);
  border-color: rgba(255,107,122,0.35);
  color: #ffd0d5;
}
.btn.ghost { background: transparent; }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  color: var(--muted);
  font-size: 0.75rem;
  min-width: 0;
}
.field.grow { flex: 1 1 160px; min-width: 0; }
.control-row .field.grow { min-width: 0; flex: 1 1 140px; }
.field input, .field select, .field textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  background: #0a100e;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  min-height: 42px;
  font-family: var(--mono);
  font-size: 0.85rem;
}
.field input[type="password"],
.field input[type="text"],
.field input[type="email"] {
  overflow: hidden;
  text-overflow: ellipsis;
}
.field .muted,
.field small {
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.4;
}
.field-label {
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
}
.field-hint {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

/* Settings — Universe filters */
#tab-settings .panel-universe {
  border-color: rgba(61, 255, 168, 0.22);
  background: linear-gradient(165deg, rgba(61, 255, 168, 0.06) 0%, rgba(0, 0, 0, 0.12) 42%);
}
#tab-settings .panel-scanner-quality {
  margin-top: 0;
}
.universe-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}
.universe-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.62rem;
  border-radius: 999px;
  border: 1px solid rgba(61, 255, 168, 0.22);
  background: rgba(0, 0, 0, 0.22);
  color: var(--mint);
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.35;
  max-width: 100%;
  white-space: normal;
  text-align: center;
}
.form-grid-universe {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
#tab-settings .form-grid .check {
  grid-column: 1 / -1;
  margin-top: 0.15rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.14);
  border: 1px solid var(--line);
}
#tab-settings .form-grid .check.highlight-check {
  border-color: rgba(61, 255, 168, 0.28);
  background: rgba(61, 255, 168, 0.06);
}
#tab-settings .panel + .panel {
  margin-top: 0;
}

/* مفاتيح API / Telegram — عمود واحد لتجنّب overflow */
#tab-settings .form-grid:has(#apiKey),
#tab-settings .form-grid:has(#telegramToken) {
  grid-template-columns: 1fr;
}

#tab-settings .panel-head {
  align-items: flex-start;
}
#tab-settings .panel-head small {
  max-width: 100%;
  overflow-wrap: anywhere;
}
#tab-settings .control-row .btn {
  flex: 0 0 auto;
}
#tab-settings .control-row .hint {
  margin: 0;
  font-size: 0.76rem;
}
#tab-settings .profile-grid {
  grid-template-columns: 1fr;
}
@media (min-width: 520px) {
  #tab-settings .profile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 900px) {
  #tab-settings .profile-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.ticker-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
}
.ticker {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.8rem;
  background: rgba(0,0,0,0.18);
  min-width: 0;
}
.ticker .sym { font-family: var(--display); font-weight: 700; margin-bottom: 0.3rem; }
.ticker .px { font-family: var(--mono); font-size: 1.1rem; }
.ticker .chg { font-family: var(--mono); font-size: 0.82rem; margin-top: 0.2rem; }
.ticker .chg.up { color: var(--mint); }
.ticker .chg.down { color: var(--rose); }

.chart {
  height: 360px;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #070c0a;
}
.chart.volume {
  height: 110px;
  margin-top: 0.5rem;
}
.chart.equity { height: 220px; margin-top: 0.7rem; }

.trade-chart-wrap {
  display: grid;
  gap: 0;
  min-width: 0;
}
.trade-chart-wrap.tv-like {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(42, 46, 57, 0.95);
  background: #131722;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}
.trade-chart-wrap.precise-panel,
.trade-chart-wrap.exec-panel {
  margin-top: 0.85rem;
  border: 2px solid rgba(41, 98, 255, 0.35);
}
.precise-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.45rem 1rem;
  padding: 0.55rem 0.85rem;
  background: linear-gradient(180deg, #1e222d 0%, #131722 100%);
  color: #d1d4dc;
  font-size: 0.78rem;
  border-bottom: 1px solid rgba(42, 46, 57, 0.9);
}
.precise-head strong {
  color: #7ec8ff;
  font-size: 0.85rem;
}
.precise-head span {
  color: #787b86;
}
.exec-hint {
  display: block;
  margin-top: 0.25rem;
  color: #7ec8ff;
  font-size: 0.74rem;
}
.tool.active {
  border-color: rgba(41, 98, 255, 0.7);
  background: rgba(41, 98, 255, 0.18);
  color: #9bbcff;
}
.trade-chart-wrap[hidden] { display: none !important; }
.trade-chart-wrap.tv-like .chart {
  border: none;
  border-radius: 0;
  background: #131722;
}
.chart.trade-main {
  height: min(42vh, 380px);
  min-height: 280px;
}
.trade-chart-wrap.tv-like .chart.volume {
  height: 100px;
  margin-top: 0;
  border-top: 1px solid rgba(42, 46, 57, 0.9);
}

.tv-modal[hidden] { display: none !important; }
.tv-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(4px);
}
.tv-modal-card {
  width: min(1200px, 96vw);
  height: min(860px, 92vh);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.75rem;
  border-radius: 16px;
  background: #131722;
  border: 1px solid rgba(42, 46, 57, 0.95);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}
.tv-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: #d1d4dc;
}
.tv-modal-chart {
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #131722;
  border: 1px solid rgba(42, 46, 57, 0.9);
}
.tv-wrap {
  position: relative;
  width: 100%;
  min-height: 520px;
  height: min(62vh, 680px);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(42, 46, 57, 0.9);
  background: #131722;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
  display: flex;
  flex-direction: column;
}
.tv-wrap[hidden] { display: none !important; }
.tv-chrome {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.75rem;
  background: #1e222d;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  color: #d1d4dc;
  font-size: 0.78rem;
  font-family: var(--font);
  z-index: 2;
}
.tv-chrome .muted { color: #787b86; font-size: 0.72rem; }
.tv-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}
.tv-levels-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
.tv-hline {
  position: absolute;
  left: 52px;
  right: 64px;
  height: 0;
  border-top: 1.5px dashed rgba(255,255,255,0.55);
  transform: translateY(-50%);
}
.tv-hline span {
  position: absolute;
  right: 0;
  top: -1.05rem;
  padding: 0.14rem 0.5rem;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: rgba(19, 23, 34, 0.94);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
.tv-hline.entry { border-top-color: #7ec8ff; }
.tv-hline.entry span { color: #7ec8ff; }
.tv-hline.sl { border-top-color: #ff6b7a; border-top-style: solid; }
.tv-hline.sl span { color: #ff6b7a; }
.tv-hline.tp { border-top-color: #3dffa8; border-top-style: solid; }
.tv-hline.tp span { color: #3dffa8; }
.tv-hline.tp2 { border-top-color: #f0c15a; }
.tv-hline.tp2 span { color: #f0c15a; }
.tv-hline.mark { border-top-color: #d1d4dc; border-top-style: dotted; }
.tv-hline.mark span { color: #d1d4dc; }
.tv-hline.sr { border-top-color: #c9b6ff; }
.tv-hline.sr span { color: #c9b6ff; }
.tv-trade-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.65rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(18, 28, 24, 0.92);
}
.tv-trade-info {
  color: #d1d4dc;
  font-size: 0.8rem;
  line-height: 1.4;
  min-width: 0;
  flex: 1 1 220px;
}
.tv-trade-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.tv-chart {
  width: 100%;
  height: 100%;
  min-height: 520px;
  position: relative;
  z-index: 1;
}
.tv-chart iframe {
  width: 100% !important;
  height: 100% !important;
}
.tv-ctx-catcher {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 3;
  background: transparent;
  cursor: context-menu;
}
.tv-ctx-catcher.active { display: block; }
.tv-fallback {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 420px;
  color: var(--muted);
  padding: 1.5rem;
  text-align: center;
  line-height: 1.6;
}
.tool.link-tool {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.tv-catch-toggle {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  gap: 0.35rem;
}
.tv-ctx-menu {
  position: fixed;
  z-index: 9999;
  min-width: 250px;
  max-width: min(92vw, 300px);
  max-height: min(78vh, 560px);
  overflow: auto;
  padding: 0.35rem;
  border-radius: 8px;
  border: 1px solid #363a45;
  background: #1e222d;
  box-shadow: 0 12px 40px rgba(0,0,0,0.55);
  color: #d1d4dc;
  font-family: var(--font);
  font-size: 0.84rem;
}
.tv-ctx-menu .tv-ctx-head {
  padding: 0.45rem 0.7rem 0.35rem;
  color: #787b86;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}
.tv-ctx-menu button {
  display: block;
  width: 100%;
  text-align: right;
  border: 0;
  background: transparent;
  color: #d1d4dc;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 0.84rem;
  cursor: pointer;
}
.tv-ctx-menu button:hover {
  background: #2962ff;
  color: #fff;
}
.tv-ctx-sep {
  height: 1px;
  margin: 0.3rem 0.4rem;
  background: #363a45;
}

.tf-row, .chart-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.tf-label {
  color: var(--muted);
  font-size: 0.78rem;
  margin-inline-end: 0.25rem;
}
.tf-row { margin-top: 0.7rem; }
.chart-tools { margin-bottom: 0.6rem; }
.tf, .tool {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  min-height: 36px;
  font-family: var(--mono);
  font-size: 0.78rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tool { font-family: var(--font); font-size: 0.8rem; }
.tf.active, .tool.active {
  color: #04110c;
  background: var(--mint);
  border-color: transparent;
  font-weight: 700;
}
.live-dot {
  margin-inline-start: 0.25rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: #04110c;
  background: var(--mint);
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  animation: pulse 1.6s infinite;
}
.live-dot.off { background: var(--muted); animation: none; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.level-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}
.level-legend .tag {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 0.78rem;
}
.level-legend .entry { color: #7ec8ff; border-color: rgba(126,200,255,0.35); }
.level-legend .sl { color: #ef5350; border-color: rgba(239,83,80,0.35); }
.level-legend .tp { color: #26a69a; border-color: rgba(38,166,154,0.35); }
.level-legend .tp2 { color: #ff9800; border-color: rgba(255,152,0,0.35); }
.level-legend .sr { color: #ab47bc; border-color: rgba(171,71,188,0.35); }

.demo-box {
  margin-top: 0.85rem;
  border: 1px solid rgba(240,193,90,0.35);
  background: rgba(240,193,90,0.08);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  max-width: 100%;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.demo-box ol {
  margin: 0.45rem 0 0.35rem 1.1rem;
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.55;
  padding-inline-start: 1rem;
  overflow-wrap: anywhere;
}
.demo-box p,
.demo-box li {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.demo-box code {
  font-family: var(--mono);
  color: var(--amber);
  word-break: break-all;
  overflow-wrap: anywhere;
  font-size: 0.78rem;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  padding-bottom: 0.15rem;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  min-width: 560px;
}
th, td {
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
}
th { color: var(--muted); font-weight: 500; font-size: 0.74rem; }
td.mono { font-family: var(--mono); }
.sig {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
}
.pos-actions {
  white-space: nowrap !important;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  min-width: 170px;
}
.pos-actions .btn {
  min-height: 36px;
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
}
.sig.sell { background: rgba(255,107,122,0.15); color: var(--rose); }
.sig.hold { background: rgba(255,255,255,0.06); color: var(--muted); }

.note-cell {
  white-space: normal !important;
  min-width: 200px;
  max-width: 280px;
  vertical-align: top;
}
.note-box {
  display: block;
  max-width: 260px;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid rgba(140, 190, 160, 0.22);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font-size: 0.75rem;
  line-height: 1.45;
  text-align: right;
  cursor: help;
}
.note-box.empty {
  color: var(--muted);
  border-style: dashed;
  background: transparent;
  cursor: default;
}
.note-box-body {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 5.8em;
}
.note-box:hover .note-box-body,
.note-box:focus-within .note-box-body {
  -webkit-line-clamp: unset;
  max-height: 12em;
  overflow: auto;
}

@media (max-width: 640px) {
  .note-cell { min-width: 160px; max-width: 200px; }
  .note-box { max-width: 180px; font-size: 0.7rem; padding: 0.45rem 0.55rem; }
  .note-box-body { -webkit-line-clamp: 3; max-height: 4.5em; }
}

.bt-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.55rem;
  margin-top: 0.7rem;
}
.bt-metrics .m {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem;
  background: rgba(0,0,0,0.16);
  min-width: 0;
}
.bt-metrics .m span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 0.22rem;
}
.bt-metrics .m strong { font-family: var(--mono); font-size: 0.92rem; word-break: break-word; }

.activity {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 260px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.activity li {
  display: grid;
  grid-template-columns: 150px 72px minmax(0, 1fr);
  gap: 0.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.84rem;
}
.activity .ts { font-family: var(--mono); color: var(--muted); font-size: 0.72rem; }
.activity .kind {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--blue);
  text-transform: uppercase;
}
.activity .msg { word-break: break-word; }

.footer {
  text-align: center;
  color: var(--muted);
  padding: 0 var(--pad-x) calc(1.25rem + var(--safe-b));
  font-size: 0.78rem;
  line-height: 1.45;
}
.footer code {
  font-family: var(--mono);
  color: var(--mint);
}

/* —— Tablet —— */
@media (max-width: 980px) {
  :root { --pad-x: 1rem; }
  .kpis, .ticker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-grid, .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid-universe { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart { height: 300px; }
  .activity li { grid-template-columns: 1fr; gap: 0.15rem; }
}

/* —— Phone —— */
@media (max-width: 640px) {
  :root { --pad-x: 0.75rem; --radius: 14px; }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    padding-top: 0.85rem;
  }
  .brand-mark { width: 40px; height: 40px; font-size: 1.1rem; border-radius: 11px; }
  .brand p {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.72rem;
  }
  .top-meta { justify-content: flex-start; }
  .pill { font-size: 0.68rem; padding: 0.28rem 0.55rem; }
  .clock { width: 100%; margin: 0.15rem 0 0; }

  .tabs {
    padding-top: 0.35rem;
    gap: 0.35rem;
    mask-image: linear-gradient(90deg, transparent, #000 8px, #000 calc(100% - 8px), transparent);
  }
  .tab {
    padding: 0.5rem 0.8rem;
    font-size: 0.82rem;
  }

  .layout { padding-top: 0.7rem; gap: 0.75rem; }
  .tab-panel.active { gap: 0.75rem; }

  .kpis,
  .ticker-grid,
  .profile-grid,
  .form-grid,
  .form-grid-universe {
    grid-template-columns: 1fr;
  }
  .kpis {
    grid-template-columns: 1fr 1fr;
  }
  .kpi { padding: 0.75rem 0.8rem; }
  .kpi strong { font-size: 1.05rem; }

  .panel-head h2 {
    font-size: 0.95rem;
    line-height: 1.35;
  }
  .universe-presets {
    gap: 0.35rem;
  }
  .universe-chip {
    font-size: 0.68rem;
    padding: 0.24rem 0.52rem;
  }
  #tab-settings .form-grid .check {
    font-size: 0.84rem;
    line-height: 1.45;
  }
  #tab-settings .form-grid,
  #tab-settings .form-grid-universe {
    grid-template-columns: 1fr;
  }
  #tab-settings .demo-box {
    padding: 0.75rem 0.8rem;
    font-size: 0.84rem;
  }
  #tab-settings .demo-box ol {
    margin-inline-start: 0;
    padding-inline-start: 1.1rem;
    font-size: 0.8rem;
  }
  #tab-settings .field input,
  #tab-settings .field select {
    font-size: 0.8rem;
    padding: 0.5rem 0.6rem;
  }
  #tab-settings .control-row {
    flex-direction: column;
    align-items: stretch;
  }
  #tab-settings .control-row .btn {
    width: 100%;
    min-height: 44px;
  }
  .panel { padding: 0.85rem 0.8rem 0.95rem; }
  .panel-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .control-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    align-items: stretch;
  }
  .control-row .btn,
  .control-row .field {
    width: 100%;
  }
  .control-row .field.grow,
  .control-row .btn.primary:last-of-type,
  .control-row #btnProposeChart {
    grid-column: 1 / -1;
  }
  .field.grow { min-width: 0; flex: none; }

  .system-launch-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    padding: 0.85rem 0.75rem;
  }
  .system-launch-row .btn.lg {
    flex: 1 1 auto;
    width: 100%;
    min-height: 48px;
    font-size: 0.92rem;
  }
  .system-launch-row .system-status-chip {
    flex: none;
    width: 100%;
    order: 3;
    font-size: 0.78rem;
    padding-top: 0.15rem;
    border-top: 1px solid rgba(61, 255, 168, 0.12);
    margin-top: 0.15rem;
    padding-top: 0.55rem;
  }

  #tab-scanner .control-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }
  #tab-scanner .control-row .btn,
  #tab-scanner .control-row .check,
  #tab-scanner .control-row .hint {
    width: 100%;
  }
  #tab-scanner .control-row .hint {
    font-size: 0.76rem;
    line-height: 1.5;
    white-space: normal;
  }
  .criteria-grid { grid-template-columns: 1fr; }
  .panel-head-stack { width: 100%; }

  #tab-learning .panel-head {
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
  }
  .learning-head-actions {
    width: 100%;
  }
  .learning-head-actions .btn {
    flex: 1 1 auto;
    min-height: 44px;
  }
  .learning-options-grid,
  .learning-adaptive-box {
    grid-template-columns: 1fr;
  }

  #tab-guide .guide-grid { grid-template-columns: 1fr; }
  #tab-guide .guide-flow {
    font-size: 0.68rem;
    line-height: 1.6;
  }
  #tab-guide .guide-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  #tab-guide .guide-details {
    padding: 0.55rem 0.7rem;
  }

  #tab-settings .panel-head-actions,
  #tab-research .panel-head-actions {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  #tab-settings .panel-head-actions .btn,
  #tab-research .panel-head-actions .btn {
    flex: 1 1 auto;
    min-height: 44px;
  }

  .panel-head-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .panel-head-actions .btn,
  .panel-head-actions a.btn {
    width: 100%;
    text-align: center;
    min-height: 44px;
  }

  .scroll-panel { max-height: min(52vh, 360px); }
  .scroll-panel-sm { max-height: min(40vh, 240px); }
  .scroll-panel-md { max-height: min(48vh, 300px); }
  .scroll-panel-lg { max-height: min(55vh, 380px); }

  .chart { height: 240px; border-radius: 12px; }
  .chart.volume { height: 88px; }
  .chart.equity { height: 180px; }
  .chart.trade-main {
    height: min(52vh, 420px);
    min-height: 260px;
  }
  .tv-modal-card {
    width: 100%;
    height: 94vh;
    padding: 0.55rem;
  }

  .tf, .tool {
    padding: 0.38rem 0.62rem;
    font-size: 0.74rem;
  }
  .chart-tools .hint {
    width: 100%;
    margin: 0.15rem 0 0;
  }

  table { min-width: 520px; font-size: 0.8rem; }
  th, td { padding: 0.55rem 0.4rem; }

  .demo-box { padding: 0.75rem; }
  .demo-box ol { font-size: 0.8rem; margin-inline-start: 0.2rem; }

  .bt-metrics { grid-template-columns: 1fr 1fr; }

  .footer { font-size: 0.72rem; }
}

/* —— Narrow phones —— */
@media (max-width: 380px) {
  .kpis { grid-template-columns: 1fr; }
  .control-row { grid-template-columns: 1fr; }
  .bt-metrics { grid-template-columns: 1fr; }
  .chart { height: 210px; }
}

.grade-badge {
  display: inline-block;
  min-width: 1.6rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
}
.grade-a { background: rgba(61, 255, 168, 0.18); color: var(--mint); border: 1px solid rgba(61, 255, 168, 0.35); }
.grade-b { background: rgba(240, 193, 90, 0.15); color: var(--amber); border: 1px solid rgba(240, 193, 90, 0.35); }
.grade-c { background: rgba(138, 163, 150, 0.12); color: var(--muted); border: 1px solid rgba(138, 163, 150, 0.25); }

.btc-regime-pill,
.regime-pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-family: var(--mono);
  border: 1px solid var(--line);
}
.regime-on, .btc-regime-pill.regime-on { color: var(--mint); border-color: rgba(61, 255, 168, 0.35); background: rgba(61, 255, 168, 0.08); }
.regime-off, .btc-regime-pill.regime-off { color: var(--rose); border-color: rgba(255, 107, 122, 0.35); background: rgba(255, 107, 122, 0.08); }
.regime-neutral, .btc-regime-pill.regime-neutral { color: var(--amber); border-color: rgba(240, 193, 90, 0.35); background: rgba(240, 193, 90, 0.08); }

.warn-inline { color: var(--amber); font-size: 0.72rem; margin-top: 0.15rem; }

.scroll-panel {
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
}
.scroll-panel-sm { max-height: 220px; }
.scroll-panel .table-wrap { margin: 0; }
.scroll-panel thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg2);
}

.criteria-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.65rem;
}
.criteria-item {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.82rem;
}
.criteria-item strong { color: var(--mint); font-size: 0.78rem; }
.criteria-item span { color: var(--muted); line-height: 1.45; }

.highlight-panel.has-open {
  border-color: rgba(61, 255, 168, 0.35);
  box-shadow: 0 0 0 1px rgba(61, 255, 168, 0.08);
}
.positions-panel { order: -1; }
.btn-sm { padding: 0.28rem 0.65rem; font-size: 0.74rem; }
.btn.lg { padding: 0.72rem 1.35rem; font-size: 0.95rem; font-weight: 600; }
.danger-outline { border-color: rgba(255, 107, 122, 0.45); color: var(--rose); }
.danger-outline:hover { background: rgba(255, 107, 122, 0.12); }

.system-launch-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
  padding: 0.75rem;
  border: 1px solid rgba(61, 255, 168, 0.18);
  border-radius: 12px;
  background: rgba(61, 255, 168, 0.04);
  position: relative;
}
.system-launch-row .btn.lg {
  position: relative;
  z-index: 2;
  flex: 1 1 140px;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.system-launch-row .btn.danger.is-ready:not(:disabled) {
  opacity: 1;
  box-shadow: 0 0 0 1px rgba(255, 107, 122, 0.35), 0 4px 16px rgba(255, 107, 122, 0.15);
}
.system-launch-row .btn.primary.is-active:disabled {
  opacity: 0.55;
}
.system-status-chip {
  flex: 1 1 220px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
  position: relative;
  z-index: 1;
  pointer-events: none;
}
.system-controls.system-on .system-launch-row {
  border-color: rgba(61, 255, 168, 0.35);
  background: rgba(61, 255, 168, 0.07);
}
.chart-source-banner,
.chart-link-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.55rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  font-size: 0.8rem;
  line-height: 1.45;
  margin-bottom: 0.65rem;
}
.chart-source-banner {
  border: 1px solid rgba(240, 193, 90, 0.35);
  background: rgba(240, 193, 90, 0.08);
  color: var(--amber);
}
.chart-source-banner.live-mode {
  border-color: rgba(255, 107, 122, 0.35);
  background: rgba(255, 107, 122, 0.08);
  color: var(--rose);
}
.chart-link-banner {
  border: 1px solid rgba(96, 165, 250, 0.35);
  background: rgba(96, 165, 250, 0.08);
  color: var(--blue);
}
.csb-tag {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
}
.csb-tag.tv { background: rgba(96, 165, 250, 0.2); color: #93c5fd; }
.csb-tag.exec { background: rgba(240, 193, 90, 0.2); color: var(--amber); }
.csb-sep { opacity: 0.45; }
.csb-detail { color: var(--muted); font-size: 0.74rem; }
.chart-link-banner .link-icon { font-size: 0.9rem; }
.chart-link-banner .btn-sm { margin-inline-start: auto; }

.scroll-panel .activity { max-height: none; overflow: visible; }

td.rank { color: var(--muted); font-size: 0.75rem; }
.row-synced { background: rgba(240, 193, 90, 0.06); }

.panel-head .btn-sm { margin-inline-start: auto; }

.scroll-panel-proposals { max-height: 380px; }

.live-scanner-dot {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  opacity: 0.5;
  transition: opacity 0.3s, color 0.3s;
}
.live-scanner-dot.on {
  color: var(--mint);
  opacity: 1;
  animation: live-dot-blink 1.2s ease-in-out infinite;
}
.live-scanner-dot.busy { animation: live-dot-blink 0.6s ease-in-out infinite; }

@keyframes live-dot-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.strong-pulse-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 8px rgba(61, 255, 168, 0.8);
  animation: strong-pulse 1s ease-in-out infinite;
}

@keyframes strong-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
    box-shadow: 0 0 10px rgba(61, 255, 168, 0.9);
  }
  50% {
    opacity: 0.25;
    transform: scale(0.75);
    box-shadow: 0 0 4px rgba(61, 255, 168, 0.3);
  }
}

tr.row-strong-pulse {
  animation: row-glow 1.4s ease-in-out infinite;
}

@keyframes row-glow {
  0%, 100% { background: rgba(61, 255, 168, 0.07); }
  50% { background: rgba(61, 255, 168, 0.02); }
}

#liveProposalsPanel.has-strong {
  border-color: rgba(61, 255, 168, 0.4);
  box-shadow: 0 0 20px rgba(61, 255, 168, 0.08);
}

.auto-trader-panel.auto-on {
  border-color: rgba(61, 255, 168, 0.45);
  box-shadow: 0 0 24px rgba(61, 255, 168, 0.1);
}
.auto-trader-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.55rem;
}
.auto-trader-grid .m {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.12);
}
.auto-trader-grid .m span { display: block; color: var(--muted); font-size: 0.72rem; }
.auto-trader-grid .m strong { font-family: var(--mono); font-size: 0.85rem; }
.highlight-check { border: 1px solid rgba(61, 255, 168, 0.25); padding: 0.5rem 0.65rem; border-radius: 8px; }

.learning-panel { border-color: rgba(147, 112, 219, 0.3); }
.learning-lessons {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.65rem 0;
}
.learning-lesson {
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  font-size: 0.8rem;
  line-height: 1.45;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.15);
}
.learning-lesson.avoid { border-color: rgba(255, 107, 122, 0.35); color: var(--rose); }
.learning-lesson.prefer { border-color: rgba(61, 255, 168, 0.35); color: var(--mint); }
.learning-table { width: 100%; font-size: 0.78rem; min-width: 0; }
.learning-table th, .learning-table td { padding: 0.4rem 0.35rem; white-space: nowrap; }
.learning-hero { border-color: rgba(147, 112, 219, 0.45); background: linear-gradient(135deg, rgba(147,112,219,.08), rgba(61,255,168,.04)); }
.learning-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.65rem; margin-top: 0.5rem; }
.learning-kpis .kpi-card { background: rgba(0,0,0,.25); border: 1px solid rgba(255,255,255,.06); border-radius: 10px; padding: 0.55rem 0.65rem; }
.learning-kpis .kpi-card span { display: block; font-size: 0.72rem; color: var(--muted); }
.learning-kpis .kpi-card strong { font-size: 1.05rem; }
.learning-head-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.learning-options-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.75rem; align-items: end; }
.learning-adaptive-box { margin-top: 0.75rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0.5rem; }
.learning-adaptive-box .adaptive-chip { background: rgba(147,112,219,.12); border: 1px solid rgba(147,112,219,.25); border-radius: 8px; padding: 0.45rem 0.55rem; font-size: 0.8rem; }
.learning-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.learning-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 900px) { .learning-grid-2, .learning-grid-3 { grid-template-columns: 1fr; } }
.learning-insights { display: flex; flex-direction: column; gap: 0.45rem; margin-bottom: 0.75rem; }
.learning-insight { padding: 0.5rem 0.65rem; border-radius: 8px; background: rgba(61,255,168,.06); border: 1px solid rgba(61,255,168,.2); font-size: 0.82rem; }
.learning-stat-row { display: flex; justify-content: space-between; align-items: center; padding: 0.35rem 0; border-bottom: 1px solid rgba(255,255,255,.05); font-size: 0.8rem; }
.learning-stat-row .bar-wrap { flex: 1; margin: 0 0.5rem; height: 6px; background: rgba(255,255,255,.08); border-radius: 4px; overflow: hidden; }
.learning-stat-row .bar { height: 100%; border-radius: 4px; }
.learning-mini-lists { display: grid; gap: 0.35rem; font-size: 0.78rem; }
.learning-rank { display: flex; justify-content: space-between; padding: 0.3rem 0.4rem; border-radius: 6px; background: rgba(0,0,0,.2); }
.learning-patterns-table .action-avoid { color: var(--rose); }
.learning-patterns-table .action-prefer { color: var(--mint); }
.learning-help-list { margin: 0; padding-right: 1.2rem; color: var(--muted); font-size: 0.85rem; line-height: 1.7; }
.learning-help-list code { color: var(--mint); font-size: 0.78rem; }
.scroll-panel-md { max-height: 320px; }
.scroll-panel-lg { max-height: 420px; }
.tr-badge-win { color: var(--mint); }
.tr-badge-loss { color: var(--rose); }
.cooldown-tag { color: #ffb347; font-size: 0.7rem; }
.positions-panel.sl-alert { border-color: rgba(255, 107, 122, 0.55); box-shadow: 0 0 0 1px rgba(255, 107, 122, 0.2); }
tr.sl-breached { background: rgba(255, 107, 122, 0.08); }
.sl-tag { font-size: 0.68rem; color: var(--rose); border: 1px solid rgba(255,107,122,.35); padding: 0.1rem 0.35rem; border-radius: 4px; }
.hint.warn-text { color: var(--rose); }

/* ── Trade dock (يسار الشاشة) ── */
.trade-dock-tab {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10050;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.65rem 0.45rem;
  border: 1px solid rgba(61, 255, 168, 0.35);
  border-left: none;
  border-radius: 0 12px 12px 0;
  background: linear-gradient(135deg, rgba(11, 18, 16, 0.95), rgba(20, 35, 28, 0.92));
  color: var(--mint);
  cursor: pointer;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
  transition: transform 0.25s, background 0.2s;
}
.trade-dock-tab:hover { background: rgba(61, 255, 168, 0.12); transform: translateY(-50%) translateX(2px); }
.trade-dock-tab.open { left: min(340px, 92vw); border-radius: 0 12px 12px 0; }
.trade-dock-tab .tab-icon { font-size: 1.1rem; line-height: 1; }
.trade-dock-tab .tab-label { font-family: var(--mono); font-size: 0.62rem; font-weight: 700; letter-spacing: 0.06em; }
.trade-dock-tab .tab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--mint);
  color: #0b1210;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.trade-dock-tab.has-alert { animation: dock-tab-pulse 1.2s ease-in-out infinite; border-color: var(--amber); color: var(--amber); }
@keyframes dock-tab-pulse {
  0%, 100% { box-shadow: 4px 0 16px rgba(240, 193, 90, 0.2); }
  50% { box-shadow: 4px 0 28px rgba(240, 193, 90, 0.55); }
}

.trade-dock {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: min(340px, 92vw);
  z-index: 10040;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(8, 14, 12, 0.98), rgba(12, 20, 17, 0.96));
  border-right: 1px solid rgba(61, 255, 168, 0.2);
  box-shadow: 8px 0 40px rgba(0, 0, 0, 0.45);
  transform: translateX(-105%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(12px);
}
.trade-dock.open { transform: translateX(0); }
.trade-dock-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1rem 1rem 0.65rem;
  border-bottom: 1px solid var(--line);
}
.trade-dock-head h3 { margin: 0; font-size: 1rem; color: var(--mint); }
.trade-dock-head small { color: var(--muted); font-size: 0.72rem; }
.dock-close {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.dock-close:hover { color: var(--rose); border-color: rgba(255, 107, 122, 0.4); }

.trade-dock-alerts {
  max-height: 88px;
  overflow: auto;
  padding: 0.4rem 0.65rem;
  font-size: 0.72rem;
  border-bottom: 1px solid var(--line);
}
.trade-dock-alerts:empty { display: none; }
.dock-alert-line { padding: 0.25rem 0; color: var(--muted); }
.dock-alert-line.tp1 { color: var(--mint); }
.dock-alert-line.tp2 { color: var(--amber); }
.dock-alert-line.sl { color: var(--rose); }

.trade-dock-cards {
  flex: 1;
  overflow: auto;
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.dock-empty { color: var(--muted); font-size: 0.82rem; text-align: center; padding: 2rem 0.5rem; }

.dock-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.22);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.dock-card.profit { border-color: rgba(61, 255, 168, 0.35); }
.dock-card.loss { border-color: rgba(255, 107, 122, 0.35); }
.dock-card.alert-tp1 { animation: card-tp1 1.5s ease; }
.dock-card.alert-tp2 { animation: card-tp2 1.5s ease; }
.dock-card.alert-sl { animation: card-sl 1.5s ease; }
@keyframes card-tp1 { 0%,100%{ box-shadow: 0 0 0 transparent; } 50%{ box-shadow: 0 0 20px rgba(61,255,168,0.35); } }
@keyframes card-tp2 { 0%,100%{ box-shadow: 0 0 0 transparent; } 50%{ box-shadow: 0 0 20px rgba(240,193,90,0.4); } }
@keyframes card-sl { 0%,100%{ box-shadow: 0 0 0 transparent; } 50%{ box-shadow: 0 0 20px rgba(255,107,122,0.45); } }

.dock-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}
.dock-card-top strong { font-size: 0.95rem; }
.dock-pnl {
  font-family: var(--mono);
  font-size: 0.88rem;
  font-weight: 700;
}
.dock-pnl.up { color: var(--mint); }
.dock-pnl.down { color: var(--rose); }

.dock-progress {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 107, 122, 0.25);
  margin: 0.55rem 0;
  overflow: hidden;
}
.dock-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--rose), var(--mint));
  transition: width 0.4s ease;
}
.dock-progress-mark {
  position: absolute;
  top: -3px;
  width: 3px;
  height: 14px;
  background: #fff;
  border-radius: 2px;
  transform: translateX(-50%);
  box-shadow: 0 0 6px rgba(255,255,255,0.6);
  transition: left 0.4s ease;
}
.dock-progress-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.dock-levels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 0.5rem;
  font-size: 0.74rem;
  margin-bottom: 0.45rem;
}
.dock-levels span { color: var(--muted); }
.dock-levels b { font-family: var(--mono); font-weight: 600; }
.dock-levels .sl b { color: var(--rose); }
.dock-levels .tp1 b { color: var(--mint); }
.dock-levels .tp2 b { color: var(--amber); }

.dock-badges { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 0.4rem; }
.dock-badge {
  font-size: 0.62rem;
  padding: 0.12rem 0.4rem;
  border-radius: 6px;
  font-family: var(--mono);
  border: 1px solid var(--line);
  color: var(--muted);
}
.dock-badge.on { border-color: rgba(61,255,168,0.35); color: var(--mint); }

.dock-note {
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.4;
  max-height: 2.8em;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.45rem;
}

.dock-card-actions { display: flex; gap: 0.35rem; }
.dock-card-actions .btn-sm { flex: 1; font-size: 0.7rem; padding: 0.3rem 0.4rem; }

.dock-pnl-grid {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.55rem 0;
  padding: 0.55rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
}
.dock-pnl-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.1rem 0.5rem;
  align-items: baseline;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.dock-pnl-row:last-child { border-bottom: none; padding-bottom: 0; }
.dock-pnl-row .lbl { font-size: 0.72rem; color: var(--muted); grid-column: 1; }
.dock-pnl-row .val {
  font-family: var(--mono);
  font-size: 0.88rem;
  font-weight: 700;
  grid-column: 2;
  grid-row: 1 / span 2;
  text-align: left;
}
.dock-pnl-row .val.up { color: var(--mint); }
.dock-pnl-row .val.down { color: var(--rose); }
.dock-pnl-row .sub { font-size: 0.65rem; color: var(--muted); grid-column: 1; }
.dock-pnl-row.row-now { border-bottom: 1px solid rgba(61, 255, 168, 0.15); padding-bottom: 0.45rem; margin-bottom: 0.1rem; }
.dock-pnl-row.row-now .val { font-size: 1rem; }
.dock-pnl-row.hit .lbl::after { content: " ✓"; color: var(--mint); }
.dock-pnl-row.row-sl .val { color: var(--rose); }
.dock-pnl-row.row-plan .lbl { color: var(--amber); }

.targets-cell small.targets-usd {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 0.15rem;
  white-space: normal;
  line-height: 1.35;
}

.trade-dock-foot {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-top: 1px solid var(--line);
  font-size: 0.74rem;
  color: var(--muted);
}
.dock-opt { display: flex; align-items: center; gap: 0.3rem; cursor: pointer; }

.trade-alert-stack {
  position: fixed;
  top: 72px;
  left: 16px;
  z-index: 10060;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  max-width: min(360px, 90vw);
}
.trade-alert-toast {
  pointer-events: auto;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(8, 14, 12, 0.95);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.35s ease;
  font-size: 0.82rem;
  line-height: 1.45;
}
.trade-alert-toast strong { display: block; margin-bottom: 0.2rem; font-size: 0.9rem; }
.trade-alert-toast.tp1 { border-color: rgba(61,255,168,0.5); background: rgba(61,255,168,0.08); }
.trade-alert-toast.tp2 { border-color: rgba(240,193,90,0.5); background: rgba(240,193,90,0.08); }
.trade-alert-toast.sl { border-color: rgba(255,107,122,0.55); background: rgba(255,107,122,0.1); }
.trade-alert-toast .toast-pnl { font-family: var(--mono); font-weight: 700; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 640px) {
  .trade-dock-tab.open { left: min(300px, 88vw); }
  .trade-dock { width: min(300px, 88vw); }
}

/* Login */
.login-body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow);
  text-align: center;
  position: relative;
  z-index: 1;
}
.login-mark { margin: 0 auto 1rem; width: 56px; height: 56px; font-size: 1.4rem; }
.login-card h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.6rem;
}
.login-sub { color: var(--muted); margin: 0.35rem 0 1.25rem; font-size: 0.9rem; }
.login-form { text-align: start; display: grid; gap: 0.85rem; }
.login-btn { width: 100%; margin-top: 0.25rem; }
.login-foot { margin: 1rem 0 0; font-size: 0.78rem; color: var(--muted); }

/* System Guide tab */
.guide-hero .guide-lead {
  margin: 0 0 1rem;
  color: var(--muted);
  line-height: 1.65;
  font-size: 0.92rem;
}
.guide-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  align-items: center;
  font-size: 0.78rem;
  color: var(--mint);
  font-family: var(--mono);
}
.guide-arrow { color: var(--muted); }
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}
.guide-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  background: rgba(0, 0, 0, 0.18);
}
.guide-card h3 {
  margin: 0 0 0.45rem;
  font-size: 0.92rem;
  font-family: var(--display);
  color: var(--mint);
}
.guide-card p { margin: 0; font-size: 0.82rem; color: var(--muted); line-height: 1.55; }
.guide-sections { display: grid; gap: 0.5rem; }
.guide-details {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
  background: rgba(0, 0, 0, 0.12);
}
.guide-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  list-style: none;
}
.guide-details summary::-webkit-details-marker { display: none; }
.guide-details summary::before {
  content: "▸ ";
  color: var(--mint);
}
.guide-details[open] summary::before { content: "▾ "; }
.guide-details ul, .guide-details ol, .guide-details p {
  margin: 0.55rem 0 0;
  padding-inline-start: 1.1rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.6;
}
.guide-ol { padding-inline-start: 1.25rem; }
.guide-note {
  margin-top: 0.85rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  border: 1px solid rgba(240, 193, 90, 0.35);
  background: rgba(240, 193, 90, 0.08);
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--text);
}
.guide-criteria { margin-top: 0; }
.guide-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.guide-table th, .guide-table td {
  border: 1px solid var(--line);
  padding: 0.55rem 0.65rem;
  text-align: start;
}
.guide-table th { background: rgba(61, 255, 168, 0.08); color: var(--mint); }
.guide-table td { color: var(--muted); }
.guide-footer-note p { margin: 0; font-size: 0.84rem; color: var(--muted); line-height: 1.6; }

/* Mobile topbar */
@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }
  .top-meta {
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: flex-start;
  }
  .top-meta .pill { font-size: 0.68rem; }
  #btnLogout { margin-inline-start: auto; }
  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
  }
  .tabs .tab { flex: 0 0 auto; white-space: nowrap; }
  .scroll-panel .table-wrap { overflow-x: auto; }
  .scroll-panel table { min-width: 720px; }
  .panel-head-actions { margin-inline-start: 0; width: 100%; }
}

