/* Componentes que complementam o Tailwind (carregado via CDN em templates/_cabecalho.html). */
:root {
  --marca: #0e7a5f;
  --marca-escura: #0a5c48;
  --lateral: #0b211d;
  --borda: #e3e6e1;
  --fundo: #f5f6f3;
}

body {
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  background: var(--fundo);
  color: #1c2522;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}

.numeros { font-variant-numeric: tabular-nums; }

/* ---------- Superfícies ---------- */
.cartao {
  background: #fff;
  border: 1px solid var(--borda);
  border-radius: 0.75rem;
  box-shadow: 0 1px 2px rgb(16 24 20 / 0.04);
}
.cartao-titulo {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--borda);
  font-size: 0.8rem;
  font-weight: 600;
  color: #1c2522;
}
.cartao-rodape { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0.75rem 1.25rem; border-top: 1px solid var(--borda); background: #fafbf9; border-radius: 0 0 0.75rem 0.75rem; }
.rotulo-coluna {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7b8580;
}

/* ---------- Botões ---------- */
.botao, .botao-secundario {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 0.5rem;
  padding: 0.55rem 0.95rem;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.1;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.botao { background: var(--marca); color: #fff; box-shadow: 0 1px 2px rgb(14 122 95 / 0.35); }
.botao:hover { background: var(--marca-escura); }
.botao:disabled, .botao-desativado { opacity: 0.5; cursor: not-allowed; }
.botao-desativado, .botao-desativado:hover { background: #8a948f; box-shadow: none; }
.botao-secundario { background: #fff; color: #2b3632; border: 1px solid #d5dad4; }
.botao-secundario:hover { background: #f5f6f3; border-color: #c2c9c2; }
.botao:focus-visible, .botao-secundario:focus-visible, .campo:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgb(14 122 95 / 0.22);
  border-color: var(--marca);
}

/* ---------- Formulários ---------- */
.campo {
  width: 100%;
  border: 1px solid #d5dad4;
  border-radius: 0.5rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.campo::placeholder { color: #a3aba6; }
/* Versão compacta para edição em linha (tabelas). */
.campo-compacto { padding: 0.35rem 0.5rem; font-size: 0.78rem; border-radius: 0.4rem; }
select.campo-compacto { padding-right: 1.6rem; background-position: right 0.4rem center; }
.caixa { width: 0.95rem; height: 0.95rem; accent-color: var(--marca); }
/* Texto de ajuda abaixo do campo (help_text do formulário). */
.campo-ajuda { display: flex; align-items: center; gap: 0.35rem; margin-top: 0.45rem; font-size: 0.72rem; line-height: 1.3; color: #8a948f; }
.campo-ajuda svg { flex: none; color: #a9b2ad; }
/* Select com seta própria, no mesmo estilo dos demais campos. */
select.campo {
  appearance: none;
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2366716c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  cursor: pointer;
}
.campo-rotulo { display: block; font-size: 0.8rem; font-weight: 600; color: #2b3632; margin-bottom: 0.35rem; }
.errorlist { margin-top: 0.3rem; font-size: 0.78rem; color: #b42318; }

/* ---------- Selos ---------- */
.selo {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border-radius: 0.375rem;
  padding: 0.12rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}
.selo::before { content: ""; width: 0.38rem; height: 0.38rem; border-radius: 9999px; background: currentColor; opacity: 0.75; }
.selo-verde { background: #e4f3ee; color: #0a5c48; }
.selo-azul { background: #e8f0fb; color: #1d4f91; }
.selo-ambar { background: #fdf1df; color: #94560a; }
.selo-cinza { background: #eef0ed; color: #55605b; }

/* ---------- Menu lateral ---------- */
.lateral { background: var(--lateral); color: #c9d6d1; }
/* Barra de rolagem discreta, só visível quando a janela é baixa demais para o menu. */
.lateral nav { scrollbar-width: thin; scrollbar-color: rgb(255 255 255 / 0.16) transparent; }
.lateral nav::-webkit-scrollbar { width: 6px; }
.lateral nav::-webkit-scrollbar-track { background: transparent; }
.lateral nav::-webkit-scrollbar-thumb { background: rgb(255 255 255 / 0.16); border-radius: 9999px; }
.lateral nav::-webkit-scrollbar-thumb:hover { background: rgb(255 255 255 / 0.3); }
.lateral-grupo {
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #6f857d;
  padding: 0 0.75rem;
  margin: 0.9rem 0 0.25rem;
}
.passo {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.36rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.84rem;
  font-weight: 500;
  color: #b4c4be;
  transition: background 0.15s, color 0.15s;
}
.passo:hover { background: rgb(255 255 255 / 0.06); color: #fff; }
.passo-marcador {
  flex: none;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 9999px;
  display: grid;
  place-items: center;
  font-size: 0.62rem;
  font-weight: 700;
  border: 1px solid rgb(255 255 255 / 0.22);
  color: #8fa39c;
}
.passo-feito .passo-marcador { background: rgb(52 211 153 / 0.16); border-color: transparent; color: #5fe0b0; }
.passo-atual { background: rgb(255 255 255 / 0.09); color: #fff; font-weight: 600; }
.passo-atual .passo-marcador { background: #34d399; border-color: #34d399; color: #06281f; }
/* A etapa atual concluída mantém o destaque de atual, com o check no marcador. */
.passo-atual.passo-feito .passo-marcador { background: #34d399; border-color: #34d399; color: #06281f; }
.passo-bloqueado { color: #5f746d; cursor: not-allowed; }
.passo-bloqueado:hover { background: transparent; color: #5f746d; }
.passo-bloqueado .passo-marcador { border-style: dashed; border-color: rgb(255 255 255 / 0.16); color: #5f746d; }
.passo-sub { display: block; font-size: 0.7rem; font-weight: 400; color: #8fa39c; margin-top: 0.05rem; }

.modo { display: grid; grid-template-columns: 1fr 1fr; gap: 0.2rem; padding: 0.2rem; border-radius: 0.55rem; background: rgb(255 255 255 / 0.07); }
.modo a { text-align: center; padding: 0.4rem 0; border-radius: 0.4rem; font-size: 0.78rem; font-weight: 600; color: #9fb2ab; }
.modo a:hover { color: #fff; }
.modo a.ativo { background: #fff; color: #0b211d; box-shadow: 0 1px 2px rgb(0 0 0 / 0.25); }

/* ---------- Menu do usuário ---------- */
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.4rem;
  font-size: 0.84rem;
  color: #2b3632;
  text-align: left;
}
.menu-item:hover { background: #f1f3ef; }

/* ---------- Linhas de tabela/lista ---------- */
.linha { border-bottom: 1px solid #eef0ec; transition: background 0.12s; }
.linha:last-child { border-bottom: 0; }
.linha:hover, details.linha > summary:hover { background: #fafbf9; }
details.linha[open] > summary .seta { transform: rotate(90deg); }
details.linha.fechando > summary .seta { transform: none; }
.linha > summary { cursor: pointer; user-select: none; }
.seta { transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); color: #9aa39e; }

.barra { height: 0.4rem; border-radius: 9999px; background: #e9ece7; overflow: hidden; }
.barra > span { display: block; height: 100%; border-radius: 9999px; background: var(--marca); transition: width 0.6s; }

.zona-upload { border: 1.5px dashed #c9d0c9; border-radius: 0.75rem; background: #fafbf9; transition: border-color 0.15s, background 0.15s; }
.zona-upload.arrastando { border-color: var(--marca); background: #eef7f3; }

/* ---------- Grades (listas em colunas) ----------
   Cabeçalho e linhas usam a mesma classe de colunas, então ficam sempre alinhados. */
.grade { display: grid; gap: 0.75rem; align-items: center; padding: 0.75rem 1.25rem; font-size: 0.875rem; }
.grade-cabecalho {
  padding-top: 0.625rem;
  padding-bottom: 0.625rem;
  background: #fafbf9;
  border-bottom: 1px solid var(--borda);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7b8580;
}
.grade-leitura { grid-template-columns: 1.25rem 1.3fr 4.5rem 2.4fr 1.1fr 5.5rem; }
.grade-ranking { grid-template-columns: 1.25rem 2.5rem 1.2fr 2.2fr 1fr 1.5fr; }
.grade-reordenamento { grid-template-columns: 3.4rem 2.4fr 3rem 3.2fr; }
/* Reordenamento por arrastar: a alça inicia o arrasto; a linha de destino ganha a marca no topo. */
.alca { display: inline-grid; place-items: center; width: 1.1rem; height: 1.4rem; border-radius: 0.25rem; color: #a3aba6; cursor: grab; }
.alca:hover { background: #eef0ec; color: #66716c; }
.alca:active { cursor: grabbing; }
.linha.arrastando { opacity: 0.45; }
.linha.alvo-arrasto { box-shadow: inset 0 3px 0 var(--marca); background: #eef7f3; }
.grade-input-fisico { grid-template-columns: 2fr 1.7fr repeat(5, 7.6rem) 1.1fr 4.6rem 1.7fr; gap: 0.5rem; }
.grade-input-financeiro { grid-template-columns: 2.2fr 7.5rem 7.5rem 10rem repeat(8, 5.2rem); gap: 0.5rem; }
.grade-analise { grid-template-columns: 2.4fr 6.5rem repeat(6, 1fr) 4rem 2.5rem; gap: 0.6rem; }
.grade-fases { grid-template-columns: 2.4fr 8.5rem 1.4fr 1.3fr 6rem 4.5rem; }
.grade-coordenadas { grid-template-columns: 2.4fr 1.2fr 8rem 8rem 1.4fr; }
.grade-input-financeiro input[type=number] { text-align: right; }

/* ---------- Gráfico de barras (utils/_grafico_barras.html) ---------- */
.grafico-barras-area { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0.5rem; align-items: end; height: 11rem; }
.grafico-barra { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 0.3rem; }
.grafico-barra-coluna { display: block; width: 100%; max-width: 3.5rem; border-radius: 4px 4px 0 0; background: var(--marca); min-height: 2px; transition: height 0.4s; }
.grafico-barra:hover .grafico-barra-coluna { background: var(--marca-escura); }
.grafico-barra-valor { font-size: 0.72rem; font-weight: 600; color: var(--tinta); }
.grafico-barra-rotulo { font-size: 0.72rem; color: #66716c; border-top: 1px solid var(--borda); width: 100%; text-align: center; padding-top: 0.3rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaflet-container { font-family: inherit; }
.leaflet-popup-content { font-size: 0.8rem; line-height: 1.4; }
.grade-input-fisico .selo { white-space: normal; line-height: 1.25; }
.linha.htmx-request { opacity: 0.55; }

/* Área expandida de uma linha (<details class="linha">), alinhada após a seta. */
.linha-detalhe { background: #fafbf9; border-top: 1px solid #eef0ec; padding: 1rem 1.25rem 1rem 3.25rem; }

/* ---------- Avisos ---------- */
.aviso { border: 1px solid; border-radius: 0.5rem; padding: 0.75rem 1rem; font-size: 0.875rem; margin-bottom: 1.25rem; }
.aviso-sucesso { border-color: #c8e6db; background: #e4f3ee; color: #0a5c48; }
.aviso-erro { border-color: #fecaca; background: #fef2f2; color: #991b1b; }
.aviso-atencao { border-color: #fcd34d; background: #fffbeb; color: #78350f; }

/* ---------- Campo de senha com botão de mostrar/ocultar ---------- */
.campo-senha { position: relative; }
.campo-senha .campo { padding-right: 2.75rem; }
.campo-senha button {
  position: absolute; top: 0; bottom: 0; right: 0;
  display: grid; place-items: center; padding: 0 0.75rem;
  color: #66716c;
}
.campo-senha button:hover { color: #1c2522; }
.campo-senha [data-olho="fechado"], .campo-senha.visivel [data-olho="aberto"] { display: none; }
.campo-senha.visivel [data-olho="fechado"] { display: block; }

.link { font-weight: 600; color: var(--marca); }
.link:hover { text-decoration: underline; }

/* ---------- Seletor de idioma (utils/_idioma.html) ---------- */
.idioma {
  display: inline-flex; align-items: center; gap: 0.15rem;
  padding: 0.2rem 0.25rem 0.2rem 0.6rem;
  border: 1px solid #d5dad4; border-radius: 9999px; background: #fff; color: #66716c;
}
.idioma svg { margin-right: 0.25rem; }
.idioma button {
  padding: 0.2rem 0.6rem; border-radius: 9999px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.03em; color: #66716c;
}
.idioma button:hover { color: #1c2522; }
.idioma button.ativo { background: var(--marca); color: #fff; }

/* ---------- Toasts (utils/_mensagens.html) ---------- */
.toasts {
  position: fixed; top: 4.5rem; right: 1.5rem; z-index: 50;
  display: flex; flex-direction: column; gap: 0.6rem;
  width: min(24rem, calc(100vw - 3rem));
}
.toast {
  position: relative; overflow: hidden;
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.85rem 0.9rem 0.95rem;
  background: #fff; border: 1px solid var(--borda); border-radius: 0.75rem;
  box-shadow: 0 12px 32px -12px rgb(16 24 20 / 0.28), 0 2px 6px rgb(16 24 20 / 0.06);
  animation: toast-entra 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  transition: opacity 0.25s, transform 0.25s;
}
.toast.saindo { opacity: 0; transform: translateX(1rem); }
.toast-icone { flex: none; display: grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 9999px; }
.toast-sucesso .toast-icone { background: #e4f3ee; color: var(--marca); }
.toast-erro .toast-icone { background: #fee4e2; color: #b42318; }
.toast-texto { flex: 1; min-width: 0; padding-top: 0.1rem; font-size: 0.85rem; font-weight: 500; line-height: 1.35; color: #1c2522; }
.toast-fechar { flex: none; padding: 0.2rem; border-radius: 0.35rem; color: #9aa39e; }
.toast-fechar:hover { background: #f1f3ef; color: #1c2522; }
/* Barra que mostra o tempo restante até o toast sumir. */
.toast-tempo { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; transform-origin: left; animation: toast-tempo linear forwards; }
.toast-sucesso .toast-tempo { background: var(--marca); }
.toast-erro .toast-tempo { background: #d92d20; }
.toast:hover .toast-tempo { animation-play-state: paused; }
@keyframes toast-entra { from { opacity: 0; transform: translateY(-0.5rem) scale(0.98); } }
@keyframes toast-tempo { to { transform: scaleX(0); } }

/* ---------- Modal (<dialog class="modal">) ----------
   Abre com data-abrir-modal="id" em um botão ou data-abrir-ao-carregar no próprio dialog;
   fecha com data-fechar-modal, Esc ou clique fora (utils.js). */
.modal {
  width: min(28rem, calc(100vw - 2rem));
  padding: 0; border: 0; border-radius: 1rem; background: #fff; color: #1c2522;
  box-shadow: 0 24px 64px -16px rgb(16 24 20 / 0.45);
}
.modal::backdrop { background: rgb(11 33 29 / 0.55); backdrop-filter: blur(2px); }
.modal[open] { animation: modal-entra 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.1); }
.modal-corpo { padding: 1.5rem 1.5rem 1.25rem; }
.modal-titulo { margin-top: 0.9rem; font-size: 1.1rem; font-weight: 700; letter-spacing: -0.01em; }
.modal-texto { margin-top: 0.4rem; font-size: 0.875rem; line-height: 1.5; color: #66716c; }
.modal-texto strong { color: #1c2522; font-weight: 600; word-break: break-word; }
.modal-rodape { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 0.9rem 1.5rem; border-top: 1px solid var(--borda); background: #fafbf9; }
@keyframes modal-entra { from { opacity: 0; transform: translateY(0.5rem) scale(0.98); } }

/* ---------- Barra de filtros (utils/_filtros.html) ---------- */
.filtros { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin: 1.25rem 0 0.75rem; }
.filtros-principal { flex: 1 1 14rem; }
.filtros select.campo { width: auto; min-width: 10.5rem; }
.filtros .campo { padding-top: 0.5rem; padding-bottom: 0.5rem; font-size: 0.84rem; }
/* Campo de busca com lupa. */
.campo-busca {
  padding-left: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%239aa39e' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.75rem center;
}
/* Região sendo atualizada por um filtro (o htmx põe .htmx-request no hx-indicator). */
.cartao.htmx-request { opacity: 0.5; transition: opacity 0.15s; }

/* ---------- Entrada das linhas depois de um filtro (classe posta pelo utils.js) ---------- */
.entrando .linha { animation: linha-entra 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.entrando .linha:nth-child(2) { animation-delay: 30ms; }
.entrando .linha:nth-child(3) { animation-delay: 60ms; }
.entrando .linha:nth-child(4) { animation-delay: 90ms; }
.entrando .linha:nth-child(5) { animation-delay: 120ms; }
.entrando .linha:nth-child(6) { animation-delay: 150ms; }
.entrando .linha:nth-child(7) { animation-delay: 180ms; }
.entrando .linha:nth-child(8) { animation-delay: 210ms; }
.entrando .linha:nth-child(9) { animation-delay: 240ms; }
.entrando .linha:nth-child(10) { animation-delay: 270ms; }
.entrando .linha:nth-child(11) { animation-delay: 300ms; }
.entrando .linha:nth-child(12) { animation-delay: 330ms; }
.entrando .linha:nth-child(n + 13) { animation-delay: 360ms; }
@keyframes linha-entra { from { opacity: 0; transform: translateY(0.4rem); } }
@media (prefers-reduced-motion: reduce) { .entrando .linha { animation: none; } }

/* ---------- Paginação (utils/_paginacao.html) ---------- */
.paginacao { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.7rem 1.25rem; border-top: 1px solid var(--borda); background: #fafbf9; }
.paginacao-item {
  display: grid; place-items: center; min-width: 1.9rem; height: 1.9rem; padding: 0 0.4rem;
  border-radius: 0.4rem; font-size: 0.8rem; font-weight: 600; color: #55605b; font-variant-numeric: tabular-nums;
}
a.paginacao-item:hover { background: #e9ece7; color: #1c2522; }
.paginacao-item.ativo { background: var(--marca); color: #fff; }
.paginacao-item.sem-link { color: #9aa39e; }

/* ---------- Botão só com ícone (ações de linha) ---------- */
.botao-icone { display: inline-grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 0.4rem; color: #7b8580; transition: background 0.15s, color 0.15s; }
.botao-icone:hover { background: #e4f3ee; color: var(--marca); }
.botao-icone.htmx-request { opacity: 0.5; }

.modal-largo { width: min(40rem, calc(100vw - 2rem)); }
