/* ---------- HUD :: Antigravity OLED ---------- */

:root {
  --bg: #0d121b;
  --bg-deep: #070a10;
  --surface: #151b24;
  --surface-2: #1b2230;
  --surface-3: #232c3d;
  --line: #1f2937;
  --line-soft: #1a2230;
  --text: #e6edf3;
  --text-dim: #8a98ad;
  --text-mute: #5a6679;

  --mint: #4ade80;
  --mint-soft: rgba(74, 222, 128, 0.12);
  --mint-glow: rgba(74, 222, 128, 0.35);
  --blue: #60a5fa;
  --blue-soft: rgba(96, 165, 250, 0.12);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.12);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.12);
  --violet: #a78bfa;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  --shadow-deep: 0 24px 48px -16px rgba(0, 0, 0, 0.55), 0 2px 0 rgba(255, 255, 255, 0.02) inset;
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.025) inset, 0 12px 28px -16px rgba(0, 0, 0, 0.8);

  --f-display: 'Orbitron', 'Inter', sans-serif;
  --f-mono: 'Fira Code', 'JetBrains Mono', monospace;
  --f-body: 'Exo 2', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--f-body);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(96, 165, 250, 0.05), transparent 60%),
    radial-gradient(900px 500px at -10% 100%, rgba(74, 222, 128, 0.045), transparent 60%),
    var(--bg);
}

button { font-family: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font-family: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #232c3d; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #2c374b; }

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #0b1018 0%, #0d121b 100%);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 22px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(74, 222, 128, 0.18), rgba(96, 165, 250, 0.08)),
    var(--surface-2);
  border: 1px solid rgba(74, 222, 128, 0.35);
  display: grid;
  place-items: center;
  position: relative;
  box-shadow: 0 0 18px -4px var(--mint-glow);
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 4px;
  border: 1px solid rgba(74, 222, 128, 0.6);
  border-right: 0;
  border-bottom: 0;
}
.brand-mark span {
  font-family: var(--f-display);
  font-size: 11px;
  font-weight: 700;
  color: var(--mint);
  letter-spacing: 0.1em;
  text-shadow: 0 0 8px var(--mint-glow);
}

.brand-name {
  font-family: var(--f-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--text);
}
.brand-tag {
  display: block;
  font-family: var(--f-mono);
  font-size: 9px;
  color: var(--text-mute);
  letter-spacing: 0.2em;
  margin-top: 2px;
  text-transform: uppercase;
}

.nav {
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}
.nav-group {
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
  position: relative;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(74, 222, 128, 0.10), rgba(74, 222, 128, 0) 80%);
  color: var(--text);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--mint);
  box-shadow: 0 0 8px var(--mint-glow);
  border-radius: 2px;
}
.nav-item .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
}
.nav-item .badge {
  margin-left: auto;
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--mint);
  background: var(--mint-soft);
  padding: 1px 6px;
  border-radius: 999px;
  letter-spacing: 0.05em;
}
.nav-item.active .icon { color: var(--mint); opacity: 1; }

.sidebar-foot {
  border-top: 1px solid var(--line-soft);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.exch-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--f-mono);
  font-size: 11px;
}
.exch-status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 8px var(--mint-glow);
  animation: pulse 1.6s infinite;
}
.exch-status .dot.warn { background: var(--amber); box-shadow: 0 0 8px rgba(251,191,36,0.5); }
.exch-status .label { color: var(--text-dim); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--line);
}
.user-chip .avatar {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--blue), var(--mint));
  display: grid; place-items: center;
  font-family: var(--f-display);
  font-size: 11px;
  font-weight: 700;
  color: #0b1018;
}
.user-chip .meta { font-size: 12px; line-height: 1.2; }
.user-chip .meta b { color: var(--text); font-weight: 600; display: block; }
.user-chip .meta span { color: var(--text-mute); font-family: var(--f-mono); font-size: 10px; }

/* ---------- Main ---------- */
.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 18, 27, 0.85);
  backdrop-filter: blur(10px);
}
.crumb {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.crumb b { color: var(--text-dim); }
.screen-title {
  font-family: var(--f-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.topbar-spacer { flex: 1; }

/* Heartbeat do scanner no topbar (substitui a busca + Novo Bot) */
.scan-status { display: flex; align-items: center; gap: 9px; padding: 6px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.scan-status .scan-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 8px var(--mint); flex: none; animation: hudpulse 1.8s infinite; }
.scan-status.stale .scan-dot { background: var(--amber); box-shadow: 0 0 8px var(--amber); animation: none; }
.scan-status-txt { display: flex; flex-direction: column; line-height: 1.25; }
#scan-next { font-family: var(--f-mono); font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; }
#scan-last { font-family: var(--f-mono); font-size: 9.5px; color: var(--text-mute); letter-spacing: .03em; white-space: nowrap; }
@media (max-width: 640px) { #scan-last { display: none; } .scan-status { padding: 6px 10px; } }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  width: clamp(180px, 20vw, 300px);
  color: var(--text-dim);
  font-family: var(--f-mono);
  font-size: 12px;
}
.search input {
  background: transparent;
  border: 0;
  outline: 0;
  flex: 1;
  color: var(--text);
}
.search .kbd {
  font-family: var(--f-mono);
  font-size: 10px;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-mute);
}

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  transition: background 120ms ease, transform 80ms ease, box-shadow 120ms;
  border: 1px solid transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--mint);
  color: #07120c;
  box-shadow: 0 0 18px -4px var(--mint-glow);
}
.btn-primary:hover { box-shadow: 0 0 26px -2px var(--mint-glow); }
.btn-ghost {
  background: var(--surface);
  color: var(--text-dim);
  border-color: var(--line);
}
.btn-ghost:hover { color: var(--text); border-color: var(--surface-3); }
.btn-danger { color: var(--red); background: var(--red-soft); border-color: rgba(248,113,113,0.3); }
.btn-icon { padding: 8px; min-width: 34px; justify-content: center; }

/* ---------- Screen container ---------- */
.screen { display: none; padding: 24px 28px 60px; }
.screen.active { display: block; }

/* ---------- Summary cards ---------- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(74,222,128,0.0), transparent);
}
.kpi.mint::before { background: linear-gradient(90deg, transparent, var(--mint-glow) 50%, transparent); }
.kpi.blue::before { background: linear-gradient(90deg, transparent, rgba(96,165,250,0.45) 50%, transparent); }
.kpi.amber::before { background: linear-gradient(90deg, transparent, rgba(251,191,36,0.4) 50%, transparent); }

.kpi-head {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 14px;
}
.kpi-head .icon-box {
  width: 22px; height: 22px;
  border-radius: 5px;
  background: var(--surface-2);
  display: grid; place-items: center;
  color: var(--text-dim);
}
.kpi.mint .icon-box { color: var(--mint); background: var(--mint-soft); }
.kpi.blue .icon-box { color: var(--blue); background: var(--blue-soft); }
.kpi.amber .icon-box { color: var(--amber); background: var(--amber-soft); }

.kpi-val {
  font-family: var(--f-mono);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.01em;
  display: flex; align-items: baseline; gap: 6px;
}
.kpi-val .unit {
  font-size: 13px;
  color: var(--text-mute);
}
.kpi.mint .kpi-val { color: var(--mint); text-shadow: 0 0 14px rgba(74,222,128,0.25); }
.kpi.red .kpi-val { color: var(--red); }

.kpi-meta {
  display: flex; align-items: center; gap: 10px;
  margin-top: 10px;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--text-mute);
}
.kpi-delta {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}
.kpi-delta.pos { color: var(--mint); background: var(--mint-soft); }
.kpi-delta.neg { color: var(--red); background: var(--red-soft); }

.kpi-spark { margin-top: 14px; height: 36px; }

/* KPI minimize/maximize — barra acima do grid */
.kpi-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}
.kpi.minimized .kpi-head { margin-bottom: 0; }
.kpi.minimized .kpi-val,
.kpi.minimized .kpi-meta,
.kpi.minimized .kpi-st-chips,
.kpi.minimized .kpi-spark { display: none; }
.kpi.minimized { padding-bottom: 16px; }

/* Chips de filtro por status no KPI "Sinais Armados" */
.kpi-st-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 8px 0 2px; }
.kpi-st-chip {
  display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--line); background: transparent; color: var(--text-mute);
  font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.08em;
  padding: 3px 8px; border-radius: 999px; cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.kpi-st-chip span { color: var(--text-dim); font-weight: 700; }
.kpi-st-chip:hover { border-color: var(--text-dim); color: var(--text); }
.kpi-st-chip.on.st-all { border-color: var(--text-dim); color: var(--text); background: rgba(255, 255, 255, 0.05); }
.kpi-st-chip.on.st-armed { border-color: var(--mint); color: var(--mint); background: var(--mint-soft); }
.kpi-st-chip.on.st-armed span { color: var(--mint); }
.kpi-st-chip.on.st-cool { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.kpi-st-chip.on.st-cool span { color: var(--blue); }
.kpi-st-chip.on.st-warn { border-color: var(--amber); color: var(--amber); background: rgba(251, 191, 36, 0.12); }
.kpi-st-chip.on.st-warn span { color: var(--amber); }
.kpi-st-chip.on.st-idle { border-color: var(--text-dim); color: var(--text); background: rgba(255, 255, 255, 0.05); }
.kpi-st-chip.on.st-idle span { color: var(--text); }

/* ---------- Section header ---------- */
.section-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 22px 0 12px;
}
.section-head h2 {
  font-family: var(--f-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0;
  color: var(--text);
}
.section-head .sub {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--text-mute);
}
.section-head .spacer { flex: 1; }
.section-head .ctl-row { display: flex; gap: 6px; align-items: center; }

.seg {
  display: inline-flex;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.seg button {
  padding: 5px 12px;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.08em;
  border-radius: 5px;
  text-transform: uppercase;
}
.seg button.on {
  background: var(--surface-3);
  color: var(--text);
}

/* ---------- Spreads table ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-head h3 {
  font-family: var(--f-display);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin: 0;
  font-weight: 600;
}
.panel-head .spacer { flex: 1; }
.panel-head .legend {
  display: flex; gap: 14px;
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.panel-head .legend i {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: middle;
}

/* Seletor de quantidade de ativos no SCAN */
.scan-limit {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-right: 14px;
}
.scan-limit select {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--f-mono);
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.scan-limit select:hover { border-color: var(--mint); }
.scan-limit select:focus { border-color: var(--mint); }

/* Controles da aba Diagnóstico (Piso / Janela): mesmo visual escuro dos demais campos */
#diag-floor, #diag-days {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--f-mono);
  font-size: 12px;
  padding: 6px 10px;
  outline: none;
  transition: border-color 0.15s;
}
#diag-floor:hover, #diag-days:hover,
#diag-floor:focus, #diag-days:focus { border-color: var(--mint); }
/* Seletor de janela: chevron próprio (remove a seta nativa do SO) */
#diag-days {
  cursor: pointer;
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa4b2' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}
/* Campo do piso: remove as setinhas nativas (visual limpo; teclas para cima/baixo seguem funcionando) */
#diag-floor::-webkit-outer-spin-button,
#diag-floor::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#diag-floor { -moz-appearance: textfield; appearance: textfield; }

.tbl {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.tbl thead th {
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-mute);
  text-align: right;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.015);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl thead th:first-child { text-align: left; }
.tbl thead th .sort-arr { opacity: 0.4; margin-left: 4px; }

.tbl tbody td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--line-soft);
  text-align: right;
  font-family: var(--f-mono);
  vertical-align: middle;
}
.tbl tbody td:first-child { text-align: left; }
.tbl tbody tr:hover { background: rgba(255, 255, 255, 0.015); }
.tbl tbody tr.armed {
  background: linear-gradient(90deg, rgba(74,222,128,0.06), rgba(74,222,128,0.0) 40%);
  box-shadow: inset 2px 0 0 var(--mint), inset 0 0 24px -8px var(--mint-glow);
}
.tbl tbody tr.armed:hover { background: linear-gradient(90deg, rgba(74,222,128,0.10), rgba(74,222,128,0.02) 50%); }

.asset {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--f-body);
}
.asset .ticker {
  font-family: var(--f-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
}
.asset .sub {
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.asset-icon {
  width: 30px; height: 30px;
  border-radius: 7px;
  background: var(--surface-2);
  display: grid; place-items: center;
  font-family: var(--f-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: 1px solid var(--line);
}

.exch-pair {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--text-dim);
}
.exch-pair span { padding: 2px 7px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line); }
.exch-pair .arr { color: var(--text-mute); }

.num { font-variant-numeric: tabular-nums; color: var(--text); }
.num-dim { color: var(--text-dim); }
.num-pos { color: var(--mint); }
.num-pos.glow { text-shadow: 0 0 10px var(--mint-glow); }
.num-neg { color: var(--red); }
.num-amber { color: var(--amber); }

.spread-cell {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}
.spread-cell .pct { font-size: 14px; font-weight: 500; }
.spread-cell .tgt {
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.08em;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.status-chip .ico {
  width: 6px; height: 6px;
  border-radius: 50%;
}
.status-chip.armed {
  background: var(--mint-soft);
  border-color: rgba(74,222,128,0.35);
  color: var(--mint);
}
.status-chip.armed .ico { background: var(--mint); box-shadow: 0 0 8px var(--mint-glow); animation: pulse 1.2s infinite; }
.status-chip.idle {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text-dim);
}
.status-chip.idle .ico { background: var(--text-mute); }
.status-chip.cool {
  background: var(--blue-soft);
  border-color: rgba(96,165,250,0.25);
  color: var(--blue);
}
.status-chip.cool .ico { background: var(--blue); }
.status-chip.warn {
  background: var(--amber-soft);
  border-color: rgba(251,191,36,0.3);
  color: var(--amber);
}
.status-chip.warn .ico { background: var(--amber); }
.status-chip.err {
  background: var(--red-soft);
  border-color: rgba(248,113,113,0.3);
  color: var(--red);
}
.status-chip.err .ico { background: var(--red); }
/* Operação em aberto (aba Bots): azul com ponto pulsante */
.status-chip.live {
  background: var(--blue-soft);
  border-color: rgba(96,165,250,0.35);
  color: var(--blue);
}
.status-chip.live .ico { background: var(--blue); box-shadow: 0 0 8px rgba(96,165,250,0.5); animation: pulse 1.2s infinite; }
.bot-card.has-pos { border-color: rgba(96,165,250,0.35); }
/* Bot desligado AUTOMATICAMENTE (3 reversões seguidas): destaque âmbar + ⚠️ no cabeçalho. */
.bot-card.auto-off { border-color: rgba(245,158,11,0.45); }
/* Entrada pausada pela proteção (bot ATIVO + auto-off): a borda âmbar de atenção vence a
   verde de "on" (2 classes têm mais especificidade que .bot-card.on sozinha). */
.bot-card.on.auto-off { border-color: rgba(245,158,11,0.55); }
.bot-warn { cursor: help; font-size: 15px; line-height: 1; filter: drop-shadow(0 0 5px rgba(245,158,11,0.55)); }
.bot-warn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 4px; }

/* ---------- Two col ---------- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 14px;
  margin-top: 18px;
}

.panel.compact .panel-head { padding: 12px 16px; }
.panel-body { padding: 16px 18px; }

.feed {
  display: flex; flex-direction: column; gap: 0;
  max-height: 420px;
  overflow-y: auto;
}
.feed-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  align-items: center;
  font-size: 12px;
}
.feed-row:last-child { border-bottom: 0; }
.feed-time {
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.06em;
}
.feed-body { line-height: 1.4; }
.feed-body b { font-family: var(--f-display); font-weight: 600; font-size: 11px; letter-spacing: 0.1em; }
.feed-body .meta { color: var(--text-mute); font-family: var(--f-mono); font-size: 10px; display: block; margin-top: 2px; }
.feed-tag {
  font-family: var(--f-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}
.feed-tag.entry { color: var(--mint); background: var(--mint-soft); }
.feed-tag.exit { color: var(--blue); background: var(--blue-soft); }
.feed-tag.fail { color: var(--red); background: var(--red-soft); }
.feed-tag.unwound { color: var(--amber); background: var(--amber-soft); }

/* ---------- Bots screen ---------- */
/* Abas de filtro por rota/direção (espelha .kpi-st-chip) */
.bots-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.bots-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
  font-size: 12px; font-weight: 600; line-height: 1;
  border: 1px solid var(--line); background: transparent; color: var(--text-mute);
  transition: border-color .15s, color .15s, background .15s;
}
.bots-tab span { color: var(--text-dim); font-family: var(--f-mono); font-weight: 700; }
.bots-tab:hover { border-color: var(--text-dim); color: var(--text); }
.bots-tab.on { border-color: var(--mint); color: var(--mint); background: var(--mint-soft); }
.bots-tab.on span { color: var(--mint); }
.bot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.bot-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  box-shadow: var(--shadow-card);
  position: relative;
}
.bot-card.on { border-color: rgba(74,222,128,0.35); }
.bot-card.on::before {
  content: '';
  position: absolute;
  top: -1px; left: -1px; right: -1px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--mint), transparent);
  filter: blur(0.5px);
  border-radius: 10px 10px 0 0;
}

.bot-head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.bot-head .name {
  font-family: var(--f-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.12em;
}
.bot-head .sub {
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--text-mute);
  display: block;
  letter-spacing: 0.08em;
}
.bot-head .spacer { flex: 1; }

.toggle {
  position: relative;
  width: 38px; height: 22px;
  background: var(--surface-3);
  border-radius: 999px;
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background 160ms;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 160ms, background 160ms;
}
.toggle.on { background: var(--mint-soft); border-color: rgba(74,222,128,0.4); }
.toggle.on::after { background: var(--mint); transform: translateX(16px); box-shadow: 0 0 8px var(--mint-glow); }

.bot-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.bot-metric {
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 8px 10px;
}
.bot-metric .l {
  font-family: var(--f-mono);
  font-size: 9px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.bot-metric .v {
  font-family: var(--f-mono);
  font-size: 14px;
  margin-top: 3px;
}

/* Liga/desliga das pernas (entrada/saída) direto no card — sem abrir o terminal. */
.bot-legs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.leg-ctl {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 8px 12px;
}
.leg-l {
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Diálogo de confirmação in-page (sem a origem do site que o confirm() nativo carimba). */
.confirm-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0, 0, 0, 0.62);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.confirm-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  max-width: 460px; width: 100%;
  padding: 22px 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}
.confirm-title { margin: 0 0 12px; font-size: 16px; color: var(--amber); }
.confirm-msg {
  font-size: 13px; color: var(--text-dim); line-height: 1.55;
  white-space: pre-line;   /* respeita as quebras de linha da mensagem */
}
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Sugestão sem bot que divide corretora com um bot existente: sinal âmbar de risco. */
.suggest-card--warn { border-color: var(--amber); box-shadow: inset 0 0 0 1px var(--amber-soft); }
.suggest-warn-chip {
  display: inline-flex; align-items: center; margin-left: auto;
  color: var(--amber); background: var(--amber-soft);
  border: 1px solid var(--amber); border-radius: 999px; padding: 3px 7px;
}
.suggest-warn-chip svg { width: 13px; height: 13px; }
/* Aviso âmbar no rodapé do card (onde antes ficava o botão "Criar bot"): só aparece quando
   criar bot nesta rota divide corretora com um bot existente (risco de short órfão). */
.suggest-warn-foot {
  margin-top: 10px;
  display: flex; align-items: center; gap: 7px;
  padding: 7px 10px; border-radius: var(--r-sm);
  color: var(--amber); background: var(--amber-soft);
  border: 1px solid var(--amber);
  font-family: var(--f-mono); font-size: 10px; line-height: 1.3;
}
.suggest-warn-foot svg { width: 14px; height: 14px; flex-shrink: 0; }

.bot-foot {
  display: flex; align-items: center; gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}
.bot-foot .meta {
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.08em;
}

/* ---------- Positions ---------- */
.pos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}
.pos-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}
/* Card de posição (design DC: header + hero P&L/spread ao vivo + barra + métricas + ações) */
.pos-card { padding: 13px; display: flex; flex-direction: column; gap: 10px; transition: border-color .15s ease; }
.pos-card:hover { border-color: var(--line-strong, #2c313b); }

.pos-cardhead { display: flex; align-items: flex-start; gap: 11px; }
.pos-ticker {
  width: 26px; height: 26px; flex: none; border-radius: 8px;
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--f-mono); font-size: 9.5px; font-weight: 700; color: var(--text-dim); letter-spacing: .02em;
}
.pos-ticker.sm { width: 26px; height: 26px; font-size: 8.5px; }
.pos-id { min-width: 0; }
.pos-id .name { font-family: var(--f-display); font-size: 14px; font-weight: 800; letter-spacing: .02em; line-height: 1; display: flex; align-items: baseline; }
.pos-id .name.sm { font-size: 13px; font-weight: 700; }
.pos-id .name .slash { color: var(--text-mute); font-weight: 600; }
.pos-id .pos-sub { font-family: var(--f-mono); font-size: 9.5px; color: var(--text-mute); letter-spacing: .04em; white-space: nowrap; }
.pos-cardhead .pos-badge { margin-left: auto; }

/* badge de 3 estados: NO ALVO (ok) · ENCALHADA/INCOMPLETA (warn) · ABERTA (neutral) */
.pos-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 6px; font-family: var(--f-mono); font-size: 9.5px; font-weight: 700; letter-spacing: .08em; white-space: nowrap; border: 1px solid transparent; }
.pos-badge .bdot { width: 5px; height: 5px; border-radius: 50%; flex: none; background: currentColor; }
.pos-badge.ok { color: var(--mint); background: color-mix(in srgb, var(--mint) 13%, transparent); border-color: color-mix(in srgb, var(--mint) 30%, transparent); }
.pos-badge.warn { color: var(--amber); background: color-mix(in srgb, var(--amber) 13%, transparent); border-color: color-mix(in srgb, var(--amber) 30%, transparent); }
.pos-badge.neutral { color: var(--text-dim); background: color-mix(in srgb, var(--text-dim) 14%, transparent); border-color: color-mix(in srgb, var(--text-dim) 28%, transparent); }

/* hero: P&L à esquerda, spread ao vivo à direita */
.pos-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line-soft); padding-top: 11px; }
.pos-hero-label { font-family: var(--f-mono); font-size: 8.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-mute); margin-bottom: 6px; }
.pos-hero-row { display: flex; align-items: baseline; gap: 7px; flex-wrap: wrap; }
.pos-hero-val { font-family: var(--f-mono); font-size: 23px; font-weight: 800; line-height: .9; }
.pos-hero-val.pos { color: var(--mint); text-shadow: 0 0 16px var(--mint-glow); }
.pos-hero-val.neg { color: var(--red); }
.pos-hero-u { font-family: var(--f-mono); font-size: 11px; color: var(--text-mute); }
.pos-pill { font-family: var(--f-mono); font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 5px; white-space: nowrap; }
.pos-pill.pos { color: var(--mint); background: var(--mint-soft); }
.pos-pill.neg { color: var(--red); background: var(--red-soft); }
.pos-live { text-align: right; }
.pos-live-label { font-family: var(--f-mono); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-mute); margin-bottom: 7px; display: flex; align-items: center; gap: 5px; justify-content: flex-end; }
.pos-live-label .livedot, .pos-live-val .livedot { width: 5px; height: 5px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 6px var(--blue); animation: hudpulse 1.8s infinite; flex: 0 0 auto; }
.pos-live-val { font-family: var(--f-mono); font-size: 15px; font-weight: 700; }
/* Spread ao vivo LÍQUIDO (após taxas) — sub-linha muted abaixo do bruto. */
.pos-live-net { font-family: var(--f-mono); font-size: 9.5px; color: var(--text-mute); margin-top: 4px; cursor: help; }
.pos-row-net { font-family: var(--f-mono); font-size: 9px; font-weight: 400; color: var(--text-mute); margin-top: 3px; cursor: help; }
@keyframes hudpulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

/* barra spread vs. alvo — marcadores inline (posBar): preenchimento atual↔alvo, tique do alvo, bolinha com brilho */
.pos-bar-head { display: flex; justify-content: space-between; font-family: var(--f-mono); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-mute); margin-bottom: 8px; }
.pos-bar-wrap { position: relative; }
.pos-bar-track { position: relative; height: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; }
.pos-bar-legend { display: flex; justify-content: space-between; font-family: var(--f-mono); font-size: 10px; margin-top: 8px; }
.pos-bar-legend .hint { color: var(--text-dim); }

/* métricas 3-col: entrada · quantidade · valor */
.pos-metrics { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; border-top: 1px solid var(--line-soft); padding-top: 13px; }
.pos-metrics .k { font-family: var(--f-mono); font-size: 8.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-mute); margin-bottom: 5px; }
.pos-metrics .v { font-family: var(--f-mono); font-size: 12.5px; font-weight: 600; color: var(--text); }

.pos-flag { font-family: var(--f-mono); font-size: 10px; color: var(--amber); display: flex; align-items: center; gap: 6px; }

.pos-foot { display: flex; align-items: center; gap: 8px; }
.pos-foot .pos-exit { flex: 1; justify-content: center; }
.pos-foot .pos-exit b { margin-left: 4px; opacity: .85; font-weight: 700; }

/* alternância de exibição Cards/Tabela */
.pos-viewtoggle { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; }
.pos-viewbtn { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 0; border-radius: 7px; background: transparent; color: var(--text-mute); font-family: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer; transition: background .15s ease, color .15s ease; }
.pos-viewbtn:hover { color: var(--text-dim); }
.pos-viewbtn.on { background: var(--surface-2, rgba(255,255,255,.05)); color: var(--text); }

/* view de tabela */
.pos-tablewrap { overflow-x: auto; }
.pos-table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; min-width: 880px; }
.pos-thead, .pos-trow { display: grid; grid-template-columns: 1.6fr 92px 104px 110px 64px 1.15fr 92px 122px; gap: 10px; align-items: center; }
.pos-thead { padding: 12px 18px; border-bottom: 1px solid var(--line); font-family: var(--f-mono); font-size: 9px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-mute); }
.pos-trow { padding: 12px 18px; border-bottom: 1px solid var(--line-soft); }
.pos-trow:last-child { border-bottom: 0; }
.pos-trow:hover { background: rgba(255,255,255,.015); }
.pos-thead .r, .pos-tc.r { text-align: right; justify-self: end; }
.pos-tpair { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pos-tpnl { font-family: var(--f-mono); font-size: 15px; font-weight: 800; }
.pos-tpnl.pos { color: var(--mint); }
.pos-tpnl.neg { color: var(--red); }
.pos-row-cur { font-family: var(--f-mono); font-size: 9.5px; margin-top: 5px; color: var(--text-dim); }
.pos-tc.r { font-family: var(--f-mono); font-size: 12.5px; color: var(--text-dim); }
.pos-tactions { display: flex; gap: 6px; justify-content: flex-end; }
.btn.btn-sm { height: 32px; padding: 0 12px; font-size: 11.5px; }
.hint { color: var(--text-dim); }

/* ---------- History ---------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.input {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 7px 12px;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--text-dim);
}
.input input, .input select {
  background: transparent;
  border: 0; outline: 0;
  color: var(--text);
  font-family: var(--f-mono);
  font-size: 11px;
}

.tbl-log td { font-size: 12px; padding: 11px 18px; }
.tbl-log .id { color: var(--text-mute); font-size: 11px; }

/* ---------- Modal ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(7, 10, 16, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 40px;
}
.modal-mask.open { display: flex; }
.modal {
  width: 560px;
  max-width: 100%;
  max-height: 90vh;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-deep);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
.modal.wide { width: 720px; }

/* Abas internas do modal de ativo */
.asset-tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 2;
  background: var(--surface);
}
.asset-tab {
  padding: 11px 14px;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-mute);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.asset-tab:hover { color: var(--text-dim); }
.asset-tab.on { color: var(--mint); border-bottom-color: var(--mint); }
.modal-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 {
  font-family: var(--f-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0;
  flex: 1;
}
.modal-head .x {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 6px;
  color: var(--text-mute);
}
.modal-head .x:hover { background: var(--surface-2); color: var(--text); }
.modal-body { padding: 20px 22px; }
.modal-foot {
  display: flex; align-items: center; gap: 10px; justify-content: flex-end;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
}

.field {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 14px;
}
.field label {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-mute);
}
.field .control {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  display: flex; align-items: center; gap: 8px;
}
.field input, .field select {
  background: transparent;
  border: 0; outline: 0;
  flex: 1;
  font-family: var(--f-mono);
  font-size: 13px;
  color: var(--text);
}
.field .control .suffix {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--text-mute);
}

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* Notificações (aba Configurações): cada canal num cartão com switch à direita. */
.notif-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 760px) { .notif-grid { grid-template-columns: 1fr; } }
.notif-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
  transition: border-color var(--dur-fast, 150ms) ease;
}
.notif-opt:hover { border-color: rgba(74,222,128,0.35); }
.notif-opt .notif-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.notif-opt .notif-txt b { font-size: 13px; color: var(--text); }
.notif-opt .notif-txt small { font-size: 11px; color: var(--text-mute); line-height: 1.35; }
.notif-opt .toggle { flex: 0 0 auto; }

/* Aba Configurações: painéis empilhados + textos de ajuda em linguagem simples. */
.settings-stack { display: grid; grid-template-columns: 1fr; gap: 14px; }

/* Configurações em abas (Tela · Scanner · Slippage · Avisos · Conta) */
.set-wrap { max-width: 760px; }
.set-header { margin: 22px 0 18px; }
.set-eyebrow { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--mint); margin-bottom: 10px; }
.set-title { font-family: var(--f-display); font-size: 28px; font-weight: 700; letter-spacing: 0.01em; margin: 0 0 8px; }
.set-sub { color: var(--text-dim); font-size: 13px; margin: 0; }
.set-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.set-tab {
  background: none; border: 0; color: var(--text-mute);
  font-family: inherit; font-size: 13px; font-weight: 500;
  padding: 11px 16px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  transition: color var(--dur-fast,150ms) ease, border-color var(--dur-fast,150ms) ease;
}
.set-tab:hover { color: var(--text-dim); }
.set-tab.on { color: var(--text); border-bottom-color: var(--mint); }
.set-tab:focus-visible { outline: 2px solid var(--mint); outline-offset: -4px; border-radius: 4px; }
.set-pane { display: none; }
.set-pane.on { display: grid; grid-template-columns: 1fr; gap: 14px; }
.settings-help {
  margin: 12px 0 0; font-size: 12px; line-height: 1.55; color: var(--text-dim);
}
.settings-help b { color: var(--text); font-weight: 600; }
.settings-ok {
  margin-top: 10px; font-family: var(--f-mono); font-size: 11px; color: var(--mint);
}
.settings-divider { height: 1px; background: var(--line); margin: 16px 0; }
.settings-foot {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 2px 2px 0; font-size: 11.5px; line-height: 1.5; color: var(--text-mute);
}
.settings-foot svg { flex: 0 0 auto; margin-top: 1px; opacity: 0.7; }
.settings-foot b { color: var(--text-dim); }

/* Segmented control: escolha entre poucas opções, mais intuitivo que digitar número. */
.segmented {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 5px;
}
@media (max-width: 560px) { .segmented { grid-template-columns: repeat(2, 1fr); } }
.seg-opt {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 8px; border: 1px solid transparent; border-radius: calc(var(--r-sm) - 4px);
  background: transparent; color: var(--text-dim); cursor: pointer;
  font-family: inherit; transition: background var(--dur-fast, 150ms) ease, color var(--dur-fast, 150ms) ease, border-color var(--dur-fast, 150ms) ease;
}
.seg-opt b { font-size: 12.5px; font-weight: 600; letter-spacing: 0.01em; }
.seg-opt small { font-family: var(--f-mono); font-size: 10px; color: var(--text-mute); }
.seg-opt:hover { color: var(--text); background: var(--surface-2, rgba(255,255,255,0.03)); }
.seg-opt.on {
  background: var(--mint-soft, rgba(74,222,128,0.12));
  border-color: rgba(74,222,128,0.4);
  color: var(--mint);
}
.seg-opt.on small { color: var(--mint); opacity: 0.8; }
.seg-opt:focus-visible { outline: 2px solid var(--mint); outline-offset: 1px; }

.callout {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px;
  background: var(--blue-soft);
  border: 1px solid rgba(96,165,250,0.2);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}
.callout.warn { background: var(--amber-soft); border-color: rgba(251,191,36,0.25); color: var(--amber); }

/* ---------- API Keys list ---------- */
.key-row {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: var(--r-sm);
  margin-bottom: 10px;
}
.key-row .ex {
  font-family: var(--f-display);
  font-size: 10px;
  width: 32px; height: 32px;
  border-radius: 6px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  letter-spacing: 0.06em;
}
.key-row .info b {
  font-family: var(--f-display);
  font-size: 13px;
  letter-spacing: 0.1em;
  display: block;
}
.key-row .info span {
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.06em;
}

/* ---------- Status das chaves (verificação ao vivo) ---------- */
.keys-status-at {
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--text-mute);
  letter-spacing: 0.04em;
  margin-right: 10px;
}
.keys-status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
}
.keys-status-row:last-child { border-bottom: none; }
.keys-status-row .status-chip { flex: 0 0 auto; }
.keys-status-detail {
  font-size: 12px;
  color: var(--text-mid, var(--text-mute));
  line-height: 1.4;
  word-break: break-word;
}
.keys-status-empty {
  padding: 16px 4px;
  font-size: 12px;
  color: var(--text-mute);
}
.keys-status-empty.err { color: var(--red); }

@media (max-width: 640px) {
  .keys-status-row { flex-direction: column; align-items: flex-start; gap: 6px; }
}

/* ---------- Animations ---------- */
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
/* Estado de carregamento em botões de refresh */
.btn.is-loading { pointer-events: none; opacity: 0.6; }
.btn.is-loading svg { animation: spin 0.7s linear infinite; }

/* ---------- Responsive ---------- */
/* Faixa tablet (769–1024px): sidebar mais estreita, mais cards por linha */
@media (min-width: 769px) and (max-width: 1024px) {
  .app { grid-template-columns: 220px 1fr; }
  .bot-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .pos-grid { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
}
@media (max-width: 1024px) {
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  /* 3º KPI (último) ocupa a linha toda — evita buraco ao lado */
  .summary-grid .kpi:last-child:nth-child(3) { grid-column: 1 / -1; }
  .topbar { padding: 10px 14px; gap: 10px; }
  .topbar .crumb { display: none; }
  .topbar .search { display: none; }
  .topbar .btn-primary { padding: 8px; min-width: 38px; min-height: 38px; justify-content: center; }
  .topbar .btn-primary svg { flex-shrink: 0; }
  .topbar .btn-primary .btn-text { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  .screen { padding: 16px 12px 80px; }
  .two-col { grid-template-columns: 1fr; }
  .bot-grid { grid-template-columns: 1fr; }
  .pos-grid { grid-template-columns: 1fr; }
  .filter-bar { display: none; }

  /* Tabela → cards */
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr { display: block; }
  .tbl tbody tr {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    margin-bottom: 8px;
    padding: 12px;
    cursor: pointer;
  }
  .tbl tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px dashed var(--line-soft);
    text-align: right;
    font-size: 12px;
  }
  .tbl tbody td:last-child { border-bottom: 0; }
  .tbl tbody td::before {
    content: attr(data-label);
    font-family: var(--f-mono);
    font-size: 10px;
    color: var(--text-mute);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    flex-shrink: 0;
  }
  .tbl tbody td:first-child::before { display: none; }

  /* Modais → bottom sheet */
  .modal-mask { padding: 0; align-items: flex-end; }
  .modal, .modal.wide {
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 92vh;
    animation: slideUp 0.22s ease;
  }
  .modal-body { padding: 14px; }
  .modal-head { padding: 12px 14px; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .asset-tabs { padding: 0 10px; }
  .asset-tab { padding: 10px 9px; font-size: 10px; letter-spacing: 0.06em; }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ---------- Tabela compacta no desktop (SCAN / Histórico cabem sem rolar) ---------- */
@media (min-width: 769px) {
  .tbl { font-size: 12px; }
  .tbl thead th { padding: 8px 10px; font-size: 9px; letter-spacing: 0.1em; }
  .tbl tbody td { padding: 7px 10px; }
  .asset { gap: 8px; }
  .asset .ticker { font-size: 12px; letter-spacing: 0.04em; }
  .asset .sub { font-size: 9px; letter-spacing: 0.05em; }
  .asset-icon { width: 26px; height: 26px; font-size: 9px; border-radius: 6px; }
  .exch-pair { font-size: 10px; gap: 4px; }
  .exch-pair span { padding: 2px 5px; }
  .spread-cell .pct { font-size: 12px; }
  .spread-cell .tgt { font-size: 9px; }
  .status-chip { font-size: 9px; padding: 3px 8px 3px 7px; letter-spacing: 0.08em; }
  .tbl-log td { font-size: 11px; padding: 7px 10px; }
  .sig-badge { font-size: 9px; padding: 2px 5px; gap: 2px; }
}

/* ---------- Badges de Sinal (cruzamentos acima/abaixo de 0%) ---------- */
.sig-cell { display: flex; gap: 5px; justify-content: flex-end; flex-wrap: wrap; }
.sig-badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-family: var(--f-mono); font-size: 11px;
  padding: 3px 7px; border-radius: 5px;
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line);
  white-space: nowrap;
}
.sig-badge.up { color: var(--mint); }
.sig-badge.down { color: var(--red); }

/* ---------- Favorito + cabeçalhos ordenáveis ---------- */
.fav-star {
  background: none; border: 0; cursor: pointer;
  color: var(--text-mute); font-size: 14px; line-height: 1;
  padding: 0 2px; flex-shrink: 0;
  transition: color 0.15s, transform 0.15s;
}
.fav-star:hover { color: var(--amber); transform: scale(1.2); }
.fav-star.on { color: var(--amber); text-shadow: 0 0 8px rgba(251, 191, 36, 0.4); }
.ban-btn {
  background: none; border: 0; cursor: pointer;
  font-size: 13px; line-height: 1;
  padding: 0 2px; flex-shrink: 0; opacity: 0.35;
  transition: opacity 0.15s, transform 0.15s;
}
.ban-btn:hover { opacity: 1; transform: scale(1.2); }
.ban-btn.on { opacity: 1; color: var(--mint); }
.status-chip[title] { cursor: help; }
.tbl thead th.sortable { cursor: pointer; user-select: none; transition: color 0.15s; }
.tbl thead th.sortable:hover { color: var(--text-dim); }
.sort-arrow { color: var(--mint); }

/* =======================================================
   MOBILE COMPONENTS
   ======================================================= */

/* Hamburger — oculto no desktop */
.mobile-hamburger { display: none; }

/* Chips bar — oculta no desktop */
.mobile-chips-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 18, 27, 0.94);
  position: sticky;
  top: 54px;
  z-index: 20;
  overflow: hidden;
}
.chips-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}
.chips-scroll::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  user-select: none;
}
.chip.active {
  background: var(--mint);
  color: #07120c;
  border-color: var(--mint);
  font-weight: 600;
}

.mobile-search-toggle {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text-dim);
  display: grid; place-items: center;
  cursor: pointer;
}

/* Search expand */
.mobile-search-expand {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 18, 27, 0.94);
  position: sticky;
  top: 54px;
  z-index: 20;
  color: var(--text-dim);
}
.mobile-search-expand.open { display: flex; }
.mobile-search-expand input {
  flex: 1;
  background: transparent;
  border: 0; outline: 0;
  font-family: var(--f-mono);
  font-size: 13px;
  color: var(--text);
  padding: 4px 0;
}

/* Drawer overlay */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(7, 10, 16, 0.65);
  backdrop-filter: blur(3px);
  z-index: 90;
}
body.drawer-open .drawer-overlay { display: block; }

/* Drawer panel */
.mobile-drawer {
  position: fixed;
  top: 0; left: 0;
  width: min(280px, 82vw);
  height: 100dvh;
  background: linear-gradient(180deg, #0b1018 0%, #0d121b 100%);
  border-right: 1px solid var(--line);
  z-index: 100;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.32, 0, 0.15, 1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
}
body.drawer-open .mobile-drawer { transform: translateX(0); }

/* Ativa componentes mobile */
@media (max-width: 768px) {
  .mobile-hamburger { display: flex; }
  .mobile-chips-bar { display: flex; }
  .topbar .screen-title { font-size: 14px; letter-spacing: 0.08em; }
}

/* Tela muito pequena (iPhone SE/mini e menores) */
@media (max-width: 400px) {
  .summary-grid { grid-template-columns: 1fr; }
  .screen { padding: 12px 10px 80px; }
}

/* =======================================================
   ACCORDION — spread table mobile
   ======================================================= */
@media (max-width: 768px) {
  /* Collapsed: mostra só o primeiro td */
  .tbl tbody tr.acc-row:not(.acc-open) td:not(:first-child) {
    display: none !important;
  }
  .tbl tbody tr.acc-row:not(.acc-open) td:first-child {
    padding: 10px 0;
    border-bottom: 0;
  }
  .tbl tbody tr.acc-row.armed:not(.acc-open) {
    border-left: 3px solid var(--mint);
    box-shadow: inset 3px 0 0 var(--mint-glow);
  }

  /* Expanded: mostra todos os tds */
  .tbl tbody tr.acc-row.acc-open {
    border-left: 3px solid rgba(74,222,128,0.35);
  }
  .tbl tbody tr.acc-row.acc-open .acc-mobile-meta {
    display: none;
  }

  /* Summary strip (visível no collapsed) */
  .acc-mobile-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed var(--line-soft);
  }
  .acc-mobile-meta .acc-pct {
    font-family: var(--f-mono);
    font-size: 15px;
    font-weight: 500;
    flex: 1;
  }
  .acc-mobile-meta .acc-chip {
    font-size: 9px;
    padding: 3px 7px;
  }
  .acc-mobile-meta .acc-chevron {
    color: var(--text-mute);
    font-size: 11px;
    transition: transform 0.15s;
    flex-shrink: 0;
  }
  .tbl tbody tr.acc-row.acc-open .acc-chevron {
    transform: rotate(90deg);
  }

  /* Botão "Configurar Bot" dentro do card expandido */
  .acc-bot-btn {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 9px;
    background: var(--mint-soft);
    border: 1px solid rgba(74,222,128,0.3);
    color: var(--mint);
    border-radius: var(--r-sm);
    font-family: var(--f-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-align: center;
    cursor: pointer;
  }
}

/* Desktop: ocultar elementos mobile-only */
@media (min-width: 769px) {
  .acc-mobile-meta { display: none !important; }
  .acc-bot-btn { display: none !important; }
}

/* Login page mobile */
@media (max-width: 480px) {
  .login-card { padding: 28px 20px 22px !important; }
}
@media (max-width: 375px) {
  .login-card { padding: 20px 16px 18px !important; }
}

/* ---------- Sugestões de entrada (Dashboard) ---------- */
.suggest-panel {
  margin-bottom: 18px;
  background: var(--bg-deep);
  border: 1px solid rgba(251, 191, 36, 0.18);
  border-radius: var(--r-lg);
  padding: 14px 16px 10px;
}
.suggest-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.suggest-title {
  font-family: var(--f-display);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
  display: flex;
  align-items: center;
  gap: 8px;
}
.suggest-title svg { width: 14px; height: 14px; }
.suggest-sub { font-size: 11px; color: var(--text-mute); }
/* Seletor de rota das Sugestões — empurra ele (e o pager logo após) para a direita do cabeçalho */
.suggest-route {
  margin-left: auto;
  align-self: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: var(--f-mono);
  font-size: 11px;
  padding: 6px 10px;
  cursor: pointer;
}
.suggest-route:focus { outline: none; border-color: var(--mint); }

/* Barra deslizante do ciclo típico (tipo controle de volume) */
.suggest-cycle-ctrl {
  display: inline-flex; align-items: center; gap: 8px; align-self: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 5px 10px; cursor: pointer;
}
.suggest-cycle-ctrl .scc-cap { font-family: var(--f-mono); font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.suggest-cycle-ctrl .scc-val {
  font-family: var(--f-mono); font-size: 11px; font-weight: 600; color: var(--mint);
  min-width: 46px; text-align: right;
}
#suggest-cycle {
  -webkit-appearance: none; appearance: none;
  width: 110px; height: 4px; border-radius: 999px;
  background: var(--surface-3); outline: none; cursor: pointer;
}
#suggest-cycle::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--mint); border: 2px solid var(--bg);
  box-shadow: 0 0 8px var(--mint-glow); cursor: pointer;
}
#suggest-cycle::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--mint); border: 2px solid var(--bg);
  box-shadow: 0 0 8px var(--mint-glow); cursor: pointer;
}
#suggest-cycle::-moz-range-track { height: 4px; border-radius: 999px; background: var(--surface-3); }

/* Com o seletor de rota já alinhado à direita, a barra e o pager ficam logo ao lado */
/* Dois selects seguidos (ordenação + rota): só o 1º empurra p/ a direita; o 2º encosta nele. */
.suggest-route + .suggest-route { margin-left: 0; }
.suggest-route + .suggest-cycle-ctrl { margin-left: 0; }
.suggest-cycle-ctrl + .suggest-pager { margin-left: 8px; }
.suggest-route + .suggest-pager { margin-left: 8px; }
.suggest-pager { display: flex; align-items: center; align-self: center; gap: 4px; margin-left: auto; }
.suggest-addbot {
  margin-top: 10px; width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 10px; border-radius: var(--r-sm);
  border: 1px solid rgba(74, 222, 128, 0.3); background: var(--mint-soft); color: var(--mint);
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.04em; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.suggest-addbot:hover { background: rgba(74, 222, 128, 0.18); border-color: var(--mint); }
.suggest-addbot svg { width: 13px; height: 13px; }
/* overflow-x:auto força o eixo Y a recortar também; o padding cria uma "câmara"
   interna para o hover (translateY -2px, box-shadow e ::before) não ser cortado,
   e as margens negativas neutralizam esse padding para o layout externo ficar igual. */
.suggest-row { display: flex; gap: 10px; overflow-x: auto; padding: 6px 4px 18px; margin: -6px -4px -12px; }
.suggest-card {
  flex: 0 0 198px;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.suggest-card:hover {
  border-color: var(--amber);
  transform: translateY(-2px);
  box-shadow: 0 8px 22px -10px rgba(251, 191, 36, 0.45);
}
.suggest-card:hover::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 20%;
  bottom: 20%;
  width: 3px;
  background: var(--amber);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.7);
}
.suggest-top { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.suggest-sym { font-weight: 700; }
.suggest-route { font-family: var(--f-mono); font-size: 9px; letter-spacing: 0.1em; color: var(--text-mute); }
/* Sub-abas do painel de Sugestões: Estáveis ↔ Oscilantes */
.suggest-tabs { display: inline-flex; gap: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.suggest-tab { border: 0; background: transparent; color: var(--text-mute); font-family: inherit; font-size: 11px; font-weight: 600; padding: 4px 11px; border-radius: 6px; cursor: pointer; white-space: nowrap; transition: background .15s ease, color .15s ease; }
.suggest-tab:hover { color: var(--text-dim); }
.suggest-tab.on { background: var(--surface-2, rgba(255,255,255,.05)); color: var(--text); }
/* tag "BOT" no card de sugestão: encosta à direita e fica compacta */
.suggest-bot-chip { margin-left: auto; font-size: 8px; padding: 2px 7px 2px 6px; letter-spacing: 0.1em; }
.suggest-bot-chip .ico { width: 5px; height: 5px; }
.suggest-cycle { font-family: var(--f-mono); font-size: 18px; font-weight: 700; }
.suggest-cycle small { font-size: 9px; font-weight: 400; color: var(--text-mute); letter-spacing: 0.08em; text-transform: uppercase; }
.suggest-meta { display: flex; flex-direction: column; gap: 2px; font-size: 10px; color: var(--text-dim); margin-top: 6px; }
.suggest-meta b { font-family: var(--f-mono); font-weight: 600; }
.suggest-now { font-size: 10px; color: var(--text-mute); margin-top: 8px; border-top: 1px solid var(--line-soft); padding-top: 7px; }
.suggest-now b { font-family: var(--f-mono); }
.suggest-now-net { cursor: help; opacity: .85; }
.suggest-empty { font-size: 11px; color: var(--text-mute); padding: 6px 2px 10px; }

/* ---------- Carteira ---------- */
#screen-wallet .section-head { flex-wrap: wrap; row-gap: 8px; }   /* cabeçalho não espreme */
.wallet-sync { gap: 7px; }
.wallet-synced-at { font-family: var(--f-mono); font-size: 11px; color: var(--text-mute); white-space: nowrap; }

/* Barra fina de resumo — só aparece com 2+ corretoras com saldo */
.wallet-summary {
  display: flex; flex-wrap: wrap; margin-bottom: 16px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
}
.wsum-item { flex: 1; min-width: 140px; display: flex; flex-direction: column; gap: 3px; padding: 12px 18px; }
.wsum-item + .wsum-item { border-left: 1px solid var(--line); }
.wsum-item span { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-mute); }
.wsum-item b { font-family: var(--f-mono); font-size: 15px; font-weight: 700; color: var(--text); }
.wsum-item.total b { color: var(--mint); }

.wallet-exchange { margin-bottom: 14px; }
.wallet-exchange.soon { opacity: 0.62; }
.wallet-ex-total { font-family: var(--f-mono); font-size: 16px; font-weight: 700; line-height: 1; color: var(--mint); }
.wallet-ex-total small { font-size: 10px; font-weight: 400; color: var(--text-mute); }
.wallet-ex-meta {
  display: flex; gap: 22px; flex-wrap: wrap;
  padding: 12px 18px; border-bottom: 1px solid var(--line-soft);   /* alinhado com panel-head/tbl (18px) */
  background: rgba(255, 255, 255, 0.015);
  font-size: 11px; color: var(--text-dim);
}
.wallet-ex-meta b { font-family: var(--f-mono); color: var(--text); font-weight: 600; }

/* Card minimizado: só o header (nome + total) fica visível */
.wallet-exchange.minimized .wallet-ex-body { display: none; }

.wallet-hidden-note {
  padding: 10px 18px; border-top: 1px solid var(--line-soft);
  font-family: var(--f-mono); font-size: 10px; color: var(--text-mute);
  letter-spacing: 0.05em;
}

/* Filtro de valor mínimo (poeira) no cabeçalho da carteira */
.wallet-min-filter {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  font-size: 11px; color: var(--text-dim);
}
.wallet-min-filter input {
  width: 64px; padding: 5px 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  color: var(--text); font-family: var(--f-mono); font-size: 11px;
}
.wallet-min-filter input:focus { outline: none; border-color: var(--mint); }

/* === Carteira (design DC: hero + barra spot/futuros + chips + cards por corretora) === */
.wallet-head { align-items: flex-start; }
.wallet-headtext { display: flex; flex-direction: column; gap: 4px; }

.wallet-hero {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 22px 26px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 32px; flex-wrap: wrap;
  box-shadow: var(--shadow-card);
}
.wallet-hero-main { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 14px; }
.wallet-hero-label { font-family: var(--f-mono); font-size: 10px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--text-mute); }
.wallet-hero-total { display: flex; align-items: baseline; gap: 9px; }
.wallet-hero-total b { font-family: var(--f-mono); font-size: 38px; font-weight: 600; letter-spacing: -.5px; line-height: 1; color: var(--mint); text-shadow: 0 0 18px var(--mint-glow); }
.wallet-hero-total .u { font-size: 14px; color: var(--text-mute); }
.wallet-split { display: flex; flex-direction: column; gap: 9px; max-width: 440px; }
.wallet-split-bar { display: flex; gap: 3px; height: 9px; border-radius: 99px; overflow: hidden; background: var(--bg); }
.wallet-split-bar .sp { background: var(--mint); border-radius: 99px; }
.wallet-split-bar .fu { background: var(--blue); border-radius: 99px; }
.wallet-split-legend { display: flex; gap: 20px; font-size: 12px; color: var(--text-dim); }
.wallet-split-legend i.sq { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 7px; vertical-align: middle; }
.wallet-split-legend i.sq.sp { background: var(--mint); }
.wallet-split-legend i.sq.fu { background: var(--blue); }
.wallet-split-legend em { color: var(--text-mute); font-style: normal; }
.wallet-hero-side { display: flex; align-items: center; gap: 26px; }
.wallet-hero-side .col { display: flex; flex-direction: column; gap: 8px; }
.wallet-hero-side .k { font-family: var(--f-mono); font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--text-mute); }
.wallet-hero-side .v { display: flex; align-items: baseline; gap: 6px; }
.wallet-hero-side .v b { font-family: var(--f-mono); font-size: 21px; font-weight: 500; color: var(--text); }
.wallet-hero-side .v .u { font-size: 11px; color: var(--text-mute); }
.wallet-hero-side .vdiv { width: 1px; height: 50px; background: var(--line); }

/* chips de corretora */
.wallet-chips { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; flex-wrap: wrap; }
.wallet-chips-label { font-family: var(--f-mono); font-size: 10px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--text-mute); margin-right: 2px; }
.wallet-chip {
  display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 11px; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); background: transparent; color: var(--text-dim);
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.wallet-chip:hover { color: var(--text); border-color: var(--line-strong, #2c313b); }
.wallet-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 8px var(--mint); }
.wallet-chip .n { font-family: var(--f-mono); font-size: 11px; opacity: .6; }
.wallet-chip.on { border-color: color-mix(in srgb, var(--mint) 55%, transparent); background: var(--mint-soft); color: var(--mint); }

/* card por corretora */
.wallet-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; margin-bottom: 16px; box-shadow: var(--shadow-card); }
.wallet-card.soon { opacity: .62; }
.wallet-card-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; padding: 16px 22px; border-bottom: 1px solid var(--line-soft); }
.wallet-card-id { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.wallet-card-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 10px var(--mint); flex: none; }
.wallet-card-name { font-family: var(--f-display); font-size: 16px; font-weight: 700; letter-spacing: .04em; }
.wallet-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); border-radius: 8px; padding: 5px 10px; }
.wallet-pill b { font-family: var(--f-mono); color: var(--text); font-weight: 600; }
.wallet-pill.spot { background: rgba(255,255,255,.03); border: 1px solid var(--line-soft); }
.wallet-pill.fut { background: var(--blue-soft); border: 1px solid color-mix(in srgb, var(--blue) 22%, transparent); }
.wallet-card-total { display: flex; align-items: baseline; gap: 7px; }
.wallet-card-total b { font-family: var(--f-mono); font-size: 21px; font-weight: 700; color: var(--mint); }
.wallet-card-total .u { font-size: 11px; color: var(--text-mute); }

.wallet-thead, .wallet-row { display: grid; grid-template-columns: minmax(0,1fr) 130px 150px 130px; gap: 16px; align-items: center; padding: 12px 22px; }
.wallet-thead { border-bottom: 1px solid var(--line-soft); font-family: var(--f-mono); font-size: 9.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--text-mute); }
.wallet-thead .r, .wallet-row .r { text-align: right; justify-self: end; }
.wallet-row { border-bottom: 1px solid var(--line-soft); }
.wallet-row:last-child { border-bottom: 0; }
.wallet-row:hover { background: rgba(255,255,255,.015); }
.wallet-asset { display: flex; align-items: center; gap: 11px; min-width: 0; }
.wallet-asset .t { font-size: 14px; font-weight: 600; color: var(--text); }
.wallet-row .num { font-family: var(--f-mono); font-size: 13px; color: var(--text); }
.wallet-row .num.dim { color: var(--text-dim); }
.wallet-row .num.val { font-size: 14px; font-weight: 600; }
.wallet-row .num.muted { color: var(--text-mute); }
.wallet-empty { padding: 30px; text-align: center; color: var(--text-mute); font-size: 12.5px; }
.wallet-card-foot { padding: 13px 22px; background: rgba(255,255,255,.012); display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--text-mute); }
.wallet-card-foot a { font-weight: 600; color: var(--mint); text-decoration: none; }
.wallet-card-foot a:hover { text-decoration: underline; }

.wallet-disclaimer {
  display: flex; align-items: center; gap: 12px; margin-top: 4px;
  background: var(--blue-soft); border: 1px solid color-mix(in srgb, var(--blue) 20%, transparent);
  border-radius: var(--r-md); padding: 14px 18px; font-size: 13px; color: var(--text-dim); line-height: 1.5;
}
.wallet-disclaimer svg { flex: none; }
.wallet-disclaimer b { color: var(--text); font-weight: 600; }
.wallet-disclaimer .num-mute { font-family: var(--f-mono); color: var(--text-mute); }

@media (max-width: 720px) {
  .wallet-thead, .wallet-row { grid-template-columns: minmax(0,1fr) auto; gap: 10px; padding: 12px 16px; }
  .wallet-thead span:nth-child(2), .wallet-thead span:nth-child(3), .wallet-row .num:not(.val) { display: none; }
  .wallet-hero-side { gap: 18px; }
}

/* ---------- Calendário de Resultados ---------- */
.cal-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); gap: 16px; align-items: start; min-width: 0; }
/* min-width:0 impede que o conteúdo interno force a coluna a estourar a tela */
.cal-main { padding: 18px 20px 16px; min-width: 0; }

.cal-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.cal-month-name {
  font-family: var(--f-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cal-today-btn {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--amber);
  padding: 2px 0;
  opacity: 0.85;
}
.cal-today-btn:hover { opacity: 1; text-decoration: underline; }
.cal-nav { display: flex; gap: 6px; }
.cal-nav-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.cal-nav-btn:hover { border-color: var(--amber); color: var(--amber); background: var(--amber-soft); }

.cal-summary {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 6px 26px;
  justify-content: start;
  padding: 10px 14px;
  margin-bottom: 16px;
  background: var(--bg-deep);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
}
.cal-sum-item { display: flex; flex-direction: column; gap: 1px; }
.cal-sum-item .k { font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-mute); }
.cal-sum-item .v { font-family: var(--f-mono); font-size: 15px; font-weight: 600; }
.cal-sum-item .v small { font-size: 10px; color: var(--text-mute); font-weight: 400; }

/* minmax(0,1fr) deixa as 7 colunas encolherem abaixo do conteúdo (evita estouro/corte no mobile) */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-dow {
  text-align: center;
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-mute);
  padding: 2px 0 8px;
}
.cal-cell {
  position: relative;
  min-height: 72px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 7px 9px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
/* dia sem resultado: apagado e inerte (como os ícones inativos da referência) */
.cal-cell.mute { background: transparent; }
.cal-cell.mute .cal-daynum { color: var(--text-mute); opacity: 0.55; }
/* dia com resultado: presença e cor */
.cal-cell.gain, .cal-cell.loss { cursor: pointer; background: var(--surface); border-color: var(--line-soft); }
.cal-cell.gain { background: linear-gradient(165deg, var(--mint-soft), var(--surface) 70%); }
.cal-cell.loss { background: linear-gradient(165deg, var(--red-soft), var(--surface) 70%); }
.cal-cell.gain .cal-pnl { color: var(--mint); }
.cal-cell.loss .cal-pnl { color: var(--red); }
.cal-cell.gain:hover, .cal-cell.loss:hover { transform: translateY(-2px); border-color: var(--amber); }
/* selecionado: pílula âmbar com indicador lateral (linguagem da referência) */
.cal-cell.selected {
  border-color: var(--amber);
  box-shadow: 0 0 0 1px var(--amber), 0 6px 22px -8px rgba(251, 191, 36, 0.55);
}
.cal-cell.selected::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 22%;
  bottom: 22%;
  width: 3px;
  background: var(--amber);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.8);
}
.cal-daynum { font-family: var(--f-mono); font-size: 11px; color: var(--text-dim); display: flex; align-items: center; gap: 5px; }
.cal-cell.today .cal-daynum { color: var(--amber); font-weight: 700; }
.cal-today-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--amber);
  display: inline-block;
  animation: calPulse 2s ease-in-out infinite;
}
@keyframes calPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.cal-pnl { font-family: var(--f-mono); font-size: 14px; font-weight: 700; margin-top: auto; }
.cal-closes { font-size: 9px; letter-spacing: 0.1em; color: var(--text-mute); }

.cal-legend { display: flex; gap: 18px; margin-top: 14px; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-mute); }
.cal-legend span { display: flex; align-items: center; gap: 6px; }
.cal-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.cal-dot.gain { background: var(--mint); }
.cal-dot.loss { background: var(--red); }
.cal-dot.today { background: var(--amber); }

/* painel do dia (lateral, fixo enquanto rola) */
.cal-side { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 12px; }
.cal-side > * { animation: calIn 0.28s cubic-bezier(0.2, 0.8, 0.3, 1) both; }
.cal-side > *:nth-child(2) { animation-delay: 0.06s; }
.cal-side > *:nth-child(3) { animation-delay: 0.12s; }
@keyframes calIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.cal-day-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}
.cal-day-hero { position: relative; overflow: hidden; }
.cal-day-hero.gain { border-color: rgba(74, 222, 128, 0.3); }
.cal-day-hero.loss { border-color: rgba(248, 113, 113, 0.3); }
.cal-day-hero.gain::after, .cal-day-hero.loss::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(420px 140px at 85% -30%, var(--mint-soft), transparent 70%);
}
.cal-day-hero.loss::after { background: radial-gradient(420px 140px at 85% -30%, var(--red-soft), transparent 70%); }
.cal-day-date { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-mute); margin-bottom: 6px; }
.cal-day-total { font-family: var(--f-mono); font-size: 30px; font-weight: 700; line-height: 1.1; }
.cal-day-total small { font-size: 12px; font-weight: 400; color: var(--text-mute); }
.cal-day-meta { font-size: 11px; color: var(--text-dim); margin-top: 6px; }

.cal-detail-title {
  font-family: var(--f-display);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 12px;
}
.cal-rank-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.cal-rank-row:last-child { border-bottom: 0; padding-bottom: 2px; }
.cal-rank-pos {
  font-family: var(--f-mono);
  font-size: 10px;
  font-weight: 700;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  background: var(--surface-3);
  color: var(--text-mute);
}
.cal-rank-pos.gold { background: var(--amber-soft); color: var(--amber); box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.4); }
.cal-rank-pos.silver { background: rgba(230, 237, 243, 0.1); color: var(--text); }
.cal-rank-pos.bronze { background: rgba(217, 119, 6, 0.12); color: #d97706; }
.cal-rank-info { flex: 1; min-width: 0; }
.cal-rank-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.cal-rank-sym { font-weight: 600; }
.cal-rank-meta { font-size: 10px; color: var(--text-mute); margin-top: 3px; }
.cal-bar-track { height: 5px; background: var(--surface-3); border-radius: 4px; overflow: hidden; margin-top: 5px; }
.cal-bar-fill { height: 100%; border-radius: 4px; background: var(--blue); transition: width 0.4s cubic-bezier(0.2, 0.8, 0.3, 1); }
.cal-bar-fill.gain { background: var(--mint); }
.cal-bar-fill.loss { background: var(--red); }

.cal-empty { text-align: center; color: var(--text-mute); padding: 36px 18px; font-size: 12px; line-height: 1.7; }
.cal-empty-ico { opacity: 0.4; margin-bottom: 10px; }
.cal-empty-ico svg { width: 28px; height: 28px; }

@media (max-width: 1100px) {
  .cal-layout { grid-template-columns: 1fr; }
  .cal-side { position: static; }
}
@media (max-width: 768px) {
  .cal-main { padding: 14px; }
  .cal-summary { grid-template-columns: repeat(2, auto); }
  .cal-cell { min-height: 54px; padding: 4px 6px; }
  .cal-pnl { font-size: 11px; }
  .cal-closes { display: none; }
  .cal-month-name { font-size: 16px; }
}
/* Aparelhos mais estreitos (≤380px): grade e resumo bem compactos, sem corte */
@media (max-width: 380px) {
  .cal-main { padding: 10px; }
  .cal-summary { grid-template-columns: 1fr 1fr; gap: 4px 12px; padding: 8px 10px; }
  .cal-sum-item .v { font-size: 13px; }
  .cal-grid { gap: 3px; }
  .cal-cell { min-height: 44px; padding: 3px 3px; }
  .cal-daynum { font-size: 10px; }
  .cal-pnl { font-size: 10px; }
}

/* ============================================================
   Passe de responsividade mobile — descomprimir, empilhar,
   eliminar rolagem lateral e dar alvos de toque confortáveis.
   (Vem por último de propósito: sobrescreve as regras base e as
   media queries acima quando há conflito de mesma especificidade.)
   ============================================================ */
@media (max-width: 768px) {
  /* Rede contra rolagem lateral acidental (clip não quebra position:sticky) */
  .main { overflow-x: clip; }

  /* Cabeçalhos: título + ações nunca espremem/sobrepõem (antes valia só p/ a carteira) */
  .section-head { flex-wrap: wrap; row-gap: 8px; }
  .panel-head { flex-wrap: wrap; row-gap: 8px; }

  /* Alvos de toque confortáveis (>=40px) */
  .btn { min-height: 40px; }
  .btn-icon { min-width: 40px; }
  .suggest-addbot { min-height: 40px; }

  /* Sugestões: carrossel não sangra a borda; card cabe na tela */
  .suggest-row { margin-left: 0; margin-right: 0; padding-left: 2px; padding-right: 2px; }
  .suggest-card { flex: 0 0 min(76vw, 200px); }

  /* Posições: pé com botões grandes e empilhados */
  .pos-foot { flex-wrap: wrap; gap: 8px; }
  .pos-foot > span:first-child { flex: 1 1 100%; }
  .pos-foot .spacer { display: none; }
  .pos-foot [data-close-pos] { flex: 1 1 100%; }
  .pos-foot [data-asset-symbol],
  .pos-foot [data-del-pos] { flex: 1 1 0; }
}

/* ---------- Toasts de execução do bot (som + popup de 5s) ---------- */
#toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(92vw, 340px);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 12px 12px 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--text-dim);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-card);
  font-family: var(--f-body);
  animation: toastIn 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.toast-entry { border-left-color: var(--mint); }
.toast.toast-exit { border-left-color: var(--blue); }
.toast.toast-info { border-left-color: var(--amber); }
.toast.toast-out {
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast-tag {
  flex: 0 0 auto;
  font-family: var(--f-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  padding: 3px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  white-space: nowrap;
}
.toast-entry .toast-tag { color: var(--mint); background: var(--mint-soft); }
.toast-exit .toast-tag { color: var(--blue); background: var(--blue-soft); }
.toast-info .toast-tag { color: var(--amber); background: var(--amber-soft); }
.toast-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.toast-body b { font-family: var(--f-display); font-size: 13px; color: var(--text); letter-spacing: 0.02em; }
.toast-body > span { font-size: 12px; color: var(--text-dim); }
.toast-body .toast-meta { font-family: var(--f-mono); font-size: 10px; color: var(--text-mute); }
.toast-close {
  flex: 0 0 auto;
  background: none;
  border: 0;
  color: var(--text-mute);
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}
.toast-close:hover { color: var(--text); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .toast.toast-out { transition: none; }
}
@media (max-width: 768px) {
  #toast-stack { top: 10px; right: 10px; left: 10px; width: auto; }
}

@media (max-width: 480px) {
  /* Posições: empilha ENTRADA e SPREADS (não cabem lado a lado em tela pequena) */
  .legs { grid-template-columns: 1fr; }
  .leg + .leg { border-left: 0; border-top: 1px solid var(--line-soft); }

  /* Carteira: descomprime o resumo e a faixa spot/futuros */
  .wsum-item { min-width: 108px; padding: 10px 12px; }
  .wsum-item b { font-size: 14px; }
  .wallet-ex-meta { gap: 12px; }
  .wallet-ex-total { font-size: 14px; }

  /* Chaves: ícone+nome em cima, selo e botões embaixo (em vez de 4 colunas espremidas) */
  .key-row { grid-template-columns: 32px 1fr; gap: 10px 12px; }
  .key-row .info { min-width: 0; }
  .key-row .info span { word-break: break-word; }

  /* Abas do terminal do ativo: roláveis em vez de espremidas */
  .asset-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .asset-tab { white-space: nowrap; flex: 0 0 auto; }
}

