:root {
  color-scheme: dark;
  --bg: #05080d;
  --panel: #0b111d;
  --line: #233044;
  --muted: #aab4c7;
  --text: #f5f7fb;
  --blue: #0792ff;
  --blue-soft: #7fd0ff;
  --green: #22db63;
  --red: #ff383d;
  --amber: #ffb21a;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: clamp(220px, 14vw, 264px) minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  transition: grid-template-columns 160ms ease;
  background:
    radial-gradient(circle at 48% -20%, rgba(0, 145, 255, 0.14), transparent 34%),
    linear-gradient(180deg, #07101b 0%, #05080d 100%);
}

.shell.sidebar-collapsed {
  grid-template-columns: 76px minmax(0, 1fr);
}

.sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  height: 100dvh;
  min-height: 0;
  padding: 16px 14px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(7, 13, 24, 0.86);
  overflow: hidden;
  transition: opacity 140ms ease;
}

.sidebar-backdrop {
  display: none;
}

.sidebar-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 2px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  margin-left: auto;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  color: #93a4bd;
  transition: background 140ms ease, color 140ms ease;
}

.sidebar-toggle:hover {
  background: rgba(0, 136, 255, 0.16);
  color: var(--blue-soft);
}

.sidebar-toggle svg {
  width: 20px;
  height: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 48px;
  padding: 0;
}

.brand-text {
  min-width: 0;
}

/* Sidebar recolhida em rail de icones (desktop). */
.shell.sidebar-collapsed .brand-text,
.shell.sidebar-collapsed .nav-label {
  display: none;
}

.shell.sidebar-collapsed .sidebar-top {
  flex-direction: column;
  gap: 10px;
}

.shell.sidebar-collapsed .sidebar-toggle {
  margin-left: 0;
}

.shell.sidebar-collapsed .brand {
  justify-content: center;
}

.shell.sidebar-collapsed .brand-logo {
  width: 44px;
  height: 44px;
}

.shell.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 0;
  gap: 0;
}

.brand-logo {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
}

.brand strong {
  display: block;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.02em;
}

.brand span {
  display: block;
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.26em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: clamp(46px, 6vh, 58px);
  padding: 0 16px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: rgba(180, 200, 230, 0.75);
  font-size: 15px;
  font-weight: 700;
  text-align: left;
  letter-spacing: 0.01em;
  transition: background 140ms ease, color 140ms ease;
}

.nav-item:hover {
  background: rgba(0, 136, 255, 0.1);
  color: #e0ecff;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(180, 200, 230, 0.7);
  transition: background 140ms ease, color 140ms ease;
}

.nav-item:hover .nav-icon {
  background: rgba(0, 136, 255, 0.18);
  color: var(--blue-soft);
}

.nav-label {
  flex: 1;
  min-width: 0;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(0, 136, 255, 0.22), rgba(0, 136, 255, 0.07));
  color: #e8f4ff;
  box-shadow: inset 3px 0 0 var(--blue);
}

.nav-item.active .nav-icon {
  background: rgba(0, 136, 255, 0.28);
  color: var(--blue);
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* A view ativa (operacoes/treinamentos/suporte) preenche toda a altura restante,
   evitando a faixa vazia no rodape. */
.main > .view-panel {
  flex: 1 1 auto;
  min-height: 0;
}

/* Barra global: so guarda o botao de menu (usada em Treinamentos/Suporte no celular). */
.topbar {
  display: none;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.menu-button {
  display: none;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 30px;
}

/* Faixa dentro do bloco do grafico: [menu (mobile)] [Ativo] [Saldo].
   Sem fundo proprio: os chips de Ativo e Saldo ficam sobre o topo do painel,
   alinhados com o grafico logo abaixo. */
.chart-topbar {
  position: absolute;
  z-index: 6;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 0;
}

.chart-topbar .select-box {
  flex: 1 1 auto;
  max-width: 340px;
}

.chart-topbar .balance-box {
  margin-left: auto;
}

/* O seletor de ativos e o saldo so aparecem depois de conectar. */
body:not(.broker-connected) .chart-topbar .select-box,
body:not(.broker-connected) .chart-topbar .balance-box {
  visibility: hidden;
}

small,
.field-row span {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.green {
  color: var(--green);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(300px, 21vw, 390px);
  gap: 14px;
  min-height: 0;
  overflow: hidden;
  padding: 14px;
}

.view-panel {
  min-height: 0;
}

.content-view {
  min-height: 0;
  overflow: auto;
  padding: 14px;
}

.page-panel {
  min-height: 100%;
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  background: rgba(10, 17, 29, 0.88);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.22);
}

.page-head {
  max-width: 720px;
  margin-bottom: 24px;
}

.page-head > span {
  display: block;
  color: var(--blue-soft);
  font-weight: 900;
  text-transform: uppercase;
}

.page-head h1 {
  margin: 8px 0 10px;
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.05;
}

.page-head p {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

/* Netflix training layout */
.training-view {
  padding: 0 !important;
}

.training-page {
  min-height: 100%;
  overflow: auto;
}

.training-hero {
  position: relative;
  min-height: 440px;
  display: flex;
  align-items: flex-end;
  background: linear-gradient(135deg, #0d1f3c, #05080d);
  background-size: cover;
  background-position: center;
}

.training-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(5, 8, 13, 0.96) 0%,
    rgba(5, 8, 13, 0.6) 40%,
    rgba(5, 8, 13, 0.2) 100%
  );
}

.training-hero-content {
  position: relative;
  z-index: 1;
  max-width: 680px;
  padding: 48px 36px;
}

.training-hero-tag {
  display: inline-block;
  margin-bottom: 10px;
  padding: 3px 10px;
  border-radius: 4px;
  background: var(--blue);
  color: white;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.training-hero-title {
  margin: 0 0 12px;
  font-size: clamp(26px, 3vw, 42px);
  line-height: 1.1;
  color: #fff;
}

.training-hero-desc {
  margin: 0 0 22px;
  color: rgba(200, 215, 235, 0.88);
  font-size: 17px;
  line-height: 1.55;
  max-width: 520px;
}

.training-hero-play {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 24px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  font-size: 16px;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
  transition: background 140ms ease, transform 100ms ease;
}

.training-hero-play:hover {
  background: #0080f0;
  transform: scale(1.03);
}

.training-content {
  padding: 28px 24px 32px;
}

.training-grid-v2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.lesson-card-v2 {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(10, 17, 29, 0.9);
  transition: border-color 160ms ease, transform 160ms ease;
}

.lesson-card-v2:hover {
  border-color: rgba(0, 146, 255, 0.5);
  transform: translateY(-2px);
}

.lesson-card-v2.clickable {
  cursor: pointer;
}

.lesson-cover {
  position: relative;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(0, 80, 160, 0.4), rgba(0, 20, 60, 0.9)), #061020;
  overflow: hidden;
}

/* Numero fica no fundo; a imagem da capa cobre por cima. Se a imagem falhar
   (arquivo inexistente), o JS remove o <img> e o numero reaparece. */
.lesson-num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(120, 160, 220, 0.6);
  font-size: 52px;
  font-weight: 950;
  letter-spacing: -2px;
}

.lesson-cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.lesson-play-icon {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.0);
  background: rgba(0, 0, 0, 0);
  transition: background 200ms ease, color 200ms ease;
}

.lesson-card-v2.clickable:hover .lesson-play-icon {
  color: rgba(255, 255, 255, 0.95);
  background: rgba(0, 0, 0, 0.42);
}

.lesson-info {
  padding: 14px 16px 16px;
}

.lesson-info small {
  color: var(--blue-soft);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lesson-info h2 {
  margin: 6px 0 8px;
  font-size: 17px;
  line-height: 1.2;
  color: #e8f4ff;
}

.lesson-info p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.lesson-button,
.support-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(0, 146, 255, 0.6);
  border-radius: 7px;
  background: rgba(0, 146, 255, 0.12);
  color: #e8f4ff;
  font-size: 14px;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

/* Popup da aula (video) */
.lesson-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.lesson-modal[hidden] {
  display: none;
}

.lesson-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
}

.lesson-modal-box {
  position: relative;
  z-index: 1;
  width: min(980px, 100%);
}

.lesson-modal-video {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6);
}

.lesson-modal-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.lesson-modal-close {
  position: absolute;
  z-index: 2;
  top: 18px;
  right: 18px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  background: rgba(20, 26, 38, 0.9);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.lesson-modal-close:hover {
  background: rgba(40, 50, 68, 0.95);
}

body.modal-open {
  overflow: hidden;
}

.training-empty {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.support-link.primary {
  border-color: rgba(34, 219, 99, 0.72);
  background: linear-gradient(180deg, #29d45e, #16ad40);
  color: white;
}

.support-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.support-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 12, 22, 0.86);
}

.support-card h2 {
  margin: 0 0 8px;
  font-size: 21px;
}

.support-card p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
}

/* Ranking de ativos */
.ranking-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.ranking-time {
  width: auto;
  display: inline-grid;
  grid-template-columns: repeat(3, 64px);
}

.ranking-time .segment {
  min-height: 40px;
  font-size: 15px;
}

.ranking-status {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.ranking-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.ranking-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

.ranking-table th,
.ranking-table td {
  padding: 12px 14px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.ranking-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: rgba(7, 12, 22, 0.6);
}

.ranking-table tbody tr {
  cursor: pointer;
  transition: background 120ms ease;
}

.ranking-table tbody tr:hover {
  background: rgba(0, 146, 255, 0.08);
}

.ranking-rank {
  width: 40px;
  color: var(--muted);
  font-weight: 900;
}

.ranking-asset {
  font-weight: 800;
  color: #e8f4ff;
}

.ranking-payout {
  color: var(--blue-soft);
  font-weight: 800;
}

.ranking-pct {
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.ranking-pct small {
  display: inline;
  margin-left: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.ranking-pct.good {
  color: var(--green);
}

.ranking-pct.mid {
  color: var(--amber);
}

.ranking-pct.bad {
  color: #ff7a7e;
}

.ranking-empty {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

/* Trava / incentivo a depositar */
.ranking-lock {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding: 16px 18px;
  border: 1px solid rgba(255, 178, 26, 0.45);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 178, 26, 0.12), rgba(255, 178, 26, 0.04));
}

.ranking-lock-icon {
  font-size: 30px;
  flex: 0 0 auto;
}

.ranking-lock-text {
  flex: 1;
  min-width: 0;
}

.ranking-lock-text strong {
  display: block;
  font-size: 17px;
  color: #ffe2a6;
}

.ranking-lock-text p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.ranking-lock-cta {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 0 22px;
  border-radius: 9px;
  background: linear-gradient(180deg, #29d45e, #16ad40);
  color: #fff;
  font-weight: 950;
  text-decoration: none;
  white-space: nowrap;
}

.ranking-table tbody tr.locked {
  cursor: default;
}

.ranking-table tbody tr.locked:hover {
  background: transparent;
}

.ranking-asset.locked {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.ranking-lock-mini {
  font-size: 14px;
}

.ranking-blur {
  filter: blur(5px);
  user-select: none;
  opacity: 0.8;
}

@media (max-width: 680px) {
  .ranking-lock {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
  }

  .ranking-lock-cta {
    width: 100%;
    justify-content: center;
  }
}

.support-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.support-link.primary {
  border-color: rgba(34, 219, 99, 0.72);
  background: linear-gradient(180deg, #29d45e, #16ad40);
  color: white;
}

.chart-panel,
.panel {
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  background: rgba(10, 17, 29, 0.88);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.22);
}

.chart-panel {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.select-box,
.balance-box {
  position: relative;
  padding: 6px 12px 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(9, 15, 26, 0.94);
}

.select-box {
  z-index: 8;
}

.select-box > span,
.balance-box > span {
  display: block;
  margin-bottom: 1px;
  padding: 0;
  color: #9fb0c4;
  font-size: 12px;
  font-weight: 700;
}

.balance-box {
  min-width: 150px;
  text-align: right;
}

.balance-box strong {
  display: block;
  font-size: 18px;
  font-weight: 950;
  line-height: 1.25;
}

select,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #080e18;
  color: var(--text);
  outline: none;
}

select {
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  background: transparent;
  font-size: 20px;
  font-weight: 900;
}

.asset-trigger {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 24px;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.asset-trigger strong {
  overflow: hidden;
  font-size: 17px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-trigger span {
  color: #dbe7f8;
  font-size: 18px;
  text-align: center;
}

.asset-trigger:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.asset-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 8px);
  left: 0;
  width: min(420px, calc(100vw - 40px));
  max-width: 100%;
  padding: 10px;
  border: 1px solid #1f3755;
  border-radius: 8px;
  background: #07101b;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
}

.asset-menu input {
  min-height: 42px;
  padding: 0 12px;
  border-color: #25415f;
  background: #0a1422;
  color: var(--text);
  font-weight: 800;
}

.asset-options {
  max-height: min(390px, 48dvh);
  margin-top: 8px;
  overflow: auto;
  padding-right: 4px;
}

.asset-options::-webkit-scrollbar {
  width: 8px;
}

.asset-options::-webkit-scrollbar-track {
  background: #0b1422;
}

.asset-options::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #2d5278;
}

.asset-option {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #e9f2ff;
  text-align: left;
}

.asset-option strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-option span {
  color: var(--blue-soft);
  font-weight: 900;
}

/* Indicador de automacao rodando no ativo (no seletor e no nome atual). */
.asset-auto {
  margin-right: 6px;
  font-size: 14px;
  filter: drop-shadow(0 0 4px rgba(0, 146, 255, 0.5));
}

.asset-option:hover,
.asset-option.active {
  background: linear-gradient(90deg, rgba(0, 136, 255, 0.26), rgba(0, 136, 255, 0.08));
}

.asset-empty {
  padding: 14px 12px;
  color: var(--muted);
  font-weight: 800;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(62px, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segment {
  min-height: 40px;
  border: 0;
  border-right: 1px solid var(--line);
  background: rgba(7, 12, 22, 0.9);
  color: var(--text);
  font-weight: 900;
  font-size: 17px;
}

.segment:last-child {
  border-right: 0;
}

.segment.active {
  background: linear-gradient(180deg, #0d4c9a, #082f69);
  color: white;
  box-shadow: inset 0 0 0 1px var(--blue);
}

.chart-wrap {
  position: absolute;
  inset: 62px 0 0;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  font-weight: 900;
  text-align: center;
  pointer-events: none;
}

/* Marca d'agua com a logo enquanto o grafico nao carregou (1-3s). */
.chart-watermark {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease;
}

.chart-watermark img {
  width: min(300px, 36%);
  filter: grayscale(0.15);
  animation: chart-watermark-pulse 1.9s ease-in-out infinite;
}

.chart-watermark.visible {
  opacity: 1;
}

@keyframes chart-watermark-pulse {
  0%,
  100% {
    opacity: 0.05;
    transform: scale(0.97);
  }
  50% {
    opacity: 0.16;
    transform: scale(1.03);
  }
}

/* Card flutuante das operacoes ativas (manual/automatica). */
.trade-ticket {
  position: absolute;
  z-index: 4;
  top: 14px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(280px, 48%);
  pointer-events: none;
}

.trade-ticket-item {
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  background: rgba(7, 13, 24, 0.93);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(2px);
  animation: trade-ticket-in 200ms ease;
}

.trade-ticket-item.win {
  border-color: rgba(22, 199, 132, 0.65);
}

.trade-ticket-item.loss {
  border-color: rgba(234, 57, 67, 0.65);
}

.tt-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

/* X pequeno no canto superior do card (so aparece quando a operacao resolveu) */
.tt-close {
  margin-left: 2px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tt-close:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }

.tt-dir {
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 900;
  color: #06121f;
}

.tt-dir.call {
  background: #16c784;
}

.tt-dir.put {
  background: #ea3943;
}

.tt-asset {
  flex: 1;
  overflow: hidden;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.tt-amount {
  font-size: 14px;
  font-weight: 900;
}

.tt-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tt-profit {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tt-count {
  font-size: 12px;
  font-weight: 800;
  color: #cbd5e1;
}

.tt-result {
  font-size: 13px;
  font-weight: 900;
}

.tt-result.win {
  color: #16c784;
}

.tt-result.loss {
  color: #ea3943;
}

.tt-result.tie {
  color: #cbd5e1;
}

@keyframes trade-ticket-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Painel de assertividade do ativo (canto inferior esquerdo). */
.assertiveness {
  position: absolute;
  z-index: 4;
  left: 14px;
  bottom: 34px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 184px;
  max-width: 60%;
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  background: rgba(7, 13, 24, 0.86);
  color: #ffffff;
  font-weight: 400;
  pointer-events: none;
}

.assert-title {
  margin-bottom: 2px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  font-weight: 400;
}

.assert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 13px;
  font-weight: 400;
}

.assert-label {
  color: #ffffff;
}

.assert-value {
  color: #ffffff;
  font-variant-numeric: tabular-nums;
}

.assert-empty {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 400;
}

@media (max-width: 680px) {
  .assertiveness {
    left: 8px;
    bottom: 36px;
    min-width: 150px;
    padding: 7px 9px;
  }

  .assert-title {
    font-size: 11px;
  }

  .assert-row,
  .assert-empty {
    font-size: 12px;
  }
}

.candle-countdown {
  position: absolute;
  z-index: 3;
  top: 50px;
  left: 50%;
  color: rgba(232, 244, 255, 0.92);
  font-size: 22px;
  font-weight: 650;
  line-height: 1.35;
  text-align: center;
  transform: translateX(-50%) scaleY(1.14);
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.72);
}

.chart-login {
  position: absolute;
  z-index: 5;
  inset: 62px 0 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(130% 120% at 50% -10%, rgba(37, 99, 235, 0.16), transparent 58%),
    radial-gradient(120% 120% at 50% 120%, rgba(124, 58, 237, 0.12), transparent 60%),
    rgba(6, 10, 18, 0.9);
  backdrop-filter: blur(8px);
}

.chart-login-card {
  width: min(460px, 100%);
  padding: 30px 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(12, 19, 32, 0.94);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
}

/* Quando a conta nao esta conectada, esconde os elementos do grafico que
   vazariam por tras do overlay de login. */
body:not(.broker-connected) .candle-countdown,
body:not(.broker-connected) .price-label,
body:not(.broker-connected) .trade-ticket,
body:not(.broker-connected) .assertiveness,
body:not(.broker-connected) .chart-empty {
  display: none;
}

.chart-login-card .login-brand {
  margin-bottom: 18px;
}

.chart-login-card .login-brand img {
  width: 62px;
  height: 62px;
}

.chart-login-card h1 {
  font-size: 22px;
}

#chartCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

#chartCanvas:active {
  cursor: grabbing;
}

.price-label {
  position: absolute;
  right: 18px;
  top: 47%;
  min-width: 82px;
  padding: 7px 10px;
  border-radius: 3px;
  background: var(--green);
  color: white;
  font-weight: 900;
  text-align: center;
}

.manual-trade-dock {
  position: absolute;
  z-index: 4;
  right: 16px;
  bottom: 14px;
  left: 16px;
  display: grid;
  grid-template-columns: minmax(130px, 180px) minmax(210px, 270px) 1fr 1fr;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid rgba(35, 48, 68, 0.95);
  border-radius: 8px;
  background: rgba(7, 13, 24, 0.95);
  box-shadow: 0 -14px 48px rgba(0, 0, 0, 0.34);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
}

body:not([data-view="operations"]) .manual-trade-dock,
.manual-trade-dock {
  display: none;
}

.broker-connected .manual-trade-dock {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

body:not(.broker-connected) .manual-panel {
  display: none;
}

.manual-panel input {
  min-height: 36px;
  padding: 0 12px;
  font-weight: 950;
}

.manual-actions-desktop {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 11px;
}

.manual-amount span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.manual-amount input {
  min-height: 42px;
  padding: 0 14px;
  font-weight: 950;
}

.manual-expiration {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.manual-time {
  min-height: 42px;
  border: 0;
  border-right: 1px solid var(--line);
  background: rgba(7, 12, 22, 0.9);
  color: var(--text);
  font-weight: 950;
}

.manual-time:last-child {
  border-right: 0;
}

.manual-time.active {
  background: linear-gradient(180deg, #0d4c9a, #082f69);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.right-rail {
  display: grid;
  grid-template-rows: auto auto minmax(120px, 1fr);
  gap: 12px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* Painel de ultimas operacoes (ocupa o espaco que sobra no rail). */
.recent-ops {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.recent-ops-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.recent-ops-head h2 {
  margin: 0;
}

.recent-ops-all {
  flex: 0 0 auto;
  padding: 5px 10px;
  border: 1px solid rgba(0, 146, 255, 0.5);
  border-radius: 7px;
  background: rgba(0, 146, 255, 0.12);
  color: #e8f4ff;
  font-size: 12px;
  font-weight: 800;
}

.recent-ops-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  overflow: hidden;
}

.recent-op {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid rgba(35, 48, 68, 0.9);
  border-radius: 8px;
  background: rgba(7, 12, 22, 0.7);
  font-size: 13px;
}

.recent-op-asset {
  overflow: hidden;
  font-weight: 800;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.recent-op-dir {
  padding: 1px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 900;
  color: #06121f;
}

.recent-op-dir.call {
  background: #16c784;
}

.recent-op-dir.put {
  background: #ea3943;
}

.recent-op-result {
  min-width: 58px;
  font-weight: 900;
  text-align: right;
}

.recent-op-result.win {
  color: var(--green);
}

.recent-op-result.loss {
  color: var(--red);
}

.recent-op-result.pending {
  color: var(--muted);
}

.recent-ops-empty {
  padding: 14px 6px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* ---------- Indicador (modo) ---------- */
.indicator-panel { display: none; }

body.indicator-mode .indicator-panel { display: block; }
body.indicator-mode .manual-panel,
body.indicator-mode .automation-panel,
/* Esconde o historico de OPERACOES, mas mantem o historico do INDICADOR (que tambem
   usa .recent-ops, porem com a classe .indicator-panel). */
body.indicator-mode .recent-ops:not(.indicator-panel) { display: none; }

/* Gráfico limpo: no Indicador o ativo é escolhido pelo sistema, então trocamos o
   seletor por um rótulo só de leitura, e some com o painel de assertividade. */
.chart-asset-readonly { display: none; }
body.indicator-mode .chart-topbar .select-box { display: none; }
body.indicator-mode .chart-asset-readonly {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  max-width: 340px;
}
body:not(.broker-connected) .chart-asset-readonly { visibility: hidden; }
.chart-asset-readonly > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.chart-asset-readonly > strong {
  color: #e8f4ff;
  font-size: 17px;
  font-weight: 800;
}
body.indicator-mode .assertiveness { display: none; }

.indicator-need-signal { margin: 8px 0 0; font-size: 13px; }
#programEntry:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Scanner da IA (parece analise em tempo real) ---------- */
.ai-scanner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(0, 146, 255, 0.28);
  border-radius: 12px;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(0, 146, 255, 0.16), rgba(0, 146, 255, 0) 60%),
    rgba(8, 17, 30, 0.6);
  overflow: hidden;
}
/* varredura horizontal sutil passando pelo card */
.ai-scanner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(0, 146, 255, 0.16) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: ai-sweep 2.6s linear infinite;
  pointer-events: none;
}
@keyframes ai-sweep { to { transform: translateX(100%); } }

.ai-radar {
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(0, 146, 255, 0.5);
  box-shadow: inset 0 0 8px rgba(0, 146, 255, 0.25);
}
.ai-radar span {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(0, 146, 255, 0.55);
  animation: ai-ping 1.8s ease-out infinite;
}
.ai-radar span:nth-child(2) { animation-delay: 0.9s; }
@keyframes ai-ping {
  0% { transform: scale(0.35); opacity: 0.9; }
  100% { transform: scale(1); opacity: 0; }
}

.ai-scanner-body { flex: 1 1 auto; min-width: 0; }
.ai-scanner-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 800;
  color: #e8f4ff;
}
.ai-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #16c784;
  box-shadow: 0 0 0 0 rgba(22, 199, 132, 0.6);
  animation: ai-live 1.4s ease-out infinite;
}
@keyframes ai-live {
  0% { box-shadow: 0 0 0 0 rgba(22, 199, 132, 0.55); }
  100% { box-shadow: 0 0 0 7px rgba(22, 199, 132, 0); }
}
.ai-scanner-status {
  margin-top: 3px;
  font-size: 12px;
  color: var(--blue-soft, #7cc4ff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* equalizador (barras subindo/descendo) */
.ai-bars {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 30px;
}
.ai-bars i {
  width: 3px;
  background: linear-gradient(180deg, #00a3ff, #0066cc);
  border-radius: 2px;
  animation: ai-bar 1s ease-in-out infinite;
}
.ai-bars i:nth-child(1) { animation-delay: 0s; }
.ai-bars i:nth-child(2) { animation-delay: 0.12s; }
.ai-bars i:nth-child(3) { animation-delay: 0.24s; }
.ai-bars i:nth-child(4) { animation-delay: 0.36s; }
.ai-bars i:nth-child(5) { animation-delay: 0.48s; }
.ai-bars i:nth-child(6) { animation-delay: 0.6s; }
.ai-bars i:nth-child(7) { animation-delay: 0.72s; }
.ai-bars i:nth-child(8) { animation-delay: 0.84s; }
@keyframes ai-bar {
  0%, 100% { height: 6px; opacity: 0.55; }
  50% { height: 26px; opacity: 1; }
}

/* progresso da analise profunda */
.ai-progress {
  height: 8px;
  margin: 4px 0 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.ai-progress span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, #0066cc, #00a3ff);
  transition: width 0.25s ease;
}
.ai-step {
  margin: 0;
  text-align: center;
  font-size: 13px;
  color: var(--blue-soft, #7cc4ff);
}

/* badge e contagem regressiva do sinal */
.ind-signal-badge {
  display: inline-block;
  margin-bottom: 8px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: #06121f;
  background: #16c784;
}
.ind-signal-badge.expired { background: #ea3943; color: #fff; }
.ind-signal-badge.programmed {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #16c784;
}
.ind-signal-badge.programmed .ai-live-dot { background: #06121f; }
.ind-signal-card.programmed {
  border-color: rgba(22, 199, 132, 0.4);
  background: linear-gradient(180deg, rgba(22, 199, 132, 0.12), rgba(22, 199, 132, 0.03));
}
.ind-signal-card.expired {
  border-color: rgba(234, 57, 67, 0.4);
  background: linear-gradient(180deg, rgba(234, 57, 67, 0.12), rgba(234, 57, 67, 0.03));
}
.ind-signal-countdown {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  font-weight: 700;
  color: #cbd5e1;
}
.ind-signal-countdown.urgent { color: #ffb020; }

.indicator-hint {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.indicator-spinner {
  width: 38px;
  height: 38px;
  margin: 10px auto 14px;
  border: 3px solid rgba(0, 146, 255, 0.25);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: indicator-spin 0.8s linear infinite;
}

@keyframes indicator-spin {
  to { transform: rotate(360deg); }
}

#indicatorAnalyzing { text-align: center; }

.ind-signal-card {
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid rgba(0, 146, 255, 0.4);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(0, 146, 255, 0.12), rgba(0, 146, 255, 0.03));
}

.ind-signal-asset {
  font-size: 18px;
  font-weight: 950;
  color: #e8f4ff;
}

.ind-signal-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.ind-signal-dir {
  padding: 3px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 950;
  color: #06121f;
}

.ind-signal-dir.call { background: #16c784; }
.ind-signal-dir.put { background: #ea3943; }

.ind-signal-time {
  font-size: 15px;
  font-weight: 800;
  color: #cbd5e1;
}

.indicator-new {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px;
  border: 0;
  background: transparent;
  color: var(--blue-soft);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.indicator-ok {
  margin: 4px 0 14px;
  color: #d6f5e2;
  font-size: 14px;
  line-height: 1.5;
}

/* Manual dock halve/double */
.manual-amount-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
}

.amount-adj {
  min-height: 42px;
  border: 1px solid var(--line);
  border-left: 0;
  background: #0a101b;
  color: #dfe6f4;
  font-size: 14px;
  font-weight: 900;
}

.manual-amount-row input {
  border-radius: 0;
  border-left: 0;
  border-right: 0;
}

.manual-amount-row .amount-adj:first-child {
  border-left: 1px solid var(--line);
  border-radius: 7px 0 0 7px;
}

.manual-amount-row .amount-adj:last-child {
  border-radius: 0 7px 7px 0;
}

.manual-amount-row input {
  min-height: 42px;
  padding: 0 10px;
  font-weight: 950;
  text-align: center;
}

.automation-fab,
.mobile-drawer-backdrop,
.drawer-head {
  display: none;
}

.panel {
  min-height: 0;
  overflow: hidden;
  padding: 14px 15px;
}

.panel h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 11px;
  font-size: 16px;
}

.panel h2 span {
  color: var(--blue);
  font-size: 24px;
}

.panel h2 .panel-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(0, 136, 255, 0.14);
  color: var(--blue);
}

.panel h2 .panel-icon svg {
  width: 17px;
  height: 17px;
}

.signal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.signal-grid > div {
  min-height: 64px;
  padding: 9px 18px 9px 0;
  border-top: 1px solid var(--line);
}

.signal-grid > div:nth-child(2n) {
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.signal-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 23px;
  line-height: 1.05;
}

.signal-grid .probability {
  color: var(--green);
  font-size: 31px;
}

.direction.call {
  color: var(--green);
}

.direction.put {
  color: var(--red);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  display: block;
  width: 62px;
  height: 34px;
  padding: 4px;
  border-radius: 999px;
  background: #2a3447;
}

.switch span::after {
  content: "";
  display: block;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #dce8f8;
  transition: transform 150ms ease;
}

.switch input:checked + span {
  background: linear-gradient(90deg, #14a846, var(--green));
}

.switch input:checked + span::after {
  transform: translateX(28px);
}

.field-row {
  display: block;
  margin-top: 9px;
}

.field-row > span {
  margin-bottom: 5px;
  font-size: 13px;
}

.stepper {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px 44px;
}

.stepper input,
.limits input {
  min-height: 36px;
  padding: 0 14px;
  font-weight: 900;
  font-size: 16px;
}

.stepper input {
  border-radius: 7px 0 0 7px;
}

.stepper button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-left: 0;
  background: #0a101b;
  color: #dfe6f4;
  font-size: 13px;
  font-weight: 900;
}

.stepper button:last-child {
  border-radius: 0 7px 7px 0;
}

.gale .segment {
  min-height: 36px;
  font-size: 16px;
}

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

.manual-action {
  min-height: 38px;
  border: 1px solid;
  border-radius: 7px;
  color: white;
  font-size: 16px;
  font-weight: 950;
}

.manual-action.call {
  border-color: rgba(34, 219, 99, 0.72);
  background: linear-gradient(180deg, #23cf5b, #118d34);
}

.manual-action.put {
  border-color: rgba(255, 56, 61, 0.72);
  background: linear-gradient(180deg, #ff4348, #a91720);
}

.manual-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  margin-top: 11px;
  border: 0;
  border-radius: 7px;
  background: linear-gradient(180deg, #29d45e, #16ad40);
  color: white;
  font-size: 16px;
  font-weight: 950;
}

.primary-action:disabled {
  cursor: wait;
  opacity: 0.64;
}

.primary-action.running {
  background: linear-gradient(180deg, #ff4c52, #b51d27);
}

.trade-status {
  min-height: 16px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.trade-status.error {
  color: #ff7a7e;
}

.trade-status.success {
  color: var(--green);
}

.sync-status {
  min-height: 16px;
  margin: 4px 0 0;
  color: #8ea2bd;
  font-size: 13px;
  font-weight: 700;
}

.automation-status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.automation-status-item {
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(35, 48, 68, 0.9);
  border-radius: 7px;
  background: rgba(7, 12, 22, 0.74);
}

.automation-status-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.automation-status-item strong {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  font-size: 14px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-button {
  display: grid;
  grid-template-columns: 38px 1fr 24px;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 18px;
  border: 1px solid #0076e6;
  border-radius: 8px;
  background: rgba(5, 16, 31, 0.94);
  color: white;
  font-size: 15px;
  font-weight: 950;
  text-align: left;
}

.history-button span {
  color: var(--blue);
  font-size: 30px;
}

.history-button strong {
  font-size: 30px;
  line-height: 1;
}

dialog {
  width: min(980px, calc(100vw - 40px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0b111d;
  color: var(--text);
  padding: 0;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
  margin: 0;
  font-size: 20px;
}

.dialog-head button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0a101b;
  color: var(--text);
  font-size: 24px;
}

.history-table-wrap {
  max-height: 520px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.status-win {
  color: var(--green);
}

.status-lose {
  color: var(--red);
}

.origin-tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.origin-tag.manual {
  border: 1px solid rgba(159, 176, 196, 0.4);
  color: #c7d4e6;
}

.origin-tag.auto {
  border: 1px solid rgba(0, 146, 255, 0.5);
  background: rgba(0, 146, 255, 0.14);
  color: var(--blue-soft);
}

@media (max-height: 820px) and (min-width: 981px) {
  .topbar {
    min-height: 70px;
    padding: 10px 20px;
  }

  .sidebar {
    gap: 12px;
    padding: 12px;
  }

  .brand {
    min-height: 44px;
  }

  .brand-logo {
    width: 42px;
    height: 42px;
  }

  .nav-item {
    min-height: 42px;
  }

  .workspace {
    gap: 10px;
    padding: 10px;
  }

  .chart-wrap {
    inset: 58px 0 0;
  }

  .chart-login {
    inset: 58px 0 0;
  }

  .right-rail {
    grid-template-rows: auto auto 56px;
    gap: 10px;
  }

  .panel {
    padding: 16px;
  }

  .panel h2 {
    margin-bottom: 12px;
  }

  .signal-grid > div {
    min-height: 54px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .field-row {
    margin-top: 8px;
  }

  .field-row > span {
    margin-bottom: 6px;
  }

  .stepper input,
  .stepper button,
  .limits input,
  .gale .segment {
    min-height: 40px;
  }

  .primary-action {
    min-height: 48px;
  }

  .history-button {
    min-height: 56px;
  }
}

@media (max-width: 1320px) {
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .shell {
    min-height: 100dvh;
    height: auto;
    overflow: visible;
  }

  .main {
    overflow: visible;
  }

  .workspace {
    grid-template-columns: 1fr;
    overflow: visible;
  }

  .right-rail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    overflow: visible;
  }

  .history-button {
    grid-column: 1 / -1;
  }

  .chart-panel {
    height: 640px;
  }

  .training-grid-v2 {
    grid-template-columns: 1fr;
  }

  .training-hero {
    min-height: 300px;
  }

  .training-hero-content {
    padding: 28px 20px;
  }
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
    width: 100vw;
    max-width: 100vw;
  }

  .shell.sidebar-collapsed {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    z-index: 10;
    inset: 0 auto 0 0;
    width: 280px;
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform 160ms ease;
  }

  .shell.sidebar-collapsed .sidebar {
    display: grid;
    padding: 16px 14px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    opacity: 1;
    pointer-events: auto;
  }

  /* No celular o menu e sempre drawer completo (sem rail de icones). */
  .shell.sidebar-collapsed .brand-text,
  .shell.sidebar-collapsed .nav-label {
    display: block;
  }

  .shell.sidebar-collapsed .nav-item {
    justify-content: flex-start;
    gap: 13px;
    padding: 0 16px;
  }

  .sidebar-toggle {
    display: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
  }

  .sidebar.open ~ .sidebar-backdrop {
    display: block;
    position: fixed;
    z-index: 9;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
  }

  /* Celular: botao de menu visivel; a faixa do grafico vira [menu] [Ativo] [Saldo]. */
  .menu-button {
    display: grid;
    place-items: center;
  }

  /* Barra global so aparece fora da tela de operacoes (Treinamentos/Suporte). */
  body:not([data-view="operations"]) .topbar {
    display: flex;
  }

  .chart-topbar {
    gap: 8px;
    padding: 9px 10px;
  }

  .chart-topbar .select-box {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
  }

  .chart-topbar .balance-box {
    min-width: 0;
    flex: 0 0 auto;
  }

  .top-spacer {
    display: none;
  }

  .main,
  .workspace,
  .chart-panel {
    width: 100%;
    max-width: 100vw;
  }

  .workspace {
    padding: 14px;
  }

  .chart-panel {
    height: min(560px, 62dvh);
    min-height: 430px;
  }

  .asset-menu {
    width: min(420px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
  }

  .chart-wrap {
    inset: 56px 0 0;
  }

  .chart-login {
    inset: 56px 0 0;
    padding: 14px;
  }

  .chart-login-card {
    width: min(460px, calc(100vw - 28px));
  }

  .right-rail {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .content-view {
    padding: 14px;
  }

  .page-panel {
    padding: 20px;
  }

  .support-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  body[data-view="operations"] {
    overflow: hidden;
  }

  body[data-view="operations"] .shell,
  body[data-view="operations"] .main {
    height: 100dvh;
    overflow: hidden;
  }

  .topbar {
    gap: 10px;
  }

  body[data-view="operations"] .topbar {
    min-height: 58px;
    padding: 4px 10px;
  }

  body[data-view="operations"] .menu-button {
    width: 44px;
    height: 44px;
  }

  .brand strong {
    font-size: 24px;
  }

  .login-card {
    padding: 18px;
    width: min(100%, calc(100vw - 44px));
  }

  .chart-login-card {
    width: min(420px, calc(100vw - 44px));
  }

  .panel,
  .chart-toolbar {
    padding: 16px;
  }

  body[data-view="operations"] .workspace {
    display: block;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    padding: 8px;
    max-width: 100vw;
  }

  body[data-view="operations"] .chart-panel {
    height: 100%;
    min-height: 0;
    max-width: calc(100vw - 16px);
  }

  .chart-topbar .select-box,
  .chart-topbar .balance-box {
    padding: 5px 9px 6px;
  }

  .chart-topbar .select-box > span,
  .chart-topbar .balance-box > span {
    font-size: 11px;
  }

  .chart-topbar .balance-box {
    min-width: 0;
  }

  .chart-topbar .balance-box strong {
    font-size: 15px;
  }

  .chart-topbar .asset-trigger {
    min-height: 34px;
  }

  .chart-topbar .asset-trigger strong {
    font-size: 15px;
  }

  /* Faixa do grafico no topo + espaco embaixo para o dock/horario. */
  body[data-view="operations"] .chart-wrap,
  body[data-view="operations"] .chart-login {
    inset: 56px 0 126px;
  }

  body[data-view="operations"] .manual-trade-dock {
    display: grid;
    right: 8px;
    bottom: 8px;
    left: 8px;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 9px;
  }

  body[data-view="operations"] .manual-expiration {
    grid-column: 2;
  }

  body[data-view="operations"] .manual-amount input,
  body[data-view="operations"] .manual-time,
  body[data-view="operations"] .manual-action {
    min-height: 38px;
  }

  body[data-view="operations"] .manual-action {
    font-size: 15px;
  }

  body[data-view="operations"] .price-label {
    right: 8px;
    min-width: 70px;
    padding: 6px 8px;
    font-size: 13px;
  }

  body[data-view="operations"] .candle-countdown {
    top: 40px;
    font-size: 17px;
  }

  body[data-view="operations"] .automation-fab {
    position: fixed;
    z-index: 55;
    right: 14px;
    bottom: 154px;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border: 1px solid rgba(0, 146, 255, 0.6);
    border-radius: 50%;
    background: linear-gradient(180deg, #0d4c9a, #082f69);
    color: #dbeafe;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), 0 0 18px rgba(0, 146, 255, 0.22);
  }

  body[data-view="operations"] .automation-fab svg {
    width: 22px;
    height: 22px;
  }

  body[data-view="operations"] .mobile-drawer-backdrop {
    position: fixed;
    z-index: 45;
    inset: 0;
    display: block;
    background: rgba(0, 0, 0, 0.48);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
  }

  body[data-view="operations"].mobile-automation-open .mobile-drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body[data-view="operations"] .right-rail {
    position: fixed;
    z-index: 50;
    right: 10px;
    bottom: 10px;
    left: 10px;
    display: block;
    max-height: min(76dvh, 660px);
    padding: 12px;
    overflow: auto;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    background: rgba(7, 13, 24, 0.98);
    box-shadow: 0 -22px 70px rgba(0, 0, 0, 0.58);
    transform: translateY(calc(100% + 24px));
    opacity: 0;
    pointer-events: none;
    transition: transform 180ms ease, opacity 180ms ease;
  }

  body[data-view="operations"].mobile-automation-open .right-rail {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  body[data-view="operations"] .drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
  }

  body[data-view="operations"] .drawer-head strong {
    font-size: 18px;
  }

  body[data-view="operations"] .drawer-head button {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #0a101b;
    color: var(--text);
    font-size: 24px;
  }

  body[data-view="operations"] .right-rail .panel {
    margin-bottom: 10px;
    padding: 14px;
  }

  body[data-view="operations"] .manual-panel {
    display: none;
  }

  body[data-view="operations"] .history-button {
    min-height: 54px;
    margin-top: 0;
  }

  .signal-grid {
    grid-template-columns: 1fr;
  }

  .signal-grid > div:nth-child(2n) {
    padding-left: 0;
    border-left: 0;
  }

  .limits {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .lesson-card {
    grid-template-columns: 1fr;
  }

  .lesson-thumb {
    max-width: 120px;
  }

  .history-button {
    grid-template-columns: 44px 1fr 26px;
    padding: 0 18px;
  }
}
.login-screen {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 18%, rgba(0, 145, 255, 0.22), transparent 34%),
    linear-gradient(180deg, #07101b 0%, #05080d 100%);
}

.login-card {
  width: min(440px, 100%);
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(10, 17, 29, 0.92);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.36);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}

.login-brand img {
  width: 70px;
  height: 70px;
}

.login-brand strong {
  display: block;
  font-size: 32px;
  line-height: 1;
}

.login-brand span {
  display: block;
  color: var(--blue);
  font-weight: 900;
  text-align: right;
}

.login-card h1 {
  margin: 0 0 18px;
  font-size: 24px;
}

.login-card label {
  display: block;
  margin-top: 14px;
}

.login-card label span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 800;
}

.login-card input {
  min-height: 52px;
  padding: 0 16px;
  font-size: 18px;
  font-weight: 800;
}

.login-card .primary-action {
  margin-top: 18px;
}

.login-create-account {
  display: block;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  text-decoration: none;
}

.login-create-account strong {
  color: var(--blue-soft);
}

.login-create-account:hover strong {
  text-decoration: underline;
}

body:not(.broker-connected) .chart-login {
  inset: 62px 0 0;
}

/* Sem conta conectada: esconde o painel da direita (automacao + historico)
   e o botao flutuante, deixando apenas o grafico/login. */
body:not(.broker-connected) .right-rail,
body:not(.broker-connected) .automation-fab {
  display: none;
}

body:not(.broker-connected) .workspace {
  grid-template-columns: minmax(0, 1fr);
}

/* No PC, a barra superior so faz sentido na tela de operacoes (Ativo/Saldo).
   Em Treinamentos/Suporte ela ficaria vazia, entao some e a pagina sobe. */
@media (min-width: 981px) {
  body:not([data-view="operations"]) .topbar {
    display: none;
  }
}

.admin-body {
  min-height: 100%;
  overflow: auto;
}

/* Gate de senha */
.admin-gate {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
  background:
    radial-gradient(130% 120% at 50% -10%, rgba(37, 99, 235, 0.16), transparent 58%),
    linear-gradient(180deg, #07101b 0%, #05080d 100%);
}

.admin-gate-card {
  width: min(420px, 100%);
  padding: 30px 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  background: rgba(12, 19, 32, 0.94);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
}

.admin-gate-card h1 {
  margin: 0 0 6px;
  font-size: 24px;
}

.admin-gate-hint {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 14px;
}

.admin-gate-card .primary-action {
  margin-top: 16px;
}

/* Painel */
.admin-shell {
  width: min(1080px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 40px;
}

.admin-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 12px 0;
  background: linear-gradient(180deg, #05080d 70%, rgba(5, 8, 13, 0));
}

.admin-header .brand {
  min-height: auto;
  padding: 0;
  border-bottom: 0;
}

.admin-header .brand-logo {
  width: 56px;
  height: 56px;
}

.admin-header-actions {
  display: flex;
  gap: 10px;
}

.admin-small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(0, 146, 255, 0.52);
  border-radius: 8px;
  background: rgba(0, 146, 255, 0.1);
  color: #e8f4ff;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.admin-small-button.danger {
  border-color: rgba(255, 56, 61, 0.6);
  background: rgba(255, 56, 61, 0.12);
}

.admin-panel {
  display: grid;
  gap: 16px;
}

/* Abas */
.admin-tabs {
  display: flex;
  gap: 6px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(10, 17, 29, 0.88);
}

.admin-tab {
  flex: 1;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  font-size: 15px;
}

.admin-tab.active {
  background: linear-gradient(180deg, #0d4c9a, #082f69);
  color: #fff;
  box-shadow: inset 0 0 0 1px var(--blue);
}

.admin-section {
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 12px;
  background: rgba(10, 17, 29, 0.88);
}

.admin-section > h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.admin-section-sub {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.admin-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.admin-section-head h2 {
  margin: 0 0 4px;
  font-size: 20px;
}

.admin-grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.admin-field {
  display: block;
  margin-top: 14px;
}

.admin-field span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-weight: 800;
  font-size: 14px;
}

.admin-field input,
.admin-field textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #080e18;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  outline: none;
  resize: vertical;
}

.admin-field input:focus,
.admin-field textarea:focus {
  border-color: rgba(0, 146, 255, 0.6);
}

.admin-lessons {
  display: grid;
  gap: 14px;
}

.admin-lesson {
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 11px;
  background: rgba(7, 12, 22, 0.7);
}

.admin-lesson-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-lesson-head h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 17px;
}

.admin-badge {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-lesson-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.admin-check input {
  width: 18px;
  height: 18px;
  min-height: auto;
  cursor: pointer;
}

.admin-cover-row {
  display: flex;
  gap: 14px;
  align-items: center;
}

.admin-cover-thumb {
  display: grid;
  place-items: center;
  width: 160px;
  height: 90px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #061020;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.admin-cover-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Miniatura do banner de boas-vindas (formato largo). */
.admin-cover-thumb-wide {
  width: 256px;
  height: 72px;
}

.admin-subhead {
  margin: 22px 0 0;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 15px;
  color: var(--blue-soft);
}

.admin-grid.three {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.admin-html-blocks {
  display: grid;
  gap: 12px;
  margin: 14px 0;
}

.admin-html-block {
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  background: rgba(7, 12, 22, 0.7);
}

.admin-html-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.admin-html-block-head select {
  min-height: 34px;
  width: auto;
  min-width: 110px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #080e18;
  color: var(--text);
  font-weight: 700;
}

.admin-html-block textarea {
  width: 100%;
  min-height: 90px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #060c15;
  color: #e8f4ff;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 13px;
  outline: none;
  resize: vertical;
}

@media (max-width: 720px) {
  .admin-grid.three {
    grid-template-columns: 1fr;
  }
}

.admin-cover-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.admin-cover-status {
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

.admin-savebar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(8, 13, 24, 0.96);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
}

.admin-savebar .trade-status {
  margin: 0;
}

.admin-save {
  width: auto;
  min-width: 240px;
  margin-top: 0;
}

@media (max-width: 720px) {
  .admin-header {
    flex-wrap: wrap;
  }

  .admin-section-head,
  .admin-grid.two,
  .admin-cover-row {
    flex-direction: column;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .admin-lesson-head {
    flex-wrap: wrap;
  }

  .admin-savebar {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-save {
    width: 100%;
    min-width: 0;
  }
}
