@font-face {
  font-family: "Archivo";
  src: url("./assets/fonts/Archivo-Regular.ttf") format("truetype");
  font-weight: 400;
}

@font-face {
  font-family: "Archivo";
  src: url("./assets/fonts/Archivo-SemiBold.ttf") format("truetype");
  font-weight: 600;
}

@font-face {
  font-family: "Archivo";
  src: url("./assets/fonts/Archivo-Bold.ttf") format("truetype");
  font-weight: 700;
}

:root {
  --gcba-blue-dark: #1d3343;
  --gcba-blue: #035c80;
  --gcba-yellow: #ffcd02;
  --ink: #17212b;
  --muted: #5d6874;
  --line: #dbe3e8;
  --surface: #ffffff;
  --soft: #f4f7f9;
  --danger: #b42318;
  --shadow: 0 14px 40px rgba(29, 51, 67, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell {
  height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  font-family: "Archivo", Arial, sans-serif;
  background: var(--soft);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 430px) 1fr;
  min-height: 100vh;
}

.sidebar {
  z-index: 500;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 4px 0 30px rgba(29, 51, 67, 0.08);
}

.brand-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 80px;
  padding: 12px 22px 8px;
  border-bottom: 4px solid var(--gcba-yellow);
}

.brand-bar img:first-child {
  width: min(278px, calc(100% - 122px));
  height: auto;
}

.brand-bar img:last-child {
  width: 104px;
  height: auto;
  flex: 0 0 auto;
}

.title-block {
  padding: 20px 22px 12px;
}

.title-block p {
  margin: 0 0 6px;
  color: var(--gcba-blue);
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: uppercase;
}

.title-block h1 {
  margin: 0;
  color: var(--gcba-blue-dark);
  font-size: 1.55rem;
  line-height: 1.12;
}

.metrics {
  display: grid;
  grid-template-columns: minmax(68px, 0.54fr) minmax(190px, 1.66fr) minmax(128px, 1.05fr);
  gap: 1px;
  margin: 0 22px 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.metrics div {
  min-width: 0;
  padding: 12px 10px;
  background: #f9fbfc;
}

.metrics span {
  display: block;
  color: var(--gcba-blue-dark);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
}

.metrics small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
}

.filters {
  padding: 0 22px 14px;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--gcba-blue-dark);
  font-size: 0.76rem;
  font-weight: 700;
}

.search-box {
  display: grid;
  grid-template-columns: 1fr 38px;
  border: 1px solid #b9c8d1;
  border-radius: 8px;
  background: #fff;
}

.search-box:focus-within {
  border-color: var(--gcba-blue);
  box-shadow: 0 0 0 3px rgba(3, 92, 128, 0.12);
}

input,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid #b9c8d1;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input {
  height: 42px;
  padding: 0 12px;
  border: 0;
  background: transparent;
}

select {
  height: 40px;
  padding: 0 10px;
}

select:focus {
  border-color: var(--gcba-blue);
  box-shadow: 0 0 0 3px rgba(3, 92, 128, 0.12);
}

#clear-search,
#close-detail {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.results-head strong {
  color: var(--gcba-blue-dark);
  font-size: 0.92rem;
}

.results-head button {
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--gcba-blue);
  border-radius: 7px;
  background: #fff;
  color: var(--gcba-blue);
  font-weight: 700;
}

.results {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  list-style: none;
}

.results::-webkit-scrollbar {
  width: 10px;
}

.results::-webkit-scrollbar-track {
  background: #eef3f6;
}

.results::-webkit-scrollbar-thumb {
  border: 2px solid #eef3f6;
  border-radius: 999px;
  background: #9fb4c0;
}

.results::-webkit-scrollbar-thumb:hover {
  background: var(--gcba-blue);
}

.result-item {
  border-bottom: 1px solid var(--line);
}

.result-item button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  width: 100%;
  padding: 14px 22px;
  border: 0;
  background: #fff;
  color: inherit;
  text-align: left;
}

.result-item button:hover,
.result-item button:focus {
  background: #f6fafc;
  outline: none;
}

.result-item.active button {
  background: #eef7fb;
  box-shadow: inset 4px 0 0 var(--gcba-blue);
}

.result-title {
  overflow: hidden;
  color: var(--gcba-blue-dark);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-amount {
  color: var(--gcba-blue);
  font-weight: 700;
  white-space: nowrap;
}

.result-meta {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.map-panel {
  position: relative;
  min-width: 0;
}

#map {
  position: absolute;
  inset: 0;
}

.map-credit-logo {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 540;
  display: block;
  width: 118px;
  max-width: 28vw;
  pointer-events: auto;
}

.map-credit-logo img {
  display: block;
  width: 100%;
  height: auto;
}

.investment-legend {
  position: absolute;
  right: 12px;
  bottom: 28px;
  z-index: 540;
  display: grid;
  gap: 5px;
  width: 188px;
  padding: 9px 10px;
  border: 1px solid rgba(219, 227, 232, 0.95);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 22px rgba(29, 51, 67, 0.14);
  color: var(--gcba-blue-dark);
  font-family: "Archivo", Arial, sans-serif;
}

.investment-legend strong {
  font-size: 0.76rem;
  line-height: 1;
}

.investment-legend span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1.15;
}

.investment-legend i {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--investment-color, var(--gcba-blue));
  box-shadow: 0 0 0 1px rgba(29, 51, 67, 0.14);
}

.investment-range-filter {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 545;
  width: min(560px, calc(100% - 360px));
  min-width: 320px;
  padding: 0 12px;
  transform: translateX(-50%);
  color: var(--gcba-blue-dark);
  font-family: "Archivo", Arial, sans-serif;
  pointer-events: auto;
}

.investment-range-values {
  position: relative;
  height: 27px;
}

.investment-range-values span {
  position: absolute;
  left: var(--value-pos, 0%);
  bottom: 4px;
  min-width: 98px;
  padding: 5px 10px;
  border: 1px solid rgba(29, 51, 67, 0.12);
  border-radius: 7px;
  background: linear-gradient(180deg, #fff7cf 0%, var(--gcba-yellow) 100%);
  box-shadow: 0 5px 12px rgba(29, 51, 67, 0.14);
  color: var(--gcba-blue-dark);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  transform: translateX(-50%);
  white-space: nowrap;
}

.investment-slider {
  position: relative;
  height: 26px;
  --min-pos: 0%;
  --max-pos: 100%;
}

.investment-slider-track {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 10px;
  border-radius: 999px;
  background:
    linear-gradient(
      to right,
      #dcebf1 0%,
      #dcebf1 var(--min-pos),
      var(--gcba-blue) var(--min-pos),
      var(--gcba-blue) var(--max-pos),
      #dcebf1 var(--max-pos),
      #dcebf1 100%
    );
  box-shadow: inset 0 0 0 1px rgba(3, 92, 128, 0.12), 0 4px 10px rgba(29, 51, 67, 0.16);
  transform: translateY(-50%);
}

.investment-slider input[type="range"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 26px;
  margin: 0;
  background: transparent;
  pointer-events: none;
  appearance: none;
}

.investment-slider input[type="range"]::-webkit-slider-thumb {
  width: 26px;
  height: 26px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--gcba-blue-dark);
  box-shadow: 0 3px 10px rgba(29, 51, 67, 0.24);
  cursor: pointer;
  pointer-events: auto;
  appearance: none;
}

.investment-slider input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--gcba-blue-dark);
  box-shadow: 0 3px 10px rgba(29, 51, 67, 0.24);
  cursor: pointer;
  pointer-events: auto;
}

.investment-slider input[type="range"]::-webkit-slider-runnable-track,
.investment-slider input[type="range"]::-moz-range-track {
  background: transparent;
}

.investment-range-caption {
  display: inline-block;
  margin-top: 0;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--gcba-blue);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.detail-panel {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 550;
  width: min(430px, calc(100% - 36px));
  max-height: calc(100% - 36px);
  overflow: hidden;
  border: 1px solid rgba(29, 51, 67, 0.16);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.detail-panel:not(.active) {
  width: min(340px, calc(100% - 36px));
  max-height: 92px;
  pointer-events: auto;
}

.detail-panel.is-hidden {
  display: none;
}

.detail-panel.active {
  position: fixed;
  top: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 1200;
  max-height: calc(100vh - 36px);
  pointer-events: auto;
  border-color: rgba(3, 92, 128, 0.45);
  box-shadow: 0 0 0 3px rgba(255, 205, 2, 0.45), var(--shadow);
}

#close-detail {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  width: 28px;
  height: 28px;
}

.detail-content {
  max-height: inherit;
  padding: 15px 42px 15px 16px;
  overflow: auto;
}

.empty-detail {
  margin: 0;
  padding-right: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.detail-kicker {
  margin: 0 36px 8px 0;
  color: var(--gcba-blue);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.detail-content h2 {
  margin: 0 34px 10px 0;
  color: var(--gcba-blue-dark);
  font-size: 1.25rem;
  line-height: 1.18;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef5f8;
  color: var(--gcba-blue-dark);
  font-size: 0.76rem;
  font-weight: 700;
}

.tag.yellow {
  background: rgba(255, 205, 2, 0.3);
}

.detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.detail-stats div {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.detail-stats strong {
  display: block;
  color: var(--gcba-blue-dark);
  font-size: 1rem;
}

.detail-stats span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.74rem;
}

.fields {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.field {
  display: grid;
  grid-template-columns: 38% 1fr;
  gap: 12px;
  padding: 10px 12px;
  background: #fff;
}

.field dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.field dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.86rem;
}

.cluster-help {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.cluster-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cluster-list button {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: inherit;
  text-align: left;
}

.cluster-list button:hover,
.cluster-list button:focus {
  border-color: var(--gcba-blue);
  background: #f6fafc;
  outline: none;
}

.cluster-list strong {
  overflow: hidden;
  color: var(--gcba-blue-dark);
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cluster-list span {
  color: var(--muted);
  font-size: 0.78rem;
}

.marker-pin {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 3px solid #fff;
  border-radius: 50% 50% 50% 4px;
  background: var(--investment-color, var(--gcba-blue));
  box-shadow: 0 5px 14px rgba(29, 51, 67, 0.32);
  transform: rotate(-45deg);
}

.investment-tier-1 {
  --investment-color: #2f9e6d;
  --investment-shadow: rgba(47, 158, 109, 0.26);
}

.investment-tier-2 {
  --investment-color: #0396a6;
  --investment-shadow: rgba(3, 150, 166, 0.26);
}

.investment-tier-3 {
  --investment-color: #0570b0;
  --investment-shadow: rgba(5, 112, 176, 0.28);
}

.investment-tier-4 {
  --investment-color: #f2b705;
  --investment-shadow: rgba(242, 183, 5, 0.32);
}

.investment-tier-5 {
  --investment-color: #f47c20;
  --investment-shadow: rgba(244, 124, 32, 0.3);
}

.investment-tier-6 {
  --investment-color: #d9480f;
  --investment-shadow: rgba(217, 72, 15, 0.3);
}

.investment-tier-7 {
  --investment-color: #b42318;
  --investment-shadow: rgba(180, 35, 24, 0.3);
}

.investment-tier-8 {
  --investment-color: #7f1d1d;
  --investment-shadow: rgba(127, 29, 29, 0.32);
}

.marker-hover-card {
  position: absolute;
  bottom: 86px;
  left: 50%;
  z-index: 2;
  display: grid;
  width: 300px;
  gap: 7px;
  padding: 8px;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(29, 51, 67, 0.2);
  color: var(--gcba-blue-dark);
  font-family: "Archivo", Arial, sans-serif;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) rotate(45deg) translateY(8px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.map-hover-tooltip {
  position: fixed;
  z-index: 1300;
  display: grid;
  width: 300px;
  gap: 8px;
  padding: 8px;
  border-radius: 7px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(29, 51, 67, 0.2);
  color: var(--gcba-blue-dark);
  font-family: "Archivo", Arial, sans-serif;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.map-hover-tooltip.visible {
  opacity: 1;
}

.marker-hover-card.rich {
  gap: 8px;
}

.marker-pin:hover .marker-hover-card {
  opacity: 1;
  transform: translateX(-50%) rotate(45deg) translateY(4px);
}

.marker-hover-card img,
.map-hover-tooltip img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 5px;
  object-fit: cover;
  background: #e8eef2;
}

.marker-hover-card.image-error img,
.map-hover-tooltip.image-error img {
  display: none;
}

.marker-hover-card strong,
.map-hover-tooltip strong {
  overflow: hidden;
  color: var(--gcba-blue-dark);
  font-size: 0.88rem;
  line-height: 1.2;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hover-expediente {
  color: var(--gcba-blue);
  font-size: 0.72rem;
  font-weight: 700;
}

.hover-source {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
}

.streetview-error {
  display: none;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.25;
}

.streetview-error.visible {
  display: block;
}

.marker-hover-card.image-error .streetview-error,
.map-hover-tooltip.image-error .streetview-error {
  display: block;
}

.marker-hover-card dl,
.map-hover-tooltip dl {
  display: grid;
  gap: 1px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--line);
}

.marker-hover-card dl div,
.map-hover-tooltip dl div {
  display: grid;
  grid-template-columns: 38% 1fr;
  gap: 8px;
  padding: 7px 8px;
  background: #fff;
}

.marker-hover-card dt,
.map-hover-tooltip dt {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
}

.marker-hover-card dd,
.map-hover-tooltip dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 600;
}

.marker-pin::after {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gcba-yellow);
  content: "";
}

.marker-pin.selected {
  background: var(--gcba-yellow);
}

.marker-pin.selected::after {
  background: var(--gcba-blue-dark);
}

.investment-cluster {
  display: grid;
  width: 44px !important;
  height: 44px !important;
  margin-left: -22px !important;
  margin-top: -22px !important;
  place-items: center;
  border-radius: 999px;
  background-color: var(--investment-shadow, rgba(3, 92, 128, 0.22));
}

.investment-cluster span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 999px;
  background-color: var(--investment-color, var(--gcba-blue));
  color: #fff;
  font-size: 0.84rem;
  font-weight: 700;
  box-shadow: 0 5px 14px rgba(29, 51, 67, 0.24);
}

.leaflet-control-layers,
.leaflet-control-zoom a {
  border: 0 !important;
  font-family: "Archivo", Arial, sans-serif;
}

.detail-streetview-link {
  display: inline-flex;
  margin: 0 0 14px;
  padding: 9px 11px;
  border: 1px solid var(--gcba-blue);
  border-radius: 7px;
  background: #fff;
  color: var(--gcba-blue);
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
}

.detail-streetview-link:hover {
  background: #f6fafc;
  text-decoration: underline;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 48vh 52vh;
  }

  .sidebar {
    grid-row: 2;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .map-panel {
    grid-row: 1;
  }

  .brand-bar {
    padding: 12px 16px 10px;
  }

  .brand-bar img:first-child {
    max-width: 190px;
  }

  .title-block,
  .filters,
  .results-head {
    padding-left: 16px;
    padding-right: 16px;
  }

  .metrics {
    margin-left: 16px;
    margin-right: 16px;
  }

  .result-item button {
    padding-left: 16px;
    padding-right: 16px;
  }

  .detail-panel {
    right: 10px;
    bottom: 10px;
    width: calc(100% - 20px);
    max-height: 78%;
  }

  .investment-range-filter {
    bottom: 8px;
    width: min(430px, calc(100% - 110px));
    min-width: 240px;
    padding: 0 8px;
  }

  .investment-range-values span {
    min-width: 78px;
    padding: 4px 8px;
    font-size: 0.72rem;
  }

  .detail-panel.active {
    top: 10px;
    right: 10px;
    bottom: 10px;
    width: calc(100% - 20px);
    max-height: calc(100vh - 20px);
  }
}

@media (max-width: 520px) {
  .filter-grid,
  .detail-stats,
  .field {
    grid-template-columns: 1fr;
  }

  .metrics span {
    font-size: 0.88rem;
  }

  .investment-range-filter {
    width: calc(100% - 88px);
    min-width: 0;
  }

  .investment-range-caption {
    display: none;
  }
}
