.branch-hero { padding-block: clamp(3.3rem, 5.65vw, 5.2rem) clamp(5.9rem, 8vw, 7.5rem); }

.branch-map {
  position: relative;
  margin-top: clamp(-4.15rem, -4.3vw, -2.75rem);
  scroll-margin-top: 105px;
}

.branch-map-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.78fr) minmax(290px, 1fr);
  align-items: stretch;
  border: 1px solid #284e3a;
  border-radius: .85rem;
  overflow: hidden;
  box-shadow: 0 22px 48px #0b30242a;
}

.branch-map-figure {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  min-width: 0;
  background: #0b271e;
  color: #f2f8eb;
}

.map-top {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .8rem;
  padding: 1.4rem 1.5rem 1rem;
}

.map-top h2 { font-size: clamp(1.26rem, 2.4vw, 1.85rem); letter-spacing: -.045em; }

.map-views {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}

.map-views button {
  min-height: 44px;
  border: 1px solid #537664;
  border-radius: .4rem;
  padding: .35rem .65rem;
  color: #d6e6d9;
  background: transparent;
  font-size: .875rem;
  font-weight: 660;
  line-height: 1.3;
}

.map-views button[aria-pressed="true"] { background: #d8f5a3; color: #112e21; }
.map-views button[aria-pressed="false"]:hover { background: #294b3a; }
.map-views button:focus-visible, .map-pin:focus-visible { outline-color: #d8f5a3; }

.map-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .4rem .8rem;
  padding: .65rem 1.5rem 0;
  border-top: 1px solid #3b5b4b;
}

.map-breadcrumb, .map-zoom { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem; }
.map-breadcrumb { color: #d7e8da; font-size: .875rem; }
.map-breadcrumb > :not(:first-child)::before {
  content: "";
  display: inline-block;
  width: .3rem;
  height: .3rem;
  margin: 0 .55rem .12rem .12rem;
  border-top: 1px solid #a1bca8;
  border-right: 1px solid #a1bca8;
  transform: rotate(45deg);
}
.map-breadcrumb [aria-current] { color: var(--lime); font-weight: 700; }
.map-breadcrumb button, .map-zoom button {
  min-height: 36px;
  border: 1px solid #527562;
  border-radius: .35rem;
  background: #15352a;
  color: #f2f8eb;
  padding: .2rem .55rem;
}
.map-breadcrumb button { border-color: transparent; background: transparent; padding-inline: .15rem; }
.map-zoom button { width: 36px; font-size: 1.1rem; }
.map-breadcrumb button:hover, .map-zoom button:hover { background: #294b3a; }
.map-breadcrumb button:focus-visible, .map-zoom button:focus-visible { outline-color: var(--lime); }
.map-north {
  position: absolute;
  z-index: 1;
  top: .9rem;
  right: 1.5rem;
  color: #cfe5cf;
  font: 650 .85rem/1.35 var(--font, sans-serif);
  text-align: center;
  pointer-events: none;
}

.map-canvas {
  height: clamp(375px, 46vw, 545px);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 58% 58%, #183b2f, transparent 73%),
    linear-gradient(90deg, #9fcdad0a 1px, transparent 1px),
    linear-gradient(0deg, #9fcdad0a 1px, transparent 1px);
  background-size: auto, 32px 32px, 32px 32px;
}

.map-cartography, .map-points, .map-pins { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-points, .map-pins { pointer-events: none; }
.map-cartography { overflow: hidden; }

.map-state {
  fill: url(#map-hatch);
  fill-rule: evenodd;
  stroke: #709783;
  stroke-width: .9;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.map-state.is-operating { stroke: #afd0ae; }
.map-territory[role="button"] { cursor: pointer; }
.map-territory[role="button"]:hover .map-state,
.map-territory:focus-visible .map-state { fill: #3a654d; stroke: var(--lime); stroke-width: 1.65; }
.map-state.is-selected { stroke: var(--lime); stroke-width: 2.6; }
/* The center of each visible marker coincides with its mapped municipality. */
.map-anchor { fill: #a9d7b9; opacity: 0; }
.map-anchor.is-visible.is-branch-dot { opacity: .78; }
.map-anchor.is-visible.is-selected { fill: #dcf9ab; stroke: #132f23; stroke-width: 1.2; r: 4.5; opacity: 1; }

.map-pin {
  position: absolute;
  display: grid;
  place-items: center;
  width: 40px;
  height: 42px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  color: #122b1f;
  outline-offset: 0;
  -webkit-tap-highlight-color: transparent;
}

.map-pin { pointer-events: auto; }
.map-pin-building {
  grid-area: 1 / 1;
  width: 25px;
  height: 28px;
  filter: drop-shadow(0 2px 2px #071e16);
  transition: scale .2s;
  pointer-events: none;
}
.map-pin-matrix .map-pin-building, .map-pin-territory .map-pin-building {
  width: 30px;
  height: 33px;
}
.map-pin-matrix .map-pin-building, .map-legend-matrix { filter: brightness(1.2) drop-shadow(0 0 2px #e1f5ac66); }
.map-pin:hover, .map-pin:focus-visible, .map-pin[aria-pressed="true"] { z-index: 2; }
.map-pin:hover .map-pin-building, .map-pin[aria-pressed="true"] .map-pin-building { scale: 1.12; }
.map-pin[aria-pressed="true"] .map-pin-building { filter: drop-shadow(0 0 4px #d9f3a5a0); }
.map-pin-count {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 18px;
  min-height: 18px;
  border: 1px solid #bee988;
  border-radius: 10px;
  padding: 1px 3px;
  background: #15362a;
  color: #edfbdb;
  font-size: .7rem;
  font-weight: 800;
  line-height: 14px;
}

.map-pin-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  width: max-content;
  max-width: 170px;
  padding: .3rem .5rem;
  border: 1px solid #527565;
  border-radius: .35rem;
  transform: translateX(-50%);
  background: #102f24;
  color: #f2f8eb;
  font-size: .82rem;
  font-weight: 650;
  line-height: 1.3;
  text-align: center;
  pointer-events: none;
}

@media (hover: hover) { .map-pin:hover .map-pin-tooltip { display: block; } }
.map-pin:focus-visible .map-pin-tooltip,
.map-pin[aria-pressed="true"] .map-pin-tooltip { display: block; }

.map-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .55rem 1.1rem;
  padding: .6rem 1.5rem 1.25rem;
  color: #c9e0ce;
  font-size: .875rem;
}

.map-legend span { display: inline-flex; align-items: center; gap: .36rem; }
.map-legend i { width: 10px; height: 10px; border: 1px solid #c6e6c8; border-radius: 50%; }
.map-legend-building { width: 17px; height: 18px; }
.map-legend-group { display: grid; place-items: center; width: 17px; height: 17px; border: 1px solid #bee988; border-radius: 50%; color: #edfbdb; font-size: .65rem; }
.map-legend .map-legend-state { background: repeating-linear-gradient(135deg, #29463b 0 3px, #83a696 3px 4px); border-color: #9bc49c; border-radius: 2px; }

.map-sidebar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: .65rem;
  padding: clamp(1.3rem, 3.4vw, 2.4rem);
  min-width: 0;
  background: #eef5e8;
}

.map-scope { padding-bottom: .65rem; border-bottom: 1px solid #bed0bc; }
.map-scope-title { color: var(--deep); font-size: clamp(1.4rem, 2.6vw, 2.05rem); line-height: 1.15; }
.map-scope-count { margin-top: .25rem; color: var(--muted); font-size: .9rem; }
.map-territory-options { display: flex; flex-wrap: wrap; gap: .35rem; }
.map-territory-options:empty { display: none; }
.map-territory-options button {
  min-height: 38px;
  padding: .3rem .6rem;
  border: 1px solid #abc1ac;
  border-radius: .35rem;
  background: #f9fcf7;
  color: var(--green);
  font-size: .85rem;
  font-weight: 650;
}
.map-territory-options button:hover { background: #dcecd7; }
.map-city-label { font-weight: 730; font-size: .925rem; }
.map-sidebar select {
  appearance: none;
  width: 100%;
  min-height: 46px;
  border: 1px solid #99b29b;
  border-radius: .45rem;
  padding: .65rem 2.1rem .65rem .8rem;
  color: #143528;
  font: inherit;
  font-weight: 660;
  background:
    linear-gradient(45deg, transparent 50%, #305743 50%) calc(100% - 20px) 50% / 5px 5px no-repeat,
    linear-gradient(135deg, #305743 50%, transparent 50%) calc(100% - 15px) 50% / 5px 5px no-repeat,
    #fff;
  text-overflow: ellipsis;
}

.map-nearby { margin-top: .75rem; padding: .8rem; border: 1px solid #c3d8c0; border-radius: .55rem; background: #f7fbf4; }
.map-nearby p { margin-bottom: .5rem; font-size: .9rem; font-weight: 720; }
.map-nearby-options { display: flex; flex-wrap: wrap; gap: .3rem; }
.map-nearby-options button {
  padding: .4rem .55rem;
  min-height: 38px;
  border-radius: .3rem;
  border: 1px solid #c4d5bf;
  color: #204932;
  background: white;
  font-size: .84rem;
  font-weight: 650;
  text-align: start;
}
.map-nearby-options button:hover { border-color: #498264; }
.map-nearby-options button[aria-pressed="true"] { background: #204932; color: white; border-color: #204932; }
.map-details { margin-top: .85rem; }
.map-details.is-changing { animation: map-address-enter .34s ease-out both; }
@keyframes map-address-enter {
  from { opacity: .4; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.map-location-label { margin-bottom: .4rem; }
.map-location-title { font-size: clamp(1.45rem, 2.6vw, 2.1rem); line-height: 1.1; scroll-margin-top: 92px; }
.map-location-addresses { margin-top: 1.1rem; }
.map-address { padding: .88rem 0; border-top: 1px solid #bed0bc; }
.map-address address { color: #30483b; font-size: .93rem; font-style: normal; }
.map-address-link, .map-directory-link { font-weight: 730; color: #21563c; text-underline-offset: .18em; }
.map-address-link { display: inline-flex; align-items: center; gap: .35rem; margin-top: .55rem; }
.map-address-link .icon { width: 1.05rem; height: 1.05rem; }
.map-directory-link { align-self: flex-start; margin-top: auto; padding-top: .75rem; }
.map-position-note, .map-credits, .map-location-empty { color: #4d6253; font-size: .875rem; }
.map-position-note { margin-top: .3rem; }
.map-credits { padding: .5rem .15rem 0; }
.map-credits a { text-underline-offset: .2em; }

.branch-directory-title { margin-bottom: 1.2rem; font-size: clamp(1.65rem, 3vw, 2.65rem); }
.branch-card-actions { display: flex; align-items: center; flex-wrap: wrap; gap: .3rem .85rem; }
.branch-map-jump {
  min-height: 44px;
  padding: .28rem .15rem;
  border: 0;
  background: transparent;
  color: var(--green);
  font-size: .9rem;
  font-weight: 720;
  text-decoration: underline;
  text-underline-offset: .2em;
}

@media (max-width: 950px) {
  .branch-map-shell { grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr); }
  .map-top, .map-toolbar { padding-inline: 1.15rem; }
  .map-legend { padding-inline: 1.15rem; }
}

@media (max-width: 760px) {
  .branch-map { width: min(calc(100% - 32px), var(--max)); }
  .branch-map-shell { grid-template-columns: minmax(0, 1fr); }
  .map-canvas { height: clamp(320px, 102vw, 490px); }
  .map-sidebar { gap: .5rem; }
  .map-details { margin-top: .85rem; }
  .map-location-addresses { margin-top: .8rem; }
}

@media (max-width: 400px) {
  .map-top, .map-toolbar, .map-legend { padding-inline: .85rem; }
}

@media (prefers-reduced-motion: reduce) {
  .map-pin-building { transition: none; }
  .map-details.is-changing { animation: none; }
}
