/* estadisticas-autoescuelas-por-poblacion.php y estadisticas-por-permiso.php */
.po { --po-t1: #c0392b; --po-t2: #f0a07a; --po-t3: #e3e7ec; --po-t4: #8fd19e; --po-t5: #1e8449; }
.po-titulo { font-size: 20px !important; margin: 28px 0 12px; }
.po-permisos { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 18px; }
.po-permisos > span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ap-texto-3); margin-right: 4px; }
.po-permisos a {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--ap-borde);
    background: var(--ap-superficie); color: var(--ap-texto-2); font-weight: 700; font-size: 14px; text-decoration: none; transition: transform .15s, border-color .15s, color .15s;
}
.po-permisos a svg { width: 18px; height: 18px; }
.po-permisos a:hover { transform: translateY(-2px); border-color: var(--ap-acento); color: var(--ap-acento); }
.po-permisos a[aria-current] { background: var(--ap-acento); border-color: var(--ap-acento); color: #fff; box-shadow: 0 4px 12px rgba(42, 120, 214, .3); }

.po-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.po-kpis > div {
    padding: 16px; border-radius: 14px; color: #fff; box-shadow: var(--ap-sombra);
    background: linear-gradient(135deg, var(--ap-marca), var(--ap-acento)); animation: po-sube .5s both;
}
.po-kpis > div:nth-child(2) { animation-delay: .06s; background: linear-gradient(135deg, #1e6f5c, #2e9d4f); }
.po-kpis > div:nth-child(3) { animation-delay: .12s; background: linear-gradient(135deg, #5b3fa8, #7b61d1); }
.po-kpis > div:nth-child(4) { animation-delay: .18s; background: linear-gradient(135deg, #a8550f, #e08a2c); }
.po-kpis > div:nth-child(5) { animation-delay: .24s; background: linear-gradient(135deg, #8b1d3f, #c8456b); }
.po-kpis strong { display: block; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.po-kpis span { font-size: 13px; opacity: .9; }

.po-curiosos { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.po-curiosos li {
    display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; background: var(--ap-superficie); border: 1px solid var(--ap-borde);
    border-radius: 12px; box-shadow: var(--ap-sombra); animation: po-sube .5s both; animation-delay: calc(var(--i, 0) * 70ms + .2s);
    transition: transform .15s, box-shadow .15s;
}
.po-curiosos li:hover { transform: translateY(-3px); box-shadow: var(--ap-sombra-alta); }
.po-curiosos p { margin: 0; font-size: 14px; line-height: 1.5; }
.po-cur-icono { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--ap-acento-suave); color: var(--ap-acento); }
.po-cur-icono svg { width: 20px; height: 20px; }

.po-mapa-bloque { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.po .ap-mapa-escala { --ap-mapa-n0: #d5d8dc; --ap-mapa-n1: var(--po-t1); --ap-mapa-n2: var(--po-t2); --ap-mapa-n3: var(--po-t3); --ap-mapa-n4: var(--po-t4); --ap-mapa-n5: var(--po-t5); }
.po .ap-mapa-n1 .ap-mapa-pct, .po .ap-mapa-n5 .ap-mapa-pct { fill: #fff; }
.po .ap-mapa-n3 .ap-mapa-pct, .po .ap-mapa-n4 .ap-mapa-pct, .po .ap-mapa-n2 .ap-mapa-pct { fill: #1f2933; }
.po-leyenda { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 0; margin: 8px 0 0; font-size: 12px; color: var(--ap-texto-2); }
.po-leyenda i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }
.po-leyenda .po-t1, .po-celda.po-t1, .po-indice.po-t1, .po-barras .po-t1 .po-barra { background: var(--po-t1); }
.po-leyenda .po-t2, .po-celda.po-t2, .po-indice.po-t2, .po-barras .po-t2 .po-barra { background: var(--po-t2); }
.po-leyenda .po-t3, .po-celda.po-t3, .po-indice.po-t3, .po-barras .po-t3 .po-barra { background: var(--po-t3); }
.po-leyenda .po-t4, .po-celda.po-t4, .po-indice.po-t4, .po-barras .po-t4 .po-barra { background: var(--po-t4); }
.po-leyenda .po-t5, .po-celda.po-t5, .po-indice.po-t5, .po-barras .po-t5 .po-barra { background: var(--po-t5); }
.po-barras .po-t3 .po-barra { background: #aab4c0; }

.po-barras { margin: 0; padding: 16px; background: var(--ap-superficie); border: 1px solid var(--ap-borde); border-radius: 14px; }
.po-barras figcaption { font-weight: 700; font-size: 16px; margin-bottom: 10px; }
.po-barras figcaption small { font-weight: 500; color: var(--ap-texto-3); margin-left: 6px; }
.po-barras ol { list-style: none; margin: 0; padding: 0; max-height: 640px; overflow-y: auto; }
.po-barras li { display: grid; grid-template-columns: 150px 1fr 44px; align-items: center; gap: 8px; padding: 2px 0; font-size: 13px; }
.po-barra-nombre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.po-barra-pista { position: relative; height: 12px; background: var(--ap-superficie-2); border-radius: 0 4px 4px 0; }
.po-barra { display: block; height: 100%; border-radius: 0 4px 4px 0; transform-origin: left; animation: po-crece .8s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 15ms); }
.po-media { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--ap-texto); opacity: .6; }
.po-barra-valor { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.po-tabla-bloque { margin-top: 10px; }
.po-tabla-cab { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.po-tabla-cab input { height: 36px; padding: 4px 12px; border: 1px solid var(--ap-borde); border-radius: 999px; font-size: 14px; }
.po-tabla-cab input:focus { outline: none; border-color: var(--ap-acento); box-shadow: 0 0 0 3px var(--ap-acento-suave); }
.po-nota { color: var(--ap-texto-2); font-size: 14px; margin: 0 0 10px; }
.po-tabla { background: var(--ap-superficie); border-radius: 10px; overflow: hidden; font-size: 14px; }
.po-tabla th { white-space: nowrap; background: var(--ap-superficie-2); }
.po-tabla th button { border: 0; background: none; padding: 0; font-weight: 700; color: inherit; cursor: pointer; }
.po-tabla th button::after { content: ' ↕'; opacity: .35; font-size: 11px; }
.po-tabla th[aria-sort=ascending] button::after { content: ' ↑'; opacity: 1; }
.po-tabla th[aria-sort=descending] button::after { content: ' ↓'; opacity: 1; }
.po-num { text-align: right; font-variant-numeric: tabular-nums; }
.po-tabla tfoot th, .po-tabla tfoot td { font-weight: 700; background: var(--ap-acento-suave); }
.po-tabla small { display: block; font-size: 11px; opacity: .8; }
.po-indice { display: inline-block; min-width: 56px; padding: 1px 8px; border-radius: 999px; font-weight: 700; font-size: 12px; text-align: center; }
.po-indice.po-t1, .po-indice.po-t5, .po-celda.po-t1, .po-celda.po-t5 { color: #fff; }
.po-tabla-calor td.po-celda { transition: transform .12s; }
.po-tabla-calor td.po-celda:hover { transform: scale(1.08); position: relative; z-index: 1; box-shadow: var(--ap-sombra-alta); }
.po-tabla-alta { max-height: 640px; overflow-y: auto; }
.po-tabla-alta thead th { position: sticky; top: 0; z-index: 1; }
.po-tabla tr[hidden] { display: none; }

.po-fuentes { margin: 28px 0 10px; padding: 16px 18px; border-radius: 12px; background: var(--ap-superficie-2); border: 1px solid var(--ap-borde); font-size: 13px; color: var(--ap-texto-2); }
.po-fuentes h2 { font-size: 15px !important; margin: 0 0 6px; }
.po-fuentes ul { margin: 0; padding-left: 18px; }

/* Página de un permiso */
.pp-cab { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.pp-cab-icono { flex: none; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 16px; background: linear-gradient(135deg, var(--ap-marca), var(--ap-acento)); color: #fff; box-shadow: var(--ap-sombra-alta); }
.pp-cab-icono svg { width: 34px; height: 34px; }
.pp-cab p { margin: 0; color: var(--ap-texto-2); }
.pp-tarjetas { list-style: none; margin: 0 0 20px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.pp-tarjetas a {
    display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 16px; border: 1px solid var(--ap-borde); border-radius: 14px;
    background: var(--ap-superficie); text-decoration: none !important; color: var(--ap-texto); box-shadow: var(--ap-sombra);
    transition: transform .15s, box-shadow .15s, border-color .15s; animation: po-sube .45s both; animation-delay: calc(var(--i, 0) * 50ms);
}
.pp-tarjetas a:hover { transform: translateY(-3px); border-color: var(--ap-acento); box-shadow: var(--ap-sombra-alta); }
.pp-tarjetas .pp-icono { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; background: var(--ap-acento-suave); color: var(--ap-acento); }
.pp-tarjetas .pp-icono svg { width: 22px; height: 22px; }
.pp-tarjetas h2 { margin: 0; font-size: 17px !important; }
.pp-tarjetas p { margin: 0; font-size: 13px; color: var(--ap-texto-2); }
.pp-tarjetas dl { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin: 6px 0 0; font-size: 12px; }
.pp-tarjetas dt { color: var(--ap-texto-3); font-weight: 500; }
.pp-tarjetas dd { margin: 0; font-weight: 700; font-size: 15px; color: var(--ap-texto); font-variant-numeric: tabular-nums; }
.pp-tipos { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.pp-tipo { padding: 16px; border-radius: 14px; background: var(--ap-superficie); border: 1px solid var(--ap-borde); }
.pp-tipo h3 { margin: 0 0 8px; font-size: 15px !important; }
.pp-anillo { --p: 50; width: 110px; height: 110px; border-radius: 50%; margin: 6px auto 10px; display: grid; place-items: center;
    background: conic-gradient(var(--ap-verde) calc(var(--p) * 1%), var(--ap-borde-suave) 0); animation: po-aparece .6s both; }
.pp-anillo span { display: grid; place-items: center; width: 82px; height: 82px; border-radius: 50%; background: var(--ap-superficie); font-weight: 800; font-size: 20px; }
.pp-tipo dl { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; margin: 0; font-size: 13px; }
.pp-tipo dd { margin: 0; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.pp-evolucion { display: flex; align-items: flex-end; gap: 4px; height: 180px; padding: 10px 0 0; border-bottom: 1px solid var(--ap-borde); }
.pp-evolucion div { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.pp-evolucion b { display: block; width: 100%; max-width: 38px; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, var(--ap-acento), var(--ap-marca));
    transform-origin: bottom; animation: po-crece-v .7s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 30ms); }
.pp-evolucion small { font-size: 10px; color: var(--ap-texto-3); margin-top: 3px; white-space: nowrap; }
.pp-evolucion div:hover b { filter: brightness(1.2); }

@keyframes po-sube { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes po-crece { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes po-crece-v { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes po-aparece { from { opacity: 0; transform: scale(.8) rotate(-30deg); } to { opacity: 1; transform: none; } }

@media (max-width: 900px) { .po-mapa-bloque { grid-template-columns: 1fr; } }
@media (max-width: 600px) {
    .po-barras li { grid-template-columns: 110px 1fr 40px; }
    .po-kpis strong { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { .po *, .pp-tarjetas * { animation: none !important; transition: none !important; } }

/* Las tablas nuevas tienen <thead>: sin el estilo de "primera fila = cabecera" de las antiguas */
.ap .po-tabla > tbody > tr:first-child > td { color: inherit; font-size: inherit; text-transform: none; letter-spacing: normal; border-top: 1px solid #ddd; border-bottom: 0; white-space: normal; }
.ap .po-tabla > tbody > tr:first-child > td:not(.po-celda) { background: transparent; }
.ap .po-tabla td.po-num, .ap .po-tabla th.po-num { text-align: right; }
.ap .po-tabla > tbody > tr > td.po-t1 { background: var(--po-t1); }
.ap .po-tabla > tbody > tr > td.po-t2 { background: var(--po-t2); }
.ap .po-tabla > tbody > tr > td.po-t3 { background: var(--po-t3); }
.ap .po-tabla > tbody > tr > td.po-t4 { background: var(--po-t4); }
.ap .po-tabla > tbody > tr > td.po-t5 { background: var(--po-t5); }
