/* ================================================
   POLYMARKET AI TRADER — Premium UI V2
   ================================================ */

:root {
  /* Core Colors */
  --void:       #030308;
  --surface:    #0a0a14;
  --surface2:   #121220;
  --surface3:   #1a1a2e;
  
  /* Accents */
  --cyan:       #00e5ff;
  --cyan-dim:   rgba(0,229,255,0.12);
  --cyan-glow:  rgba(0,229,255,0.4);
  --violet:     #a855f7;
  --violet-dim: rgba(168,85,247,0.12);
  --violet-glow:rgba(168,85,247,0.4);
  --emerald:    #10b981;
  --emerald-dim:rgba(16,185,129,0.12);
  --emerald-glow:rgba(16,185,129,0.4);
  --amber:      #f59e0b;
  --amber-dim:  rgba(245,158,11,0.12);
  --amber-glow: rgba(245,158,11,0.4);
  --rose:       #f43f5e;
  --rose-dim:   rgba(244,63,94,0.12);
  --rose-glow:  rgba(244,63,94,0.4);

  /* Typography */
  --text1: #f8fafc;
  --text2: #cbd5e1;
  --text3: #64748b;

  /* Layout Borders */
  --border-light: rgba(255,255,255,0.06);
  --border-med:   rgba(255,255,255,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  
  --sidebar-w: 240px;
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--void);
  color: var(--text1);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  font-size: 13px;
}

/* Base Ambient Background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 20% -10%, rgba(168,85,247,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(0,229,255,0.06) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.mono { font-family: 'JetBrains Mono', monospace; }

.app-layout {
  display: flex;
  height: 100vh;
  width: 100vw;
  position: relative;
  z-index: 1;
}

/* ════════════════════════════════════════
   SIDEBAR NAV
════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: rgba(10,10,20, 0.6);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
}

.sidebar-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 40px;
}
.brand-mark {
  width: 48px; height: 48px;
  background: linear-gradient(145deg, var(--surface2), var(--surface));
  border: 1px solid var(--border-light);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(0,229,255,0.1);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text3);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  text-align: left;
}

.nav-btn:hover {
  background: var(--surface2);
  color: var(--text2);
}

.nav-btn.active {
  background: linear-gradient(90deg, rgba(168,85,247,0.15) 0%, transparent 100%);
  border-left: 3px solid var(--violet);
  color: var(--text1);
  font-weight: 600;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
}

.logout-btn { color: var(--rose); }
.logout-btn:hover { background: var(--rose-dim); color: var(--rose); }


/* ════════════════════════════════════════
   MAIN CONTENT & TOPBAR
════════════════════════════════════════ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0; /* fixes flex overflow */
}

.topbar {
  height: 64px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 30px;
  background: rgba(10,10,20, 0.4);
  backdrop-filter: blur(12px);
}

.topbar-left, .topbar-right {
  display: flex; align-items: center; gap: 20px;
}

.brand-text-mobile { display: none; font-weight: 800; color: var(--text1); letter-spacing: 1px; }

/* Status Chip */
.status-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
}
.chip-led { width: 8px; height: 8px; border-radius: 50%; }
.chip-connecting { background: rgba(68,138,255,0.12); color: #448aff; }
.chip-connecting .chip-led { background: #448aff; animation: blink 1s infinite; }
.chip-real { background: var(--violet-dim); color: var(--violet); border: 1px solid rgba(168,85,247,0.3); box-shadow: 0 0 15px var(--violet-glow); }
.chip-real .chip-led { background: var(--violet); animation: blink 2s infinite; }
.chip-simulacao { background: var(--cyan-dim); color: var(--cyan); border: 1px solid rgba(0,229,255,0.3); box-shadow: 0 0 15px var(--cyan-glow); }
.chip-simulacao .chip-led { background: var(--cyan); animation: blink 2s infinite; }
.chip-stopped { background: var(--surface2); color: var(--text3); border: 1px solid var(--border-light); }
.chip-stopped .chip-led { background: var(--text3); opacity: 0.5; }

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* Daily Briefing */
.daily-briefing {
  background: linear-gradient(90deg, rgba(168,85,247,0.1) 0%, transparent 100%);
  border: 1px solid var(--violet-dim);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--text2);
  animation: slideIn 0.4s ease;
}
.brief-icon { color: var(--amber); font-size: 14px; }

@keyframes slideIn { from{opacity:0; transform:translateX(-10px);} to{opacity:1; transform:translateX(0);} }

/* Topbar Metrics */
.topbar-metrics { display: flex; align-items: center; gap: 15px; }
.tm { display: flex; flex-direction: column; align-items: flex-end; }
.tm-label { font-size: 9px; color: var(--text3); font-weight: 700; letter-spacing: 1px; }
.tm-value { font-size: 14px; font-weight: 700; color: var(--text1); }
.tm-div { width: 1px; height: 30px; background: var(--border-light); }


.btn-danger {
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 700; cursor: pointer;
  background: var(--rose-dim); border: 1px solid rgba(244,63,94,0.3); color: var(--rose);
  transition: 0.2s;
}
.btn-danger:hover { background: rgba(244,63,94,0.2); }

.toggle-power-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 700; cursor: pointer;
  transition: 0.3s; color: white;
  border: 1px solid transparent; background: transparent;
}
.toggle-power-btn.bot-stop {
  background: var(--rose-dim); border-color: rgba(244,63,94,0.3); color: var(--rose);
}
.toggle-power-btn.bot-stop:hover { background: rgba(244,63,94,0.2); box-shadow: 0 0 15px var(--rose-glow); }
.toggle-power-btn.bot-start {
  background: var(--emerald-dim); border-color: rgba(16,185,129,0.3); color: var(--emerald);
}
.toggle-power-btn.bot-start:hover { background: rgba(16,185,129,0.2); box-shadow: 0 0 15px var(--emerald-glow); }

.btn-primary {
  background: linear-gradient(135deg, var(--violet), #7c3aed);
  border: none; color: white; padding: 12px 24px;
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 700;
  cursor: pointer; transition: 0.15s; font-family: inherit;
}
.btn-primary:hover { opacity: 0.9; box-shadow: 0 4px 15px var(--violet-glow); }

.btn-ghost {
  background: var(--surface2); border: 1px solid var(--border-light);
  color: var(--text2); padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 12px; cursor: pointer; font-weight: 600; transition: 0.2s;
}
.btn-ghost:hover { background: var(--surface3); color: var(--text1); border-color: var(--border-med); }

.icon-btn {
  background: none; border: none; color: var(--text3);
  font-size: 16px; cursor: pointer; padding: 4px; border-radius: 4px;
}
.icon-btn:hover { color: var(--cyan); background: var(--surface2); }

/* ════════════════════════════════════════
   TAB CONTENT WRAPPER
════════════════════════════════════════ */
.tab-content-wrapper {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 30px;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease;
}
.tab-pane.active { display: block; }
@keyframes fadeIn { from{opacity:0;} to{opacity:1;} }


/* ════════════════════════════════════════
   GLOBAL GLASS PANELS
════════════════════════════════════════ */
.glass-panel {
  background: rgba(18, 18, 30, 0.4);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.panel-header-premium {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  font-weight: 700;
  color: var(--text1);
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,0.02);
}
.panel-body { padding: 20px; flex: 1; }
.scrollable { overflow-y: auto; }
.scrollable::-webkit-scrollbar { width: 6px; }
.scrollable::-webkit-scrollbar-track { background: transparent; }
.scrollable::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 4px; }


/* ════════════════════════════════════════
   TAB: DASHBOARD
════════════════════════════════════════ */
.dashboard-grid { display: flex; flex-direction: column; gap: 24px; }

/* KPIs Banner */
.kpi-banner {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.kpi-card { padding: 20px; border-top-width: 3px; }
.kpi-card:hover { transform: translateY(-2px); transition: 0.2s; }
.kpi-cyan { border-top-color: var(--cyan); background: linear-gradient(180deg, var(--cyan-dim) 0%, transparent 100%); }
.kpi-emerald { border-top-color: var(--emerald); background: linear-gradient(180deg, var(--emerald-dim) 0%, transparent 100%); }
.kpi-amber { border-top-color: var(--amber); background: linear-gradient(180deg, var(--amber-dim) 0%, transparent 100%); }
.kpi-violet { border-top-color: var(--violet); background: linear-gradient(180deg, var(--violet-dim) 0%, transparent 100%); }

.kpi-card-label { font-size: 11px; font-weight: 800; color: var(--text3); letter-spacing: 1px; }
.kpi-card-value { font-size: 28px; font-weight: 800; color: var(--text1); margin-top: 8px; }
/* Main Dashboard Layout V2 Columns */
.dashboard-columns { display: flex; gap: 24px; }
.dashboard-col-main { flex: 2; display: flex; flex-direction: column; gap: 24px; }
.dashboard-col-side { flex: 1; display: flex; flex-direction: column; gap: 24px; }
.charts-row, .bottom-row { display: flex; gap: 24px; } /* kept for backwards compat if needed */
.flex-1 { flex: 1; min-height: 250px; }
.flex-2 { flex: 1; min-height: 250px; }

.chart-filters { display: flex; gap: 8px; }
.chart-filter { background: transparent; border: 1px solid var(--border-light); color: var(--text3); padding: 4px 10px; font-size: 11px; border-radius: 12px; cursor: pointer; }
.chart-filter.active { background: var(--cyan-dim); color: var(--cyan); border-color: rgba(0,229,255,0.3); }

.chart-container { width: 100%; height: 320px; position: relative; padding: 15px; }
.pie-container { height: 260px; display: flex; justify-content: center; align-items: center; }

/* Radar Heatmap */
.radar-feed { max-height: 320px; display: flex; flex-direction: column; gap: 8px; }
.radar-item {
  padding: 12px; background: var(--surface2); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); display: flex; justify-content: space-between; align-items: center;
}
.radar-name { font-size: 12px; color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.radar-edge { font-size: 14px; font-weight: 800; color: var(--emerald); font-family: 'JetBrains Mono', monospace; }

/* Positions List */
.style-list { max-height: 260px; display: flex; flex-direction: column; gap: 6px; }


/* ════════════════════════════════════════
   TAB: TÉCNICA
════════════════════════════════════════ */
.tech-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.tech-header h2 { font-size: 20px; font-weight: 800; }

.tech-grid {
  display: flex; gap: 24px;
  height: calc(100vh - 160px);
}
.tech-main { flex: 4; }
.tech-sidebar {
  flex: 2;
  display: flex; flex-direction: column; gap: 16px;
  min-width: 300px;
}

.terminal-body { background: #04040a; font-family: 'JetBrains Mono', monospace; padding: 16px; flex: 1; min-height: 0; overflow-y: auto; }
.glow-violet { border-bottom: 2px solid var(--violet); }
.glow-amber { border-bottom: 2px solid var(--amber); }
.glow-emerald { border-bottom: 2px solid var(--emerald); }
.glow-rose { border-bottom: 2px solid var(--rose); }

.live-indicator { font-size: 10px; font-weight: 800; color: var(--rose); padding: 4px 10px; background: var(--rose-dim); border-radius: 12px; animation: blink 2s infinite;}


/* IA Terminal Lines */
.dec-line {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 6px 10px; border-radius: 6px; font-size: 12px; line-height: 1.5;
  border-left: 2px solid transparent; margin-bottom: 4px;
  animation: slideIn 0.2s ease;
}
.dec-line:hover { background: rgba(255,255,255,0.03); }
.dec-line.type-scan       { border-left-color: #334155; }
.dec-line.type-opportunity{ border-left-color: var(--violet); background: rgba(168,85,247,0.05); }
.dec-line.type-trade      { border-left-color: var(--emerald); background: rgba(16,185,129,0.08); }
.dec-line.type-reject     { border-left-color: #1e293b; }
.dec-line.type-risk       { border-left-color: var(--amber); background: rgba(245,158,11,0.05); }
.dec-line.type-system     { border-left-color: var(--cyan); background: rgba(0,229,255,0.03); }

.dec-ts { font-size: 10px; color: #475569; white-space: nowrap; min-width: 65px; margin-top:2px; }
.dec-icon { font-size: 14px; }
.dec-msg { color: var(--text2); font-family: 'Inter', sans-serif; flex: 1; }
.dec-repeat-badge {
  flex-shrink: 0; margin-left: 6px; padding: 1px 6px;
  background: rgba(100,116,139,0.25); border: 1px solid rgba(100,116,139,0.3);
  border-radius: 10px; font-size: 10px; font-weight: 700; color: #64748b;
  align-self: center; white-space: nowrap;
}

/* Técnica: Sidebars Minis */
.risk-block { display: flex; flex-direction: column; gap: 12px; }
.risk-row { display: flex; align-items: center; gap: 10px; }
.risk-lbl { font-size: 11px; color: var(--text3); min-width: 65px; }
.risk-track { flex: 1; height: 6px; background: var(--surface3); border-radius: 4px; overflow: hidden; }
.risk-fill { height: 100%; transition: 0.4s; }
.fill-rose { background: linear-gradient(90deg, var(--rose), #ff6b85); }
.fill-cyan { background: linear-gradient(90deg, var(--cyan), #29b6f6); }
.risk-num { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text1); min-width: 45px; text-align: right; }
.circuit-flex { display: flex; justify-content: space-between; align-items: center; margin-top: 15px; font-size: 12px; color: var(--text3);}

/* Zen mode full width */
.tech-grid.zen-active .tech-sidebar, .tech-grid.zen-active .tech-header h2 { display: none; }
.tech-grid.zen-active .tech-main { flex: 1; height: 85vh; }
.tech-grid.zen-active .panel-header-premium { padding: 10px 20px;}


/* ════════════════════════════════════════
   TAB: SETTINGS
════════════════════════════════════════ */
.settings-layout { display: block; max-width: 900px; margin: 40px auto; padding-bottom: 80px; }
.settings-form { display: block; overflow: visible; background: var(--surface2); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: 30px; box-shadow: 0 10px 40px rgba(0,0,0,0.3); }

.form-body { display: block; }
.journal-wrapper { flex: 3; display: flex; flex-direction: column; overflow: hidden; }

.cfg-group { margin-bottom: 24px; }
.cfg-group h3 { font-size: 11px; font-weight: 800; color: var(--text3); text-transform: uppercase; margin-bottom: 12px; border-bottom: 1px solid var(--border-light); padding-bottom: 6px; }

.cfg-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cfg-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.cfg-grid-1 { display: flex; flex-direction: column; gap: 12px; }

.cfg-field { display: flex; flex-direction: column; gap: 6px; }
.cfg-field label { font-size: 11px; font-weight: 600; color: var(--text2); }
.cfg-field input {
  background: rgba(0,0,0,0.2); border: 1px solid var(--border-med);
  border-radius: var(--radius-sm); color: var(--text1);
  padding: 8px 12px; font-size: 13px; font-family: 'JetBrains Mono', monospace;
  transition: 0.2s;
}
.cfg-field input:focus { outline: none; border-color: var(--violet); background: rgba(168,85,247,0.05); }

/* Switch Modern */
.switch-modern { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch-modern input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background-color: var(--surface3); border-radius: 24px; transition: .3s; border: 1px solid var(--border-med); }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: var(--text2); transition: .3s; border-radius: 50%; }
.switch-modern input:checked + .slider { background-color: var(--violet); border-color: var(--violet-glow); }
.switch-modern input:checked + .slider:before { transform: translateX(20px); background-color: white;}

.cfg-actions { margin-top: 30px; pt-top: 20px; border-top: 1px solid var(--border-light); padding-top: 20px; }


/* Premium Table (Journal) */
.full-table-body { padding: 0; }
.premium-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.premium-table th { text-align: left; padding: 12px 16px; font-weight: 700; color: var(--text3); border-bottom: 1px solid var(--border-light); text-transform: uppercase; font-size: 10px; letter-spacing: 1px; }
.premium-table td { padding: 10px 16px; border-bottom: 1px solid rgba(255,255,255,0.03); color: var(--text2); font-family: 'JetBrains Mono', monospace;}
.premium-table tr:hover td { background: rgba(255,255,255,0.02); }

.jtabs { display: flex; gap: 4px; }
.jtab { background: none; border: none; color: var(--text3); padding: 4px 12px; font-size: 11px; font-weight: 700; cursor: pointer; border-radius: 12px; transition: 0.2s; }
.jtab.active { background: var(--violet-dim); color: var(--violet); }

/* Common Empty States */
.empty-state { padding: 20px; text-align: center; color: var(--text3); font-size: 12px; font-style: italic; }
.chip-count { font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 8px; font-family: 'JetBrains Mono'; }
.chip-count.cyan { background: var(--cyan-dim); color: var(--cyan); }
.chip-count.rose { background: var(--rose-dim); color: var(--rose); }

/* Components re-used */
.position-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: rgba(0,0,0,0.2); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
}
.position-question { font-size: 12px; color: var(--text1); font-weight: 500; max-width: 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.position-side { font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 4px;}
.side-yes { background: var(--emerald-dim); color: var(--emerald); }
.side-no  { background: var(--rose-dim); color: var(--rose); }
.position-stake, .position-edge { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.position-edge { font-weight: 800; color: var(--emerald); }

.cal-big-metric { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px 0; border-bottom: 1px solid var(--border-light);}
.cal-val { font-size: 32px; font-weight: 800; font-family: 'JetBrains Mono'; color: var(--text1); }
.cal-qual { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text3); }

/* Responsive adjustments */
@media (max-width: 1024px) {
  .dashboard-grid { gap: 16px; }
  .dashboard-columns { flex-direction: column; }
  .settings-layout { flex-direction: column; height: auto; display:block; }
  .settings-form { max-width: 100%; border-bottom: 1px solid var(--border-light); margin-bottom: 20px;}
}

/* Mobile Layout: Bottom Tab Nav */
@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  
  .sidebar { 
    width: 100%; 
    height: 70px;
    padding: 0;
    flex-direction: row; 
    border-right: none;
    border-top: 1px solid var(--border-light);
    order: 2; /* Move to bottom */
    position: fixed;
    bottom: 0;
    left: 0;
    z-index: 999;
    background: rgba(10,10,20, 0.95);
  }
  
  .main-content {
    height: calc(100vh - 70px);
    padding-bottom: 20px;
  }
  
  .sidebar-brand { display: none; }
  
  .sidebar-nav {
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    margin: 0;
    padding: 0 10px;
  }
  
  .nav-btn {
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    font-size: 10px;
    text-align: center;
    justify-content: center;
    flex: 1;
    border: none;
    border-left: none !important;
    border-bottom: 3px solid transparent;
  }
  
  .nav-btn.active {
    background: transparent;
    border-left: none !important;
    border-bottom: 3px solid var(--violet) !important;
    color: var(--text1);
  }
  
  .nav-icon { margin: 0; font-size: 1.2rem; }
  .nav-label { display: block; font-weight: normal; }
  
  .sidebar-footer { display: none; } /* Hide logout from bottom nav to save space */
  
  .topbar { padding: 0 16px; height: 60px; }
  .topbar-metrics { display: none; }
  .brand-text-mobile { display: block; margin-right: 10px; font-weight: 700; color: var(--cyan); }
}

/* ─── UTILITY ─────────────────────────────────────── */
.text-dim { color: var(--text-dim); }

/* ─── JOURNAL INFO MODAL ──────────────────────────── */
.info-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.info-modal-box {
  width: min(600px, 94vw);
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  animation: modalIn .2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.info-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
}

.info-modal-body {
  padding: 1.5rem;
}

.info-glossary {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0;
}

.info-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  align-items: start;
}

.info-row dt {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--accent-cyan);
  font-family: 'JetBrains Mono', monospace;
  padding-top: 2px;
}

.info-row dd {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.info-row dd em { color: var(--text-primary); font-style: normal; }
.info-row dd strong { color: var(--text-primary); }

/* ─── V2 UI IMPROVEMENTS ──────────────────────────── */

/* Sidebar Brand */
.brand-name {
  color: var(--text1);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 1px;
  margin-top: 12px;
}
.sidebar-brand {
  flex-direction: column;
  align-items: center;
}

/* Mode Badge in Header */
.mode-badge {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 6px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s;
  margin-left: 10px;
}
.mode-badge:hover { opacity: 0.8; }
.mode-sim { background: var(--cyan-dim); color: var(--cyan); border: 1px solid rgba(0,229,255,0.3); }
.mode-live { background: var(--rose-dim); color: var(--rose); border: 1px solid rgba(244,63,94,0.3); animation: pulse-live 2s infinite; }
@keyframes pulse-live { 0% { box-shadow: 0 0 0 0 rgba(244,63,94,0.4); } 70% { box-shadow: 0 0 0 8px rgba(244,63,94,0); } 100% { box-shadow: 0 0 0 0 rgba(244,63,94,0); } }

/* Subtitles & Hints */
.panel-sub-hint {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 400;
  font-family: 'Inter', sans-serif;
  margin-left: 12px;
}
.tech-subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-top: 4px;
}
.feed-hint {
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 10px 15px 0 15px;
  margin: 0;
  font-style: italic;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 10px;
}

/* Settings Form Improvements */
.cfg-group {
  margin-bottom: 30px;
  padding-bottom: 25px;
  border-bottom: 1px dashed var(--border-med);
}
.cfg-group:last-child { border-bottom: none; }
.cfg-group h3 {
  color: var(--text1);
  font-size: 1.1rem;
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 8px;
}
.cfg-group-desc {
  color: var(--text-dim);
  margin-bottom: 15px;
  font-size: 0.9rem;
  line-height: 1.5;
}
.live-warning-box {
  background: rgba(244,63,94,0.1);
  border: 1px solid rgba(244,63,94,0.3);
  padding: 12px 16px;
  border-radius: 8px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  color: var(--text1);
  margin-bottom: 20px;
}
.cfg-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 4px;
  font-weight: 400;
  line-height: 1.3;
}
.cfg-field-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}
.cfg-field-info {
  flex: 1;
}
.cfg-desc {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 4px;
  line-height: 1.4;
}

/* Market Maker settings section */
.cfg-group-beta {
  background: linear-gradient(135deg, rgba(0,229,255,0.05) 0%, transparent 100%);
  border: 1px solid rgba(0,229,255,0.1);
  border-radius: 12px;
  padding: 20px;
}
.badge-beta {
  background: var(--cyan);
  color: var(--void);
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  vertical-align: middle;
}
.mm-toggle-row {
  background: rgba(0,0,0,0.2);
  padding: 15px;
  border-radius: 8px;
  border: 1px inset var(--border-light);
}

.cfg-save-hint {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-left: 15px;
  font-style: italic;
}

/* Circuit Breaker Display */
.circuit-flex {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--border-light);
}
.circuit-label {
  font-weight: 600;
  color: var(--text1);
}
.circuit-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 4px;
  line-height: 1.4;
  max-width: 200px;
}
.circuit-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.calib-explain {
  font-size: 0.8rem;
  color: var(--text2);
  line-height: 1.4;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-light);
}

.kpi-card-sub {
  font-size: 0.75rem;
  color: var(--text3);
  margin-top: 8px;
  line-height: 1.3;
}
/* ════════════════════════════════════════
   TAB: HISTORY (Advanced View)
════════════════════════════════════════ */
#tab-history { padding: 20px 40px; }
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.history-subtitle { font-size: 13px; color: var(--text3); margin-top: 4px; }

/* Filter bar — flex-direction:row is explicit to override .glass-panel column direction */
.history-filter-bar {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  padding: 20px 24px;
  margin-bottom: 20px;
  border-radius: var(--radius-lg);
  background: var(--surface2);
  border: 1px solid var(--border-light);
}
.filter-group { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 130px; max-width: 220px; }
.filter-group label { font-size: 10px; font-weight: 800; color: var(--text3); text-transform: uppercase; letter-spacing: 0.8px; }
.filter-group select, .filter-group input {
  background: var(--surface3); border: 1px solid var(--border-light);
  color: var(--text1); padding: 9px 12px; border-radius: 8px; font-size: 13px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.filter-group select:focus, .filter-group input:focus { border-color: var(--violet); outline: none; box-shadow: 0 0 0 2px var(--violet-dim); }

.search-group { flex: 2; min-width: 220px; max-width: none; }
.search-input-wrapper { position: relative; }
.search-input-wrapper input { width: 100%; box-sizing: border-box; padding-right: 40px; }
.search-icon { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--text3); font-size: 14px; pointer-events: none; }

#apply-filters-btn { align-self: flex-end; white-space: nowrap; padding: 9px 20px; }

/* History Stats */
.history-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
@media (max-width: 900px) { .history-stats-grid { grid-template-columns: repeat(2, 1fr); } }
.h-stat-card {
  padding: 18px 20px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  display: flex; flex-direction: column; gap: 6px;
  transition: border-color 0.2s;
}
.h-stat-card:hover { border-color: rgba(139,92,246,0.3); }
.h-stat-lbl { font-size: 10px; color: var(--text3); text-transform: uppercase; font-weight: 800; letter-spacing: 0.5px; }
.h-stat-val { font-size: 22px; font-weight: 800; font-family: 'JetBrains Mono'; color: var(--text1); }

/* Table Wrapper */
.history-table-wrapper {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface2);
  border: 1px solid var(--border-light);
}
.history-table { width: 100%; border-collapse: collapse; font-size: 13px; text-align: left; }
.history-table thead { position: sticky; top: 0; z-index: 1; }
.history-table th {
  padding: 14px 16px;
  background: rgba(255,255,255,0.04);
  color: var(--text3);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 800;
  border-bottom: 1px solid var(--border-light);
}
.history-table td { padding: 13px 16px; border-bottom: 1px solid rgba(255,255,255,0.04); vertical-align: middle; }
.history-table tr:last-child td { border-bottom: none; }
.history-table tbody tr:hover td { background: rgba(139,92,246,0.04); }
.history-table .empty-state { text-align: center; color: var(--text3); font-size: 13px; padding: 40px; }

/* IA & Monitor Clean Refactor */
.active-pos-wrapper { flex: 1.5; display: flex; flex-direction: column; overflow: hidden; min-width: 320px; }
.mini-journal { padding: 15px; }
.mini-pos-grid { display: flex; flex-direction: column; gap: 12px; }
.mini-pos-card { 
  background: rgba(255,255,255,0.03); border: 1px solid var(--border-light); 
  border-radius: var(--radius-sm); padding: 12px; transition: 0.2s; 
}
.mini-pos-card:hover { border-color: var(--cyan); background: rgba(0, 230, 246, 0.05); }
.mini-pos-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.mini-pos-q { font-size: 11px; font-weight: 600; color: var(--text1); line-height: 1.3; max-width: 80%; }
.m-pnl { font-family: 'JetBrains Mono'; font-weight: 800; }
.m-pnl.pos { color: var(--emerald); }
.m-pnl.neg { color: var(--rose); }

.panel-footer-links { padding: 12px; border-top: 1px solid var(--border-light); text-align: center; }
.link-btn { background: none; border: none; color: var(--cyan); cursor: pointer; font-size: 11px; font-weight: 700; }
.link-btn:hover { text-decoration: underline; }

.status-won { color: var(--emerald); font-weight: 800; }
.status-lost { color: var(--rose); font-weight: 800; }
.status-open { color: var(--cyan); font-weight: 800; }

.btn-primary-gradient {
  background: linear-gradient(135deg, var(--violet), var(--violet-glow));
  color: white; border: none; padding: 10px 24px; border-radius: 8px;
  font-weight: 700; cursor: pointer; transition: 0.3s;
}
.btn-primary-gradient:hover { transform: translateY(-2px); box-shadow: 0 4px 15px var(--violet-dim); }

/* Connection Test Group */
.test-status-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 20px;
}
.test-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
}
.test-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-med);
}
.test-icon { font-size: 1.2rem; }
.test-label { font-size: 0.85rem; font-weight: 600; color: var(--text2); flex: 1; }
.test-indicator { font-size: 0.75rem; font-weight: 700; padding: 4px 10px; border-radius: 12px; min-width: 90px; text-align: center; }

.indicator-pending { background: var(--surface3); color: var(--text3); }
.indicator-loading { background: var(--amber-dim); color: var(--amber); animation: blink 1s infinite; }
.indicator-success { background: var(--emerald-dim); color: var(--emerald); border: 1px solid rgba(16, 185, 129, 0.3); }
.indicator-failed { background: var(--rose-dim); color: var(--rose); border: 1px solid rgba(244, 63, 94, 0.3); }

.test-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}
#test-summary-msg {
  font-family: 'Inter', sans-serif;
  font-weight: 500;
}
.msg-success { color: var(--emerald); }
.msg-failed { color: var(--rose); }
.msg-partial { color: var(--amber); }

/* Utility classes */
.text-emerald { color: var(--emerald); }
.text-rose { color: var(--rose); }
.text-cyan { color: var(--cyan); }
