/* ═══════════════════════════════════════════════════════════════
   PAINEL DE CAMADAS ATIVAS
═══════════════════════════════════════════════════════════════ */
.active-layers-panel {
  position: fixed;
  bottom: 36px;
  left: 16px;
  z-index: 1050;
  max-width: 320px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.alp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  padding: 10px 12px;
  pointer-events: all;
  width: 100%;
  transform: translateY(8px);
  opacity: 0;
  transition: opacity var(--t-normal), transform var(--t-normal);
}

.alp-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.alp-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.alp-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-hint);
  flex: 1;
}

.alp-count {
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  transition: transform .15s cubic-bezier(.34,1.56,.64,1);
}

.alp-count.bump { transform: scale(1.35); }

.alp-clear {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-hint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--r-sm);
  transition: color var(--t-fast), background var(--t-fast);
  white-space: nowrap;
}

.alp-clear:hover { color: var(--md-red-500); background: #fce8e6; }

.alp-chips { display: flex; flex-wrap: wrap; gap: 5px; }

.alp-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 7px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 500;
  max-width: 200px;
  animation: chipIn .2s cubic-bezier(.34,1.56,.64,1) both;
  transition: opacity .15s, transform .15s;
}

.alp-chip.removing { opacity: 0; transform: scale(.8); }

@keyframes chipIn {
  from { opacity: 0; transform: scale(.75); }
  to   { opacity: 1; transform: scale(1);   }
}

.alp-chip.blue   { background: var(--md-blue-50);  color: var(--md-blue-700);  border: 1px solid var(--md-blue-200);  }
.alp-chip.yellow { background: #e6f4ea;             color: var(--md-green-700); border: 1px solid #a8d5b5;            }
.alp-chip.green  { background: #e6f4ea;             color: var(--md-green-700); border: 1px solid #a8d5b5;             }
.alp-chip.grey   { background: var(--md-grey-100);  color: var(--md-grey-700);  border: 1px solid var(--md-grey-300);  }
.alp-chip.purple { background: #f3e8fd;             color: #7b1fa2;             border: 1px solid #d9b3f5;             }
.alp-chip.orange { background: #fff3e0;             color: #e65100;             border: 1px solid #ffcc80;             }

.alp-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.alp-chip.blue   .alp-dot { background: var(--md-blue-600);  }
.alp-chip.yellow .alp-dot { background: var(--md-green-500);}
.alp-chip.green  .alp-dot { background: var(--md-green-500); }
.alp-chip.grey   .alp-dot { background: var(--md-grey-500);  }
.alp-chip.purple .alp-dot { background: #9c27b0;             }
.alp-chip.orange .alp-dot { background: #e65100;             }

.alp-chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alp-chip-remove {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: inherit;
  opacity: .5;
  transition: opacity var(--t-fast), background var(--t-fast);
  flex-shrink: 0;
  margin-left: 1px;
}

.alp-chip-remove:hover { opacity: 1; background: rgba(0,0,0,.10); }


/* ═══════════════════════════════════════════════════════════════
   PAINEL DE LEGENDA
═══════════════════════════════════════════════════════════════ */
.legend-panel {
  position: absolute;
  top: 16px;
  right: 68px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
  z-index: 1100;
  width: 240px;
  max-height: calc(100vh - 80px);
  overflow: hidden;
  display: none;
  flex-direction: column;
}

.legend-panel.open { display: flex; }

.legend-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.legend-panel-title {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-hint);
}

.legend-panel-count {
  font-size: 10px;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  min-width: 18px;
  height: 18px;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.legend-panel-body {
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--md-grey-300) transparent;
}

.legend-panel-body::-webkit-scrollbar { width: 4px; }
.legend-panel-body::-webkit-scrollbar-thumb { background: var(--md-grey-300); border-radius: 2px; }

.legend-empty {
  padding: 24px 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-hint);
  line-height: 1.5;
}

.legend-empty svg { display: block; margin: 0 auto 8px; opacity: .4; }

.legend-layer-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--md-grey-100);
}

.legend-layer-item:last-child { border-bottom: none; }

.legend-layer-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-layer-img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--r-sm);
}

.legend-layer-error {
  font-size: 11px;
  color: var(--text-hint);
  font-style: italic;
}

/* simples: ícone à esquerda, nome à direita */
.legend-layer-item.legend-simple {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.legend-layer-item.legend-simple .legend-layer-img {
  order: -1; /* puxa img para antes do nome */
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
  border-radius: 0;
}

.legend-layer-item.legend-simple .legend-layer-name {
  margin-bottom: 0;
}

.legend-layer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 6px;
}

.legend-layer-count {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-hint);
  background: var(--md-grey-100);
  border-radius: var(--r-pill);
  padding: 1px 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* simples — count fica inline com nome, sem margem abaixo */
.legend-layer-item.legend-simple .legend-layer-header {
  margin-bottom: 0;
}

/* ═══════════════════════════════════════════════════════════════
   POPUP DO LOTE
═══════════════════════════════════════════════════════════════ */
.leaflet-popup-content-wrapper {
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow-3) !important;
  padding: 0 !important;
  overflow: hidden;
}

.leaflet-popup-content { margin: 0 !important; width: auto !important; }
.leaflet-popup-tip-container { margin-top: -1px; }

.lote-popup {
  min-width: 220px;
  max-width: 320px;
  font-family: var(--font-ui);
}

.lote-popup-head {
  background: var(--primary);
  color: #fff;
  padding: 10px 14px 8px;
}

.lote-popup-head-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
}

.lote-popup-head-sub {
  font-size: 11px;
  opacity: .8;
  margin-top: 2px;
}

.lote-popup-body { padding: 10px 14px 12px; }

.lote-popup-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 3px 0;
  border-bottom: 1px solid var(--md-grey-100);
  font-size: 12px;
}

.lote-popup-row:last-child { border-bottom: none; }

.lote-popup-key {
  color: var(--text-hint);
  font-weight: 500;
  flex-shrink: 0;
}

.lote-popup-val {
  color: var(--text-primary);
  font-weight: 500;
  text-align: right;
  word-break: break-word;
}


/* ═══════════════════════════════════════════════════════════════
   POPUP GetFeatureInfo
═══════════════════════════════════════════════════════════════ */
.gfi-popup {
  font-family: var(--font-ui);
  min-width: 360px;  /* era 260px */
  max-width: 560px;  /* era 420px */
}

.gfi-popup-head {
  background: var(--primary);
  color: #fff;
  padding: 10px 14px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.gfi-popup-head-icon {
  width: 22px;
  height: 22px;
  background: rgba(255,255,255,.18);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.gfi-popup-head-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gfi-popup-body {
  padding: 10px 14px 12px;
  max-height: 340px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--md-grey-300) transparent;
}

.gfi-popup-body::-webkit-scrollbar { width: 4px; }
.gfi-popup-body::-webkit-scrollbar-thumb { background: var(--md-grey-300); border-radius: 2px; }

.gfi-layer-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-hint);
  margin: 10px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.gfi-layer-title:first-child { margin-top: 0; }

.gfi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.gfi-table tr {
  border-bottom: 1px solid var(--md-grey-100);
  transition: background var(--t-fast);
}

.gfi-table tr:last-child { border-bottom: none; }
.gfi-table tr:hover { background: var(--md-grey-50); }

/* DEPOIS — texto horizontal normal */
.gfi-table td.gfi-col-name {
  width: 40%;
  padding: 6px 8px;
  vertical-align: middle;
  text-align: left;
}

.gfi-col-name-inner {
  display: inline;
  writing-mode: horizontal-tb;
  transform: none;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-hint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gfi-table td.gfi-col-divider {
  width: 1px;
  background: var(--md-grey-200);
  padding: 0;
}

.gfi-table td.gfi-col-val {
  padding: 6px 8px 6px 10px;
  color: var(--text-primary);
  font-weight: 500;
  word-break: break-word;
  line-height: 1.4;
}

.gfi-empty {
  padding: 16px 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-hint);
}

.lote-popup-wrapper .leaflet-popup-close-button {
  width: 18px !important;
  height: 18px !important;
  top: 10px !important;
  right: 10px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  color: rgba(255,255,255,0.55) !important;
  opacity: 1 !important;
  line-height: 18px !important;
  text-align: center !important;
  border-radius: 50% !important;
  background: transparent !important;
  transition: background 0.15s, color 0.15s !important;
}

.lote-popup-wrapper .leaflet-popup-close-button:hover {
  background: rgba(255,255,255,0.25) !important;
  color: #fff !important;
}