:root {
  --signal-panel-width: 520px;
  --green: #22ff9a;
  --green-bright: #7dff4a;
  --green-dim: #0d3d28;
  --green-glow: rgba(34, 255, 154, 0.45);
  --bg-deep: #040806;
  --bg-panel: #07120c;
  --border: rgba(34, 255, 154, 0.35);
  --text: #e8fff3;
  --text-muted: #8fb9a8;
  --header-bg: #ffffff;
  --header-text: #0a0a0a;
}

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

html {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
  color: var(--text);
  font-family: "Rajdhani", system-ui, sans-serif;
}

.app {
  flex: 1 1 auto;
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 100dvh;
}

/* —— Broker (esquerda) —— */
.broker-zone {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #0c0c0c;
}

.broker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.25rem;
  background: var(--header-bg);
  color: var(--header-text);
  border-bottom: 1px solid #e8e8e8;
  flex-shrink: 0;
}

.broker-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.broker-logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: linear-gradient(145deg, #1a237e 0%, #0d47a1 40%, #000 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.15);
}

.broker-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.lang-pill {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #ddd;
  background: #fafafa;
}

.btn-register {
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.45rem 1rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(180deg, #1976d2, #1565c0);
  color: #fff;
  cursor: pointer;
}

.btn-register:hover {
  filter: brightness(1.05);
}

.iframe-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
}

.broker-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  background: #111;
}

.app.is-resizing .broker-frame {
  pointer-events: none;
}

.app.is-resizing {
  cursor: col-resize;
  user-select: none;
}

/* Divisor arrastável (tablet em pé / PC; escondido no mobile estreito) */
.panel-resizer {
  display: none;
  flex: 0 0 14px;
  width: 14px;
  position: relative;
  z-index: 30;
  align-self: stretch;
  min-height: 120px;
  flex-shrink: 0;
  cursor: col-resize;
  touch-action: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(6, 18, 12, 0.95), rgba(13, 61, 40, 0.5), rgba(6, 18, 12, 0.95));
  box-shadow: inset 0 0 12px rgba(34, 255, 154, 0.12);
}

.panel-resizer-grips {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 12px 0;
  pointer-events: none;
}

.panel-resizer-grip {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green-glow), 0 0 2px rgba(125, 255, 74, 0.8);
}

.panel-resizer:hover,
.panel-resizer:focus-visible {
  background: linear-gradient(
    180deg,
    rgba(13, 61, 40, 0.95),
    rgba(34, 255, 154, 0.18),
    rgba(13, 61, 40, 0.95)
  );
  box-shadow:
    inset 0 0 18px rgba(34, 255, 154, 0.2),
    0 0 16px rgba(34, 255, 154, 0.15);
  outline: none;
}

.panel-resizer:active {
  background: rgba(34, 255, 154, 0.22);
}

@media (min-width: 768px) {
  /* PC: sem rolagem na página — só rolagem interna no painel de sinais se precisar */
  html {
    height: 100%;
    overflow: hidden;
  }

  body {
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
    overflow-x: clip;
  }

  .app {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    overflow: hidden;
  }

  .broker-zone {
    min-width: 240px;
    min-height: 0;
    overflow: hidden;
  }

  .panel-resizer {
    display: flex;
    align-self: stretch;
    min-height: 0;
  }

  .signal-panel {
    width: var(--signal-panel-width);
    max-width: min(960px, calc(100vw - 280px));
    min-width: 260px;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow-x: clip;
    overflow-y: auto;
  }
}

/* —— Painel de sinais (direita) —— */
.signal-panel {
  position: relative;
  flex-shrink: 0;
  align-self: stretch;
  overflow-x: clip;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 1.35rem 1.15rem 1.5rem;
  background:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(34, 255, 154, 0.12), transparent 55%),
    linear-gradient(165deg, var(--bg-panel) 0%, #030705 100%);
  box-shadow:
    inset 0 0 60px rgba(34, 255, 154, 0.04),
    -8px 0 32px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.signal-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid var(--border);
  border-radius: 0;
  pointer-events: none;
  box-shadow:
    0 0 20px var(--green-glow),
    inset 0 0 30px rgba(34, 255, 154, 0.06);
  margin: 6px;
  opacity: 0.9;
}

.signal-scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.12) 2px,
    rgba(0, 0, 0, 0.12) 4px
  );
  opacity: 0.35;
  z-index: 0;
}

.signal-grid-bg {
  position: absolute;
  inset: -40% -20%;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(34, 255, 154, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 255, 154, 0.06) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, black 20%, transparent 75%);
  z-index: 0;
}

.signal-header,
.signal-form,
.signal-results {
  position: relative;
  z-index: 1;
}

/* Dropdown do seletor: filhos não vencem tios no mesmo nível — sem isso,
   .signal-results (mesmo z-index, depois no DOM) cobre o painel da lista. */
.signal-panel:has(.asset-picker-trigger[aria-expanded="true"]) .signal-form {
  z-index: 12;
}

.signal-header {
  text-align: center;
}

.signal-logo-ring {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 0 auto 0.5rem;
  border-radius: 50%;
  background: conic-gradient(from 200deg, var(--green-dim), var(--green), var(--green-bright), var(--green-dim));
  padding: 3px;
  box-shadow: 0 0 24px var(--green-glow);
  animation: pulse-ring 4s ease-in-out infinite;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes pulse-ring {
  0%,
  100% {
    box-shadow: 0 0 18px var(--green-glow);
  }
  50% {
    box-shadow: 0 0 32px rgba(125, 255, 74, 0.5);
  }
}

.signal-logo-ring::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #0f2418, #050a08);
  z-index: 0;
}

.signal-logo-icon {
  position: relative;
  z-index: 1;
  width: 36px;
  height: 36px;
  color: var(--green);
  filter: drop-shadow(0 0 6px var(--green-glow));
  pointer-events: none;
}

.signal-product {
  position: relative;
  margin: 0 auto 0.35rem;
  font-family: "Orbitron", sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--green-bright);
  text-shadow: 0 0 12px var(--green-glow);
}

.signal-welcome {
  font-family: "Orbitron", sans-serif;
  font-size: clamp(1rem, 3.5vw, 1.15rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  margin: 0 0 0.5rem;
  background: linear-gradient(90deg, #b8ffd9, var(--green), var(--green-bright));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px var(--green-glow);
}

.signal-tip {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text-muted);
  max-width: 280px;
  margin-inline: auto;
}

.signal-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(34, 255, 154, 0.75);
}

.signal-select {
  appearance: none;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.65rem 2.25rem 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background:
    linear-gradient(180deg, rgba(13, 61, 40, 0.5), rgba(4, 12, 8, 0.95)) padding-box,
    linear-gradient(135deg, rgba(34, 255, 154, 0.3), transparent) border-box;
  color: var(--text);
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2322ff9a' d='M3 4.5L6 8l3-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
}

.signal-select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 1px var(--green-glow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Seletor de ativos (substitui <select> nativo — lista legível no tema escuro) */
.asset-picker {
  position: relative;
  z-index: 8;
}

.asset-picker:has(.asset-picker-trigger[aria-expanded="true"]) {
  z-index: 24;
}

.asset-picker-trigger {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.6rem 2.25rem 0.6rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(13, 61, 40, 0.55), rgba(4, 12, 8, 0.98));
  color: var(--text);
  cursor: pointer;
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.asset-picker-trigger:hover {
  border-color: rgba(34, 255, 154, 0.55);
}

.asset-picker-trigger[aria-expanded="true"] {
  border-color: var(--green);
  box-shadow: 0 0 0 1px var(--green-glow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.asset-picker-icon-wrap {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  border: 1px solid rgba(34, 255, 154, 0.35);
  background: radial-gradient(circle at 35% 30%, rgba(34, 255, 154, 0.2), rgba(4, 12, 8, 0.95));
  box-shadow: 0 0 12px rgba(34, 255, 154, 0.15);
}

.asset-picker-icon-wrap[data-kind="pares"] {
  color: #b8ffd9;
}

.asset-picker-icon-wrap[data-kind="criptos"] {
  color: #7dff4a;
}

.asset-picker-icon-wrap[data-kind="acoes"] {
  color: #9ecbff;
}

.asset-picker-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-picker-chev {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.55rem;
  color: var(--green);
  pointer-events: none;
}

.asset-picker-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 2;
  max-height: min(52vh, 420px);
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #0c1812 0%, #050a08 55%, #040806 100%);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.65),
    0 0 24px rgba(34, 255, 154, 0.12);
  scrollbar-color: var(--green) rgba(0, 0, 0, 0.4);
  scrollbar-width: thin;
}

.asset-picker-panel[hidden] {
  display: none !important;
}

.asset-picker-group-title {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0;
  padding: 0.45rem 0.75rem 0.35rem;
  font-family: "Orbitron", sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: rgba(34, 255, 154, 0.85);
  background: #06120e;
  border-bottom: 1px solid rgba(34, 255, 154, 0.15);
}

.asset-picker-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: none;
  border-bottom: 1px solid rgba(34, 255, 154, 0.08);
  background: #050a08;
  color: #f0fff6;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.asset-picker-option:hover,
.asset-picker-option:focus-visible {
  background: rgba(34, 255, 154, 0.12);
  outline: none;
}

.asset-picker-option.is-active {
  background: rgba(34, 255, 154, 0.18);
  color: var(--green-bright);
}

.asset-picker-option .asset-tag {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(184, 255, 217, 0.55);
}

.asset-picker-option .asset-picker-icon-wrap--sm {
  width: 30px;
  height: 30px;
  font-size: 0.58rem;
}

.btn-generate {
  position: relative;
  margin-top: 0.35rem;
  padding: 0.95rem 1rem;
  border: none;
  border-radius: 12px;
  font-family: "Orbitron", sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #021208;
  cursor: pointer;
  background: linear-gradient(180deg, var(--green-bright) 0%, var(--green) 45%, #00c853 100%);
  box-shadow:
    0 0 28px var(--green-glow),
    0 4px 0 #006b3a,
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn-generate:hover {
  transform: translateY(-1px);
  box-shadow:
    0 0 36px rgba(125, 255, 74, 0.55),
    0 5px 0 #006b3a,
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-generate:active {
  transform: translateY(2px);
  box-shadow:
    0 0 20px var(--green-glow),
    0 2px 0 #006b3a,
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-generate-glow {
  position: absolute;
  inset: -2px;
  border-radius: 14px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  opacity: 0.25;
  animation: sweep 2.5s linear infinite;
  pointer-events: none;
}

@keyframes sweep {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

.btn-generate-label {
  position: relative;
  z-index: 1;
}

.signal-analysis {
  position: relative;
  z-index: 4;
  margin: 1rem 0 1.15rem;
  min-height: 200px;
  border-radius: 14px;
  border: 1px solid rgba(34, 255, 154, 0.25);
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(34, 255, 154, 0.1), transparent 55%),
    linear-gradient(165deg, rgba(8, 22, 14, 0.95), rgba(3, 8, 5, 0.98));
  box-shadow:
    inset 0 0 40px rgba(34, 255, 154, 0.06),
    0 0 24px rgba(34, 255, 154, 0.08);
  overflow: hidden;
}

.signal-analysis[hidden] {
  display: none !important;
}

.signal-analysis-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 1.25rem 1rem 1.35rem;
  text-align: center;
}

.signal-analysis-radar {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(34, 255, 154, 0.35);
  box-shadow: 0 0 20px rgba(34, 255, 154, 0.2), inset 0 0 20px rgba(34, 255, 154, 0.08);
  background: radial-gradient(circle at 50% 50%, rgba(13, 61, 40, 0.4), rgba(4, 10, 7, 0.95));
}

.signal-analysis-radar-sweep {
  position: absolute;
  inset: 4px;
  display: block;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0deg, transparent 240deg, rgba(34, 255, 154, 0.35) 300deg, transparent 360deg);
  animation: radar-spin 2.2s linear infinite;
}

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

.signal-analysis-title {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--green-bright);
  text-shadow: 0 0 14px var(--green-glow);
  animation: analysis-pulse 1.4s ease-in-out infinite;
}

@keyframes analysis-pulse {
  0%,
  100% {
    opacity: 0.85;
  }
  50% {
    opacity: 1;
  }
}

.signal-analysis-scanlines {
  display: flex;
  gap: 0.35rem;
  height: 10px;
  align-items: center;
}

.signal-analysis-scanlines span {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: rgba(34, 255, 154, 0.25);
  animation: scan-bar 1.1s ease-in-out infinite;
}

.signal-analysis-scanlines span:nth-child(2) {
  animation-delay: 0.15s;
}

.signal-analysis-scanlines span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes scan-bar {
  0%,
  100% {
    transform: scaleX(0.35);
    opacity: 0.35;
  }
  50% {
    transform: scaleX(1);
    opacity: 1;
  }
}

.signal-analysis-progress {
  width: 100%;
  max-width: 260px;
  height: 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(34, 255, 154, 0.2);
  overflow: hidden;
}

.signal-analysis-progress-bar {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--green-dim), var(--green), var(--green-bright));
  box-shadow: 0 0 12px var(--green-glow);
}

.signal-analysis-progress-bar.signal-analysis-progress-bar--run {
  animation: analysis-progress-fill 15s linear forwards;
}

@keyframes analysis-progress-fill {
  from {
    width: 0%;
  }
  to {
    width: 100%;
  }
}

.signal-analysis-hint {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text-muted);
  max-width: 280px;
  min-height: 2.6em;
}

.signal-results {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: auto;
}

.signal-results.is-waiting {
  opacity: 0.35;
  pointer-events: none;
  filter: grayscale(0.2);
}

.result-card {
  padding: 0.95rem 1.05rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #0d2418 0%, #050a08 100%);
  box-shadow:
    0 0 20px rgba(34, 255, 154, 0.1),
    inset 0 0 24px rgba(34, 255, 154, 0.04);
}

.result-title {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(184, 255, 217, 0.9);
}

.result-value {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--green);
  text-shadow: 0 0 12px var(--green-glow);
  min-height: 1.5em;
  line-height: 1.35;
}

.result-value--multiline {
  font-family: "Rajdhani", sans-serif;
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.4;
}

.result-value.is-flash {
  animation: flash 0.45s ease;
}

@keyframes flash {
  0% {
    color: #fff;
    text-shadow: 0 0 20px #fff;
  }
  100% {
    color: var(--green);
    text-shadow: 0 0 10px var(--green-glow);
  }
}

@media (max-width: 767px) {
  /* Preenche a viewport: corretora (1fr) + gerador com rolagem interna — sem faixa preta embaixo */
  html,
  body {
    height: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  .app {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) minmax(0, min(46dvh, 50svh));
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    max-height: 100dvh;
    overflow: hidden;
  }

  .broker-header {
    padding: 0.45rem 0.75rem;
  }

  .broker-brand {
    font-size: 0.88rem;
  }

  .btn-register {
    padding: 0.38rem 0.75rem;
    font-size: 0.82rem;
  }

  .broker-zone {
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .iframe-wrap {
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
  }

  .broker-frame {
    /* iOS / WebKit: evita largura 0 em alguns casos */
    min-width: 100%;
    min-height: 100%;
  }

  .signal-panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    min-height: 0;
    max-height: none;
    flex-shrink: 1;
    overflow-y: auto;
    overflow-x: clip;
  }

  .signal-panel::before {
    margin: 6px 6px 0;
  }
}

