/* ============================================================
   atlas.css — Mapa de dominio a pantalla completa (versión
   mexicana del mapa por casilla de VoteHub 2024).
   Reutiliza los tokens de styles.css (superficies, tinta, acento
   magenta INE, Archivo / Inter / Space Grotesk).
   ============================================================ */

:root {
  --ax-sky: #e9ecf3;
  --ax-land: #eceef1;
  --ax-shadow: 0 1px 2px rgba(20, 22, 26, .06), 0 6px 22px rgba(20, 22, 26, .12);
  --ax-shadow-lg: 0 2px 4px rgba(20, 22, 26, .06), 0 14px 40px rgba(20, 22, 26, .16);
  --ax-muted: #8a909b;
  --ax-up: #12804a;
  --ax-down: #b4322a;
  --ax-note: #f2a900;
}
[data-theme="dark"] {
  --ax-sky: #101217;
  --ax-land: #1b1e24;
  --ax-shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .45);
  --ax-shadow-lg: 0 2px 4px rgba(0, 0, 0, .5), 0 16px 44px rgba(0, 0, 0, .55);
  --ax-muted: #7d8594;
  --ax-up: #4cc38a;
  --ax-down: #f07a70;
}

/* Icono SVG del botón de tema del topbar. */
.theme-icon { display: inline-flex; }
.theme-icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Modo atlas: la vista ocupa todo el alto bajo el topbar ---------- */
body.atlas-mode { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
body.atlas-mode .app { flex: 1 1 auto; min-height: 0; max-width: none; margin: 0; padding: 0; }
body.atlas-mode .app > section { margin: 0; }
body.atlas-mode .foot { display: none; }

.ax {
  position: relative; height: 100%; overflow: hidden;
  font-family: var(--font-body); color: var(--ink);
  -webkit-user-select: none; user-select: none;
}
.ax svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
:where(.ax) button { font: inherit; color: inherit; }
.ax [hidden] { display: none !important; }
.ax :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Motor (atlas.js) ---------- */
.ax-map { position: absolute; inset: 0; }
.atlas-viewport {
  overflow: hidden; touch-action: none; cursor: grab;
  background: linear-gradient(180deg, var(--ax-sky), var(--ax-land) 60%);
}
.atlas-viewport:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; }
.atlas-viewport.is-pointing { cursor: pointer; }
.atlas-viewport.is-grabbing { cursor: grabbing; }
.atlas-plane { position: absolute; background: var(--ax-land); will-change: transform; }
.atlas-c { position: absolute; left: 0; top: 0; display: block; }
.atlas-spikes { position: absolute; inset: 0; pointer-events: none; }
.atlas-box {
  position: absolute; pointer-events: none; border-radius: 3px;
  border: 1.5px dashed var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.atlas-box[data-mode="remove"] { border-color: var(--ax-down); background: color-mix(in srgb, var(--ax-down) 12%, transparent); }
.atlas-viewport.is-tilted .atlas-plane { box-shadow: 0 -30px 60px -20px rgba(0, 0, 0, .18); }

/* ---------- Superficies flotantes ---------- */
.ax-tools, .ax-bar .ax-btn, .ax-layers, .ax-panel, .ax-legend, .ax-status, .ax-tools-open {
  background: var(--surface); box-shadow: var(--ax-shadow);
}

/* Vidrio esmerilado: los controles que flotan sobre el mapa dejan ver el color
   de debajo. El panel de resultados es más opaco para que su texto se lea bien.
   Si el navegador no soporta backdrop-filter, o el usuario pide menos
   transparencia, se conserva el fondo sólido de arriba. */
:root { --ax-blur: blur(18px) saturate(170%); --ax-edge: inset 0 1px 0 rgba(255, 255, 255, .7), inset 0 0 0 1px rgba(255, 255, 255, .32); }
[data-theme="dark"] { --ax-edge: inset 0 1px 0 rgba(255, 255, 255, .08), inset 0 0 0 1px rgba(255, 255, 255, .04); }
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .ax-tools, .ax-bar .ax-btn, .ax-layers, .ax-legend, .ax-status, .ax-tools-open {
    background: color-mix(in srgb, var(--surface) 72%, transparent);
    -webkit-backdrop-filter: var(--ax-blur); backdrop-filter: var(--ax-blur);
    box-shadow: var(--ax-shadow), var(--ax-edge);
  }
  .ax-layers { background: color-mix(in srgb, var(--surface) 86%, transparent); }
  .ax-panel {
    background: color-mix(in srgb, var(--surface) 87%, transparent);
    -webkit-backdrop-filter: blur(16px) saturate(150%); backdrop-filter: blur(16px) saturate(150%);
    box-shadow: var(--ax-shadow), var(--ax-edge);
  }
}
@media (prefers-reduced-transparency: reduce) {
  .ax-tools, .ax-bar .ax-btn, .ax-layers, .ax-panel, .ax-legend, .ax-status, .ax-tools-open {
    background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none;
  }
}

/* Cifras tabulares: los dígitos ocupan el mismo ancho y las columnas quedan alineadas. */
.ax-tip, .ax-panel, .ax-legend, .ax-status, .ax-layers { font-variant-numeric: tabular-nums; }
.ax-title, .ax-scope { font-variant-numeric: normal; }

/* Herramientas (arriba a la izquierda) */
.ax-tools { position: absolute; z-index: 6; top: 16px; left: 16px; width: 132px; border-radius: 12px; padding: 4px 0 8px; }
.ax-tools-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--hair-2); margin-bottom: 6px; }
.ax-tools-head span { font-family: var(--font-data); font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.ax-tools-row { display: grid; grid-template-columns: 38px 18px 1fr; align-items: center; gap: 6px; padding: 5px 12px; font-size: .74rem; color: var(--ink-2); }
.ax-tools-row svg { width: 18px; height: 18px; color: var(--ink-2); }
.ax kbd {
  justify-self: start; font-family: var(--font-data); font-size: .7rem; font-weight: 700; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--hair); border-bottom-width: 2px; border-radius: 5px; padding: 2px 6px; line-height: 1.2;
}
.ax-tools-open { position: absolute; z-index: 6; top: 16px; left: 16px; width: 40px; height: 40px; border: 0; border-radius: 10px; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.ax-tools-open svg { width: 20px; height: 20px; }
.ax-icon-sm {
  flex: none; width: 28px; height: 28px; display: grid; place-items: center;
  border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer;
  transition: background-color .15s, color .15s;
}
.ax-icon-sm svg { width: 16px; height: 16px; }
.ax-icon-sm:hover { background: var(--surface-2); color: var(--ink); }

/* Barra de controles (arriba a la derecha) */
.ax-bar { position: absolute; z-index: 7; top: 16px; right: 16px; display: flex; gap: 10px; }
.ax-btn {
  width: 46px; height: 46px; display: grid; place-items: center; cursor: pointer;
  border: 0; border-radius: 11px; color: var(--ink-2);
  transition: color .15s, box-shadow .15s, transform .12s cubic-bezier(.2, .8, .2, 1);
}
.ax-btn svg { width: 20px; height: 20px; }
.ax-btn:hover { color: var(--ink); }
.ax-btn:active { transform: scale(.94); }
.ax-btn.is-on { color: var(--accent); box-shadow: var(--ax-shadow), inset 0 0 0 1.5px var(--accent); }

/* Popover de capas */
.ax-layers {
  position: absolute; z-index: 8; top: 74px; right: 16px; width: 252px;
  border-radius: 14px; padding: 14px; display: grid; gap: 12px;
  transform-origin: top right; animation: axPop .18s cubic-bezier(.2, .8, .2, 1);
}
@keyframes axPop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
.ax-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ax-modes button {
  height: 34px; border: 1px solid var(--hair); border-radius: 8px; background: var(--surface);
  font-size: .8rem; font-weight: 600; color: var(--ink-2); cursor: pointer;
  transition: background-color .15s, color .15s, border-color .15s;
}
.ax-modes button:hover { border-color: var(--ink-2); color: var(--ink); }
.ax-modes button[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.ax-sub { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--hair-2); }
.ax-sub-h { margin: 0; font-size: .78rem; font-weight: 600; color: var(--ink); }
.ax-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ax-chips button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 4px 10px;
  border: 1px solid var(--hair); border-radius: 8px; background: var(--surface);
  font-size: .76rem; font-weight: 500; color: var(--ink-2); cursor: pointer;
  transition: border-color .15s, color .15s, background-color .15s;
}
.ax-chips button:hover { border-color: var(--ink-2); color: var(--ink); }
.ax-chips button[aria-checked="true"] { border-color: var(--accent); color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); box-shadow: inset 0 0 0 .5px var(--accent); }
.ax-chips-party button { padding: 4px 9px; }
.ax-note {
  margin: 0; padding: 8px 10px; border-radius: 8px; font-size: .72rem; line-height: 1.4; color: var(--ink-2);
  background: color-mix(in srgb, var(--ax-note) 13%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--ax-note) 45%, transparent);
}
.ax-toggle {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 12px; text-align: left;
  border: 1px solid var(--hair); border-radius: 8px; background: var(--surface); cursor: pointer;
  font-size: .8rem; font-weight: 500; color: var(--ink-2);
}
.ax-toggle:hover { border-color: var(--ink-2); color: var(--ink); }
.ax-toggle-box { width: 16px; height: 16px; border: 1.5px solid var(--hair); border-radius: 4px; display: grid; place-items: center; transition: background-color .15s, border-color .15s; }
.ax-toggle[aria-pressed="true"] { color: var(--ink); border-color: var(--accent); }
.ax-toggle[aria-pressed="true"] .ax-toggle-box { background: var(--accent); border-color: var(--accent); }
.ax-toggle[aria-pressed="true"] .ax-toggle-box::after { content: ""; width: 8px; height: 4px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.ax-layers-legend { display: none; }

/* ---------- Panel de resultados (abajo a la izquierda) ---------- */
.ax-panel {
  position: absolute; z-index: 5; left: 16px; bottom: 16px; width: 384px;
  max-height: calc(100% - 152px); display: flex; flex-direction: column;
  border-radius: 14px; overflow: hidden;
}
.ax-ph { flex: none; display: flex; align-items: center; gap: 6px; min-height: 54px; padding: 8px 10px 8px 20px; border-bottom: 1px solid var(--hair-2); }
.ax-scope { flex: 1 1 auto; min-width: 0; margin: 0; font-family: var(--font-body); font-size: .9rem; font-weight: 600; letter-spacing: 0; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ax-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--hair) transparent; }
.ax-panel.is-collapsed .ax-body { display: none; }
.ax-panel.is-collapsed .ax-ph { border-bottom: 0; }

.ax-intro { padding: 18px 20px 18px; border-bottom: 1px solid var(--hair-2); }
.ax-title { margin: 0; font-family: var(--font-display); font-size: 1.62rem; font-weight: 800; line-height: 1.1; letter-spacing: -.022em; text-wrap: balance; }
.ax-by { margin: 10px 0 0; font-size: .76rem; line-height: 1.45; color: var(--muted); }
.ax-seats { margin-top: 16px; }
.ax-seats-lbl { display: flex; gap: 2px; margin-bottom: 5px; }
.ax-seats-lbl span { min-width: 0; font-family: var(--font-data); font-size: .66rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); white-space: nowrap; overflow: hidden; }
.ax-seats-bar { display: flex; gap: 2px; height: 26px; border-radius: 999px; overflow: hidden; }
.ax-seats-bar span {
  min-width: 22px; display: flex; align-items: center; justify-content: center;
  background: var(--c); color: var(--t); font-family: var(--font-data); font-size: .8rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ax-seats-cap { margin: 6px 0 0; font-size: .7rem; color: var(--muted); }

.ax-search { position: relative; padding: 16px 20px; border-bottom: 1px solid var(--hair-2); }
.ax-search > svg { position: absolute; left: 33px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.ax-search input {
  width: 100%; height: 42px; padding: 0 12px 0 40px; border: 1px solid var(--hair); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: 400 .88rem var(--font-body);
  -webkit-user-select: text; user-select: text; caret-color: var(--accent);
  transition: border-color .15s, box-shadow .15s;
}
.ax-search input::placeholder { color: var(--muted); }
.ax-search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.ax-search input::-webkit-search-cancel-button { display: none; }
.ax-results {
  position: absolute; z-index: 3; left: 20px; right: 20px; top: calc(100% - 12px); margin: 0; padding: 4px; list-style: none;
  max-height: 268px; overflow-y: auto; background: var(--surface); border-radius: 10px; box-shadow: var(--ax-shadow-lg);
}
.ax-results li { display: grid; gap: 1px; padding: 9px 12px; border-radius: 7px; cursor: pointer; }
.ax-results li b { font-size: .86rem; font-weight: 600; }
.ax-results li span { font-size: .7rem; color: var(--muted); }
.ax-results li[aria-selected="true"], .ax-results li:hover { background: var(--surface-2); }
.ax-results .ax-r-empty { cursor: default; font-size: .8rem; color: var(--muted); }
.ax-results .ax-r-empty:hover { background: none; }

/* Tabla por fuerza */
.ax-t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ax-t thead th {
  padding: 12px 20px 10px; text-align: right; white-space: nowrap;
  font-family: var(--font-body); font-size: .7rem; font-weight: 500; letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
  border-bottom: 1px solid var(--hair);
}
.ax-t thead th:first-child { text-align: left; }
.ax-t tbody th { padding: 11px 6px 11px 20px; text-align: left; font-weight: 400; }
.ax-t tbody th { display: flex; align-items: center; gap: 10px; }
.ax-t td { padding: 11px 20px 11px 8px; text-align: right; white-space: nowrap; font-family: var(--font-data); font-size: .95rem; font-weight: 700; color: var(--ink); }
.ax-t td:last-child { font-weight: 500; color: var(--ink-2); font-size: .88rem; }
.ax-t tbody tr + tr > * { border-top: 1px solid var(--hair-2); }
.ax-t tbody tr.is-on { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.ax-t4 td { padding-left: 4px; padding-right: 14px; font-size: .84rem; }
.ax-t4 td:last-child { padding-right: 20px; font-weight: 700; }
.ax-t td.is-up { color: var(--ax-up); }
.ax-t td.is-down { color: var(--ax-down); }
.ax-pn { min-width: 0; display: grid; gap: 1px; }
.ax-pn > span { display: flex; align-items: center; gap: 6px; font-size: .94rem; font-weight: 600; color: var(--ink); }
.ax-pn em { font-size: .7rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ax-lead {
  font-family: var(--font-data); font-size: .58rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 11%, var(--surface)); border-radius: 4px; padding: 1px 5px;
}
.ax-dot { flex: none; width: 11px; height: 11px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); }
.ax-shift { margin: 0; padding: 10px 20px 12px; font-size: .8rem; color: var(--ink-2); border-top: 1px solid var(--hair); }
.ax-shift b { color: var(--ink); font-family: var(--font-data); }
.ax-empty { margin: 0; padding: 18px 20px; font-size: .84rem; line-height: 1.45; color: var(--muted); }

.ax-pfoot { padding: 12px 20px 16px; border-top: 1px solid var(--hair); background: var(--surface-2); }
.ax-pfoot p { margin: 0 0 4px; font-size: .78rem; line-height: 1.45; color: var(--ink-2); }
.ax-pfoot b { font-family: var(--font-data); font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.ax-pfoot .ax-src { margin-top: 6px; font-size: .68rem; color: var(--muted); }
.ax-link {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 0; border: 0; background: none; cursor: pointer;
  font-size: .82rem; font-weight: 600; color: var(--accent-ink) !important; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.ax-link svg { width: 15px; height: 15px; transition: transform .15s; }
.ax-link:hover svg { transform: translateX(2px); }

/* ---------- Tooltip ---------- */
:root { --ax-tip-bg: #eef0f3; --ax-tip-head: #0d0f13; --ax-lead: #14161a; --ax-lead-halo: rgba(255, 255, 255, .9); }
[data-theme="dark"] { --ax-tip-bg: #232831; --ax-tip-head: #050608; --ax-lead: #f1f3f7; --ax-lead-halo: rgba(0, 0, 0, .75); }

.ax-tip {
  position: absolute; z-index: 20; left: 0; top: 0; pointer-events: none;
  /* Ancho = el que pida el contenido (no se recorta ninguna columna); el
     tope solo evita que crezca sin límite en pantallas pequeñas. */
  width: max-content; min-width: 264px; max-width: min(380px, calc(100% - 16px));
  border-radius: 12px; overflow: hidden;
  background: var(--ax-tip-bg); font-size: .82rem;
  box-shadow: 0 2px 6px rgba(10, 12, 16, .14), 0 14px 34px rgba(10, 12, 16, .24);
}
.ax-tip:not([hidden]) { animation: axTipIn .14s cubic-bezier(.2, .8, .2, 1); }
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .ax-tip {
    background: color-mix(in srgb, var(--ax-tip-bg) 90%, transparent);
    -webkit-backdrop-filter: blur(14px) saturate(160%); backdrop-filter: blur(14px) saturate(160%);
  }
}
@media (prefers-reduced-transparency: reduce) {
  .ax-tip { background: var(--ax-tip-bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@keyframes axTipIn { from { opacity: 0; } }
.ax-tip-h { display: grid; gap: 2px; padding: 9px 14px 8px; background: var(--ax-tip-head); color: #fff; }
.ax-tip-h b { font-size: 1.04rem; font-weight: 600; line-height: 1.2; letter-spacing: -.005em; }
.ax-tip-h span { font-size: .64rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: rgba(255, 255, 255, .78); }
.ax-tip-b { padding: 8px 14px 9px; }

.ax-tip-t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.ax-tip-t thead th {
  padding: 0 0 5px 10px; text-align: right; white-space: nowrap; font-size: .68rem; font-weight: 500; color: var(--ink-2);
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 14%, transparent);
}
.ax-tip-t thead th:first-child { padding-left: 0; text-align: left; }
/* Celda del partido: el flex vive en un contenedor interno para que la tabla
   conserve su layout (un <th> con display:flex deja de ser celda de tabla). */
.ax-tip-t tbody th { padding: 4px 10px 4px 0; text-align: left; font-weight: 500; color: var(--ink); width: 100%; }
.ax-tip-p { display: flex; align-items: center; gap: 8px; min-height: 24px; white-space: nowrap; }
/* Nombre + barra de apoyo (el líder a todo lo ancho). */
.ax-tip-pn { flex: 1 1 auto; min-width: 0; display: grid; gap: 3px; }
.ax-tip-t tbody tr:first-child .ax-tip-pn > span:first-child { font-weight: 600; }
.ax-tip-bar { display: block; height: 4px; border-radius: 999px; overflow: hidden; background: color-mix(in srgb, var(--ink) 10%, transparent); }
.ax-tip-bar i { display: block; height: 100%; width: var(--w); border-radius: inherit; background: var(--c); transform-origin: left center; animation: axBarIn .34s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes axBarIn { from { transform: scaleX(0); } }
.ax-tip-t td { padding: 4px 0 4px 12px; text-align: right; white-space: nowrap; font-family: var(--font-data); color: var(--ink); }
.ax-tip-t td:nth-child(2) { font-weight: 700; }
.ax-tip-t td:last-child { color: var(--ink-2); min-width: 36px; }
.ax-tip-t tbody tr:first-child > * { padding-top: 6px; }
.ax-tip-t td.is-up { color: var(--ax-up); font-weight: 700; }
.ax-tip-t td.is-down { color: var(--ax-down); font-weight: 700; }
/* Logotipo: azulejo blanco (los PNG traen fondo transparente) recortado al
   emblema. El de Morena es un logotipo tipográfico: azulejo más ancho y
   recorte mayor para que la palabra se lea. */
.ax-tip-logo {
  flex: none; width: 24px; height: 24px; border-radius: 5px; overflow: hidden; display: grid; place-items: center;
  background: #fff; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}
.ax-tip-logo img { width: 24px; height: 24px; transform: scale(1.22); object-fit: contain; }
.ax-tip-logo.is-wordmark { width: 40px; }
.ax-tip-logo.is-wordmark img { width: 40px; height: 24px; transform: none; object-fit: cover; object-position: 50% 54%; }

.ax-tip-g { margin: 7px 0 0; font-size: .74rem; color: var(--ink-2); }
.ax-tip-m { display: flex; align-items: center; gap: 6px; }
.ax-tip-m .ax-dot { width: 9px; height: 9px; }
.ax-tip-m b { color: var(--ink); font-family: var(--font-data); }
.ax-tip-f { margin: 7px 0 0; padding-top: 6px; border-top: 1px solid color-mix(in srgb, var(--ink) 12%, transparent); font-size: .68rem; color: var(--ink-2); }
.ax-tip-b > .ax-tip-f:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

/* Flecha que une la tarjeta con el punto señalado. */
.ax-tip-lead { position: absolute; z-index: 19; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.ax-tip-lead:not([hidden]) { animation: axTipIn .14s cubic-bezier(.2, .8, .2, 1); }
.ax-tip-lead path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ax-lead-halo { stroke: var(--ax-lead-halo); stroke-width: 4.5; }
.ax-lead-line { stroke: var(--ax-lead); stroke-width: 1.6; }

@media (prefers-reduced-motion: reduce) {
  .ax-tip:not([hidden]), .ax-tip-lead:not([hidden]), .ax-tip-bar i { animation: none; }
}

/* ---------- Estado de carga ---------- */
.ax-status {
  position: absolute; z-index: 9; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  font-size: .76rem; font-weight: 500; color: var(--ink-2); white-space: nowrap;
}
.ax-status[data-kind="info"]::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--hair); border-top-color: var(--accent); animation: axSpin .8s linear infinite;
}
.ax-status[data-kind="warn"] { background: color-mix(in srgb, var(--ax-note) 16%, var(--surface)); color: var(--ink); white-space: normal; max-width: min(460px, 70vw); }
@keyframes axSpin { to { transform: rotate(360deg); } }

/* ---------- Leyenda ---------- */
.ax-legend { position: absolute; z-index: 4; right: 16px; bottom: 34px; max-width: 250px; padding: 10px 12px; border-radius: 10px; font-size: .68rem; color: var(--ink-2); }
.ax-lg-h { margin: 0 0 6px; font-weight: 600; color: var(--ink); }
.ax-lg-grid { display: grid; grid-template-columns: auto auto; align-items: center; gap: 4px 10px; }
.ax-lg-n { font-family: var(--font-data); font-weight: 700; letter-spacing: .03em; }
.ax-lg-ramp { display: flex; gap: 1px; }
.ax-lg-ramp i { width: 16px; height: 9px; }
.ax-lg-ramp i:first-child { border-radius: 2px 0 0 2px; }
.ax-lg-ramp i:last-child { border-radius: 0 2px 2px 0; }
.ax-lg-2 i { width: 40px; }
.ax-lg-wide i { width: 28px; }
.ax-lg-scale { display: flex; justify-content: space-between; gap: 12px; margin-top: 5px; color: var(--muted); }
.ax-lg-sw { display: flex; flex-wrap: wrap; gap: 6px 12px; max-width: 220px; }
.ax-lg-sw span { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-data); font-weight: 700; }
.ax-lg-sw .ax-dot { width: 10px; height: 10px; border-radius: 3px; }
.ax-lg-spike { display: flex; align-items: center; gap: 6px; margin: 8px 0 0; padding-top: 7px; border-top: 1px solid var(--hair-2); }
.ax-lg-spike svg { width: 10px; height: 12px; fill: var(--ink-2); stroke: none; }

.ax-attr {
  position: absolute; z-index: 4; right: 10px; bottom: 8px; margin: 0;
  font-size: .62rem; color: var(--muted); background: color-mix(in srgb, var(--surface) 82%, transparent);
  padding: 2px 7px; border-radius: 4px;
}
.ax-attr a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

.ax ::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); }

/* ---------- Tabletas y móviles ---------- */
@media (max-width: 860px) {
  .ax-tools, .ax-tools-open { display: none !important; }
  .ax-bar { top: 12px; right: 12px; gap: 6px; }
  .ax-btn { width: 42px; height: 42px; border-radius: 10px; }
  .ax-layers { top: 64px; right: 12px; left: auto; width: min(300px, calc(100% - 24px)); }
  .ax-layers-legend { display: block; padding-top: 12px; border-top: 1px solid var(--hair-2); font-size: .68rem; color: var(--ink-2); }
  .ax-legend { display: none; }
  .ax-status { top: 64px; }
  .ax-attr { top: 62px; bottom: auto; right: 12px; }
  .ax-panel {
    left: 0; right: 0; bottom: 0; width: auto; max-height: 50%;
    border-radius: 16px 16px 0 0; box-shadow: var(--ax-shadow-lg);
  }
  .ax-ph { min-height: 50px; padding-left: 16px; }
  .ax-intro { padding: 14px 16px; }
  .ax-title { font-size: 1.3rem; }
  .ax-search { padding: 12px 16px; }
  .ax-search > svg { left: 29px; }
  .ax-results { left: 16px; right: 16px; }
  .ax-t thead th { padding-left: 16px; padding-right: 16px; }
  .ax-t tbody th { padding-left: 16px; }
  .ax-t td { padding-right: 16px; }
  .ax-pfoot { padding: 12px 16px 16px; }
  .ax-tip { min-width: 210px; }
}

@media (prefers-reduced-motion: reduce) {
  .ax-layers { animation: none; }
  .ax-status[data-kind="info"]::before { animation-duration: 2.4s; }
}

/* Topbar compacto en teléfonos (todas las vistas). */
@media (max-width: 560px) {
  .cuenta-corte, .theme-text, .demo-badge { display: none; }
  .topbar { gap: .75rem; }
}


/* ---------- Gubernatura anterior (17 estados) y vistas de encuestas ---------- */
.ax-coal {
  font-family: var(--font-data); font-size: .56rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-2); background: color-mix(in srgb, var(--ax-note) 22%, var(--surface)); border-radius: 4px; padding: 1px 5px;
}
.ax-pn > span:has(.ax-coal) { flex-wrap: wrap; row-gap: 2px; }
.ax-coal-n { min-width: 0; overflow-wrap: anywhere; font-size: .86rem; }
.ax-pfoot .ax-note { margin: 8px 0 0; }
.ax-tip-w {
  margin: 7px 0 0; padding: 5px 7px; border-radius: 6px; font-size: .68rem; line-height: 1.35; color: var(--ink);
  background: color-mix(in srgb, var(--ax-note) 18%, var(--surface));
}
.ax-lg-note { margin: 6px 0 0; font-size: .66rem; color: var(--ink-2); }
.ax-by a { color: var(--accent-ink); font-weight: 600; }
.ax-src-box {
  margin: 12px 0 0; padding: 9px 11px; border-radius: 8px; font-size: .72rem; line-height: 1.45; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--hair-2);
}
.ax-src-box b { color: var(--ink); }
.ax-src-box q { font-style: italic; color: var(--ink); }
.ax-kpis { display: flex; gap: 14px; margin: 12px 0 0; }
.ax-kpis div { display: grid; gap: 1px; }
.ax-kpis b { font-family: var(--font-data); font-size: 1.25rem; font-weight: 700; color: var(--ink); }
.ax-kpis span { font-size: .68rem; color: var(--muted); }
.ax-polls { margin: 0; padding: 4px 20px 12px; list-style: none; font-size: .76rem; color: var(--ink-2); }
.ax-polls li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--hair-2); }
.ax-polls li:first-child { border-top: 0; }
.ax-polls a { color: var(--accent-ink); }
.ax-h3 { margin: 0; padding: 12px 20px 2px; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.ax-hatch-sw { display: inline-block; width: 14px; height: 10px; border-radius: 2px; vertical-align: -1px; margin-right: 6px; background: var(--c); }

/* ---------- Desplegable de fuentes ---------- */
.ax-fuente {
  margin: 12px 0 0; border-radius: 8px; font-size: .74rem; line-height: 1.45; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--hair-2);
}
.ax-pfoot .ax-fuente, .ax-layers .ax-fuente { margin: 8px 0 0; }
.ax-fuente > summary {
  display: flex; align-items: center; gap: 8px; padding: 8px 11px; cursor: pointer; list-style: none;
  font-weight: 600; color: var(--ink); border-radius: 8px;
}
.ax-fuente > summary::-webkit-details-marker { display: none; }
.ax-fuente > summary::before {
  content: ""; flex: none; width: 7px; height: 7px; border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg); transition: transform .15s;
}
.ax-fuente[open] > summary::before { transform: rotate(45deg); }
.ax-fuente > summary:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.ax-fuente > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ax-fuente-b { padding: 0 11px 10px 26px; }
.ax-fuente-b p { margin: 6px 0 0; }
.ax-fuente-b p:first-child { margin-top: 0; }
.ax-fuente-b b { color: var(--ink); }
.ax-fuente-b q { font-style: italic; color: var(--ink); }
.ax-fuente-b a { color: var(--accent-ink); }
.ax-fuente.is-aviso { background: color-mix(in srgb, var(--ax-note) 13%, var(--surface)); border-color: color-mix(in srgb, var(--ax-note) 45%, transparent); }
.ax-tip-s { margin: 6px 0 0; font-size: .68rem; color: var(--ink-2); }
