:root {
  --site-bg: #0B3A66;
  --site-bg-dark: #082B4D;
  --site-accent: #1E88E5;
  --site-accent-soft: rgba(30, 136, 229, 0.16);
  --site-button: #1976D2;
  --site-button-hover: #0D47A1;
}


/* GEOX SITE BRANDING */
#main-header,
.site-header,
.header,
.app-header {
  background: linear-gradient(135deg, var(--site-bg-dark), var(--site-bg));
  border-bottom-color: var(--site-accent);
}

.summary-item,
.site-kpi,
.kpi-card,
.summary-card {
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

#site-title,
.site-title,
.header-title,
h1 {
  color: #ffffff;
}

#site-subtitle,
#site-description,
.site-subtitle,
.header-subtitle,
.site-description,
.header-description {
  color: rgba(255, 255, 255, 0.88);
}

#btn-search,
button.primary,
.btn-primary,
.search-button,
#searchBtn,
.buscar-btn {
  background: var(--site-button);
  color: #ffffff;
  border-color: var(--site-button);
}

#btn-search:hover,
button.primary:hover,
.btn-primary:hover,
.search-button:hover,
#searchBtn:hover,
.buscar-btn:hover {
  background: var(--site-button-hover);
  border-color: var(--site-button-hover);
}

#main-footer,
.portal-footer,
.footer,
.bottom-nav,
.geox-footer {
  background: var(--site-bg-dark);
  border-top: 1px solid var(--site-accent);
}

#main-footer a:hover,
.portal-footer a:hover,
.bottom-nav a:hover,
.geox-footer a:hover {
  color: var(--site-accent);
}

#territorial-panel h3,
#territorial-panel strong,
.panel-territorial strong,
.panel-title,
.layer-group-title {
  color: var(--site-bg);
}

input[type="checkbox"]:checked {
  accent-color: var(--site-accent);
}

.is-active,
.active,
.selected,
.portal-link.active {
  color: var(--site-accent);
}

.badge,
.site-badge,
.layer-badge {
  background: var(--site-accent-soft);
  color: var(--site-bg);
}

.home-link,
.geox-button,
#geoxBtn,
.btn-geox {
  border-color: var(--site-accent);
  color: var(--site-bg);
}

.home-link:hover {
  background: var(--site-accent-soft);
  color: var(--site-bg);
}

.mobile-layer-toggle.is-active,
#mobile-layer-toggle.is-active {
  border-color: var(--site-accent);
  background: var(--site-accent-soft);
  color: var(--site-bg);
}

.toggle-row input {
  accent-color: var(--site-accent);
}

.search-result-item:hover,
.search-result-item:focus {
  background: var(--site-accent-soft);
}

.geoipt-intro-button {
  background: var(--site-button);
}

.geoipt-intro-button:hover {
  background: var(--site-button-hover);
}

.panel-layer-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.panel-layer-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #1f2933;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.panel-layer-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--site-accent);
}

.panel-layer-toggle input:disabled {
  cursor: wait;
  opacity: 0.55;
}

.eva-project-label {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #1f2933;
  font-size: var(--geox-label-font-size, 15.118px);
  font-weight: 600;
  padding: 0 !important;
  pointer-events: none;
  text-shadow:
    0 1px 2px rgba(255,255,255,0.9),
    0 -1px 2px rgba(255,255,255,0.9),
    1px 0 2px rgba(255,255,255,0.9),
    -1px 0 2px rgba(255,255,255,0.9);
}

.eva-project-label::before {
  display: none !important;
}

#territorial-panel {
  width: auto;
  min-width: 180px;
  padding: 12px 14px;
}

#territorial-panel .panel-layer-controls {
  margin-top: 0;
}

/* Panel Territorial limpio: bajo el zoom nativo Leaflet y sin badge flotante. */
.leaflet-top.leaflet-left,
.leaflet-control-zoom {
  z-index: 1100;
}

#territorial-panel,
.territorial-panel,
.floating-panel {
  top: 70px;
  left: 20px;
  z-index: 1000;
}

#territorial-panel h3 {
  margin: 0 0 10px 0;
  color: var(--site-bg);
  font-size: 16px;
  line-height: 1.2;
}

.mobile-layer-toggle,
#mobile-layer-toggle,
#map-hint {
  display: none !important;
}

#territorial-panel .panel-layer-controls {
  margin-top: 0;
}

/* GEOX STANDARD TERRITORIAL PANEL */
.leaflet-top.leaflet-left,
.leaflet-control-zoom {
  z-index: 1100;
}

#territorial-panel,
.territorial-panel,
.floating-panel {
  position: absolute;
  top: 78px;
  left: 20px;
  z-index: 1000;
  width: 320px;
  min-width: 0;
  max-width: calc(100% - 40px);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 20px;
  padding: 18px 20px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
  overflow-y: visible;
}

#territorial-panel h2,
#territorial-panel h3,
#panel-title {
  margin: 0 0 14px 0;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
  color: #1f2933;
}

.panel-toggle-list,
#territorial-panel .panel-layer-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
}

.panel-toggle-row,
.panel-layer-toggle,
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  color: #1f2933;
  cursor: pointer;
}

.panel-toggle-row input,
.panel-layer-toggle input,
.toggle-row input {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.badge,
.site-badge,
.layer-badge,
.mobile-layer-toggle,
#mobile-layer-toggle,
#map-hint {
  display: none !important;
}

@media (max-width: 768px) {
  #territorial-panel,
  .territorial-panel,
  .floating-panel {
    display: block;
    top: 118px;
    left: 12px;
    width: min(320px, calc(100% - 24px));
    max-width: calc(100% - 24px);
    padding: 16px 18px;
  }
}

/* GEOX STANDARD LABEL CONTROL */
html,
body,
#app {
  max-width: 100%;
  overflow-x: hidden;
}

#main-header {
  min-width: 0;
}

#summary-bar {
  min-width: 0;
  flex-wrap: wrap;
  align-items: stretch;
}

#territorial-panel,
.territorial-panel,
.floating-panel {
  position: absolute;
  top: 78px;
  left: 20px;
  z-index: 1000;
  width: auto;
  min-width: 210px;
  max-width: min(320px, calc(100% - 40px));
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.12);
  overflow: visible;
}

#territorial-panel h2,
#territorial-panel h3,
#panel-title {
  margin: 0 0 10px 0;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
  color: #1f2933;
}

#territorial-panel .panel-section,
#territorial-panel .panel-territorial-control {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.panel-toggle-list,
#territorial-panel .panel-layer-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}

.panel-toggle-row,
.panel-layer-toggle,
.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #1f2933;
  cursor: pointer;
}

.panel-toggle-row input,
.panel-layer-toggle input,
.toggle-row input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.mobile-layer-toggle,
#mobile-layer-toggle,
#map-hint {
  display: none !important;
}

@media (max-width: 768px) {
  .leaflet-control-zoom {
    display: none !important;
  }

  #main-header {
    grid-template-columns: minmax(0, 1fr);
    padding: 8px 10px;
    gap: 8px;
  }

  #site-title {
    font-size: 21px;
  }

  #site-subtitle,
  #site-description {
    font-size: 11px;
  }

  #summary-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
    width: 100%;
    gap: 5px;
    justify-content: stretch;
    overflow: visible;
  }

  .summary-item,
  .site-kpi,
  .kpi-card,
  .summary-card {
    min-width: 0;
    padding: 5px 4px;
    border-radius: 8px;
  }

  .summary-value,
  .kpi-value {
    font-size: 14px;
    line-height: 1.1;
    overflow-wrap: anywhere;
  }

  .summary-label,
  .kpi-label {
    font-size: 9px;
    line-height: 1.1;
  }

  #control-bar {
    max-width: 100%;
    overflow-x: auto;
  }

  #search-box-wrapper {
    top: 10px;
    left: 10px;
    right: 118px;
    width: auto;
    min-width: 0;
    transform: none;
  }

  .map-toggle,
  #mobile-map-controls .map-toggle {
    top: 60px;
    right: 10px;
  }

  #btn-my-location,
  #mobile-map-controls #btn-my-location {
    top: 106px;
    right: 10px;
    width: 38px;
    height: 38px;
  }

  #territorial-panel,
  .territorial-panel,
  .floating-panel {
    display: block !important;
    top: 110px;
    left: 10px;
    width: auto;
    min-width: 0;
    max-width: min(250px, calc(100% - 70px));
    padding: 10px 12px;
    border-radius: 14px;
  }

  #territorial-panel h2,
  #territorial-panel h3,
  #panel-title {
    margin-bottom: 7px;
    font-size: 14px;
  }

  .panel-toggle-row,
  .panel-layer-toggle,
  .toggle-row {
    gap: 7px;
    font-size: 12px;
  }

  .panel-toggle-row input,
  .panel-layer-toggle input,
  .toggle-row input {
    width: 15px;
    height: 15px;
  }
}

/* GEOX MOBILE LABEL STANDARD */
.mobile-layer-toggle,
#mobile-layer-toggle {
  display: none;
}

@media (max-width: 768px) {
  .leaflet-control-zoom {
    display: none !important;
  }

  #main-header {
    grid-template-columns: minmax(0, 1fr);
    padding: 7px 9px;
    gap: 6px;
    min-width: 0;
  }

  #site-title { font-size: 20px; line-height: 1.1; }
  #site-subtitle,
  #site-description { font-size: 10px; line-height: 1.15; }

  #summary-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
    width: 100%;
    gap: 4px;
    justify-content: stretch;
    overflow: visible;
    min-width: 0;
  }

  .summary-item,
  .site-kpi,
  .kpi-card,
  .summary-card {
    min-width: 0;
    padding: 4px 3px;
    border-radius: 7px;
  }

  .summary-value,
  .kpi-value { font-size: 12px; line-height: 1.05; overflow-wrap: anywhere; }
  .summary-label,
  .kpi-label { font-size: 8px; line-height: 1.05; }

  #search-box-wrapper {
    top: 10px;
    left: 10px;
    right: 10px;
    width: auto;
    min-width: 0;
    transform: none;
  }

  #search-box-wrapper #search-box,
  #search-box {
    height: 40px;
    border-radius: 14px;
    padding: 0 12px;
    font-size: 13px;
    text-overflow: ellipsis;
  }

  #territorial-panel,
  .territorial-panel,
  .floating-panel { display: none !important; }

  .map-toggle,
  #mobile-map-controls .map-toggle {
    top: auto !important;
    right: 10px !important;
    bottom: 16px !important;
    z-index: 1500;
  }

  #btn-my-location,
  #mobile-map-controls #btn-my-location {
    top: 60px !important;
    right: 10px !important;
    width: 38px;
    height: 38px;
  }

  .mobile-layer-toggle,
  #mobile-layer-toggle {
    position: absolute;
    top: 108px !important;
    right: 10px !important;
    left: auto !important;
    z-index: 1600;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    min-width: 42px;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    background: #ffffff;
    color: #334155;
    font-size: 20px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
  }

  .mobile-layer-toggle-text { display: none !important; }
}


/* Mobile map control refinements: master label eye + separated base-map toggle. */
.mobile-layer-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  line-height: 0;
}

.mobile-layer-toggle-svg {
  display: block;
  width: 22px;
  height: 22px;
}

@media (max-width: 768px) {
  #territorial-panel,
  .territorial-panel,
  .floating-panel,
  #territorial-panel .panel-layer-controls,
  #territorial-panel .panel-toggle-list {
    display: none !important;
  }

  .leaflet-control-zoom {
    display: none !important;
  }

  .map-toggle,
  #mobile-map-controls .map-toggle {
    top: auto !important;
    right: max(12px, env(safe-area-inset-right)) !important;
    bottom: max(58px, calc(env(safe-area-inset-bottom) + 42px)) !important;
    z-index: 1700 !important;
    padding: 5px !important;
    background: rgba(15, 23, 42, 0.86) !important;
    border: 1px solid rgba(255, 255, 255, 0.72) !important;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.32) !important;
  }

  .map-toggle-btn {
    min-width: 44px;
    min-height: 34px;
    font-weight: 800;
  }

  #btn-my-location,
  #mobile-map-controls #btn-my-location,
  .mobile-layer-toggle,
  #mobile-layer-toggle {
    right: max(12px, env(safe-area-inset-right)) !important;
    left: auto !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 14px !important;
    background: #ffffff !important;
    color: #1e293b !important;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.2) !important;
  }

  #btn-my-location,
  #mobile-map-controls #btn-my-location {
    top: 64px !important;
    z-index: 1700 !important;
  }

  .mobile-layer-toggle,
  #mobile-layer-toggle {
    top: 116px !important;
    z-index: 1700 !important;
    padding: 0 !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .mobile-layer-toggle.is-active,
  #mobile-layer-toggle.is-active,
  .mobile-layer-toggle.is-inactive,
  #mobile-layer-toggle.is-inactive {
    background: #ffffff !important;
    color: #1e293b !important;
  }

  .mobile-layer-toggle-text {
    display: none !important;
  }
}

/* Mobile Cross Access visibility guard: keep the GeoX links reserved above the map. */
@media (max-width: 768px) {
  :root {
    --mobile-crossbar-height: 40px;
    --mobile-crossbar-gap: 12px;
  }

  html,
  body,
  #app {
    min-height: 100%;
    overflow-x: hidden;
  }

  #app {
    height: 100%;
  }

  #main-layout {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  #map-container {
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: calc(100dvh - var(--mobile-crossbar-height)) !important;
    overflow: hidden !important;
  }

  #map {
    inset: 0 0 0 0 !important;
  }

  #main-footer,
  .portal-footer,
  .footer,
  .bottom-nav,
  .geox-footer {
    position: sticky !important;
    bottom: env(safe-area-inset-bottom) !important;
    z-index: 2600 !important;
    flex: 0 0 var(--mobile-crossbar-height) !important;
    width: 100% !important;
    min-height: var(--mobile-crossbar-height) !important;
    height: var(--mobile-crossbar-height) !important;
    padding: 0 max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    font-size: 12px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    box-shadow: 0 -8px 22px rgba(15, 23, 42, 0.22) !important;
  }

  #main-footer a,
  .portal-footer a,
  .bottom-nav a,
  .geox-footer a {
    flex: 0 1 auto !important;
    min-width: 0 !important;
    padding: 0 2px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .map-toggle,
  #mobile-map-controls .map-toggle {
    top: auto !important;
    right: max(12px, env(safe-area-inset-right)) !important;
    bottom: calc(var(--mobile-crossbar-height) + var(--mobile-crossbar-gap)) !important;
    z-index: 1700 !important;
  }

  .leaflet-control-attribution {
    margin-bottom: calc(var(--mobile-crossbar-height) + 4px) !important;
    max-width: calc(100vw - 130px) !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
}

#search-results {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 2600;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.18);
}

#search-results.is-open {
  display: block;
}

.search-result-item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  color: #102a43;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
