:root {
  --fondo: #f3f7f5;
  --superficie: #ffffff;
  --borde: #e5ece8;
  --texto: #17211e;
  --suave: #5f6b66;
  --verde: #059669;
  --verde-oscuro: #047857;
  --hover: #047857;
  --verde-claro: #ecfdf5;
  --acento: #10b981;
  --oro: #f5c518;
  --gris: #94a3b8;
  --azul: #2563eb;
  --rojo: #dc2626;
  --radio: 12px;
  --sombra: 0 2px 8px rgba(21, 58, 43, .08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}
body {
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  display: flex;
  flex-direction: column;
  font-size: 15px;
  overflow: hidden;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1rem; margin: 0 0 .5rem; display: flex; align-items: center; gap: .5rem; }
h3 { font-size: 1rem; margin: 0; }
button, input, select { font: inherit; }
button, summary, .opcion-camino, .interruptor { touch-action: manipulation; }

button {
  border: 1px solid var(--verde);
  background: var(--verde);
  color: #fff;
  border-radius: 8px;
  padding: .5rem .9rem;
  cursor: pointer;
}
button:hover { background: var(--hover); }
button:disabled { opacity: .6; cursor: progress; }
button.secundario { background: var(--superficie); color: var(--verde-oscuro); }
button.secundario:hover { background: var(--verde-claro); }
@media (hover: none) {
  button:hover { background: var(--verde); }
  button.secundario:hover { background: var(--superficie); }
  button:active { background: var(--hover); }
  button.secundario:active { background: var(--verde-claro); }
}
button.principal { font-weight: 600; }
button.enlace { background: none; border: none; color: var(--verde-oscuro); padding: 0; text-decoration: underline; }
button.enlace:hover,
button.enlace:active { background: none; color: var(--verde-oscuro); }

input, select {
  border: 1px solid var(--borde);
  border-radius: 8px;
  padding: .45rem .6rem;
  background: var(--superficie);
  color: var(--texto);
  min-width: 0;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--verde); outline-offset: 1px; }

.ayuda { color: var(--suave); font-size: .85rem; margin: .25rem 0; }
.error { color: var(--rojo); font-size: .9rem; min-height: 1.2em; margin: .25rem 0; }
.fila { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.acciones { justify-content: flex-end; margin-top: .75rem; }
.acciones .interruptor,
.acciones #ayuda-ubicacion { flex: 1 0 100%; }
.acciones .interruptor { margin-top: .35rem; margin-bottom: 0; }
.acciones #ayuda-ubicacion { margin: .15rem 0 0; }
.opcion-camino {
  display: flex; align-items: flex-start; gap: .55rem;
  margin: .85rem 0 .2rem; cursor: pointer; line-height: 1.35;
}
.opcion-camino input { width: 1.15rem; height: 1.15rem; margin-top: .15rem; accent-color: var(--verde); flex: none; }
.interruptor {
  display: flex; align-items: center; gap: .65rem;
  min-height: 44px; margin: .85rem 0 .35rem; cursor: pointer;
}
.interruptor input {
  position: absolute; opacity: 0; width: 1px; height: 1px;
}
.pista {
  width: 2.75rem; height: 1.55rem; border-radius: 999px; flex: none;
  background: #c5cdc7; position: relative;
}
.pista::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 1.25rem; height: 1.25rem; border-radius: 50%; background: #fff;
  transition: transform .15s ease;
}
.interruptor input:checked + .pista { background: var(--verde); }
.interruptor input:checked + .pista::after { transform: translateX(1.2rem); }
.interruptor input:focus-visible + .pista { outline: 2px solid var(--azul); outline-offset: 2px; }
.peso { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem .6rem; margin: .35rem 0 .15rem; }
.peso label { font-weight: 600; }
.peso input { width: 5.5rem; }
.peso .ayuda { flex-basis: 100%; margin: 0; }
.peso[hidden] { display: none !important; }

/* ---------- Barra superior ---------- */
.barra {
  display: flex;
  align-items: center;
  gap: .75rem 1rem;
  padding: max(.6rem, env(safe-area-inset-top)) 1rem .6rem;
  background: var(--superficie);
  border-bottom: 1px solid var(--borde);
  flex-wrap: wrap;
}
.marca {
  display: inline-flex; align-items: center; gap: .55rem;
  font-weight: 800; font-size: 1.35rem; letter-spacing: -.03em;
  color: var(--texto); text-decoration: none; flex: none;
}
.marca .acento { color: var(--acento); }
.icono-cesta {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 12px; background: var(--verde); color: #fff; flex: none;
}
.herramientas {
  display: flex; align-items: center; gap: .5rem;
  margin-left: auto; min-width: 0;
}
button.icono {
  min-width: 2.6rem; padding-inline: .55rem; font-size: 1.05rem;
  background: var(--fondo); color: var(--texto); border-color: var(--borde);
}
button.icono:hover { background: var(--verde-claro); color: var(--verde-oscuro); }
.pestanas {
  display: flex;
  gap: .25rem;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.pestanas::-webkit-scrollbar { display: none; }
.pestanas button, .pestanas-dialogo button {
  background: none;
  border: none;
  color: var(--suave);
  border-radius: 8px;
  white-space: nowrap;
  flex: none;
}
.pestanas button:hover, .pestanas-dialogo button:hover { background: var(--verde-claro); }
.pestanas button.activa, .pestanas-dialogo button.activa { background: var(--verde-claro); color: var(--verde-oscuro); font-weight: 600; }
.cuenta { display: flex; gap: .5rem; align-items: center; margin-left: 0; min-width: 0; }
.cuenta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34vw; }

/* ---------- Vistas ---------- */
main { flex: 1; min-height: 0; min-width: 0; display: flex; overflow: hidden; }
.vista { display: none; flex: 1; min-height: 0; min-width: 0; }
.vista.activa { display: flex; }
.contenido {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  overflow: auto;
  flex: 1;
  min-height: 0;
  min-width: 0;
}
.encabezado { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* ---------- Panel de búsqueda ---------- */
.panel {
  width: clamp(300px, 34vw, 420px);
  flex-shrink: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem;
  background: var(--superficie);
  border-right: 1px solid var(--borde);
  min-width: 0;
  min-height: 0;
}
.paso { padding-bottom: 1rem; margin-bottom: 1rem; border-bottom: 1px solid var(--borde); }
.paso .num {
  display: inline-grid; place-items: center; flex: none;
  width: 1.5rem; height: 1.5rem; border-radius: 50%;
  background: var(--verde); color: #fff; font-size: .8rem;
}
#radio { flex: 1; accent-color: var(--verde); }
#radio-num { width: 4.5rem; }
#item-texto { flex: 1; }
#item-cantidad { width: 4.2rem; }

.items { list-style: none; padding: 0; margin: .75rem 0 0; }
.items li {
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem .5rem; border-radius: 8px;
}
.items li:nth-child(odd) { background: var(--fondo); }
.items li span { flex: 1; overflow-wrap: anywhere; }
.items li input { width: 3.8rem; padding: .2rem .4rem; }
.items li button { background: none; border: none; color: var(--suave); padding: .2rem .4rem; }
.items li button:hover { color: var(--rojo); background: none; }
.items .vacia { color: var(--suave); font-style: italic; background: none !important; }

/* ---------- Resultados ---------- */
.resumen-resultados { margin: 0 0 .75rem; }
.tarjeta {
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: .75rem;
  margin-bottom: .6rem;
  cursor: pointer;
  background: var(--superficie);
}
.tarjeta:hover { box-shadow: var(--sombra); }
.tarjeta.mejor { border: 2px solid var(--oro); background: #fffbea; }
.tarjeta.parcial { opacity: .9; }
.tarjeta header { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.tarjeta header h3 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tarjeta .total { font-weight: 700; font-size: 1.1rem; margin-left: auto; white-space: nowrap; }
.tarjeta .meta { color: var(--suave); font-size: .85rem; margin: .2rem 0; }
.tarjeta .ahorro { color: var(--verde-oscuro); font-weight: 600; font-size: .9rem; margin: .3rem 0 0; }
.tarjeta .faltan { color: var(--rojo); font-size: .85rem; margin: .3rem 0 0; }
.tarjeta details, .popup details { margin-top: .45rem; font-size: .88rem; }
.tarjeta summary, .popup summary { color: var(--verde-oscuro); cursor: pointer; font-weight: 700; }
.guia { margin-top: .45rem; }
.guia-opciones { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; }
.guia-opciones[hidden] { display: none; }
.guia-opciones a {
  display: inline-flex; align-items: center; justify-content: center;
  width: 3rem; height: 3rem; min-height: 3rem; padding: .35rem; border-radius: 8px;
  border: 1px solid var(--borde); background: var(--fondo);
  color: var(--texto); text-decoration: none;
}
.guia-opciones svg { width: 1.85rem; height: 1.85rem; display: block; }
.elige-item {
  cursor: pointer;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: .65rem;
}
.elige-item input {
  width: 1.35rem; height: 1.35rem; margin-top: .15rem;
  accent-color: var(--verde); flex: none; order: 0;
}
.elige-item > div { flex: 1; min-width: 0; }
.estrella { color: var(--oro); font-size: 1.3rem; line-height: 1; flex: none; }
.tarjeta.activa { outline: 2px solid var(--azul); }
.tabla-scroll { max-height: 320px; overflow: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .35rem .4rem; border-bottom: 1px solid var(--borde); vertical-align: top; overflow-wrap: break-word; }
th { color: var(--suave); font-weight: 600; font-size: .85rem; }
td:first-child { overflow-wrap: anywhere; }
td.num, th.num { text-align: right; }
th.num { max-width: 8rem; }
td.num { white-space: nowrap; }

.actualizaciones { font-size: .88rem; margin-top: 1rem; }
.actualizaciones summary { cursor: pointer; color: var(--suave); }
.actualizaciones ul { padding-left: 1.1rem; }
.actualizaciones li { margin-bottom: .4rem; }

/* ---------- Mapa ---------- */
.mapa-contenedor { flex: 1; position: relative; min-height: 300px; }
#mapa { position: absolute; inset: 0; }
.leyenda {
  position: absolute; left: .75rem; bottom: 1.5rem; z-index: 500;
  background: var(--superficie); border-radius: 8px; box-shadow: var(--sombra);
  padding: .4rem .6rem; display: flex; gap: .75rem; flex-wrap: wrap; font-size: .8rem;
}
.leyenda span { display: inline-flex; align-items: center; gap: .3rem; }
.punto { display: inline-grid; place-items: center; width: 14px; height: 14px; border-radius: 50%; font-style: normal; font-size: 10px; }
.punto.origen { background: var(--azul); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--azul); }
.punto.super { background: #c0392b; }
.punto.mini { background: #2471a3; }
.punto.mejor { background: var(--oro); color: #fff; }
.punto.completo { background: var(--verde); }
.punto.parcial { background: var(--gris); }
.punto.parada { background: var(--azul); }
.punto.ruta.auto { background: #1d4ed8; }
.punto.ruta.pie { background: #0f766e; }
.leyenda-ruta[hidden] { display: none !important; }
.leyenda-parada[hidden] { display: none !important; }

.pin-origen {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--azul); border: 3px solid #fff; box-shadow: 0 0 0 2px var(--azul), var(--sombra);
}
.marca-comercio {
  display: inline-grid; place-items: center; flex: none;
  width: 2.15rem; height: 2.15rem; border-radius: 8px; overflow: hidden;
  background: hsl(var(--tono, 150) 42% 32%); color: #fff;
  font-weight: 800; font-size: .78rem; letter-spacing: .02em; line-height: 1;
}
.marca-comercio img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.pin .marca-comercio { width: 1.45rem; height: 1.45rem; border-radius: 6px; font-size: .62rem; }
.popup-titulo { display: flex; align-items: center; gap: .45rem; margin-bottom: .25rem; }
.popup-titulo h4 { margin: 0; }
.popup-titulo .marca-comercio { width: 1.8rem; height: 1.8rem; }
.pin {
  display: inline-flex; align-items: center; gap: .28rem; transform: translate(-50%, -100%);
  background: var(--verde); color: #fff; font-weight: 700; font-size: 12px;
  padding: 3px 7px 3px 3px; border-radius: 12px; white-space: nowrap; box-shadow: var(--sombra);
  border: 2px solid #fff; position: relative;
}
.pin::after {
  content: ""; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: #fff;
}
.pin.parcial { background: var(--gris); }
.pin.parada { background: var(--azul); }
.pin.mejor { background: var(--oro); color: #3d2f00; font-size: 14px; padding: 4px 9px; z-index: 1000; }
.pin.mejor .estrella-pin { font-size: 17px; margin-right: 2px; }
.pin-gris { width: 10px; height: 10px; border-radius: 50%; background: var(--gris); border: 2px solid #fff; box-shadow: var(--sombra); }
.pin-gris.en-zona { background: var(--verde); }
.leaflet-div-icon { background: none; border: none; }
.popup { max-width: min(260px, calc(100vw - 4.5rem)); }
.popup h4 { margin: 0 0 .25rem; overflow-wrap: anywhere; }
.popup table { font-size: .82rem; }
.leaflet-popup-content { margin: 10px 12px; }
.leaflet-control-attribution { max-width: 55%; }

/* ---------- Recomendada y estadísticas ---------- */
.bloque {
  background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 1rem; margin-bottom: 1rem;
}
.bloque h2 { margin-bottom: .75rem; }
.seccion-lista { margin: 1.1rem 0 .15rem; font-size: .95rem; }
.bloque > .principal { margin-top: .9rem; }
.rejilla { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.cifras { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.cifra { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--radio); padding: .75rem 1rem; }
.cifra .valor { font-size: 1.5rem; font-weight: 700; }
.cifra .rotulo { color: var(--suave); font-size: .85rem; }
.etiqueta { display: inline-block; background: var(--verde-claro); color: var(--verde-oscuro); border-radius: 999px; padding: .05rem .5rem; font-size: .75rem; font-weight: 600; margin-left: .3rem; }
.etiqueta.reponer { background: #fff1c2; color: #7a5b00; }
.vacio { text-align: center; color: var(--suave); padding: 2rem 1rem; }
.lista-anterior { border-bottom: 1px solid var(--borde); padding: .6rem 0; display: flex; gap: .75rem 1rem; align-items: center; flex-wrap: wrap; }
.lista-anterior:last-child { border-bottom: none; }
.lista-anterior div { flex: 1; min-width: min(100%, 12rem); }
.lista-anterior small { color: var(--suave); overflow-wrap: anywhere; }

/* ---------- Diálogo y avisos ---------- */
dialog {
  border: none; border-radius: 14px; padding: 1.25rem;
  width: min(400px, calc(100vw - 1.5rem - env(safe-area-inset-left) - env(safe-area-inset-right)));
  max-height: min(92dvh, 640px);
  overflow: auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(20, 30, 25, .45); }
dialog label { display: flex; flex-direction: column; gap: .25rem; margin-top: .6rem; font-size: .9rem; }
.pestanas-dialogo { display: flex; gap: .25rem; margin-bottom: .5rem; }
#form-cuenta:not(.registro) .solo-registro { display: none; }
#dialogo-ubicacion h2 { margin: 0 0 .35rem; font-size: 1.15rem; }

.avisos {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  left: max(1rem, env(safe-area-inset-left));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  width: min(360px, calc(100vw - 2rem));
  margin-left: auto;
}
.aviso {
  background: var(--texto); color: #fff; padding: .7rem .9rem; border-radius: 10px;
  box-shadow: var(--sombra); font-size: .9rem; animation: entrar .25s ease-out;
}
.aviso.error { background: var(--rojo); color: #fff; }
@keyframes entrar { from { transform: translateY(10px); opacity: 0; } }

/* ---------- Teléfono y tablet angosta ---------- */
@media (max-width: 899px) {
  .barra {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "marca cuenta" "pestanas pestanas";
    align-items: center;
    gap: .35rem .75rem;
    padding-left: max(.75rem, env(safe-area-inset-left));
    padding-right: max(.75rem, env(safe-area-inset-right));
  }
  .marca { grid-area: marca; }
  .herramientas { grid-area: cuenta; margin-left: 0; }
  .cuenta { margin-left: 0; }
  .pestanas { grid-area: pestanas; width: 100%; padding-bottom: .15rem; }

  h1 { font-size: 1.3rem; }
  .contenido { padding: 1rem .75rem max(1rem, env(safe-area-inset-bottom)); }
  .rejilla { grid-template-columns: 1fr; }
  .cifras { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }

  input, select, textarea { font-size: 16px; }
  .cuenta button,
  .pestanas button,
  .acciones button,
  #form-item button,
  dialog .acciones button,
  .bloque > .principal,
  .lista-anterior button { min-height: 48px; }
  .items li { min-height: 48px; padding-top: .15rem; padding-bottom: .15rem; }
  .items li input { width: 4.6rem; min-height: 44px; }
  .items li button { min-width: 44px; min-height: 44px; padding: .35rem .55rem; }
  .opcion-camino, .interruptor, .elige-item { min-height: 48px; align-items: center; }
  .elige-item input { width: 1.4rem; height: 1.4rem; }
  .opcion-camino input { width: 1.4rem; height: 1.4rem; }
  .actualizaciones summary,
  .tarjeta summary,
  .popup summary,
  .guia-abrir { min-height: 48px; display: flex; align-items: center; }
  #radio { height: 44px; }
  #item-texto, #item-cantidad, #radio-num, #peso, #form-item button { min-height: 48px; }
  #vista-buscar .acciones {
    position: sticky;
    bottom: 0;
    z-index: 6;
    flex-direction: column;
    align-items: stretch;
    gap: .45rem;
    background: var(--superficie);
    margin: .75rem -1rem 0;
    padding: .6rem 1rem max(.7rem, env(safe-area-inset-bottom));
    box-shadow: 0 -8px 16px rgba(20, 40, 25, .08);
  }
  #vista-buscar .acciones button,
  #vista-buscar .acciones .interruptor,
  #vista-buscar .acciones #ayuda-ubicacion { width: 100%; flex: 0 0 auto; }
  #vista-buscar .panel { padding-bottom: max(1.25rem, env(safe-area-inset-bottom)); }
  dialog .acciones { flex-direction: column; align-items: stretch; }
  dialog input { min-height: 48px; }
  dialog .acciones button.principal,
  dialog .acciones button.secundario { width: 100%; flex: 0 0 auto; min-height: 48px; }
  .bloque > .principal { width: 100%; }
  .leaflet-bar a,
  .leaflet-touch .leaflet-bar a {
    width: 44px;
    height: 44px;
    line-height: 44px;
    font-size: 22px;
  }

  #vista-buscar.activa {
    flex-direction: column;
    overflow: hidden;
  }
  .mapa-contenedor {
    order: -1;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: auto;
    min-height: 0;
  }
  #mapa {
    position: relative;
    inset: auto;
    flex: 0 0 auto;
    height: clamp(190px, 36dvh, 420px);
    min-height: 190px;
  }
  .panel {
    width: 100%;
    flex: 1;
    border-right: none;
    border-top: 1px solid var(--borde);
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
  .leyenda {
    position: static;
    left: auto;
    right: auto;
    bottom: auto;
    max-width: none;
    border-radius: 0;
    box-shadow: none;
    border-top: 1px solid var(--borde);
    padding: .35rem .6rem;
  }
  #form-item { align-items: stretch; }
  #item-texto { flex: 1 1 12rem; }
  #form-item button { flex: 1 1 auto; }
  .acciones .principal { flex: 1 1 10rem; }

  .encabezado label { display: flex; flex-direction: column; gap: .25rem; }
  .encabezado select { width: 100%; }
}

/* Teléfono horizontal: el mapa al lado, no encima de una franja mínima. */
@media (max-width: 899px) and (max-height: 480px) {
  .barra {
    display: flex;
    flex-wrap: nowrap;
    gap: .35rem .6rem;
    padding-top: max(.35rem, env(safe-area-inset-top));
    padding-bottom: .35rem;
  }
  .pestanas { width: auto; flex: 1; }
  .herramientas { margin-left: auto; }
  #vista-buscar.activa { flex-direction: row; }
  .mapa-contenedor {
    order: 0;
    display: block;
    flex: 1 1 auto;
    width: auto;
    height: auto;
    min-height: 0;
  }
  #mapa { position: absolute; inset: 0; height: auto; min-height: 0; }
  .leyenda {
    position: absolute;
    left: .4rem;
    right: .4rem;
    bottom: .35rem;
    border-radius: 8px;
    box-shadow: var(--sombra);
    border-top: none;
  }
  .panel {
    width: min(300px, 48vw);
    flex: none;
    border-top: none;
    border-right: 1px solid var(--borde);
  }
  #vista-buscar .acciones { flex-direction: row; }
  #vista-buscar .acciones button { width: auto; flex: 1 1 0; }
}

#vista-buscar.activa.sin-mapa {
  display: block;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
#vista-buscar.activa.sin-mapa .mapa-contenedor { display: none; }
#vista-buscar.activa.sin-mapa .panel {
  width: min(720px, 100%);
  max-width: 720px;
  margin-inline: auto;
  border: none;
  overflow: visible;
  flex: none;
}

@media (max-width: 420px) {
  .marca { font-size: 1.15rem; }
  .icono-cesta { width: 32px; height: 32px; border-radius: 10px; }
  .pestanas button { padding: .4rem .45rem; font-size: .85rem; }
  .cuenta span { max-width: 26vw; }
  .paso h2 { align-items: flex-start; }
  #item-texto { flex-basis: 100%; }
  .tarjeta .total { font-size: 1rem; }
  .cifra .valor { font-size: 1.25rem; }
}

.lugar { align-items: flex-end; }
.selector-lugar { display: flex; flex-direction: column; gap: .25rem; flex: 1; min-width: 12rem; font-size: .9rem; }
.ceja {
  margin: 0 0 .35rem; color: var(--verde); font-size: .72rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
}
.bloque label { display: flex; flex-direction: column; gap: .25rem; margin: .35rem 0 .7rem; font-size: .9rem; }
.bloque label.elige-item {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: .65rem;
  margin: 0;
  font-size: inherit;
}
.bloque select { width: 100%; }
.populares { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.producto-popular {
  border: 1px solid var(--borde); background: var(--fondo); color: var(--texto);
  border-radius: 12px; padding: .75rem .55rem; text-align: center; cursor: pointer;
}
.producto-popular:hover { border-color: var(--verde); }
.producto-popular small { display: block; color: var(--suave); font-size: .75rem; }
.producto-popular strong { display: block; margin-top: .15rem; font-size: .92rem; }
.grafico { position: relative; height: 220px; margin: .4rem 0 .8rem; }
.alerta { border-radius: 8px; padding: .45rem .65rem; font-size: .82rem; margin: .35rem 0; }
.alerta.minimo { background: var(--verde-claro); color: var(--verde-oscuro); }
.alerta.sube { background: #fff7ed; color: #9a3412; }
.alerta.neutra { background: var(--fondo); color: var(--suave); }
.inflacion {
  display: flex; justify-content: space-between; gap: .75rem; align-items: center;
  padding: .45rem .65rem; margin: .3rem 0; border-radius: 8px; background: var(--fondo); font-size: .85rem;
}
.sube-precio { color: var(--rojo); }
.baja-precio { color: var(--verde-oscuro); }
#competitividad p { margin: .35rem 0; padding-bottom: .35rem; border-bottom: 1px solid var(--borde); }
.alternar-vista { display: none; }

body.oscuro {
  --fondo: #111827;
  --superficie: #1f2937;
  --borde: #374151;
  --texto: #e5e7eb;
  --suave: #9ca3af;
  --verde-claro: #064e3b;
  --verde-oscuro: #6ee7b7;
  --hover: #065f46;
  color-scheme: dark;
}
body.oscuro .alerta.sube { background: #431407; color: #fdba74; }
body.oscuro .tarjeta.mejor { background: #3f3410; }
body.oscuro .pista { background: #4b5563; }
body.oscuro .leaflet-popup-content-wrapper,
body.oscuro .leaflet-popup-tip { background: #1f2937; color: #e5e7eb; }
body.oscuro button.icono:hover { color: #ecfdf5; }

@media (max-width: 899px) {
  .alternar-vista {
    display: inline-flex; align-items: center; justify-content: center;
    position: fixed; z-index: 1200;
    bottom: max(1rem, env(safe-area-inset-bottom));
    left: 50%; transform: translateX(-50%);
    border: 0; border-radius: 999px; background: #059669; color: #fff;
    font-weight: 700; padding: .8rem 1.25rem;
    box-shadow: 0 8px 24px rgb(15 23 42 / 28%);
  }
  .alternar-vista[hidden] { display: none !important; }
  #vista-buscar .panel { padding-bottom: 5.5rem; }
  #vista-buscar.activa:not(.movil-mapa) .mapa-contenedor { display: none; }
  #vista-buscar.activa.movil-mapa {
    display: flex !important; flex-direction: column; overflow: hidden;
  }
  #vista-buscar.activa.movil-mapa .panel { display: none; }
  #vista-buscar.activa.movil-mapa .mapa-contenedor {
    display: block !important; order: 0; flex: 1; width: 100%;
    height: auto; min-height: 0; position: relative;
  }
  #vista-buscar.activa.movil-mapa #mapa {
    position: absolute; inset: 0; height: auto; min-height: 0;
  }
}
