:root {
  --fondo: #f6f4ef; --tarjeta: #ffffff; --tinta: #1d2433; --suave: #525b6c; --tenue: #898781;
  --linea: #e3ded3; --acento: #7a1f2b; --sello: #f3e6e3;
  --serie: #2a78d6; --serie-suave: #cde2fb;
  --aviso: #8a5a00; --aviso-fondo: #fdf3d8;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { display: flex; flex-direction: column; background: var(--fondo); color: var(--tinta);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; overflow: hidden; }
button, select, input { font: inherit; color: inherit; }

.barra { display: flex; align-items: center; gap: 16px; padding: 8px 16px; background: var(--tarjeta); border-bottom: 1px solid var(--linea); }
.marca { display: flex; align-items: center; gap: 8px; font-size: 16px; white-space: nowrap; }
.chip { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; background: var(--sello); color: var(--acento); padding: 2px 8px; border-radius: 99px; font-weight: 600; }
.estado { flex: 1; color: var(--suave); font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.estado b { color: var(--aviso); background: var(--aviso-fondo); padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.acciones { display: flex; gap: 8px; }
.boton { display: inline-flex; align-items: center; border: 1px solid var(--linea); background: var(--tarjeta); border-radius: 8px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.boton:hover { border-color: var(--suave); }
.boton.primario { background: var(--acento); border-color: var(--acento); color: #fff; }
.boton.primario:disabled { opacity: .6; cursor: progress; }
.boton.chico { padding: 4px 10px; font-size: 13px; }
:focus-visible { outline: 2px solid var(--serie); outline-offset: 2px; }

.filtros { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 8px 16px; border-bottom: 1px solid var(--linea); background: var(--fondo); }
.grupo { display: flex; align-items: center; gap: 6px; }
.grupo.crece { flex: 1; min-width: 200px; }
.rotulo { font-size: 12px; color: var(--suave); }
.a { color: var(--tenue); font-size: 12px; }
select, input[type=search] { border: 1px solid var(--linea); background: var(--tarjeta); border-radius: 8px; padding: 5px 8px; }
input[type=search] { width: 100%; }
select { max-width: 190px; }
.segmentos { display: inline-flex; border: 1px solid var(--linea); border-radius: 8px; overflow: hidden; background: var(--tarjeta); }
.segmentos button { border: 0; background: none; padding: 5px 10px; cursor: pointer; border-left: 1px solid var(--linea); }
.segmentos button:first-child { border-left: 0; }
.segmentos button[aria-pressed=true] { background: var(--tinta); color: #fff; }
.segmentos.sueltos button { min-width: 32px; font-weight: 600; }

.cuerpo { flex: 1; display: flex; min-height: 0; }
.mapa-caja { flex: 1; position: relative; min-width: 0; }
#mapa { position: absolute; inset: 0; background: #e8e6df; }
.sobre-mapa { position: absolute; top: 10px; right: 10px; z-index: 500; display: flex; gap: 8px; align-items: center; }
.sobre-mapa .boton { box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.ver-puntos { background: var(--tarjeta); border: 1px solid var(--linea); border-radius: 8px; padding: 5px 10px; font-size: 13px; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.soltar { position: absolute; inset: 12px; z-index: 900; display: grid; place-items: center; font-size: 22px; background: rgba(255,255,255,.88); border: 3px dashed var(--acento); border-radius: 16px; color: var(--acento); }

.panel { width: 500px; flex: none; display: flex; flex-direction: column; background: var(--tarjeta); border-left: 1px solid var(--linea); min-height: 0; }
.pestanas { display: flex; border-bottom: 1px solid var(--linea); padding: 0 8px; }
.pestanas button { border: 0; background: none; padding: 10px 10px 8px; cursor: pointer; color: var(--suave); border-bottom: 2px solid transparent; white-space: nowrap; }
.pestanas button[aria-selected=true] { color: var(--tinta); border-bottom-color: var(--acento); font-weight: 600; }
.cuenta { font-size: 11px; background: var(--fondo); border: 1px solid var(--linea); border-radius: 99px; padding: 0 6px; color: var(--suave); font-weight: 400; }
.cuenta:empty { display: none; }
.contenido { flex: 1; overflow-y: auto; padding: 14px 16px 20px; min-height: 0; }
.pie { margin: 0; padding: 8px 16px; border-top: 1px solid var(--linea); font-size: 12px; color: var(--suave); }

.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.tile { border: 1px solid var(--linea); border-radius: 10px; padding: 8px 10px; background: var(--tarjeta); text-align: left; cursor: pointer; }
.tile[aria-pressed=true] { border-color: var(--tinta); box-shadow: inset 0 0 0 1px var(--tinta); }
.tile .n { display: block; font-size: 20px; font-weight: 600; line-height: 1.2; white-space: nowrap; }
.tile .q { display: block; font-size: 12px; color: var(--suave); }
h2 { font-size: 13px; margin: 16px 0 6px; font-weight: 600; }
h2 small { font-weight: 400; color: var(--suave); }
.nota { color: var(--suave); font-size: 12.5px; margin: 4px 0 10px; }
.vacio { color: var(--suave); padding: 12px 0; }

.barras { display: grid; grid-template-columns: max-content 1fr max-content; gap: 3px 8px; align-items: center; }
.barras .fila { display: contents; cursor: default; }
.barras .fila.clic { cursor: pointer; }
.barras .eti { font-size: 12.5px; color: var(--suave); white-space: nowrap; max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
.barras .pista { height: 14px; position: relative; border-radius: 4px; }
.barras .fila.clic:hover .pista { background: var(--fondo); }
.barras .relleno { position: absolute; left: 0; top: 2px; bottom: 2px; background: var(--serie); border-radius: 0 4px 4px 0; min-width: 0; }
.barras .val { font-size: 12.5px; text-align: right; font-variant-numeric: tabular-nums; }
.barras .fila.activa .eti, .barras .fila.activa .val { color: var(--tinta); font-weight: 600; }
.barras .fila.apagada .relleno { background: var(--serie-suave); }

.cruce { border: 1px solid var(--linea); border-radius: 10px; margin: 0 0 8px; }
.cruce summary { padding: 8px 10px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; list-style: none; }
.cruce summary::-webkit-details-marker { display: none; }
.cruce summary .quien { font-weight: 600; flex: 1; min-width: 0; }
.cruce summary .cuanto { color: var(--suave); font-size: 12.5px; white-space: nowrap; }
.cruce[open] summary { border-bottom: 1px solid var(--linea); }
.cruce .adentro { padding: 8px 10px; font-size: 13px; }
.cruce .mencion { padding: 4px 0; border-top: 1px dashed var(--linea); }
.cruce .mencion:first-child { border-top: 0; }
.cruce .mencion b { font-weight: 600; }
.sello { font-size: 11px; border-radius: 99px; padding: 1px 8px; white-space: nowrap; border: 1px solid var(--linea); color: var(--suave); }
.sello.firme { background: var(--sello); color: var(--acento); border-color: transparent; font-weight: 600; }
.enlace { border: 0; background: none; padding: 0; color: var(--serie); cursor: pointer; text-decoration: underline; font-size: 12.5px; }

table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th { text-align: left; font-weight: 600; color: var(--suave); border-bottom: 1px solid var(--linea); padding: 4px 6px; position: sticky; top: -14px; background: var(--tarjeta); }
td { padding: 5px 6px; border-bottom: 1px solid var(--linea); vertical-align: top; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--fondo); }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.revisar li { margin: 3px 0; }
.revisar ul { padding-left: 18px; margin: 4px 0 12px; font-size: 13px; }

/* Leaflet */
.leaflet-container { font: inherit; }
.rot { background: none; border: 0; box-shadow: none; padding: 0; font-size: 11px; font-weight: 600; color: #1d2433;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff, 0 0 3px #fff; }
.rot::before { display: none; }
.rot.grande { font-size: 14px; }
.rot.zona { font-size: 15px; }
.leyenda { background: rgba(255,255,255,.95); border: 1px solid var(--linea); border-radius: 10px; padding: 8px 10px; font-size: 12px; line-height: 1.5; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.leyenda b { display: block; margin-bottom: 2px; }
.leyenda .esc { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.leyenda i { width: 16px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); flex: none; }
.leyenda .pt { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--acento); background: #fff; }
.leyenda .pt.ex { background: var(--acento); border-color: #fff; box-shadow: 0 0 0 1px var(--acento); }
.leyenda .pt.co { border-style: dashed; }
.leyenda hr { border: 0; border-top: 1px solid var(--linea); margin: 6px 0; }
.globo { font-size: 13px; line-height: 1.45; min-width: 230px; max-width: 320px; }
.globo .t { font-weight: 600; font-size: 14px; }
.globo .s { color: var(--suave); }
.globo .l { margin-top: 4px; }
.globo .l span { color: var(--suave); }
.globo .caja { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--linea); }
.globo .aprox { color: var(--aviso); background: var(--aviso-fondo); border-radius: 6px; padding: 2px 6px; display: inline-block; margin-top: 4px; font-size: 12px; }
.leaflet-popup-content { margin: 12px 14px; }
.leaflet-popup-content-wrapper { border-radius: 12px; }
.consejo { background: #1d2433; color: #fff; border: 0; border-radius: 6px; padding: 4px 8px; font-size: 12.5px; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.consejo::before { display: none; }
.leyenda .franja { width: 190px; height: 12px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); margin-top: 2px; }
.leyenda .marcas { display: flex; justify-content: space-between; width: 190px; font-variant-numeric: tabular-nums; color: var(--suave); }
.leyenda i.blanco { background: #fff; }
/* Medidas combinadas: barras en tramos y su clave de colores */
.barras .apilada { position: absolute; left: 0; top: 2px; bottom: 2px; display: flex; gap: 2px; }
.barras .seg { border-radius: 2px; min-width: 2px; }
.barras .seg:last-child { border-radius: 2px 4px 4px 2px; }
.barras .fila.apagada .apilada { opacity: .35; }
.punto { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.claves { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; margin: -4px 0 4px; }
.claves .aclara { color: var(--suave); flex-basis: 100%; }
.segmentos:not(.sueltos) button[aria-pressed=true] + button[aria-pressed=true] { border-left-color: rgba(255,255,255,.35); }
/* Lupa de direcciones sobre el mapa */
.buscador { position: absolute; top: 10px; left: 56px; z-index: 500; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; width: min(430px, calc(100% - 250px));
  background: var(--tarjeta); border: 1px solid var(--linea); border-radius: 10px; padding: 4px; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.buscador input { flex: 1; min-width: 120px; border: 0; padding: 5px 8px; background: none; }
.buscador select { border: 0; background: var(--fondo); padding: 5px 4px; }
.buscador .lupa { display: grid; place-items: center; width: 34px; height: 30px; border: 0; border-radius: 7px; background: var(--tinta); color: #fff; cursor: pointer; }
.buscador .aviso { flex-basis: 100%; font-size: 12.5px; color: var(--aviso); background: var(--aviso-fondo); border-radius: 6px; padding: 4px 8px; }
.globo .cerca { padding-top: 4px; border-top: 1px dashed var(--linea); }
.globo .cerca .aprox { display: block; width: fit-content; }
.leaflet-popup-scrolled { border: 0; }
/* Colores por zona */
.leyenda .esc .franja { width: 120px; margin-top: 0; }
.buscador { width: min(430px, calc(100% - 420px)); }
