*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  display: flex; height: 100vh; overflow: hidden;
}

#mapa { flex: 1; }

/* Panel izquierdo */
#panel {
  width: 240px; min-width: 200px;
  background: #fff;
  border-right: 1px solid #ddd;
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 10;
}

#panel-header {
  padding: 10px 12px 6px;
  border-bottom: 1px solid #eee;
  font-weight: 600;
  font-size: 14px;
  color: #333;
  flex-shrink: 0;
}

#panel-header small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: #888;
}

#buscador-wrap {
  padding: 8px 10px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
  position: relative;
}

#buscador-wrap input {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 12px;
  outline: none;
}

#buscador-wrap input:focus { border-color: #666; }

#buscador-sugerencias {
  position: absolute;
  left: 10px;
  right: 10px;
  background: #fff;
  border: 1px solid #ccc;
  border-top: none;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.12);
  z-index: 100;
  display: none;
  max-height: 220px;
  overflow-y: auto;
}

#buscador-sugerencias.visible { display: block; }

.sug-item {
  padding: 6px 8px;
  font-size: 11px;
  cursor: pointer;
  color: #333;
  border-bottom: 1px solid #f0f0f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sug-item:last-child { border-bottom: none; }
.sug-item:hover, .sug-item.activa { background: #f0f4ff; }

#buscador-resultado {
  font-size: 11px;
  color: #666;
  margin-top: 4px;
  min-height: 14px;
}

#capas-lista {
  overflow-y: auto;
  flex: 1;
  padding: 4px 0;
}

.grupo-titulo {
  padding: 6px 10px 3px;
  font-size: 11px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.grupo-titulo .flecha { font-size: 9px; transition: transform 0.2s; }
.grupo-titulo.colapsado .flecha { transform: rotate(-90deg); }

.grupo-capas { overflow: hidden; }
.grupo-capas.colapsado { display: none; }

.capa-fila {
  display: flex;
  align-items: center;
  padding: 3px 10px 3px 18px;
  gap: 7px;
  cursor: pointer;
  border-radius: 3px;
  margin: 1px 4px;
}

.capa-fila:hover { background: #f5f5f5; }

.capa-fila input[type="checkbox"] {
  flex-shrink: 0;
  cursor: pointer;
}

.capa-nombre {
  flex: 1;
  font-size: 12px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.capa-zoom {
  font-size: 10px;
  color: #aaa;
  white-space: nowrap;
}

.opacidad-wrap {
  padding: 1px 10px 4px 32px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.opacidad-wrap input[type="range"] {
  flex: 1;
  height: 4px;
  cursor: pointer;
}

.opacidad-label { font-size: 10px; color: #aaa; width: 28px; text-align: right; }

/* Ficha derecha */
#ficha {
  position: absolute;
  right: 10px; top: 10px;
  width: 240px;
  background: rgba(255,255,255,0.97);
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  padding: 10px 12px;
  z-index: 20;
  display: none;
  max-height: calc(100vh - 20px);
  overflow-y: auto;
}

#ficha.visible { display: block; }

#ficha-cerrar {
  position: absolute; right: 8px; top: 6px;
  cursor: pointer; font-size: 16px; color: #999;
  line-height: 1;
}
#ficha-cerrar:hover { color: #333; }

#ficha h3 {
  margin: 0 20px 8px 0;
  font-size: 13px;
  color: #333;
  border-bottom: 1px solid #eee;
  padding-bottom: 5px;
}

.ficha-tabla { width: 100%; border-collapse: collapse; }
.ficha-tabla td { padding: 3px 0; font-size: 12px; vertical-align: top; }
.ficha-tabla td:first-child { color: #888; padding-right: 8px; white-space: nowrap; width: 40%; }
.ficha-tabla td:last-child { color: #333; font-weight: 500; word-break: break-word; }

.ficha-seccion { font-weight: 600; font-size: 11px; color: #555; padding-top: 8px !important; border-top: 1px solid #eee; text-transform: uppercase; letter-spacing: 0.03em; }

.ficha-catastro-link {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  color: #0066cc;
  text-decoration: none;
}
.ficha-catastro-link:hover { text-decoration: underline; }

.ficha-advertencia {
  margin-top: 8px;
  font-size: 10px;
  color: #888;
  font-style: italic;
  border-top: 1px solid #eee;
  padding-top: 6px;
  line-height: 1.4;
}

/* Pie */
#pie {
  position: absolute;
  bottom: 0; left: 240px; right: 0;
  background: rgba(255,255,255,0.85);
  font-size: 10px;
  color: #666;
  padding: 3px 8px;
  display: flex; gap: 10px; flex-wrap: wrap;
  z-index: 10;
}

.pie-attr { white-space: nowrap; }

/* Leyenda remanente */
#leyenda-remanente {
  margin: 8px 10px 4px;
  padding: 8px;
  background: #f8f8f8;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
}
.leyenda-titulo { font-size: 11px; font-weight: 600; color: #444; margin-bottom: 5px; }
.leyenda-fila { display: flex; align-items: center; gap: 7px; font-size: 11px; color: #333; margin-bottom: 3px; }
.leyenda-color { display: inline-block; width: 14px; height: 14px; border-radius: 2px; flex-shrink: 0; border: 1px solid rgba(0,0,0,0.15); }

/* ── Aviso de navegador sin WebGL ──────────────────────────────────────────── */
#aviso-webgl {
  display: none;              /* lo enciende visor.js si no hay WebGL 2 */
  flex: 1;
  align-items: center;
  justify-content: center;
  background: #f7f7f5;
  overflow: auto;
  padding: 24px;
}

#aviso-webgl .aviso-caja {
  max-width: 560px;
  background: #fff;
  border: 1px solid #e0ddd6;
  border-left: 4px solid #B5532E;
  border-radius: 4px;
  padding: 22px 26px;
  line-height: 1.55;
  color: #333;
}

#aviso-webgl h2 { margin: 0 0 12px; font-size: 18px; color: #B5532E; }
#aviso-webgl h3 { margin: 18px 0 8px; font-size: 14px; }
#aviso-webgl ul { margin: 0; padding-left: 20px; }
#aviso-webgl li { margin-bottom: 10px; }
#aviso-webgl code {
  background: #f0ede7;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}
#aviso-webgl .aviso-nota {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid #eee;
  font-size: 12px;
  color: #666;
}

/* ── Filtro de parcelas ────────────────────────────────────────────────────── */
#filtro {
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
  display: none;              /* lo enciende filtro.js cuando el índice carga */
  flex-direction: column;
  min-height: 0;
}
#filtro.listo { display: flex; }

#filtro-cabecera {
  padding: 7px 10px;
  font-weight: 600;
  color: #444;
  cursor: pointer;
  user-select: none;
  background: #faf9f7;
  display: flex;
  align-items: center;
  gap: 6px;
}
#filtro-cabecera .flecha { font-size: 9px; color: #999; transition: transform .15s; }
#filtro-cabecera.colapsado .flecha { transform: rotate(-90deg); }

#filtro-total {
  margin-left: auto;
  font-weight: 700;
  font-size: 12px;
  color: #B5532E;
  font-variant-numeric: tabular-nums;
}

#filtro-contenido {
  overflow-y: auto;
  max-height: 46vh;
  padding: 0 10px 8px;
}
#filtro-contenido.colapsado { display: none; }

#filtro-botones { display: flex; gap: 6px; margin: 8px 0 4px; }
#filtro-botones button {
  flex: 1;
  font-size: 11px;
  padding: 4px 2px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 3px;
  cursor: pointer;
  color: #555;
}
#filtro-botones button:hover { background: #f2efe9; border-color: #c9c3b7; }

.filtro-seccion {
  margin: 12px 0 4px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #999;
}

.filtro-fila {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1.5px 0;
  font-size: 12px;
}
.filtro-fila input[type="checkbox"] { margin: 0; flex-shrink: 0; }
.filtro-nombre {
  flex: 1;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.filtro-cuenta {
  font-size: 10.5px;
  color: #999;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.filtro-grupo { font-weight: 600; margin-top: 3px; }
.filtro-grado { padding-left: 16px; color: #666; }

#filtro-distrito, #filtro-barrio {
  width: 100%;
  margin-bottom: 5px;
  font-size: 12px;
  padding: 3px 4px;
  border: 1px solid #ddd;
  border-radius: 3px;
  background: #fff;
}

.filtro-campo {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  margin: 6px 0;
}
.filtro-campo input {
  width: 70px;
  font-size: 12px;
  padding: 2px 4px;
  border: 1px solid #ddd;
  border-radius: 3px;
}

/* Punto de color de los niveles de confianza en el filtro */
.filtro-color {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-block;
}
.filtro-confianza .filtro-nombre { text-transform: none; }

#leyenda-confianza .leyenda-nota {
  margin-top: 6px;
  font-size: 10px;
  color: #888;
  line-height: 1.35;
}
#leyenda-confianza code { font-size: 9.5px; background: #f0ede7; padding: 0 3px; }

/* Botón de descarga del filtro */
#filtro-excel {
  width: 100%;
  margin-top: 10px;
  padding: 7px 4px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: #B5532E;
  border: none;
  border-radius: 3px;
  cursor: pointer;
}
#filtro-excel:hover:not(:disabled) { background: #9c4727; }
#filtro-excel:disabled { background: #c9a394; cursor: default; }

.filtro-nota {
  margin-top: 5px;
  font-size: 10px;
  color: #999;
  line-height: 1.35;
}
