/* ===========================
   TOKENS / ROOT
   =========================== */
:root {
  --map-color: #748573;
  --map-color-transparent: rgba(151, 177, 41, .15);
  --brand-primary: #748573;
  --brand-accent: #c6b194;
  --card-bg: #fff;
  --card-border: rgba(0, 0, 0, .06);
  --card-shadow: 0 10px 30px rgba(0, 0, 0, .08);
  --card-shadow-hover: 0 16px 40px rgba(0, 0, 0, .12);
  --diag-left: #748573;
  --diag-right: #c6b194;
  --dur: .32s;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

.ribagorza-theme {
  --ele-bg: rgba(151, 177, 41, .1);
  --ele-axis: #566B13;
  --ele-area: #97B129;
  --ele-grid: #CCC;
  --ele-brush: rgba(99, 126, 11, .4);
  --ele-poly: #566B13;
  --ele-line: #70ab00;
}

.leaflet-control-zoomhome-in, .leaflet-control-zoomhome-out {
  font-size: 22px !important
}

/* ===========================
   LINKS & BUTTONS
   =========================== */
.custom-links ul {
  margin: 0;
  padding: 0
}

.custom-links ul li {
  list-style: none;
  margin: 0;
  padding: 0
}

.custom-buttons {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap
}

.custom-buttons__item {
  padding: 10px 20px;
  border-radius: 40px;
  transition: all .2s ease-in;
  font: 16px/1 inherit;
  display: inline-block;
  text-align: center
}

.custom-buttons__item a, .custom-buttons__item-link, .custom-links__item-link {
  color: inherit;
  text-decoration: none
}

.custom-buttons__item.outline {
  background: transparent;
  border: 2px solid #97B129;
  color: #97B129
}

.custom-buttons__item.outline:hover {
  background: #97B129;
  color: #fff;
  cursor: pointer
}

.custom-buttons__item.outline-orange {
  background: transparent;
  border: 1px solid #F59E24;
  color: #F59E24;
  text-transform: uppercase
}

.custom-buttons__item.outline-orange:hover {
  background: #F59E24;
  color: #fff;
  cursor: pointer
}

.custom-buttons__item.outline-orange .custom-buttons__item-icon {
  width: 10px
}

.custom-buttons__item.outline-orange .custom-buttons__item-link {
  display: flex;
  align-items: center;
  gap: 20px;
  justify-content: center;
  font-size: 14px;
  font-weight: 700
}

.custom-buttons__item.filled {
  background: #97B129;
  color: #fff;
  border: 2px solid #97B129
}

.custom-buttons__item.filled:hover {
  opacity: .9;
  cursor: pointer
}

/* ===========================
   LAYOUT / SIDEBAR
   =========================== */
.territorios-mapa-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: auto;
  background: #fff;
  border-top: 1px solid #ddd
}

.territorios-sidebar {
  order: 1;
  flex: none;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-bottom: 1px solid #ddd;
  padding: 15px 20px;
  overflow-y: auto;
  z-index: 3;
  box-shadow: 2px 0 8px rgba(0, 0, 0, .05)
}

.territorios-sidebar h2, .territorios-sidebar h3 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 15px;
  color: #748573;
  letter-spacing: .03em;
  animation: fadeInUp .6s ease forwards
}

.territorios-sidebar h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px
}

.territorios-sidebar .btn-back-sidebar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: #748573;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
  transition: background .3s, transform .2s, box-shadow .2s
}

.territorios-sidebar .btn-back-sidebar:hover {
  transform: scale(1.05)
}

.territorios-sidebar .btn-back-sidebar:focus {
  outline: 2px solid rgba(182, 190, 26, .6);
  outline-offset: 2px
}

.territorios-sidebar .btn-back-sidebar img {
  width: 18px;
  height: 18px;
  display: block;
  filter: brightness(0) invert(1)
}

.territorios-sidebar .title-text {
  text-transform: uppercase
}

.territorios-sidebar label {
  display: block;
  margin-bottom: 12px;
  font-size: .95rem;
  color: #555;
  user-select: none
}

.territorios-sidebar input, .territorios-sidebar select {
  width: 100%;
  padding: 8px 12px;
  font-size: 1rem;
  border: 1.8px solid #bbb;
  border-radius: 6px;
  background: #fff;
  box-shadow: inset 0 2px 5px rgb(0 0 0 / 5%);
  transition: border-color .3s, box-shadow .3s
}

.territorios-sidebar input:focus, .territorios-sidebar select:focus {
  outline: none
}

/* Filtros */
.filtros-basicos {
  display: flex;
  flex-flow: column nowrap;
  gap: 20px
}

.filtros-basicos-row {
  display: flex;
  flex-flow: row wrap;
  gap: 10px;
  margin-bottom: 10px
}

.filtros-basicos-row label input, .filtros-basicos-row label select {
  margin-top: 10px
}

.filtros-avanzados {
  margin-top: 20px;
  border-top: 1px solid #ddd;
  padding-top: 12px
}

.filtros-avanzados summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 12px;
  list-style: none;
  position: relative;
  padding-left: 22px;
  color: #B6BE1A;
  user-select: none;
  transition: color .3s;
  animation: fadeInLeft .5s ease forwards
}

.filtros-avanzados summary::marker {
  content: ''
}

.filtros-avanzados summary::before {
  content: "▶";
  position: absolute;
  left: 0;
  top: -.2rem;
  font-size: 1.1rem;
  color: #B6BE1A;
  transition: transform .3s
}

.filtros-avanzados[open] summary::before {
  transform: rotate(90deg)
}

.filtros-avanzados label {
  margin-left: 14px;
  font-weight: 500;
  font-size: .9rem
}

/* Chips */
.cat-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 16px
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1.8px solid #bbb;
  border-radius: 999px;
  background: #fff;
  font-size: .9rem;
  cursor: pointer;
  user-select: none;
  transition: border-color .2s, box-shadow .2s, transform .15s
}

.cat-chip img {
  width: 16px;
  height: 16px;
  display: block
}

.cat-chip.is-on {
  border-color: #97B129;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .08)
}

.cat-chip:active {
  transform: scale(.98)
}

/* Acordeones categoría */
.cat-acc {
  border: 1px solid #ddd;
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .06);
  background: #fff;
  animation: fadeInUp .3s ease both
}

.cat-acc[open] {
  box-shadow: 0 6px 14px rgba(0, 0, 0, .07)
}

.cat-acc summary {
  list-style: none;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  user-select: none
}

.cat-acc summary::-webkit-details-marker {
  display: none
}

.cat-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0
}

.cat-bullet {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cat-color, #bbb);
  flex: 0 0 12px;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .04) inset
}

.cat-name {
  font-weight: 700;
  color: #333;
  letter-spacing: .02em
}

.cat-count {
  font-size: .85rem;
  color: #666
}

.cat-actions {
  display: flex;
  align-items: center;
  gap: 8px
}

.cat-eye {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #f6f6f6;
  border: 1px solid #e2e2e2;
  cursor: pointer;
  transition: background .2s, transform .1s, border-color .2s
}

.cat-eye:hover {
  background: #efefef;
  border-color: #d5d5d5
}

.cat-eye:active {
  transform: scale(.96)
}

.cat-eye img {
  width: 20px;
  height: 20px
}

.cat-caret {
  width: 18px;
  height: 18px;
  opacity: .75;
  transform: rotate(0);
  transition: transform .2s
}

.cat-acc[open] .cat-caret {
  transform: rotate(90deg)
}

.cat-accordion__panel {
  padding: 12px 14px;
  border-top: 1px solid #eee;
  background: #fff
}

.cat-accordion__panel ul {
  list-style: none;
  margin: 0;
  padding: 0
}

.cat-empty {
  font-size: .9rem;
  color: #777;
  padding: 6px 2px
}

/* ===========================
   LISTADO (cards sidebar)
   =========================== */
#lista-territorios {
  list-style: none;
  padding: 0;
  margin: 0
}

#lista-territorios li {
  padding: 0;
  margin-bottom: 16px;
  background: transparent;
  border-radius: 16px;
  box-shadow: none;
  transition: box-shadow .3s, transform .25s;
  animation: fadeInUp .4s ease forwards;
  list-style: none !important
}

#lista-territorios .territorio-card {
  display: grid !important;
  grid-template-columns: 108px 1fr !important;
  gap: 14px !important;
  padding: 14px !important;
  background: var(--card-bg) !important;
  border: 1px solid var(--card-border) !important;
  border-radius: 16px !important;
  box-shadow: var(--card-shadow) !important;
  transition: transform .18s, box-shadow .18s, border-color .2s !important;
  position: relative !important;
  isolation: isolate !important
}

#lista-territorios .territorio-card:hover {
  transform: translateY(-2px) !important;
  box-shadow: var(--card-shadow-hover) !important;
  border-color: color-mix(in oklab, var(--brand-accent) 35%, var(--card-border)) !important
}

#lista-territorios .territorio-card>.img-wrapper {
  align-self: center !important
}

#lista-territorios .territorio-card .img-wrapper {
  position: relative !important;
  display: block !important;
  width: 108px !important;
  height: 108px !important;
  flex-shrink: 0 !important;
  overflow: hidden !important;
  border-radius: 12px !important;
  background: #f3f3f3 !important;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .04) !important;
  z-index: 1 !important
}

#lista-territorios .territorio-card .img-wrapper+.img-wrapper {
  margin-top: 8px !important
}

#lista-territorios .territorio-card .img-wrapper img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  object-position: center !important;
  display: block !important;
  opacity: 0;
  filter: blur(10px);
  transition: opacity .35s, filter .35s, transform .35s
}

#lista-territorios .territorio-card .img-wrapper img.loaded {
  opacity: 1;
  filter: blur(0)
}

#lista-territorios .territorio-card-content {
  z-index: 1 !important;
  display: grid !important;
  grid-template-rows: auto 1fr auto !important;
  gap: 6px !important;
  align-content: start !important
}

#lista-territorios .territorio-card-title, #lista-territorios .territorio-card-title-item {
  font-size: 1rem !important;
  font-weight: 800 !important;
  letter-spacing: .01em !important;
  color: #2a2f27 !important;
  margin: 0 0 2px 0 !important
}

#lista-territorios .territorio-card-excerpt {
  margin: 0 0 6px 0 !important;
  color: #5b5f58 !important;
  font-size: .9rem !important;
  line-height: 1.35 !important
}

#lista-territorios .territorio-card-excerpt a {
  font-size: .9rem !important;
  color: #5b5f58 !important;
  text-decoration: none !important
}

#lista-territorios .territorio-card-excerpt h2 {
  margin-top: 0
}

#lista-territorios .territorio-card-links {
  display: flex !important;
  gap: 8px !important;
  margin-top: 6px !important;
  margin-left: auto !important;
  justify-content: flex-end !important
}

#lista-territorios .territorio-card-button, .territorios-sidebar .button {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  width: fit-content !important;
  text-align: center !important;
  padding: 10px 12px !important;
  font-size: .85rem !important;
  font-weight: 700 !important;
  background: var(--brand-primary) !important;
  color: #fff !important;
  border-radius: 999px !important;
  text-decoration: none !important;
  transition: transform .15s, box-shadow .15s, filter .15s, background-color .2s !important;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .08) !important;
  border: 0 !important
}

.territorios-sidebar .button.load {
  display: none !important
}

#lista-territorios .territorio-card-button.is-ghost {
  background: #fff !important;
  color: var(--brand-primary) !important;
  border: 1px solid color-mix(in oklab, var(--brand-primary) 35%, #fff) !important;
  box-shadow: none !important
}

#lista-territorios .territorio-card-button.is-ghost:hover {
  background: color-mix(in oklab, var(--brand-primary) 7%, #fff) !important
}

#lista-territorios .territorio-card-button:hover, .territorios-sidebar .button:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .12) !important;
  filter: saturate(1.05) !important
}

/* ===========================
   MAPA / CONTROLES
   =========================== */
#map-container {
  position: relative;
  flex: 1;
  height: 100%;
  z-index: 1
}

#map {
  width: 100%;
  height: 70vh
}

#map-loader {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #eee 25%, #ddd 50%, #eee 75%);
  background-size: 200% 100%;
  animation: shimmerAnim 1.5s infinite;
  z-index: 2
}

/* Skeleton listado */
.skeleton-card {
  display: flex;
  gap: 10px;
  padding: 10px !important
}

.skeleton-image, .skeleton-line {
  background: linear-gradient(90deg, #eee 25%, #ddd 50%, #eee 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.2s infinite
}

.skeleton-image {
  width: 100px;
  height: 100px;
  border-radius: 4px;
  flex-shrink: 0
}

.skeleton-lines {
  flex: 1
}

.skeleton-line {
  height: 12px;
  margin-bottom: 8px;
  border-radius: 4px
}

.skeleton-line.short {
  width: 40%
}

.skeleton-line.medium {
  width: 70%
}

/* Scrollbar sidebar */
.territorios-sidebar::-webkit-scrollbar {
  width: 9px
}

.territorios-sidebar::-webkit-scrollbar-track {
  background: #f7f3ef;
  border-radius: 8px
}

.territorios-sidebar::-webkit-scrollbar-thumb {
  background: #c6b194;
  border-radius: 8px;
  border: 2px solid #f7f3ef;
  transition: background-color .3s
}

.territorios-sidebar::-webkit-scrollbar-thumb:hover {
  background: #b59f82
}

.territorios-sidebar {
  scrollbar-color: #c6b194 #f7f3ef;
  scrollbar-width: thin
}

/* Leaflet UI */
.leaflet-tooltip.map-tooltip {
  background: var(--map-color);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .2);
  pointer-events: none;
  font: 16px/1.2 system-ui, sans-serif;
  text-transform: uppercase
}

/* Chip marcador */
.poi-chip .poi-chip-inner, .poi-chip-inner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--chip-color, #333);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25)
}

/* Control filtros */
.leaflet-control.custom-filters {
  position: relative
}

.leaflet-control.custom-filters .filters-panel {
  display: none;
  position: absolute;
  top: 32px;
  left: 0;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 220px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
  z-index: 1000
}

.leaflet-control.custom-filters.open .filters-panel {
  display: block
}

.filters-panel .filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px
}

.filters-panel .filters-close {
  background: none;
  border: 0;
  font-size: 18px;
  line-height: 1;
  cursor: pointer
}

.filters-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0
}

/* Leyenda */
.leaflet-control.legend-box {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .1);
  font-size: 12px
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 3px 0
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c, #666);
  display: inline-block
}

/* Polígonos suaves */
.smooth-transition {
  transition: opacity .2s, fill-opacity .2s
}

/* Clusters */
.marker-cluster .mcircle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--c, #666);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
  display: flex;
  align-items: center;
  justify-content: center
}

.marker-cluster .mcircle span {
  color: #fff;
  font: 600 13px/1 system-ui, sans-serif
}

.marker-cluster-small .mcircle {
  transform: scale(.9)
}

.marker-cluster-medium .mcircle {
  transform: scale(1)
}

.marker-cluster-large .mcircle {
  transform: scale(1.1)
}

.marker-cluster div {
  margin-left: 0 !important;
  margin-top: 0 !important
}

.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large {
  background-color: transparent !important
}

/* ===========================
   MEDIA QUERIES
   =========================== */
body:not(:has(#wpadminbar)) .territorios-mapa-container {
  height: calc(100vh - 136px)
}

@media (min-width:783px) {
  body:has(#wpadminbar) .territorios-mapa-container {
    height: calc(100vh - (136px + 32px))
  }
}

@media (max-width:782px) {
  body:has(#wpadminbar) .territorios-mapa-container {
    height: calc(100vh - (136px + 46px))
  }
}

@media (min-width:769px) {
  .territorios-mapa-container {
    flex-direction: row
  }

  body:has(.admin-bar) .territorios-mapa-container {
    height: calc(100vh - 172px)
  }

  body .territorios-mapa-container {
    height: calc(100vh - 136px)
  }

  .territorios-sidebar {
    order: initial;
    flex: 0 0 30%;
    border-bottom: none;
    border-right: 1px solid #ddd;
    padding: 20px 25px
  }

  #map {
    height: 100%
  }

  .filtros-basicos-row label:first-of-type {
    flex: 1 0 calc(60% - 5px)
  }

  .filtros-basicos-row label:last-of-type {
    flex: 1 0 calc(40% - 5px)
  }
}

@media (max-width:480px) {
  #lista-territorios .territorio-card {
    grid-template-columns: 84px 1fr !important;
    padding: 12px !important;
    border-radius: 14px !important
  }

  #lista-territorios .territorio-card .img-wrapper {
    width: 84px !important;
    height: 84px !important;
    border-radius: 10px !important
  }
}

/* ===========================
   ANIMACIONES
   =========================== */
@keyframes shimmerAnim {
  100% {
    background-position-x: -200%
  }
}

@keyframes skeleton-loading {
  to {
    background-position: -200% 0
  }
}

@keyframes fadeInUp {
  0% {
    opacity: 0;
    transform: translateY(12px)
  }

  100% {
    opacity: 1;
    transform: translateY(0)
  }
}

@keyframes fadeInLeft {
  0% {
    opacity: 0;
    transform: translateX(-12px)
  }

  100% {
    opacity: 1;
    transform: translateX(0)
  }
}

/* ===========================
   POPUP MODERNO (Leaflet)
   =========================== */
.leaflet-popup.popup-modern .leaflet-popup-content-wrapper {
  padding: 0;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .22);
  border: 1px solid rgba(0, 0, 0, .06);
  overflow: hidden
}

.leaflet-popup.popup-modern .leaflet-popup-content {
  margin: 0
}

.leaflet-popup.popup-modern .leaflet-popup-tip {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .06)
}

.pm-card {
  overflow: hidden;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow)
}

.pm-cover {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: cover;
  object-position: center;
  background: #eef1ee;
  position: relative
}

.pm-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, color-mix(in oklab, var(--brand-accent) 26%, transparent) 0%, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, .12) 100%);
  pointer-events: none
}

.pm-body {
  padding: 16px 16px 18px
}

.pm-title {
  margin: 0 0 10px;
  font-size: 17px;
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: .005em;
  color: #2a2f27
}

.pm-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  line-height: 1;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--brand-primary);
  color: #fff !important;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .12);
  transition: transform .15s, box-shadow .15s, filter .15s
}

.pm-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .16);
  filter: saturate(1.06)
}

.pm-btn.is-ghost {
  background: #fff;
  color: var(--brand-primary) !important;
  border: 1px solid color-mix(in oklab, var(--brand-primary) 35%, #fff);
  box-shadow: none
}

.pm-btn.is-ghost:hover {
  background: color-mix(in oklab, var(--brand-primary) 7%, #fff)
}

.leaflet-popup-content-wrapper, .leaflet-popup-content {
  padding: 0 !important;
  margin: 0 !important
}

/* Control de capas */
.leaflet-control-layers-toggle {
  background-image: url('../assets/leaflet/images/layers.png') !important
}

@media (-webkit-min-device-pixel-ratio:2), (min-resolution:192dpi) {
  .leaflet-control-layers-toggle {
    background-image: url('../assets/leaflet/images/layers-2x.png') !important;
    background-size: 26px 26px
  }
}

/* =========================================================
   MODO ENFOCADO (brm-vendedores + overlays)
   ========================================================= */
.territorios-sidebar.is-focused #lista-territorios li {
  margin-bottom: 16px
}

.territorios-sidebar.is-focused #lista-territorios .territorio-card {
  display: none !important
}

.territorios-sidebar.is-focused .brm-vendedores-card {
  --split-top: 62%;
  --split-bottom: 38%;
  position: relative;
  display: block;
  overflow: hidden;
  padding: .75rem;
  border-radius: 1.4rem;
  background: #fff;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .06);
  border: 1px solid rgba(0, 0, 0, .06);
  transition: transform .18s, box-shadow .18s
}

.territorios-sidebar.is-focused .brm-vendedores-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, .1)
}

.territorios-sidebar.is-focused .brm-vendedores-card__box {
  position: relative;
  border-radius: 1.2rem 1.2rem 0 1.2rem;
  overflow: hidden;
  background: #fff
}

.territorios-sidebar.is-focused .brm-vendedores-card__media {
  position: relative;
  height: var(--card-h, 200px);
  overflow: hidden;
  background: #f5f5f7
}

.territorios-sidebar.is-focused .brm-vendedores-card__media img {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform .2s
}

.territorios-sidebar.is-focused .brm-vendedores-card:hover .brm-vendedores-card__media img {
  transform: scale(1.02)
}

.territorios-sidebar.is-focused .brm-vendedores-card__bar {
  position: absolute;
  bottom: -.375rem;
  right: -.375rem;
  height: 3.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 .9rem;
  background: #fff;
  border-top-left-radius: 1rem;
  z-index: 1
}

.territorios-sidebar.is-focused .brm-vendedores-card__title {
  flex: 1 1 auto;
  min-width: 0;
  color: #111;
  font-size: .98rem;
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.brm-vendedores-card__icon {
  flex: 0 0 auto;
  width: 2.55rem;
  height: 2.55rem;
  border-radius: .75rem;
  display: block;
  background-color: #e6e6e6
}

.brm-vendedores-card__icon.is-img {
  background-image: var(--icon-url) !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-size: contain !important;
  background-color: transparent !important
}

.territorios-sidebar.is-focused .brm-vendedores-card--compact {
  --card-h: clamp(160px, 34vw, 220px)
}

@media (max-width:480px) {
  .territorios-sidebar.is-focused .brm-vendedores-card--compact {
    --card-h: clamp(140px, 42vw, 200px)
  }
}

/* Overlays */
.territorios-sidebar.is-focused .brm-vendedores-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transition: opacity .18s
}

.territorios-sidebar.is-focused .brm-vendedores-card:hover::after, .territorios-sidebar.is-focused .brm-vendedores-card:focus-visible::after {
  opacity: .82
}

.territorios-sidebar.is-focused .brm-overlay {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 4;
  opacity: 0;
  transition: opacity var(--dur) var(--ease), clip-path var(--dur) var(--ease);
  pointer-events: auto
}

.territorios-sidebar.is-focused .brm-vendedores-card:hover .brm-overlay, .territorios-sidebar.is-focused .brm-vendedores-card:focus-visible .brm-overlay {
  opacity: .9
}

.territorios-sidebar.is-focused .brm-overlay span {
  font: 800 1rem/1.1 system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: .01em;
  pointer-events: none;
  margin: 0;
  white-space: nowrap
}

.territorios-sidebar.is-focused .brm-overlay--left {
  background: color-mix(in oklab, var(--diag-left) 72%, transparent)
}

.territorios-sidebar.is-focused .brm-overlay--right {
  background: color-mix(in oklab, var(--diag-right) 72%, transparent)
}

.territorios-sidebar.is-focused .brm-overlay--left span {
  color: #fff
}

.territorios-sidebar.is-focused .brm-overlay--right span {
  color: #2a2f27
}

.territorios-sidebar.is-focused .two-actions .brm-overlay--left {
  clip-path: polygon(0 0, var(--split-top) 0, var(--split-bottom) 100%, 0 100%)
}

.territorios-sidebar.is-focused .two-actions .brm-overlay--right {
  clip-path: polygon(var(--split-top) 0, 100% 0, 100% 100%, var(--split-bottom) 100%)
}

.territorios-sidebar.is-focused .two-actions .brm-overlay--left,
.territorios-sidebar.is-focused .two-actions .brm-overlay--right {
  display: grid;
  align-items: center;
  justify-items: initial;
  padding: 0
}

.territorios-sidebar.is-focused .two-actions .brm-overlay--left {
  justify-items: start;
  padding-inline: 75px
}

.territorios-sidebar.is-focused .two-actions .brm-overlay--left span {
  justify-self: start;
  text-align: left
}

.territorios-sidebar.is-focused .two-actions .brm-overlay--right {
  justify-items: end;
  padding-inline: 75px
}

.territorios-sidebar.is-focused .two-actions .brm-overlay--right span {
  justify-self: end;
  text-align: right
}

/* Efecto expansión */
.territorios-sidebar.is-focused .brm-vendedores-card {
  position: relative
}

.territorios-sidebar.is-focused .brm-vendedores-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  background: transparent;
  transition: opacity var(--dur) var(--ease), clip-path var(--dur) var(--ease), background-color var(--dur) var(--ease);
  clip-path: inset(0)
}

.territorios-sidebar.is-focused .brm-vendedores-card.two-actions:has(.brm-overlay--left:hover)::before {
  opacity: .9;
  background: color-mix(in oklab, var(--diag-left) 84%, transparent)
}

.territorios-sidebar.is-focused .brm-vendedores-card.two-actions:has(.brm-overlay--right:hover)::before {
  opacity: .9;
  background: color-mix(in oklab, var(--diag-right) 84%, transparent)
}

.territorios-sidebar.is-focused .brm-vendedores-card.two-actions:has(.brm-overlay--left:hover) .brm-overlay--right,
.territorios-sidebar.is-focused .brm-vendedores-card.two-actions:has(.brm-overlay--right:hover) .brm-overlay--left {
  opacity: 0 !important;
  transition: opacity var(--dur) var(--ease)
}

/* Single-action (centrado) */
.territorios-sidebar.is-focused .single-action .brm-overlay {
  clip-path: none !important;
  opacity: 0;
  display: grid !important;
  place-items: center !important;
  padding-inline: 14px !important
}

.territorios-sidebar.is-focused .single-action .brm-overlay span {
  justify-self: center !important;
  text-align: center !important
}

.territorios-sidebar.is-focused .brm-vendedores-card .brm-overlay:only-child {
  clip-path: none !important;
  display: grid !important;
  place-items: center !important;
  padding-inline: 14px !important
}

.territorios-sidebar.is-focused .brm-vendedores-card .brm-overlay:only-child span {
  justify-self: center !important;
  text-align: center !important
}

.territorios-sidebar.is-focused .single-action .brm-overlay--left,
.territorios-sidebar.is-focused .single-action .brm-overlay--right {
  justify-items: center !important
}

.territorios-sidebar.is-focused .single-action .brm-overlay--left span,
.territorios-sidebar.is-focused .single-action .brm-overlay--right span {
  justify-self: center !important;
  text-align: center !important
}

.territorios-sidebar.is-focused .single-action .brm-vendedores-card:hover .brm-overlay,
.territorios-sidebar.is-focused .single-action .brm-vendedores-card:focus-visible .brm-overlay {
  opacity: .94
}

.territorios-sidebar.is-focused .single-action--map .brm-overlay--left {
  background: color-mix(in oklab, var(--diag-left) 80%, transparent)
}

.territorios-sidebar.is-focused .single-action--ficha .brm-overlay--right {
  background: color-mix(in oklab, var(--diag-right) 80%, transparent)
}

/* Accesibilidad foco */
.territorios-sidebar.is-focused a.brm-vendedores-card:focus-visible {
  outline: 2px solid color-mix(in oklab, #748573 60%, #fff);
  outline-offset: 2px
}

/* Respeto movimiento */
@media (prefers-reduced-motion:reduce) {

  .territorios-sidebar.is-focused .brm-vendedores-card::before,
  .territorios-sidebar.is-focused .brm-overlay {
    transition: none
  }
}

/* ====== Leaflet: popup sin límite + sin padding ====== */
.leaflet-popup.lp .leaflet-popup-content-wrapper {
  border-radius: 24px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .22);
  border: 1px solid rgba(0, 0, 0, .06)
}

.leaflet-popup.lp .leaflet-popup-content {
  margin: 0 !important;
  width: auto !important
}

/* ====== Card-8 (compacto) ====== */
.lp-card8 {
  --c-text: #f9f9f9;
  --c-muted: #d6d6d6;
  --c-pill-text: #2b2d29;
  --c-pill-bg: #fff;
  position: relative;
  display: block;
  background: #fff;
  border-radius: 36px;
  padding: 8px;
  width: min(92vw, 720px);
  box-shadow: 0 20px 50px rgb(0 0 0 / 8%);
  font-family: inherit
}

.lp-card8__img {
  position: absolute;
  inset: 8px;
  width: calc(100% - 16px);
  height: calc(100% - 16px);
  object-fit: cover;
  object-position: center;
  border-radius: 28px;
  display: block
}

.lp-card8__content {
  position: relative;
  z-index: 1;
  padding: 200px 24px 24px;
  border-radius: inherit;
  color: var(--c-text);
  background: linear-gradient(rgb(0 0 0 / 0%) 0%, rgb(0 0 0 / 50%) 50%)
}

.lp-card8__title {
  margin: 0 0 6px;
  font-weight: 600;
  font-size: 24px;
  letter-spacing: .01em
}

.lp-card8__subtitle {
  margin: 0 0 16px;
  font-weight: 400;
  font-size: 16px;
  color: var(--c-muted)
}

.lp-card8__desc {
  margin: 0 0 18px;
  color: var(--c-muted);
  font-size: 14px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.lp-card8__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 24px;
  border: 0;
  border-radius: 32px;
  background: var(--c-pill-bg);
  color: var(--c-pill-text) !important;
  text-decoration: none;
  font-weight: 600;
  font-size: 15px
}

.lp-card8.is-noimg .lp-card8__content {
  background: transparent;
  color: #2b2d29;
  padding: 20px
}

.lp-card8.is-noimg .lp-card8__subtitle, .lp-card8.is-noimg .lp-card8__desc {
  color: #6d6d6d
}

/* ===== Popup vertical (fondo blanco + media wrapper) ===== */
.lpv-card {
  position: relative;
  width: clamp(260px, 70vw, 360px);
  height: clamp(300px, 75vw, 420px);
  border-radius: 20px;
  padding: 8px;
  background: #fff;
  box-shadow: 0 20px 50px rgb(0 0 0 / 8%);
  color: #fff;
  overflow: hidden
}

.lpv-media {
  position: absolute;
  top: 8px;
  right: 8px;
  bottom: 8px;
  left: 8px;
  border-radius: 14px;
  overflow: hidden
}

.leaflet-popup.lp .lpv-media>img.lpv-img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  object-fit: cover;
  object-position: center;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important
}

.lpv-card::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  bottom: 8px;
  left: 8px;
  border-radius: 14px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, .18) 0%, rgba(0, 0, 0, .55) 55%, rgba(0, 0, 0, .72) 100%)
}

.lpv-content {
  position: absolute;
  top: 8px;
  right: 8px;
  bottom: 8px;
  left: 8px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 20px;
  z-index: 1;
  color: #fff;
  border-radius: 14px
}

.lpv-title {
  margin: 0 0 6px;
  font-weight: 600;
  font-size: clamp(16px, 2.6vw, 20px);
  letter-spacing: .01em;
  color: #fff
}

.lpv-subtitle {
  margin: 0 0 10px;
  font-weight: 400;
  font-size: clamp(12px, 2.2vw, 14px);
  color: #e2e2e2
}

.lpv-desc {
  margin: 0 0 14px;
  color: #d6d6d6;
  font-size: clamp(12px, 2.2vw, 14px);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

.lpv-btn {
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: clamp(38px, 6vw, 46px);
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: #c6b194;
  color: #fff !important;
  text-decoration: none;
  font-weight: 600;
  font-size: clamp(13px, 2.4vw, 15px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .16);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease, background-color .15s ease
}

.lpv-btn:hover {
  background: color-mix(in oklab, #c6b194 88%, #000);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(0, 0, 0, .22);
  filter: saturate(1.05)
}

.lpv-btn:active {
  transform: translateY(0);
  box-shadow: 0 6px 16px rgba(0, 0, 0, .16)
}

/* Close button (cruz roja) */
.leaflet-popup.lp .leaflet-popup-close-button {
  top: 10px !important;
  right: 10px !important;
  width: 36px;
  height: 36px;
  padding: 0 !important;
  border: none;
  background: transparent;
  color: #e53935;
  font-weight: 700;
  font-size: 26px;
  line-height: 36px;
  text-align: center;
  opacity: 1;
  transition: transform .12s ease, color .12s ease, text-shadow .12s ease;
  z-index: 3
}

.leaflet-popup.lp .leaflet-popup-close-button:hover {
  color: #b71c1c;
  transform: scale(1.06);
  text-shadow: 0 2px 6px rgba(0, 0, 0, .25)
}