:root {
  --azul: #2563eb;
  --azul-escuro: #1e3a8a;
  --roxo: #7c3aed;
  --verde: #059669;
  --vermelho: #dc2626;
  --amarelo: #d97706;
  --texto: #111827;
  --texto-suave: #4b5563;
  --fundo: #f8fafc;
  --cartao: #ffffff;
  --borda: #e5e7eb;
  --sombra: 0 1px 2px rgba(15, 23, 42, 0.04);
  --raio: 10px;
  font-size: 16px;
}

* { box-sizing: border-box; }

/* O atributo hidden precisa vencer os `display` declarados abaixo. */
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--azul);
  outline-offset: 2px;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  line-height: 1.5;
}

a { color: var(--azul); }

header.topo {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--borda);
  padding: 0.7rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

header.topo h1 {
  font-size: 1.05rem;
  margin: 0;
  letter-spacing: -0.01em;
}

header.topo h1 span { color: var(--azul); }

header.topo nav {
  margin-left: auto;
  display: flex;
  gap: 0.8rem;
  font-size: 0.9rem;
}

header.topo nav a { color: var(--texto-suave); text-decoration: none; }
header.topo nav a:hover { color: var(--azul); }

main { max-width: 1080px; margin: 0 auto; padding: 1.5rem 1.2rem 4rem; }

#quiz, #resultado { scroll-margin-top: 122px; }

.hero {
  text-align: center;
  padding: 2.2rem 1rem 1.2rem;
}

.hero .selo {
  display: inline-block;
  background: #eef2ff;
  color: var(--azul-escuro);
  border-radius: 999px;
  padding: 0.25rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.hero h2 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  margin: 0 0 0.6rem;
  letter-spacing: -0.02em;
}

.hero p { max-width: 620px; margin: 0 auto 1.4rem; color: var(--texto-suave); }

.estado-escolha {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--texto-suave);
}

.estado-escolha select {
  border: 1px solid var(--borda);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  font-size: 0.9rem;
  background: #fff;
  color: var(--texto);
  min-height: 38px;
}

button.botao {
  background: var(--azul);
  border: none;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
  min-height: 40px;
}

button.botao:hover { background: var(--azul-escuro); }
button.botao:disabled { opacity: 0.6; cursor: progress; }
button.botao.secundario {
  background: #fff;
  color: var(--azul);
  border: 1px solid var(--borda);
}

.cartao {
  background: var(--cartao);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: 1.2rem 1.3rem;
  margin-bottom: 1.1rem;
}

.quiz-cartao {
  padding: 0;
  overflow: visible;
}

.quiz-cabecalho {
  position: sticky;
  top: 57px;
  z-index: 6;
  background: var(--cartao);
  border-bottom: 1px solid var(--borda);
  border-radius: var(--raio) var(--raio) 0 0;
  padding: 0.85rem 1.2rem 0.65rem;
}

.quiz-cabecalho-topo {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.84rem;
  color: var(--texto-suave);
  margin-bottom: 0.45rem;
}

.quiz-cabecalho-topo span:first-child {
  font-weight: 700;
  color: var(--texto);
}

.quiz-cabecalho .barra {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.quiz-cabecalho .barra div {
  height: 100%;
  background: var(--azul);
  width: 0%;
  transition: width 0.25s ease;
}

#quiz-perguntas {
  padding: 0.4rem 1.2rem 0;
}

.quiz-rodape {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  padding: 1rem 1.2rem 1.2rem;
}

.eixo-bloco h3 {
  font-size: 1.05rem;
  margin: 0 0 0.2rem;
}

.eixo-bloco .descricao { color: var(--texto-suave); font-size: 0.88rem; margin-bottom: 0.8rem; }

.pergunta {
  border-top: 1px solid var(--borda);
  padding: 0.8rem 0;
}

.pergunta:first-of-type { border-top: none; }

.pergunta-estado {
  background: #f8fafc;
  margin: 0 -1.2rem;
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--borda);
}

.pergunta-estado .estado-escolha {
  justify-content: flex-start;
  margin-bottom: 0;
}

.pergunta p { margin: 0 0 0.55rem; font-size: 0.95rem; }

.likert { display: flex; gap: 0.45rem; flex-wrap: wrap; }

.likert label {
  cursor: pointer;
  font-size: 0.78rem;
  border: 1px solid var(--borda);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  color: var(--texto-suave);
  background: #fff;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  user-select: none;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
}

.likert input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.likert input:focus-visible + span {
  outline: 2px solid var(--azul);
  outline-offset: 3px;
  border-radius: 4px;
}

.likert label:hover { border-color: #c7d2fe; }
.likert label.selecionada { background: var(--azul); color: #fff; border-color: var(--azul); }

.tipo-perfil {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.tipo-perfil .codigo {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.15rem;
  color: var(--azul-escuro);
}

.tipo-perfil .rotulo { color: var(--texto-suave); }

.eixos-resumo { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0.7rem; margin-top: 0.8rem; }

.eixo-mini { background: #f1f5f9; border-radius: 10px; padding: 0.6rem 0.7rem; font-size: 0.82rem; }
.eixo-mini .titulo { font-weight: 600; margin-bottom: 0.3rem; }
.eixo-mini .trilho { height: 6px; background: #cbd5e1; border-radius: 999px; position: relative; }
.eixo-mini .trilho .centro { position: absolute; left: 50%; top: -2px; width: 1px; height: 10px; background: #94a3b8; }
.eixo-mini .trilho .marcador { position: absolute; top: -3px; width: 12px; height: 12px; border-radius: 50%; background: var(--azul); transform: translateX(-50%); }

.abas { display: flex; gap: 0.4rem; flex-wrap: wrap; margin: 1rem 0 1.1rem; }

.abas button {
  border: 1px solid var(--borda);
  background: #fff;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--texto-suave);
  min-height: 36px;
}

.abas button.ativa { background: var(--azul-escuro); border-color: var(--azul-escuro); color: #fff; font-weight: 600; }

.lista-candidatos { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 0.9rem; }

.candidato-cartao {
  background: var(--cartao);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: 0.9rem;
  display: flex;
  gap: 0.8rem;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease;
}

.candidato-cartao:hover { transform: translateY(-2px); border-color: #c7d2fe; }

.candidato-cartao .foto {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  background: #e2e8f0;
  flex-shrink: 0;
}

.candidato-cartao .iniciais {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #dbeafe;
  color: var(--azul-escuro);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.candidato-cartao .info { flex: 1; min-width: 0; }
.candidato-cartao .nome { font-weight: 700; font-size: 0.95rem; }
.candidato-cartao .meta { color: var(--texto-suave); font-size: 0.8rem; margin-bottom: 0.35rem; }
.candidato-cartao .rodape { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.pill {
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}

.pill.match { background: #dcfce7; color: #15803d; }
.pill.match.baixo { background: #fef9c3; color: #a16207; }
.pill.match.ruim { background: #fee2e2; color: #b91c1c; }
.pill.sem { background: #f1f5f9; color: #64748b; }
.pill.aviso { background: #fef3c7; color: #92400e; }

.barras-eixo { display: grid; gap: 0.25rem; margin-top: 0.4rem; }
.barra-eixo { display: flex; align-items: center; gap: 0.4rem; font-size: 0.72rem; color: var(--texto-suave); }
.barra-eixo .rotulo { width: 96px; }
.barra-eixo .trilho { flex: 1; height: 7px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.barra-eixo .trilho div { height: 100%; border-radius: 999px; background: var(--azul); }
.barra-eixo .trilho div.alto { background: var(--verde); }
.barra-eixo .trilho div.baixo { background: var(--vermelho); }

.lista-simples { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.6rem; }
.lista-simples span {
  border: 1px solid var(--borda);
  background: #fff;
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  color: var(--texto-suave);
}

.aviso-dados {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: var(--raio);
  padding: 0.8rem 1rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 40;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 2.4rem 1rem;
  overflow-y: auto;
}

.overlay .janela {
  background: #fff;
  border-radius: 18px;
  max-width: 820px;
  width: 100%;
  padding: 1.4rem 1.5rem 2rem;
  position: relative;
}

.overlay .fechar {
  position: absolute;
  right: 1rem;
  top: 0.9rem;
  border: none;
  background: #f1f5f9;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
}

.dossie-cabecalho { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.dossie-cabecalho .foto, .dossie-cabecalho .iniciais { width: 84px; height: 84px; font-size: 1.4rem; }
.dossie-cabecalho h3 { margin: 0; font-size: 1.35rem; }
.dossie-cabecalho .meta { color: var(--texto-suave); font-size: 0.9rem; }

table.tabela { width: 100%; border-collapse: collapse; font-size: 0.86rem; margin-top: 0.6rem; }
table.tabela th, table.tabela td { border-bottom: 1px solid var(--borda); padding: 0.5rem 0.45rem; text-align: left; vertical-align: top; }
table.tabela th { color: var(--texto-suave); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
table.tabela td.num { white-space: nowrap; }

.voto-sim { color: var(--verde); font-weight: 700; }
.voto-nao { color: var(--vermelho); font-weight: 700; }
.voto-outro { color: var(--texto-suave); }

.alinhado { color: var(--verde); }
.contrario { color: var(--vermelho); }

.aviso-neutro {
  background: #f8fafc;
  border-left: 4px solid var(--azul);
  padding: 0.7rem 0.9rem;
  border-radius: 8px;
  color: var(--texto-suave);
  font-size: 0.84rem;
  margin-top: 1rem;
}

#verificador {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: min(420px, calc(100vw - 2rem));
  max-height: min(560px, calc(100vh - 2rem));
  background: #fff;
  border: 1px solid var(--borda);
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 70;
}

#verificador header {
  background: var(--azul-escuro);
  color: #fff;
  padding: 0.6rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

#verificador header .avatar-topo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #eef2ff;
  border: 2px solid rgba(255, 255, 255, 0.55);
  flex-shrink: 0;
}

#verificador .titulo-verificador { display: flex; flex-direction: column; line-height: 1.15; }
#verificador .titulo-verificador b { font-size: 0.92rem; }
#verificador .titulo-verificador span { font-size: 0.72rem; opacity: 0.82; }

#verificador header button {
  margin-left: auto;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
}

#verificador .mensagens {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem 0.8rem;
  font-size: 0.86rem;
  background: #fbfaf7;
}

.msg-linha { display: flex; gap: 0.5rem; margin-bottom: 0.7rem; align-items: flex-end; }
.msg-linha.usuario { justify-content: flex-end; }

.avatar-mini {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #eef2ff;
  border: 1px solid var(--borda);
  flex-shrink: 0;
}

.msg-linha .msg {
  max-width: 84%;
  padding: 0.55rem 0.75rem;
  border-radius: 14px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.msg-linha.agente .msg.agente {
  background: #fffdf8;
  border: 1px solid #efe6d9;
  border-bottom-left-radius: 4px;
  color: var(--texto);
}

.msg-linha.usuario .msg.usuario {
  background: #dbeafe;
  border: 1px solid #bfdbfe;
  border-bottom-right-radius: 4px;
  color: #1e3a8a;
}

.msg-linha .msg.erro { background: #fef2f2; border-color: #fecaca; color: var(--vermelho); }

.msg.agente p { margin: 0 0 0.5rem; }
.msg.agente p:last-child { margin-bottom: 0; }
.msg.agente ul,
.msg.agente ol { margin: 0.3rem 0 0.5rem; padding-left: 1.2rem; }
.msg.agente li { margin-bottom: 0.2rem; }
.msg.agente code { background: #f5efe4; padding: 0.05rem 0.3rem; border-radius: 4px; font-size: 0.85em; }
.msg.agente pre { background: #0f172a; color: #e2e8f0; padding: 0.6rem 0.7rem; border-radius: 8px; overflow-x: auto; }
.msg.agente pre code { background: transparent; color: inherit; padding: 0; }
.msg.agente a { color: var(--azul); }

.msg.ferramenta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.55rem 34px;
  background: #f1f5f9;
  border: 1px solid var(--borda);
  color: var(--texto-suave);
  font-size: 0.73rem;
  border-radius: 999px;
  padding: 0.18rem 0.6rem;
}

.msg.ferramenta::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  flex-shrink: 0;
}

.msg.digitando { display: inline-flex; gap: 4px; align-items: center; min-height: 1.2em; }
.msg.digitando span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a8a29e;
  animation: pulsar 1s infinite ease-in-out;
}
.msg.digitando span:nth-child(2) { animation-delay: 0.15s; }
.msg.digitando span:nth-child(3) { animation-delay: 0.3s; }

@keyframes pulsar {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.estado-erro { padding: 0.8rem 0; }
.estado-erro p { margin: 0 0 0.5rem; }

.tabela-wrap { overflow-x: auto; }

.aviso-erro {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: var(--raio);
  padding: 0.8rem 1rem;
  font-size: 0.88rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.acoes-resultado {
  display: flex;
  justify-content: center;
  margin: 0.2rem 0 1.2rem;
}
#verificador form { display: flex; gap: 0.4rem; padding: 0.6rem; border-top: 1px solid var(--borda); background: #fff; }
#verificador input {
  flex: 1;
  border: 1px solid var(--borda);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  font-size: 0.88rem;
  background: #f8fafc;
}
#verificador input:focus-visible { background: #fff; }
#verificador button.enviar {
  background: var(--azul);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  font-weight: 600;
}
#verificador .rodape-verificador { padding: 0 0.7rem 0.6rem; font-size: 0.72rem; color: var(--texto-suave); background: #fff; }

.botao-flutuante {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 45;
  background: var(--azul-escuro);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 0.9rem 0.5rem 0.6rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(30, 58, 138, 0.25);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.botao-flutuante img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #eef2ff;
}

body.modal-aberto .botao-flutuante { display: none; }

@media (max-width: 640px) {
  main { padding-bottom: 5.5rem; }
}

footer.rodape {
  border-top: 1px solid var(--borda);
  padding: 1.6rem 1.2rem;
  color: var(--texto-suave);
  font-size: 0.82rem;
  text-align: center;
  background: #fff;
}

footer.rodape a { color: var(--texto-suave); }

.grid-ficha { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.5rem; margin-top: 0.8rem; font-size: 0.84rem; }
.grid-ficha div { background: #f8fafc; border-radius: 8px; padding: 0.45rem 0.6rem; }
.grid-ficha b { display: block; color: var(--texto-suave); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; }

.carregando { color: var(--texto-suave); font-size: 0.9rem; padding: 1rem 0; }
.vazio { color: var(--texto-suave); font-size: 0.9rem; }

h3.secao-titulo { margin: 1.6rem 0 0.6rem; font-size: 1.1rem; }
