:root {
  --fundo: #0d1117;
  --fundo-2: #161b22;
  --fundo-3: #1f2630;
  --borda: #2d3748;
  --texto: #e6edf3;
  --texto-2: #8b949e;
  --acento: #58a6ff;
  --acento-forte: #1f6feb;
  --ok: #3fb950;
  --alerta: #d29922;
  --erro: #f85149;
  --raio: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--fundo);
  color: var(--texto);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

.escondido { display: none !important; }

/* ---------------- login ---------------- */
.tela-login {
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: radial-gradient(900px 500px at 50% -10%, #16233a 0%, var(--fundo) 60%);
}

.cartao-login {
  width: 100%; max-width: 400px;
  background: var(--fundo-2);
  border: 1px solid var(--borda);
  border-radius: 14px;
  padding: 28px 24px 20px;
}

.marca { display: flex; gap: 12px; align-items: center; margin-bottom: 24px; }

.logo {
  width: 44px; height: 44px; flex: 0 0 44px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--acento), #1f6feb);
  color: #fff; font-weight: 700; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
}
.logo.pequeno { width: 30px; height: 30px; flex-basis: 30px; font-size: 15px; border-radius: 8px; }

.marca h1 { margin: 0; font-size: 19px; letter-spacing: -0.2px; }
.sub { margin: 2px 0 0; font-size: 13px; color: var(--texto-2); }

label { display: block; font-size: 13px; color: var(--texto-2); margin: 14px 0 6px; }

input, textarea, select {
  width: 100%;
  background: var(--fundo-3);
  border: 1px solid var(--borda);
  color: var(--texto);
  border-radius: var(--raio);
  padding: 11px 13px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--acento); }
input::placeholder, textarea::placeholder { color: #5b6675; }

button {
  cursor: pointer; font-family: inherit; font-size: 15px;
  border-radius: var(--raio); border: 1px solid transparent;
  background: var(--acento-forte); color: #fff;
  padding: 11px 18px; font-weight: 500;
  transition: filter .15s;
}
button:hover { filter: brightness(1.12); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.link { background: none; border: none; color: var(--texto-2); padding: 6px 8px; font-size: 14px; }
button.link:hover { color: var(--texto); }

#btn-entrar { width: 100%; margin-top: 20px; }

.erro { color: var(--erro); font-size: 13px; margin: 12px 0 0; }
.aviso { font-size: 13px; margin: 10px 0 0; color: var(--ok); }
.aviso.ruim { color: var(--erro); }
.rodape { color: var(--texto-2); font-size: 12px; text-align: center; margin: 20px 0 0; }

/* ---------------- topo ---------------- */
#tela-app { display: flex; flex-direction: column; height: 100%; }

.topo {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px;
  background: var(--fundo-2);
  border-bottom: 1px solid var(--borda);
  flex: 0 0 auto;
}
.marca-topo { display: flex; align-items: center; gap: 9px; }
.titulo { font-weight: 600; letter-spacing: -0.2px; }

.abas { display: flex; gap: 4px; margin-left: 8px; }
.aba {
  background: none; border: none; color: var(--texto-2);
  padding: 7px 12px; border-radius: 8px; font-size: 14px;
}
.aba:hover { background: var(--fundo-3); color: var(--texto); }
.aba.ativa { background: var(--fundo-3); color: var(--texto); }

.usuario { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--texto-2); }

/* ---------------- chat ---------------- */
.painel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
#painel-usuarios { overflow-y: auto; padding: 20px; gap: 16px; display: block; }

.conversa {
  flex: 1 1 auto; overflow-y: auto;
  padding: 22px 16px 10px;
  display: flex; flex-direction: column; gap: 16px;
}

.vazio { margin: auto; text-align: center; max-width: 560px; padding: 20px; }
.vazio h2 { font-size: 22px; margin: 0 0 6px; letter-spacing: -0.3px; }
.vazio p { color: var(--texto-2); margin: 0 0 22px; font-size: 14px; }
.sugestoes { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.sugestao {
  background: var(--fundo-2); border: 1px solid var(--borda); color: var(--texto);
  padding: 9px 14px; border-radius: 999px; font-size: 13.5px;
}
.sugestao:hover { border-color: var(--acento); color: var(--acento); }

.msg { max-width: 780px; width: 100%; margin: 0 auto; display: flex; gap: 10px; }
.msg .quem {
  flex: 0 0 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.msg.usuario .quem { background: var(--fundo-3); color: var(--texto-2); }
.msg.assistente .quem { background: linear-gradient(135deg, var(--acento), #1f6feb); color: #fff; }

.balao {
  flex: 1 1 auto; min-width: 0;
  background: var(--fundo-2);
  border: 1px solid var(--borda);
  border-radius: 12px;
  padding: 13px 15px;
}
.msg.usuario .balao { background: var(--fundo-3); }
.balao p { margin: 0 0 9px; }
.balao p:last-child { margin-bottom: 0; }
.balao ul { margin: 6px 0; padding-left: 20px; }
.balao li { margin: 3px 0; }
.balao strong { color: #fff; }
.balao a { color: var(--acento); }

.selo {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; margin-bottom: 8px;
  text-transform: uppercase; letter-spacing: .4px;
}
.selo.documentos { background: #1f6feb33; color: #79c0ff; border: 1px solid #1f6feb66; }
.selo.dados { background: #23863633; color: #56d364; border: 1px solid #23863666; }
.selo.mista { background: #9e6a0333; color: #e3b341; border: 1px solid #9e6a0366; }

.detalhes { margin-top: 10px; border-top: 1px solid var(--borda); padding-top: 9px; }
.detalhes summary {
  cursor: pointer; font-size: 12.5px; color: var(--texto-2); list-style: none;
  display: flex; align-items: center; gap: 6px;
}
.detalhes summary::-webkit-details-marker { display: none; }
.detalhes summary::before { content: "▸"; transition: transform .15s; }
.detalhes[open] summary::before { transform: rotate(90deg); }
.detalhes pre {
  background: var(--fundo); border: 1px solid var(--borda); border-radius: 8px;
  padding: 10px; overflow-x: auto; font-size: 12px; color: #a5d6ff;
  margin: 9px 0 0; white-space: pre-wrap; word-break: break-word;
}
.fontes { margin: 8px 0 0; padding: 0; list-style: none; font-size: 12.5px; }
.fontes li { margin: 4px 0; color: var(--texto-2); }

.digitando { display: inline-flex; gap: 4px; align-items: center; }
.digitando span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--texto-2);
  animation: pisca 1.2s infinite;
}
.digitando span:nth-child(2) { animation-delay: .2s; }
.digitando span:nth-child(3) { animation-delay: .4s; }
@keyframes pisca { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* ---------------- barra de pergunta ---------------- */
.barra-pergunta {
  flex: 0 0 auto;
  display: flex; gap: 9px; align-items: flex-end;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--fundo-2);
  border-top: 1px solid var(--borda);
}
.barra-pergunta textarea {
  resize: none; max-height: 140px; overflow-y: auto;
  padding: 11px 13px; line-height: 1.4;
}
#btn-enviar {
  flex: 0 0 42px; width: 42px; height: 42px; padding: 0;
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
}

/* ---------------- usuários ---------------- */
.cartao {
  background: var(--fundo-2); border: 1px solid var(--borda);
  border-radius: 12px; padding: 18px; margin: 0 auto 16px; max-width: 900px;
}
.cartao h2 { font-size: 15px; margin: 0 0 14px; letter-spacing: -0.2px; }
.ajuda { font-size: 13px; color: var(--texto-2); margin: -6px 0 14px; }
.codigo-grande {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 26px; letter-spacing: 8px; font-weight: 700; color: var(--acento);
  background: var(--fundo); border: 1px dashed var(--borda); border-radius: var(--raio);
  padding: 12px; text-align: center; margin: 12px 0 4px;
}

.form-linha { display: flex; flex-wrap: wrap; gap: 9px; }
.form-linha input, .form-linha select { flex: 1 1 180px; width: auto; }
.form-linha button { flex: 0 0 auto; }

.lista-usuarios { display: flex; flex-direction: column; gap: 8px; }
.linha-usuario {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 11px 13px; background: var(--fundo-3);
  border-radius: 9px; font-size: 14px;
}
.linha-usuario .dados { flex: 1 1 220px; min-width: 0; }
.linha-usuario .email { color: var(--texto-2); font-size: 12.5px; }
.papel {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: #1f6feb33; color: #79c0ff; border: 1px solid #1f6feb66;
}
.papel.admin { background: #9e6a0333; color: #e3b341; border-color: #9e6a0366; }
.inativo { opacity: .55; }
.linha-usuario button { padding: 6px 12px; font-size: 13px; background: var(--fundo-2); border: 1px solid var(--borda); color: var(--texto); }

/* ---------------- mobile ---------------- */
@media (max-width: 640px) {
  .topo { padding: 9px 12px; gap: 8px; }
  .titulo { display: none; }
  .usuario span { display: none; }
  .abas { margin-left: 0; }
  .conversa { padding: 16px 12px 8px; }
  .barra-pergunta { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .vazio h2 { font-size: 19px; }
  #painel-usuarios { padding: 12px; }
  .cartao { padding: 14px; }
}
