:root {
  --bg: #f3ede1;
  --bg-deep: #ebe3d2;
  --land: #e6dcc6;
  --land-strong: #d8caaa;
  --water: #c8d8dc;
  --water-deep: #aac3c9;
  --ink: #1A1A1A;
  --ink-soft: #3a3a3a;
  --ink-mute: #555555;
  --line: #2a251c;
  --rule: #c9bfa9;
  --paper: #faf6ec;
  --paper-clean: #FFFFFF;
  --gris-calido: #F5F5F7;
  --red: #E31E24;
  --red-deep: #b8050f;
  --red-soft: #f6c8cb;
  --gold: #FFB800;
  --blue: #1f4e8c;
  --teal: #0f766e;
  --orange: #c2410c;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body, #root {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: "Montserrat", "Hanken Grotesk", -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  grid-template-columns: 1fr 380px;
  grid-template-areas:
    "header header"
    "map    panel"
    "legend panel"
    "footer panel";
  height: 100%;
  background: var(--bg);
}

/* ---------- Header ---------- */
.header {
  grid-area: header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px 12px;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  gap: 24px;
  z-index: 10;
  min-height: 78px;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 20px;
  min-width: 0;
  flex: 1;
}
.logo-horiz {
  height: 46px;
  flex-shrink: 0;
}
.logo-horiz img { height: 100%; object-fit: contain; display: block; }
.header-divider {
  width: 1px;
  height: 42px;
  background: var(--rule);
}

.header-title { line-height: 1; min-width: 0; overflow: hidden; }
.header-eyebrow {
  font-family: "Montserrat", sans-serif;
  font-size: 10.5px;
  letter-spacing: 0.22em;
  color: var(--ink-mute);
  text-transform: uppercase;
  font-weight: 600;
}
.header-h1 {
  font-family: "Montserrat", sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.005em;
  margin-top: 4px;
  color: var(--ink);
  text-transform: uppercase;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-h1 em {
  font-style: normal;
  color: var(--red);
  font-weight: 800;
}

.header-right {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-shrink: 0;
}
.stat {
  font-family: "Montserrat", sans-serif;
  text-align: right;
  line-height: 1.05;
  flex-shrink: 0;
}
.stat .v {
  font-family: "Montserrat", sans-serif;
  font-size: 21px;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}
.stat .k {
  font-size: 8.5px;
  letter-spacing: 0.16em;
  color: var(--ink-mute);
  text-transform: uppercase;
  margin-top: 4px;
  font-weight: 700;
}
.stat-divider {
  width: 1px;
  height: 28px;
  background: var(--rule);
  flex-shrink: 0;
}

/* ---------- Map ---------- */
.map-wrap {
  grid-area: map;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}
.map-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Leaflet tile recolor — warm sepia editorial tone over Positron */
.fdb-tiles {
  filter: sepia(0.35) saturate(0.65) brightness(1.02) contrast(0.96) hue-rotate(-8deg);
}
.fdb-tile-labels {
  filter: sepia(0.35) saturate(0.65) brightness(0.92) contrast(1.1) hue-rotate(-8deg);
  opacity: 0.7 !important;
  transition: opacity 0.3s ease;
}
/* Leaflet keeps inline-writing opacity on the layer container, so we target
   the children instead — they aren't touched by GridLayer._updateOpacity. */
body[data-zoom-tier="pano"] .fdb-tile-labels > * {
  opacity: 0;
  transition: opacity 0.3s ease;
}
body[data-zoom-tier="region"] .fdb-tile-labels > * {
  opacity: 0.55;
  transition: opacity 0.3s ease;
}
body[data-zoom-tier="comuna"] .fdb-tile-labels > * { opacity: 0.85; }
body[data-zoom-tier="project"] .fdb-tile-labels > * { opacity: 1; }
body[data-tile="neutral"] .fdb-tiles {
  filter: saturate(0.5) brightness(1.0) contrast(0.95);
}
body[data-tile="neutral"] .fdb-tile-labels {
  filter: saturate(0.5) brightness(0.9) contrast(1.1);
}
body[data-tile="mono"] .fdb-tiles {
  filter: grayscale(1) brightness(1.04) contrast(0.92);
}
body[data-tile="mono"] .fdb-tile-labels {
  filter: grayscale(1) brightness(0.9) contrast(1.1);
}

/* Leaflet container */
.leaflet-container {
  background: var(--bg) !important;
  font-family: "Hanken Grotesk", sans-serif !important;
  outline: none;
}
.leaflet-control-attribution {
  background: rgba(250, 246, 236, 0.85) !important;
  font-size: 9px !important;
  padding: 2px 8px !important;
  border-radius: 2px;
  border: 1px solid var(--rule);
  margin: 8px !important;
}
.leaflet-control-attribution a { color: var(--ink-soft) !important; }

/* ---------- Markers ---------- */

/* Comuna context dots — subtle backdrop showing covered comunas. */
.comuna-context-icon { background: transparent !important; border: none !important; }
.comuna-context {
  position: relative;
  width: 22px; height: 22px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.18s ease;
}
.comuna-context:hover { transform: scale(1.18); }
.comuna-context-dot {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--paper-clean);
  border: 1.5px dashed var(--ink-mute);
  color: var(--ink-mute);
  font-family: "Montserrat", sans-serif;
  font-size: 10px;
  font-weight: 800;
  display: grid;
  place-items: center;
  opacity: 0.55;
  transition: all 0.2s ease;
}
.comuna-context:hover .comuna-context-dot {
  opacity: 1;
  border-color: var(--ink);
  color: var(--ink);
}
.comuna-context.hi .comuna-context-dot {
  background: var(--red);
  border: 2px solid var(--red-deep);
  color: var(--paper-clean);
  opacity: 1;
  box-shadow: 0 2px 8px rgba(227, 30, 36, 0.35), 0 0 0 3px rgba(227, 30, 36, 0.18);
  width: 26px; height: 26px;
  font-size: 11px;
}

/* Region labels (low-zoom overlay) — HTML, follow map position */
.region-overlay {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 600;
  text-align: center;
  text-shadow: 0 1px 3px rgba(250, 246, 236, 0.95), 0 0 8px rgba(250, 246, 236, 0.6);
  will-change: transform;
  transition: opacity 0.25s ease;
}
.region-overlay-sub {
  font-family: "Montserrat", sans-serif;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--ink);
  font-weight: 600;
  opacity: 0.7;
}
.region-overlay-name {
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  font-size: 26px;
  color: var(--ink);
  line-height: 1.05;
  margin-top: 4px;
  white-space: nowrap;
  letter-spacing: -0.005em;
  text-transform: uppercase;
}
.region-overlay-meta {
  font-family: "Montserrat", sans-serif;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  color: var(--red);
  text-transform: uppercase;
  margin-top: 4px;
  font-weight: 600;
  white-space: nowrap;
}

/* Sede de proyecto — pin de gota con color por área programática */
.sede-pin-icon { background: transparent !important; border: none !important; overflow: visible !important; }
.sede-pin {
  position: relative;
  width: 34px;
  height: 42px;
  cursor: pointer;
  transition: transform 0.18s ease;
  display: block;
}
.sede-pin:hover { transform: scale(1.12) translateY(-1px); }
.sede-pin-pole {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 2px;
  height: 12px;
  background: var(--c);
  transform: translateX(-50%);
  box-shadow: 0 1px 0 rgba(255,255,255,0.6);
}
.sede-pin-head {
  position: absolute;
  left: 50%;
  bottom: 9px;
  width: 28px;
  height: 28px;
  background: var(--c);
  border-radius: 50% 50% 50% 0;
  transform: translateX(-50%) rotate(-45deg);
  display: grid;
  place-items: center;
  box-shadow: 0 3px 8px rgba(20,16,8,0.32), inset 0 1px 0 rgba(255,255,255,0.35);
  border: 1.5px solid rgba(255,255,255,0.85);
}
.sede-pin-core {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--paper-clean);
  transform: rotate(45deg);
}
.sede-pin.selected .sede-pin-head {
  box-shadow: 0 0 0 4px rgba(255,255,255,0.65), 0 0 0 6px var(--c), 0 3px 8px rgba(20,16,8,0.4);
  transform: translateX(-50%) rotate(-45deg) scale(1.1);
}
.sede-pin.selected { transform: scale(1.05) translateY(-2px); }

/* Pines no seleccionados — segundo plano */
.sede-pin.dimmed {
  transform: scale(0.6) translateY(4px);
  filter: grayscale(1) opacity(0.32);
  transition: transform 0.25s ease, filter 0.25s ease;
}
.sede-pin.dimmed:hover {
  transform: scale(0.75) translateY(2px);
  filter: grayscale(0.4) opacity(0.7);
}
.sede-pin.compact.dimmed {
  transform: scale(0.65);
  filter: grayscale(1) opacity(0.28);
  transition: transform 0.25s ease, filter 0.25s ease;
}
.sede-pin.compact.dimmed:hover {
  transform: scale(0.85);
  filter: grayscale(0.3) opacity(0.65);
}

/* Compact form (low zoom) */
.sede-pin.compact { width: 14px; height: 14px; }
.sede-pin.compact:hover { transform: scale(1.4); }
.sede-pin.compact .sede-pin-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid var(--paper-clean);
  box-shadow: 0 1px 2px rgba(20,16,8,0.4);
}
.sede-pin.compact.selected .sede-pin-dot {
  box-shadow: 0 0 0 3px rgba(255,255,255,0.7), 0 0 0 5px var(--c);
}

/* Leaflet tooltips */
.fdb-tooltip.leaflet-tooltip {
  background: var(--paper-clean);
  border: 1px solid var(--rule);
  border-radius: 2px;
  color: var(--ink);
  font-family: "Montserrat", sans-serif;
  font-size: 10.5px;
  font-weight: 700;
  padding: 4px 9px;
  box-shadow: 0 3px 8px rgba(20,16,8,0.14);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.fdb-tooltip.leaflet-tooltip::before { display: none; }
.fdb-tooltip.rich {
  text-transform: none;
  letter-spacing: 0;
  padding: 7px 11px;
  max-width: 260px;
}
.fdb-tooltip.rich b {
  display: block;
  font-size: 12px;
  letter-spacing: -0.005em;
  color: var(--ink);
  margin-bottom: 3px;
}
.fdb-tooltip.rich .tt-addr {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
}

/* Coverage overlays (shown when a project is selected) */
.coverage-circle {
  pointer-events: none;
  animation: coverage-in 0.4s ease both;
}
.coverage-line { pointer-events: none; animation: coverage-line-in 0.5s ease both; }
@keyframes coverage-in {
  from { stroke-opacity: 0; fill-opacity: 0; }
}
@keyframes coverage-line-in {
  from { stroke-opacity: 0; stroke-dashoffset: 60; }
}
.coverage-label-icon { background: transparent !important; border: none !important; }
.coverage-label {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: var(--c);
  color: var(--paper-clean);
  font-family: "Montserrat", sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 4px 9px;
  white-space: nowrap;
  border-radius: 2px;
  box-shadow: 0 2px 6px rgba(20,16,8,0.22);
}

/* Sede CENTRAL administrativa — Jécar Nehgme 11 */
.hq-icon { background: transparent !important; border: none !important; overflow: visible !important; }
.hq-marker {
  position: relative;
  width: 60px; height: 60px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.hq-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid var(--red);
  pointer-events: none;
}
.hq-ring-outer {
  width: 52px; height: 52px;
  opacity: 0.4;
  animation: hq-pulse 2.4s ease-in-out infinite;
}
.hq-ring-inner {
  width: 32px; height: 32px;
  opacity: 0.9;
}
@keyframes hq-pulse {
  0%, 100% { transform: scale(1); opacity: 0.45; }
  50% { transform: scale(1.18); opacity: 0.15; }
}
.hq-cross { position: absolute; background: var(--red); }
.hq-cross-h { width: 28px; height: 1.5px; }
.hq-cross-v { width: 1.5px; height: 28px; }
.hq-core {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid var(--paper-clean);
  z-index: 2;
}
.hq-tag {
  position: absolute;
  top: -34px;
  left: 32px;
  background: var(--red);
  color: var(--paper-clean);
  font-family: "Montserrat", sans-serif;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.22em;
  padding: 5px 9px;
  white-space: nowrap;
  border-radius: 2px;
  box-shadow: 0 2px 4px rgba(20,16,8,0.25);
  text-transform: uppercase;
}
.hq-tag::before {
  content: "";
  position: absolute;
  bottom: -10px;
  left: -10px;
  width: 14px;
  height: 14px;
  border-left: 1.5px solid var(--red);
  border-bottom: 1.5px solid var(--red);
}
.hq-tag-addr {
  position: absolute;
  top: -52px;
  left: 32px;
  font-family: "Montserrat", sans-serif;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  background: var(--paper-clean);
  padding: 2px 7px;
  border-radius: 2px;
  border: 1px solid var(--rule);
}

/* HQ zoom-tier visibility */
body[data-zoom-tier="pano"] .hq-tag,
body[data-zoom-tier="pano"] .hq-tag-addr { display: none; }
body[data-zoom-tier="region"] .hq-tag-addr { display: none; }
body[data-zoom-tier="pano"] .hq-ring-outer { opacity: 0.6; }
body[data-zoom-tier="pano"] .hq-marker { transform: scale(0.85); }

/* ---------- Frame corners + compass + indicator (editorial) ---------- */
.frame-corner {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--ink);
  pointer-events: none;
  z-index: 850;
  opacity: 0.7;
}
.frame-corner.tl { top: 10px; left: 10px; border-right: none; border-bottom: none; }
.frame-corner.tr { top: 10px; right: 10px; border-left: none; border-bottom: none; }
.frame-corner.bl { bottom: 10px; left: 10px; border-right: none; border-top: none; }
.frame-corner.br { bottom: 10px; right: 10px; border-left: none; border-top: none; }

.compass {
  position: absolute;
  bottom: 22px;
  right: 22px;
  z-index: 850;
  background: rgba(250, 246, 236, 0.85);
  padding: 4px;
  border: 1px solid var(--rule);
  border-radius: 50%;
  pointer-events: none;
}

/* ---------- Controls ---------- */
.controls {
  position: absolute;
  top: 22px;
  right: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 900;
  align-items: flex-end;
  pointer-events: auto;
}
.zoom-stack {
  display: flex;
  flex-direction: row;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(20, 16, 8, 0.06);
  width: fit-content;
}
.zoom-stack button {
  width: 34px; height: 34px;
  background: var(--paper);
  border: none;
  cursor: pointer;
  font-family: "Hanken Grotesk", sans-serif;
  font-size: 17px;
  color: var(--ink);
  border-right: 1px solid var(--rule);
  display: grid;
  place-items: center;
  transition: background 0.15s ease;
}
.zoom-stack button:last-child { border-right: none; }
.zoom-stack button:hover { background: var(--bg-deep); }
.zoom-stack button:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: -2px;
}

.view-jumps {
  display: flex;
  gap: 4px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(20, 16, 8, 0.06);
}
.view-jumps button {
  border: none;
  background: transparent;
  padding: 7px 12px;
  font-family: "Montserrat", sans-serif;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.15s ease, color 0.15s ease;
}
.view-jumps button:hover { background: var(--bg-deep); color: var(--ink); }
.view-jumps button.active { background: var(--red); color: var(--paper); }
.view-jumps button:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.zoom-indicator {
  position: absolute;
  top: 22px;
  left: 24px;
  background: var(--paper);
  border: 1px solid var(--rule);
  padding: 8px 14px;
  border-radius: 2px;
  font-family: "Montserrat", sans-serif;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
  box-shadow: 0 2px 8px rgba(20, 16, 8, 0.06);
  z-index: 900;
}
.zoom-indicator b { color: var(--red); font-weight: 600; margin-left: 4px; }

/* Active selection banner — replaces zoom indicator when something is selected */
.map-active-bar {
  position: absolute;
  top: 22px;
  left: 24px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--c, var(--red));
  border-radius: 2px;
  padding: 7px 8px 7px 12px;
  box-shadow: 0 2px 8px rgba(20,16,8,0.1);
  max-width: 300px;
  animation: bar-in 0.18s ease both;
}
@keyframes bar-in {
  from { opacity: 0; transform: translateY(-4px); }
}
.map-active-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--c, var(--red));
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.8);
}
.map-active-name {
  font-family: "Montserrat", sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.005em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.map-active-close {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 2px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--ink-mute);
  padding: 2px 7px;
  flex-shrink: 0;
  font-family: sans-serif;
  transition: background 0.15s ease, color 0.15s ease;
}
.map-active-close:hover { background: var(--red); color: var(--paper-clean); border-color: var(--red); }
.map-active-close:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

/* ---------- Legend (horizontal rail under map) ---------- */
.legend {
  grid-area: legend;
  background: var(--paper);
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 10px 24px;
  flex-wrap: wrap;
}
.legend-title {
  font-family: "Montserrat", sans-serif;
  font-size: 9.5px;
  letter-spacing: 0.18em;
  color: var(--ink-mute);
  text-transform: uppercase;
  margin-right: 4px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
}
.legend-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  border: 1.5px solid var(--paper);
  flex-shrink: 0;
}
.legend-label { color: var(--ink-soft); }
.legend-divider {
  width: 1px;
  height: 18px;
  background: var(--rule);
}

/* ---------- Side Panel ---------- */
.panel {
  grid-area: panel;
  background: var(--paper);
  border-left: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel-header {
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--rule);
}
.panel-eyebrow {
  font-family: "Montserrat", sans-serif;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--ink-mute);
  text-transform: uppercase;
  font-weight: 600;
}
.panel-title {
  font-family: "Montserrat", sans-serif;
  font-size: 24px;
  margin-top: 6px;
  line-height: 1.1;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.005em;
  text-transform: uppercase;
}
.panel-title em {
  font-style: normal;
  color: var(--red);
  font-weight: 700;
}
.panel-sub {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--ink-mute);
  line-height: 1.5;
  font-family: "Montserrat", sans-serif;
  font-weight: 400;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 22px;
}

.section-head {
  font-family: "Montserrat", sans-serif;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--ink-mute);
  text-transform: uppercase;
  margin: 18px 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--rule);
  padding-top: 16px;
  font-weight: 700;
}
.section-head:first-child { border-top: none; padding-top: 0; margin-top: 0;}
.section-head .count {
  font-family: "Montserrat", sans-serif;
  color: var(--red);
  font-weight: 700;
  letter-spacing: 0.1em;
}

.proj-card {
  border: 1px solid var(--rule);
  background: var(--bg);
  padding: 12px 14px;
  margin-bottom: 8px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}
.proj-card:hover {
  border-color: var(--red);
  background: var(--paper);
  transform: translateX(-2px);
}
.proj-card.selected {
  border-color: var(--red);
  background: #fff;
  box-shadow: -3px 0 0 var(--red);
}
.proj-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}
.proj-card-area {
  font-family: "Montserrat", sans-serif;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 2px;
  flex-shrink: 0;
  color: white;
}
.proj-card-kind {
  font-family: "Montserrat", sans-serif;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: var(--ink-mute);
  text-transform: uppercase;
}
.proj-card-name {
  font-family: "Montserrat", sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
  letter-spacing: -0.005em;
}
.proj-card-meta {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--ink-soft);
  display: flex;
  gap: 14px;
  font-family: "Montserrat", sans-serif;
}
.proj-card-meta b {
  color: var(--ink);
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: -0.01em;
}
.proj-card-comunas {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.4;
}
.proj-card-target {
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-mute);
  font-style: italic;
  line-height: 1.4;
}

.comuna-summary {
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 2px;
  margin-bottom: 14px;
  border: 1px solid var(--rule);
}
.comuna-summary-coord {
  font-family: "Montserrat", sans-serif;
  font-size: 10px;
  color: var(--ink-mute);
  letter-spacing: 0.1em;
}
.comuna-summary-stat {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  align-items: baseline;
}
.comuna-summary-stat .v {
  font-family: "Montserrat", sans-serif;
  font-size: 30px;
  color: var(--red);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.comuna-summary-stat .k {
  font-family: "Montserrat", sans-serif;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.empty {
  font-family: "Montserrat", sans-serif;
  font-style: normal;
  color: var(--ink-mute);
  font-size: 14px;
  line-height: 1.5;
  padding: 14px 0;
  font-weight: 500;
}
.empty-hint {
  font-family: "Montserrat", sans-serif;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  color: var(--red);
  text-transform: uppercase;
  margin-top: 12px;
}

/* ---------- Footer rail ---------- */
.footer {
  grid-area: footer;
  padding: 10px 24px;
  border-top: 1px solid var(--rule);
  background: var(--paper);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: "Montserrat", sans-serif;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.footer .l, .footer .r { display: flex; gap: 18px; align-items: center;}
.footer-pulse {
  width: 7px; height: 7px;
  background: var(--red);
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.7); }
}


.tweaks-panel { z-index: 50; }

.body-copy {
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.55;
  font-weight: 400;
}

/* Stats grid (replaces inline summary) */
.stat-pair {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  gap: 12px;
  align-items: center;
}
.stat-pair::before {
  content: "";
  grid-column: 2;
  height: 38px;
  width: 1px;
  background: var(--rule);
  order: 2;
}
.stat-pair .stat-cell:first-child { grid-column: 1; }
.stat-pair .stat-cell:last-child { grid-column: 3; }
.stat-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-cell-v {
  font-family: "Montserrat", sans-serif;
  font-size: 34px;
  line-height: 1;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.025em;
}
.stat-cell-k {
  font-family: "Montserrat", sans-serif;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  color: var(--ink-mute);
  text-transform: uppercase;
  font-weight: 700;
  line-height: 1.3;
}

/* Brand hero (top of overview) */
.brand-hero {
  position: relative;
  padding: 22px 22px 18px;
  background: var(--red);
  color: var(--paper-clean);
  overflow: hidden;
}
.brand-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 90% 20%, rgba(255,255,255,0.08) 0, transparent 50%),
                    radial-gradient(circle at 10% 90%, rgba(0,0,0,0.12) 0, transparent 50%);
  pointer-events: none;
}
.brand-hero-mark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--paper-clean);
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  position: relative;
  z-index: 1;
}
.brand-hero-mark img {
  width: 76%;
  height: 76%;
  object-fit: contain;
}
.brand-hero-quote {
  font-family: "Montserrat", sans-serif;
  font-style: normal;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.5;
  color: var(--paper-clean);
  position: relative;
  z-index: 1;
  letter-spacing: 0.01em;
  text-wrap: pretty;
}
.brand-hero-tag {
  margin-top: 14px;
  font-family: "Montserrat", sans-serif;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.24em;
  color: var(--paper-clean);
  opacity: 0.85;
  position: relative;
  z-index: 1;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.25);
}

/* Comuna list (in project detail) */
.comuna-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--rule);
}
.comuna-list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 2px;
  border-bottom: 1px solid var(--rule);
}
.comuna-list-name {
  font-family: "Montserrat", sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
}
.comuna-list-tag {
  font-family: "Montserrat", sans-serif;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-mute);
  padding: 2px 7px;
  border: 1px solid var(--rule);
  border-radius: 2px;
}

.sector-pill {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--gris-calido);
  border-left: 3px solid var(--red);
  font-family: "Montserrat", sans-serif;
  font-size: 12px;
}
.sector-pill span {
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-mute);
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
}
.sector-pill b {
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}

/* Brand ribbon (foot of detail panels) */
.brand-ribbon {
  margin-top: 28px;
  padding: 14px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--ink);
  color: var(--paper-clean);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}
.brand-ribbon img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}
.brand-ribbon-tag {
  font-family: "Montserrat", sans-serif;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--paper-clean);
}
.brand-ribbon-text {
  font-family: "Montserrat", sans-serif;
  font-size: 10px;
  color: rgba(255,255,255,0.65);
  margin-top: 3px;
  line-height: 1.4;
  font-weight: 400;
}

/* Sede card */
.sede-card {
  position: relative;
  padding: 18px 18px 16px;
  background: var(--ink);
  color: var(--paper-clean);
  border-radius: 2px;
  margin-bottom: 14px;
  overflow: hidden;
}
.sede-card-mark {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 80px;
  height: 80px;
  opacity: 0.15;
  filter: brightness(2);
}
.sede-card-eyebrow {
  font-family: "Montserrat", sans-serif;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.24em;
  color: var(--red);
  position: relative;
  z-index: 1;
}
.sede-card-title {
  font-family: "Montserrat", sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.015em;
  margin-top: 5px;
  position: relative;
  z-index: 1;
}
.sede-card-sub {
  font-family: "Montserrat", sans-serif;
  font-size: 12px;
  opacity: 0.75;
  margin-top: 3px;
  font-weight: 500;
  position: relative;
  z-index: 1;
}
.sede-card-line {
  width: 32px;
  height: 2px;
  background: var(--red);
  margin: 12px 0 10px;
  position: relative;
  z-index: 1;
}
.sede-card-cite {
  font-family: "Montserrat", sans-serif;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--paper-clean);
  opacity: 0.65;
  font-weight: 600;
  position: relative;
  z-index: 1;
}

/* Area rows (overview) */
.area-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}
.area-bar {
  width: 4px;
  height: 38px;
  border-radius: 1px;
  flex-shrink: 0;
}
.area-name {
  font-family: "Montserrat", sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.area-meta {
  font-family: "Montserrat", sans-serif;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-top: 3px;
  font-weight: 500;
}
.area-figure {
  font-family: "Montserrat", sans-serif;
  font-weight: 800;
  font-size: 24px;
  letter-spacing: -0.02em;
}

/* Region jumps */
.region-jumps {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.region-jump {
  padding: 14px 14px;
  border: 1px solid var(--rule);
  background: var(--paper);
  cursor: pointer;
  text-align: left;
  border-radius: 2px;
  font-family: "Montserrat", sans-serif;
  transition: all 0.15s ease;
}
.region-jump:hover {
  border-color: var(--red);
  background: var(--paper-clean);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(20,16,8,0.08);
}
.region-jump-eyebrow {
  font-size: 9px;
  letter-spacing: 0.2em;
  font-weight: 700;
  color: var(--ink-mute);
  text-transform: uppercase;
}
.region-jump-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.015em;
  margin-top: 4px;
  color: var(--ink);
  text-transform: uppercase;
}
.region-jump-meta {
  font-size: 9.5px;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
  margin-top: 8px;
  font-weight: 700;
}

/* Brand footer */
.brand-footer {
  margin-top: 28px;
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.brand-footer-line {
  height: 2px;
  background: var(--red);
  width: 32px;
}
.brand-footer-text {
  font-family: "Montserrat", sans-serif;
  font-size: 10.5px;
  color: var(--ink-mute);
  line-height: 1.55;
  font-weight: 400;
}
.brand-footer-text b {
  color: var(--ink);
  font-weight: 700;
}

/* ─── Sede address card (project detail) ─────────────────────────────── */
.sede-address-card {
  border-left: 3px solid var(--red);
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 0 2px 2px 0;
  margin-bottom: 14px;
}
.sede-address-eyebrow {
  font-family: "Montserrat", sans-serif;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 4px;
}
.sede-address-pin { display: flex; align-items: center; }
.sede-address-text {
  font-family: "Montserrat", sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.005em;
}

/* ─── Project browser (panel overview) ───────────────────────────────── */
.proj-browser {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.proj-browser-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 2px;
  cursor: pointer;
  text-align: left;
  font-family: "Montserrat", sans-serif;
  transition: all 0.15s ease;
  width: 100%;
}
.proj-browser-item:hover {
  border-color: var(--area-color, var(--red));
  background: var(--paper);
  transform: translateX(-2px);
  box-shadow: -2px 0 0 var(--area-color, var(--red));
}
.proj-browser-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid rgba(255,255,255,0.7);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.proj-browser-name {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.proj-browser-addr {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  color: var(--ink-mute);
  text-transform: uppercase;
  font-weight: 700;
  flex-shrink: 0;
}
.proj-browser-arrow {
  font-size: 10px;
  color: var(--area-color, var(--red));
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.proj-browser-item:hover .proj-browser-arrow { opacity: 1; }
.proj-browser-item:focus-visible {
  outline: 2px solid var(--area-color, var(--red));
  outline-offset: 2px;
}

/* ─── Coverage ring animation (selected sede) ────────────────────────── */
@keyframes sel-ring-pulse {
  0%, 100% { stroke-opacity: 0.85; r: 0; }
  60% { stroke-opacity: 0.1; }
}
.coverage-sel-ring {
  animation: sel-ring-pulse 1.6s ease-out infinite;
}
.coverage-glow {
  pointer-events: none;
  animation: coverage-in 0.6s ease both;
}

/* Compact sede pin — larger for panoramic visibility */
.sede-pin.compact { width: 20px; height: 20px; }
.sede-pin.compact:hover { transform: scale(1.35); }
.sede-pin.compact .sede-pin-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--c);
  border: 2.5px solid var(--paper-clean);
  box-shadow: 0 2px 5px rgba(20,16,8,0.45), 0 0 0 1px rgba(0,0,0,0.1);
  margin: 2px;
}
.sede-pin.compact.selected .sede-pin-dot {
  box-shadow: 0 0 0 3px rgba(255,255,255,0.8), 0 0 0 5px var(--c), 0 2px 6px rgba(20,16,8,0.35);
  width: 18px; height: 18px;
  margin: 1px;
}

/* ─── Reduced motion ─────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .hq-ring-outer,
  .footer-pulse,
  .coverage-sel-ring,
  .coverage-circle,
  .coverage-glow,
  .coverage-line {
    animation: none !important;
    transition: none !important;
  }
  .sede-pin,
  .sede-pin.compact,
  .proj-browser-item,
  .proj-card,
  .region-jump {
    transition: none !important;
  }
}

/* ─── Mobile responsive (≤ 767px) ─────────────────────────────────────── */
@media (max-width: 767px) {

  /* Grid: single column — panel removed from flow (goes fixed) */
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto auto;
    grid-template-areas:
      "header"
      "map"
      "legend"
      "footer";
  }

  /* Header: compact — logo only, no stats */
  .header {
    padding: 9px 14px;
    min-height: 54px;
    gap: 10px;
  }
  .logo-horiz { height: 32px; }
  .header-divider { display: none; }
  .header-title { display: none; }
  .header-right { display: none; }

  /* Panel: fixed bottom sheet */
  .panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72vh;
    border-left: none;
    border-top: 3px solid var(--red);
    border-radius: 14px 14px 0 0;
    z-index: 1100;
    box-shadow: 0 -8px 40px rgba(20,16,8,0.25);
    transform: translateY(110%);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
    overflow: hidden;
  }
  .app[data-panel-open="true"] .panel {
    transform: translateY(0);
  }
  /* Drag handle pill at top of panel */
  .panel::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 4px;
    background: var(--rule);
    border-radius: 2px;
    z-index: 10;
  }
  /* Space below handle for first panel child */
  .panel > :first-child { margin-top: 22px; }

  /* Mobile backdrop */
  .mobile-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20,16,8,0.38);
    z-index: 1050;
  }
  .app[data-panel-open="true"] .mobile-backdrop { display: block; }

  /* Close button: top-right of panel */
  .panel-close-mobile {
    display: grid;
    place-items: center;
    position: fixed;
    top: calc(28vh + 10px);
    right: 14px;
    z-index: 1200;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--paper);
    border: 1px solid var(--rule);
    cursor: pointer;
    font-size: 14px;
    color: var(--ink-mute);
    font-family: sans-serif;
    box-shadow: 0 2px 6px rgba(20,16,8,0.14);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .app[data-panel-open="true"] .panel-close-mobile {
    opacity: 1;
    pointer-events: auto;
  }

  /* FAB: opens panel */
  .panel-fab {
    display: flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    bottom: 82px;
    right: 14px;
    z-index: 1050;
    background: var(--ink);
    color: var(--paper-clean);
    border: none;
    border-radius: 28px;
    padding: 11px 16px;
    font-family: "Montserrat", sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(20,16,8,0.3);
    transition: background 0.15s ease;
  }
  .panel-fab:hover,
  .panel-fab:active { background: var(--red); }
  .app[data-panel-open="true"] .panel-fab { display: none; }

  /* Legend: compact horizontal strip */
  .legend {
    gap: 12px;
    padding: 7px 14px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .legend-title { display: none; }
  .legend-divider { display: none; }

  /* Footer: single row, simplified */
  .footer {
    padding: 6px 14px;
    font-size: 8.5px;
    letter-spacing: 0.1em;
  }
  .footer .r { display: none; }
  .footer .l { gap: 8px; }

  /* Map controls: tighter positioning */
  .controls { top: 14px; right: 14px; }
  .zoom-indicator { top: 14px; left: 14px; font-size: 9.5px; padding: 6px 10px; }
  .map-active-bar { top: 14px; left: 14px; max-width: calc(100vw - 110px); }
  .view-jumps button { padding: 6px 9px; font-size: 9px; letter-spacing: 0.1em; }
}

/* Hide mobile-only elements on desktop */
@media (min-width: 768px) {
  .panel-fab,
  .panel-close-mobile,
  .mobile-backdrop { display: none !important; }
}
