:root {
  --fundo: #0b1220;
  --painel: #111a2e;
  --painel-2: #17223a;
  --linha: #26324d;
  --texto: #e6edf7;
  --suave: #8ea0bd;
  --azul: #3b82f6;
  --ok: #22c55e;
  --trabalhando: #eab308;
  --aguardando: #38bdf8;
  --ocioso: #94a3b8;
  --erro: #ef4444;
  --faltante: #f97316;
  --sem_dados: #64748b;
  --pixel: "Press Start 2P", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--fundo); color: var(--texto); font: 13px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { display: flex; flex-direction: column; overflow: hidden; }
button { font: inherit; color: inherit; }

/* ---------- Topo ---------- */
#topo {
  display: flex; align-items: center; gap: 14px; padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top));
  background: linear-gradient(180deg, #16223b, #111a2e); border-bottom: 2px solid #0a0f1c; box-shadow: 0 2px 0 #26324d inset;
}
.marca { display: flex; align-items: center; gap: 10px; }
.marca .logo { height: 38px; image-rendering: auto; filter: drop-shadow(0 2px 0 rgba(0,0,0,.4)); }
.marca strong { display: block; font-size: 15px; letter-spacing: .02em; }
#conexao { font-size: 11px; color: var(--suave); display: inline-flex; align-items: center; gap: 5px; }
.ponto { width: 8px; height: 8px; border-radius: 50%; background: var(--sem_dados); display: inline-block; }
#conexao.on .ponto { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
#contadores { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.contador { display: flex; flex-direction: column; align-items: center; min-width: 58px; padding: 3px 8px; border-radius: 8px; background: var(--painel-2); border: 1px solid var(--linha); }
.contador b { font-size: 16px; font-variant-numeric: tabular-nums; }
.contador small { font-size: 10px; color: var(--suave); white-space: nowrap; }
.contador.destaque b { color: var(--cor); }
.botao { padding: 7px 12px; border-radius: 8px; background: var(--azul); color: #fff; text-decoration: none; font-weight: 600; white-space: nowrap; border: 0; cursor: pointer; box-shadow: 0 2px 0 #1d4ed8; }

/* ---------- Grade principal ---------- */
#painel { flex: 1; min-height: 0; display: grid; grid-template-columns: 270px 1fr 300px; }
#lista, #lateral { background: var(--painel); overflow: auto; }
#lista { border-right: 1px solid var(--linha); }
#lateral { border-left: 1px solid var(--linha); }
#centro { display: grid; grid-template-rows: 1fr 190px; min-width: 0; min-height: 0; }

/* ---------- Lista de agentes ---------- */
.busca { position: sticky; top: 0; z-index: 2; padding: 10px; background: var(--painel); border-bottom: 1px solid var(--linha); }
.busca input { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--linha); background: var(--fundo); color: var(--texto); }
.grupo { border-bottom: 1px solid var(--linha); }
.grupo h3 { margin: 0; padding: 10px 12px 6px; font-size: 11px; color: var(--suave); text-transform: uppercase; letter-spacing: .06em; display: flex; justify-content: space-between; }
.agente { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: center; width: 100%; padding: 7px 12px; border: 0; background: none; text-align: left; cursor: pointer; border-left: 3px solid transparent; }
.agente:hover { background: var(--painel-2); }
.agente.sel { background: #1b2a4a; border-left-color: var(--azul); }
.agente img { height: 34px; justify-self: center; }
.agente .nome { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.agente .sub { font-size: 11px; color: var(--suave); display: flex; align-items: center; gap: 6px; }
.selo { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 999px; font-size: 10px; font-weight: 700; background: color-mix(in srgb, var(--cor) 18%, transparent); color: var(--cor); border: 1px solid color-mix(in srgb, var(--cor) 45%, transparent); white-space: nowrap; }
.bolinha { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--cor); flex: none; }

/* ---------- Mapa ---------- */
#mapa-moldura { position: relative; overflow: auto; background: #1c2740 repeating-linear-gradient(45deg, #1a2540 0 10px, #1d2945 10px 20px); display: grid; place-items: center; padding: 10px; }
#mapa { background: #e9e2d6; position: relative; width: min(100%, calc((100vh - 290px) * 1.768)); aspect-ratio: 2688 / 1520; border-radius: 10px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.45), 0 0 0 3px #0a0f1c; }
#fundo { width: 100%; height: 100%; display: block; user-select: none; image-rendering: auto; }
#camada { position: absolute; inset: 0; }

.rotulo-sala {
  position: absolute; transform: translateY(-50%); padding: 2px 8px; border-radius: 6px;
  background: rgba(11, 18, 32, .82); color: #fff; font-size: clamp(8px, .75vw, 11px); font-weight: 700; letter-spacing: .03em; white-space: nowrap;
  border: 1px solid rgba(255,255,255,.15); cursor: default; display: flex; align-items: center; gap: 5px; pointer-events: auto;
}
.rotulo-sala.clicavel { cursor: pointer; }

.robo { position: absolute; transform: translate(-50%, -100%); height: 10.5%; cursor: pointer; z-index: 1; display: flex; flex-direction: column; align-items: center; }
.robo .corpo { height: 100%; position: relative; animation: respira 2.6s ease-in-out infinite; transform-origin: bottom center; }
.robo .corpo img { height: 100%; display: block; filter: drop-shadow(0 2px 0 rgba(0,0,0,.35)); }
.robo.espelho .corpo img { transform: scaleX(-1); }
.robo .sombra { position: absolute; bottom: -3%; left: 50%; width: 80%; height: 12%; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(closest-side, var(--cor) 0 55%, transparent 70%); opacity: .75; z-index: -1; }
.robo .etiqueta {
  position: absolute; bottom: 102%; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; padding: 1px 7px 1px 5px; border-radius: 999px;
  background: rgba(11, 18, 32, .9); color: #fff; font-size: clamp(8px, .72vw, 11px); font-weight: 600; white-space: nowrap;
  border: 1px solid rgba(255,255,255,.18); box-shadow: 0 2px 0 rgba(0,0,0,.35);
}
.robo .balao {
  position: absolute; bottom: 128%; left: 62%; min-width: 18px; padding: 0 5px; border-radius: 6px;
  background: #fff; color: #0b1220; font-weight: 900; font-size: clamp(9px, .8vw, 12px); text-align: center; line-height: 1.5;
  box-shadow: 0 2px 0 rgba(0,0,0,.35);
}
.robo .balao::after { content: ""; position: absolute; left: 4px; bottom: -4px; border: 4px solid transparent; border-top-color: #fff; border-bottom: 0; }
.robo:hover { z-index: 5; }
.robo:hover .corpo { animation-duration: .8s; }
.robo.sel { z-index: 6; }
.robo.sel .sombra { opacity: 1; animation: pulsa 1.2s infinite; }

.robo.st-trabalhando .corpo { animation: digita .45s ease-in-out infinite; }
.robo.st-erro .corpo img { filter: drop-shadow(0 0 4px var(--erro)) drop-shadow(0 0 2px var(--erro)); }
.robo.st-erro .corpo { animation: nega .9s ease-in-out infinite; }
.robo.st-ocioso .corpo img { filter: saturate(.75) drop-shadow(0 2px 0 rgba(0,0,0,.35)); }
.robo.st-sem_dados .corpo, .robo.st-faltante .corpo { animation: cochila 4s ease-in-out infinite; }
.robo.st-sem_dados .corpo img { filter: grayscale(.85) brightness(.85); opacity: .85; }
.robo.st-faltante .corpo img { filter: grayscale(.6) sepia(.4) hue-rotate(-20deg); }
.robo.filtrado-fora { opacity: .25; }

@keyframes respira { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2%); } }
@keyframes digita { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-3%) rotate(-1.5deg); } }
@keyframes nega { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
@keyframes cochila { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(5deg) translateY(1%); } }
@keyframes pulsa { 50% { transform: translateX(-50%) scale(1.35); opacity: .5; } }
@keyframes pisca { 50% { opacity: .25; } }

/* ---------- Atividade ---------- */
#atividade { border-top: 1px solid var(--linha); background: var(--painel); display: flex; flex-direction: column; min-height: 0; }
#atividade header { display: flex; align-items: baseline; gap: 8px; padding: 8px 12px 4px; }
#atividade header span { color: var(--suave); font-size: 11px; }
#feed { list-style: none; margin: 0; padding: 0 6px 8px; overflow: auto; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
#feed li { display: grid; grid-template-columns: 44px 18px 22px 190px 1fr; gap: 6px; align-items: center; padding: 3px 6px; border-radius: 6px; cursor: pointer; }
#feed li:hover { background: var(--painel-2); }
#feed time { color: var(--suave); }
#feed img { height: 20px; justify-self: center; }
#feed .quem { font-weight: 700; font-family: system-ui, sans-serif; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#feed .oque { color: #c8d3e6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#feed li.falha .oque { color: #fca5a5; }

/* ---------- Ficha / Reunião do dia ---------- */
#ficha { padding: 14px; }
.ficha-topo { display: flex; gap: 12px; align-items: flex-end; padding-bottom: 12px; border-bottom: 1px solid var(--linha); }
.ficha-topo img { height: 92px; filter: drop-shadow(0 3px 0 rgba(0,0,0,.4)); }
.ficha-topo h2 { margin: 0 0 4px; font-size: 16px; }
.ficha-topo .id { font: 11px ui-monospace, monospace; color: var(--suave); }
.ficha dl { display: grid; grid-template-columns: 92px 1fr; gap: 7px 10px; margin: 12px 0; }
.ficha dt { color: var(--suave); }
.ficha dd { margin: 0; word-break: break-word; }
.ficha pre { margin: 0; padding: 8px; border-radius: 8px; background: var(--fundo); border: 1px solid var(--linha); white-space: pre-wrap; word-break: break-word; font-size: 11px; max-height: 160px; overflow: auto; }
.ficha h4 { margin: 14px 0 6px; font-size: 11px; color: var(--suave); text-transform: uppercase; letter-spacing: .06em; }
.ficha .mini-feed { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.ficha .mini-feed li { display: flex; gap: 8px; padding: 3px 0; border-bottom: 1px dashed var(--linha); }
.ficha .mini-feed time { color: var(--suave); font-family: ui-monospace, monospace; }
.voltar { background: none; border: 0; color: var(--azul); cursor: pointer; padding: 0 0 10px; }
.reuniao h2 { margin: 0 0 2px; font-size: 16px; }
.reuniao .sub { color: var(--suave); margin-bottom: 12px; }
.alerta { display: grid; grid-template-columns: 30px 1fr; gap: 8px; align-items: center; padding: 8px; border-radius: 8px; background: var(--painel-2); border: 1px solid var(--linha); border-left: 3px solid var(--cor); margin-bottom: 6px; cursor: pointer; }
.alerta img { height: 30px; }
.alerta small { display: block; color: var(--suave); }
.tudo-ok { padding: 10px; border-radius: 8px; background: color-mix(in srgb, var(--ok) 12%, transparent); border: 1px solid color-mix(in srgb, var(--ok) 40%, transparent); }

#aviso { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #7f1d1d; padding: 8px 14px; border-radius: 10px; z-index: 50; }
#abas-celular { display: none; }

/* ---------- Telas menores ---------- */
@media (max-width: 1180px) {
  #painel { grid-template-columns: 240px 1fr; }
  #lateral { position: fixed; right: 10px; top: 70px; bottom: 10px; width: 300px; z-index: 20; border-radius: 12px; border: 1px solid var(--linha); box-shadow: 0 10px 30px rgba(0,0,0,.5); display: none; }
  body.com-ficha #lateral { display: block; }
}
@media (max-width: 760px) {
  #topo { flex-wrap: wrap; gap: 8px; }
  #contadores { order: 3; width: 100%; margin: 0; overflow-x: auto; flex-wrap: nowrap; }
  .botao { margin-left: auto; padding: 6px 10px; font-size: 12px; }
  #painel { display: block; position: relative; }
  #lista, #centro { position: absolute; inset: 0; }
  #centro { grid-template-rows: 1fr; }
  #lista, #atividade { display: none; }
  body.aba-lista #lista { display: block; }
  body.aba-lista #centro { display: none; }
  body.aba-atividade #atividade { display: flex; position: absolute; inset: 0; }
  body.aba-atividade #mapa-moldura { display: none; }
  #mapa-moldura { place-items: start; }
  #mapa { width: 920px; }
  #feed li { grid-template-columns: 40px 14px 20px 1fr; }
  #feed li .oque { grid-column: 3 / -1; }
  #lateral { left: 8px; right: 8px; width: auto; top: auto; bottom: 64px; max-height: 62%; }
  #abas-celular { display: flex; border-top: 1px solid var(--linha); background: var(--painel); padding-bottom: env(safe-area-inset-bottom); }
  #abas-celular button { flex: 1; padding: 12px 0; background: none; border: 0; color: var(--suave); font-weight: 600; }
  #abas-celular button.ativa { color: #fff; box-shadow: inset 0 3px 0 var(--azul); }
}

/* ---------- Balão de fala ---------- */
#fala {
  position: absolute; transform: translate(-50%, -100%); z-index: 20; width: clamp(220px, 26%, 340px);
  background: #fffdf5; color: #1e293b; border: 3px solid #0b1220; border-radius: 10px; padding: 8px 10px 10px;
  box-shadow: 0 4px 0 #0b1220, 0 10px 24px rgba(0,0,0,.35); font-size: clamp(11px, .9vw, 13px); line-height: 1.4;
  animation: surge .18s ease-out;
}
#fala::after { content: ""; position: absolute; left: 50%; bottom: -14px; transform: translateX(-50%); border: 11px solid transparent; border-top-color: #0b1220; border-bottom: 0; }
#fala.esq { transform: translate(-12%, -100%); } #fala.esq::after { left: 12%; }
#fala.dir { transform: translate(-88%, -100%); } #fala.dir::after { left: 88%; }
#fala .fala-topo { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 4px; }
#fala .fala-topo b { font-size: 12px; color: #0b1220; }
#fala button { background: #e2e8f0; border: 0; border-radius: 6px; padding: 2px 6px; margin-left: 4px; cursor: pointer; color: #0b1220; }
#fala button:hover { background: #cbd5e1; }
#fala p { margin: 0; min-height: 3.5em; }
#fala.abaixo { transform: translate(-50%, 0); }
#fala.abaixo.esq { transform: translate(-12%, 0); } #fala.abaixo.dir { transform: translate(-88%, 0); }
#fala.abaixo::after { bottom: auto; top: -14px; border: 11px solid transparent; border-bottom-color: #0b1220; border-top: 0; }
@keyframes surge { from { opacity: 0; margin-top: 8px; } to { opacity: 1; margin-top: 0; } }
.botao.voz { background: #334155; box-shadow: 0 2px 0 #1e293b; }
.botao.voz:not(.desligada) { background: #16a34a; box-shadow: 0 2px 0 #15803d; }
@media (max-width: 760px) { .botao.voz { padding: 6px 8px; font-size: 12px; } #fala { width: 260px; } }
