/* ============================
   OKX AI Trading Bot — Styles
   ============================ */

/* ===== DARK THEME (Default) ===== */
:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #21262d;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --blue: #1f6feb;
  --green: #2ea043;
  --red: #f85149;
  --yellow: #d29922;
  --purple: #8957e5;
  --cyan: #39c5cf;
  --sidebar-w: 220px;
  --radius: 10px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --shadow: 0 2px 8px rgba(0,0,0,0.4);
}

/* ===== LIGHT THEME ===== */
body.light {
  --bg: #f0f4f8;
  --bg2: #ffffff;
  --bg3: #eaf0f6;
  --border: #d0d7de;
  --text: #1a2332;
  --text-muted: #57606a;
  --blue: #0969da;
  --green: #1a7f37;
  --red: #cf222e;
  --yellow: #9a6700;
  --purple: #6e40c9;
  --cyan: #0598a8;
  --shadow: 0 2px 8px rgba(0,0,0,0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; transition: background 0.2s, color 0.2s, border-color 0.2s; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 16px;
}
.logo-icon { font-size: 24px; }

.nav-links { list-style: none; padding: 12px 0; flex: 1; }
.nav-links li { margin: 2px 8px; }
.nav-link {
  display: block;
  padding: 10px 14px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-muted);
  transition: all 0.2s;
  font-size: 13.5px;
}
.nav-link:hover, .nav-link.active {
  background: var(--bg3);
  color: var(--text);
}
.nav-link.active { color: var(--cyan); }

.sidebar-status {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.status-dot-wrap { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: background 0.3s;
}
.dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.offline { background: var(--red); }

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== TOPBAR ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.section-title { font-size: 18px; font-weight: 700; }
.mode-badge {
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  background: #1a3a5c;
  color: #79c0ff;
  border: 1px solid #1f6feb;
}
.mode-badge.real { background: #3d1a1a; color: #ff7b72; border-color: var(--red); }

.topbar-right { display: flex; align-items: center; gap: 16px; }
.system-time { font-size: 12px; color: var(--text-muted); font-family: monospace; }
.bot-status-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.bot-status-badge.running { background: #12261e; color: #56d364; border-color: var(--green); }
.bot-status-badge.paused { background: #2e2200; color: #e3b341; border-color: var(--yellow); }
.bot-status-badge.danger { background: #3d1a1a; color: #ff7b72; border-color: var(--red); }

/* ===== SECTIONS ===== */
.section { display: none; padding: 24px 28px; gap: 20px; flex-direction: column; }
.section.active { display: flex; }

/* ===== METRIC CARDS ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card-label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.card-value { font-size: 24px; font-weight: 700; }
.card-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.card-blue { border-top: 3px solid var(--blue); }
.card-green { border-top: 3px solid var(--green); }
.card-purple { border-top: 3px solid var(--purple); }
.card-gray { border-top: 3px solid var(--text-muted); }

/* ===== SENTIMENT MACRO CARD ===== */
.sentiment-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sentiment-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.sentiment-fng-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sentiment-icon { font-size: 16px; }
.sentiment-label { font-size: 13px; font-weight: 600; }
.fng-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--bg3);
  border: 1px solid var(--border);
}
.fng-badge.extreme-fear { background: #3d1a1a; color: #ff7b72; border-color: var(--red); }
.fng-badge.fear { background: #3d2a1a; color: #ffa657; border-color: #ffa657; }
.fng-badge.neutral { background: #232a35; color: #79c0ff; border-color: var(--blue); }
.fng-badge.greed { background: #1a382a; color: #56d364; border-color: var(--green); }
.fng-badge.extreme-greed { background: #12261e; color: #3fb950; border-color: #3fb950; font-weight: 800; }

.fng-score {
  font-size: 13px;
  font-weight: 700;
  font-family: monospace;
}
.sentiment-updated {
  font-size: 11px;
  color: var(--text-muted);
}
.sentiment-news-scroll {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}
.news-ticker-item {
  font-size: 12px;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ===== CONTROL PANEL ===== */
.control-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.control-panel-title { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }
.control-buttons { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn:hover { opacity: 0.85; transform: translateY(-1px); }
.btn-start { background: var(--green); color: #fff; }
.btn-pause { background: var(--yellow); color: #0d1117; }
.btn-stop { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-kill { background: var(--red); color: #fff; }
.btn-primary { background: var(--blue); color: #fff; }

.control-info {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
  font-family: monospace;
}

/* ===== MISSION CONTROL & AI THOUGHT STREAM ===== */
.mission-control-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}
@media (max-width: 1024px) {
  .mission-control-grid { grid-template-columns: 1fr; }
}

.ai-thought-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.thought-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.thought-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ai-brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  color: #00ff88;
  background: rgba(0, 255, 136, 0.12);
  border: 1.5px solid #00ff88;
  border-radius: 8px;
  padding: 4px 10px;
  letter-spacing: 1px;
  box-shadow: 0 0 14px rgba(0, 255, 136, 0.35);
}
.highlight-ai-green {
  color: #00ff88;
  font-size: 18px;
  font-weight: 800;
}
.thought-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.thought-sub {
  font-size: 11px;
  color: var(--text-muted);
}
.thought-status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--blue);
}
.thought-token-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(227, 179, 65, 0.12);
  border: 1px solid rgba(227, 179, 65, 0.35);
  color: #e3b341;
  font-family: monospace;
}

/* Quick Metrics Bar */
.ai-metrics-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--bg3);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.metric-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding-right: 12px;
  border-right: 1px solid var(--border);
}
.metric-chip:last-child { border-right: none; }
.chip-label { color: var(--text-muted); }
.badge-trend {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}
.badge-trend.STRONG_BULLISH, .badge-trend.BULLISH { background: #12261e; color: #56d364; }
.badge-trend.STRONG_BEARISH, .badge-trend.BEARISH { background: #3d1a1a; color: #ff7b72; }
.badge-trend.NEUTRAL { background: #232a35; color: #79c0ff; }

/* Terminal Screen */
.ai-terminal-screen {
  background: #090d13;
  color: #c9d1d9;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 14px 16px;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  min-height: 140px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.4);
}
body.light .ai-terminal-screen {
  background: #1e2430;
  color: #e6edf3;
  border-color: #3b4252;
}
.terminal-entry {
  margin-bottom: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  transition: all 0.3s ease;
}
.terminal-entry.newest-thought {
  animation: glowPulse 2s infinite alternate ease-in-out;
  background: rgba(0, 255, 136, 0.08);
}
@keyframes glowPulse {
  0% {
    box-shadow: 0 0 4px rgba(0, 255, 136, 0.2);
    border-left: 3px solid rgba(0, 255, 136, 0.5);
  }
  100% {
    box-shadow: 0 0 14px rgba(0, 255, 136, 0.7);
    border-left: 3px solid #00ff88;
  }
}
.terminal-prompt { color: var(--green); font-weight: 700; }
.terminal-dim { color: #8b949e; }
.terminal-highlight { color: #58a6ff; font-weight: 600; }
.terminal-bold { color: #f0883e; font-weight: 700; }
.terminal-reason { color: #e6edf3; padding-left: 12px; border-left: 2px solid var(--blue); margin-top: 4px; }

/* Verdict Bar */
.ai-verdict-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg3);
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.verdict-action-box {
  display: flex;
  align-items: center;
  gap: 10px;
}
.verdict-label { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.verdict-action {
  font-size: 13px;
  font-weight: 800;
  padding: 4px 14px;
  border-radius: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.verdict-action.BUY { background: #12261e; color: #56d364; border: 1px solid #238636; }
.verdict-action.SELL { background: #3d1a1a; color: #ff7b72; border: 1px solid #da3633; }
.verdict-action.HOLD { background: #2e2200; color: #e3b341; border: 1px solid #9e6a03; }
.verdict-conf { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.verdict-levels {
  display: flex;
  gap: 14px;
  font-size: 12px;
  font-family: monospace;
}
.text-danger { color: var(--red); }
.text-success { color: var(--green); }

/* Radar Card */
.market-radar-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.radar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.radar-title { font-size: 14px; font-weight: 700; }
.radar-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
}
.radar-badge.greed { background: #1a382a; color: #56d364; border-color: var(--green); }
.radar-badge.extreme-greed { background: #12261e; color: #3fb950; border-color: #3fb950; font-weight: 800; }
.radar-badge.fear { background: #3d2a1a; color: #ffa657; border-color: #ffa657; }
.radar-badge.extreme-fear { background: #3d1a1a; color: #ff7b72; border-color: var(--red); }
.radar-badge.neutral { background: #232a35; color: #79c0ff; border-color: var(--blue); }
.radar-fng-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.fng-meter {
  flex: 1;
  height: 8px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.fng-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff7b72, #e3b341, #3fb950);
  transition: width 0.5s ease;
}
.fng-score-text { font-size: 12px; font-weight: 700; font-family: monospace; }
.radar-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.radar-live-status {
  font-size: 10px;
  font-weight: 700;
  color: var(--blue);
  background: rgba(56, 139, 253, 0.12);
  border: 1px solid rgba(56, 139, 253, 0.3);
  padding: 2px 8px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.5px;
}
.radar-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 6px var(--blue);
  animation: radarPulse 1.8s infinite;
}
@keyframes radarPulse {
  0% { transform: scale(0.9); opacity: 0.5; }
  50% { transform: scale(1.4); opacity: 1; box-shadow: 0 0 10px var(--blue); }
  100% { transform: scale(0.9); opacity: 0.5; }
}

.news-stream-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}
.news-stream-title { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.news-updated-time { font-size: 10px; color: var(--green); font-family: monospace; font-weight: 600; }

.news-stream-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 185px;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding-right: 4px;
}
.news-stream-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  line-height: 1.4;
  background: var(--bg3);
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}
.news-stream-item.newest-news {
  border-color: rgba(56, 139, 253, 0.6);
  background: rgba(56, 139, 253, 0.08);
  box-shadow: 0 0 8px rgba(56, 139, 253, 0.2);
}
.news-stream-item.newest-news .news-dot {
  color: var(--green);
  animation: radarDotGlow 1.5s infinite;
}
@keyframes radarDotGlow {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.3); }
}
.news-dot { color: var(--blue); font-size: 9px; margin-top: 3px; flex-shrink: 0; }
.news-text { color: var(--text); }

/* Split Card Grid */
.dashboard-split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 1024px) {
  .dashboard-split-grid { grid-template-columns: 1fr; }
}

.table-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}
.btn-refresh-sm {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}
.badge-winrate {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.badge-res {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.badge-res.win { background: #12261e; color: #56d364; }
.badge-res.loss { background: #3d1a1a; color: #ff7b72; }
.badge-res.open { background: #1f2d3d; color: #58a6ff; }

/* System Logs Console */
.system-logs-console {
  padding: 12px 16px;
  height: 240px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg);
}
.log-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.4;
  border-bottom: 1px dashed rgba(255,255,255,0.06);
  padding-bottom: 4px;
}
body.light .log-item {
  border-bottom: 1px dashed rgba(0,0,0,0.08);
}
.log-time { color: var(--text-muted); font-size: 10px; white-space: nowrap; }
.log-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}
.tag-ai { background: #1f2d3d; color: #79c0ff; }
.tag-risk { background: #3b2e1a; color: #f0883e; }
.tag-trade { background: #1a382a; color: #56d364; }
.tag-sys { background: #21262d; color: #c9d1d9; }
.log-msg { color: var(--text); word-break: break-word; }

/* ===== TABLES ===== */
.table-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-card-title {
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.data-table { width: 100%; border-collapse: collapse; min-width: 520px; }
.data-table th {
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.data-table td {
  padding: 8px 10px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg3); }
.empty-row { text-align: center; color: var(--text-muted); padding: 24px !important; }

.pnl-pos { color: var(--green); font-weight: 600; }
.pnl-neg { color: var(--red); font-weight: 600; }
.side-long { color: var(--green); font-weight: 600; }
.side-short { color: var(--red); font-weight: 600; }
.status-open { color: var(--cyan); }
.status-closed { color: var(--text-muted); }

/* ===== SETUP FORMS ===== */
.setup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.setup-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.setup-card h3 { margin-bottom: 18px; font-size: 15px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font);
  transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--blue);
}
.form-group textarea { resize: vertical; min-height: 80px; }

/* ===== COIN SELECTION DROPDOWN & TAGS ===== */
.symbol-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.symbol-header-row label {
  margin-bottom: 0 !important;
}
.symbol-counter {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg3);
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-weight: 600;
}
.symbol-dropdown-row {
  margin-bottom: 8px;
}
.symbol-dropdown-row select {
  width: 100%;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  background: var(--bg3);
  color: var(--text);
  border: 1.5px solid var(--blue);
  border-radius: 6px;
  cursor: pointer;
  outline: none;
}
.symbol-dropdown-row select optgroup {
  background: var(--bg2);
  color: var(--text-muted);
  font-weight: 700;
  padding: 6px 0;
}
.symbol-dropdown-row select option {
  background: var(--bg3);
  color: var(--text);
  padding: 8px 12px;
}
.symbol-presets {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.preset-label {
  font-size: 11px;
  color: var(--text-muted);
}
.btn-chip-action {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-chip-action:hover {
  color: var(--text);
  border-color: var(--blue);
}
.selected-tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 10px 0;
  min-height: 38px;
  padding: 6px 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  align-items: center;
}
.selected-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #1a3a5c;
  color: #79c0ff;
  border: 1px solid #1f6feb;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  user-select: none;
}
body.light .selected-tag {
  background: #e8f0fe;
  color: #0969da;
  border-color: #0969da;
}
.selected-tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: inherit;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}
.selected-tag-remove:hover {
  background: var(--red);
  color: #fff;
}
.empty-tags-hint {
  color: var(--text-muted);
  font-size: 12px;
  padding: 4px;
}
.symbol-input-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.symbol-input-bar input {
  flex: 1;
}
.symbol-input-bar button {
  padding: 6px 14px;
  white-space: nowrap;
}
.sub-label {
  font-size: 11px !important;
  color: var(--text-muted);
  margin-top: 6px;
  display: block;
}

.toggle-group { display: flex; gap: 16px; }
.toggle-label { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 13px; }
.real-mode { color: var(--yellow); }

.security-note {
  background: #1a2538;
  border: 1px solid #1f6feb40;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 11px;
  color: #79c0ff;
  margin: 10px 0 14px;
}
.save-result { margin-top: 10px; font-size: 12px; min-height: 18px; }
.save-result.success { color: var(--green); }
.save-result.error { color: var(--red); }

/* ===== AI FEED ===== */
.ai-feed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  padding: 4px 0 16px;
}
.feed-count { font-size: 12px; color: var(--text-muted); }
.ai-feed-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 70vh;
  overflow-y: auto;
}
.feed-placeholder { text-align: center; color: var(--text-muted); padding: 40px; }

.feed-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  border-left: 4px solid var(--border);
}
.feed-item.BUY { border-left-color: var(--green); }
.feed-item.SELL { border-left-color: var(--red); }
.feed-item.HOLD { border-left-color: var(--yellow); }
.feed-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.feed-item-symbol { font-weight: 700; }
.feed-item-action { font-size: 11px; font-weight: 700; padding: 2px 10px; border-radius: 10px; }
.feed-item-action.BUY { background: #12261e; color: #56d364; }
.feed-item-action.SELL { background: #3d1a1a; color: #ff7b72; }
.feed-item-action.HOLD { background: #2e2200; color: #e3b341; }
.feed-item-reason { font-size: 12.5px; color: var(--text-muted); line-height: 1.5; margin-bottom: 8px; }
.feed-item-meta { font-size: 11px; color: var(--text-muted); font-family: monospace; }

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .setup-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .logo-text, .nav-link span, .sidebar-status { display: none; }
  .main-content { margin-left: 60px; }
  .cards-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== THEME TOGGLE & GUIDE BUTTON ===== */
.btn-theme {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; width: 36px; height: 36px; font-size: 16px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.btn-theme:hover { border-color: var(--blue); }
.btn-guide {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text-muted);
  border-radius: 8px; padding: 6px 12px; font-size: 12px; cursor: pointer;
}
.btn-guide:hover { color: var(--text); border-color: var(--blue); }

/* ===== GUIDE SECTION ===== */
.guide-container { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.guide-hero {
  background: linear-gradient(135deg, #1a2a4a 0%, #0d1117 100%);
  border: 1px solid var(--blue); border-radius: var(--radius); padding: 32px; text-align: center;
}
body.light .guide-hero { background: linear-gradient(135deg, #e8f0fe 0%, #f0f4f8 100%); }
.guide-hero h1 { font-size: 28px; margin-bottom: 8px; }
.guide-hero p { color: var(--text-muted); font-size: 15px; }

.guide-step {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; display: flex; gap: 20px; align-items: flex-start;
}
.guide-step-num {
  background: var(--blue); color: #fff; width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.guide-step-content { flex: 1; }
.guide-step-content h3 { font-size: 16px; margin-bottom: 10px; }
.guide-step-content p { color: var(--text-muted); margin-bottom: 10px; line-height: 1.6; }
.guide-step-content ol { padding-left: 20px; color: var(--text-muted); line-height: 2.2; }
.guide-step-content a { color: var(--blue); text-decoration: none; }
.guide-step-content a:hover { text-decoration: underline; }

.guide-note {
  background: #2a1a00; border: 1px solid #d2992280; border-radius: 6px;
  padding: 10px 14px; font-size: 12.5px; color: #e3b341; margin-top: 10px;
}
body.light .guide-note { background: #fff8e6; border-color: var(--yellow); color: var(--yellow); }

.guide-providers { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.guide-provider {
  background: var(--bg3); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.guide-badge { padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.guide-badge.green { background: #12261e; color: #56d364; }
.guide-badge.blue { background: #1a2b4a; color: #79c0ff; }
.guide-badge.gray { background: var(--bg3); color: var(--text-muted); border: 1px solid var(--border); }
.guide-badge.purple { background: #231a3a; color: #c9a8ff; }
body.light .guide-badge.green { background: #e6ffec; color: var(--green); }
body.light .guide-badge.blue { background: #e8f0fe; color: var(--blue); }
body.light .guide-badge.purple { background: #f0e8ff; color: var(--purple); }

.guide-config-list { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.guide-config-item {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--bg3); border-radius: 8px; padding: 12px 16px; border: 1px solid var(--border);
}
.config-icon { font-size: 20px; }
.guide-config-item p { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.guide-section-title { font-size: 15px; font-weight: 700; padding: 8px 0 4px; border-bottom: 1px solid var(--border); }

.guide-risk-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.guide-risk-item {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; display: flex; gap: 10px; align-items: flex-start;
}
.risk-num {
  background: var(--blue); color: #fff; width: 24px; height: 24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.guide-risk-item small { color: var(--text-muted); font-size: 11px; }

.guide-controls-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.guide-ctrl { border-radius: 8px; padding: 16px; font-size: 13px; border: 1px solid var(--border); line-height: 1.8; }
.green-ctrl { background: #12261e; border-color: var(--green); }
.yellow-ctrl { background: #2e2200; border-color: var(--yellow); }
.gray-ctrl { background: var(--bg3); }
.red-ctrl { background: #3d1a1a; border-color: var(--red); }
body.light .green-ctrl { background: #e6ffec; }
body.light .yellow-ctrl { background: #fff8e6; }
body.light .red-ctrl { background: #fff0f0; }
.btn-demo { color: var(--green); font-weight: 700; }

.guide-warning {
  background: #2a1a00; border: 1px solid #d2992260; border-radius: 8px;
  padding: 16px 20px; font-size: 13px; color: var(--text-muted); line-height: 1.7;
}
body.light .guide-warning { background: #fff8e6; border-color: var(--yellow); }

/* ===== LIGHT THEME OVERRIDES ===== */
body.light .feed-item-action.BUY { background: #e6ffec; color: var(--green); }
body.light .feed-item-action.SELL { background: #fff0f0; color: var(--red); }
body.light .feed-item-action.HOLD { background: #fff8e6; color: var(--yellow); }
body.light .ai-signal-action.BUY { background: #e6ffec; color: var(--green); }
body.light .ai-signal-action.SELL { background: #fff0f0; color: var(--red); }
body.light .ai-signal-action.HOLD { background: #fff8e6; color: var(--yellow); }
body.light .bot-status-badge.running { background: #e6ffec; color: var(--green); border-color: var(--green); }
body.light .bot-status-badge.paused { background: #fff8e6; color: var(--yellow); border-color: var(--yellow); }
body.light .bot-status-badge.danger { background: #fff0f0; color: var(--red); border-color: var(--red); }
body.light .mode-badge { background: #e8f0fe; color: var(--blue); border-color: var(--blue); }
body.light .mode-badge.real { background: #fff0f0; color: var(--red); border-color: var(--red); }
body.light .data-table th { background: var(--bg3); }
body.light .security-note { background: #e8f0fe; border-color: #0969da40; color: var(--blue); }
/* Light: nút vàng/xanh cần chữ trắng để đủ tương phản trên nền đậm hơn */
body.light .btn-pause { color: #fff; }
body.light .btn-resume { color: #fff; }
body.light .stale-note {
  background: rgba(154, 103, 0, 0.10);
  border-color: #b7791f;
  border-left-color: #b7791f;
  color: #7a4f00;
}

@media (max-width: 900px) {
  .guide-risk-grid { grid-template-columns: repeat(2, 1fr); }
  .guide-controls-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   HARDENING ADDITIONS — auth overlay, badges, control escape hatches
   ============================================================ */

/* ===== AUTH OVERLAY ===== */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(5, 8, 12, 0.88);
  backdrop-filter: blur(4px);
}
body.light .auth-overlay { background: rgba(240, 244, 248, 0.92); }
.auth-overlay.auth-hidden { display: none; }

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 26px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-logo { font-size: 15px; font-weight: 700; color: var(--cyan); }
.auth-title { font-size: 20px; font-weight: 700; }
.auth-desc { font-size: 12.5px; color: var(--text-muted); line-height: 1.6; }
.auth-desc code, .auth-hint code {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11.5px;
}
.auth-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  font-family: monospace;
}
.auth-input:focus { outline: none; border-color: var(--blue); }
.auth-submit { width: 100%; }
.auth-submit:disabled { opacity: 0.6; cursor: progress; }
.auth-error { min-height: 18px; font-size: 12.5px; color: var(--text-muted); }
.auth-error.error { color: var(--red); font-weight: 600; }
.auth-hint { font-size: 11px; color: var(--text-muted); line-height: 1.6; border-top: 1px solid var(--border); padding-top: 10px; }

/* ===== MODE BADGE — unknown state ===== */
.mode-badge.unknown {
  background: var(--bg3);
  color: var(--text-muted);
  border-color: var(--border);
}
body.light .mode-badge.unknown { background: var(--bg3); color: var(--text-muted); border-color: var(--border); }

/* ===== CONTROL ESCAPE HATCHES ===== */
.btn-resume { background: var(--cyan); color: #06222a; }
.btn-kill-reset { background: var(--bg3); color: var(--text); border: 1px solid var(--red); }
.btn-danger-outline {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
}
.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.field-note {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ===== POSITIONS TOOLBAR ===== */
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.table-toolbar .save-result { margin-top: 0; }

/* ===== CLOSE POSITION BUTTON ===== */
.close-pos-btn { white-space: nowrap; }

.btn[hidden] { display: none !important; }

/* ===== PHONE-FIRST OPERATIONS =====
   The dashboard is most often checked from a phone.  Keep control actions
   comfortably tappable and turn navigation into a bottom tab bar instead of
   leaving a narrow, unusable desktop sidebar. */
@media (max-width: 640px) {
  body { font-size: 14px; padding-bottom: 68px; }
  .sidebar {
    width: 100%; height: 64px; min-height: 64px; bottom: 0; top: auto;
    padding: 4px 2px; border-right: 0; border-top: 1px solid var(--border);
    flex-direction: row; overflow-x: auto; background: var(--bg2);
  }
  .logo, .sidebar-status { display: none; }
  .nav-links { display: flex; flex: 1; padding: 0; gap: 2px; min-width: 560px; }
  .nav-links li { margin: 0; flex: 1; min-width: 76px; }
  .nav-link {
    height: 56px; padding: 5px 3px; display: flex; align-items: center;
    justify-content: center; text-align: center; line-height: 1.15;
    font-size: 10px; border-radius: 7px; white-space: normal;
  }
  .main-content { margin-left: 0; min-width: 0; }
  .topbar { padding: 10px 12px; min-height: 54px; }
  .topbar-right { gap: 7px; }
  .system-time, .btn-guide { display: none; }
  .section-title { font-size: 16px; }
  .mode-badge { padding: 3px 6px; font-size: 10px; }
  .bot-status-badge { padding: 4px 7px; font-size: 10px; }
  .section { padding: 12px; gap: 12px; }
  .cards-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .card { padding: 13px; }
  .card-value { font-size: 18px; overflow-wrap: anywhere; }
  .card-label, .card-sub { font-size: 11px; }
  .control-panel { padding: 14px; }
  .control-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
  .control-buttons .btn { min-height: 46px; padding: 9px 6px; font-size: 12px; }
  .control-buttons .btn-kill, .control-buttons .btn-kill-reset { grid-column: 1 / -1; }
  .mission-control-grid, .dashboard-split-grid { gap: 12px; }
  .ai-thought-card, .market-radar-card { padding: 13px; }
  .thought-title { font-size: 13px; }
  .thought-sub, .thought-token-badge { display: none; }
  .ai-metrics-bar { max-height: 104px; overflow: auto; }
  .metric-chip { font-size: 11px; padding-right: 7px; }
  .ai-terminal-screen { min-height: 180px; max-height: 260px; font-size: 11px; }
  .verdict-levels { gap: 7px; font-size: 11px; flex-wrap: wrap; }
  .table-card { overflow: hidden; }
  .table-card-header { padding: 10px 12px; gap: 8px; }
  .table-card-title { font-size: 13px; }
  .table-scroll { -webkit-overflow-scrolling: touch; }
  .data-table { min-width: 520px; }
  .setup-card, .guide-step { padding: 14px; }
  .guide-step { gap: 12px; }
  .guide-risk-grid, .guide-controls-grid { grid-template-columns: 1fr; }
  .auth-overlay { padding: 14px; align-items: flex-start; overflow-y: auto; }
  .auth-card { margin-top: 8vh; padding: 22px 18px; }
}


/* ===== STALE LIVE DATA WARNING ===== */
.stale-note {
  margin: 0 0 14px 0;
  padding: 10px 14px;
  border: 1px solid #b7791f;
  border-left: 4px solid #f6ad55;
  border-radius: 8px;
  background: rgba(183, 121, 31, 0.12);
  color: #f6ad55;
  font-size: 13px;
  line-height: 1.4;
}
.stale-note[hidden] { display: none !important; }
.card-value.stale { color: var(--text-muted, #8b93a7); }

/* ===== KEY STATUS BADGE BOX ===== */
.key-status-box {
  margin: 12px 0 16px 0;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg3);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}
.key-status-box.connected {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.08);
  color: #10b981;
}
.key-status-box.unconfigured {
  border-color: var(--border);
  background: var(--bg3);
  color: var(--text-muted);
}
.key-status-box.error {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
  color: var(--red);
}
body.light .key-status-box.connected {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}
body.light .key-status-box.unconfigured {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #475569;
}

/* ===== MODERN CUSTOM CONFIRM MODAL ===== */
.modal-backdrop-custom {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 16px;
  animation: modalFadeIn 0.2s ease-out;
}
.modal-backdrop-custom[hidden] {
  display: none !important;
}
@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card-custom {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: modalScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modalScaleUp {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header-custom {
  display: flex;
  align-items: center;
  gap: 12px;
}
.modal-icon-custom {
  font-size: 26px;
  line-height: 1;
}
.modal-title-custom {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}
.modal-body-custom {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted);
  white-space: pre-line;
  word-break: break-word;
}
.modal-actions-custom {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}
.btn-modal-cancel {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-modal-cancel:hover {
  background: var(--border);
}
.btn-modal-confirm {
  background: var(--blue);
  border: 1px solid transparent;
  color: #fff;
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-modal-confirm:hover {
  filter: brightness(1.15);
}
.btn-modal-confirm.danger {
  background: var(--red);
}

/* ===== TOAST NOTIFICATIONS (TỰ ĐÓNG) ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 380px;
  width: calc(100% - 40px);
}
@media (max-width: 640px) {
  .toast-container {
    top: 12px;
    right: 12px;
    left: 12px;
    width: auto;
  }
}

.toast-item {
  pointer-events: auto;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1), toastFadeOut 0.3s ease-in 3.7s forwards;
  position: relative;
  overflow: hidden;
}
@keyframes toastSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@media (max-width: 640px) {
  @keyframes toastSlideIn {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }
}
@keyframes toastFadeOut {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0.92); }
}

.toast-item.success {
  border-left: 4px solid var(--green);
}
.toast-item.error {
  border-left: 4px solid var(--red);
}
.toast-item.warning {
  border-left: 4px solid #f0883e;
}
.toast-item.info {
  border-left: 4px solid var(--blue);
}
.toast-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}
.toast-msg {
  flex: 1;
  word-break: break-word;
}
.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.toast-close:hover {
  color: var(--text);
}

