:root {
  --bg: #0b0b0c; --panel: #121214; --panel2: #18181b; --line: #232327; --line2: #2f2f35;
  --text: #ececef; --muted: #8e8e97; --dim: #5f5f68;
  --green: #3ddc84; --green-bg: rgba(61,220,132,.10); --red: #ff5a4e; --red-bg: rgba(255,90,78,.10);
  --orange: #ff5a1f; --amber: #ffb020; --amber-bg: rgba(255,176,32,.10); --purple: #a78bfa; --blue: #60a5fa;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 14px; }
a { color: var(--blue); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: var(--mono); background: var(--panel2); border: 1px solid var(--line2); color: var(--text); border-radius: 7px; padding: 8px 10px; font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--green); }
textarea { width: 100%; min-height: 120px; }
[hidden] { display: none !important; }

/* Topo + abas */
header { position: sticky; top: 0; z-index: 20; background: rgba(11,11,12,.94); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 22px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px; margin-right: 8px; }
.logo { width: 24px; height: 24px; border-radius: 7px; background: var(--orange); display: grid; place-items: center; font-weight: 800; font-size: 12px; color: #000; }
.top .right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
nav.tabs { display: flex; gap: 2px; padding: 0 16px; overflow-x: auto; }
nav.tabs a { text-decoration: none; color: var(--muted); padding: 10px 14px; border-bottom: 2px solid transparent; white-space: nowrap; font-size: 13.5px; display: flex; gap: 7px; align-items: center; }
nav.tabs a:hover { color: var(--text); }
nav.tabs a.active { color: var(--text); border-bottom-color: var(--orange); }
nav.tabs .cnt { background: var(--orange); color: #000; border-radius: 9px; font-size: 10px; padding: 1px 6px; font-weight: 700; }

main { padding: 20px 22px 80px; max-width: 1500px; margin: 0 auto; }
.tab { display: none; }
.tab.show { display: block; }
h2 { font-size: 20px; font-weight: 500; margin: 0 0 4px; }
h2 em { color: var(--orange); font-style: italic; }
h3 { font-size: 15px; margin: 18px 0 8px; }
.sub { color: var(--muted); font-size: 12.5px; margin-bottom: 16px; }
.head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.head .tools { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.pill { font-family: var(--mono); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; border-radius: 999px; padding: 5px 11px; border: 1px solid var(--line2); color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.pill.ok { color: var(--green); border-color: rgba(61,220,132,.4); }
.pill.bad { color: var(--red); border-color: rgba(255,90,78,.4); }
.pill.sim { color: #000; background: var(--amber); border-color: var(--amber); font-weight: 700; }
.pill.live { color: #fff; background: var(--red); border-color: var(--red); font-weight: 700; }
.pill.run { color: var(--green); border-color: rgba(61,220,132,.5); background: var(--green-bg); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }
.pill.run .dot { animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .3; } }

.btn { border: 1px solid var(--line2); background: var(--panel2); color: var(--text); border-radius: 8px; padding: 8px 14px; font-size: 13px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--green); border-color: var(--green); color: #04130a; font-weight: 700; }
.btn.orange { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 700; }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); font-weight: 700; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.banner { border: 1px solid var(--amber); background: var(--amber-bg); color: var(--amber); border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 16px; }
.banner.live { border-color: var(--red); background: var(--red-bg); color: #ffb4ae; }
.banner.info { border-color: var(--line2); background: var(--panel); color: var(--muted); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.label { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin-bottom: 6px; }
.big { font-family: var(--mono); font-size: 21px; font-weight: 600; }
.green { color: var(--green); } .red { color: var(--red); } .muted { color: var(--muted); } .dim { color: var(--dim); } .amber { color: var(--amber); } .purple { color: var(--purple); }
.mono { font-family: var(--mono); } .small { font-size: 12px; } .r { text-align: right; }
.grid { display: grid; gap: 12px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); }
.two { display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; }
.cols3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; font-family: var(--mono); font-size: 10px; letter-spacing: .09em; text-transform: uppercase; color: var(--dim); font-weight: 500; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); font-family: var(--mono); vertical-align: top; }
tr:hover td { background: rgba(255,255,255,.015); }
.scroll { overflow-x: auto; }

/* Tabela de cotações */
.qt td { white-space: nowrap; }
.qcell { line-height: 1.35; }
.qcell .a { color: var(--red); } .qcell .b { color: var(--green); }
.qcell.bestA { box-shadow: inset 0 0 0 1px rgba(255,90,78,.6); border-radius: 6px; }
.qcell.bestB { box-shadow: inset 0 0 0 1px rgba(61,220,132,.6); border-radius: 6px; }
.qcell.bestA.bestB { box-shadow: inset 0 0 0 1px var(--amber); }
.qcell.stale { opacity: .35; }
.qcell small { color: var(--dim); font-size: 10px; }

/* Oportunidades */
.opps { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.opp .route { display: flex; align-items: center; gap: 8px; font-weight: 600; flex-wrap: wrap; }
.opp .sym { font-family: var(--mono); background: var(--panel2); padding: 2px 8px; border-radius: 5px; font-size: 12px; }
.opp .profit { font-family: var(--mono); font-size: 22px; font-weight: 700; margin: 10px 0 2px; }
.opp .meta { font-family: var(--mono); font-size: 11.5px; color: var(--muted); line-height: 1.7; }
.opp .why { font-size: 11.5px; color: var(--amber); margin-top: 6px; }
.tag { font-family: var(--mono); font-size: 10px; padding: 2px 7px; border-radius: 4px; background: var(--panel2); color: var(--muted); text-transform: uppercase; }
.tag.inv { color: var(--purple); } .tag.dex { color: #c4a7ff; background: rgba(123,63,228,.15); } .tag.auto { color: var(--purple); background: rgba(167,139,250,.14); }
.ico { width: 24px; height: 24px; border-radius: 6px; display: inline-grid; place-items: center; font-weight: 800; font-size: 10px; flex: none; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line2); background: transparent; color: var(--muted); border-radius: 6px; padding: 5px 10px; }
.chip.on { background: var(--green-bg); color: var(--green); border-color: rgba(61,220,132,.5); }

/* Autobot */
.bigswitch { display: flex; align-items: center; gap: 18px; }
.switch { position: relative; width: 74px; height: 38px; border-radius: 38px; background: var(--line2); border: none; flex: none; }
.switch::after { content: ''; position: absolute; top: 5px; left: 5px; width: 28px; height: 28px; border-radius: 50%; background: #888; transition: .2s; }
.switch.on { background: var(--green); } .switch.on::after { left: 41px; background: #04130a; }
.switch.sm { width: 46px; height: 24px; } .switch.sm::after { width: 16px; height: 16px; top: 4px; left: 4px; } .switch.sm.on::after { left: 26px; }
.status-line { font-family: var(--mono); font-size: 12.5px; color: var(--muted); padding: 11px 13px; background: var(--panel2); border-radius: 8px; margin-top: 14px; }

.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.form label, .fl { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.form input, .form select { width: 100%; }
.help { font-size: 11px; color: var(--dim); margin-top: 4px; line-height: 1.45; }

.st { font-size: 10px; padding: 2px 7px; border-radius: 4px; font-weight: 700; font-family: var(--mono); white-space: nowrap; }
.st-done { background: var(--green-bg); color: var(--green); }
.st-failed, .st-aborted { background: var(--red-bg); color: var(--red); }
.st-running, .st-pending_deposit { background: var(--amber-bg); color: var(--amber); }
.st-skipped { background: var(--panel2); color: var(--muted); }

.bar { height: 8px; background: var(--panel2); border-radius: 5px; position: relative; overflow: hidden; min-width: 80px; }
.bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--green); border-radius: 5px; }
.bar i.low { background: var(--red); } .bar i.high { background: var(--amber); }
.bar b { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #fff5; }

/* Configurações */
.subtabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.subtabs button { border: 1px solid var(--line2); background: transparent; color: var(--muted); border-radius: 8px; padding: 7px 13px; font-size: 13px; }
.subtabs button.on { background: var(--panel2); color: var(--text); border-color: var(--muted); }
.exgrid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.excard .hd { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.excard .hd b { font-size: 15px; }
.excard input { width: 100%; margin-bottom: 8px; }
.excard .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.excard .msg { font-size: 12px; margin-top: 8px; font-family: var(--mono); }
.guide ol { padding-left: 20px; line-height: 1.75; color: #d0d0d6; margin: 6px 0; }
details.g { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; background: var(--panel); }
details.g summary { cursor: pointer; font-weight: 600; }

.logbox { max-height: 420px; overflow: auto; font-family: var(--mono); font-size: 11.5px; line-height: 1.7; background: var(--panel2); border-radius: 8px; padding: 10px; color: var(--muted); }
.logbox .error { color: var(--red); } .logbox .warn { color: var(--amber); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; padding: 26px; }
.login input { width: 100%; margin-bottom: 10px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.72); display: none; place-items: center; z-index: 50; backdrop-filter: blur(3px); padding: 16px; }
.modal-bg.show { display: grid; }
.modal { width: 100%; max-width: 540px; background: #111113; border: 1px solid var(--line2); border-radius: 16px; padding: 22px; max-height: 92vh; overflow: auto; }
.modal .kicker { font-family: var(--mono); font-size: 10.5px; letter-spacing: .12em; color: var(--orange); text-transform: uppercase; }
.modal h3 { margin: 2px 0 14px; font-weight: 500; font-size: 18px; }
.modal .x { float: right; background: none; border: none; color: var(--muted); font-size: 18px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; position: relative; padding-bottom: 13px; }
.timeline li::before { content: ''; position: absolute; left: 11px; top: 24px; bottom: 0; width: 2px; background: var(--line2); }
.timeline li:last-child::before { display: none; }
.timeline .ic { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line2); display: grid; place-items: center; font-size: 12px; color: #04130a; }
.timeline .ok .ic { background: var(--green); border-color: var(--green); } .timeline .ok::before { background: var(--green); }
.timeline .run .ic { border-color: var(--orange); border-top-color: transparent; animation: spin 1s linear infinite; }
.timeline .err .ic { background: var(--red); border-color: var(--red); color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.timeline .t { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); }
.timeline .ok .t { color: var(--green); } .timeline .run .t { color: var(--orange); } .timeline .err .t { color: var(--red); }
.timeline .d { font-size: 12.5px; color: #cfcfd4; margin-top: 2px; }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel2); border: 1px solid var(--line2); padding: 12px 16px; border-radius: 10px; font-size: 13px; z-index: 60; max-width: 440px; display: none; }
.toast.show { display: block; } .toast.err { border-color: var(--red); color: #ffb4ae; }
.empty { color: var(--dim); font-size: 13px; padding: 22px; text-align: center; }
.chart { width: 100%; height: 220px; display: block; }

@media (max-width: 900px) { .two { grid-template-columns: 1fr; } main { padding: 14px; } .top { padding: 10px 14px; } }

/* ---------- Celular ---------- */
body { padding-bottom: env(safe-area-inset-bottom); }
.captable td, .captable th { white-space: nowrap; }
@media (max-width: 700px) {
  .hide-sm { display: none !important; }
  .top { gap: 6px; padding: 8px 10px; }
  .brand { font-size: 14px; margin-right: 2px; }
  .pill { font-size: 10px; padding: 4px 8px; }
  nav.tabs { padding: 0 6px; }
  nav.tabs a { padding: 9px 10px; font-size: 13px; }
  main { padding: 10px 10px 70px; }
  h2 { font-size: 18px; }
  .head .tools { margin-left: 0; width: 100%; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .big { font-size: 17px; }
  .opps, .exgrid, .cols3 { grid-template-columns: 1fr; }
  .form { grid-template-columns: 1fr 1fr; gap: 10px; }
  .bigswitch { gap: 12px; }
  .switch { width: 64px; height: 34px; } .switch::after { width: 24px; height: 24px; } .switch.on::after { left: 35px; }
  .modal { padding: 16px; border-radius: 14px; }
  .banner { font-size: 12px; padding: 8px 10px; }
  table { font-size: 11.5px; } td, th { padding: 7px 6px; }
  .grid[style*="1fr 1fr"] { grid-template-columns: 1fr !important; }
}
@media (max-width: 420px) { .form { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .top .right { margin-left: 0; width: auto; } #logoutBtn { padding: 4px 8px; } }
