:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --surface-soft: #eef2f7;
  --text: #0f172a;
  --text-soft: #334155;
  --muted: #64748b;
  --primary: #0b6cff;
  --border: #dbe2ea;
  --success: #0f9d58;
  --danger: #d93025;
  --bg-gradient-start: #dbeafe;
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --shadow-card: 0 10px 25px rgba(15, 23, 42, 0.06);
  --shadow-soft: 0 8px 18px rgba(15, 23, 42, 0.15);
}

html[data-theme='dark'] {
  --bg: #020617;
  --surface: #0f172a;
  --surface-muted: #111c32;
  --surface-soft: #1e293b;
  --text: #e2e8f0;
  --text-soft: #cbd5e1;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --border: #334155;
  --success: #22c55e;
  --danger: #ef4444;
  --bg-gradient-start: #0f172a;
  --topbar-bg: rgba(2, 6, 23, 0.92);
  --shadow-card: 0 12px 28px rgba(2, 6, 23, 0.55);
  --shadow-soft: 0 10px 24px rgba(2, 6, 23, 0.42);
  color-scheme: dark;
}

html[data-theme='dark'] input,
html[data-theme='dark'] select,
html[data-theme='dark'] textarea {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  color-scheme: dark;
}

html[data-theme='dark'] dialog,
html[data-theme='dark'] dialog .card {
  background: var(--surface);
  color: var(--text);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-weight: 400;
  line-height: 1.5;
  background: radial-gradient(circle at 10% 0%, var(--bg-gradient-start) 0, var(--bg) 40%);
  color: var(--text);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  min-width: 0;
}

.brand-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  line-height: 0;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

a.brand-logo:hover,
a.brand-logo:focus {
  text-decoration: none;
  opacity: 1;
  outline: none;
}

.brand-logo-img {
  width: 120px;
  height: auto;
  display: block;
}

/* Claro → letras negras; oscuro → letras blancas (contraste). */
.brand-logo-dark { display: none; }
html[data-theme='dark'] .brand-logo-light { display: none; }
html[data-theme='dark'] .brand-logo-dark { display: block; }

.brand img { width: 120px; height: auto; }

.brand-user-mini,
.menu-user-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  min-width: 0;
  max-width: 220px;
}

.brand-user-mini img,
.menu-user-mini img {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--surface-muted);
}

.brand-user-mini-meta,
.menu-user-mini-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-user-mini-meta strong,
.menu-user-mini-meta strong {
  font-size: 0.74rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-user-mini-meta span,
.menu-user-mini-meta span {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.menu-user-mini {
  display: none;
}

.topbar-nav { display: flex; align-items: center; }
.topbar-nav-links { display: flex; align-items: center; gap: 14px; }
.topbar a { color: var(--text); text-decoration: none; font-weight: 500; }
.topbar a[aria-current="page"] { font-weight: 700; color: var(--primary); }

.nav-group {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.nav-group-toggle {
  list-style: none;
  cursor: pointer;
  color: var(--text);
  font-weight: 500;
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.nav-group-toggle::-webkit-details-marker { display: none; }
.nav-group-toggle::after {
  content: "▾";
  font-size: 0.7em;
  opacity: 0.7;
}
.nav-group.is-active > .nav-group-toggle,
.nav-group[open] > .nav-group-toggle {
  font-weight: 700;
  color: var(--primary);
}
.nav-group-menu {
  display: none;
  min-width: 210px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface, #fff);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
  z-index: 120;
}
.nav-group[open] > .nav-group-menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-group-link {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}
.nav-group-link:hover,
.nav-group-link:focus-visible {
  background: var(--surface-muted, #f1f5f9);
}
.nav-group-link[aria-current="page"] {
  font-weight: 700;
  color: var(--primary);
}

@media (hover: hover) and (min-width: 981px) {
  .nav-group-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
  }
  .nav-group:hover > .nav-group-menu,
  .nav-group:focus-within > .nav-group-menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
}

.topbar-menu-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  width: 42px;
  height: 38px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text);
  flex: 0 0 auto;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Backdrop eliminado: los overlays fixed bloqueaban taps en movil */
.topbar-menu-backdrop {
  display: none !important;
}

/*
  Menu movil en flujo normal (flex-wrap): empuja el contenido,
  sin position:fixed ni capas que intercepten la navegacion.
*/
.topbar.is-collapsed,
.topbar.is-mobile {
  flex-wrap: wrap;
  gap: 10px;
}

.topbar.is-collapsed .topbar-menu-toggle,
.topbar.is-mobile .topbar-menu-toggle {
  display: inline-flex;
}

.topbar.is-collapsed .brand-user-mini,
.topbar.is-mobile .brand-user-mini {
  display: none;
}

.topbar.is-collapsed .topbar-nav,
.topbar.is-mobile .topbar-nav {
  display: none;
  flex: 1 1 100%;
  width: 100%;
  order: 3;
  position: static;
  pointer-events: auto;
}

.topbar.is-collapsed .topbar-nav.is-open,
.topbar.is-mobile .topbar-nav.is-open {
  display: block;
}

.topbar.is-collapsed .topbar-nav-links,
.topbar.is-mobile .topbar-nav-links {
  display: flex;
  width: 100%;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  max-height: none;
  overflow: visible;
}

.topbar.is-collapsed .topbar-nav-links .menu-user-mini,
.topbar.is-mobile .topbar-nav-links .menu-user-mini {
  display: flex;
  width: 100%;
  max-width: none;
  border-radius: 12px;
  padding: 8px 10px;
}

.topbar.is-collapsed .topbar-nav-links a,
.topbar.is-collapsed .topbar-nav-links .btn,
.topbar.is-collapsed .topbar-nav-links .inline-form,
.topbar.is-mobile .topbar-nav-links a,
.topbar.is-mobile .topbar-nav-links .btn,
.topbar.is-mobile .topbar-nav-links .inline-form {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  touch-action: manipulation;
  position: relative;
  z-index: 1;
}

.topbar.is-collapsed .topbar-nav-links .nav-group,
.topbar.is-mobile .topbar-nav-links .nav-group {
  display: block;
  width: 100%;
}
.topbar.is-collapsed .topbar-nav-links .nav-group-toggle,
.topbar.is-mobile .topbar-nav-links .nav-group-toggle {
  width: 100%;
  min-height: 44px;
  padding: 0 4px;
  justify-content: space-between;
}
.topbar.is-collapsed .topbar-nav-links .nav-group-menu,
.topbar.is-mobile .topbar-nav-links .nav-group-menu {
  position: static;
  width: 100%;
  min-width: 0;
  margin: 4px 0 8px;
  box-shadow: none;
  border-color: var(--border);
  background: var(--surface-muted, #f8fafc);
}
.topbar.is-collapsed .topbar-nav-links .nav-group-link,
.topbar.is-mobile .topbar-nav-links .nav-group-link {
  width: 100%;
  min-height: 42px;
  padding-left: 14px;
}

.topbar.is-collapsed .topbar-nav-links .inline-form,
.topbar.is-mobile .topbar-nav-links .inline-form {
  display: block;
}

.topbar.is-collapsed .topbar-nav-links .inline-form .btn,
.topbar.is-mobile .topbar-nav-links .inline-form .btn {
  justify-content: flex-start;
  width: 100%;
}

/* CSS puro: en pantallas angostas siempre modo movil (aunque falle el JS) */
@media (max-width: 768px) {
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
  }

  .topbar .topbar-menu-toggle {
    display: inline-flex !important;
  }

  .topbar .brand-user-mini {
    display: none !important;
  }

  .topbar .topbar-nav {
    display: none;
    flex: 1 1 100%;
    width: 100%;
    order: 3;
    position: static !important;
  }

  .topbar .topbar-nav.is-open {
    display: block !important;
  }

  .topbar .topbar-nav-links {
    display: flex;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-soft);
  }

  .topbar .topbar-nav-links .menu-user-mini {
    display: flex;
    width: 100%;
    max-width: none;
  }

  .topbar .topbar-nav-links a,
  .topbar .topbar-nav-links .btn,
  .topbar .topbar-nav-links .inline-form {
    width: 100%;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .topbar .topbar-nav-links .nav-group {
    display: block;
    width: 100%;
  }
  .topbar .topbar-nav-links .nav-group-toggle {
    width: 100%;
    min-height: 44px;
    padding: 0 4px;
    justify-content: space-between;
  }
  .topbar .topbar-nav-links .nav-group-menu {
    position: static;
    width: 100%;
    min-width: 0;
    margin: 4px 0 8px;
    box-shadow: none;
    background: var(--surface-muted, #f8fafc);
  }
  .topbar .topbar-nav-links .nav-group-link {
    width: 100%;
    min-height: 42px;
    padding-left: 14px;
  }
}

.container {
  width: min(100%, calc(100% - 32px));
  max-width: 100%;
  margin: 24px auto 40px;
  display: grid;
  gap: 20px;
  min-width: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-card);
  max-width: 100%;
  min-width: 0;
}

.narrow { width: min(560px, 100%); margin: 0 auto; }

.reports-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.reports-kpi {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 12px;
}

.reports-kpi h3 {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.reports-kpi p {
  margin: 8px 0 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.reports-heatmap {
  display: grid;
  gap: 8px;
  margin: 10px 0 16px;
}

.reports-map-stage {
  display: grid;
  gap: 0;
}

.reports-map-stage:fullscreen,
.reports-map-stage:-webkit-full-screen,
.reports-map-stage.is-fullscreen {
  width: 100%;
  height: 100%;
  padding: 12px;
  box-sizing: border-box;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reports-map-stage:fullscreen .reports-map-wrap,
.reports-map-stage:-webkit-full-screen .reports-map-wrap,
.reports-map-stage.is-fullscreen .reports-map-wrap {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.reports-map-stage:fullscreen .reports-leaflet-map,
.reports-map-stage:-webkit-full-screen .reports-leaflet-map,
.reports-map-stage.is-fullscreen .reports-leaflet-map,
.reports-map-stage:fullscreen #reports-gis-canvas,
.reports-map-stage:-webkit-full-screen #reports-gis-canvas,
.reports-map-stage.is-fullscreen #reports-gis-canvas {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
}

.reports-map-wrap {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
  margin: 10px 0 14px;
  position: relative;
}

.reports-map-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
}

.reports-map-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 8px 0 12px;
}

.reports-map-mode label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--text-soft);
}

.reports-toolbar {
  margin-top: 12px;
}

.reports-filters-modal-content {
  width: min(720px, 100%);
}

.reports-leaflet-map {
  width: 100%;
  height: min(460px, 50vh);
  background: var(--surface-muted);
}

.reports-map-fallback {
  margin: 0;
  padding: 12px;
  color: #475569;
  font-size: 0.9rem;
}

.reports-map-pin-wrapper {
  background: transparent;
  border: 0;
}

.reports-map-cluster-wrapper {
  background: transparent;
  border: 0;
}

.reports-map-cluster {
  --cluster-size: 36px;
  width: var(--cluster-size);
  height: var(--cluster-size);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 800;
  color: #0f172a;
  background: color-mix(in srgb, #f59e0b 34%, #ffffff);
  border: 2px solid #d97706;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.28);
}

.reports-map-pin {
  --pin-size: 26px;
  --pin-color: #2563eb;
  width: var(--pin-size);
  height: var(--pin-size);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #0f172a;
  background: color-mix(in srgb, var(--pin-color) 28%, #ffffff);
  border: 2px solid var(--pin-color);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.24);
}

#reports-gis-canvas {
  width: 100%;
  height: min(460px, 50vh);
  display: block;
  background: var(--surface-muted);
}

#reports-gis-empty {
  padding: 8px 12px 12px;
}

.heatmap-row {
  display: grid;
  grid-template-columns: minmax(160px, 3fr) minmax(120px, 6fr) auto;
  gap: 8px;
  align-items: center;
}

.heatmap-row-label {
  font-size: 0.78rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.heatmap-row-track {
  position: relative;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: var(--surface-soft);
  overflow: hidden;
}

.heatmap-row-bar {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #0284c7);
}

.heatmap-row-value {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text);
}

.leader-cluster-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.2fr) minmax(280px, 1fr);
  gap: 14px;
  align-items: stretch;
}

.leader-cluster-grid.bottom-row {
  margin-top: 14px;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
}

.leader-cluster-table-wrap {
  max-height: 360px;
  overflow: auto;
}

.reports-chart-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  padding: 12px;
}

.reports-chart-card h3 {
  margin: 0 0 10px;
  font-size: 0.9rem;
  color: var(--text);
}

#reports-leader-bar-chart,
#reports-leader-line-chart,
#reports-leader-scatter-chart,
#reports-fc-chart {
  width: 100%;
  max-width: 100%;
  min-height: 220px;
  height: auto;
  display: block;
  border-radius: 10px;
  background: var(--surface-muted);
}

.login-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.login-brand img {
  width: 120px;
  height: auto;
}

.login-brand span {
  font-weight: 700;
  color: var(--text);
}

.login-forgot {
  margin: -4px 0 0;
  text-align: right;
}

.login-forgot button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--primary, #1d4ed8);
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: underline;
}

.password-reset-modal-content {
  width: min(440px, 100%);
}

h1, h2, h3 {
  margin-top: 0;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.muted { color: var(--muted); font-size: 0.9rem; }

.input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.invite-link-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-family: monospace;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
}

.form-grid {
  display: grid;
  gap: 14px;
  min-width: 0;
  max-width: 100%;
}
.form-grid.two-col {
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
}
.form-grid label {
  display: grid;
  gap: 6px;
  font-weight: 500;
  min-width: 0;
}
input, select, button {
  font: inherit;
}
input, select, textarea {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
textarea {
  resize: vertical;
  min-height: 120px;
}
.full-width { grid-column: 1 / -1; }

.voter-lookup-actions {
  display: grid;
  gap: 8px;
}

#friend-lookup-feedback.ok {
  color: var(--success);
  font-weight: 600;
}

#friend-lookup-feedback.error {
  color: var(--danger);
  font-weight: 600;
}

body.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
}

#candidate-message-modal {
  z-index: 240;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.modal-content {
  position: relative;
  width: min(980px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  padding: 16px;
  display: grid;
  gap: 10px;
  animation: genealogy-modal-in 0.22s ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.friend-share-modal-content {
  width: min(760px, 100%);
}

.friends-manage-modal-content {
  width: min(860px, 100%);
}

.message-groups-modal-content {
  width: min(980px, 100%);
}

.message-groups-age-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.message-groups-age-row input {
  width: 100%;
  min-width: 0;
}

.message-groups-filters select[multiple] {
  min-height: 96px;
}

.message-groups-friends-wrap {
  max-height: 320px;
  overflow: auto;
}

.message-groups-checks {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

.friend-share-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-items: start;
}

.friend-share-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

.friend-share-qr-wrap {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.friend-share-qr {
  width: min(240px, 100%);
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  object-fit: cover;
}

.voter-lookup-modal-actions {
  display: flex;
  justify-content: flex-start;
}

#friend-voter-lookup-iframe {
  width: 100%;
  min-height: 520px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
}

.btn {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}
.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-whatsapp {
  background: #25D366;
  color: #fff;
  border-color: #25D366;
}
.btn-whatsapp:hover,
.btn-whatsapp:focus {
  background: #1ebe57;
  border-color: #1ebe57;
  color: #fff;
}
.btn-whatsapp-invite {
  position: relative;
  isolation: isolate;
  animation: whatsapp-invite-spring 4s ease-in-out infinite;
}
.btn-whatsapp-invite-icon {
  position: relative;
  z-index: 1;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: block;
}
.btn-whatsapp-invite-label {
  position: relative;
  z-index: 1;
}
.btn-whatsapp-invite-shine {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
}
.btn-whatsapp-invite-shine::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 42%;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(255, 255, 255, 0.05) 35%,
    rgba(255, 255, 255, 0.55) 50%,
    rgba(255, 255, 255, 0.05) 65%,
    transparent 100%
  );
  transform: translateX(-140%);
  animation: whatsapp-invite-shine 4s ease-in-out infinite;
}
@keyframes whatsapp-invite-spring {
  0% { transform: scale(1); }
  8% { transform: scale(1.025); }
  14% { transform: scale(0.994); }
  20% { transform: scale(1.01); }
  26%, 100% { transform: scale(1); }
}
@keyframes whatsapp-invite-shine {
  0% { transform: translateX(-140%); opacity: 1; }
  24% { transform: translateX(360%); opacity: 1; }
  25%, 100% { transform: translateX(-140%); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .btn-whatsapp-invite,
  .btn-whatsapp-invite-shine::after {
    animation: none;
  }
}
.btn.ghost {
  background: transparent;
}

.inline-form { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }

.candidate-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.candidate-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-width: 190px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.candidate-tab small {
  font-weight: 500;
  color: var(--muted);
}

.candidate-tab.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.candidate-tab.is-active small {
  color: rgba(255, 255, 255, 0.88);
}

.segment-nav {
  margin-top: 12px;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-muted);
}

.segment-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}

.segment-btn.is-active {
  color: #fff;
  border-color: var(--primary);
  background: var(--primary);
}

.role-color-field {
  display: flex;
  align-items: center;
  gap: 10px;
}

.role-color-field input[type="color"] {
  width: 48px;
  height: 40px;
  padding: 2px;
  border-radius: 10px;
  cursor: pointer;
}

.role-color-field input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
}

.genealogy-tree {
  margin-top: 16px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-muted) 100%);
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

#genealogy-section,
#coordinator-genealogy-section,
#candidate-genealogy-section {
  overflow-x: hidden;
  max-width: 100%;
  min-width: 0;
}

.genealogy-p5-host {
  display: flex;
  flex-direction: column;
  min-height: 360px;
  max-height: min(85vh, 900px);
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
}

.genealogy-p5-host:fullscreen,
.genealogy-p5-host:-webkit-full-screen,
.genealogy-p5-host.is-fullscreen {
  width: 100%;
  height: 100%;
  max-height: none;
  min-height: 100%;
  border-radius: 0;
}

.genealogy-p5-host:fullscreen .genealogy-p5-canvas,
.genealogy-p5-host:-webkit-full-screen .genealogy-p5-canvas,
.genealogy-p5-host.is-fullscreen .genealogy-p5-canvas {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

.genealogy-p5-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, #93c5fd 12%);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  flex: 0 0 auto;
}

.genealogy-p5-toolbar-main {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  flex: 1 1 200px;
  max-width: 100%;
}

.genealogy-p5-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  max-width: 100%;
}

.genealogy-p5-status {
  font-size: 0.85rem;
  min-height: 1.2em;
}

.genealogy-p5-status.is-error {
  color: #b91c1c;
}

.genealogy-p5-levels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
}

.genealogy-level-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  opacity: 0.55;
}

.genealogy-role-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
}

.genealogy-role-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
}

.genealogy-p5-canvas {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 280px;
  flex: 1 1 auto;
  overflow: hidden;
  touch-action: pan-y;
  position: relative;
}

.genealogy-p5-canvas canvas {
  display: block;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  max-height: none !important;
  cursor: grab;
}

/* Modal detalle genealogía — tarjeta centrada (no fullscreen) */
.genealogy-user-modal {
  z-index: 80;
  padding: 16px;
  place-items: center;
}

.genealogy-user-modal.is-open {
  display: grid !important;
}

.genealogy-user-modal .modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.genealogy-user-modal-content {
  position: relative;
  z-index: 1;
  width: min(460px, 100%) !important;
  max-width: min(460px, 100%) !important;
  height: auto !important;
  max-height: min(88vh, 640px) !important;
  min-height: 0;
  border-radius: 16px !important;
  border: 1px solid var(--border) !important;
  margin: 0;
  padding: 16px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  display: grid;
  gap: 10px;
  box-shadow: var(--shadow-soft);
  animation: genealogy-modal-in 0.22s ease;
}

.genealogy-user-modal-content .modal-header {
  align-items: flex-start;
}

.genealogy-user-modal-content .modal-header h3 {
  margin: 2px 0 0;
  font-size: 1.15rem;
}

.genealogy-user-modal-content .modal-header .muted {
  margin: 0;
  font-size: 0.85rem;
}

.genealogy-user-modal .genealogy-modal-photo {
  width: 88px;
  height: 88px;
}

.genealogy-user-modal .genealogy-assign-box {
  margin-top: 4px;
}

@keyframes genealogy-modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.genealogy-modal-hero {
  display: flex;
  justify-content: center;
  margin: 4px 0 8px;
}

.genealogy-modal-photo {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #93c5fd;
  background: var(--surface-muted);
}

.genealogy-modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.genealogy-modal-grid div {
  background: var(--surface-muted);
  border-radius: 10px;
  padding: 10px 12px;
}

.genealogy-modal-grid dt {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.genealogy-modal-id {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: var(--text-soft);
}

.genealogy-assign-box {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-muted) 80%, #dbeafe 20%);
  display: grid;
  gap: 10px;
}

.genealogy-assign-box[hidden] {
  display: none !important;
}

.genealogy-assign-box h4 {
  margin: 0;
  font-size: 1rem;
}

.genealogy-assign-help {
  margin: 0;
  font-size: 0.85rem;
}

.genealogy-assign-label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}

.genealogy-assign-label input {
  width: 100%;
  max-width: 100%;
}

.genealogy-assign-preview {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px dashed var(--border);
  font-size: 0.9rem;
  color: var(--muted);
}

.genealogy-assign-preview.is-ok {
  border-style: solid;
  border-color: #86efac;
  color: #166534;
  background: color-mix(in srgb, #dcfce7 55%, var(--surface));
}

.genealogy-assign-preview.is-error {
  border-style: solid;
  border-color: #fca5a5;
  color: #991b1b;
  background: color-mix(in srgb, #fee2e2 55%, var(--surface));
}

.genealogy-assign-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.genealogy-assign-feedback {
  margin: 0;
  min-height: 1.2em;
  font-size: 0.85rem;
  color: var(--muted);
}

.genealogy-assign-feedback.is-error {
  color: #b91c1c;
}

.genealogy-assign-feedback.is-ok {
  color: #166534;
}

.genealogy-root {
  display: flex;
  flex-direction: column;
  gap: 32px;
  align-items: center;
}

.genealogy-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.genealogy-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
  min-width: 120px;
  max-width: 140px;
  cursor: pointer;
}

.genealogy-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  border-color: #3b82f6;
}

.genealogy-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #e2e8f0;
  background: var(--surface-muted);
}

.genealogy-info {
  text-align: center;
  width: 100%;
}

.genealogy-name {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  word-wrap: break-word;
}

.genealogy-role {
  margin: 4px 0 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: capitalize;
}

.genealogy-children {
  display: flex;
  flex-direction: row;
  gap: 24px;
  margin-top: 32px;
  padding-top: 32px;
  position: relative;
  justify-content: center;
  flex-wrap: wrap;
}

.genealogy-children::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 32px;
  background: linear-gradient(180deg, #cbd5e1 0%, transparent 100%);
}

.genealogy-children > .genealogy-node::before {
  content: '';
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 32px;
  background: #cbd5e1;
}

@media (max-width: 768px) {
  .genealogy-children {
    flex-direction: column;
    gap: 16px;
  }

  .genealogy-card {
    min-width: 100px;
    max-width: 120px;
  }

  .genealogy-avatar {
    width: 52px;
    height: 52px;
  }

  .genealogy-modal-grid {
    grid-template-columns: 1fr;
  }

  .genealogy-p5-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .genealogy-p5-actions {
    justify-content: stretch;
  }

  .genealogy-p5-actions .btn {
    flex: 1 1 auto;
  }

  .genealogy-p5-hint {
    font-size: 0.8rem;
  }
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.stats article {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface-muted);
}

.profile-home-card {
  max-width: 780px;
  margin: 0 auto;
}

.profile-home-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.profile-mini-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  padding: 4px 8px;
  border: 1px solid var(--text);
  font-weight: 700;
  font-size: 0.76rem;
  letter-spacing: 0.04em;
}

.profile-menu-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 700;
}

.profile-home-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.profile-home-welcome {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.profile-home-name {
  margin: 2px 0 6px;
  font-size: clamp(1.45rem, 2vw, 1.9rem);
}

.profile-home-meta {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.profile-avatar-placeholder {
  width: 116px;
  height: 116px;
  border-radius: 50%;
  border: 1px solid var(--text);
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 0.72rem;
  padding: 10px;
  cursor: pointer;
}

.profile-photo-upload {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.profile-photo-input {
  width: 1px;
  height: 1px;
  opacity: 0;
  position: absolute;
  pointer-events: none;
}

.profile-photo-preview {
  width: 116px;
  height: 116px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--text);
  background: var(--surface);
}

.profile-photo-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
}

.profile-photo-actions .btn {
  font-size: 0.78rem;
  padding: 6px 12px;
}

.profile-qr-block {
  margin-top: 18px;
  display: grid;
  justify-items: center;
  gap: 8px;
}

.profile-qr-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
}

.profile-qr-help {
  margin: 0;
  text-align: center;
  max-width: 380px;
}

.profile-qr-image {
  width: 240px;
  max-width: 100%;
  border: 6px solid var(--surface);
  box-shadow: var(--shadow-soft);
}

.referral-qr-panel {
  margin-top: 18px;
  width: 100%;
}

.referral-flyer-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
  width: 100%;
}

.referral-flyer-card-panel {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 8px;
}

.referral-flyer-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.referral-flyer {
  position: relative;
  width: min(100%, 300px);
  aspect-ratio: 3 / 4;
  container-type: inline-size;
  border-radius: 16px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: var(--shadow-card, 0 8px 24px rgba(15, 23, 42, 0.12));
  border: 1px solid var(--border);
  touch-action: none;
}

.referral-flyer-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  transform: scale(1);
  transform-origin: center center;
  pointer-events: none;
  user-select: none;
}

.referral-flyer-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.referral-drag {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  width: max-content;
  max-width: 86%;
  cursor: grab;
  user-select: none;
  touch-action: none;
  text-align: center;
  color: #111827;
}

.referral-drag[data-drag="welcome"] { left: 50%; top: 8%; }
.referral-drag[data-drag="candidate"] { left: 50%; top: 14%; }
.referral-drag[data-drag="qr"] { left: 50%; top: 42%; }
.referral-drag[data-drag="owner"] { left: 50%; top: 66%; }
.referral-drag[data-drag="invite"] { left: 50%; top: 74%; }
.referral-drag[data-drag="scan"] { left: 50%; top: 80%; }
.referral-drag[data-drag="tech"] { left: 88%; top: 94%; }

.referral-drag.is-dragging {
  cursor: grabbing;
  z-index: 5;
}

.referral-flyer-welcome,
.referral-flyer-line,
.referral-flyer-owner {
  font-size: 3.9cqw;
  line-height: 1.25;
  font-weight: 500;
  white-space: normal;
  word-break: break-word;
}

.referral-flyer-candidate {
  font-size: 5.5cqw;
  font-weight: 800;
  line-height: 1.15;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #2d63c8;
}

.referral-flyer-qr-box {
  width: 42%;
  aspect-ratio: 1;
  max-width: 200px;
  background: #fff;
  border-radius: 12px;
  padding: 8px;
  box-sizing: border-box;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.08);
}

.referral-flyer-qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border: none;
  box-shadow: none;
  pointer-events: none;
}

.referral-template-note {
  margin: 0;
  text-align: center;
}

.referral-flyer-tech {
  font-size: 3cqw;
  color: #4b5563;
  max-width: 46%;
  text-align: right;
}

.referral-flyer-controls {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface, #fff);
  box-shadow: var(--shadow-soft, 0 4px 14px rgba(15, 23, 42, 0.06));
  box-sizing: border-box;
}

.referral-controls-toggle[hidden] {
  display: none !important;
}

.referral-controls-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text, #111827);
}

.referral-controls-toggle-icon {
  transition: transform 0.25s ease;
}

.referral-controls-toggle[aria-expanded="true"] .referral-controls-toggle-icon {
  transform: rotate(180deg);
}

.referral-controls-body {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.25s ease;
  max-height: 600px;
  opacity: 1;
}

.referral-controls-body.hidden {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

.referral-flyer-controls h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 700;
}

.referral-flyer-controls-subtitle {
  margin-top: 12px !important;
}

.referral-flyer-controls label:not(.referral-color-label) {
  display: grid;
  grid-template-columns: 14px 1fr;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--muted);
}

.referral-flyer-controls input[type="range"] {
  display: block;
  width: 100%;
  margin: 0;
  height: 16px;
}

.referral-color-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 6px 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.referral-color-label input[type="color"] {
  width: 42px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.referral-flyer-controls-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.referral-flyer-controls-actions .btn {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  font-size: 0.8rem;
}

.referral-flyer-controls-actions .btn:nth-child(3) {
  grid-column: 1 / -1;
}

.referral-download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: min(100%, 300px);
  margin: 12px auto 0;
  min-height: 44px;
  border-radius: 10px;
  font-size: 0.9rem;
}

.referral-download-icon {
  flex-shrink: 0;
}

#referral-qr-feedback {
  margin-top: 8px;
  font-size: 0.75rem;
}

@media (min-width: 900px) {
  .referral-flyer-layout:has(.referral-flyer-controls:not(.hidden)) {
    grid-template-columns: minmax(280px, 340px) minmax(240px, 1fr);
    max-width: 720px;
    margin: 0 auto;
  }

  .referral-flyer-layout:has(.referral-flyer-controls:not(.hidden)) .referral-flyer-controls {
    margin: 0;
    max-width: none;
  }

  .referral-flyer-layout:has(.referral-flyer-controls:not(.hidden)) .referral-flyer {
    width: 100%;
    max-width: 320px;
  }
}

@media (min-width: 1080px) {
  .profile-home-card.profile-home-split {
    max-width: none;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(400px, 460px);
    column-gap: 20px;
    row-gap: 12px;
    align-items: stretch;
  }

  .profile-home-card.profile-home-split > .profile-home-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100%;
  }

  .profile-home-card.profile-home-split .profile-home-head {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 14px;
  }

  .profile-home-card.profile-home-split > .referral-qr-panel {
    grid-column: 2;
    grid-row: 1;
    margin-top: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px 16px 14px;
    background: var(--surface);
  }

  .profile-home-card.profile-home-split .referral-flyer-layout,
  .profile-home-card.profile-home-split .referral-flyer-card-panel,
  .profile-home-card.profile-home-split .referral-flyer-wrap {
    width: 100%;
    justify-items: center;
  }

  .profile-home-card.profile-home-split .referral-flyer-layout:has(.referral-flyer-controls:not(.hidden)) {
    grid-template-columns: 1fr;
    max-width: none;
    margin: 0;
  }

  .profile-home-card.profile-home-split .referral-flyer-controls {
    max-width: none;
    margin-top: 12px;
  }

  .profile-home-card.profile-home-split .profile-qr-title {
    width: 100%;
    text-align: center;
    margin: 0 0 8px;
  }

  .profile-home-card.profile-home-split .referral-download-btn {
    width: 100%;
    max-width: none;
    min-height: 46px;
    margin: auto 0 0;
    border-radius: 12px;
  }

  .profile-home-card.profile-home-split .referral-flyer {
    width: 100%;
    max-width: none;
  }

  .profile-home-card.profile-home-split .candidate-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
  }

  .profile-home-card.profile-home-split .candidate-tab {
    flex: 1 1 calc(50% - 10px);
    max-width: calc(50% - 5px);
    min-width: 0;
    min-height: 58px;
    border-radius: 12px;
    justify-content: center;
  }

  .profile-home-card.profile-home-split .profile-cta-group {
    justify-content: flex-start;
    align-items: center;
    margin-top: 12px;
  }

  .profile-home-card.profile-home-split .profile-cta-group > .btn,
  .profile-home-card.profile-home-split .profile-cta-group > .profile-cta-dropdown > summary {
    min-height: 42px;
    border-radius: 10px;
  }

  .profile-home-card.profile-home-split .profile-total-banner {
    width: 100%;
    max-width: none;
    min-height: 46px;
    margin: auto 0 0;
    border-radius: 12px;
    background: #e7f6fb;
    color: #0b3b66;
    border: 1px solid #b7e4f4;
    font-size: 1rem;
    text-align: left;
    display: flex;
    align-items: center;
  }

  .profile-home-card.profile-home-split .profile-photo-upload {
    display: block;
    width: 56px;
  }

  .profile-home-card.profile-home-split .profile-avatar-placeholder,
  .profile-home-card.profile-home-split .profile-photo-preview {
    width: 56px;
    height: 56px;
  }

  .profile-home-card.profile-home-split .profile-photo-actions {
    justify-content: flex-end;
    align-self: start;
    margin-top: 0;
  }

  .profile-home-card.profile-home-split .profile-photo-actions .btn {
    min-height: 34px;
    padding: 6px 12px;
    border-radius: 8px;
  }
}

.profile-cta-group {
  margin-top: 14px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.profile-cta-dropdown {
  position: relative;
  display: inline-block;
}

.profile-cta-dropdown > summary {
  list-style: none;
}

.profile-cta-dropdown > summary::-webkit-details-marker {
  display: none;
}

.profile-cta-dropdown > summary::after {
  content: "▾";
  font-size: 0.8em;
  line-height: 1;
}

.profile-cta-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  min-width: 240px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
}

.profile-cta-menu a {
  display: block;
  padding: 10px 12px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  border-radius: 8px;
}

.profile-cta-menu a:hover,
.profile-cta-menu a:focus {
  background: var(--surface-soft);
}

.coord-barrio-options {
  display: grid;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted, var(--surface));
}

.coord-barrio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 0.86rem;
  margin: 0;
}

.coord-barrio-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
}

.municipio-typeahead-select {
  display: block;
  width: 100%;
  margin-top: 6px;
  min-height: 120px;
  max-height: 160px;
}

.friend-name-with-dot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.vote-place-dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  flex-shrink: 0;
  vertical-align: middle;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
}

.vote-place-dot.is-missing {
  background: #dc2626;
}

.vote-place-dot.is-ready {
  background: #16a34a;
}

.vote-place-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.message-groups-checks {
  max-height: 180px;
  overflow: auto;
  border: 1px solid color-mix(in srgb, var(--muted) 35%, transparent);
  padding: 8px 10px;
  margin-bottom: 8px;
}

.hidden-accessory-fields {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.profile-total-banner {
  margin: 14px auto 0;
  width: min(420px, 100%);
  text-align: center;
  padding: 10px 14px;
  border: 1px solid #0b6cff;
  border-radius: 0;
  background: #16a6db;
  color: #fff;
  font-weight: 800;
  font-size: 1.25rem;
  line-height: 1.25;
}

.profile-legal-note {
  margin: 10px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.68rem;
}

.profile-counts {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  font-size: 1.05rem;
  font-weight: 700;
}

.profile-counts strong {
  font-size: 1.35rem;
}

.site-footer {
  margin-top: 32px;
  padding: 18px 16px 28px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.site-footer p {
  margin: 0;
}

.topbar-notify-btn {
  position: relative;
  width: 40px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.topbar-notify-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.candidate-message-modal-content {
  width: min(520px, 100%);
}

.candidate-message-modal-body {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.45;
}

.candidate-message-channels {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.form-grid .channel-check {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin: 0;
}

.form-grid .channel-check input {
  width: auto;
  margin: 0;
}

.alert {
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-weight: 600;
}
.alert.error { background: #fdecea; color: var(--danger); border: 1px solid #f7c7c3; }
.alert.success { background: #e9f8ef; color: #0a7d42; border: 1px solid #b6e7ca; }
.hidden { display: none !important; }

.captcha-status {
  border: 1px dashed #94a3b8;
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface-muted);
  font-weight: 600;
}

.captcha-status.ok {
  border-style: solid;
  border-color: #86efac;
  color: #166534;
  background: #f0fdf4;
}

.captcha-status.error {
  border-style: solid;
  border-color: #fecaca;
  color: #b91c1c;
  background: #fef2f2;
}

table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--border); padding: 10px 8px; text-align: left; font-size: 0.95rem; }
.table-wrap { overflow-x: auto; }

button:disabled,
.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.permission-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--surface);
  font-weight: 500;
}

.permission-item input {
  margin-top: 2px;
}

.permission-item span {
  display: grid;
  gap: 3px;
}

.permission-item small {
  color: var(--muted);
  font-size: 0.82rem;
}

.user-photo-preview {
  display: grid;
  justify-items: start;
  gap: 8px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface-muted);
}

.user-avatar {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--surface);
}

.user-avatar.list {
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

.map-placeholder {
  height: 180px;
  border: 1px dashed #94a3b8;
  border-radius: 12px;
  display: grid;
  place-items: center;
  margin-bottom: 10px;
  background: repeating-linear-gradient(45deg, var(--surface-muted), var(--surface-muted) 12px, var(--surface-soft) 12px, var(--surface-soft) 24px);
}

.theme-toggle-btn {
  min-width: 112px;
}

.topbar-theme-pwa {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.topbar-theme-pwa .theme-toggle-btn {
  min-width: auto;
}

.pwa-install-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  width: 40px;
  height: 40px;
  padding: 0;
}

.pwa-install-icon {
  flex-shrink: 0;
}

.topbar-pwa-hint {
  width: 100%;
  margin: 4px 0 0;
  text-align: right;
  font-size: 0.72rem;
}

.topbar.is-collapsed .topbar-nav-links .topbar-theme-pwa,
.topbar.is-mobile .topbar-nav-links .topbar-theme-pwa {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
  justify-content: stretch;
  gap: 8px;
}

.topbar.is-collapsed .topbar-nav-links .topbar-theme-pwa .btn,
.topbar.is-mobile .topbar-nav-links .topbar-theme-pwa .btn {
  flex: 1 1 auto;
  min-width: 0;
}

.topbar.is-collapsed .topbar-nav-links .topbar-pwa-hint,
.topbar.is-mobile .topbar-nav-links .topbar-pwa-hint {
  text-align: left;
}

@media (max-width: 768px) {
  .topbar { gap: 10px; }
  .brand {
    gap: 8px;
    min-width: 0;
    flex: 1;
  }
  .brand-head {
    min-width: 0;
    gap: 6px;
  }
  .brand-head span {
    font-size: 0.95rem;
    line-height: 1.1;
    white-space: nowrap;
  }
  .brand img,
  .brand-logo-img { width: 100px; }
  .login-brand img,
  .login-brand .brand-logo-img { width: 100px; }
  .brand-user-mini {
    display: none;
  }

  .topbar-menu-toggle {
    width: 36px;
    height: 34px;
  }

  .login-brand img {
    width: 104px;
  }

  .login-brand span {
    font-size: 0.95rem;
    line-height: 1.1;
  }

  .profile-home-head {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .heatmap-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .reports-map-mode {
    gap: 8px;
  }

  .reports-map-mode label {
    font-size: 0.82rem;
  }

  #reports-gis-canvas {
    height: min(340px, 46vh);
  }

  .reports-leaflet-map {
    height: min(340px, 46vh);
  }

  .leader-cluster-grid,
  .leader-cluster-grid.bottom-row {
    grid-template-columns: 1fr;
  }

  .profile-home-meta {
    font-size: 0.72rem;
  }

  .profile-total-banner {
    font-size: 1.3rem;
  }

  .segment-nav {
    width: 100%;
  }

  .segment-btn {
    flex: 1 1 calc(50% - 8px);
    text-align: center;
  }
}

/* Eventos — flyer QR */
.modal-dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  max-width: min(96vw, 480px);
  background: transparent;
}
.modal-dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
}

.network-performance-search-label {
  min-width: min(100%, 260px);
  flex: 1 1 220px;
}

#network-performance-table th:nth-child(2),
#network-performance-table td:nth-child(2) {
  min-width: 220px;
}

.network-performance-name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
  width: max-content;
  max-width: 100%;
}

.network-performance-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2.5px solid #64748b;
  background: var(--surface-muted, #f1f5f9);
  flex: 0 0 36px;
}

.network-performance-name-link {
  flex: 0 1 auto;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.network-origin-modal-card {
  margin: 0;
  min-width: min(100%, 420px);
  max-width: min(96vw, 520px);
  background: var(--surface);
  box-sizing: border-box;
}

.network-origin-modal-card.is-fullscreen,
.network-origin-modal-card:fullscreen,
.network-origin-modal-card:-webkit-full-screen {
  width: 100%;
  max-width: none;
  min-width: 0;
  height: 100%;
  max-height: none;
  margin: 0;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 20px 20px;
}

.network-origin-modal-card.is-fullscreen .network-origin-chain,
.network-origin-modal-card:fullscreen .network-origin-chain,
.network-origin-modal-card:-webkit-full-screen .network-origin-chain,
.network-origin-chain.is-fullscreen-chain {
  flex: 1 1 auto;
  max-height: none;
  min-height: 0;
  justify-content: flex-start;
  padding-top: 16px;
}

.network-origin-modal-toolbar {
  flex: 0 0 auto;
}

.network-origin-export-btn[hidden] {
  display: none !important;
}

.network-origin-modal-card.is-fullscreen .network-origin-export-btn,
.network-origin-modal-card:fullscreen .network-origin-export-btn,
.network-origin-modal-card:-webkit-full-screen .network-origin-export-btn {
  display: inline-flex;
}

.network-origin-chain {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px 4px 4px;
  text-align: center;
  max-height: min(70vh, 640px);
  overflow: auto;
}

.network-origin-legend {
  justify-content: center;
  margin-bottom: 4px;
}

.network-origin-cards {
  width: 100%;
  gap: 0;
}

.network-origin-node {
  width: 100%;
}

.network-origin-card {
  position: relative;
  overflow: hidden;
  background: color-mix(in srgb, var(--origin-role-color, #64748b) 18%, var(--surface));
  border-width: 2px;
  min-width: 150px;
  max-width: 200px;
  cursor: default;
}

a.network-origin-card-link {
  display: flex;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

a.network-origin-card-link:hover,
a.network-origin-card-link:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.18);
  outline: none;
}

.network-origin-card::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 6px;
  background: var(--origin-role-color, #64748b);
}

.network-origin-card .genealogy-name {
  font-size: 0.9rem;
}

.network-origin-card .genealogy-role {
  font-size: 0.72rem;
  text-transform: none;
  letter-spacing: 0.02em;
  opacity: 0.92;
}

.network-origin-arrow {
  font-size: 1.25rem;
  line-height: 1;
  opacity: 0.75;
  user-select: none;
  margin: 6px 0;
  color: var(--muted);
}

.network-origin-btn {
  white-space: nowrap;
}

.network-contact-modal-card {
  margin: 0;
  min-width: min(100%, 420px);
  max-width: min(96vw, 520px);
  background: var(--surface);
  box-sizing: border-box;
}

.network-contact-body {
  margin-top: 12px;
}

.network-contact-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.network-contact-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #64748b;
  background: var(--surface-muted, #f1f5f9);
  flex: 0 0 auto;
}

.network-contact-name {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.3;
}

.network-contact-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 0;
}

.network-contact-field {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  align-items: start;
  padding: 8px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-muted, #f1f5f9) 70%, transparent);
}

.network-contact-field dt {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.network-contact-field dd {
  margin: 0;
  word-break: break-word;
}

@media (max-width: 480px) {
  .network-contact-field {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

.network-origin-step {
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}

.network-origin-step.is-candidate {
  letter-spacing: 0.04em;
  opacity: 0.92;
}
.event-detail-split {
  display: grid;
  gap: 16px;
  align-items: start;
}

.event-detail-flyer-col,
.event-detail-attendees-col {
  min-width: 0;
}

.event-detail-attendees-col .table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 960px) {
  .event-detail-split {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  }

  .event-detail-flyer-col {
    position: sticky;
    top: 12px;
  }
}

.event-flyer-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 320px;
}
.event-flyer-controls {
  width: 100%;
  max-width: 300px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted, #f8fafc);
  box-sizing: border-box;
}
.event-flyer-controls h3 {
  margin: 0 0 6px;
  font-size: 0.8rem;
  font-weight: 700;
}
.event-flyer-controls label {
  display: grid;
  grid-template-columns: 14px 1fr;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  font-weight: 600;
  font-size: 0.72rem;
  color: var(--muted);
}
.event-flyer-controls input[type="range"] {
  display: block;
  width: 100%;
  margin: 0;
  height: 16px;
}
.event-flyer-controls-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}
.event-flyer-controls-actions .btn {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  font-size: 0.78rem;
}
.event-flyer-controls-actions .btn:nth-child(4),
.event-flyer-controls-actions .btn:nth-child(5) {
  grid-column: 1 / -1;
}
.event-flyer-controls #event-attendance-link {
  margin: 8px 0 0;
  font-size: 0.68rem;
  word-break: break-all;
}
.event-flyer-wrap {
  display: flex;
  justify-content: center;
  margin: 0;
  width: 100%;
}
.event-flyer {
  position: relative;
  width: min(100%, 300px);
  aspect-ratio: 3 / 4;
  border: none;
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-card, 0 8px 24px rgba(15, 23, 42, 0.12));
  background: #0b1630;
  touch-action: none;
}
.event-flyer-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 50%;
  transform: scale(1);
  transform-origin: center center;
  display: block;
  pointer-events: none;
  user-select: none;
}
.event-flyer-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.event-drag {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  max-width: 90%;
  text-align: center;
}
.event-drag.is-dragging {
  cursor: grabbing;
  z-index: 5;
  outline: 1px dashed rgba(255,255,255,.7);
}
.event-drag[data-drag="qr"] {
  width: 52%;
}
.event-flyer-qr-box {
  width: 100%;
  aspect-ratio: 1;
  background: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
  box-sizing: border-box;
  box-shadow: 0 8px 20px rgba(0,0,0,.18);
  pointer-events: none;
}
.event-flyer-qr-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
}
.event-flyer-event {
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,.55);
  white-space: nowrap;
}
.event-flyer-candidate {
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,.55);
  white-space: nowrap;
}
.btn-whatsapp-channel {
  background: #16a34a !important;
  border-color: #15803d !important;
  color: #fff !important;
}

/* PWA campo /campo */
.field-app-body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg, #e2e8f0);
}
.field-app-main {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 14px 28px;
  box-sizing: border-box;
}
.field-app-header {
  text-align: center;
  margin-bottom: 14px;
}
.field-app-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.field-app-install-hint {
  margin: 0 0 10px;
  text-align: center;
}
.field-app-logo-wrap {
  display: inline-flex;
  justify-content: center;
  margin: 0 auto 10px;
}
.field-app-logo-wrap .brand-logo-img {
  width: min(100%, 200px);
  height: auto;
  max-height: 48px;
  object-fit: contain;
  margin: 0;
}
.field-app-welcome {
  margin: 0;
  font-size: 0.9rem;
}
.field-app-meta {
  margin: 2px 0;
  font-size: 0.82rem;
  color: var(--muted);
}
.field-app-card {
  margin-bottom: 14px;
}
.field-app-title {
  margin: 0 0 6px;
  font-size: 1.15rem;
}
.field-app-qr-wrap {
  display: flex;
  justify-content: center;
  margin: 12px 0;
}
.field-app-qr {
  width: 220px;
  max-width: 100%;
  border: 6px solid var(--surface, #fff);
  box-shadow: var(--shadow-soft);
}
.field-app-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 10px 0;
}
.field-app-toolbar.topbar-theme-pwa {
  justify-content: center;
}
.field-app-install-hint {
  margin: 0 0 10px;
  text-align: center;
}
.field-app-footer {
  text-align: center;
  margin: 8px 0 0;
}
@media (max-width: 480px) {
  .field-app-main {
    padding: 12px 10px 24px;
  }
  .field-app-qr {
    width: 200px;
  }
}

.barrios-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.barrios-toolbar .muted {
  margin: 6px 0 0;
}
.barrios-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}
.btn.icon {
  width: 38px;
  min-width: 38px;
  padding: 8px;
  gap: 0;
}
.btn.icon svg {
  display: block;
}
.barrio-map-btn.is-missing {
  color: #b91c1c;
  border-color: #fecaca;
}
.barrio-map-btn.has-coords {
  color: #0f766e;
}
.barrio-map-modal-content {
  width: min(760px, 100%);
}
#barrio-map-modal,
#barrio-form-modal,
#barrios-filters-modal,
#barrio-import-modal {
  z-index: 220;
}
.barrio-import-modal-content {
  width: min(640px, 100%);
}
.barrio-import-result {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-muted);
  max-height: min(280px, 40vh);
  overflow: auto;
}
.barrio-import-summary {
  margin: 0.35rem 0 0.75rem;
  padding-left: 1.2rem;
}
.barrio-map-host {
  width: 100%;
  height: min(380px, 46vh);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-muted);
  border: 1px solid var(--border);
}
@media (max-width: 768px) {
  .barrio-map-host {
    height: min(300px, 42vh);
  }
  .barrios-actions {
    flex-wrap: wrap;
  }
}

.profile-honor-medal {
  position: relative;
  display: block;
  margin-top: 8px;
  line-height: 0;
  text-decoration: none;
}
.profile-honor-medal img {
  position: relative;
  z-index: 1;
  width: 96px;
  height: 96px;
  object-fit: contain;
  display: block;
  transform-origin: center;
  animation: honor-medal-turn 0.85s ease-in-out 1 both;
}
.profile-honor-medal-bits {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 0;
  height: 0;
  z-index: 2;
  pointer-events: none;
}
.profile-honor-medal-bits i {
  position: absolute;
  left: 0;
  top: 0;
  width: 6px;
  height: 9px;
  border-radius: 1px;
  opacity: 0;
  animation: honor-medal-bit 0.85s ease-out 1 both;
}
.profile-honor-medal-bits i:nth-child(1) { background: #fde68a; --x: -34px; --y: -28px; --r: -40deg; }
.profile-honor-medal-bits i:nth-child(2) { background: #fb7185; --x: 8px; --y: -36px; --r: 28deg; animation-delay: 0.04s; }
.profile-honor-medal-bits i:nth-child(3) { background: #fff; --x: 36px; --y: -16px; --r: 55deg; animation-delay: 0.08s; }
.profile-honor-medal-bits i:nth-child(4) { background: #fbbf24; --x: 32px; --y: 10px; --r: -20deg; width: 8px; height: 4px; }
.profile-honor-medal-bits i:nth-child(5) { background: #fecaca; --x: -18px; --y: 30px; --r: 36deg; animation-delay: 0.06s; }
.profile-honor-medal-bits i:nth-child(6) { background: #f59e0b; --x: 14px; --y: 32px; --r: -48deg; width: 4px; height: 10px; }
.profile-honor-medal-bits i:nth-child(7) { background: #fff; --x: -36px; --y: 2px; --r: 18deg; width: 8px; height: 4px; }
.profile-honor-medal-bits i:nth-child(8) { background: #fde68a; --x: 4px; --y: -12px; --r: -70deg; animation-delay: 0.1s; width: 3px; height: 8px; }
.profile-home-card.profile-home-split .profile-home-head {
  grid-template-columns: 96px minmax(0, 1fr) auto;
}
.profile-home-card.profile-home-split .profile-photo-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 96px;
}
.profile-home-card.profile-home-split .profile-honor-medal img {
  width: 84px;
  height: 84px;
}
.profile-honor-medal.is-locked img {
  filter: grayscale(1);
  opacity: 0.38;
}
@keyframes honor-medal-turn {
  0% { transform: skewX(0deg) scaleX(1) scaleY(1); }
  42% { transform: skewX(-18deg) scaleX(0.08) scaleY(1); }
  100% { transform: skewX(0deg) scaleX(1) scaleY(1); }
}
@keyframes honor-medal-bit {
  0% { opacity: 0; transform: translate(0, 0) rotate(0deg); }
  36% { opacity: 1; transform: translate(0, 0) rotate(0deg); }
  100% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--r)); }
}
@media (prefers-reduced-motion: reduce) {
  .profile-honor-medal img,
  .logro-card.is-unlocked .logro-medal,
  .logro-card.is-unlocked::after,
  .profile-honor-medal-bits i {
    animation: none;
  }
}
.logros-kicker {
  margin: 0 0 4px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
}
.logros-page h1 {
  margin: 0 0 8px;
}
.logros-count {
  margin: 14px 0 4px;
  font-size: 1.15rem;
  font-weight: 700;
}
.logros-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.logro-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 16px 12px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}
.logro-card.is-unlocked {
  position: relative;
  border-color: #d4a017;
  box-shadow: 0 0 0 1px rgba(212, 160, 23, 0.35);
}
@property --logro-shine {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
.logro-card.is-unlocked::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 3px;
  background: conic-gradient(
    from var(--logro-shine),
    rgba(212, 160, 23, 0.2) 0deg,
    rgba(212, 160, 23, 0.2) 230deg,
    rgba(255, 214, 102, 0.95) 292deg,
    #fff 328deg,
    #fff 342deg,
    #ffd15c 360deg
  );
  filter: drop-shadow(0 0 5px rgba(255, 214, 120, 0.9));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  animation: logro-bevel-shine 2.4s linear infinite;
  pointer-events: none;
  z-index: 3;
}
@keyframes logro-bevel-shine {
  to { --logro-shine: 360deg; }
}
.logro-medal-stage {
  position: relative;
  display: block;
  line-height: 0;
}
.logro-medal {
  width: 132px;
  height: 132px;
  object-fit: contain;
}
.logro-card.is-unlocked .logro-medal {
  transform-origin: center;
  animation: honor-medal-turn 0.85s ease-in-out 1 both;
}
.logro-card.is-locked .logro-medal {
  filter: grayscale(1);
  opacity: 0.38;
}
.logro-order {
  font-size: 0.75rem;
  color: var(--muted);
}
.logro-card h2 {
  margin: 0;
  font-size: 1.05rem;
}
.logro-tier,
.logro-summary {
  margin: 0;
}

