/* Sala de operações — tokens
   Cromo escuro e quieto (azul-petróleo); o palco isométrico é a única área clara e chamativa.
   Cada equipe tem uma cor própria usada de forma consistente em toda a interface. */
:root {
  --ink: #0d1a27;
  --ink-2: #132536;
  --ink-3: #1a3147;
  --line: #27425c;
  --paper: #e9eff5;
  --muted: #8fa5b9;
  --dim: #5f778d;
  --floor: #d9d2c3;
  --floor-2: #c9c1b0;
  --fx: #43c6cf;
  --gold: #e6ae45;
  --pm: #b295f8;
  --gain: #58d68d;
  --loss: #ff6f6f;
  --warn: #f2b84b;
  --crit: #ff5d5d;
  --radius: 10px;
  --font: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --rail: 208px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ink); color: var(--paper); font: 14px/1.45 var(--font);
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--fx); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 22px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 6px; color: var(--muted); }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.small { font-size: 12px; }
.num { text-align: right; white-space: nowrap; }
.t-FOREX { --team: var(--fx); }
.t-GOLD { --team: var(--gold); }
.t-POLYMARKET { --team: var(--pm); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; padding: 18px 12px; background: var(--ink-2);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
}
.brand { font-size: 16px; font-weight: 700; padding: 4px 10px 16px; line-height: 1.15; }
.brand span { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--muted);
}
.nav a:hover { background: var(--ink-3); color: var(--paper); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--ink-3); color: var(--paper); box-shadow: inset 3px 0 0 var(--team, var(--paper)); }
.nav .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--team, var(--dim)); flex: none; }
.nav .sep { height: 1px; background: var(--line); margin: 8px 4px; }
.rail .foot { margin-top: auto; font-size: 12px; color: var(--muted); padding: 10px; }
.main { min-width: 0; display: flex; flex-direction: column; }

.strip {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 22px; background: rgba(13, 26, 39, .94); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
.strip .grow { flex: 1; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px;
  font-weight: 600; border: 1px solid var(--line); background: var(--ink-2); white-space: nowrap;
}
.badge.mode-PAPER { border-color: var(--fx); color: var(--fx); }
.badge.mode-LIVE { background: var(--crit); border-color: var(--crit); color: #1b0606; }
.badge.mode-BACKTEST { border-color: var(--pm); color: var(--pm); }
.badge.sim { border-style: dashed; border-color: var(--warn); color: var(--warn); }
.badge.ok { color: var(--gain); border-color: #2c6a49; }
.badge.warn { color: var(--warn); border-color: #7a5a1f; }
.badge.crit { color: var(--crit); border-color: #8a2f2f; }
.badge.status-PAPER_TRADING { color: var(--fx); }
.badge.status-ACTIVE, .badge.status-PROMOTED, .badge.status-DUPLICATED { color: var(--gain); }
.badge.status-PAUSED, .badge.status-REVIEW, .badge.status-BACKTESTING, .badge.status-INITIALIZING { color: var(--warn); }
.badge.status-ELIMINATED, .badge.status-ARCHIVED { color: var(--dim); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.page { padding: 22px; display: flex; flex-direction: column; gap: 18px; max-width: 1500px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.page-head .grow { flex: 1; }
.page-head p { margin: 2px 0 0; color: var(--muted); }

/* ---------- blocos ---------- */
.panel { background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.flush > h2 { padding: 14px 16px 0; }
.grid { display: grid; gap: 14px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }

/* cabeçalho da home: uma faixa única com as leituras principais */
.ledger { display: grid; grid-template-columns: 1.5fr repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--ink-2); }
.ledger > div { padding: 16px 18px; border-left: 1px solid var(--line); min-width: 0; }
.ledger > div:first-child { border-left: 0; background: var(--ink-3); }
.ledger .k { color: var(--muted); font-size: 12.5px; }
.ledger .v { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ledger > div:first-child .v { font-size: 34px; }
.ledger .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.stat .k { color: var(--muted); font-size: 12.5px; }
.stat .v { font-size: 19px; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px 18px; }

.team-card { border-top: 3px solid var(--team); display: flex; flex-direction: column; gap: 10px; }
.team-card .top { display: flex; align-items: baseline; gap: 8px; }
.team-card .top a { font-weight: 600; font-size: 15px; }
.team-card .big { font-size: 22px; font-weight: 600; }
.bar { height: 6px; border-radius: 3px; background: var(--ink-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--team, var(--fx)); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 12px; border-bottom: 1px solid rgba(39, 66, 92, .55); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover { background: var(--ink-3); }
.scroll-x { overflow-x: auto; }
.empty { padding: 22px 16px; color: var(--muted); }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 62px 1fr; gap: 10px; padding: 8px 16px; border-bottom: 1px solid rgba(39, 66, 92, .55); }
.feed li:last-child { border-bottom: 0; }
.feed time { color: var(--dim); font-size: 12px; padding-top: 1px; }
.feed .who { font-weight: 600; color: var(--team, var(--paper)); }
.feed .lvl-WARN { color: var(--warn); }
.feed .lvl-ERROR, .feed .lvl-CRITICAL { color: var(--crit); }
.feed.tall { max-height: 560px; overflow-y: auto; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--ink-3); cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.btn.danger { border-color: #8a2f2f; color: var(--crit); }
.btn.danger.on { background: var(--crit); color: #1b0606; border-color: var(--crit); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.nowrap { white-space: nowrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink-3); color: var(--paper); box-shadow: inset 0 -2px 0 var(--team, var(--paper)); }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { color: var(--muted); font-size: 12.5px; }
.field input, .field select, .field textarea, .input {
  background: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%;
}
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.note { border-left: 3px solid var(--warn); background: rgba(242, 184, 75, .08); padding: 10px 12px; border-radius: 0 8px 8px 0; }
.note.crit { border-color: var(--crit); background: rgba(255, 93, 93, .08); }
pre.json { margin: 0; font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); max-height: 320px; overflow: auto; }
details > summary { cursor: pointer; color: var(--muted); }

/* ---------- gráficos ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; touch-action: none; }
.chart .tip { position: absolute; top: 6px; left: 8px; font-size: 12px; color: var(--muted); pointer-events: none; }
.spark { width: 84px; height: 24px; }

/* ---------- sala de operações ---------- */
.room-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
.stage { background: #0a141e; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; position: relative; }
.stage svg { display: block; width: 100%; height: auto; }
.stage .toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--ink-2); }
.stage .toolbar .grow { flex: 1; }
.station { cursor: pointer; }
.station:focus-visible { outline: none; }
.station:focus-visible .ring, .station.sel .ring { stroke: var(--paper); stroke-width: 2.5; opacity: 1; }
.station .tag text { font: 600 11px var(--font); }
.ticker { display: flex; gap: 22px; padding: 9px 14px; border-top: 1px solid var(--line); background: var(--ink-2); overflow-x: auto; white-space: nowrap; font-size: 12.5px; }
.ticker b { color: var(--team, var(--paper)); font-weight: 600; margin-right: 6px; }
@keyframes working { 0%, 100% { opacity: .25; } 50% { opacity: .9; } }
.working { animation: working 2.2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .working { animation: none; opacity: .7; } }

.side { position: sticky; top: 64px; display: flex; flex-direction: column; gap: 14px; }
.sheet { border-top: 3px solid var(--team, var(--line)); }
.sheet .head { display: flex; align-items: flex-start; gap: 8px; }
.sheet .head .grow { flex: 1; min-width: 0; }
.sheet .name { font-size: 18px; font-weight: 600; }
.sheet .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.sheet .pair .v { font-size: 18px; font-weight: 600; }
.x { border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 18px; line-height: 1; padding: 2px 6px; }
.videoslot { aspect-ratio: 16 / 9; background: #070e16; border: 1px dashed var(--line); border-radius: 8px; display: grid; place-items: center; overflow: hidden; color: var(--dim); text-align: center; padding: 10px; }
.videoslot video, .videoslot iframe { width: 100%; height: 100%; border: 0; display: block; }
.videoslot.filled { padding: 0; border-style: solid; }

.funnel-row { display: grid; grid-template-columns: 190px 1fr 96px; gap: 10px; align-items: center; padding: 5px 0; }
.funnel-row .bar { height: 14px; }
.funnel-row .bar > i { background: var(--pm); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .panel { width: 100%; max-width: 380px; }
.login h1 { margin-bottom: 4px; }
.err { color: var(--crit); min-height: 20px; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 50; background: var(--paper); color: var(--ink); padding: 10px 14px; border-radius: 8px; max-width: min(420px, calc(100vw - 36px)); font-weight: 500; }
.toast.bad { background: var(--crit); color: #1b0606; }

/* ---------- responsivo ---------- */
@media (max-width: 1180px) {
  .room-layout { grid-template-columns: 1fr; }
  .side { position: static; }
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ledger { grid-template-columns: repeat(2, 1fr); }
  .ledger > div:first-child { grid-column: 1 / -1; }
  .ledger > div { border-left: 0; border-top: 1px solid var(--line); }
  .ledger > div:nth-child(odd):not(:first-child) { border-left: 1px solid var(--line); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 30; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line); overflow-x: auto; gap: 2px;
  }
  .brand, .rail .foot, .nav .sep { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a { flex-direction: column; gap: 3px; font-size: 11px; padding: 6px 10px; white-space: nowrap; }
  .nav a[aria-current="page"] { box-shadow: inset 0 3px 0 var(--team, var(--paper)); }
  .main { padding-bottom: 68px; }
  .page { padding: 14px; }
  .strip { padding: 8px 14px; }
  .cols-2, .cols-3, .split { grid-template-columns: 1fr; }
  .funnel-row { grid-template-columns: 120px 1fr 70px; }
  .feed li { grid-template-columns: 50px 1fr; padding: 8px 12px; }
  .toast { bottom: 82px; }
}
@media (max-width: 520px) {
  .cols-4 { grid-template-columns: 1fr; }
  .ledger { grid-template-columns: 1fr; }
  .ledger > div:nth-child(odd):not(:first-child) { border-left: 0; }
  .ledger > div:first-child .v { font-size: 28px; }
  h1 { font-size: 19px; }
}

/* ---------- Growth ---------- */
.t-GROWTH { --team: #7fd08a; }
.gdesk { border-top: 1px solid var(--line); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.gdesk-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.gdesk-head b { color: var(--team); font-size: 15px; }
.gdesk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.gseat { display: grid; grid-template-columns: 10px 1fr; column-gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--ink-2); text-decoration: none; color: inherit; }
.gseat:hover, .gseat:focus-visible { border-color: var(--team); }
.gseat .lamp { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); grid-row: span 2; }
.gseat .nm { font-weight: 600; font-size: 13px; }
.gseat .st { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gseat.idle .lamp { background: var(--gain); opacity: .55; }
.gseat.run .lamp { background: var(--gain); animation: working 1.2s ease-in-out infinite; }
.gseat.wait .lamp { background: var(--warn); }
.gseat.err .lamp { background: var(--crit); }
.field textarea { resize: vertical; font: inherit; color: inherit; }
.field select { color: inherit; font: inherit; }
.t-MAESTRO { --team: #f0c36a; }
