:root {
  /* Paleta oficial ETM Engenharia */
  --azul-escuro: #063057; /* azul etm - Pantone 648 C */
  --azul: #77ae43;        /* verde etm com contraste (Pantone 2294 C), usado como cor de acao/link */
  --verde: #77ae43;       /* verde etm + contraste */
  --verde-claro: #8dc63f; /* verde etm - Pantone 2292 C */
  --vermelho: #c0392b;
  --amarelo: #b8860b;
  --cinza: #636466;       /* cinza etm textos - Pantone Cool Gray 10 C */
  --cinza-claro: #a7a9ac; /* cinza etm - Pantone Cool Gray 6 C */
  --fundo: #dcddde;       /* cinza fundos - Pantone Cool Gray 1 C */
  --borda: #c9cccd;
}

* { box-sizing: border-box; }

.icone {
  flex-shrink: 0;
  vertical-align: middle;
  position: relative;
  top: -1px;
}

button, .botao-primario, .botao-secundario, .botao-microsoft {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.acoes-tabela button { display: inline-flex; }

body {
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--fundo);
  color: #1f2937;
  margin: 0;
  padding: 0;
}

.container {
  max-width: 780px;
  margin: 40px auto;
  padding: 32px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

h1 {
  color: var(--azul-escuro);
  font-size: 1.5rem;
  margin-top: 0;
}

.subtitulo {
  color: var(--cinza);
  margin-bottom: 28px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--borda);
  border-radius: 8px;
  margin-bottom: 24px;
  font-size: 1rem;
}

.dropzone {
  border: 2px dashed var(--azul);
  border-radius: 10px;
  padding: 48px 20px;
  text-align: center;
  color: var(--cinza);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.dropzone.arrastando {
  background: #eaf3fb;
  border-color: var(--azul-escuro);
}

.dropzone strong { color: var(--azul-escuro); }

#nome-arquivo {
  margin-top: 14px;
  font-weight: 600;
  color: var(--azul-escuro);
}

button {
  margin-top: 24px;
  width: 100%;
  padding: 14px;
  background: var(--azul);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  background: var(--cinza);
  cursor: not-allowed;
}

.erro {
  color: var(--vermelho);
  margin-top: 12px;
  font-weight: 600;
}

.barra-progresso {
  width: 100%;
  height: 22px;
  background: var(--borda);
  border-radius: 12px;
  overflow: hidden;
  margin: 20px 0;
}

.barra-progresso-interna {
  height: 100%;
  background: var(--verde);
  width: 0%;
  transition: width 0.3s ease;
  text-align: center;
  color: #fff;
  font-size: 0.8rem;
  line-height: 22px;
  white-space: nowrap;
}

.resumo {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.resumo-item {
  flex: 1;
  min-width: 100px;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  background: var(--fundo);
}

.resumo-item .numero { font-size: 1.6rem; font-weight: 700; display: block; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--borda);
  font-size: 0.92rem;
}

th { color: var(--cinza); font-weight: 600; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
}

.botao-copiar-link {
  background: none;
  border: 1px solid var(--borda);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--azul-escuro);
  white-space: nowrap;
}

.botao-copiar-link:hover { background: var(--fundo); }

.badge-processando { background: var(--amarelo); }
.badge-enviado { background: var(--verde); }
.badge-erro { background: var(--vermelho); }
.badge-ignorado { background: var(--cinza-claro); }

.badge-assinatura-pendente { background: var(--cinza-claro); }
.badge-assinatura-visualizado { background: var(--amarelo); }
.badge-assinatura-assinado { background: var(--verde); }
.badge-assinatura-rejeitado { background: var(--vermelho); }

.badge-metodo { background: var(--cinza); font-weight: 500; }

.voltar {
  display: inline-block;
  margin-top: 20px;
  color: var(--azul);
  text-decoration: none;
  font-weight: 600;
}

/* ------------------------------------------------------------------ */
/* Layout autenticado (sidebar + conteudo)                             */
/* ------------------------------------------------------------------ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--azul-escuro);
  color: #dbe7f2;
  padding: 24px 0;
  flex-shrink: 0;
}

.sidebar .marca {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px 20px;
  font-weight: 700;
  font-size: 1.3rem;
  letter-spacing: -0.01em;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 12px;
}

.marca-logo {
  height: 32px;
  width: auto;
  max-width: 40px;
  object-fit: contain;
  border-radius: 4px;
  background: #fff;
  padding: 2px;
}

.login-titulo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.login-titulo .marca-logo { height: 40px; max-width: 52px; }

.linha-logo-atual {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-preview {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border: 1px solid var(--borda);
  border-radius: 8px;
  background: var(--fundo);
  padding: 6px;
  flex-shrink: 0;
}

.logo-preview-vazio {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  color: var(--cinza);
  text-align: center;
}

.marca-sub {
  display: block;
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #a9c2d9;
  margin-top: 2px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: #cfe0ee;
  text-decoration: none;
  font-size: 0.95rem;
  border-left: 3px solid transparent;
}

.sidebar nav a .icone { opacity: 0.85; }
.sidebar nav a.ativo .icone { opacity: 1; }

.sidebar nav a:hover { background: rgba(255, 255, 255, 0.06); }

.sidebar nav a.ativo {
  background: rgba(255, 255, 255, 0.1);
  border-left-color: #fff;
  color: #fff;
  font-weight: 600;
}

.sidebar .usuario-atual {
  padding: 16px 24px 0;
  margin-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.85rem;
  color: #a9c2d9;
}

.sidebar .usuario-atual strong { display: block; color: #fff; }

.sidebar .sair {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 24px 0;
  color: #ffb4b4;
  font-size: 0.85rem;
  text-decoration: none;
}

.conteudo-principal {
  flex: 1;
  padding: 40px 32px;
  display: flex;
  justify-content: center;
}

.conteudo-central {
  width: 100%;
  max-width: 860px;
}

.conteudo-central-largo { max-width: 1400px; }

.conteudo-principal h1 {
  color: var(--azul-escuro);
  font-size: 1.4rem;
  margin-top: 0;
  margin-bottom: 24px;
}

/* ------------------------------------------------------------------ */
/* Responsivo: menu lateral vira gaveta (off-canvas) em telas estreitas */
/* ------------------------------------------------------------------ */
.botao-menu-mobile {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  background: var(--azul-escuro);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  width: auto;
  margin: 0;
  cursor: pointer;
}

.fundo-menu-mobile {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 149;
}

.fundo-menu-mobile.visivel { display: block; }

@media (max-width: 860px) {
  .botao-menu-mobile { display: inline-flex; }

  .app-shell { flex-direction: column; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: min(280px, 82vw);
    z-index: 150;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.sidebar-aberta { transform: translateX(0); }

  .sidebar .marca { padding-top: 8px; }

  .conteudo-principal {
    padding: 72px 16px 32px;
  }
}

@media (max-width: 600px) {
  .conteudo-principal { padding: 64px 12px 24px; }
  .cartao-corpo { padding: 14px; }
  .container { margin: 16px auto; padding: 20px; }
  .resumo-item { min-width: 80px; }
}

/* ------------------------------------------------------------------ */
/* Cartoes de configuracao (estilo Configuracoes de APIs)              */
/* ------------------------------------------------------------------ */
.cartao {
  background: #fff;
  border: 1px solid var(--borda);
  border-radius: 10px;
  margin-bottom: 24px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(6, 48, 87, 0.06);
}

.cartao-titulo {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f4f6f8;
  padding: 14px 20px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--azul-escuro);
  border-bottom: 1px solid var(--borda);
}

.cartao-titulo .icone { color: var(--cinza); }

.cartao-corpo { padding: 20px; }

.grade-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grade-filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: start;
}

.grade-filtros > div {
  flex: 1 1 160px;
  min-width: 160px;
}

.grade-filtros .filtro-botao {
  flex: 0 0 auto;
  min-width: 120px;
}

/* A coluna do botao tem um <label> identico aos outros (com
   visibility:hidden) reservando exatamente a mesma altura do rotulo
   das colunas vizinhas - evita ter que calcular/adivinhar um
   padding-top manual em px que quebra sempre que o texto do rotulo
   muda. */
.grade-filtros .filtro-botao .campo-label { visibility: hidden; }

/* Sobrescreve .cartao-corpo input[type="text"] (mesma especificidade,
   mas declarada antes no arquivo) para os inputs de texto dentro dos
   filtros nao ganharem margin-bottom - isso fazia o item de grid ficar
   mais alto que os <select> vizinhos e "descer" com align-items:end. */
form.grade-filtros input[type="text"] { margin-bottom: 0; }

.grade-filtros select, .grade-filtros input[type="text"] {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 10px;
  border: 1px solid var(--borda);
  border-radius: 8px;
  box-sizing: border-box;
}

/* Altura fixa e igual a dos inputs acima - nao depende de padding
   "parecido" entre <input>/<select> e <button>, que tem fonte e
   padding proprios e por isso nunca ficam com a mesma altura por
   coincidencia. */
.filtro-botao .botao-secundario {
  height: 44px;
  padding: 0 20px;
  box-sizing: border-box;
  width: 100%;
  white-space: nowrap;
}

.botao-reenviar {
  background: none;
  border: 1px solid var(--amarelo);
  color: var(--amarelo);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}

.botao-reenviar:hover { background: #fdf6e3; }
.botao-reenviar:disabled { opacity: 0.6; cursor: not-allowed; }

#resultado-documentos.filtros-carregando { opacity: 0.5; pointer-events: none; transition: opacity 0.15s; }

@media (max-width: 600px) {
  .grade-filtros > div,
  .grade-filtros .filtro-botao {
    flex-basis: 100%;
  }
}

.campo-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--cinza);
  margin-bottom: 6px;
}

.cartao-corpo input[type="text"],
.cartao-corpo input[type="email"],
.cartao-corpo input[type="password"],
.cartao-corpo input[type="url"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--borda);
  border-radius: 8px;
  font-size: 0.95rem;
  margin-bottom: 16px;
}

.aviso {
  background: #fdf6e3;
  border: 1px solid #f0e0a8;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 0.88rem;
  color: #7a5b00;
  margin-bottom: 16px;
}

.linha-botoes {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.linha-botoes button {
  width: auto;
  margin-top: 0;
}

.botao-primario, .botao-secundario {
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  border: none;
}

.botao-primario {
  background: var(--azul-escuro);
  color: #fff;
  flex: 1;
}

.botao-secundario {
  background: #fff;
  color: var(--azul-escuro);
  border: 1px solid var(--borda);
}

.botao-perigo {
  padding: 12px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  background: #fff;
  color: var(--vermelho);
  border: 1px solid #f0c9c3;
}

.botao-perigo:hover:not(:disabled) { background: #fdecea; }

.botao-perigo:disabled {
  background: #fff;
  color: var(--cinza-claro);
  border-color: var(--borda);
  cursor: not-allowed;
}

.resultado-teste {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  display: none;
}

.resultado-teste.ok { background: #e7f6ec; color: #1e7e37; display: block; }
.resultado-teste.falha { background: #fdecea; color: var(--vermelho); display: block; }

/* ------------------------------------------------------------------ */
/* Tela de login                                                       */
/* ------------------------------------------------------------------ */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(560px circle at 15% 10%, rgba(119, 174, 67, 0.10), transparent 60%),
    radial-gradient(620px circle at 85% 90%, rgba(6, 48, 87, 0.10), transparent 60%),
    var(--fundo);
}

.login-cartao {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 1px 2px rgba(6, 48, 87, 0.04), 0 16px 40px -12px rgba(6, 48, 87, 0.18);
  border: 1px solid rgba(6, 48, 87, 0.06);
}

.login-titulo {
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

.login-cartao h1 {
  font-size: 1.25rem;
  color: var(--azul-escuro);
  margin: 0 0 4px;
}

.login-cartao .subtitulo {
  margin-bottom: 28px;
  font-size: 0.9rem;
  line-height: 1.45;
  text-align: center;
}

.campo-label-oculto {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.login-cartao input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--borda);
  border-radius: 9px;
  margin-bottom: 14px;
  font-size: 0.95rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-cartao input:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(119, 174, 67, 0.15);
}

.separador {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--cinza);
  font-size: 0.78rem;
  margin: 20px 0;
}

.separador::before,
.separador::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--borda);
}

.botao-microsoft {
  width: 100%;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--borda);
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.92rem;
  color: #1f2937;
  cursor: pointer;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

.botao-microsoft:hover {
  border-color: var(--cinza-claro);
  box-shadow: 0 2px 8px rgba(6, 48, 87, 0.08);
}

.botao-microsoft:active { transform: translateY(1px); }

.icone-microsoft { flex-shrink: 0; }

.botao-microsoft.desabilitado {
  color: var(--cinza);
  cursor: not-allowed;
  pointer-events: none;
}

.login-cartao button[type="submit"] {
  margin-top: 4px;
  border-radius: 9px;
  transition: filter 0.15s ease, transform 0.05s ease;
}

.login-cartao button[type="submit"]:hover { filter: brightness(1.05); }
.login-cartao button[type="submit"]:active { transform: translateY(1px); }

.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  font-size: 0.9rem;
}

.flash-erro { background: #fdecea; color: var(--vermelho); }
.flash-sucesso { background: #e7f6ec; color: #1e7e37; }

/* ------------------------------------------------------------------ */
/* Tela de usuarios                                                     */
/* ------------------------------------------------------------------ */
.barra-acoes {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}

.cabecalho-pagina {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.botao-compacto {
  flex: none;
  padding: 10px 18px;
  width: auto;
  margin-top: 0;
}

.cartao table {
  margin: 0;
}

.cartao table th, .cartao table td {
  padding: 14px 20px;
}

.cartao table thead tr {
  background: #f4f6f8;
}

.cartao table tr:last-child td {
  border-bottom: none;
}

.badge-papel {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
}

.badge-papel.admin { background: var(--azul-escuro); }
.badge-papel.rh { background: var(--cinza); }

.badge-ativo { color: var(--verde); font-weight: 600; }
.badge-inativo { color: var(--vermelho); font-weight: 600; }

.acoes-tabela {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}

.acoes-tabela button, .acoes-tabela summary {
  background: none;
  border: 1px solid var(--borda);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--azul-escuro);
  white-space: nowrap;
}

.acoes-tabela button:hover { background: var(--fundo); }

.acoes-tabela .botao-perigo {
  color: var(--vermelho);
  border-color: #f0c9c3;
}

.acoes-tabela .botao-perigo:hover { background: #fdecea; }

.modal-fundo {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-fundo.aberto { display: flex; }

.modal-caixa {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  width: 380px;
}

.modal-caixa h2 { margin-top: 0; font-size: 1.1rem; color: var(--azul-escuro); }

.modal-caixa input, .modal-caixa select {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--borda);
  border-radius: 8px;
  margin-bottom: 14px;
}

.modal-caixa label { font-size: 0.85rem; margin-bottom: 4px; }

/* ------------------------------------------------------------------ */
/* Matriz de acesso                                                    */
/* ------------------------------------------------------------------ */
.tabela-matriz-wrap { overflow-x: auto; }

/* Impede que celulas quebrem em varias linhas espremendo o conteudo -
   sem isso, o navegador prefere quebrar texto (linhas irregulares,
   "Obra"/"Nome" em 2 linhas) em vez de deixar a tabela mais larga que
   o container e rolar horizontalmente. Com nowrap, cada linha fica com
   altura uniforme e nada e cortado - so rola pra ver colunas fora da
   tela, o scroll de .tabela-matriz-wrap ja cuida disso. */
.tabela-nowrap th, .tabela-nowrap td { white-space: nowrap; }

.paginacao {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: 1px solid var(--borda);
}

.paginacao-info { color: var(--cinza); font-size: 0.88rem; }

.paginacao-botoes { display: flex; gap: 10px; }

.paginacao-botoes .botao-compacto { padding: 8px 16px; }

.paginacao-botoes a.desabilitado {
  pointer-events: none;
  opacity: 0.4;
}

/* ------------------------------------------------------------------ */
/* Abas (ex.: Colaboradores - Obras / Colaboradores)                   */
/* ------------------------------------------------------------------ */
.abas {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--borda);
  margin-bottom: 20px;
}

.aba-botao {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--cinza);
  cursor: pointer;
  margin-bottom: -1px;
}

.aba-botao:hover { color: var(--azul-escuro); }

.aba-botao.ativo {
  color: var(--azul-escuro);
  border-bottom-color: var(--azul-escuro);
}

.aba-painel { display: none; }
.aba-painel.ativo { display: block; }

.tabela-matriz {
  width: 100%;
  border-collapse: collapse;
}

.tabela-matriz th, .tabela-matriz td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--borda);
  text-align: left;
  white-space: nowrap;
}

.tabela-matriz th { color: var(--cinza); font-weight: 600; font-size: 0.85rem; }

.tabela-matriz .celula-checkbox {
  text-align: center;
}

.tabela-matriz input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.badge-papel.sms { background: var(--verde); }
.badge-papel.adm { background: var(--amarelo); }
