/* Edificios — mapa de edificios + portero. Pantalla completa: la barra reservada de la app
   (--ziv-bar-h, chip del usuario + casita) queda arriba y todo lo demás empieza debajo. */
:root {
  --spinner-color: #A3B84C;   /* color de la tarjeta del menú */
  --e-sin: #8a8f98;      /* sin predicar */
  --e-neutro: #6b7a8c;   /* lo que ve el publicador común: sin estado */
  --e-parcial: #a98bd6;  /* empezado y no terminado (soltado, o "en proceso" viejo del Excel) */
  --e-proc: #378ADD;     /* lo tiene alguien */
  --e-ok: #1D9E75;       /* terminado hace ≤ 6 meses */
  --e-warn: #EF9F27;     /* terminado hace 6–12 meses */
  --e-bad: #D85A30;      /* terminado hace más de un año */
  --r-atendio: #1D9E75; --r-no: #a87420; --r-noquiere: #c0392b; --r-revisita: #378ADD;
}
html, body { margin: 0; height: 100%; }
/* --ed-top en body (no en :root): --ziv-bar-h lo define body.ziv-barra, y en :root valdría 0 */
body { --ed-top: var(--ziv-bar-h, 0px); font-family: system-ui, sans-serif; background: var(--bg-primary); color: var(--text-primary); overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
/* Capas: todo lo de la pantalla del mapa (barra, lista, botones: 240–270) queda DEBAJO del chip del usuario
   (#ziv-session, z 300) para que su menú se vea; el portero y las hojas (950+) lo tapan a propósito. */
#map { position: fixed; inset: 0; top: var(--ed-top); z-index: 0; background: var(--bg-primary); }

.btn-home {
  position: fixed; top: 12px; left: 12px; z-index: 120; width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; color: var(--text-primary);
  background: var(--bg-card); border: 1px solid var(--border-light); text-decoration: none;
}
.btn-home svg { width: 20px; height: 20px; }

/* ── barra de búsqueda y filtros ── */
.topbar {
  position: fixed; top: var(--ed-top); left: 0; right: 0; z-index: 250;
  padding: 10px 12px 8px;
  background: linear-gradient(var(--bg-primary) 70%, transparent);
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.top-row { display: flex; gap: 8px; align-items: center; max-width: 720px; width: 100%; }
.titulo { font-weight: 700; font-size: 16px; white-space: nowrap; }
.titulo small { display: block; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.buscar {
  flex: 1; min-width: 0; height: 40px; border-radius: 12px; border: 1px solid var(--border-input);
  background: var(--bg-input); color: var(--text-primary); padding: 0 12px; font-size: 15px; box-sizing: border-box;
}
.icon-btn {
  width: 40px; height: 40px; flex: none; border-radius: 12px; border: 1px solid var(--border-light);
  background: var(--bg-card); display: flex; align-items: center; justify-content: center;
}
.icon-btn svg { width: 20px; height: 20px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 32px; padding: 0 12px; border-radius: 16px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--border-light); background: var(--bg-card); color: var(--text-secondary);
  display: flex; align-items: center; gap: 6px;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.chip .n { font-weight: 700; color: var(--text-muted); font-size: 12px; }
.chip.on { background: var(--text-primary); color: var(--bg-primary); border-color: var(--text-primary); }
.chip.on .n { color: inherit; opacity: .7; }

/* ── pines ── */
.ed-pin {
  position: relative; width: 30px; height: 30px; border-radius: 9px;
  background: var(--c); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.ed-pin::after {
  content: ''; position: absolute; left: 50%; top: 100%; transform: translate(-50%, -1px);
  border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 7px solid #fff;
}
.ed-pin svg { width: 16px; height: 16px; }
.ed-pin.dudoso { border-style: dashed; }
.ed-pin.dudoso::before {
  content: '?'; position: absolute; top: -8px; right: -8px; width: 16px; height: 16px; border-radius: 50%;
  background: #EF9F27; color: #1a1c1f; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.ed-pin.sel { transform: scale(1.25); }
.ed-pin.moviendo { animation: ed-latido 1s infinite; }
@keyframes ed-latido { 50% { box-shadow: 0 0 0 8px rgba(239,159,39,.35); } }
/* De lejos (zoom < 16) los pines son puntos: los edificios del centro se tapan entre sí. */
.lejos .ed-pin { width: 14px; height: 14px; border-radius: 50%; border-width: 2px; transform: translate(8px, 20px); }
.lejos .ed-pin svg, .lejos .ed-pin::after { display: none; }
.lejos .ed-pin.dudoso::before { top: -9px; right: -9px; width: 12px; height: 12px; font-size: 9px; }
.lejos .ed-pin.sel { transform: translate(8px, 20px) scale(1.5); }
.salon-pin { width: 26px; height: 26px; border-radius: 50%; background: #232628; border: 2px solid var(--sc, #9c4dcc); color: var(--sc, #9c4dcc); display: flex; align-items: center; justify-content: center; }
.salon-pin svg { width: 14px; height: 14px; }

/* ── resumen abajo ── */
.bottombar {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 250;
  display: flex; gap: 8px; align-items: center; justify-content: space-between; pointer-events: none;
}
.bottombar > * { pointer-events: auto; }
.resumen {
  background: var(--bg-card); border: 1px solid var(--border-light); border-radius: 14px;
  padding: 8px 12px; font-size: 13px; color: var(--text-secondary); line-height: 1.35;
}
.resumen b { color: var(--text-primary); }
.bottombar { align-items: flex-end; }
.der-col { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.zoom-btns {
  display: flex; flex-direction: column; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--border-light); background: var(--bg-card);
}
.zoom-btns button { width: 44px; height: 44px; border: 0; background: none; display: flex; align-items: center; justify-content: center; }
.zoom-btns button + button { border-top: 1px solid var(--border-light); }
.zoom-btns button:disabled { opacity: .35; cursor: default; }
.zoom-btns svg { width: 20px; height: 20px; }
.zoom-btns[hidden] { display: none; }
.pill-btn {
  height: 44px; padding: 0 16px; border-radius: 14px; border: 1px solid var(--border-light);
  background: var(--bg-card); font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px;
}
.pill-btn svg { width: 18px; height: 18px; }
.banner-mover {
  position: fixed; left: 12px; right: 12px; top: calc(var(--ed-top) + 104px); z-index: 260;
  background: #EF9F27; color: #1a1c1f; border-radius: 12px; padding: 10px 12px; font-size: 14px; font-weight: 600;
  display: none; align-items: center; gap: 10px; max-width: 560px;
}
.banner-mover.on { display: flex; }
.banner-mover button { margin-left: auto; border: 0; background: #1a1c1f; color: #fff; border-radius: 9px; padding: 8px 12px; font-weight: 700; flex: none; }
.banner-mover button.sec { margin-left: 0; background: transparent; color: #1a1c1f; text-decoration: underline; }

.cargando {
  position: fixed; inset: 0; top: var(--ed-top); z-index: 270; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 12px; background: var(--bg-primary); color: var(--text-secondary); font-size: 14px; text-align: center; padding: 20px;
}
#cargando-txt { font-size: 14px; color: var(--k-tx-888888, #888); }   /* mismo cargador que el resto (.spinner de styles-base) */

/* ── hojas (bottom sheets) ── */
.velo { position: fixed; inset: 0; z-index: 970; background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .25s; }
.velo.on { opacity: 1; pointer-events: auto; }
.hoja {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 971; max-height: 86vh; overflow-y: auto;
  background: var(--bg-modal); border-radius: 20px 20px 0 0; border-top: 1px solid var(--border-light);
  padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .3s cubic-bezier(.22,1,.36,1);
  max-width: 560px; margin: 0 auto; box-sizing: border-box;
}
.hoja.on { transform: translateY(0); }
.asa { width: 40px; height: 4px; border-radius: 2px; background: var(--border-input); margin: 4px auto 12px; }
.h-sup { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-muted); }
.h-tit { font-size: 22px; font-weight: 700; margin: 2px 0 10px; }
.estado-tag { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; padding: 6px 11px; border-radius: 10px; background: color-mix(in srgb, var(--c) 18%, transparent); color: var(--c); }
.estado-tag::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.aviso { font-size: 13px; color: #EF9F27; background: rgba(239,159,39,.1); border: 1px solid rgba(239,159,39,.3); border-radius: 10px; padding: 8px 10px; margin-top: 10px; line-height: 1.4; }
.aviso.neutro { color: var(--text-secondary); background: none; border-color: var(--border-light); }
.datos { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; margin: 14px 0; }
.datos dt { color: var(--text-muted); }
.datos dd { margin: 0; }
.acciones { display: grid; gap: 8px; margin-top: 10px; }
.acciones.dos { grid-template-columns: 1fr 1fr; }
.btn {
  height: 48px; border-radius: 13px; border: 1px solid var(--border-light); background: var(--bg-secondary);
  font-weight: 700; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.primario { background: #378ADD; border-color: #378ADD; color: #fff; }
.btn.verde { background: #1D9E75; border-color: #1D9E75; color: #fff; }
.btn.peligro { color: #e05a4a; }
.btn.chico { height: 40px; font-size: 14px; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.resp { margin-top: 14px; padding: 12px; border-radius: 13px; border: 1px solid var(--border-light); }
.resp-txt { font-size: 13.5px; color: var(--text-secondary); line-height: 1.45; }
.resp-txt b { color: var(--text-primary); }
.hist { margin-top: 16px; }
.hist h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.hist-item { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 7px 0; border-bottom: 1px solid var(--border-primary); }
.hist-item:last-child { border-bottom: 0; }
.hist-item > span:last-child { color: var(--text-muted); text-align: right; flex: none; }
.hist-item .nota { color: var(--text-muted); }

/* ── lista ── */
.lista { position: fixed; inset: 0; top: var(--ed-top); z-index: 240; background: var(--bg-primary); overflow-y: auto; display: none; padding: 110px 12px 90px; box-sizing: border-box; }
.lista.on { display: block; }
.lista-in { max-width: 720px; margin: 0 auto; }
.lista-sec { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 16px 4px 8px; }
.fila {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px; border-radius: 14px; border: 1px solid var(--border-primary); background: var(--bg-card); margin-bottom: 8px;
}
.fila .sq { width: 12px; height: 34px; border-radius: 4px; background: var(--c); flex: none; }
.fila .t { font-weight: 700; font-size: 15px; }
.fila .s { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.fila .der { margin-left: auto; font-size: 12px; color: var(--text-muted); text-align: right; flex: none; }
.fila .der .falta { color: #EF9F27; }
.vacio { text-align: center; color: var(--text-muted); font-size: 14px; padding: 30px 10px; }

/* ── portero ── */
.portero { position: fixed; inset: 0; z-index: 950; background: var(--bg-primary); overflow-y: auto; display: none; }
.portero.on { display: block; }
.por-wrap { max-width: 520px; margin: 0 auto; padding: 12px 14px 150px; }
.por-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.por-head .h-tit { margin: 0; font-size: 19px; }
.progreso { margin: 0 0 14px; }
.progreso .barra { height: 8px; border-radius: 4px; background: var(--border-primary); overflow: hidden; }
.progreso .barra i { display: block; height: 100%; background: #1D9E75; border-radius: 4px; transition: width .3s; }
.progreso .txt { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-secondary); margin-top: 6px; }
.panel {
  border-radius: 22px; padding: 16px 14px 18px;
  background: linear-gradient(160deg, #4a4e55, #2b2e33 55%, #23262a);
  border: 1px solid #555a62; box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 8px 24px rgba(0,0,0,.35);
}
.rejilla { display: flex; justify-content: center; gap: 4px; margin-bottom: 14px; }
.rejilla i { width: 4px; height: 18px; border-radius: 2px; background: #1b1d20; box-shadow: inset 0 1px 2px rgba(0,0,0,.6); }
.pisos { display: grid; gap: 7px; }
.piso { display: grid; grid-template-columns: 34px repeat(var(--cols), minmax(0, 1fr)); gap: 7px; align-items: center; }
.piso.sin-lbl { grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); max-width: calc(var(--cols) * 120px); margin: 0 auto; width: 100%; }
.piso-lbl { font-size: 12px; font-weight: 800; color: #b9bec6; text-align: center; }
.timbre {
  height: 50px; border-radius: 11px; border: 1px solid #1d1f22; position: relative; padding: 0 2px;
  background: linear-gradient(#3b3f45, #2d3035); color: #e8e8e8; font-weight: 800; font-size: 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 2px 0 #1a1c1f;
  display: flex; align-items: center; justify-content: center; flex-direction: column; line-height: 1.05;
}
.timbre:active { transform: translateY(1px); box-shadow: inset 0 1px 0 rgba(255,255,255,.1); }
.timbre small { font-size: 9.5px; font-weight: 700; opacity: .85; margin-top: 2px; }
.timbre[data-res] { color: #fff; border-color: rgba(0,0,0,.35); }
.timbre[data-res="atendio"] { background: var(--r-atendio); }
.timbre[data-res="no_atendio"] { background: var(--r-no); }
.timbre[data-res="no_quiere"] { background: repeating-linear-gradient(45deg, var(--r-noquiere) 0 7px, #a5301f 7px 14px); }
.timbre[data-res="revisita"] { background: var(--r-revisita); }
.timbre.chico { height: 30px; font-size: 12px; }
.altavoz { display: grid; grid-template-columns: repeat(7, 6px); gap: 5px; justify-content: center; margin-top: 16px; }
.altavoz i { width: 6px; height: 6px; border-radius: 50%; background: #17191b; }
.herramientas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 960;
  background: var(--bg-modal); border-top: 1px solid var(--border-light);
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
}
.herr-txt { font-size: 12px; color: var(--text-muted); text-align: center; margin-bottom: 8px; }
.herr-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; max-width: 520px; margin: 0 auto; }
.herr {
  height: 54px; border-radius: 12px; border: 2px solid transparent; background: var(--bg-secondary);
  font-size: 12px; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.herr i { width: 14px; height: 14px; border-radius: 4px; background: var(--c); }
.herr.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 22%, var(--bg-secondary)); }

/* ── formularios ── */
.forma { display: grid; gap: 14px; }
.forma label { font-size: 13px; color: var(--text-secondary); display: block; margin-bottom: 6px; font-weight: 600; }
.forma .buscar { width: 100%; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border-light); background: var(--bg-secondary); font-size: 22px; font-weight: 700; }
.stepper output { min-width: 40px; text-align: center; font-size: 20px; font-weight: 700; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.seg.tres { grid-template-columns: repeat(3, 1fr); }
.seg button { min-height: 42px; padding: 6px 8px; line-height: 1.25; border-radius: 11px; border: 1px solid var(--border-light); background: var(--bg-secondary); font-weight: 600; }
.seg button.on { background: var(--text-primary); color: var(--bg-primary); }
.ayuda { font-size: 14px; color: var(--text-secondary); margin: 0 0 16px; line-height: 1.45; }

.leaflet-control-attribution { font-size: 9px; }
.leaflet-control-zoom { display: none; }
