/* =========================================================================
   CLIENTS / LEADS
   ========================================================================= */
.clients-layout { display: grid; grid-template-columns: 1fr 360px; gap: 0; height: calc(100vh - 36px - 56px - 24px - 40px); border: 1px solid var(--border-1); border-radius: 4px; background: var(--bg-surface); overflow: hidden; }
.cl-list { border-right: 1px solid var(--border-1); display: flex; flex-direction: column; min-height: 0; }
.cl-search { padding: 12px; border-bottom: 1px solid var(--border-1); }
.cl-rows { overflow: auto; flex: 1; }
.cl-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border-3); cursor: pointer; }
.cl-row:hover { background: var(--bg-inset); }
.cl-row.active { background: var(--red-50); box-shadow: inset 2px 0 0 var(--revin-red); }
.cl-row .ava { width: 36px; height: 36px; border-radius: 999px; background: var(--neutral-700); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.cl-row.cooling .ava { background: var(--revin-red); }
.cl-name { font-size: 14px; font-weight: 600; color: var(--fg-1); }
.cl-meta { font-size: 11px; color: var(--fg-2); margin-top: 1px; display: flex; gap: 8px; align-items: center; }
.cl-budget { font-family: var(--font-mono); font-size: 11px; color: var(--fg-2); text-align: right; }
.cl-budget .big { font-size: 13px; color: var(--fg-1); font-weight: 700; display: block; }

/* Client drawer (detail) */
.cl-drawer { display: flex; flex-direction: column; background: var(--bg-surface); min-height: 0; overflow: auto; }
.cl-head { padding: 20px 20px 16px; border-bottom: 1px solid var(--border-1); }
.cl-head .top { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.cl-head .big-ava { width: 48px; height: 48px; border-radius: 999px; background: var(--revin-black); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; flex-shrink: 0; }
.cl-head h2 { margin: 0; font-family: var(--font-body); font-size: 18px; font-weight: 700; text-transform: none; letter-spacing: 0; color: var(--fg-1); line-height: 1.2; }
.cl-head .sub { font-size: 12px; color: var(--fg-2); margin-top: 2px; }
.cl-contact { display: flex; gap: 6px; margin-top: 8px; }
.btn-wa { width: 32px; height: 32px; border-radius: 999px; background: #25D366; border: none; color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; transition: background 120ms; }
.btn-wa:hover { background: #1DA851; }
.btn-wa .icon { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.75; fill: none; }
.btn-tel { width: 32px; height: 32px; border-radius: 999px; background: var(--revin-black); color: #fff; border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.btn-tel:hover { background: var(--neutral-700); }
.btn-tel .icon { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.75; fill: none; }
.btn-mail { width: 32px; height: 32px; border-radius: 999px; background: var(--bg-inset); color: var(--fg-1); border: 1px solid var(--border-2); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.btn-mail:hover { background: var(--bg-surface-2); }
.btn-mail .icon { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.75; fill: none; }

/* WhatsApp templates dropdown placeholder */
.cl-section { padding: 16px 20px; border-bottom: 1px solid var(--border-3); }
.cl-section h4 { margin: 0 0 10px; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--fg-3); }
.cl-kv-list { display: flex; flex-direction: column; gap: 8px; }
.cl-kv { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 12px; }
.cl-kv .k { color: var(--fg-2); }
.cl-kv .v { color: var(--fg-1); font-weight: 600; text-align: right; }

/* Matching result */
.match-result { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--border-3); cursor: pointer; }
.match-result:hover { background: var(--bg-inset); }
.match-score { font-family: var(--font-mono); font-size: 13px; font-weight: 700; padding: 4px 8px; border-radius: 2px; background: var(--success-bg); color: var(--success-fg); width: 50px; text-align: center; flex-shrink: 0; }
.match-score.med { background: var(--warning-bg); color: var(--warning-fg); }
.match-score.low { background: var(--bg-inset); color: var(--fg-3); }
.match-body { flex: 1; min-width: 0; }
.match-name { font-size: 13px; font-weight: 600; color: var(--fg-1); }
.match-meta { font-size: 11px; color: var(--fg-2); margin-top: 1px; }

/* =========================================================================
   CALENDAR / AGENDA
   ========================================================================= */
.cal-grid { background: var(--bg-surface); border: 1px solid var(--border-1); border-radius: 4px; overflow: hidden; }
.cal-header { display: grid; grid-template-columns: 80px repeat(7, 1fr); border-bottom: 1px solid var(--border-1); background: var(--bg-inset); }
.cal-h-cell { padding: 10px 12px; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--fg-2); border-right: 1px solid var(--border-1); }
.cal-h-cell:last-child { border-right: none; }
.cal-h-cell.today { color: var(--revin-red); }
.cal-h-cell .day-num { font-family: var(--font-display); font-size: 20px; margin-top: 4px; color: var(--fg-1); letter-spacing: .02em; }
.cal-h-cell.today .day-num { color: var(--revin-red); }
.cal-body { display: grid; grid-template-columns: 80px repeat(7, 1fr); }
.cal-time { padding: 8px 12px; font-family: var(--font-mono); font-size: 11px; color: var(--fg-3); border-right: 1px solid var(--border-1); border-bottom: 1px solid var(--border-3); text-align: right; }
.cal-cell { border-right: 1px solid var(--border-3); border-bottom: 1px solid var(--border-3); min-height: 48px; padding: 2px; position: relative; }
.cal-cell:last-child { border-right: none; }
.cal-cell.today { background: var(--red-50); }
.cal-event { background: var(--revin-black); color: #fff; padding: 4px 6px; font-size: 11px; line-height: 1.2; border-radius: 2px; border-left: 2px solid var(--revin-red); margin-bottom: 2px; cursor: pointer; }
.cal-event.warn { background: var(--warning); border-left-color: var(--warning-fg); }
.cal-event.info { background: var(--info); border-left-color: var(--info-fg); }
.cal-event.success { background: var(--success); border-left-color: var(--success-fg); }
.cal-event .ev-time { font-family: var(--font-mono); font-size: 9px; opacity: .8; }
.cal-event .ev-title { font-weight: 600; }

/* =========================================================================
   MAP
   ========================================================================= */
.map-layout { display: grid; grid-template-columns: 1fr 320px; height: calc(100vh - 36px - 56px); position: relative; }
/* El lienzo lo pinta MapLibre. Hasta el 27-ago-2026 esto eran gradientes que
   simulaban carreteras y manzanas, con los ::before y ::after dibujando una
   ciudad inventada; los pines se colocaban encima con `left: lng%`. Ya no hay
   decorado: debajo hay callejero del IGN, ortofoto del PNOA y el parcelario
   del Catastro, servicios publicos reales. */
.map-canvas { position: relative; overflow: hidden; background: var(--bg-inset); }
.map-canvas .maplibregl-map { position: absolute; inset: 0; }

/* Un inmueble. El color dice si la coordenada es de fiar: rojo de marca para
   portal exacto, ambar para aproximada. Pintarlas igual seria mentir con un
   punto. El numero aparece cuando varios comparten portal. */
.rv-punto {
  border-radius: 999px; cursor: pointer; padding: 0;
  border: 2px solid #fff; box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: var(--font-body); font-size: 10px; font-weight: 700;
  line-height: 1; transition: width 120ms, height 120ms;
}
/* El COLOR es el estado comercial. La OPACIDAD (por opciones del Marker) dice
   si la coordenada es de fiar. Dos preguntas distintas, dos canales distintos:
   mezclarlas obligaba a elegir cual de las dos se cuenta y cual se calla. */
.rv-punto.disponible { background: var(--revin-red); }
.rv-punto.vendido    { background: var(--fg-1); }
.rv-punto.otro       { background: var(--fg-3); }

/* Tu posicion. Azul y no rojo a proposito: no eres un inmueble. */
.rv-yo {
  width: 16px; height: 16px; border-radius: 999px;
  background: var(--info); border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(37,99,168,.35), var(--shadow-md);
}

/* Navegacion por niveles de la parcela: dirección › escalera › planta › puerta.
   Cada fila lleva su cuenta a la derecha, que es lo que dice si merece la pena
   entrar: "358" en un garaje avisa antes de pinchar. */
.rv-niveles { display: flex; flex-direction: column; gap: 2px; }
.rv-niveles button {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left; padding: 9px 10px;
  background: var(--bg-surface); border: 1px solid var(--border-3); border-radius: 3px;
  font-family: inherit; font-size: 12px; color: var(--fg-1); cursor: pointer;
}
.rv-niveles button:hover { background: var(--bg-inset); border-color: var(--border-2); }
.rv-niveles button .n {
  font-family: var(--font-mono); font-size: 10px; color: var(--fg-2);
  background: var(--bg-inset); border-radius: 999px; padding: 1px 7px; flex: none;
}

.rv-miga { font-size: 11px; color: var(--fg-3); margin: 0 0 8px; line-height: 1.5; }
.rv-miga button {
  border: none; background: none; padding: 0; cursor: pointer;
  font-family: inherit; font-size: 11px; color: var(--revin-red);
}
.rv-miga button:hover { text-decoration: underline; }

.rv-clave {
  display: inline-block; width: 8px; height: 8px; border-radius: 999px;
  margin-right: 4px; vertical-align: middle;
}
.rv-clave.disponible { background: var(--revin-red); }
.rv-clave.vendido    { background: var(--fg-1); }
.rv-clave.otro       { background: var(--fg-3); }

.rv-filtro {
  background: var(--bg-surface); border: 1px solid var(--border-1); border-radius: 4px;
  padding: 8px 10px; font-family: inherit; font-size: 12px; color: var(--fg-1);
  box-shadow: var(--shadow-md); cursor: pointer;
}
.rv-punto.activo { border-width: 3px; box-shadow: 0 0 0 3px var(--revin-red), var(--shadow-md); }
/* El foco va por outline porque border y box-shadow los escribe el propio
   marcador en linea: el anillo del sistema quedaria invisible. */
.rv-punto:focus-visible { outline: 3px solid var(--revin-red); outline-offset: 2px; }

/* Punto donde se ha pinchado para consultar el Catastro. Es una diana, no un
   pin: no marca un inmueble nuestro, marca "he preguntado aqui". */
.rv-parcela-punto {
  width: 18px; height: 18px; border-radius: 999px;
  border: 2px solid var(--revin-black); background: transparent;
  box-shadow: 0 0 0 2px #fff, var(--shadow-sm); pointer-events: none;
}
.rv-parcela-punto::after {
  content: ""; display: block; width: 4px; height: 4px; border-radius: 999px;
  background: var(--revin-black); margin: 5px auto;
}

.rv-capas {
  display: flex; gap: 0; border: 1px solid var(--border-1); border-radius: 4px;
  overflow: hidden; background: var(--bg-surface); box-shadow: var(--shadow-md);
}
.rv-capas button {
  border: none; background: var(--bg-surface); color: var(--fg-2);
  font-family: inherit; font-size: 12px; padding: 8px 12px; cursor: pointer;
}
.rv-capas button[aria-pressed="true"] { background: var(--revin-black); color: #fff; }
.rv-capas label {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px;
  font-size: 12px; color: var(--fg-2); border-left: 1px solid var(--border-1);
}

.rv-aviso-mapa {
  position: absolute; left: 16px; bottom: 16px; z-index: 10; max-width: 300px;
  background: var(--bg-surface); border: 1px solid var(--border-1);
  border-radius: 4px; padding: 6px 10px; font-size: 11px; color: var(--fg-2);
  box-shadow: var(--shadow-sm);
}

.rv-cat { border-top: 1px solid var(--border-1); padding: 12px 16px; font-size: 12px; }
.rv-cat dt { color: var(--fg-3); font-size: 11px; }
.rv-cat dd { margin: 0; text-align: right; }
.rv-cat .fila { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 6px; }
.rv-cat code { font-family: var(--font-mono); font-size: 11px; background: var(--bg-inset); border: 1px solid var(--border-1); padding: 1px 5px; border-radius: 2px; }
.rv-nota { color: var(--fg-3); font-size: 11px; margin-top: 8px; line-height: 1.45; }
.map-pin { position: absolute; transform: translate(-50%, -100%); cursor: pointer; z-index: 5; }
.map-pin .pin-shape {
  width: 30px; height: 38px; position: relative;
  background: var(--revin-red);
  clip-path: path("M15 0 C 6 0, 0 6, 0 14 C 0 24, 15 38, 15 38 C 15 38, 30 24, 30 14 C 30 6, 24 0, 15 0 Z");
  display: flex; align-items: flex-start; justify-content: center; padding-top: 6px;
  filter: drop-shadow(0 2px 4px rgba(22,26,29,.3));
}
.map-pin .pin-shape::after { content: ""; position: absolute; top: 9px; left: 50%; transform: translateX(-50%); width: 10px; height: 10px; border-radius: 999px; background: #fff; }
.map-pin.you .pin-shape { background: var(--info); }
.map-pin.cooling .pin-shape { background: var(--warning); }
.map-pin .pin-label { position: absolute; left: 50%; bottom: -22px; transform: translateX(-50%); background: var(--revin-black); color: #fff; font-family: var(--font-mono); font-size: 9px; padding: 2px 6px; border-radius: 2px; white-space: nowrap; opacity: 0; transition: opacity 120ms; pointer-events: none; }
.map-pin:hover .pin-label { opacity: 1; }
/* flex-wrap: con las capas, el buscador, el filtro de estado y los dos botones
   de accion en una sola fila, en una ventana estrecha el buscador se estrujaba
   hasta desaparecer. Que baje de linea antes que encogerse. */
.map-overlay { position: absolute; top: 16px; left: 16px; right: 16px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; z-index: 10; pointer-events: none; }
.map-overlay > * { pointer-events: auto; }
.map-search { background: var(--bg-surface); border: 1px solid var(--border-1); border-radius: 4px; padding: 8px 12px; display: flex; align-items: center; gap: 8px; width: 340px; box-shadow: var(--shadow-md); }
.map-search input { border: none; background: transparent; outline: none; font-family: inherit; font-size: 13px; color: var(--fg-1); flex: 1; }
.map-search .icon { width: 14px; height: 14px; stroke: var(--fg-3); stroke-width: 2; fill: none; }
.map-near { background: var(--revin-red); color: #fff; border: none; padding: 8px 14px; border-radius: 4px; font-family: var(--font-body); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; box-shadow: var(--shadow-md); }
.map-near .icon { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; }
.map-near:hover { background: var(--red-600); }
.map-side { background: var(--bg-surface); border-left: 1px solid var(--border-1); display: flex; flex-direction: column; overflow: hidden; }
.map-side-h { padding: 14px 16px; border-bottom: 1px solid var(--border-1); }
.map-side-h h3 { margin: 0; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-1); }
.map-side-h .sub { font-size: 11px; color: var(--fg-2); margin-top: 2px; }
.map-rows { overflow: auto; flex: 1; }
.map-row { padding: 12px 16px; border-bottom: 1px solid var(--border-3); cursor: pointer; }
.map-row:hover { background: var(--bg-inset); }
.map-row .addr { font-size: 13px; font-weight: 600; color: var(--fg-1); }
.map-row .meta { font-size: 11px; color: var(--fg-2); margin-top: 2px; display: flex; gap: 8px; }
.map-row .dist { font-family: var(--font-mono); font-size: 11px; color: var(--revin-red); font-weight: 700; }

.map-radius { position: absolute; border: 2px solid rgba(226,35,44,.5); background: rgba(226,35,44,.08); border-radius: 999px; pointer-events: none; transform: translate(-50%, -50%); z-index: 3; }

/* .btn-wa:disabled no existia: un WhatsApp apagado seguia verde y se iluminaba
   al pasar por encima. Se queda (Mobile tambien usa .btn-wa). Las reglas de
   .match-result.inerte se fueron con el bloque de matching en B2. */
.btn-wa:disabled { opacity: .4; cursor: not-allowed; }
.btn-wa:disabled:hover { background: #25D366; }

/* Sugerencias de dirección del buscador del mapa. onMouseDown y no onClick en
   los botones: el input pierde el foco antes de que llegue el click y el
   desplegable ya se habría cerrado. */
.rv-sugerencias {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 20;
  background: var(--bg-surface); border: 1px solid var(--border-1);
  border-radius: 4px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.rv-sug-eyebrow {
  margin: 0; padding: 6px 10px 4px; font-size: 10px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; color: var(--fg-3);
  border-bottom: 1px solid var(--border-3);
}
.rv-sugerencias button {
  display: block; width: 100%; text-align: left; padding: 7px 10px;
  border: none; background: none; cursor: pointer; font-family: inherit;
}
.rv-sugerencias button:hover { background: var(--bg-inset); }
.rv-sugerencias .d { display: block; font-size: 12px; color: var(--fg-1); }
.rv-sugerencias .m { display: block; font-size: 10px; color: var(--fg-3); }

/* Resultado de crear una captación o asignar una parcela. Antes era una nota
   gris en rojo de peligro: "Creada la captación REF-041" se anunciaba con el
   mismo color que un error. Ahora se distingue, y se sube sola a la vista
   (FichaParcela) porque en el móvil caía por debajo del pliegue de la hoja. */
.rv-resultado {
  margin-top: 10px; padding: 9px 11px; border-radius: 4px;
  /* Que no quede pegado al borde de la hoja al subirlo a la vista. */
  scroll-margin: 12px;
  font-size: 12px; font-weight: 600; line-height: 1.4;
  background: var(--red-50); border: 1px solid var(--red-200); color: var(--danger);
}
.rv-resultado.ok {
  background: rgba(31,157,85,.08); border-color: rgba(31,157,85,.35); color: var(--success);
}

/* Rotulillo de sección dentro de la ficha de parcela. */
.rv-sub-ojo {
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--fg-2); margin-bottom: 6px;
}
