:root {
  color-scheme: light dark;
  --bg: #0b1120;
  --bg-elevated: #111a2e;
  --surface: #16213a;
  --surface-2: #1c2942;
  --text: #eef2f9;
  --text-muted: #9aa7c2;
  --border: #263354;
  --accent: #f5b942;
  --accent-2: #ff7a59;
  --success: #34d399;
  --danger: #f87171;
  /* Colores de marca del país activo (bandera). layout.php los sobreescribe
     por país; estos son solo el valor por defecto si aún no hay país activo. */
  --brand-primary: #ce1126;
  --brand-secondary: #0b3d91;
  --brand-primary-text: #e8596b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 20px 45px -20px rgba(0, 0, 0, .55);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  /* Ancho general del contenido (incluido el mapa, que debe ser el
     protagonista de la página de país: mismo ancho que el resto, no una
     franja angosta). */
  --container-w: 1320px;
}

* { box-sizing: border-box; }

/* Cualquier clase de autor que fije "display" (.btn, .leader-card,
   .province-list-item, etc.) le gana en cascada a la regla [hidden] del
   navegador (misma especificidad, pero la del navegador es de origen UA).
   Sin esto, `el.hidden = true` deja el elemento con contenido viejo
   visible en vez de ocultarlo — pasó de verdad con la tarjeta del líder al
   cambiar de cantón sin cerrar el panel. Una sola regla global evita tener
   que acordarse de agregar "X[hidden]{display:none}" por cada clase nueva. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; display: flex; flex-direction: column; }

a { color: inherit; text-decoration: none; }

img { max-width: 100%; }

.muted { color: var(--text-muted); }
.small { font-size: .85rem; }

/* ---------- Banner de los primeros 3 (país/provincia/cantón) ---------- */

.top3-banner {
  position: relative;
  background: linear-gradient(90deg, var(--brand-secondary), var(--brand-primary));
  color: #fff;
  overflow: hidden;
}
.top3-banner-inner {
  max-width: var(--container-w);
  margin: 0 auto;
  padding: .55rem 2.6rem .55rem 1.1rem;
  display: flex;
  align-items: center;
  gap: .7rem;
  font-size: .85rem;
}
.top3-flag { flex: none; font-size: 1.05rem; }
.top3-slides { position: relative; flex: 1; min-width: 0; height: 1.3rem; }
.top3-slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: .5rem;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top3-slide.active { opacity: 1; pointer-events: auto; }
.top3-slide:hover { text-decoration: underline; }
.top3-rank {
  flex: none;
  background: rgba(255, 255, 255, .22);
  border-radius: 999px;
  padding: .1rem .5rem;
  font-weight: 800;
  font-size: .74rem;
}
.top3-text { overflow: hidden; text-overflow: ellipsis; }
.top3-cta {
  flex: none;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .32);
  border-radius: 999px;
  padding: .32rem .85rem;
  font-weight: 700;
  font-size: .78rem;
  white-space: nowrap;
}
.top3-cta:hover { background: rgba(255, 255, 255, .28); }
.top3-close {
  position: absolute;
  top: 50%;
  right: .7rem;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, .7);
  font-size: .9rem;
  cursor: pointer;
  padding: .25rem;
  line-height: 1;
}
.top3-close:hover { color: #fff; }
.top3-progress { height: 2px; background: rgba(255, 255, 255, .18); }
.top3-progress > span { display: block; height: 100%; width: 0; background: #fff; }

@media (max-width: 640px) {
  .top3-banner-inner { font-size: .78rem; padding: .5rem 2.3rem .5rem .9rem; gap: .5rem; }
  .top3-flag { display: none; }
}

/* ---------- Header / Footer ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 17, 32, .82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; font-size: 1.15rem; }
.brand-mark { font-size: 1.4rem; }
.brand-flag { font-size: 1.2rem; line-height: 1; }
.site-header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 4px;
  /* Franja de 3 bandas (no un degradado difuminado) para que se lea
     inequívocamente como los colores de la bandera del país activo. */
  background: linear-gradient(90deg,
    var(--brand-secondary) 0%, var(--brand-secondary) 40%,
    #fff 40%, #fff 60%,
    var(--brand-primary) 60%, var(--brand-primary) 100%);
}

.site-nav { display: flex; gap: 1.4rem; }
.site-nav a { color: var(--text-muted); font-weight: 600; font-size: .95rem; transition: color .15s; }
.site-nav a:hover { color: var(--text); }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  flex: none;
}
.nav-toggle span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 1px; }

main { flex: 1; }

.breadcrumbs { max-width: var(--container-w); margin: 0 auto; padding: .8rem 1.5rem 0; }
.breadcrumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem; font-size: .82rem; }
.breadcrumbs li { color: var(--text-muted); display: flex; align-items: center; gap: .3rem; }
.breadcrumbs li:not(:last-child)::after { content: "›"; margin-left: .3rem; color: var(--border); }
.breadcrumbs a { color: var(--text-muted); font-weight: 600; }
.breadcrumbs a:hover { color: var(--brand-primary-text); }
.breadcrumbs li span[aria-current] { color: var(--text); font-weight: 600; }

.site-footer {
  padding: 2.5rem 1.5rem 3rem;
  text-align: center;
  color: var(--text-muted);
  font-size: .85rem;
  border-top: 1px solid var(--border);
}
.site-footer p { margin: .3rem 0; }

/* ---------- Stats en vivo (pie de página) ---------- */

.live-stats-bar {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  flex-wrap: wrap;
  margin: 0 auto 1.8rem;
  padding: 1.1rem 1.8rem;
  max-width: 420px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.live-stat { display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.live-stat strong { font-size: 1.6rem; font-weight: 800; color: var(--text); line-height: 1; }
.live-stat span { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.live-stat-pulse strong { color: var(--success); }
.pulse-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  margin-bottom: .3rem;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, .6);
  animation: pulse-live 1.8s ease-out infinite;
}
@keyframes pulse-live {
  0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .6); }
  70% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

@media (max-width: 480px) {
  .live-stats-bar { gap: 1.6rem; padding: 1rem 1.2rem; }
  .live-stat strong { font-size: 1.35rem; }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .7rem 1.3rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); background: var(--surface-2); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a1000;
  border: none;
  box-shadow: 0 10px 25px -10px rgba(245, 185, 66, .6);
}
.btn-primary:hover { box-shadow: 0 14px 30px -10px rgba(245, 185, 66, .75); }

.btn-lg { padding: .95rem 1.8rem; font-size: 1.05rem; }
.btn-sm { padding: .4rem .8rem; font-size: .8rem; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(248, 113, 113, .4); }
.btn-danger:hover { background: rgba(248, 113, 113, .1); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ---------- Hero (home) ---------- */

.hero {
  padding: 6rem 1.5rem 5rem;
  text-align: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(245, 185, 66, .18), transparent 45%),
    radial-gradient(circle at 80% 0%, rgba(255, 122, 89, .16), transparent 40%),
    var(--bg);
}
.hero-inner { max-width: 760px; margin: 0 auto; }
.eyebrow { color: var(--brand-primary-text); font-weight: 700; letter-spacing: .04em; margin-bottom: .6rem; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.15; margin: 0 0 1rem; }
.hero-sub { color: var(--text-muted); font-size: 1.1rem; line-height: 1.6; margin-bottom: 2rem; }

/* ---------- Sections ---------- */

.section { max-width: var(--container-w); margin: 0 auto; padding: 3.5rem 1.5rem; }
.section-tight { padding-top: 0; padding-bottom: 1.5rem; }
.section-title { font-size: 1.6rem; margin-bottom: 1.6rem; text-align: center; }

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
}

/* ---------- Country grid (home) ---------- */

.country-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
}

/* Un solo país activo: no tiene sentido una grilla ni el título "Elegí un
   país" — una tarjeta grande y centrada es la protagonista de la sección. */
.country-grid-single {
  grid-template-columns: none;
  max-width: 420px;
  margin: 0 auto;
}
.country-grid-single .country-card { padding: 2.6rem 2rem; text-align: center; }
.country-grid-single .country-card-flag { font-size: 3.2rem; }
.country-grid-single .country-card h3 { font-size: 1.6rem; }
.country-grid-single .country-card-meta { font-size: 1rem; }
.country-grid-single .country-card-cta { font-size: 1rem; }

.country-card {
  position: relative;
  border-radius: var(--radius);
  padding: 1.8rem 1.4rem;
  background: linear-gradient(165deg,
    var(--from, #0f172a) 0%, var(--from, #0f172a) 58%,
    var(--to, #1e3a8a) 100%);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.country-card:hover { transform: translateY(-4px); box-shadow: 0 26px 50px -18px rgba(0, 0, 0, .6); }
.country-card-flag { font-size: 2.2rem; }
.country-card h3 { margin: 0; font-size: 1.25rem; }
.country-card-meta { color: rgba(255, 255, 255, .78); font-size: .9rem; margin: 0; }
.country-card-cta { margin-top: .6rem; font-weight: 700; font-size: .9rem; }

.progress { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .18); overflow: hidden; margin: .3rem 0; }
.progress-bar { height: 100%; background: var(--accent); border-radius: inherit; }

/* ---------- Aportes recientes ---------- */

.recent-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; max-width: 640px; margin: 0 auto; }
.recent-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  font-size: .92rem;
}
.recent-flag { margin-right: .4rem; }

/* ---------- Steps ---------- */

.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; margin-bottom: 1.5rem; }
.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem;
  text-align: center;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a1000;
  font-weight: 800;
  margin-bottom: .8rem;
}
.step h3 { margin: .2rem 0; }
.step p { color: var(--text-muted); font-size: .92rem; margin: 0; }

.disclaimer { text-align: center; color: var(--text-muted); font-size: .82rem; max-width: 620px; margin: 0 auto; }

/* ---------- FAQ ---------- */
/* Tarjetas tipo "píldora" en grilla de 2 columnas (1 en mobile), con un
   círculo +/– a la derecha — en vez de una lista plana de flechas por
   defecto del navegador. */

.faq-list {
  max-width: var(--container-w);
  margin: 0 auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  align-items: start;
}
.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 1.1rem 1.5rem;
  transition: border-color .15s ease, border-radius .15s ease, background .15s ease;
}
.faq-item:hover { border-color: var(--brand-primary-text); }
.faq-item[open] { border-radius: var(--radius); background: var(--surface-2); }
.faq-item summary {
  cursor: pointer;
  font-weight: 700;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  flex: none;
  width: 1.7rem;
  height: 1.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  font-size: 1.15rem;
  line-height: 1;
  color: var(--text-muted);
  transition: border-color .15s ease, color .15s ease;
}
.faq-item:hover summary::after { border-color: var(--brand-primary-text); color: var(--text); }
.faq-item[open] summary::after { content: "–"; border-color: var(--brand-primary); color: var(--brand-primary-text); }
.faq-item p { color: var(--text-muted); margin: .9rem 0 0; line-height: 1.65; font-size: .92rem; }

@media (max-width: 480px) {
  .faq-item { border-radius: var(--radius); }
  .faq-item[open] { border-radius: var(--radius); }
}

/* ---------- Country page ---------- */

.country-hero {
  /* Héroe compacto a propósito: el protagonista de esta página es el mapa
     de los 84 cantones, no el banner. */
  padding: 1.9rem 1.5rem 1.5rem;
  text-align: center;
  /* Bandas sólidas (no un degradado difuminado de punta a punta) para que
     se reconozca como los colores de la bandera y no como un morado
     genérico: mezclar azul y rojo en un degradado largo siempre pasa por
     magenta a mitad de camino. */
  background: linear-gradient(165deg,
    var(--from, #0f172a) 0%, var(--from, #0f172a) 58%,
    var(--to, #1e3a8a) 100%);
  color: #fff;
}
.country-hero-inner { max-width: 720px; margin: 0 auto; }
.back-link { display: inline-block; margin-bottom: .6rem; color: rgba(255, 255, 255, .8); font-size: .85rem; }
.country-hero-flag { font-size: 1.9rem; }
.country-hero h1 { font-size: clamp(1.4rem, 3vw, 1.9rem); margin: .1rem 0 .4rem; }
.country-hero .hero-sub { color: rgba(255, 255, 255, .85); font-size: .95rem; margin-bottom: 0; }
.country-hero-stats { font-weight: 700; color: rgba(255, 255, 255, .92); }

.map-wrap {
  /* Tan ancho como el resto del contenido: el mapa es el protagonista de
     la página de país, no una franja angosta al centro. position:relative
     porque el popup flotante (.map-tooltip) se posiciona contra este
     contenedor. */
  position: relative;
  max-width: var(--container-w);
  margin: 0 auto 2.5rem;
  padding: 0 1.5rem;
  text-align: center;
}
.map-wrap svg { width: 100%; height: auto; max-height: 78vh; }
.map-loading { padding: 2rem; }
.map-wrap svg [data-province] { cursor: pointer; transition: opacity .15s ease, filter .15s ease, stroke .15s ease; stroke: var(--bg); stroke-width: 1; }
.map-wrap svg [data-province]:hover { opacity: .92; filter: brightness(1.1); }
.map-wrap svg [data-province].is-unclaimed:hover { stroke: var(--success); stroke-width: 2; }
.map-wrap svg [data-province].is-claimed:hover { stroke: #fff; stroke-width: 2; }
.canton-pin { fill: #0f172a; stroke: #fff; stroke-width: 1.2; }

/* ---------- Popup del mapa al pasar el mouse sobre un cantón ---------- */

.map-tooltip {
  position: absolute;
  z-index: 30;
  left: 0;
  top: 0;
  min-width: 170px;
  max-width: 220px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .7rem .9rem;
  box-shadow: var(--shadow);
  pointer-events: none;
  font-size: .84rem;
  text-align: left;
}
.map-tooltip[hidden] { display: none; }
.map-tooltip-name { display: block; font-size: .95rem; margin-bottom: .3rem; }
.map-tooltip-status { display: block; margin-bottom: .35rem; line-height: 1.4; color: var(--text); }
.map-tooltip-status .is-claimed { display: block; color: #60a5fa; font-weight: 800; text-transform: uppercase; font-size: .7rem; letter-spacing: .04em; margin-bottom: .15rem; }
.map-tooltip-status .is-unclaimed { color: var(--success); font-weight: 800; }
.map-tooltip-hint { display: block; color: var(--text-muted); font-size: .76rem; }

/* ---------- Selector "Municipios" (cantones hermanos) en el panel ---------- */

.municipios-pills { margin: .9rem 0 1.1rem; }
.municipios-label { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; margin-bottom: .5rem; }
.municipios-pill-row { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .3rem; }
.municipio-pill {
  flex: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: .5rem .8rem;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.municipio-pill:hover { border-color: var(--accent); }
.municipio-pill.active { background: var(--success); color: #04160f; border-color: var(--success); font-weight: 800; }

.intro-copy { max-width: 760px; margin: 0 auto; padding: 0 1.5rem; color: var(--text-muted); line-height: 1.7; text-align: center; }

.load-more-wrap { text-align: center; margin-top: 1.5rem; }

.related-list { list-style: none; margin: 0 0 .8rem; padding: 0; display: grid; gap: .5rem; }
.related-list a { color: var(--text); font-weight: 600; }
.related-list a:hover { color: var(--brand-primary-text); }

.province-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1rem;
  max-width: var(--container-w);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.province-card {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 1.1rem 1rem;
  text-align: left;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease;
  color: var(--text);
  font-family: inherit;
}
.province-card:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--accent); }
.province-card h4 { margin: 0 0 .3rem; font-size: 1.05rem; }
.province-card .status-line { font-size: .82rem; color: var(--text-muted); }
.province-card.is-unclaimed .status-line { color: var(--success); }
.province-card.is-claimed { border-style: dashed; }
.province-card.is-claimed .status-line { color: var(--danger); font-weight: 700; }
.province-card .owner { display: block; margin-top: .3rem; font-size: .8rem; color: var(--accent); font-weight: 700; }

/* ---------- Barra de estadísticas del país ---------- */

.stats-bar {
  display: flex;
  justify-content: center;
  gap: .8rem;
  flex-wrap: wrap;
  margin: -1rem auto 1.6rem;
  padding: 0 1.5rem;
  position: relative;
  z-index: 5;
}
.stat-pill {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .55rem 1.1rem;
  font-size: .88rem;
  font-weight: 700;
  box-shadow: var(--shadow);
}
.stat-pill-accent { color: var(--accent); border-color: rgba(245, 185, 66, .4); }

/* ---------- Ranking: botones de acceso (página de país) ---------- */

.ranking-links {
  display: flex;
  justify-content: center;
  gap: .7rem;
  flex-wrap: wrap;
  max-width: var(--container-w);
  margin: 0 auto 1.8rem;
  padding: 0 1.5rem;
}

/* ---------- Lista de provincias (página de país) ---------- */
/* Filas horizontales de ancho completo (nombre a la izquierda, stats a la
   derecha) en vez de tarjetas angostas apiladas en grilla. */

.province-list {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  max-width: var(--container-w);
  margin: 0 auto;
  padding: 0 1.5rem;
}
.province-list-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand-secondary);
  border-radius: var(--radius-sm);
  padding: .9rem 1.2rem;
  transition: border-color .15s ease, transform .15s ease, background .15s ease;
}
.province-list-item:hover { border-left-color: var(--brand-primary); background: var(--surface-2); transform: translateX(2px); }
.province-list-item strong { font-size: 1rem; }
.province-list-item .province-arrow { color: var(--text-muted); font-size: 1.1rem; margin-left: .4rem; }

@media (max-width: 560px) {
  .province-list-item { flex-direction: column; align-items: flex-start; gap: .3rem; }
}

/* ---------- Chips de filtro por provincia (mapa de país) ---------- */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
  max-width: var(--container-w);
  margin: 0 auto 1.5rem;
  padding: 0 1.5rem;
}
.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  padding: .4rem .9rem;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.active { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }

.canton-province-tag {
  display: inline-block;
  font-size: .72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: .2rem;
}

/* ---------- Tablas de ranking (página de país, provincia, /ranking) ---------- */
/* No reusa .admin-table (definida en admin.css): ese hoja no se carga en
   las páginas públicas, así que una tabla de ranking pública necesita su
   propio estilo self-contained. */

.rank-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.rank-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.rank-table th, .rank-table td { padding: .7rem .9rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.rank-table tbody tr:last-child td { border-bottom: none; }
.rank-table tbody tr:hover { background: var(--surface-2); }
.rank-table th { color: var(--text-muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.rank-table td a { font-weight: 700; color: var(--text); }
.rank-table td a:hover { color: var(--brand-primary-text); }
.rank-pos { font-weight: 800; color: var(--text-muted); }
.rank-pos.is-top3 { color: var(--accent); }

.rank-tabs { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; max-width: var(--container-w); margin: 0 auto 1.8rem; padding: 0 1.5rem; }
.rank-tab-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  padding: .6rem 1.2rem;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
}
.rank-tab-btn:hover { color: var(--text); border-color: var(--accent); }
.rank-tab-btn.active { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }

.rank-section[hidden] { display: none; }
.rank-province-group { margin-bottom: 1.8rem; }
.rank-province-group:last-child { margin-bottom: 0; }
.rank-province-group h3 { font-size: 1rem; margin: 0 0 .6rem; }
.rank-province-group h3 a { font-weight: 800; }
.rank-province-group h3 a:hover { color: var(--brand-primary-text); }

/* ---------- Panel lateral de provincia ---------- */

.side-panel { position: fixed; inset: 0; z-index: 50; }
.side-panel[hidden] { display: none; }
.side-panel-backdrop { position: absolute; inset: 0; background: rgba(4, 7, 16, .72); backdrop-filter: blur(2px); }
.side-panel-body {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  padding: 2rem 1.6rem 1.6rem;
  overflow-y: auto;
  box-shadow: -20px 0 45px -20px rgba(0, 0, 0, .55);
  animation: slide-in .2s ease;
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.modal-close {
  position: absolute;
  top: .8rem;
  right: .8rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
}

.modal-price { color: var(--accent); font-weight: 800; font-size: 1.3rem; margin-top: -.3rem; }

.territory-badge {
  display: inline-block;
  padding: .3rem .7rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .03em;
  margin-bottom: .8rem;
}
.territory-badge.is-claimed { background: rgba(248, 113, 113, .16); color: var(--danger); }
.territory-badge.is-unclaimed { background: rgba(52, 211, 153, .16); color: var(--success); }

.leader-card {
  display: flex;
  align-items: center;
  gap: .7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .8rem .9rem;
  margin: 1rem 0;
}
.leader-flag { font-size: 1.3rem; }
.leader-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.leader-info strong { font-size: .95rem; }
.leader-info span { font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-amount { font-weight: 800; color: var(--accent); white-space: nowrap; }
.leader-link { display: inline-block; margin-top: .15rem; font-size: .78rem; font-weight: 700; color: var(--brand-primary-text); }
.leader-link:hover { text-decoration: underline; }

.report-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  font-size: .78rem;
  color: var(--text-muted);
  cursor: pointer;
}
.report-btn:hover { color: var(--danger); text-decoration: underline; }
.report-btn:disabled { color: var(--success); cursor: default; text-decoration: none; }

.global-rank { font-size: .88rem; font-weight: 700; color: var(--text); margin: .3rem 0 1.1rem; }

.btn-cta {
  background: linear-gradient(135deg, var(--danger), #b91c1c);
  color: #fff;
  border: none;
  font-size: 1rem;
  padding: .9rem 1rem;
  box-shadow: 0 10px 25px -10px rgba(239, 68, 68, .55);
}
.btn-cta:hover { box-shadow: 0 14px 30px -10px rgba(239, 68, 68, .7); }

.center-text { text-align: center; }

.panel-link { display: block; text-align: center; margin: .6rem 0 1.4rem; font-size: .88rem; font-weight: 600; color: var(--accent); }

.history-block { border-top: 1px solid var(--border); padding-top: 1rem; }
.history-toggle {
  background: transparent;
  border: none;
  color: var(--text);
  font-weight: 700;
  font-size: .88rem;
  cursor: pointer;
  padding: 0;
}
.history-list { list-style: none; margin: .8rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.history-list[hidden] { display: none; }
.history-list li { font-size: .84rem; color: var(--text-muted); border-bottom: 1px dashed var(--border); padding-bottom: .5rem; }
.history-list li strong { color: var(--text); }

.back-link-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  margin-bottom: 1rem;
}

#contribution-form label, .admin-form label {
  display: block;
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: .9rem;
  font-weight: 600;
}
#contribution-form input, #contribution-form textarea {
  display: block;
  width: 100%;
  margin-top: .35rem;
  padding: .6rem .7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
#contribution-form input:focus, #contribution-form textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.form-error {
  background: rgba(248, 113, 113, .12);
  border: 1px solid rgba(248, 113, 113, .4);
  color: #fecaca;
  padding: .6rem .8rem;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  margin: .6rem 0;
}
.form-success {
  background: rgba(52, 211, 153, .12);
  border: 1px solid rgba(52, 211, 153, .4);
  color: #bbf7d0;
  padding: .6rem .8rem;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  margin: .6rem 0;
}

#panel-success { text-align: center; padding-top: .5rem; }
.confetti-emoji { font-size: 3rem; animation: bounce .6s ease; }
@keyframes bounce { 0% { transform: scale(.5); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }

@media (max-width: 640px) {
  .nav-toggle { display: flex; }
  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: .9rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem 1.4rem;
    box-shadow: var(--shadow);
  }
  .site-nav.is-open { display: flex; }
  .hero { padding: 4rem 1.2rem 3rem; }
}

/* ---------- Banner de instalación de la PWA ---------- */

.pwa-install-banner {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 60;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: .8rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  box-shadow: var(--shadow);
}
.pwa-install-icon { font-size: 1.4rem; flex: none; }
.pwa-install-text { flex: 1; font-size: .85rem; line-height: 1.4; color: var(--text); }
.pwa-install-close {
  flex: none;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: .95rem;
  cursor: pointer;
  padding: .3rem;
  line-height: 1;
}
.pwa-install-close:hover { color: var(--text); }

@media (max-width: 480px) {
  .pwa-install-banner { flex-wrap: wrap; left: .6rem; right: .6rem; bottom: .6rem; }
  .pwa-install-text { font-size: .8rem; }
}
