:root {
  --fundo: #F3F5F1;
  --tinta: #1E2B24;
  --suave: #5E6B63;
  --linha: #D5DBD3;
  --floresta: #1F5F4A;
  --floresta-escura: #174636;
  --intersecao: #D1127A;
  --branco: #FFFFFF;
  --raio: 6px;
  font-family: "Archivo", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--tinta);
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  display: grid;
  grid-template-columns: 360px 1fr;
  background: var(--fundo);
}

#mapa { height: 100%; min-height: 0; }

.painel {
  height: 100%;
  overflow-y: auto;
  border-right: 1px solid var(--linha);
  padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px);
  display: flex;
  flex-direction: column;
}

.cabecalho { padding: 22px 20px 14px; border-bottom: 1px solid var(--linha); }
.cabecalho h1 {
  font-size: 1.35rem;
  font-stretch: 85%;
  font-weight: 700;
  line-height: 1.15;
  margin: 0;
}
.sub { margin: 6px 0 0; color: var(--suave); font-size: .9rem; }

.bloco { padding: 16px 20px; border-bottom: 1px solid var(--linha); }
.bloco h2 {
  font-size: .95rem;
  font-weight: 650;
  margin: 0 0 10px;
}

.lista { list-style: none; margin: 0; padding: 0; }

.camada {
  display: grid;
  grid-template-columns: auto 18px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  font-size: .88rem;
  line-height: 1.25;
}
.camada + .camada { border-top: 1px dashed var(--linha); }
.camada input[type=checkbox] { margin: 0; accent-color: var(--floresta); }
.amostra {
  width: 18px; height: 14px; border-radius: 3px;
  border: 2px solid currentColor;
}
.amostra.tracejado { border-style: dashed; }
.camada .nome { cursor: pointer; }
.camada .nome:hover { text-decoration: underline; }
.camada .meta { color: var(--suave); font-size: .8rem; font-variant-numeric: tabular-nums; text-align: right; }
.camada .erro { color: #9B1C1C; }
.camada .carregar {
  grid-column: 3 / 5;
  font-size: .8rem;
}
.link-botao {
  background: none; border: 0; padding: 0;
  color: var(--floresta); text-decoration: underline; cursor: pointer;
  font: inherit;
}
.remover {
  background: none; border: 0; cursor: pointer; color: var(--suave);
  font-size: 1.05rem; line-height: 1; padding: 2px 4px;
}
.remover:hover { color: #9B1C1C; }

.soltar {
  display: block;
  border: 1.5px dashed #9AA79F;
  border-radius: var(--raio);
  padding: 14px;
  background: var(--branco);
  cursor: pointer;
  font-size: .85rem;
  color: var(--suave);
}
.soltar strong { display: block; color: var(--floresta); margin-bottom: 3px; font-size: .92rem; }
.soltar input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.soltar.ativo, body.arrastando .soltar { border-color: var(--floresta); background: #E6EFE9; }
.soltar:focus-within, .soltar:focus-visible { outline: 2px solid var(--floresta); outline-offset: 2px; }
#lista-usuario:not(:empty) { margin-top: 10px; }

.acoes { display: flex; flex-direction: column; gap: 8px; }
.acoes.linha { flex-direction: row; flex-wrap: wrap; margin-top: 14px; }

.btn {
  font: inherit;
  font-size: .87rem;
  font-weight: 600;
  padding: 9px 12px;
  border-radius: var(--raio);
  border: 1px solid var(--floresta);
  background: var(--branco);
  color: var(--floresta);
  cursor: pointer;
  text-align: left;
}
.btn:hover:not(:disabled) { background: #E6EFE9; }
.btn.principal { background: var(--floresta); color: var(--branco); }
.btn.principal:hover:not(:disabled) { background: var(--floresta-escura); }
.btn.discreto { border-color: transparent; color: var(--suave); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .link-botao:focus-visible, .remover:focus-visible { outline: 2px solid var(--floresta); outline-offset: 2px; }

.progresso { font-size: .83rem; color: var(--suave); margin: 10px 0 0; min-height: 1em; }

.aviso {
  margin: 14px 20px 0;
  padding: 10px 12px;
  border-radius: var(--raio);
  background: #FFF6DB;
  border: 1px solid #E8D18A;
  font-size: .83rem;
  line-height: 1.4;
}

/* Resultados: cartão por polígono com barras por camada */
.resultado {
  background: var(--branco);
  border: 1px solid var(--linha);
  border-radius: var(--raio);
  padding: 12px;
  margin-bottom: 10px;
}
.resultado h3 {
  font-size: .92rem; margin: 0; font-weight: 650;
  display: flex; justify-content: space-between; gap: 8px;
}
.resultado h3 span { color: var(--suave); font-weight: 400; font-variant-numeric: tabular-nums; white-space: nowrap; }
.resultado .origem { font-size: .78rem; color: var(--suave); margin: 2px 0 8px; }
.barra-item { margin-top: 8px; font-size: .8rem; cursor: pointer; }
.barra-item:hover .barra-rotulo { text-decoration: underline; }
.barra-rotulo { display: flex; justify-content: space-between; gap: 8px; }
.barra-rotulo span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.barra { height: 6px; background: #E7EBE5; border-radius: 3px; margin-top: 3px; overflow: hidden; }
.barra i { display: block; height: 100%; border-radius: 3px; }
.sem { font-size: .8rem; color: var(--suave); margin-top: 6px; }

.tabela-wrap { overflow-x: auto; }
table.pares { border-collapse: collapse; width: 100%; font-size: .8rem; }
table.pares th, table.pares td { padding: 6px 4px; border-bottom: 1px solid var(--linha); text-align: left; vertical-align: top; }
table.pares td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.pares tr.clicavel { cursor: pointer; }
table.pares tr.clicavel:hover td { background: #EEF3EF; }
table.pares .ponto { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

.rodape { padding: 14px 20px 20px; font-size: .76rem; color: var(--suave); margin-top: auto; }

/* Popups */
.leaflet-popup-content { font-family: "Archivo", "Segoe UI", Roboto, Arial, sans-serif; font-size: .82rem; }
.popup h4 { margin: 0 0 6px; font-size: .9rem; }
.popup table { border-collapse: collapse; }
.popup td { padding: 2px 6px 2px 0; vertical-align: top; }
.popup td:first-child { color: var(--suave); }
.popup .popup-props { max-height: 180px; overflow-y: auto; }

@media (max-width: 800px) {
  body { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; }
  html, body { height: auto; }
  #mapa { grid-row: 1; height: 55vh; }
  .painel { grid-row: 2; height: auto; overflow: visible; border-right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
