/* ==========================================================================
   Sistema visual CMB v2 — moderno, institucional, offline.
   Identidade: emblema da Cidade de Bissau (verde/amarelo/vermelho).
   Padrão: sidebar escura + conteúdo claro, tipografia Inter, profundidade
   subtil e micro-interações. Tudo local (fonte vendorizada).
   ========================================================================== */
@font-face {
  font-family: "Inter";
  src: url("../vendor/inter/InterVariable.2bf3d951bf9d.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --verde: #128000;
  --verde-escuro: #0b5200;
  --verde-claro: #eef6ec;
  --amarelo: #efe000;
  --vermelho: #d81e05;
  --azul: var(--verde);
  --azul-escuro: var(--verde-escuro);
  --azul-claro: var(--verde-claro);

  --lateral-fundo: #0e2a08;
  --lateral-fundo-2: #143a0c;
  --lateral-texto: #cfdccb;
  --lateral-titulo: #8aa583;

  --fundo: #f4f6f3;
  --superficie: #ffffff;
  --texto: #1c2420;
  --texto-suave: #63705f;
  --borda: #e2e7df;
  --exito: #1b7a3d;
  --atencao: #9a6b00;
  --perigo: #b02a2a;

  --raio: 12px;
  --raio-s: 8px;
  --sombra: 0 1px 2px rgba(16, 34, 10, 0.06), 0 1px 6px rgba(16, 34, 10, 0.05);
  --sombra-alta: 0 4px 14px rgba(16, 34, 10, 0.12);
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--verde-escuro); }
h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.02em; color: var(--texto); margin: 0.1rem 0 0.35rem; }
h2 { font-size: 1.05rem; font-weight: 650; letter-spacing: -0.01em; color: var(--texto); margin: 1.5rem 0 0.55rem; }
h3 { font-size: 0.95rem; font-weight: 650; margin: 1rem 0 0.4rem; }

/* ----- concha da aplicação: sidebar escura + coluna principal ----- */
.corpo { display: flex; flex: 1; min-height: 0; }
.lateral {
  width: 16.5rem;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--lateral-fundo-2), var(--lateral-fundo) 30%);
  color: var(--lateral-texto);
  padding: 0 0 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.lateral-marca {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1rem 1rem 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0.6rem;
}
.lateral-marca img { height: 2.5rem; filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4)); }
.lateral-marca strong { color: #fff; font-size: 0.95rem; line-height: 1.2; display: block; letter-spacing: -0.01em; }
.lateral-marca span { font-size: 0.72rem; color: var(--lateral-titulo); }

.pesquisa-global { padding: 0 0.9rem 0.6rem; }
.pesquisa-global input {
  width: 100%;
  font-size: 0.84rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: var(--raio-s);
  padding: 0.45rem 0.7rem;
}
.pesquisa-global input::placeholder { color: rgba(255, 255, 255, 0.45); }
.pesquisa-global input:focus { outline: 2px solid rgba(239, 224, 0, 0.35); border-color: var(--amarelo); }

.grupo-menu summary {
  margin: 0.3rem 0.5rem 0.05rem;
  padding: 0.34rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--lateral-titulo);
  cursor: pointer;
  list-style: none;
  user-select: none;
  border-radius: var(--raio-s);
  transition: background 0.15s, color 0.15s;
}
.grupo-menu summary::-webkit-details-marker { display: none; }
.grupo-menu summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.45rem;
  color: var(--amarelo);
  transition: transform 0.15s ease;
}
.grupo-menu[open] summary::before { transform: rotate(90deg); }
.grupo-menu summary:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.grupo-menu a {
  display: block;
  margin: 0.08rem 0.5rem;
  padding: 0.38rem 0.8rem 0.38rem 1.5rem;
  color: var(--lateral-texto);
  text-decoration: none;
  font-size: 0.89rem;
  border-radius: var(--raio-s);
  transition: background 0.15s, color 0.15s;
}
.grupo-menu a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.grupo-menu a.ativo {
  background: rgba(239, 224, 0, 0.14);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--amarelo);
}
.contagem {
  display: inline-block;
  min-width: 1.3rem;
  padding: 0 0.34rem;
  border-radius: 99px;
  background: var(--vermelho);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.3rem;
  float: right;
}
.grupo-menu summary .contagem { float: none; margin-left: 0.4rem; vertical-align: 1px; }

/* ----- coluna principal ----- */
.principal { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topo {
  background: var(--superficie);
  border-bottom: 1px solid var(--borda);
  padding: 0.5rem 1.6rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.9rem;
  min-height: 3rem;
}
.topo .sessao { display: flex; align-items: center; gap: 0.9rem; font-size: 0.86rem; color: var(--texto-suave); }
.topo .sessao a { color: var(--verde-escuro); text-decoration: none; font-weight: 550; }
.topo .sessao a:hover { text-decoration: underline; }
.topo form { margin: 0; }
.botao-sair {
  background: transparent;
  border: 1px solid var(--borda);
  color: var(--texto-suave);
  padding: 0.28rem 0.8rem;
  border-radius: 99px;
  cursor: pointer;
  font-size: 0.82rem;
  transition: all 0.15s;
}
.botao-sair:hover { border-color: var(--vermelho); color: var(--vermelho); }

.conteudo { flex: 1; padding: 1.5rem 1.9rem 2.4rem; max-width: 82rem; width: 100%; min-width: 0; }
.rodape {
  padding: 0.55rem 1.6rem;
  font-size: 0.75rem;
  color: var(--texto-suave);
  border-top: 1px solid var(--borda);
  background: var(--superficie);
}

/* ----- cabeçalho clássico (páginas públicas, sem sidebar) ----- */
.cabecalho {
  background: linear-gradient(90deg, var(--lateral-fundo), var(--verde-escuro));
  color: #fff;
  padding: 0.6rem 1.4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 3px solid var(--amarelo);
}
.identidade { display: flex; align-items: center; gap: 0.7rem; }
.identidade img, .cabecalho .identidade img { height: 2.6rem; }
.marca { display: flex; flex-direction: column; line-height: 1.25; }
.marca span { font-size: 0.8rem; opacity: 0.8; }
.cabecalho .sessao { display: flex; align-items: center; gap: 0.9rem; font-size: 0.9rem; }
.cabecalho .sessao a { color: #fff; text-decoration: none; opacity: 0.92; }
.cabecalho .sessao a:hover { opacity: 1; text-decoration: underline; }
.cabecalho .sessao form { margin: 0; }
.cabecalho .botao-sair { border-color: rgba(255,255,255,0.5); color: #fff; }

/* ----- página: cabeçalho e ações ----- */
.cabecalho-pagina {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem;
}
.cabecalho-pagina p { margin: 0.15rem 0 0; color: var(--texto-suave); font-size: 0.88rem; max-width: 46rem; }
.acoes { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin: 0.7rem 0; }
.acoes a, .botao {
  display: inline-block;
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--raio-s);
  padding: 0.42rem 0.9rem;
  color: var(--texto);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 550;
  box-shadow: var(--sombra);
  transition: all 0.15s;
}
.acoes a:hover, .botao:hover { border-color: var(--verde); color: var(--verde-escuro); transform: translateY(-1px); box-shadow: var(--sombra-alta); }

/* ----- botões ----- */
button {
  font: inherit;
  font-size: 0.86rem;
  font-weight: 550;
  background: var(--superficie);
  color: var(--texto);
  border: 1px solid var(--borda);
  border-radius: var(--raio-s);
  padding: 0.44rem 0.95rem;
  cursor: pointer;
  box-shadow: var(--sombra);
  transition: all 0.15s;
}
button:hover { border-color: var(--verde); color: var(--verde-escuro); transform: translateY(-1px); }
button:active { transform: translateY(0); }
button:focus-visible, a:focus-visible { outline: 2px solid rgba(18, 128, 0, 0.4); outline-offset: 2px; }
button.primario, .formulario button[type="submit"] {
  background: linear-gradient(180deg, var(--verde), var(--verde-escuro));
  border-color: var(--verde-escuro);
  color: #fff;
  font-weight: 620;
}
button.primario:hover, .formulario button[type="submit"]:hover { filter: brightness(1.08); color: #fff; }
button.perigo { color: var(--perigo); border-color: #ecc8c8; }
button.perigo:hover { background: #fbeeee; border-color: var(--perigo); color: var(--perigo); }

/* ----- formulários: controlos modernos, generosos e consistentes ----- */
input, select, textarea {
  font: inherit;
  font-size: 0.95rem;
  border: 1.5px solid #d7e0d3;
  border-radius: 10px;
  padding: 0.58rem 0.85rem;
  min-height: 2.65rem;
  background-color: #fbfdfa;
  color: var(--texto);
  max-width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
textarea { min-height: 5.5rem; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #9aa79a; }
input:hover, select:hover, textarea:hover { border-color: #b9c9b3; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--verde);
  background-color: #fff;
  box-shadow: 0 0 0 3.5px rgba(18, 128, 0, 0.13);
}
/* seta própria nos selects — a seta nativa do Windows denuncia «anos 90» */
select:not([multiple]) {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%230b5200' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 0.9rem;
  padding-right: 2.4rem;
  cursor: pointer;
}
input[type="checkbox"], input[type="radio"] {
  width: 1.15rem; height: 1.15rem; min-height: 0; box-shadow: none;
  accent-color: var(--verde); vertical-align: -3px; cursor: pointer;
}
input[type="file"] { padding: 0.42rem; }
input[type="file"]::file-selector-button {
  font: inherit; font-size: 0.84rem; font-weight: 550;
  background: var(--verde-claro); color: var(--verde-escuro);
  border: 1px solid #cbe3c4; border-radius: 8px;
  padding: 0.4rem 0.9rem; margin-right: 0.7rem; cursor: pointer;
  transition: all 0.15s;
}
input[type="file"]::file-selector-button:hover { background: #dff0da; }
input[type="date"], input[type="time"] { cursor: pointer; }

/* ----- Tom Select com o tema institucional ----- */
.ts-wrapper { min-width: 12rem; }
.ts-control {
  border: 1.5px solid #d7e0d3 !important;
  border-radius: 10px !important;
  padding: 0.52rem 0.85rem !important;
  min-height: 2.65rem;
  font-size: 0.95rem;
  background: #fbfdfa !important;
  box-shadow: none !important;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ts-wrapper:hover .ts-control { border-color: #b9c9b3 !important; }
.ts-wrapper.focus .ts-control {
  border-color: var(--verde) !important;
  box-shadow: 0 0 0 3px rgba(18, 128, 0, 0.14) !important;
}
.ts-dropdown {
  border: 1px solid var(--borda);
  border-radius: var(--raio-s);
  box-shadow: var(--sombra-alta);
  font-size: 0.9rem;
}
.ts-dropdown .active { background: var(--verde-claro); color: var(--verde-escuro); }
.ts-dropdown .no-results { padding: 0.5rem 0.8rem; color: var(--texto-suave); }
.ts-wrapper.multi .ts-control > .item {
  background: var(--verde-claro); color: var(--verde-escuro);
  border-radius: 99px; padding: 0.1rem 0.55rem;
}
.formulario { max-width: 34rem; }
.formulario p { margin: 0 0 0.85rem; }
.formulario label { display: block; font-weight: 600; font-size: 0.82rem; margin-bottom: 0.25rem; color: var(--texto); }
.formulario input:not([type="checkbox"]):not([type="radio"]),
.formulario select, .formulario textarea { width: 100%; }
.formulario .helptext { display: block; font-size: 0.76rem; color: var(--texto-suave); margin-top: 0.2rem; font-weight: 400; }
.formulario ul.errorlist, ul.errorlist {
  list-style: none; margin: 0 0 0.6rem; padding: 0.5rem 0.8rem;
  background: #fbeeee; border-left: 3px solid var(--perigo);
  border-radius: var(--raio-s);
  color: var(--perigo); font-size: 0.84rem;
}
.forma-linha { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin: 0; }
.forma-linha input, .forma-linha select { width: auto; }

/* ----- cartões e grelhas ----- */
.cartao {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
  transition: box-shadow 0.2s;
}
.cartao:hover { box-shadow: var(--sombra-alta); }
.cartao h2:first-child, .cartao h3:first-child { margin-top: 0; }
.grelha { display: grid; grid-template-columns: repeat(auto-fit, minmax(15.5rem, 1fr)); gap: 1rem; }
.grelha .cartao { margin-bottom: 0; }
.indicador .rotulo { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--texto-suave); font-weight: 650; }
.indicador .valor { font-size: 1.75rem; font-weight: 750; letter-spacing: -0.03em; color: var(--verde-escuro); margin: 0.15rem 0; }

/* ----- tabelas: sem gaiola, separadores finos ----- */
.tabela {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  background: var(--superficie);
  box-shadow: var(--sombra);
  border-radius: var(--raio);
  overflow: hidden;
  font-size: 0.88rem;
  margin: 0.5rem 0 1.2rem;
}
.tabela th, .tabela td { padding: 0.6rem 0.85rem; text-align: left; vertical-align: middle; border: none; }
.tabela thead th {
  background: var(--superficie);
  color: var(--texto-suave);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border-bottom: 2px solid var(--borda);
}
.tabela tbody td { border-bottom: 1px solid var(--borda); }
.tabela tbody tr:last-child td { border-bottom: none; }
.tabela tbody tr { transition: background 0.12s; }
.tabela tbody tr:hover { background: var(--verde-claro); }

/* ----- barra universal de exportação (injetada pelo exportar.js) ----- */
.barra-exportar {
  display: flex;
  gap: 0.4rem;
  justify-content: flex-end;
  margin: 0.4rem 0 -0.7rem;
}
.barra-exportar button {
  font-size: 0.76rem;
  padding: 0.25rem 0.65rem;
  box-shadow: none;
  color: var(--texto-suave);
}
.barra-exportar button:hover { color: var(--verde-escuro); }

/* ----- marcadores de estado ----- */
.marcador {
  display: inline-block;
  padding: 0.14rem 0.6rem;
  border-radius: 99px;
  font-size: 0.74rem;
  font-weight: 650;
  white-space: nowrap;
  background: var(--fundo);
  color: var(--texto-suave);
  border: 1px solid var(--borda);
}
.marcador-exito { background: #e5f4e9; color: var(--exito); border-color: #c2e4cc; }
.marcador-atencao { background: #fdf4dd; color: var(--atencao); border-color: #eddaa4; }
.marcador-perigo { background: #fceceb; color: var(--perigo); border-color: #eec7c3; }
.marcador-info { background: var(--verde-claro); color: var(--verde-escuro); border-color: #cbe3c4; }

/* ----- mensagens ----- */
.mensagens { list-style: none; padding: 0; margin: 0 0 1rem; }
.mensagens li {
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--borda);
  border-left: 4px solid var(--verde);
  background: var(--superficie);
  border-radius: var(--raio-s);
  box-shadow: var(--sombra);
  margin-bottom: 0.45rem;
  font-size: 0.88rem;
}
.mensagens li.error { border-left-color: var(--perigo); }
.mensagens li.success { border-left-color: var(--exito); }
.nota { color: var(--texto-suave); font-size: 0.84rem; }

/* ----- entrada (login) ----- */
.cartao-entrada {
  max-width: 23.5rem;
  margin: 7vh auto 0;
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(14, 42, 8, 0.16);
  padding: 1.9rem 1.9rem 1.5rem;
}
.cartao-entrada h1 { font-size: 1.25rem; text-align: center; margin-bottom: 1.1rem; }
.cartao-entrada .formulario { max-width: none; }
.cartao-entrada button { width: 100%; margin-top: 0.35rem; padding: 0.55rem; }

/* ----- modo consulta: ver sem editar (por perfil) ----- */
.aviso-consulta {
  background: #eef4ff; border: 1px solid #c4d4f0; border-left: 4px solid #2b5fad;
  color: #1d3f74; border-radius: var(--raio-s);
  padding: 0.55rem 0.9rem; margin-bottom: 0.9rem; font-size: 0.86rem;
}
.modo-consulta main form[method="post" i] { opacity: 0.85; }

/* ----- impressão: documento completo, com timbre institucional ----- */
.impressao-cabecalho { display: none; }
.impressao-rodape { display: none; }
@media print {
  @page { margin: 1.4cm; }
  .cabecalho, .rodape, .lateral, .topo, .mensagens, .acoes, .botoes, .barra-exportar, .filtros { display: none !important; }
  /* linearizar a concha flex: sem isto o browser corta a impressão à 1ª página */
  body, .corpo, .principal { display: block; min-height: 0; height: auto; overflow: visible; }
  .conteudo { padding: 0; max-width: none; }
  body { background: #fff; font-family: "Segoe UI", sans-serif; color: #000; }
  .tabela, .cartao { box-shadow: none; }
  .impressao-cabecalho {
    display: flex; align-items: center; gap: 0.9rem;
    border-bottom: 3px double var(--verde-escuro);
    padding-bottom: 0.55rem; margin-bottom: 0.9rem;
  }
  .impressao-cabecalho img { height: 1.6cm; }
  .impressao-titulos { display: flex; flex-direction: column; line-height: 1.3; }
  .impressao-titulos strong { font-size: 1.05rem; }
  .impressao-titulos span { font-size: 0.8rem; color: #333; }
  .impressao-meta { margin-left: auto; text-align: right; font-size: 0.72rem; color: #444; }
  .aviso-consulta { display: none !important; }
  .impressao-rodape {
    display: flex; justify-content: space-between; align-items: flex-end;
    gap: 2rem; margin-top: 2.4rem; padding-top: 0.5rem;
    border-top: 1.5px solid var(--verde-escuro); font-size: 0.78rem; color: #333;
  }
  .impressao-rodape .assinatura-linha {
    min-width: 17rem; text-align: center; border-top: 1px solid #333;
    padding-top: 0.25rem;
  }
  a { color: #000 !important; text-decoration: none; }
  .tabela thead { display: table-header-group; }  /* cabeçalho repete em cada folha */
  .tabela tr { page-break-inside: avoid; }
  .tabela th, .tabela td { border-color: #999; }
}

/* ----- ecrãs estreitos ----- */
@media (max-width: 880px) {
  .corpo { flex-direction: column; }
  .lateral { width: 100%; }
  .conteudo { padding: 1rem; }
}
