:root {
  color-scheme: dark;
  --fundo: #0b0d12;
  --fundo-2: #10131a;
  --fundo-3: #151923;
  --fundo-4: #1b2030;
  --borda: #232938;
  --borda-forte: #323a50;
  --texto: #e8ebf2;
  --texto-2: #a3abbd;
  --texto-3: #7d869b;
  --acento: #8b98ff;
  --acento-fundo: #1f2547;
  --verde: #34d399;
  --amarelo: #fbbf24;
  --vermelho: #f87171;
  --raio: 12px;
  --raio-p: 8px;
  --lateral: 264px;
  --painel: 340px;
  --fonte: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--fundo); color: var(--texto);
  font-family: var(--fonte); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--acento); }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; border-radius: 6px; }

.so-leitor { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pular { position: absolute; left: -999px; top: 8px; background: var(--acento); color: #0b0d12; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.pular:focus { left: 8px; }
.suave { color: var(--texto-2); }
.pequeno { font-size: 13px; }

/* ---------- Botões ---------- */
.botao {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--borda-forte); background: var(--fundo-3); color: var(--texto);
  padding: 8px 14px; border-radius: var(--raio-p); cursor: pointer; font-weight: 500; min-height: 36px;
  transition: background .15s, border-color .15s;
}
.botao:hover:not(:disabled) { background: var(--fundo-4); border-color: #44506d; }
.botao:disabled { opacity: .55; cursor: not-allowed; }
.botao-primario { background: var(--acento); border-color: var(--acento); color: #0b0d12; font-weight: 600; }
.botao-primario:hover:not(:disabled) { background: #a2adff; border-color: #a2adff; }
.botao-suave { background: transparent; }
.botao-perigo { color: #fecaca; border-color: #5b2b32; background: #2a1519; }
.botao-perigo:hover:not(:disabled) { background: #3a1b21; border-color: #7a3a43; }
.botao-ok { color: #a7f3d0; border-color: #1d5a46; background: #11271f; }
.botao-ok:hover:not(:disabled) { background: #16342a; border-color: #2a7c60; }
.botao-pequeno { padding: 5px 10px; min-height: 30px; font-size: 13px; }
.botao-icone {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--raio-p);
  border: 1px solid transparent; background: transparent; color: var(--texto-2); cursor: pointer;
}
.botao-icone:hover { background: var(--fundo-3); color: var(--texto); }
.botao-icone[aria-expanded="true"] { background: var(--acento-fundo); color: var(--acento); }
.icone { width: 18px; height: 18px; flex: none; }
.icone-slot { display: inline-flex; }
.selo {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--amarelo); color: #1c1400; font-size: 12px; font-weight: 700;
}

/* ---------- Páginas de acesso ---------- */
.pagina-auth { display: grid; place-items: center; min-height: 100%; padding: 24px 16px; background:
  radial-gradient(900px 500px at 15% -10%, #1a2150 0%, transparent 60%), var(--fundo); }
.cartao-auth {
  width: 100%; max-width: 400px; background: var(--fundo-2); border: 1px solid var(--borda);
  border-radius: 16px; padding: 28px; display: grid; gap: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.cartao-auth h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.form { display: grid; gap: 14px; margin-top: 4px; }
.campo { display: grid; gap: 6px; font-size: 13px; color: var(--texto-2); font-weight: 500; }
.campo input {
  background: var(--fundo); border: 1px solid var(--borda-forte); border-radius: var(--raio-p);
  padding: 10px 12px; color: var(--texto); font-size: 15px; min-height: 42px;
}
.campo input:focus-visible { outline-offset: 0; border-color: var(--acento); }
.erro { color: #fecaca; background: #2a1519; border: 1px solid #5b2b32; border-radius: var(--raio-p); padding: 8px 12px; font-size: 14px; }

.marca { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.01em; }
.marca-logo { width: 26px; height: 26px; border-radius: 8px; background: var(--acento); position: relative; flex: none; }
.marca-logo::after { content: ''; position: absolute; inset: 7px 6px; border-top: 2.5px solid #0b0d12; border-bottom: 2.5px solid #0b0d12; }

/* ---------- Layout do app ---------- */
.app {
  display: grid; grid-template-columns: var(--lateral) minmax(0, 1fr); height: 100vh; height: 100dvh;
}
.app.com-painel { grid-template-columns: var(--lateral) minmax(0, 1fr) var(--painel); }

.lateral {
  background: var(--fundo-2); border-right: 1px solid var(--borda); display: flex; flex-direction: column; min-height: 0;
}
.lateral-topo { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px; }
.salas { flex: 1; overflow-y: auto; padding: 8px; display: grid; gap: 2px; align-content: start; }
.sala-item {
  display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; text-align: left;
  padding: 8px 10px; border-radius: 10px; border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--texto-2);
}
.sala-item:hover { background: var(--fundo-3); color: var(--texto); }
.sala-item[aria-current="page"] { background: var(--fundo-4); color: var(--texto); border-color: var(--borda-forte); }
.sala-icone {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--cor) 22%, transparent); color: var(--cor);
}
.sala-icone .icone { width: 16px; height: 16px; }
.sala-nome { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sala-meta { display: flex; align-items: center; gap: 8px; }
.online-contagem { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--texto-3); }
.online-contagem.tem { color: var(--verde); }
.ponto { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }
.atividade { width: 8px; height: 8px; border-radius: 50%; background: var(--acento); }

.lateral-rodape { border-top: 1px solid var(--borda); padding: 12px; display: grid; gap: 10px; }
.usuario { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px; }
.usuario-nome { font-weight: 600; font-size: 14px; line-height: 1.2; }
.usuario-papel { font-size: 12px; color: var(--texto-3); }
.estado-geral { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--verde); }
.estado-geral.ausente { color: var(--amarelo); }

.avatar {
  --tam: 36px; width: var(--tam); height: var(--tam); border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: var(--cor, #6366f1); color: #fff; font-weight: 700; font-size: calc(var(--tam) * .38); position: relative;
  letter-spacing: .02em; text-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.avatar.ia { border-radius: 10px; }
.avatar .estado {
  position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--verde); border: 2px solid var(--fundo); 
}
.avatar .estado.ausente { background: var(--amarelo); }

.principal { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--fundo); }
.topo {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--borda); min-height: 64px;
}
.topo-sala { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.topo-sala h1 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.topo-sala p { font-size: 13px; color: var(--texto-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topo-acoes { display: flex; align-items: center; gap: 8px; }

/* ---------- Mesa (cartões das IAs + pessoas) ---------- */
.mesa {
  display: flex; gap: 14px; align-items: stretch; overflow-x: auto; padding: 14px 20px; border-bottom: 1px solid var(--borda);
  background: linear-gradient(180deg, var(--fundo-2), var(--fundo)); scrollbar-width: thin;
}
.mesa:empty { display: none; }
.mesa-grupo { display: flex; gap: 12px; align-items: stretch; }
.mesa-pessoas {
  display: flex; flex-direction: column; justify-content: center; gap: 8px; min-width: 130px; padding: 10px 14px;
  border: 1px dashed var(--borda-forte); border-radius: var(--raio); flex: none;
}
.mesa-pessoas h2, .cartao-rotulo { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--texto-3); font-weight: 600; }
.pilha { display: flex; flex-wrap: wrap; gap: 6px; }
.pilha .avatar { --tam: 32px; }
.mesa-vazia { font-size: 13px; color: var(--texto-3); }

.cartao-ia {
  width: 280px; flex: none; background: var(--fundo-3); border: 1px solid var(--borda); border-radius: var(--raio);
  padding: 12px 14px; display: grid; gap: 10px; align-content: start;
}
.cartao-ia.cinza { opacity: .55; filter: grayscale(.8); }
.cartao-cabeca { display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: center; }
.cartao-cabeca .avatar { --tam: 40px; }
.cartao-nome { font-weight: 600; font-size: 14px; line-height: 1.25; }
.cartao-cargo { font-size: 12px; color: var(--texto-2); line-height: 1.3; }
.status {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  width: fit-content; background: var(--fundo-4); color: var(--texto-2);
}
.status.trabalhando { background: #10281f; color: var(--verde); }
.status.trabalhando .ponto { animation: pulsar 1.4s ease-in-out infinite; }
.status.ocioso, .status.disponivel { background: #14233a; color: #93c5fd; }
.status.erro { background: #2a1519; color: var(--vermelho); }
.status.pausado { background: #2b2410; color: var(--amarelo); }
@keyframes pulsar { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.7); } }
.cartao-linha { display: grid; gap: 2px; font-size: 13px; }
.link-botao {
  background: none; border: 0; padding: 0; color: var(--acento); cursor: pointer; text-align: left; font-weight: 500;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.link-botao:hover { text-decoration: underline; }
.cartao-data { font-size: 12px; color: var(--texto-3); }
.cartao-lista { margin: 0; padding: 0; list-style: none; display: grid; gap: 3px; font-size: 12.5px; color: var(--texto-2); }

/* ---------- Chat ---------- */
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.mensagens { flex: 1; overflow-y: auto; padding: 16px 20px 8px; scroll-behavior: auto; }
.mensagens:focus-visible { outline-offset: -2px; }
.mais { display: flex; justify-content: center; padding: 4px 0 12px; }
.dia { display: flex; align-items: center; gap: 12px; color: var(--texto-3); font-size: 12px; margin: 14px 0 8px; }
.dia::before, .dia::after { content: ''; flex: 1; height: 1px; background: var(--borda); }
.msg { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; padding: 3px 8px; margin: 0 -8px; border-radius: 8px; }
.msg:hover { background: var(--fundo-2); }
.msg.junta { padding-top: 0; }
.msg.junta .msg-avatar { visibility: hidden; height: 0; }
.msg-cabeca { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; }
.msg.junta .msg-cabeca { display: none; }
.msg-autor { font-weight: 600; font-size: 14px; }
.msg-autor.ia { color: var(--acento); }
.etiqueta-ia { font-size: 10px; font-weight: 700; letter-spacing: .06em; padding: 1px 6px; border-radius: 4px; background: var(--acento-fundo); color: var(--acento); align-self: center; }
.msg-hora { font-size: 12px; color: var(--texto-3); }
.msg-texto { overflow-wrap: anywhere; font-size: 15px; }
.msg-texto > :first-child { margin-top: 0; }
.msg.sistema { display: flex; justify-content: center; padding: 6px 8px; }
.msg.sistema:hover { background: transparent; }
.msg.sistema .msg-texto { font-size: 13px; color: var(--texto-2); background: var(--fundo-3); border: 1px solid var(--borda); border-radius: 999px; padding: 4px 14px; text-align: center; }
.msg.sistema .msg-hora { margin-left: 8px; }
.vazio { text-align: center; color: var(--texto-3); padding: 48px 16px; font-size: 14px; }

.markdown p { margin: 0 0 6px; }
.markdown p:last-child, .markdown ul:last-child, .markdown ol:last-child { margin-bottom: 0; }
.markdown ul, .markdown ol { margin: 0 0 6px; padding-left: 22px; }
.markdown li { margin: 2px 0; }
.markdown h3 { font-size: 17px; margin: 14px 0 6px; }
.markdown h4 { font-size: 15px; margin: 12px 0 4px; }
.markdown code { background: var(--fundo-4); border: 1px solid var(--borda); border-radius: 5px; padding: 1px 5px; font-size: .9em; font-family: ui-monospace, 'SF Mono', Menlo, monospace; }
.markdown pre { background: var(--fundo-2); border: 1px solid var(--borda); border-radius: var(--raio-p); padding: 10px 12px; overflow-x: auto; margin: 6px 0; }
.markdown pre code { background: none; border: 0; padding: 0; }
.markdown blockquote { margin: 6px 0; padding: 2px 12px; border-left: 3px solid var(--borda-forte); color: var(--texto-2); }
.mencao { color: var(--acento); background: var(--acento-fundo); border-radius: 5px; padding: 0 4px; font-weight: 500; }

.pensando { padding: 0 20px; min-height: 22px; font-size: 13px; color: var(--texto-2); }
.pensando-item { display: inline-flex; align-items: center; gap: 8px; margin-right: 14px; }
.pontinhos { display: inline-flex; gap: 3px; }
.pontinhos i { width: 5px; height: 5px; border-radius: 50%; background: var(--acento); animation: salto 1.2s infinite ease-in-out; }
.pontinhos i:nth-child(2) { animation-delay: .15s; }
.pontinhos i:nth-child(3) { animation-delay: .3s; }
@keyframes salto { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.compositor {
  display: flex; align-items: flex-end; gap: 10px; padding: 10px 20px 16px; position: relative;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.compositor textarea {
  flex: 1; resize: none; max-height: 180px; min-height: 44px; padding: 11px 14px; border-radius: var(--raio);
  background: var(--fundo-3); border: 1px solid var(--borda-forte); line-height: 1.4;
}
.compositor textarea:focus-visible { outline-offset: 0; border-color: var(--acento); }
.compositor .botao { min-height: 44px; }
.contador { position: absolute; right: 120px; top: -6px; font-size: 12px; color: var(--amarelo); background: var(--fundo); padding: 0 6px; }

/* ---------- Painel lateral ---------- */
.painel { background: var(--fundo-2); border-left: 1px solid var(--borda); display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.painel-topo { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 0 16px; border-bottom: 1px solid var(--borda); }
.abas { display: flex; gap: 4px; }
.aba {
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--texto-2); padding: 10px 8px 12px;
  cursor: pointer; font-weight: 500; font-size: 14px; display: inline-flex; gap: 6px; align-items: center;
}
.aba[aria-selected="true"] { color: var(--texto); border-bottom-color: var(--acento); }
.painel-conteudo { flex: 1; overflow-y: auto; padding: 14px 16px 24px; display: grid; gap: 12px; align-content: start; }
.painel-vazio { color: var(--texto-3); font-size: 14px; text-align: center; padding: 28px 8px; }
.item-relatorio { background: var(--fundo-3); border: 1px solid var(--borda); border-radius: var(--raio); padding: 12px; display: grid; gap: 4px; }
.item-relatorio .quem { font-size: 12px; color: var(--texto-3); }

.proposta { background: var(--fundo-3); border: 1px solid var(--borda); border-radius: var(--raio); padding: 14px; display: grid; gap: 10px; }
.proposta h3 { font-size: 15px; line-height: 1.3; }
.proposta .meta { font-size: 12px; color: var(--texto-3); }
.proposta .secao-titulo { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--texto-3); font-weight: 600; margin-bottom: 2px; }
.proposta .markdown { font-size: 14px; color: var(--texto-2); }
.riscos { margin: 0; padding-left: 18px; font-size: 14px; color: #fcd9a0; }
.proposta-acoes { display: flex; flex-wrap: wrap; gap: 8px; }
.proposta-nota { display: grid; gap: 8px; }
.proposta-nota textarea {
  background: var(--fundo); border: 1px solid var(--borda-forte); border-radius: var(--raio-p); padding: 8px 10px; min-height: 64px; resize: vertical; font-size: 14px;
}
.proposta-nota textarea:focus-visible { outline-offset: 0; border-color: var(--acento); }

/* ---------- Modal e avisos ---------- */
.modal-fundo { position: fixed; inset: 0; background: rgba(4, 6, 10, .72); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { width: 100%; max-width: 680px; max-height: 88vh; max-height: 88dvh; display: flex; flex-direction: column; background: var(--fundo-2); border: 1px solid var(--borda-forte); border-radius: 16px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.modal-topo { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 18px 8px 22px; }
.modal-topo h2 { font-size: 18px; line-height: 1.3; }
.modal-corpo { padding: 8px 22px 16px; overflow-y: auto; font-size: 15px; }
.modal-rodape { padding: 12px 22px 18px; display: flex; gap: 10px; align-items: center; justify-content: space-between; color: var(--texto-3); font-size: 13px; border-top: 1px solid var(--borda); }
.avisos { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; width: min(420px, calc(100vw - 32px)); }
.aviso { background: var(--fundo-4); border: 1px solid var(--borda-forte); border-radius: var(--raio-p); padding: 10px 14px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.aviso.erro { border-color: #7a3a43; color: #fecaca; background: #2a1519; }

.veu { position: fixed; inset: 0; background: rgba(4, 6, 10, .6); z-index: 30; }
.so-celular { display: none; }

/* ---------- Responsivo ---------- */
@media (max-width: 1180px) {
  .app.com-painel { grid-template-columns: var(--lateral) minmax(0, 1fr); }
  .painel {
    position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100vw); z-index: 40; box-shadow: -20px 0 60px rgba(0,0,0,.5);
  }
}
@media (max-width: 760px) {
  .app, .app.com-painel { grid-template-columns: minmax(0, 1fr); }
  .so-celular { display: inline-grid; }
  .lateral {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 86vw); z-index: 40; transform: translateX(-102%);
    transition: transform .2s ease; box-shadow: 20px 0 60px rgba(0,0,0,.5);
  }
  .app.menu-aberto .lateral { transform: none; }
  .topo { padding: 10px 12px; }
  .topo-sala p, .rotulo-longo { display: none; }
  .mesa { padding: 10px 12px; }
  .cartao-ia { width: 248px; }
  .mensagens { padding: 12px; }
  .compositor { padding: 8px 12px max(12px, env(safe-area-inset-bottom)); }
  .contador { right: 100px; }
  .painel { width: 100vw; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Tela inicial ---------- */
a.botao { text-decoration: none; }
.pagina-inicio .cartao-auth { max-width: 460px; text-align: center; justify-items: center; padding: 40px 32px; gap: 16px; }
.pagina-inicio h1 { font-size: 30px; }
.botao-grande { min-height: 56px; padding: 0 28px; font-size: 18px; border-radius: 14px; width: 100%; justify-content: center; }
.inicio-links { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
