:root {
  /* Tinta — refinada con tonos más profundos */
  --ink: #0A1F2D;
  --ink-deep: #050F18;     /* navbar premium */
  --ink-2: #1E3A52;
  --muted: #5A6B7A;
  --muted-2: #94A3B8;
  --muted-3: #B8C5D1;      /* texto sub-sub muy bajo contraste */

  /* Papel */
  --paper: #FFFFFF;
  --paper-2: #F8FAFC;
  --paper-3: #F1F5F9;       /* paneles secundarios */
  --surface: #FFFFFF;

  /* Líneas */
  --line: #E2E8F0;
  --line-soft: #F1F5F9;

  /* Acentos */
  --gold: #F0A400;
  --gold-soft: #FFF4DA;
  --terracotta: #01466D;
  --sage: #3A8C5C;
  --alarm: #DC2626;

  /* Cepas */
  --cab: #5C1A2F;
  --carmen: #7A1F3D;
  --merlot: #4A0E1F;
  --syrah: #2D0A14;
  --chard: #D4B85A;
  --sauv: #A8C97F;

  /* Fonts */
  --serif: 'Source Serif 4','Charter','Source Serif Pro',Georgia,serif;
  --sans: 'DM Sans',-apple-system,BlinkMacSystemFont,sans-serif;
  --mono: 'JetBrains Mono','SF Mono',Consolas,monospace;

  /* Radios y sombras */
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-pill: 999px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 24px 48px -16px rgba(0,0,0,.18), 0 8px 16px -8px rgba(0,0,0,.06);
  --ease-spring: cubic-bezier(.34,1.56,.64,1);
  --ease-out: cubic-bezier(.16,1,.3,1);
  --ease-soft: cubic-bezier(.4,0,.2,1);
}

/* ───────── Motion: keyframes + reduced-motion ───────── */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes shimmer {
  from { background-position: -200% 0; }
  to   { background-position: 200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-delay: 0ms !important;
    transition-duration: .001ms !important;
  }
}

/* ───────── Focus rings (a11y) ───────── */
*:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}
.chip:focus-visible, .cat-chip:focus-visible,
.btn-nav:focus-visible, .cuartel-link:focus-visible {
  outline-offset: 3px;
}

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

html, body {
  min-height: 100%;
  font-family: var(--sans);
  font-feature-settings: "ss01","cv11";
  letter-spacing: -.012em;
  -webkit-font-smoothing: antialiased;
  color: var(--ink);
  background: var(--paper-2);
}

h1, h2, h3 { font-family: var(--serif); font-weight: 500; }

.mono, .ref, .lbl { font-family: var(--mono); }
.lbl {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
}

/* ===== Layout 3 columnas ===== */
#app {
  display: grid;
  grid-template-columns: 360px 1fr 420px;
  grid-template-rows: 56px 1fr;
  height: 100vh;
  background: var(--paper);
}
@media (max-width: 1300px) {
  #app { grid-template-columns: 320px 1fr 380px; }
}

/* ===== Topbar ===== */
.nav {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, var(--ink-deep) 0%, var(--ink) 100%);
  color: var(--paper);
  padding: 0 24px;
  border-bottom: 1px solid #000;
  position: relative;
}
.nav::after {
  /* línea sutil oro debajo del topbar — toque heritage */
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--gold) 50%, transparent 100%);
  opacity: .25;
}
.brand {
  display: flex; align-items: center; gap: 14px;
  text-decoration: none;
  color: inherit;
  transition: opacity .2s var(--ease-out);
}
.brand:hover { opacity: .85; }
.brand:hover .brand-logo { filter: drop-shadow(0 2px 8px rgba(240,164,0,.35)); }

/* Logo oficial Cousiño Macul (PNG con alpha) — versión light (blanca) sobre
   fondo dark del navbar. Para fondos claros usar .brand-logo-dark. */
.brand-logo {
  height: 36px;
  width: auto;
  max-width: 180px;
  display: block;
  transition: filter .2s var(--ease-out);
  /* fallback gold mientras carga / si falla */
  background: transparent;
}
.brand-logo-dark {
  /* misma config pero para fondos claros (login form, footers) */
  height: 44px;
  width: auto;
  max-width: 200px;
  display: block;
}

/* Legacy .logo gold square se mantiene para compatibilidad si algún día
   necesitamos fallback sin la imagen */
.logo {
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: var(--gold);
  color: var(--ink);
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 14px;
  font-variation-settings: "opsz" 36;
  letter-spacing: -.02em;
  box-shadow: 0 2px 8px rgba(240,164,0,.25), inset 0 1px 0 rgba(255,255,255,.2);
  position: relative;
}
.logo::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(10,31,45,.18);
  border-radius: 3px;
  pointer-events: none;
}
.brand-name {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 500;
  font-variation-settings: "opsz" 36;
  line-height: 1;
  letter-spacing: -.014em;
}
.brand-sub {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand-sub .heritage {
  color: var(--gold);
  font-weight: 600;
  letter-spacing: .18em;
}
.brand-sub .dot {
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--muted);
  display: inline-block;
}
.nav-center { display: flex; align-items: center; gap: 10px; }
.nav-center .lbl { color: var(--muted-2); }
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-right .lbl { color: var(--gold); font-size: 9px; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  color: var(--muted-2);
  border: 1px solid #2a4458;
  text-decoration: none;
  transition: all .15s var(--ease-out);
}
.btn-icon:hover {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(240,164,0,.08);
}
.btn-icon svg { display: block; }
.btn-icon.active {
  color: var(--ink);
  background: var(--gold);
  border-color: var(--gold);
}
.btn-icon.active:hover { background: var(--gold); color: var(--ink); }

/* ───────── Edit mode banner (mapa) ───────── */
.edit-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: var(--ink-deep);
  color: var(--paper);
  border-radius: var(--r-pill);
  padding: 8px 18px 8px 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35), 0 2px 4px rgba(0,0,0,.18);
  border: 1px solid var(--gold);
  animation: fade-up .35s var(--ease-out);
}
.edit-banner[hidden] { display: none; }
.edit-banner-content {
  display: flex;
  align-items: center;
  gap: 14px;
}
.edit-banner-pulse {
  width: 8px;
  height: 8px;
  background: var(--gold);
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(240,164,0,.6);
  animation: pulse-gold 1.6s infinite;
}
@keyframes pulse-gold {
  0%   { box-shadow: 0 0 0 0    rgba(240,164,0,.6); }
  70%  { box-shadow: 0 0 0 12px rgba(240,164,0,0);  }
  100% { box-shadow: 0 0 0 0    rgba(240,164,0,0);  }
}
.edit-banner-text {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--paper);
  letter-spacing: -.005em;
}
.edit-banner-text strong {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--gold);
  margin-right: 6px;
}
.edit-banner-text #edit-changed-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--gold);
  font-feature-settings: "tnum";
}
.edit-banner .btn-secondary,
.edit-banner .btn-primary {
  background: rgba(255,255,255,.08);
  color: var(--paper);
  border-color: rgba(255,255,255,.2);
}
.edit-banner .btn-secondary:hover {
  background: rgba(255,255,255,.16);
  color: var(--paper);
  border-color: var(--gold);
}
.edit-banner .btn-primary {
  background: var(--gold);
  color: var(--ink);
  border-color: var(--gold);
}
.edit-banner .btn-primary:hover { background: #FFB833; }

/* Polígono en modo edit: marker handles más visibles */
.leaflet-pm-marker-icon {
  border: 2px solid var(--gold) !important;
  background: var(--paper) !important;
  width: 10px !important;
  height: 10px !important;
  margin-left: -5px !important;
  margin-top: -5px !important;
  border-radius: 2px;
}
.leaflet-pm-marker-icon.marker-icon-middle {
  background: var(--gold-soft) !important;
  border-color: var(--gold) !important;
  opacity: .8;
}

/* ───────── Modal genérico (reusable) ───────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 31, 45, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fade-in .2s var(--ease-out);
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--paper);
  border-radius: var(--r-lg);
  box-shadow: 0 32px 64px -16px rgba(0,0,0,.32), 0 8px 16px -8px rgba(0,0,0,.12);
  width: 100%; max-width: 520px; max-height: 90vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: fade-up .3s var(--ease-out);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-title {
  font-family: var(--serif);
  font-size: 22px; font-weight: 500;
  font-variation-settings: "opsz" 36;
  color: var(--ink);
  letter-spacing: -.018em;
}
.modal-close {
  background: transparent; border: none;
  font-size: 28px; line-height: 1;
  color: var(--muted); cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.modal-close:hover { color: var(--ink); background: var(--paper-2); }
.modal-body {
  padding: 22px 24px;
  overflow-y: auto;
  flex: 1;
}
.form-row {
  margin-bottom: 16px;
  display: flex; flex-direction: column;
  gap: 8px;
}
.form-row[hidden] { display: none; }
.form-lbl {
  font-family: var(--mono);
  font-size: 10px; font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}
.form-lbl .req { color: var(--alarm); margin-left: 2px; }
.form-row input[type="text"],
.form-row input[type="email"],
.form-row select {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  font-family: var(--sans); font-size: 14px;
  color: var(--ink); background: var(--paper);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-row input:focus, .form-row select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(240,164,0,.12);
}
.form-hint {
  font-size: 11px; color: var(--muted);
  line-height: 1.45;
  font-style: italic;
}
.form-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

.chip {
  background: transparent;
  border: 1px solid #2a4458;
  color: var(--paper);
  padding: 5px 14px;
  border-radius: var(--r-pill);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all .2s var(--ease-spring);
}
.chip:hover { border-color: var(--gold); }
.chip-on { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.nav-sep {
  width: 1px;
  height: 18px;
  background: #2a4458;
  margin: 0 6px;
  display: inline-block;
}

/* Selector métrica del heatmap (aparece sólo en modo heatmap) */
.heatmap-metric-select {
  background: var(--ink-deep);
  color: var(--paper);
  border: 1px solid var(--gold);
  border-radius: var(--r-pill);
  padding: 4px 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: background .15s;
}
.heatmap-metric-select:hover { background: var(--ink-2); }
.heatmap-metric-select[hidden] { display: none; }

/* Leyenda heatmap (overlay sobre mapa, bottom-right) */
.heatmap-legend {
  position: absolute;
  bottom: 18px; right: 18px;
  z-index: 500;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-size: 11px;
  min-width: 200px;
}
.heatmap-legend[hidden] { display: none; }
.heatmap-legend h5 {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.heatmap-scale {
  height: 12px;
  border-radius: var(--r-sm);
  margin-bottom: 6px;
}
.heatmap-scale-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 9.5px;
  font-feature-settings: "tnum";
  color: var(--ink-2);
}

/* Botones de navegación cross-page (Dashboard ↔ Mapa) */
.btn-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--gold);
  color: var(--ink);
  padding: 7px 16px;
  border-radius: var(--r-pill);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  text-decoration: none;
  transition: transform .15s var(--ease-spring), box-shadow .15s, background .15s;
}
.btn-nav:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(240,164,0,.35); }
.btn-nav .arrow { transition: transform .2s var(--ease-spring); display: inline-block; }
.btn-nav:hover .arrow { transform: translateX(2px); }
.btn-nav-back {
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--gold);
}
.btn-nav-back:hover { background: var(--gold); color: var(--ink); }
.btn-nav-back:hover .arrow { transform: translateX(-2px); }

/* ===== Sidebar ===== */
.sidebar {
  background: var(--paper);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.sidebar-head {
  padding: 18px 18px 12px;
  display: flex; align-items: baseline; justify-content: space-between;
  border-bottom: 1px solid var(--line-soft);
}
.count {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  font-feature-settings: "tnum";
  letter-spacing: .04em;
}
.search {
  margin: 12px 18px 4px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: var(--paper-2);
  outline: none;
  transition: all .15s;
}
.search:focus { border-color: var(--gold); background: var(--paper); box-shadow: 0 0 0 3px rgba(240,164,0,.12); }

.filter-categoria {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 16px 4px;
}
.cat-chip {
  background: var(--paper-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  padding: 5px 10px;
  border-radius: var(--r-pill);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all .15s var(--ease-spring);
  white-space: nowrap;
}
.cat-chip:hover { border-color: var(--gold); background: var(--paper); }
.cat-chip.on { background: var(--gold); color: var(--ink); border-color: var(--gold); }
.cat-chip .cat-count {
  font-feature-settings: "tnum";
  margin-left: 4px;
  opacity: .65;
}
.cat-chip.on .cat-count { opacity: .85; }

.filter-row {
  padding: 10px 18px 14px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line-soft);
}
.filter-row select {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 5px 8px;
  font: inherit;
  font-size: 12px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}

.list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 18px;
}
.list-item {
  padding: 9px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background .15s, transform .15s var(--ease-spring);
}
.list-item:hover { background: var(--paper-2); }
.list-item.on { background: var(--gold-soft); }
.list-item .swatch {
  width: 12px; height: 12px;
  border-radius: 3px;
  border: 1.5px solid var(--ink);
  flex-shrink: 0;
}
.list-item .li-name {
  font-family: var(--serif);
  font-size: 14px;
  font-variation-settings: "opsz" 24;
  color: var(--ink);
  flex: 1;
  line-height: 1.2;
  letter-spacing: -.01em;
}
.list-item .li-meta {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

/* ===== Map ===== */
#map-wrap { position: relative; width: 100%; height: 100%; }
#map { width: 100%; height: 100%; background: var(--paper-2); }

/* ===== Detail ===== */
.detail {
  background: var(--paper);
  border-left: 1px solid var(--line);
  padding: 28px 24px;
  overflow-y: auto;
}
.detail-empty {
  margin-top: 80px;
  text-align: center;
  color: var(--muted-2);
}
.detail-empty .lbl { font-size: 10px; margin-bottom: 10px; display: block; }
.detail-empty p { font-size: 13px; line-height: 1.5; color: var(--muted); }
.detail-ref {
  font-family: var(--mono); font-size: 10px;
  color: var(--muted); letter-spacing: .18em; text-transform: uppercase;
  margin-bottom: 8px;
  font-weight: 500;
}
.detail-name {
  font-family: var(--serif);
  font-size: 28px;
  font-variation-settings: "opsz" 48;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.1;
  letter-spacing: -.022em;
}
.detail-cepa-tag {
  display: inline-flex; align-items: center; gap: 9px;
  margin: 16px 0 4px;
  padding: 5px 14px 5px 6px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  font-size: 12px;
  color: var(--ink-2);
}
.detail-cepa-tag .swatch { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--ink); }

.detail-tags {
  margin: 18px 0 4px;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.tag {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  font-size: 12px;
  color: var(--ink-2);
  background: var(--paper-2);
}
.tag .swatch { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--ink); }
.tag-calidad {
  padding-left: 12px;
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .16em; text-transform: uppercase;
  font-weight: 600;
}
.tag-ico { background: #2D0A14; border-color: #2D0A14; color: #F0A400; }
.tag-unconfirmed {
  background: #FEF3E2;
  border-color: #E8B86F;
  color: #8B5800;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  padding-left: 10px;
}
.match-warning {
  margin-top: 12px;
  padding: 10px 12px;
  background: #FEF3E2;
  border-left: 3px solid #E8B86F;
  border-radius: var(--r-sm);
  font-size: 11.5px;
  line-height: 1.5;
  color: #6E4220;
}
.match-warning strong { font-weight: 600; }
.match-warning code {
  font-family: var(--mono);
  font-size: 11px;
  background: rgba(0,0,0,.05);
  padding: 1px 4px;
  border-radius: 2px;
}
.tag-gr  { background: #FEF3E2; border-color: #E8B86F; color: #6E4220; }
.tag-res { background: #F5E0E6; border-color: #C97FA0; color: #6B1C2F; }
.tag-var { background: var(--paper-2); color: var(--ink-2); }

.detail-section {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}
.detail-section > .detail-grid {
  margin-top: 14px;
  padding-top: 0;
  border-top: none;
}
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.veredicto-pill {
  font-family: var(--mono); font-size: 9.5px;
  letter-spacing: .14em; text-transform: uppercase;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  white-space: nowrap;
}
.veredicto-ok      { background: var(--sage);  color: #FFFFFF; border-color: var(--sage); }
.veredicto-bad     { background: var(--alarm); color: #FFFFFF; border-color: var(--alarm); }
.veredicto-neutral { background: var(--gold-soft); color: #8B5800; border-color: #E8B86F; }

.kv-full { grid-column: 1 / -1; }
.kv .val.val-neg { color: var(--alarm); font-weight: 600; }
.kv .val.val-pos { color: var(--sage);  font-weight: 600; }

/* Breakeven block en ficha cuartel */
.breakeven-block {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--r);
  border: 1px solid;
}
.breakeven-block.be-ok  { background: rgba(58,140,92,.06); border-color: rgba(58,140,92,.3); }
.breakeven-block.be-bad { background: rgba(220,38,38,.05); border-color: rgba(220,38,38,.25); }
.be-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}
.be-status {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  border: 1px solid;
}
.be-ok .be-status  { background: var(--sage); color: white; border-color: var(--sage); }
.be-bad .be-status { background: var(--alarm); color: white; border-color: var(--alarm); }
.be-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 3px 0;
  font-size: 12px;
}
.be-row.be-delta {
  margin-top: 4px; padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}
.be-lbl { font-family: var(--mono); font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.be-val { font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--ink); font-feature-settings: "tnum"; }
.be-row.be-delta .be-val { font-weight: 600; font-size: 14px; }
.be-pct { font-size: 10px; color: var(--muted); margin-left: 4px; font-weight: 500; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 18px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}
.kv .lbl { display: block; margin-bottom: 6px; }
.kv .val {
  font-family: var(--mono); font-weight: 500;
  font-size: 14px;
  font-feature-settings: "tnum";
  color: var(--ink);
  letter-spacing: -.005em;
}
.kv .val.serif {
  font-family: var(--serif); font-weight: 400; font-size: 17px;
  font-variation-settings: "opsz" 24; letter-spacing: -.012em;
}

.detail-foot {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  font-size: 11px;
  color: var(--muted-2);
  line-height: 1.55;
}

/* ===== Leaflet popup editorial ===== */
.leaflet-popup-content-wrapper {
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  padding: 0;
}
.leaflet-popup-content {
  font-family: var(--sans);
  font-size: 13px;
  margin: 14px 18px;
  line-height: 1.4;
  color: var(--ink-2);
  letter-spacing: -.005em;
}
.pop-n {
  font-family: var(--mono); font-size: 10px;
  color: var(--muted); margin-bottom: 5px;
  letter-spacing: .14em; text-transform: uppercase;
  font-weight: 500;
}
.pop-dir {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 400;
  font-variation-settings: "opsz" 24;
  color: var(--ink);
  margin-bottom: 8px;
  line-height: 1.25;
  letter-spacing: -.012em;
}
.pop-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted-2);
  margin-top: 8px;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.leaflet-popup-tip { background: var(--surface); }

/* ===== Leyenda ===== */
.legend {
  position: absolute;
  bottom: 18px; left: 18px;
  z-index: 500;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-size: 11px;
  color: var(--ink);
  min-width: 200px;
  max-width: 240px;
}
.legend h5 {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}
.lrow {
  display: flex; align-items: center; gap: 8px;
  padding: 3px 0;
  font-size: 11px;
  color: var(--ink-2);
}
.lrow .swatch { width: 14px; height: 14px; border-radius: 3px; border: 1.5px solid var(--ink); flex-shrink: 0; }
.lrow .lcount {
  margin-left: auto;
  font-family: var(--mono);
  font-weight: 600;
  color: var(--muted);
  font-size: 10px;
  font-feature-settings: "tnum";
}

/* ===== Layer control ===== */
.leaflet-top.leaflet-right { top: 12px; right: 12px; }
.leaflet-control-layers {
  border-radius: var(--r) !important;
  border: 1px solid var(--line) !important;
  box-shadow: var(--shadow) !important;
  font-family: var(--sans) !important;
  font-size: 12px !important;
  padding: 4px 8px !important;
}
.leaflet-control-zoom {
  border-radius: var(--r) !important;
  border: 1px solid var(--line) !important;
  overflow: hidden;
}
.leaflet-control-zoom a {
  color: var(--ink) !important;
  font-family: var(--serif);
  font-weight: 500;
}
