:root {
  --bg: #0f1420;
  --panel: #171e2e;
  --line: #263049;
  --text: #e6eaf2;
  --muted: #8a96b0;
  --working: #2ecc71;
  --blocked: #e74c3c;
  --idle: #8a96b0;
  --offline: #4a5468;
  font-family: system-ui, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
header {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
header h1 { font-size: 17px; margin: 0; white-space: nowrap; }
.spacer { flex: 1; }
#updated { color: var(--muted); font-size: 12px; }
#stats { display: flex; gap: 10px; font-size: 13px; }
.stat { display: flex; align-items: center; gap: 6px; }
button {
  background: #24304a; color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 12px; cursor: pointer; font: inherit; font-size: 13px;
}
button:hover { background: #2d3b5a; }
main { flex: 1; display: flex; min-height: 0; }
aside {
  width: 300px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
#search {
  margin: 10px; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; font-size: 13px;
}
#filters { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 10px 8px; }
#filters button { padding: 3px 8px; font-size: 12px; }
#filters button[aria-pressed="true"] { background: #3b4f7a; border-color: #5a73a8; }
#agent-list { list-style: none; margin: 0; padding: 0 0 12px; overflow-y: auto; flex: 1; }
#agent-list .machine {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  padding: 10px 12px 4px; display: flex; align-items: center; gap: 6px;
}
#agent-list .agent {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: pointer; font-size: 13px;
}
#agent-list .agent:hover, #agent-list .agent.selected { background: #212b42; }
#agent-list .agent .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#agent-list .agent small { color: var(--muted); display: block; font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.dot.working { background: var(--working); box-shadow: 0 0 6px var(--working); }
.dot.blocked { background: var(--blocked); }
.dot.idle { background: var(--idle); }
.dot.offline { background: var(--offline); }
#stage { flex: 1; position: relative; min-width: 0; }
#scene { position: absolute; inset: 0; }
#grid2d {
  position: absolute; inset: 0; overflow-y: auto; padding: 16px;
}
#grid2d h2 { font-size: 14px; color: var(--muted); margin: 18px 0 8px; display: flex; gap: 8px; align-items: center; }
#grid2d .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--idle);
  border-radius: 8px; padding: 10px 12px; cursor: pointer; font-size: 13px;
}
.card.working { border-left-color: var(--working); }
.card.blocked { border-left-color: var(--blocked); }
.card.offline { border-left-color: var(--offline); opacity: .6; }
.card .emoji { font-size: 22px; }
.card .task { color: var(--muted); font-size: 12px; margin-top: 4px; }
#detail {
  position: absolute; right: 16px; top: 16px; width: 340px; max-height: calc(100% - 32px); overflow-y: auto;
  background: rgba(23, 30, 46, .96); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px;
  font-size: 13px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
}
#detail h2 { margin: 0 0 4px; font-size: 16px; display: flex; gap: 8px; align-items: center; }
#detail .meta { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
#detail p { line-height: 1.45; }
#detail .close { position: absolute; top: 8px; right: 8px; padding: 2px 8px; }
#detail .item { background: var(--bg); border-radius: 6px; padding: 6px 8px; margin: 4px 0; }
#error {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%);
  background: #4a1d1d; border: 1px solid var(--blocked); padding: 8px 14px; border-radius: 6px; font-size: 13px;
}
/* Etiquetas sobre a cabeça dos agentes (CSS2DRenderer). */
.tag { pointer-events: auto; cursor: pointer; text-align: center; transform: translateY(-4px); }
.tag .em { font-size: 20px; filter: drop-shadow(0 1px 2px #000); }
.tag .nm {
  display: none; font-size: 11px; background: rgba(15, 20, 32, .9); padding: 2px 6px; border-radius: 4px;
  white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis;
}
.tag:hover .nm, .tag.selected .nm { display: block; }
.tag .bubble {
  font-size: 11px; background: #eafff1; color: #0b3d20; padding: 3px 7px; border-radius: 8px;
  white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px;
}

.room-label {
  font-size: 13px; font-weight: 600; background: rgba(15, 20, 32, .85); padding: 3px 10px;
  border-radius: 6px; border: 1px solid var(--line); white-space: nowrap;
}
.room-label.offline { color: var(--muted); }
.zone-label, .squad-label {
  font-size: 13px; font-weight: 600; background: rgba(255, 255, 255, .92); color: #1b2333; padding: 3px 10px;
  border-radius: 6px; border: 1px solid #c9d2e3; white-space: nowrap;
}
.zone-label.blocked { background: #ffe9e6; color: #6b1209; border-color: #f2b8b0; }
.zone-label.offline { background: #2a2f3d; color: #c9cfdc; border-color: #444b5e; }
.squad-label { max-width: 170px; overflow: hidden; text-overflow: ellipsis; font-size: 11px; font-weight: 500; background: rgba(27, 35, 51, .85); color: #e6eaf2; border-color: #3b4f7a; }
.tag.dim { opacity: .55; }
