:root {
  --bg: #0b1020; --bg2: #11182c; --card: #151d33; --card2: #1b2540; --line: #26314f;
  --txt: #e6ebf5; --muted: #8b97b3; --accent: #6d8bff; --accent2: #4f6bf0;
  --ok: #22c55e; --warn: #f59e0b; --err: #ef4444; --think: #a78bfa; --idle: #94a3b8;
  --r: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--txt); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.erro { color: var(--err); min-height: 1.2em; }
h1, h2, h3, h4 { margin: 0; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
a { color: var(--accent); }
code, pre { font-family: ui-monospace, "JetBrains Mono", Menlo, monospace; font-size: 12px; }

/* botões e campos */
.btn { background: var(--card2); color: var(--txt); border: 1px solid var(--line); border-radius: 9px; padding: 8px 14px; cursor: pointer; font: inherit; font-weight: 600; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn.primary:hover { background: var(--accent); }
.btn.danger { background: transparent; border-color: #5b2330; color: #ff8a8a; }
.btn.ok { background: #14532d; border-color: #166534; color: #bbf7d0; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
input, textarea, select { width: 100%; background: var(--bg2); color: var(--txt); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font: inherit; }
textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.check { display: flex; gap: 8px; align-items: center; color: var(--txt); font-size: 13px; font-weight: 500; margin: 6px 0; cursor: pointer; }
.check input { width: auto; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--muted); }
.badge { background: var(--err); color: #fff; border-radius: 999px; font-size: 10px; padding: 1px 6px; margin-left: 4px; }

/* login */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 30% 20%, #1b2a5a, var(--bg) 60%); }
.login-box { width: min(360px, 92vw); background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 30px; text-align: center; display: grid; gap: 12px; }
.logo-big { font-size: 48px; }

/* topo */
.topbar { display: flex; align-items: center; gap: 18px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--bg2); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand b { color: var(--accent); }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav button { background: none; border: 0; color: var(--muted); padding: 8px 12px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; }
nav button.active, nav button:hover { color: var(--txt); background: var(--card); }
.top-right { display: flex; gap: 8px; align-items: center; }
#conn.on { color: var(--ok); } #conn.off { color: var(--err); }
.aviso { margin: 12px 18px 0; padding: 10px 14px; border-radius: 10px; background: #3b2a0a; border: 1px solid #6b4a10; color: #fcd34d; }

main { padding: 16px 18px 40px; max-width: 1600px; margin: 0 auto; }

/* escritório */
.office-wrap { position: relative; background: #1c2340; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; margin-bottom: 16px; }
#office { display: block; margin: 0 auto; image-rendering: pixelated; cursor: pointer; }

.grid3 { display: grid; grid-template-columns: 290px 1fr 320px; gap: 16px; align-items: start; }
@media (max-width: 1150px) { .grid3 { grid-template-columns: 1fr; } }
.col { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; min-width: 0; }
.col-head { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 10px; }
.col-head:not(:first-child) { margin-top: 18px; }

/* cards de agente */
.ag { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; margin-bottom: 6px; background: var(--bg2); }
.ag:hover { border-color: var(--line); }
.ag.sel { border-color: var(--accent); background: var(--card2); }
.avatar { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; color: #fff; flex: none; position: relative; }
.avatar .dot { position: absolute; right: -3px; bottom: -3px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--card); }
.ag-info { min-width: 0; flex: 1; }
.ag-nome { font-weight: 700; }
.ag-ativ { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-ocioso { background: var(--idle); } .st-pensando { background: var(--think); } .st-trabalhando { background: var(--ok); } .st-aguardando { background: var(--warn); } .st-erro { background: var(--err); }
.tx-ocioso { color: var(--idle); } .tx-pensando { color: var(--think); } .tx-trabalhando { color: var(--ok); } .tx-aguardando { color: var(--warn); } .tx-erro { color: var(--err); }

/* painel do agente */
.ph { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.ph .avatar { width: 50px; height: 50px; font-size: 20px; }
.ph h2 { font-size: 20px; }
.subtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.subtabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 8px 12px; cursor: pointer; font: inherit; font-weight: 600; white-space: nowrap; }
.subtabs button.active { color: var(--txt); border-bottom-color: var(--accent); }
.ordem-box { display: flex; gap: 8px; margin-bottom: 14px; }
.ordem-box textarea { min-height: 46px; height: 46px; }
.vazio { text-align: center; color: var(--muted); padding: 30px 10px; }

/* execuções / log */
.exec { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.exec-h { display: flex; gap: 8px; align-items: center; padding: 9px 12px; background: var(--bg2); cursor: pointer; font-size: 13px; }
.exec-h .t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.exec-b { padding: 10px 12px; max-height: 460px; overflow: auto; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 6px; font-weight: 700; background: var(--card2); color: var(--muted); white-space: nowrap; }
.tag.concluido { background: #0f3a22; color: #86efac; } .tag.erro { background: #46121a; color: #fca5a5; } .tag.rodando { background: #1e2a66; color: #a5b4fc; } .tag.cancelado { background: #333; color: #ccc; }
.passo { display: flex; gap: 8px; padding: 5px 0; border-bottom: 1px dashed #1f2944; font-size: 13px; }
.passo:last-child { border: 0; }
.passo .ic { width: 20px; flex: none; text-align: center; }
.passo .ct { min-width: 0; flex: 1; }
.passo pre { margin: 4px 0 0; white-space: pre-wrap; word-break: break-word; background: #0a0f1e; padding: 8px; border-radius: 8px; color: #b8c4e0; max-height: 220px; overflow: auto; }
.passo.resposta .ct { background: #10203a; border: 1px solid #1d3a66; padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; }
.passo.erro .ct { color: #fca5a5; }

/* aprovações / notificações */
.aprov { background: #2a1f08; border: 1px solid #6b4a10; border-radius: 10px; padding: 10px; margin-bottom: 8px; font-size: 13px; }
.aprov .acoes { display: flex; gap: 6px; margin-top: 8px; }
.notif { padding: 8px 10px; border-left: 3px solid var(--line); background: var(--bg2); border-radius: 6px; margin-bottom: 6px; font-size: 13px; }
.notif.nl { background: var(--card2); }
.notif.erro { border-color: var(--err); } .notif.alerta { border-color: var(--warn); } .notif.concluido { border-color: var(--ok); } .notif.aprovacao { border-color: var(--warn); } .notif.info { border-color: var(--accent); }
.notif small { color: var(--muted); }
.notif-list { max-height: 520px; overflow: auto; }

/* páginas */
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.card h4 { font-size: 15px; margin-bottom: 4px; }
.card .acoes { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.tipo { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--card2); color: var(--accent); text-transform: uppercase; }
.split { display: grid; grid-template-columns: 340px 1fr; gap: 16px; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.tk { padding: 10px; border-radius: 10px; background: var(--bg2); margin-bottom: 6px; cursor: pointer; border: 1px solid transparent; }
.tk.sel { border-color: var(--accent); }
.msg { max-width: 80%; padding: 8px 12px; border-radius: 12px; margin: 6px 0; white-space: pre-wrap; }
.msg.cli { background: var(--card2); }
.msg.eu { background: #1d3a66; margin-left: auto; }
.msg small { display: block; color: var(--muted); font-size: 11px; }
.rotina { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.qr { background: #fff; padding: 10px; border-radius: 12px; width: 260px; }
.modelos { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.modelo { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 14px; cursor: pointer; }
.modelo:hover, .modelo.sel { border-color: var(--accent); }
.modelo .avatar { margin-bottom: 8px; }
.mem { display: flex; gap: 8px; align-items: flex-start; padding: 6px 8px; background: var(--bg2); border-radius: 8px; margin-bottom: 4px; font-size: 13px; }
.mem span { flex: 1; }

/* modal / toast */
.modal { position: fixed; inset: 0; background: #0009; display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal-box { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; width: min(720px, 100%); max-height: 90vh; overflow: auto; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--card2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 10px; z-index: 30; box-shadow: 0 10px 30px #0008; }

/* escritório 3D */
#office3d { position: relative; width: 100%; height: clamp(420px, 68vh, 780px); }
.office-wrap.cheia { position: fixed; inset: 0; z-index: 50; border-radius: 0; margin: 0; }
.office-wrap.cheia #office3d { height: 100vh; }
.office-tools .btn.on { border-color: var(--accent); color: var(--accent); }
.office-tools { flex-wrap: wrap; justify-content: flex-end; max-width: calc(100% - 20px); }
#office3d canvas { display: block; }
#office3d .css2d { position: absolute; inset: 0; cursor: grab; }
#office3d.carregando::after { content: 'Carregando escritório 3D…'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }
.office-tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; z-index: 2; }
.office-tools .btn { background: #0b1020cc; backdrop-filter: blur(6px); }
.office-dica { position: absolute; left: 12px; bottom: 10px; font-size: 11px; color: #cbd5e1; background: #0b1020aa; padding: 4px 9px; border-radius: 8px; pointer-events: none; }
#office:not(.hidden) ~ .office-dica { display: none; }
.lbl3d { pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 4px; transform: translateY(-6px); font-family: system-ui, sans-serif; }
.lbl3d .nm { display: flex; align-items: center; gap: 5px; background: #0b1020d9; color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px 2px 6px; border-radius: 999px; border: 1px solid #ffffff22; white-space: nowrap; }
.lbl3d.sel .nm { border-color: var(--accent); box-shadow: 0 0 0 2px #6d8bff55; }
.lbl3d .nm i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.lbl3d .bub { position: relative; max-width: 230px; background: #fff; color: #0f172a; font-size: 11px; font-weight: 600; padding: 5px 9px; border-radius: 10px; box-shadow: 0 4px 14px #0006; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lbl3d .bub::after { content: ''; position: absolute; left: 50%; bottom: -5px; margin-left: -5px; border: 5px solid transparent; border-bottom: 0; border-top-color: inherit; }
.lbl3d .bub.vazio { display: none; }
.lbl3d .bub.aguardando { background: #f59e0b; animation: pulsa 0.8s ease-in-out infinite alternate; }
.lbl3d .bub.erro { background: #ef4444; color: #fff; }
.lbl3d .bub.pensando { background: #ede9fe; }
.lbl3d .bub.trabalhando { background: #dcfce7; }
@keyframes pulsa { from { transform: scale(1); } to { transform: scale(1.06); } }
input[type=color] { padding: 3px; height: 40px; cursor: pointer; }

/* barra do gerente */
#barraGerente { margin-bottom: 16px; }
.barra-g { display: flex; gap: 12px; align-items: center; background: linear-gradient(90deg, #0f2f2c, var(--card)); border: 1px solid #1f5c55; border-radius: var(--r); padding: 12px 14px; flex-wrap: wrap; }
.barra-g.vazia { background: var(--card); border: 1px dashed var(--line); justify-content: space-between; color: var(--muted); font-size: 13px; }
.barra-g .bg-info { min-width: 180px; flex: 0 1 260px; }
.barra-g textarea { flex: 1 1 320px; min-height: 46px; height: 46px; }
.modelo.bloq { opacity: .45; cursor: not-allowed; }

/* agente desligado */
.ag { position: relative; }
.ag.deslig { opacity: .55; }
.ag.deslig .avatar { filter: grayscale(1); }
.pwr { flex: none; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); color: var(--ok); font-size: 14px; cursor: pointer; display: grid; place-items: center; }
.pwr.off { color: var(--muted); }
.pwr:hover, .pwr:focus-visible { border-color: var(--accent); outline: none; }
.aviso-off { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: var(--bg2); border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: 13px; }

.lbl3d .bub.fala { background: #F2B544; color: #1A1306; }
.sala3d { display: flex; align-items: center; gap: 6px; background: rgba(7,11,20,.8); border: 1px solid rgba(255,255,255,.1); border-radius: 999px; padding: 3px 10px; font: 700 10.5px Inter, system-ui, sans-serif; letter-spacing: .06em; color: #DCE3F2; white-space: nowrap; pointer-events: none; }
.sala3d i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

/* microfone */
.btn.mic { flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-width: 46px; height: 46px; padding: 0 12px; }
.btn.mic.gravando { background: #3B1015; border-color: #EF4444; color: #FCA5A5; font-family: ui-monospace, monospace; }
.btn.mic .rec { width: 10px; height: 10px; border-radius: 50%; background: #EF4444; animation: pisca3d 1s infinite; }
.btn.mic .spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: gira 0.8s linear infinite; }
@keyframes pisca3d { 50% { opacity: .2; } }
@keyframes gira { to { transform: rotate(360deg); } }
