:root {
  color-scheme: dark;
  --bg: #05060f;
  --glass: rgba(10, 14, 28, 0.72);
  --line: rgba(120, 160, 255, 0.22);
  --text: #eef3ff;
  --dim: #8ea0c8;
  --cyan: #3de7ff;
  --magenta: #ff3ec8;
  --green: #3dff9a;
  --red: #ff3b55;
  --orange: #ff9a32;
  --purple: #b46bff;
  --violet: #7a3cff;
  --font: "Segoe UI", "Avenir Next", system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Segoe UI Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
body {
  background:
    radial-gradient(900px 420px at 50% 18%, rgba(90, 40, 160, 0.22), transparent 60%),
    radial-gradient(700px 300px at 80% 80%, rgba(20, 80, 140, 0.16), transparent 55%),
    var(--bg);
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
canvas { width: 100%; height: 100%; display: block; min-width: 0; min-height: 0; }

.shell { height: 100vh; width: 100vw; display: flex; flex-direction: column; overflow: hidden; }
.shell[hidden] { display: none !important; }
.nav { display: flex; gap: 6px; align-items: center; padding: 6px 8px; overflow: auto; border-bottom: 1px solid var(--line); background: rgba(8, 12, 22, 0.92); }
.nav a, #pop-out { color: var(--dim); text-decoration: none; font-size: 11px; letter-spacing: 0.08em; padding: 4px 8px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.nav a.on { color: var(--cyan); border-color: rgba(61, 231, 255, 0.45); }
.desk {
  flex: 1;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(280px, 1.25fr) minmax(196px, 0.62fr) auto;
  gap: 8px;
  padding: 8px 10px 8px;
}
.desk[hidden], .drawer[hidden], #login[hidden] { display: none !important; }

.glass, .topbar, .pricehead, .rail, .reactor-wrap, .side, .gate-card {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03), 0 10px 40px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
}

.topbar, .pricehead, .foot {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}
.topbar { padding: 6px 10px; }
.brand { font-weight: 750; letter-spacing: 0.16em; font-size: 14px; }
.brand span { color: var(--cyan); font-weight: 560; letter-spacing: 0.12em; }
.venue {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: #b9ffe0;
  border: 1px solid rgba(61, 255, 154, 0.45);
  border-radius: 999px;
  padding: 4px 10px;
  box-shadow: 0 0 16px rgba(61, 255, 154, 0.18);
}
.equity-chip { margin-left: auto; font-size: 12px; color: var(--dim); }
.equity-chip b { color: var(--green); font-family: var(--mono); font-size: 16px; margin-left: 6px; }
.equity-chip small { margin-left: 6px; letter-spacing: 0.12em; }
.sym { display: flex; align-items: center; gap: 6px; }
.btc { color: #f4b000; font-size: 16px; }
select, input {
  background: #0b1020;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}
.mode, .kill, .gear, .fire {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #101628;
  padding: 7px 12px;
  letter-spacing: 0.08em;
  font-size: 12px;
}
.mode.live { color: #ffd0d6; border-color: var(--red); box-shadow: 0 0 12px rgba(255, 59, 85, 0.35); }
.kill { background: linear-gradient(180deg, #ff4d63, #c41732); border: 0; color: white; font-weight: 750; }
.kill.on { box-shadow: 0 0 18px rgba(255, 59, 85, 0.7); animation: pulse 1.1s ease-in-out infinite; }
.gear { padding: 7px 10px; }

.alert {
  border: 1px solid rgba(255, 75, 99, 0.55);
  color: #ffd0d6;
  background: rgba(255, 40, 70, 0.1);
  border-radius: 10px;
  padding: 4px 10px;
  font-size: 12px;
}

.pricehead { padding: 4px 12px; min-height: 64px; flex-wrap: wrap; }
.pricehead .alert { flex: 1 0 100%; padding: 3px 8px; }
.bigprice { display: flex; align-items: baseline; gap: 10px; min-width: 220px; }
.bigprice strong {
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 680;
  letter-spacing: -0.03em;
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.18);
}
.bigprice strong.tick { animation: pop 0.35s ease; }
.bigprice span { font-family: var(--mono); font-size: 14px; }
.agents { display: flex; gap: 8px; flex: 1; justify-content: center; min-width: 0; overflow: hidden; }
.agent {
  background: rgba(8, 12, 24, 0.55);
  border: 1px solid var(--line);
  border-radius: 12px;
  flex: 1 1 0;
  min-width: 0;
  max-width: 160px;
  padding: 6px 8px 6px 10px;
  text-align: left;
}
.agent i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; box-shadow: 0 0 8px currentColor; }
.agent strong { font-size: 11px; letter-spacing: 0.14em; }
.agent small { display: block; color: var(--dim); font-size: 10px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.agent[data-agent="taker"] i { background: var(--cyan); color: var(--cyan); }
.agent[data-agent="spotter"] i { background: var(--orange); color: var(--orange); }
.agent[data-agent="kelly"] i { background: var(--purple); color: var(--purple); }
.agent[data-agent="edge"] i { background: var(--magenta); color: var(--magenta); }
.agent[data-agent="closer"] i { background: var(--red); color: var(--red); }
.agent[data-agent="prior"] i { background: var(--green); color: var(--green); }
.agent.hot { box-shadow: 0 0 16px rgba(122, 60, 255, 0.45); border-color: rgba(180, 107, 255, 0.7); }
.head-side { margin-left: auto; font-family: var(--mono); color: var(--dim); font-size: 12px; text-align: right; }

.stage { display: grid; grid-template-columns: 210px minmax(0, 1fr) 280px; gap: 8px; min-height: 0; min-width: 0; }
.rail, .reactor-wrap, .side { min-height: 0; min-width: 0; max-width: 100%; padding: 8px; overflow: hidden; }
.rail { display: grid; grid-template-rows: auto repeat(6, minmax(0, 1fr)); gap: 4px; }
.col-title, .panel-h { font-size: 11px; letter-spacing: 0.16em; color: var(--dim); display: flex; justify-content: space-between; }
.spark { min-height: 0; display: grid; grid-template-rows: auto 1fr; }
.spark header { display: flex; justify-content: space-between; font-size: 10px; letter-spacing: 0.12em; color: var(--dim); }
.spark header b { color: var(--text); font-family: var(--mono); letter-spacing: 0; }
.spark canvas { height: 28px; }
.reactor-wrap { position: relative; display: flex; flex-direction: column; }
#reactor { position: relative; flex: 1; min-height: 0; }
#reactor canvas { position: absolute; inset: 0; }
.telemetry { display: flex; gap: 12px; font-size: 10px; letter-spacing: 0.08em; color: var(--dim); }
.telemetry b { color: var(--text); font-family: var(--mono); letter-spacing: 0; }
.float-card {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  background: rgba(8, 12, 24, 0.78);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px 8px;
  font-size: 10px;
  letter-spacing: 0.12em;
  white-space: nowrap;
  box-shadow: 0 0 12px rgba(80, 140, 255, 0.18);
}
.float-card b { display: block; font-family: var(--mono); letter-spacing: 0; color: var(--text); }
.float-card.hot { border-color: rgba(180, 107, 255, 0.8); box-shadow: 0 0 16px rgba(180, 107, 255, 0.45); }
.side { display: grid; grid-template-rows: auto 92px minmax(0, 1fr); gap: 8px; padding: 0; background: transparent; border: 0; box-shadow: none; }
.tight { padding: 8px; display: flex; flex-direction: column; min-height: 0; }
.grow { min-height: 0; }
#flowbars, #miniline, #book { flex: 1; min-height: 0; }
.dom-stats { display: flex; gap: 10px; font-family: var(--mono); font-size: 11px; color: var(--dim); margin-bottom: 4px; }
.dom-stats em { color: var(--text); font-style: normal; }

.bottom { display: grid; grid-template-columns: minmax(0,1.05fr) minmax(0,1.25fr) minmax(0,0.85fr) minmax(0,0.8fr) minmax(0,1fr) minmax(0,0.9fr); gap: 8px; min-height: 0; min-width: 0; }
.bottom .glass { padding: 8px; min-height: 0; min-width: 0; overflow: hidden; display: flex; flex-direction: column; }
#equity, #candles, #pricer, #spectrum { flex: 1; min-height: 0; }
.pnl-figures { display: flex; gap: 12px; align-items: baseline; }
.pnl-figures strong { font-family: var(--mono); font-size: 26px; color: var(--green); text-shadow: 0 0 12px rgba(61, 255, 154, 0.35); }
.pnl-figures span { font-family: var(--mono); color: var(--dim); }
.pnl-stats { display: flex; gap: 10px; font-size: 10px; color: var(--dim); font-family: var(--mono); }
#trace { list-style: none; margin: 0; padding: 0; overflow: hidden; font-family: var(--mono); font-size: 10px; line-height: 1.45; }
#trace li { color: #9dffc8; border-bottom: 1px solid rgba(255,255,255,0.04); animation: slide 0.35s ease; }
#trace li.erro, #trace li.risco { color: #ffb4be; }
.triage { display: grid; gap: 6px; }
.rowt {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(120, 160, 255, 0.12);
}
.rowt b { letter-spacing: 0.12em; color: var(--cyan); }
.rowt span { color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rowt em { font-family: var(--mono); font-style: normal; color: var(--text); }
.rowt.bad { border-color: rgba(255, 59, 85, 0.45); }
.rowt.bad b { color: var(--red); }

.foot { gap: 10px; min-height: 46px; }
.ticker { flex: 1 1 auto; min-width: 0; overflow: hidden; mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); }
.ticker span {
  display: inline-block;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--dim);
  animation: marquee 28s linear infinite;
}
.fire {
  flex: 0 0 auto;
  white-space: nowrap;
  background: linear-gradient(90deg, #6a2bff, #b44bff 55%, #7a3cff);
  border: 0;
  color: white;
  font-weight: 750;
  letter-spacing: 0.12em;
  padding: 12px 22px;
  box-shadow: 0 0 22px rgba(140, 70, 255, 0.55);
  animation: glow 2.4s ease-in-out infinite;
}
#symbol-foot { max-width: 140px; }

.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.gate-card { width: min(460px, 100%); padding: 28px; }
.gate-card.wide { width: min(720px, 100%); max-height: min(92vh, 900px); overflow: auto; }
.drawer { position: fixed; inset: 0; background: rgba(2, 4, 12, 0.62); display: grid; place-items: center; z-index: 6; padding: 16px; }
.eyebrow { letter-spacing: 0.2em; color: var(--cyan); font-size: 12px; margin: 0; }
h1 { margin: 8px 0 8px; }
.muted, .fine, .warn { color: var(--dim); font-size: 13px; line-height: 1.45; }
.warn { color: #ffb4be; }
label { display: grid; gap: 6px; margin: 10px 0; font-size: 12px; color: var(--dim); letter-spacing: 0.04em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.check { grid-template-columns: 18px 1fr; align-items: center; }
button[type="submit"] {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  background: linear-gradient(90deg, #6a2bff, #ff3ec8);
  color: white;
  font-weight: 700;
}

@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes pulse { 50% { filter: brightness(1.25); } }
@keyframes glow { 50% { box-shadow: 0 0 32px rgba(180, 80, 255, 0.85); } }
@keyframes pop { 40% { transform: scale(1.03); } }
@keyframes slide { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

@media (max-width: 1500px) {
  .stage { grid-template-columns: 180px minmax(0, 1fr) 240px; }
  .bigprice strong { font-size: 28px; }
  .agent { min-width: 92px; }
  .bottom { grid-template-columns: 1fr 1.1fr 0.8fr 0.8fr 0.9fr 0.85fr; }
}
.screen { flex: 1; min-height: 0; overflow: auto; padding: 12px; display: grid; gap: 10px; align-content: start; }
.screen[hidden], .desk[hidden] { display: none !important; }
.screen h2 { margin: 0; letter-spacing: 0.14em; font-size: 12px; color: var(--dim); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.card { padding: 10px; }
.card b { display: block; font-family: var(--mono); font-size: 18px; margin-top: 4px; }
table.grid { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12px; }
table.grid th, table.grid td { text-align: left; padding: 4px 6px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.rules { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 860px; }
.inspector { position: absolute; right: 8px; bottom: 8px; max-width: 220px; z-index: 2; }

@media (max-width: 1366px) {
  .desk { gap: 6px; padding: 6px; }
  .brand { letter-spacing: 0.08em; font-size: 12px; }
  .equity-chip b { font-size: 14px; }
  .agent small { display: none; }
  .head-side { display: none; }
  .stage { grid-template-columns: 150px minmax(0, 1fr) 210px; }
  .bottom { grid-template-columns: 1fr 1fr 1fr; grid-auto-rows: minmax(140px, 1fr); overflow: auto; }
}
