:root {
  color-scheme: dark;
  --bg: #0A0F1A;
  --surface: #111a2b;
  --surface-2: #17223a;
  --line: #22304a;
  --text: #e8eef8;
  --muted: #8594ad;
  --brand: #ffb547;
  --call: #2bd67b;
  --call-soft: rgba(43, 214, 123, .14);
  --put: #ff5a6a;
  --put-soft: rgba(255, 90, 106, .14);
  --draw: #9aa6bb;
  --ema9: #ffb547;
  --ema21: #6fa8ff;
  --bb: rgba(160, 176, 205, .35);
  --radius: 18px;
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Manrope", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.label { color: var(--muted); font-size: 12px; letter-spacing: .04em; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

/* topo */
.top {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-name { font-family: var(--f-display); font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.pulse {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 0 rgba(255, 181, 71, .6);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 181, 71, .55); }
  70% { box-shadow: 0 0 0 10px rgba(255, 181, 71, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 181, 71, 0); }
}
.asset-btn {
  margin-left: auto;
  display: flex; flex-direction: column; align-items: flex-end;
  background: none; border: 0; cursor: pointer; padding: 2px 4px; line-height: 1.2;
}
#assetLabel { font-weight: 700; }
.asset-meta { font-size: 11px; color: var(--muted); font-family: var(--f-mono); }
.conn { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.conn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--draw); }
.conn[data-state="on"] .dot { background: var(--call); }
.conn[data-state="err"] .dot { background: var(--put); }

main { flex: 1; padding: 16px 16px 96px; }
.screen { display: none; flex-direction: column; gap: 14px; }
.screen[data-active="true"] { display: flex; }

.price-row { display: flex; justify-content: space-between; align-items: flex-end; }
.price { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.candle-timer { text-align: right; }
.big-timer { font-size: 20px; font-weight: 700; color: var(--brand); }

/* card do sinal */
.signal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  transition: background .3s, border-color .3s;
}
.signal-card[data-dir="CALL"] { background: linear-gradient(160deg, var(--call-soft), var(--surface) 70%); border-color: rgba(43, 214, 123, .45); }
.signal-card[data-dir="PUT"] { background: linear-gradient(160deg, var(--put-soft), var(--surface) 70%); border-color: rgba(255, 90, 106, .45); }
.signal-card.flash { animation: flash .9s ease-out; }
@keyframes flash { 0% { transform: scale(.97); } 60% { transform: scale(1.01); } 100% { transform: scale(1); } }
.sc-head { display: flex; justify-content: space-between; align-items: center; }
.strength { display: flex; gap: 3px; }
.strength i { width: 18px; height: 5px; border-radius: 3px; background: var(--line); }
.signal-card[data-dir="CALL"] .strength i.on { background: var(--call); }
.signal-card[data-dir="PUT"] .strength i.on { background: var(--put); }
.sc-main { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sc-dir {
  font-family: var(--f-display); font-weight: 800;
  font-size: clamp(44px, 14vw, 64px); line-height: 1; letter-spacing: -.03em;
  color: var(--muted);
}
.signal-card[data-dir="none"] .sc-dir { font-size: 30px; white-space: nowrap; }
.signal-card[data-dir="CALL"] .sc-dir { color: var(--call); }
.signal-card[data-dir="PUT"] .sc-dir { color: var(--put); }
.sc-side { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kv { display: flex; justify-content: space-between; gap: 14px; font-size: 13px; }
.kv span { color: var(--muted); }
.sc-reasons { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); display: grid; gap: 2px; }
.sc-progress { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.sc-progress div { height: 100%; width: 0; background: var(--brand); transition: width 1s linear; }

/* gráfico */
.chart-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 10px 8px; }
#chart { width: 100%; height: 220px; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 11px; color: var(--muted); padding: 6px 4px 0; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.lg-ema9 { background: var(--ema9); } .lg-ema21 { background: var(--ema21); } .lg-bb { background: var(--muted); }
#rsiNow { margin-left: auto; }

.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 2px 8px; margin-top: 8px; }
.section-head h2 { white-space: nowrap; margin: 0; font-family: var(--f-display); font-weight: 600; font-size: 17px; letter-spacing: -.01em; }

.score { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.score div, .stat-grid div {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.score b, .stat-grid b { font-family: var(--f-mono); font-size: 18px; font-variant-numeric: tabular-nums; }
.score span, .stat-grid span { font-size: 11px; color: var(--muted); }
.pos { color: var(--call); } .neg { color: var(--put); }

/* feed */
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.feed li {
  display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 10px;
  padding: 10px 2px; border-bottom: 1px solid var(--line); font-size: 13px;
}
.feed .dir { font-weight: 800; font-family: var(--f-display); font-size: 15px; }
.feed .dir.CALL { color: var(--call); } .feed .dir.PUT { color: var(--put); }
.feed .meta { color: var(--muted); font-family: var(--f-mono); font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 99px; letter-spacing: .04em; }
.pill.WIN { background: var(--call-soft); color: var(--call); }
.pill.LOSS { background: var(--put-soft); color: var(--put); }
.pill.EMPATE, .pill.ABERTO { background: var(--surface-2); color: var(--draw); }
.feed .empty { display: block; color: var(--muted); border: 0; padding: 12px 0; }

/* desempenho */
.bt-hero { display: flex; align-items: center; gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.gauge { flex: 0 0 120px; }
.gauge svg { display: block; width: 120px; height: 120px; }
.bt-verdict { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.bt-verdict strong { font-family: var(--f-display); font-size: 20px; color: var(--text); line-height: 1.15; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.note { font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }
.note b { color: var(--text); }

/* ajustes */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 99px;
  padding: 8px 14px; cursor: pointer; font-weight: 500; font-size: 14px;
}
.chip[aria-checked="true"] { border-color: var(--brand); color: var(--brand); background: rgba(255, 181, 71, .08); }
.strat { display: flex; flex-direction: column; gap: 8px; }
.strat button {
  text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 14px;
  padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 2px;
}
.strat button b { font-family: var(--f-display); font-weight: 600; font-size: 16px; }
.strat button span { color: var(--muted); font-size: 13px; }
.strat button[aria-checked="true"] { border-color: var(--brand); }
.strat button[aria-checked="true"] b { color: var(--brand); }
input[type="range"] { width: 100%; accent-color: var(--brand); }
.toggle { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 14px; cursor: pointer; align-self: flex-start; }
.toggle[aria-pressed="true"] { border-color: var(--brand); color: var(--brand); }
.disclaimer { font-size: 12px; color: var(--muted); line-height: 1.6; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 10px; }

/* barra inferior */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
}
.tabs button {
  flex: 1; max-width: 160px; background: none; border: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 700; color: var(--muted); padding: 6px 0;
}
.tabs svg { width: 22px; height: 22px; }
.tabs button[aria-current="page"] { color: var(--brand); }

.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 16px; font-size: 13px; z-index: 10; max-width: calc(100% - 32px);
}

@media (prefers-reduced-motion: reduce) {
  .pulse, .signal-card.flash { animation: none; }
  .sc-progress div { transition: none; }
}
