:root {
  --bg: #fcfcfc;
  --card: #ffffff;
  --ink: #000000;
  --text: #2d2d2d;
  --muted: #898989;
  --accent: #0368fe;
  --accent-soft: #e8f0ff;
  --chip: #f2f2f2;
  --border: #ebebeb;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 12px 32px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Red Hat Display", -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}

.topbar {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  right: 0;
  background: #ffffffcc;
  color: #2d2d2d;
  border-bottom: 1px solid #ebebeb;
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 72px;
  padding: 0 24px;
  white-space: nowrap;
}
.header-leading,
.header-trailing {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.header-trailing { flex-shrink: 0; }
.header-logo {
  display: flex;
  flex-shrink: 0;
  color: inherit;
  text-decoration: none;
}
.combination-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 24px;
  color: #2d2d2d;
  font-size: 15.6px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
}
.combination-mark svg {
  display: block;
  height: 100%;
  width: auto;
  fill: currentColor;
}
.top-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 15px;
  font-weight: 600;
}
.sep { color: #898989; }
.mes { flex-shrink: 0; font-weight: 600; font-size: 14px; color: #898989; }

#map { position: absolute; inset: 72px 0 0; }

.panel {
  position: absolute;
  z-index: 2;
  top: 88px;
  left: 16px;
  width: min(380px, calc(100vw - 32px));
  max-height: calc(100vh - 104px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 1.15rem 1.15rem 0.9rem;
}
.kicker {
  margin: 0;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
h1 {
  margin: 0.2rem 0 0.25rem;
  font-size: 1.55rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.15;
}
.lede { margin: 0; color: var(--muted); font-size: 0.9rem; font-weight: 600; line-height: 1.4; }
.field { display: block; margin: 0.9rem 0 0.35rem; font-size: 0.78rem; font-weight: 800; color: var(--muted); }
select {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--chip);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}
.buscador { position: relative; margin-top: 0.9rem; }
.buscador input {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--chip);
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
}
.buscador input:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: var(--card); }
.sugerencias {
  position: absolute;
  z-index: 5;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  max-height: 320px;
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.sugerencias li { padding: 0.45rem 0.55rem; border-radius: 10px; cursor: pointer; }
.sugerencias li.activa, .sugerencias li:hover { background: var(--accent-soft); }
.sugerencias .sug-nombre { display: block; font-size: 0.86rem; font-weight: 800; color: var(--ink); }
.sugerencias .sug-nombre mark { background: transparent; color: var(--accent); }
.sugerencias .sug-lugar { display: block; margin-top: 0.05rem; font-size: 0.72rem; font-weight: 600; color: var(--muted); }
.sugerencias .sug-vacio { cursor: default; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.legend { display: flex; align-items: center; gap: 0.45rem; margin: 0.7rem 0 0.2rem; font-size: 0.72rem; font-weight: 700; color: var(--muted); }
.ramp { flex: 1; height: 8px; border-radius: 999px; }
.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-top: 0.75rem;
}
.metric {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.55rem 0.65rem;
}
.metric .value { display: block; font-weight: 900; color: var(--ink); font-size: 1.02rem; letter-spacing: -0.02em; }
.metric .label { display: block; margin-top: 0.1rem; color: var(--muted); font-size: 0.72rem; font-weight: 700; }
.metric.wide { grid-column: 1 / -1; }
.rank-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; margin-top: 0.95rem; }
.rank-head h2 { margin: 0; font-size: 0.95rem; font-weight: 900; color: var(--ink); }
.text-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  padding: 0;
}
.ranking { list-style: none; margin: 0.45rem 0 0; padding: 0; }
.ranking li button {
  width: 100%;
  display: grid;
  grid-template-columns: 1.6rem 1fr auto;
  gap: 0.45rem;
  align-items: center;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  font: inherit;
  padding: 0.48rem 0.15rem;
  cursor: pointer;
  color: var(--text);
}
.ranking li button:hover, .ranking li button.active { background: var(--accent-soft); }
.rank-n { font-weight: 900; color: var(--accent); font-size: 0.82rem; }
.rank-name { font-weight: 700; font-size: 0.88rem; }
.rank-score { font-weight: 800; color: var(--ink); font-size: 0.82rem; }
.metodo { margin: 0.8rem 0 0.2rem; color: var(--muted); font-size: 0.78rem; font-weight: 600; line-height: 1.45; }
.metodo summary { cursor: pointer; font-weight: 800; color: var(--text); }
.metodo p { margin: 0.45rem 0 0; }
.panel.ancho { width: min(560px, calc(100vw - 32px)); }
.toggle { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.8rem; font-size: 0.8rem; font-weight: 800; color: var(--ink); cursor: pointer; }
.toggle input { accent-color: var(--accent); }
.des-legend { display: flex; flex-wrap: wrap; gap: 0.3rem 0.7rem; margin-top: 0.35rem; font-size: 0.72rem; font-weight: 700; color: var(--muted); }
.des-legend span { display: inline-flex; align-items: center; gap: 0.3rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18); }
.desarrollo { margin-top: 0.75rem; }
.desarrollo h3 { margin: 1rem 0 0.4rem; font-size: 0.88rem; font-weight: 900; color: var(--ink); }
.desarrollo .aviso { margin: 0.5rem 0 0; font-size: 0.76rem; font-weight: 700; color: #a15c00; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 0.8rem; margin: 0; font-size: 0.8rem; }
.kv dt { color: var(--muted); font-weight: 700; }
.kv dd { margin: 0; color: var(--ink); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip { background: var(--chip); border-radius: 999px; padding: 0.22rem 0.6rem; font-size: 0.74rem; font-weight: 700; color: var(--ink); }
.tabla-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.tabla { border-collapse: collapse; font-size: 0.74rem; white-space: nowrap; }
.tabla th, .tabla td { padding: 0.35rem 0.55rem; border-bottom: 1px solid var(--border); text-align: right; }
.tabla th { position: sticky; top: 0; background: var(--chip); color: var(--muted); font-weight: 800; }
.tabla td { color: var(--ink); font-weight: 600; }
.tabla th:first-child, .tabla td:first-child { text-align: left; }
.fila-btns { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; margin-top: 0.55rem; }
.btn-primario {
  display: block;
  width: 100%;
  margin-top: 0.7rem;
  padding: 0.7rem 1rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn-primario:hover { background: #0256d4; }
.btn-primario:disabled { opacity: 0.6; cursor: progress; }
.analisis { margin-top: 0.9rem; padding-top: 0.2rem; border-top: 1px solid var(--border); }
.analisis h3 { margin-top: 1.2rem; }
.analisis h4 { margin: 0.9rem 0 0.3rem; font-size: 0.8rem; font-weight: 900; color: var(--ink); }
.score-hero { display: flex; align-items: center; gap: 0.9rem; margin-top: 0.8rem; padding: 0.8rem 0.9rem; border-radius: 16px; background: var(--chip); }
.score-hero .score-n { font-size: 2.3rem; font-weight: 900; letter-spacing: -0.04em; color: var(--ink); }
.score-hero .score-de { font-size: 0.85rem; font-weight: 800; color: var(--muted); }
.score-hero strong { display: block; font-size: 0.95rem; font-weight: 900; color: var(--ink); }
.score-hero span { font-size: 0.76rem; font-weight: 600; color: var(--muted); }
.score-hero.alto { background: #e7f6ee; }
.score-hero.medio { background: #fff4df; }
.score-hero.bajo { background: #fdecec; }
.barras, .prev { display: grid; gap: 0.35rem; margin-top: 0.7rem; }
.barra { display: grid; grid-template-columns: minmax(0, 1.5fr) 1fr 2.2rem; gap: 0.5rem; align-items: center; font-size: 0.74rem; font-weight: 700; }
.barra-label { color: var(--text); }
.barra-label em { font-style: normal; color: var(--muted); font-weight: 600; }
.barra-track { height: 7px; border-radius: 999px; background: var(--chip); overflow: hidden; }
.barra-fill { display: block; height: 100%; border-radius: 999px; }
.barra-fill.alto { background: #16a34a; }
.barra-fill.medio { background: #f59e0b; }
.barra-fill.bajo { background: #dc2626; }
.barra-fill.gris { background: #c4c4c4; }
.barra-v { text-align: right; font-weight: 900; color: var(--ink); }
.bullets { margin: 0; padding-left: 1.05rem; font-size: 0.8rem; font-weight: 600; line-height: 1.45; }
.bullets li { margin: 0.12rem 0; }
.bullets.pos li::marker { color: #16a34a; }
.bullets.neg li::marker { color: #dc2626; }
.bullets.acc li::marker { color: var(--accent); }
.bullets.alerta li { color: #a15c00; }
.nota { margin: 0.4rem 0; font-size: 0.76rem; font-weight: 600; color: var(--muted); line-height: 1.4; }
.nota strong { color: var(--ink); }
.tabla.comp { width: 100%; }
.tabla td.pos { color: #15803d; font-weight: 800; }
.tabla td.neg { color: #b91c1c; font-weight: 800; }
.tabla tr.sec td { color: var(--muted); }
.tabla .text-btn { font-size: 0.74rem; text-align: left; }
.chip.pos { background: #e7f6ee; color: #15803d; }
.chip.neg { background: #fdecec; color: #b91c1c; }
.des-destacado { position: relative; width: 0; height: 0; pointer-events: none; }
.des-anillo, .des-pulso {
  position: absolute;
  left: 50%;
  top: 50%;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.des-anillo { width: 26px; height: 26px; border: 3px solid var(--ink); box-shadow: 0 0 0 3px #fff; }
.des-pulso { width: 26px; height: 26px; background: var(--accent); opacity: 0.45; animation: des-pulso 1.6s ease-out infinite; }
@keyframes des-pulso {
  from { width: 26px; height: 26px; opacity: 0.5; }
  to { width: 90px; height: 90px; opacity: 0; }
}
.des-etiqueta {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  max-width: 240px;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: var(--shadow);
}
@media (prefers-reduced-motion: reduce) { .des-pulso { animation: none; opacity: 0; } }
.maplibregl-popup-content {
  font-family: "Red Hat Display", sans-serif;
  border-radius: 14px;
  padding: 0.7rem 0.8rem;
  font-weight: 700;
}
.maplibregl-ctrl-attrib { font-size: 10px; }

@media (max-width: 720px) {
  .sep, .top-title { display: none; }
  .panel {
    top: auto;
    bottom: 12px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 46vh;
  }
  h1 { font-size: 1.25rem; }
}

.top-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-width: 120px;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: #f2f2f2;
  color: #2d2d2d;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.top-btn:hover { background: #ebebeb; }

.cuenta { position: relative; flex-shrink: 0; }
.cuenta[hidden], .cuenta-menu[hidden] { display: none; }
.cuenta-trigger {
  display: flex;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}
.cuenta-trigger:focus-visible { outline: 2px solid #6792f4; outline-offset: 2px; }
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: #121212;
  color: #f7f7f7;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.cuenta-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 288px;
  padding: 24px;
  border: 1px solid #ebebeb;
  border-radius: 24px;
  background: #fcfcfc;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}
.cuenta-fila {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 16px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #2d2d2d;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.cuenta-fila:hover { background: #1212120d; }
.cuenta-fila-filled { background: #f7f7f7; }
.cuenta-fila-filled:hover { background: #f2f2f2; }
.cuenta-textos { display: flex; flex: 1; flex-direction: column; gap: 4px; min-width: 0; }
.cuenta-nombre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cuenta-sub { color: #898989; font-weight: 500; }
.cuenta-chevron { width: 20px; height: 20px; flex-shrink: 0; }
.cuenta-divisor { height: 1px; margin: 4px 16px; background: #ebebeb; }

.carga {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 1.2rem 1.3rem;
  color: var(--text);
  font-family: inherit;
}
.carga::backdrop { background: rgba(0, 0, 0, 0.35); }
.carga-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 0 0 0.4rem; }
.carga-head h2 { margin: 0; font-size: 1.2rem; font-weight: 900; color: var(--ink); }
.carga-links { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.9rem 0; }
.carga-links a {
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 800;
  text-decoration: none;
}
.carga-archivo { display: block; padding: 0.8rem; border: 1px dashed #c9c9c9; border-radius: 14px; background: var(--bg); font-size: 0.85rem; font-weight: 700; }
.carga-reporte { margin-top: 0.8rem; font-size: 0.82rem; }
.carga-reporte h3 { margin: 0.8rem 0 0.3rem; font-size: 0.85rem; font-weight: 900; color: var(--ink); }
.carga-reporte .estado { margin: 0; font-weight: 800; }
.carga-reporte .estado.ok { color: #15803d; }
.carga-reporte .estado.mal { color: #b91c1c; }
.carga-reporte dl { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.8rem; margin: 0.4rem 0 0; }
.carga-reporte dt { color: var(--muted); font-weight: 700; }
.carga-reporte dd { margin: 0; font-weight: 800; color: var(--ink); }
.carga-acciones { display: flex; justify-content: flex-end; margin-top: 0.9rem; }
.carga-acciones .btn-primario { width: auto; padding-inline: 1.2rem; }
html.sin-sesion .topbar,
html.sin-sesion #map,
html.sin-sesion .panel,
html.sin-sesion .carga { visibility: hidden; }

#login[hidden] { display: none; }
.login-pantalla {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem 4.5rem;
  background: #f4f7fb;
  color: var(--text);
}
.login-caja { width: min(345px, 100%); }
.login-marca { display: flex; flex-direction: column; gap: 0.75rem; align-items: center; text-align: center; }
.login-marca p { margin: 0; font-size: 0.92rem; font-weight: 500; line-height: 1.45; }
.login-logo { margin: 0; font-weight: 900; letter-spacing: -0.04em; color: var(--ink); font-size: 1.35rem; }
.login-logo span { color: var(--accent); }
.login-fuerte { font-weight: 800 !important; color: var(--ink); }
.login-form { display: flex; flex-direction: column; gap: 0.35rem; padding-top: 1.5rem; }
.login-form label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.78rem; font-weight: 800; color: var(--ink); }
.login-form input, .login-form select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.75rem 0.85rem;
}
.login-form input:focus, .login-form select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.login-form input:disabled { background: var(--chip); color: var(--muted); }
.login-form .btn-primario { margin-top: 0.85rem; }
.login-ayuda { min-height: 1rem; margin: 0; color: #b91c1c; font-size: 0.75rem; font-weight: 700; }
.login-divisor {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}
.login-divisor::before, .login-divisor::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.login-social { display: flex; flex-direction: column; gap: 0.75rem; }
.login-social button, .login-secundario {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 0.7rem 1rem;
  cursor: pointer;
}
.login-social button:disabled, .login-secundario:disabled, .login-form .btn-primario:disabled { opacity: 0.55; cursor: not-allowed; }
.login-secundario { margin-top: 0.55rem; }
.login-clave, .login-tel { display: flex; gap: 0.4rem; }
.login-clave button {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  padding: 0 0.7rem;
}
.login-tel select { width: 5.5rem; }
.login-opcional { font-weight: 600; color: var(--muted); }
.login-olvido { margin: 0.15rem 0 0; text-align: right; }
.login-olvido a, .login-legal a { color: var(--accent); font-weight: 800; text-decoration: none; }
.login-legal {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
}
.login-estado { display: flex; align-items: center; justify-content: center; gap: 0.6rem; margin: 1.2rem 0 0; font-weight: 700; }
.login-giro {
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-bottom-color: var(--ink);
  animation: login-giro 0.8s linear infinite;
}
@keyframes login-giro { to { transform: rotate(360deg); } }
.login-toast {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 2rem));
  margin: 0;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  background: #3b0d0d;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
}
.login-error { color: #b91c1c; font-weight: 800; text-align: center; }

.carga-log {
  margin: 0.8rem 0 0;
  max-height: 220px;
  overflow: auto;
  padding: 0.7rem;
  border-radius: 12px;
  background: #111;
  color: #e5e5e5;
  font-size: 0.72rem;
  line-height: 1.4;
  white-space: pre-wrap;
}
