/* Salarios AGE: verde de carpeta administrativa, papel cuadriculado de cuaderno y subrayador. */
@font-face { font-family: "Bricolage Grotesque"; src: url("/fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Source Sans 3"; src: url("/fonts/source-sans-3-latin-wght-normal.woff2") format("woff2"); font-weight: 200 900; font-display: swap; }

:root {
  --bg: #EEF2F0; --surface: #FBFCFB; --ink: #10231E; --muted: #4F645D; --line: #CCD8D3;
  --accent: #0B6B55; --accent-ink: #FFFFFF; --soft: #E0ECE8; --soft-2: #CFE0DA; --line-strong: #8FA69E; --float: 0 8px 24px rgba(16, 35, 30, .16);
  --hero: #0A4D3F; --hero-2: #0E5C4B; --hero-ink: #F1F8F5; --hero-line: rgba(255, 255, 255, .07);
  --marker: #FFE94D; --marker-ink: #10231E; --below: #93A49E;
  --s0: #E9EEEC; --s1: #CFE6DD; --s2: #9CCFBC; --s3: #5FAE95; --s4: #1F8069; --s5: #0A4D3F;
  --on1: #10231E; --on2: #10231E; --on3: #10231E; --on4: #FFFFFF; --on5: #FFFFFF;
  --display: "Bricolage Grotesque", "Trebuchet MS", sans-serif;
  --body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0D1714; --surface: #14211D; --ink: #E6F0EC; --muted: #9DB3AB; --line: #2A3B35;
  --accent: #5FD0B0; --accent-ink: #0D1714; --soft: #1D2F29; --soft-2: #29423A; --line-strong: #4B6359; --float: 0 8px 24px rgba(0, 0, 0, .5);
  --hero: #0B3A30; --hero-2: #0E4639; --hero-ink: #F1F8F5; --below: #6C7F78;
  --s0: #1B2A25; --s1: #1C4238; --s2: #22604F; --s3: #2F8870; --s4: #57B89C; --s5: #9BE3CC;
  --on1: #E6F0EC; --on2: #E6F0EC; --on3: #FFFFFF; --on4: #0D1714; --on5: #0D1714; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #0D1714; --surface: #14211D; --ink: #E6F0EC; --muted: #9DB3AB; --line: #2A3B35;
  --accent: #5FD0B0; --accent-ink: #0D1714; --soft: #1D2F29; --soft-2: #29423A; --line-strong: #4B6359; --float: 0 8px 24px rgba(0, 0, 0, .5);
  --hero: #0B3A30; --hero-2: #0E4639; --hero-ink: #F1F8F5; --below: #6C7F78;
  --s0: #1B2A25; --s1: #1C4238; --s2: #22604F; --s3: #2F8870; --s4: #57B89C; --s5: #9BE3CC;
  --on1: #E6F0EC; --on2: #E6F0EC; --on3: #FFFFFF; --on4: #0D1714; --on5: #0D1714; color-scheme: dark }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 16px; scroll-padding-bottom: 110px; } /* el banner fijo no debe tapar el foco */
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.5 var(--body); }
h1, h2, h3, p { margin: 0; }
h1, h2 { font-family: var(--display); text-wrap: balance; letter-spacing: -.015em; }
a { color: var(--accent); }
mark { background: var(--marker); color: var(--marker-ink); padding: 0 .16em; }
code { font-size: .88em; background: var(--soft); padding: 0 .3em; border-radius: 2px; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hero :focus-visible { outline-color: var(--marker); }

/* Ancho de contenido fijo de 1088 px, con el margen lateral por fuera. */
:root { --gutter: 24px; }
@media (max-width: 640px) { :root { --gutter: 12px; } }
.inner { max-width: calc(1088px + 2 * var(--gutter)); margin-inline: auto; padding-inline: max(var(--gutter), env(safe-area-inset-left, 0px)) max(var(--gutter), env(safe-area-inset-right, 0px)); }
.top { background: var(--hero); color: var(--hero-ink); }
.top .inner { display: flex; justify-content: space-between; align-items: center; padding-block: 14px; }
.brand { font: 800 1.1rem var(--display); color: inherit; text-decoration: none; letter-spacing: -.01em; }
.marca { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; }
.por { font-size: .8rem; opacity: .85; }
.por a { color: inherit; }
.foot a { color: inherit; }
.tema { background: none; border: 1px solid rgba(255, 255, 255, .35); border-radius: 3px; width: 34px; height: 34px; color: inherit; }
.top :focus-visible { outline-color: var(--marker); }
/* Pestañas de cuerpo: una sección de la web por cuerpo. */
.secciones { border-top: 1px solid rgba(255, 255, 255, .12); }
.top .secciones .inner { justify-content: flex-start; gap: 4px; padding-block: 0; overflow-x: auto; scrollbar-width: none; }
.secciones a { color: inherit; text-decoration: none; font-weight: 600; font-size: .92rem; white-space: nowrap;
  padding: 9px 12px 7px; border-bottom: 3px solid transparent; opacity: .8; }
.secciones a:first-child { margin-left: -12px; }
.secciones a:hover { opacity: 1; }
.secciones a[aria-current] { opacity: 1; border-bottom-color: var(--marker); }
/* En móvil, solo el nombre y más juntas: así caben las cuatro a 360 px. */
@media (max-width: 480px) {
  .pestana-sub { display: none; }
  .secciones a { padding-inline: 8px; font-size: .88rem; }
  .secciones a:first-child { margin-left: -8px; }
}

/* Portada */
.hero { color: var(--hero-ink); background-color: var(--hero);
  background-image: linear-gradient(var(--hero-line) 1px, transparent 1px), linear-gradient(90deg, var(--hero-line) 1px, transparent 1px);
  background-size: 22px 22px; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 40px; align-items: center; padding-block: 40px 56px; }
.hero h1 { font-size: clamp(2.3rem, 5.4vw, 3.9rem); font-weight: 800; line-height: 1.02; }
.lede { font-size: 1.14rem; margin-top: 18px; max-width: 46ch; }
/* Mismo aspecto de título que «Otros recursos» (.recursos h2). */
.cta { margin-top: 26px; max-width: 480px; }
.recursos h2, .cta h2 { font: 800 1rem var(--display); margin: 0 0 8px; letter-spacing: 0; }
.cta-botones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
/* Enlace de texto, no botón: pesa menos que «Ver listado». */
.cta-enlace { display: inline-block; margin-top: 14px; color: inherit; font-size: .95rem; font-weight: 600;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; opacity: .9; }
.cta-enlace:hover { opacity: 1; color: var(--marker); }
.btn { display: block; text-align: center; padding: 11px 14px; border: 1px solid rgba(255, 255, 255, .5); border-radius: 3px; color: inherit; text-decoration: none; font-weight: 600; }
.btn:hover { background: var(--hero-2); }
.btn.primary { grid-column: 1 / -1; background: var(--marker); border-color: var(--marker); color: var(--marker-ink); }
.btn.primary:hover { background: var(--marker); filter: brightness(.95); }
.hero-card { background: var(--surface); color: var(--ink); border-radius: 4px; padding: 22px 24px; min-width: 0; }
.hero-nivel { justify-content: flex-end; margin-top: 8px; gap: 6px; }
.hero-nivel .map-lab { font-size: .76rem; }
.hero-nivel .seg { padding: 2px; }
.hero-nivel .seg button { min-width: 30px; min-height: 24px; padding: 0 7px; font-size: .78rem; }
.card-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; font-size: .82rem; color: var(--muted); font-weight: 600; }
.big { font: 800 clamp(2.6rem, 5vw, 3.5rem)/1.1 var(--display); letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
.trio dt { font: 800 1.45rem/1.15 var(--display); font-variant-numeric: tabular-nums; }
.trio dd { margin: 3px 0 0; font-size: .84rem; color: var(--muted); line-height: 1.3; }
.fine { font-size: .84rem; color: var(--muted); margin-top: 10px; }
.hero-side { display: grid; gap: 14px; min-width: 0; }
/* Escritorio: rejilla de 2×2 para que «AGE y entidades dependientes» y «Otros recursos» empiecen a la misma altura. */
@media (min-width: 861px) {
  .hero-grid { grid-template-areas: "texto tarjeta" "cta recursos"; row-gap: 26px; }
  .hero-copy, .hero-side { display: contents; }
  .hero-texto { grid-area: texto; align-self: center; }
  .hero-card { grid-area: tarjeta; }
  .hero .cta { grid-area: cta; align-self: start; margin-top: 0; }
  .recursos { grid-area: recursos; align-self: start; }
}
.recursos-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.recurso { display: grid; gap: 2px; align-content: start; padding: 11px 14px; background: var(--hero-2); border: 2px solid var(--marker); border-radius: 3px; color: inherit; text-decoration: none; }
.recurso:hover { background: var(--marker); border-color: var(--marker); color: var(--marker-ink); }
.recurso strong { font-weight: 600; line-height: 1.25; }
.recurso strong::after { content: " →"; }
.recurso span { font-size: .84rem; opacity: .85; line-height: 1.3; }

.hero-pagina .inner { padding-block: 26px 34px; }
.hero-pagina h1 { font-size: clamp(1.9rem, 4.2vw, 3rem); max-width: 22ch; margin-top: 10px; }
.hero-pagina .lede { max-width: 66ch; font-size: 1.04rem; margin-top: 12px; }
.volver { color: inherit; font-size: .9rem; text-underline-offset: 3px; }

/* Histograma */
.hist { position: relative; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 2px; align-items: end; height: 130px; margin-top: 14px; border-bottom: 1px solid var(--line); }
.hist.small { height: 62px; margin-top: 0; }
.hist .bar { height: 100%; display: flex; align-items: flex-end; }
.hist .bar i { display: block; width: 100%; background: var(--below); border-radius: 3px 3px 0 0; min-height: 1px; }
.hist .bar.on i { background: var(--accent); }
.hist .bar:hover i { filter: brightness(1.15); }
.hist .tick { position: absolute; bottom: -19px; font-size: .72rem; color: var(--muted); transform: translateX(-50%); white-space: nowrap; }
.hist .tick.first { transform: none; }
.hist .tick.last { transform: translateX(-100%); }
.hist .tick.key { color: var(--ink); font-weight: 600; }
.hist .cut { position: absolute; top: 0; bottom: 0; border-left: 1px dashed var(--ink); pointer-events: none; }
.hist .cut span { position: absolute; left: 6px; top: -2px; font-size: .74rem; font-weight: 600; white-space: nowrap; }
.hero-card .hist { margin-bottom: 28px; }

/* Bloques */
.stack { display: grid; gap: 20px; padding-block: 28px 56px; }
.stack > * { min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 26px; scroll-margin-top: 12px; min-width: 0; }
@media (max-width: 640px) { .card { padding: 18px 12px; } }
.card h2 { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.card-title { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px 24px; margin-bottom: 18px; }
.sub { color: var(--muted); max-width: 68ch; margin-top: 4px; }
/* Los controles van siempre en su fila: si compartieran la del texto, saltarían al crecer este. */
#comunidades .card-title { display: grid; grid-template-columns: minmax(0, 1fr); }
/* Reserva las líneas del texto más largo, para que el mapa no se mueva al cambiar de filtro. */
#map-sub { max-width: none; }
@media (max-width: 960px) { #map-sub { min-height: 3em; } }
@media (max-width: 520px) { #map-sub { min-height: 4.5em; } }
.map-controles { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.map-control { display: flex; align-items: center; gap: 8px; }
.map-lab { font-size: .85rem; font-weight: 600; color: var(--muted); }
@media (max-width: 520px) {
  .map-controles, .map-control { width: 100%; }
  #m-niveles { flex: 1; min-width: 0; }
  #m-niveles button { flex: 1; padding-inline: 2px; }
}
.seg { display: inline-flex; background: var(--soft); border-radius: 3px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 2px; font-size: .92rem; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* Mapa */
.map-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.map-wrap { min-width: 0; }
#map { width: 100%; height: auto; display: block; }
.region { stroke: var(--surface); stroke-width: .8; cursor: pointer; fill: var(--s0); }
.region:hover { stroke: var(--ink); stroke-width: 1.2; }
.region.sel { stroke: var(--ink); stroke-width: 1.6; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: .8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.legend i { width: 13px; height: 13px; border-radius: 2px; border: 1px solid var(--line); }
.regions { display: grid; gap: 2px; min-width: 0; }
.reg { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; width: 100%; background: none; border: 0; padding: 5px 4px; text-align: left; border-radius: 2px; }
.reg:hover, .reg.sel { background: var(--soft); }
.reg small { color: var(--muted); margin-left: 6px; font-variant-numeric: tabular-nums; }
.reg b { font-variant-numeric: tabular-nums; font-weight: 600; }
.reg .track { grid-column: 1 / -1; height: 5px; background: var(--soft); border-radius: 3px; overflow: hidden; }
.reg:hover .track, .reg.sel .track { background: var(--line); }
.reg .track i { display: block; height: 100%; background: var(--accent); border-radius: 0 3px 3px 0; }

/* Matriz */
.scroll { overflow-x: auto; min-width: 0; }
table { border-collapse: collapse; width: 100%; }
.matrix { border-collapse: separate; border-spacing: 3px; min-width: 620px; }
.matrix th { font-size: .82rem; font-weight: 400; color: var(--muted); text-align: center; padding: 4px; }
.matrix th.role { text-align: left; color: var(--ink); font-weight: 600; font-size: .95rem; min-width: 190px; position: sticky; left: 0; background: var(--surface); }
.matrix th.role small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; }
.matrix td { padding: 0; }
.cell { display: block; width: 100%; height: 42px; border: 0; border-radius: 2px; font-weight: 600; font-variant-numeric: tabular-nums; font-size: .92rem; }
.cell:hover { outline: 2px solid var(--ink); outline-offset: -2px; }
.cell.none { background: var(--s0); color: var(--muted); cursor: default; font-weight: 400; }
.cell.none:hover { outline: 0; }

/* Filtros */
.filter-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 auto; min-width: 0; }
.filter { position: relative; max-width: 100%; }
.pick { display: block; height: 38px; max-width: 100%; padding: 0 30px 0 13px; border: 0; border-radius: 3px; background: var(--soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; font-size: .94rem; }
.pick::after { content: ""; position: absolute; right: 13px; top: 50%; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-70%) rotate(45deg); }
.pick[aria-expanded="true"]::after { transform: translateY(-25%) rotate(225deg); }
.pick:hover, .pick[aria-expanded="true"] { background: var(--soft-2); }
.pick .lab { color: var(--muted); }
.pick .txt { font-weight: 600; }
.filter.on .pick { background: var(--soft-2); box-shadow: inset 0 0 0 1px var(--ink); }
.menu { position: absolute; z-index: 25; top: calc(100% + 4px); left: 0; min-width: 240px; max-width: calc(100vw - 24px); max-height: 340px; overflow-y: auto; margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 4px; box-shadow: var(--float); }
.menu li { position: relative; display: flex; align-items: center; min-height: 34px; padding: 5px 12px 5px 32px; border-radius: 2px; cursor: pointer; white-space: nowrap; font-size: .94rem; }
.menu li:hover, .menu li:focus-visible { background: var(--soft); outline: none; }
.menu li.any { color: var(--muted); }
.menu li.sel:not(.check)::before { content: ""; position: absolute; left: 13px; top: 50%; width: 4px; height: 8px; border: solid var(--ink); border-width: 0 1.5px 1.5px 0; transform: translateY(-60%) rotate(45deg); }
.menu li.check::before { content: ""; position: absolute; left: 10px; top: 50%; width: 14px; height: 14px; margin-top: -7px; border: 1px solid var(--muted); border-radius: 2px; }
.menu li.check.sel::before { background: var(--accent); border-color: var(--accent); }
.menu li.check.sel::after { content: ""; position: absolute; left: 15px; top: 50%; width: 3px; height: 7px; border: solid var(--accent-ink); border-width: 0 1.5px 1.5px 0; transform: translateY(-65%) rotate(45deg); }
.menu li > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.menu small { color: var(--muted); font-size: .76rem; margin-left: 10px; font-variant-numeric: tabular-nums; }
.menu.tree { width: min(340px, calc(100vw - 24px)); }
.menu li.spec { padding-left: 48px; }
.menu li.spec.sel::before { left: 29px; }
.twist { flex: none; width: 24px; height: 24px; margin: -4px -6px -4px 4px; border: 0; border-radius: 2px; background: none; color: var(--muted); font-size: 1rem; line-height: 1; transition: transform .15s; }
.twist:hover { background: var(--soft-2); color: var(--ink); }
.twist.open { transform: rotate(90deg); }
.menu.span { width: min(350px, calc(100vw - 24px)); padding: 16px 20px 12px; }
.span-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.span-head b { font-weight: 600; }
.link { border: 0; background: none; padding: 0; font-size: .8rem; text-decoration: underline; text-decoration-color: var(--muted); text-underline-offset: 3px; }
.link:hover { text-decoration-color: currentColor; color: var(--accent); }
.dual { position: relative; height: 24px; }
.dual .rail { position: absolute; left: 9px; right: 9px; top: 11px; height: 2px; background: var(--soft-2); }
.dual .rail i { position: absolute; top: 0; bottom: 0; background: var(--accent); }
.dual input { position: absolute; inset: 0; width: 100%; margin: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; }
.dual input::-webkit-slider-runnable-track { background: none; height: 24px; }
.dual input::-moz-range-track { background: none; }
.dual input::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 18px; height: 18px; margin-top: 3px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--accent); cursor: grab; }
.dual input::-moz-range-thumb { pointer-events: auto; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--accent); cursor: grab; }
.dual input:focus { outline: none; }
.dual input:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }
.dual input:focus-visible::-moz-range-thumb { outline: 2px solid var(--accent); outline-offset: 2px; }
.ticks { display: flex; justify-content: space-between; margin: 6px 9px 0; font-size: .76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.ticks span { width: 0; display: flex; justify-content: center; }
.filters { flex: 0 1 auto; }
/* «Quitar filtros» siempre a la derecha del título: al aparecer no debe mover nada. */
#organismos .card-title { flex-wrap: nowrap; }
#organismos .card-title > div { min-width: 0; }
#f-clear { flex: none; margin-top: .6em; white-space: nowrap; }
.search { display: block; width: 100%; margin-bottom: 8px; height: 42px; font: inherit; font-size: .94rem; color: inherit; background: transparent; border: 1px solid var(--line-strong); border-radius: 3px; padding: 0 12px; }
.search::placeholder { color: var(--muted); }
#f-clear { white-space: nowrap; }
.strip { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); gap: 20px 28px; align-items: center; background: var(--soft); border-radius: 3px; padding: 16px 20px 26px; margin-top: 14px; }
.strip-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 10px 20px; margin: 0; }
.strip-stats dt { font: 800 1.35rem/1.15 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* En móvil, «30,0k a 36,2k» no cabía en su columna de 140 px con el dibujo de texto de Linux y Android. */
@media (max-width: 420px) { .strip-stats dt { font-size: 1.2rem; } }
.strip-stats dd { margin: 2px 0 0; font-size: .8rem; color: var(--muted); }
.notice { margin-top: 12px; padding: 9px 12px; border-left: 3px solid var(--marker); background: var(--soft); font-size: .93rem; }

/* Tabla */
.rank { margin-top: 14px; }
.rank th { font-size: .78rem; font-weight: 600; color: var(--muted); padding: 8px 12px; text-align: left; border-bottom: 2px solid var(--accent); white-space: nowrap; }
.rank th button { background: none; border: 0; padding: 0; font-weight: 600; color: inherit; }
.rank th button:hover { color: var(--accent); }
.rank th[aria-sort="descending"] button::before { content: "↓ "; }
.rank th[aria-sort="ascending"] button::before { content: "↑ "; }
.rank th[aria-sort] { color: var(--ink); }
.rank td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.rank .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank td.val { font-weight: 600; }
/* Filas que escribe scripts/site.py en el HTML, antes de que app.js ponga las suyas. */
.rank td.entidad { padding-left: 30px; font-weight: 600; }
.rank td.entidad small { display: block; font-weight: 400; color: var(--muted); font-size: .82rem; }
span.cell { display: flex; align-items: center; justify-content: center; }
.rowbtn { position: relative; background: none; border: 0; padding: 0 0 0 18px; text-align: left; font-weight: 600; display: block; width: 100%; }
.rowbtn:hover { color: var(--accent); }
/* Centrado en la primera línea del nombre. Solo se ve medio rombo: el desplazamiento compensa el hueco de la otra mitad. */
.rowbtn::before { content: ""; position: absolute; left: 2px; top: calc(.75em - 4px); width: 8px; height: 8px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: translateX(-2px) rotate(-45deg); transition: transform .12s; }
.rowbtn[aria-expanded="true"]::before { transform: translateY(-2px) rotate(45deg); }
.rowbtn small { display: block; font-weight: 400; color: var(--muted); font-size: .82rem; }
.fuente { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; font-size: .9rem; margin-bottom: 14px; }
.fuente span { color: var(--muted); font-size: .82rem; }
.comparar { margin: -6px 0 14px; font-size: .9rem; font-weight: 600; }

/* Comparador de entidades */
.k-controles { display: grid; gap: 14px; }
.k-par { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; align-items: end; }
.k-filtros { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 14px; }
.k-campo { display: grid; grid-template-columns: minmax(0, 1fr); gap: 5px; min-width: 0; } /* sin esto, un nombre largo ensancha la columna */
/* Selector de entidad: el desplegable de la portada, a todo el ancho y con buscador. */
.k-selector .pick { width: 100%; text-align: left; }
.k-menu { width: 100%; min-width: min(320px, calc(100vw - 24px)); padding-top: 0; }
.k-busca { position: sticky; top: 0; z-index: 1; display: block; width: 100%; height: 36px; margin: 0 0 4px; padding: 0 10px;
  font: 500 .94rem var(--body); color: var(--ink); background: var(--surface); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.k-busca:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.k-menu ul { margin: 0; padding: 0 0 2px; list-style: none; }
.k-menu li { white-space: normal; }
.k-cambia { height: 38px; width: 42px; border: 1px solid var(--line-strong); border-radius: 3px; background: var(--soft); font-size: 1.1rem; }
.k-cambia:hover { background: var(--soft-2); }
@media (max-width: 640px) {
  .k-par { grid-template-columns: minmax(0, 1fr); }
  .k-cambia { justify-self: center; transform: rotate(90deg); }
}
.k-veredicto { margin-top: 22px; font: 600 1.15rem/1.4 var(--body); text-wrap: balance; }
.k-veredicto strong { background: var(--marker); color: var(--marker-ink); padding: 0 .2em; }
/* Comparación lado a lado: una tabla, dos columnas con aspecto de minitabla, filas alineadas. */
.k-cara { width: 100%; margin-top: 16px; border-collapse: separate; border-spacing: 12px 0; table-layout: fixed; }
.k-cara th, .k-cara td { padding: 9px 14px; vertical-align: top; }
.k-cara thead td { width: 32%; }
.k-cara tbody th { font-size: .84rem; font-weight: 600; color: var(--muted); text-align: left; padding-left: 0; border-bottom: 1px solid var(--line); }
.k-cara thead th { text-align: left; font: 700 .98rem/1.3 var(--body); background: var(--soft); border-top: 3px solid var(--line-strong);
  border-radius: 3px 3px 0 0; overflow-wrap: anywhere; }
.k-cara thead th.k-b { border-top-color: var(--accent); }
.k-cara td.k-a, .k-cara td.k-b { background: var(--soft); font: 800 1.15rem/1.2 var(--display); font-variant-numeric: tabular-nums;
  border-bottom: 1px solid var(--line); white-space: nowrap; }
.k-cara td small { display: block; font: 400 .74rem/1.3 var(--body); color: var(--muted); white-space: normal; }
.k-cara tbody tr:last-child td { border-radius: 0 0 3px 3px; border-bottom: 0; }
.k-cara tbody tr:last-child th { border-bottom: 0; }
/* La que paga más: marca y borde de subrayador en toda su columna. */
.k-cara .k-ganadora { box-shadow: inset 2px 0 0 var(--marker), inset -2px 0 0 var(--marker); }
.k-cara thead th.k-ganadora { border-top-color: var(--marker); }
.k-cara tbody tr:last-child .k-ganadora { box-shadow: inset 2px 0 0 var(--marker), inset -2px 0 0 var(--marker), inset 0 -2px 0 var(--marker); }
.k-gana { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; padding: 1px 8px; border-radius: 999px; background: var(--marker);
  color: var(--marker-ink); font-size: .78rem; font-weight: 700; white-space: nowrap; }
@media (max-width: 640px) {
  .k-cara { border-spacing: 6px 0; }
  .k-cara thead td { width: 28%; }
  .k-cara th, .k-cara td { padding: 8px 8px; }
  .k-cara tbody th { font-size: .76rem; }
  .k-cara td.k-a, .k-cara td.k-b { font-size: .98rem; white-space: normal; } /* el rango pasa a dos líneas antes que salirse */
  .k-cara thead th { font-size: .84rem; }
}
.k-tabla td small { display: block; font-size: .74rem; color: var(--muted); font-weight: 400; }
.k-tabla th.r { white-space: normal; min-width: 90px; }
.k-tabla tr[data-nivel] { cursor: pointer; }
.k-tabla tr.sel td { background: var(--soft); }
.k-sin { color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: 20px 28px; }
.detail-grid.solo { grid-template-columns: minmax(0, 1fr); }
.pequenas { margin-top: 24px; }
.pequenas h3 { font: 600 1.02rem var(--body); }
.pequenas .fine { margin-top: 4px; }
.pequenas .rank { margin-top: 8px; }
.detail-grid > * { min-width: 0; }
.detail h3 { font: 600 .88rem var(--body); margin-bottom: 6px; }
.detail table { font-size: .86rem; }
.detail th, .detail td { padding: 4px 8px 4px 0; background: transparent; border-bottom: 1px solid var(--line); text-align: left; font-weight: 400; }
.detail th:last-child, .detail td td:last-child { padding-right: 0; }
.detail th { color: var(--muted); font-size: .76rem; }
/* El panel empieza donde el nombre del organismo y termina donde la última columna. */
tr.detail > td { background: var(--soft); padding: 16px 12px 16px 30px; }
@media (max-width: 520px) { tr.detail > td { padding-inline: 6px; } }
.detail .r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.obs { width: 28px; height: 28px; padding: 0; background: none; border: 0; border-radius: 3px; font-size: 1.15rem; font-weight: 700; line-height: 1; color: var(--accent); cursor: help; }
.obs:hover { background: var(--soft-2); }
abbr[title] { text-decoration: none; }
.info { display: inline-grid; place-items: center; width: 18px; height: 18px; padding: 0; margin-left: 2px; vertical-align: text-bottom; background: none; border: 1px solid var(--line-strong); border-radius: 50%; font-size: .72rem; font-weight: 700; line-height: 1; color: var(--muted); cursor: help; }
.info:hover { background: var(--soft); color: var(--ink); }
.tag { cursor: help; font-size: .68rem; border: 1px solid currentColor; border-radius: 2px; padding: 0 3px; color: var(--muted); margin-left: 4px; white-space: nowrap; }
.empty { color: var(--muted); padding: 22px 12px; }
.more { display: block; margin: 14px auto 0; background: none; border: 1px solid var(--line); border-radius: 3px; padding: 8px 18px; font-weight: 600; }
.more:hover { border-color: var(--accent); }

.o-strip { grid-template-columns: minmax(0, 1fr); padding-bottom: 16px; }

/* Aviso de Opogacela */
/* «sticky» y no «fixed»: se queda abajo al hacer scroll, pero al final de la página no tapa el pie. */
.opo { position: sticky; bottom: 0; z-index: 10; background: var(--hero); color: var(--hero-ink); box-shadow: var(--float); }
.opo-fila { display: flex; align-items: center; gap: 10px 16px; padding-block: 10px; }
.opo p { flex: 1; min-width: 0; font-size: .92rem; line-height: 1.35; }
.opo-acciones { display: flex; flex: none; gap: 8px; }
.opo-accion { padding: 7px 12px; border: 1px solid rgba(255, 255, 255, .5); border-radius: 3px; font-size: .9rem; font-weight: 600; color: inherit; text-decoration: none; white-space: nowrap; }
.opo-accion:hover { background: var(--hero-2); }
.opo-accion.principal { background: var(--marker); border-color: var(--marker); color: var(--marker-ink); }
.opo-accion.principal:hover { background: var(--marker); filter: brightness(.95); }
.opo :focus-visible { outline-color: var(--marker); }
@media (max-width: 760px) {
  .opo-fila { display: grid; grid-template-columns: minmax(0, 1fr); padding-block: 8px; }
  .opo-mas { display: none; }
  .opo-accion { flex: 1; text-align: center; }
}

/* Calculadora */
.c-controles { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px 28px; align-items: start; }
.c-campo { display: grid; gap: 5px; min-width: 0; }
.c-pila { display: grid; gap: 16px; min-width: 0; }
/* Neto al mes en grande, en el hueco bajo el nivel y el específico. */
.c-destacado { display: grid; align-content: start; justify-items: start; gap: 2px; padding: 18px 20px; border-radius: 4px;
  background: var(--hero); color: var(--hero-ink); min-width: 0; }
.c-destacado-lab { font-size: .84rem; font-weight: 600; opacity: .85; }
.c-destacado b { font: 800 clamp(2.3rem, 5vw, 3.2rem)/1.05 var(--display); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.c-destacado-sub { font-size: .88rem; opacity: .85; }
.c-destacado a { margin-top: 8px; color: var(--marker); font-weight: 600; font-size: .92rem; }
/* Con tres columnas, la de la derecha baja hasta el final y el neto ocupa las otras dos. */
@media (min-width: 960px) {
  .c-controles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .c-pila-derecha { grid-column: 3; grid-row: 1 / span 2; }
  .c-destacado { grid-column: 1 / span 2; grid-row: 2; align-self: start; }
}
.c-lab { font-size: .85rem; font-weight: 600; color: var(--muted); }
.c-lab b { color: var(--ink); font-variant-numeric: tabular-nums; }
.c-niveles { display: flex; flex-wrap: wrap; }
/* Selector de cuerpo (secciones con varios): el nombre y, debajo, su nivel de entrada. */
.c-cuerpos button { display: grid; text-align: left; line-height: 1.2; padding: 6px 12px; }
.c-cuerpos button small { font-size: .74rem; font-weight: 400; opacity: .85; }
.c-niveles button { padding: 6px 9px; font-variant-numeric: tabular-nums; }
.c-fila { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
#c-ce, #c-prod, #c-irpf { width: 120px; height: 36px; font: 600 1rem var(--body); font-variant-numeric: tabular-nums; color: var(--ink); background: transparent; border: 1px solid var(--line-strong); border-radius: 3px; padding: 0 9px; }
#c-tri { width: 100%; margin: 6px 0 0; accent-color: var(--accent); height: 24px; }
.c-campo .fine { margin-top: 0; }
#c-irpf-reset { justify-self: start; }
.c-tabla tr.total td { font-weight: 600; border-top: 2px solid var(--line-strong); }
.c-tabla tr.neto td { font-weight: 600; background: var(--soft); }
.c-sub { font: 800 1.2rem var(--display); margin-top: 24px; }
.c-nivel { background: none; border: 0; padding: 0; font-weight: 600; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; font-variant-numeric: tabular-nums; }
tr.sel td { background: var(--soft); }

/* Método */
details summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "＋"; color: var(--muted); font-size: 1.2rem; }
details[open] summary::after { content: "－"; }
.method { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; margin-top: 18px; }
.method h3 { font: 600 1.02rem var(--body); margin: 16px 0 5px; }
.method h3:first-child { margin-top: 0; }
.method ul { margin: 6px 0 0; padding-left: 1.1em; display: grid; gap: 3px; font-size: .95rem; }
.method-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px 36px; }
.method-grid > * { min-width: 0; }
.faq { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 22px 36px; }
.faq > * { min-width: 0; }
.faq h3 { font: 600 1.05rem var(--body); margin-bottom: 5px; }

/* Embudo de puestos: cada barra arranca donde acabó la anterior. */
.embudo { list-style: none; margin: 14px 0 0; padding: 0; }
.embudo li { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) 62px; gap: 2px 14px; align-items: center; padding: 5px 0; font-size: .9rem; line-height: 1.3; }
.embudo li + li { border-top: 1px solid var(--line); }
.embudo b { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.e-pista { display: block; height: 10px; background: var(--soft); border-radius: 2px; overflow: hidden; }
.e-pista i { display: block; height: 100%; min-width: 2px; border-radius: 2px; background: var(--below); }
.e-total .e-pista i { background: var(--line-strong); }
.e-dentro .e-pista i { background: var(--accent); }
.e-total, .e-dentro { font-weight: 600; }

/* Fórmula del bruto */
.formula { display: flex; align-items: stretch; gap: 8px; margin-top: 14px; }
.f-bloque { flex: 1 1 0; min-width: 0; display: grid; align-content: start; gap: 2px; padding: 12px 14px; background: var(--soft); border-radius: 3px; }
.f-bloque b { font: 800 1.15rem/1.15 var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.f-bloque span { font-size: .88rem; font-weight: 600; line-height: 1.25; }
.f-bloque small { font-size: .78rem; color: var(--muted); line-height: 1.3; }
.f-total { background: var(--accent); color: var(--accent-ink); }
.f-total small { color: inherit; opacity: .85; }
.f-op { align-self: center; font: 800 1.2rem var(--display); color: var(--muted); }

/* Fuentes */
.m-fuentes { display: grid; grid-template-columns: minmax(0, 2.4fr) minmax(0, 1fr); gap: 20px 36px; padding: 18px 20px; background: var(--soft); border-radius: 3px; }
.m-fuentes > * { min-width: 0; }
.method ul.m-oficiales { display: block; columns: 2 260px; column-gap: 28px; }
.m-oficiales li { break-inside: avoid; margin-bottom: 3px; }
@media (max-width: 760px) {
  .embudo li { grid-template-columns: minmax(0, 1fr) auto; }
  .e-pista { grid-column: 1 / -1; grid-row: 2; }
  .formula { flex-direction: column; }
  .f-op { align-self: flex-start; padding-left: 14px; line-height: 1; }
  .m-fuentes { grid-template-columns: minmax(0, 1fr); padding: 14px; }
}
.foot { color: var(--muted); font-size: .88rem; padding-bottom: 32px; }
#tip { white-space: pre-line; position: fixed; z-index: 20; pointer-events: none; background: var(--ink); color: var(--bg); font-size: .82rem; padding: 6px 9px; border-radius: 3px; max-width: 260px; }

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); padding-block: 24px 32px; gap: 28px; }
  .map-grid, .strip, .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .hs { display: none; }
}
@media (max-width: 520px) {
  .card h2 { font-size: 1.6rem; }
  .hero-card { padding: 18px 16px; }
  .trio { gap: 10px; }
  .trio dt { font-size: 1.15rem; }
  .rank th, .rank td { padding-inline: 6px; }
  .rank th, .rank th.r { white-space: normal; }
  .rank > tbody > tr > td.r { font-size: .92rem; }
  .detail th, .detail th.r { white-space: nowrap; }
  .matrix th.role { min-width: 128px; font-size: .86rem; }
  .matrix { min-width: 560px; }
  .hs2 { display: none; }
}
