:root {
  --fundo: #fff; --suave: #f4f6f5; --linha: #e3e8e6; --texto: #1d2b27; --texto2: #6b7a75;
  --cor: #2f6f5e; --cor-escura: #22513f; --erro: #b3261e; --erro-fundo: #fdecea;
  --fonte: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fundo); color: var(--texto); font: 15px/1.6 var(--fonte); }
a { color: var(--cor); }
h1 { font-size: 1.4rem; font-weight: 600; margin: 0 0 18px; }
.muted { color: var(--texto2); }
.pequeno { font-size: .8rem; }
.centro { text-align: center; }

/* topo */
.topo { display: flex; align-items: center; justify-content: space-between; padding: 10px 20px; border-bottom: 1px solid var(--linha); }
.marca { font-weight: 600; color: var(--texto); text-decoration: none; }
.conta { position: relative; font-size: .9rem; }
.conta summary { cursor: pointer; list-style: none; padding: 4px 10px; border-radius: 8px; color: var(--texto2); }
.conta summary::-webkit-details-marker { display: none; }
.conta summary:hover, .conta[open] summary { background: var(--suave); }
.conta__menu { position: absolute; right: 0; top: 110%; z-index: 5; background: #fff; border: 1px solid var(--linha); border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,.08); min-width: 170px; padding: 6px; display: grid; }
.conta__menu a, .conta__menu button { display: block; text-align: left; padding: 7px 10px; border-radius: 6px; color: var(--texto);
  text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer; width: 100%; }
.conta__menu a:hover, .conta__menu button:hover { background: var(--suave); }
.conta__menu form { margin: 0; }

/* páginas */
.pagina { max-width: 1100px; margin: 0 auto; padding: 28px 20px 40px; }
.pagina--entrar { min-height: 100vh; display: grid; place-items: center; }
.pagina--chat { max-width: none; padding: 0; display: grid; grid-template-columns: 250px 1fr; min-height: calc(100vh - 49px); }
.pagina--chat > .msgs { grid-column: 1 / -1; margin: 12px 20px 0; }
.card { background: #fff; border: 1px solid var(--linha); border-radius: 14px; padding: 24px; }
.entrar { width: 100%; max-width: 340px; }
.entrar h1 { text-align: center; }
.estreito { max-width: 440px; }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: 9px 18px; border-radius: 10px; border: 1px solid var(--cor);
  background: var(--cor); color: #fff; font: 600 .9rem var(--fonte); cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--cor-escura); }
.btn--sec { background: #fff; color: var(--texto); border-color: var(--linha); font-weight: 500; }
.btn--sec:hover { background: var(--suave); }
.btn--largo { width: 100%; }

.f .campo { margin-bottom: 14px; }
.f label { display: block; font-size: .85rem; margin-bottom: 4px; color: var(--texto2); }
.f input:not([type=file]), select { width: 100%; padding: 9px 11px; border: 1px solid var(--linha); border-radius: 10px; font: inherit; background: #fff; color: var(--texto); }
.erro { color: var(--erro); font-size: .82rem; margin-top: 3px; }
.msg { padding: 10px 14px; border-radius: 10px; background: var(--suave); margin-bottom: 10px; font-size: .9rem; }
.msg--error { background: var(--erro-fundo); color: var(--erro); }

/* escolha do assistente */
.agentes { display: grid; gap: 10px; max-width: 420px; margin: 0 auto; }
.agente-card { display: block; padding: 14px 18px; border: 1px solid var(--linha); border-radius: 12px; color: var(--texto); text-decoration: none; }
.agente-card:hover { border-color: var(--cor); background: var(--suave); }

/* lateral */
.lateral { background: var(--suave); border-right: 1px solid var(--linha); padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; }
.historico { display: grid; gap: 2px; overflow-y: auto; }
.historico a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--texto); text-decoration: none; font-size: .88rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.historico a:hover { background: #e9eeec; }
.historico a.on { background: #e1e8e5; font-weight: 600; }
.historico small { color: var(--texto2); }

/* conversa */
.principal { width: 100%; max-width: 820px; margin: 0 auto; padding: 24px 20px 16px; display: flex; flex-direction: column; min-width: 0; }
.principal--vazia { justify-content: center; }
.chat { flex: 1; display: grid; gap: 18px; align-content: start; margin-bottom: 18px; }
.bolha--user { justify-self: end; max-width: 80%; background: var(--suave); border-radius: 16px; padding: 10px 16px; }
.bolha--user p { margin: 0; }
.bolha--assistant { padding: 0 2px; }
.bolha--erro { background: var(--erro-fundo); color: var(--erro); border-radius: 12px; padding: 10px 14px; }
.bolha__acoes { display: flex; gap: 14px; margin-top: 4px; font-size: .8rem; }
.bolha__acoes a, .bolha__acoes button { color: var(--texto2); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: none; }
.bolha__acoes a:hover, .bolha__acoes button:hover { color: var(--texto); }
.anexo { display: inline-block; font-size: .85rem; margin-bottom: 4px; text-decoration: none; }
.texto p { margin: 0 0 .75em; }
.texto h2, .texto h3, .texto h4 { margin: 1em 0 .4em; font-size: 1.02rem; }
.texto ul, .texto ol { padding-left: 1.3em; margin: 0 0 .75em; }
.texto table { border-collapse: collapse; margin: 0 0 .8em; font-size: .9rem; }
.texto th, .texto td { border: 1px solid var(--linha); padding: 5px 9px; text-align: left; vertical-align: top; }
.tabela-wrap { overflow-x: auto; }
.texto code { background: var(--suave); padding: 1px 4px; border-radius: 4px; }
.pensando::after { content: ''; display: inline-block; width: 11px; height: 11px; margin-left: 8px; border: 2px solid var(--cor);
  border-top-color: transparent; border-radius: 50%; animation: gira 1s linear infinite; vertical-align: -1px; }
@keyframes gira { to { transform: rotate(360deg); } }

/* caixa de pergunta */
.pergunta { display: flex; align-items: flex-end; gap: 6px; border: 1px solid var(--linha); border-radius: 22px; padding: 6px 6px 6px 10px;
  background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.04); }
.pergunta:focus-within { border-color: #c3cfca; }
.pergunta__campo { flex: 1; min-width: 0; }
.pergunta textarea { width: 100%; border: 0; outline: none; resize: none; font: inherit; padding: 7px 4px; max-height: 220px; background: transparent; color: var(--texto); }
.anexo-nome { display: block; font-size: .8rem; color: var(--texto2); padding: 4px 4px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.anexar { cursor: pointer; font-size: 1.15rem; padding: 6px; border-radius: 50%; line-height: 1; opacity: .7; }
.anexar:hover { opacity: 1; background: var(--suave); }
.enviar { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--cor); color: #fff; font-size: .95rem; cursor: pointer; flex: none; }
.enviar:hover { background: var(--cor-escura); }
.enviar[disabled] { opacity: .4; }
.rodape { text-align: center; font-size: .75rem; color: var(--texto2); margin: 8px 0 0; }
.excluir { text-align: center; margin-top: 6px; }
.excluir button { background: none; border: 0; color: var(--texto2); font: .75rem var(--fonte); cursor: pointer; text-decoration: underline; }

@media (max-width: 760px) {
  .pagina--chat { grid-template-columns: 1fr; min-height: 0; }
  .lateral { border-right: 0; border-bottom: 1px solid var(--linha); }
  .historico { max-height: 130px; }
  .principal { padding: 18px 16px 14px; }
  .bolha--user { max-width: 92%; }
  .topo { padding: 10px 16px; }
}
