/* ============================================================
   Ficha Educativa Regional — estilos institucionales
   Plantilla HTML dinámica (reemplazo Power BI)
   ============================================================ */

:root {
  --navy: #002855;
  --navy-deep: #001a3a;
  --blue: #1a4a7a;
  --blue-mid: #2e6aa6;
  --blue-light: #d6e6f5;
  --blue-cell: #5b9bd5;
  --teal-header: #b8d4e8;
  --red-brand: #c41e3a;
  --red-soft: #f4b4b4;
  --red-bar: #e88a8a;
  --pink-bar: #f2a0b0;
  --green: #2e7d32;
  --green-soft: #c6e0b4;
  --green-dot: #43a047;
  --yellow-dot: #f9a825;
  --orange-dot: #ef6c00;
  --red-dot: #e53935;
  --gray-50: #f7f8fa;
  --gray-100: #eef0f3;
  --gray-200: #dde1e6;
  --gray-400: #9aa3ad;
  --gray-600: #5a6570;
  --gray-800: #2c333a;
  --text: #1e2430;
  --white: #ffffff;
  --enla-previo: #8a8a8a;
  --enla-inicio: #8b3a3a;
  --enla-proceso: #e08a2a;
  --enla-satisf: #3d9b4a;
  --font: "Source Sans 3", "Segoe UI", sans-serif;
  --font-display: "Source Serif 4", "Georgia", "Times New Roman", serif;
  --shadow-sm: 0 1px 2px rgba(0, 40, 85, 0.06);
  --radius: 6px;
  --max: 1760px;
  --page-pad: 1.15rem 1.6rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16.5px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: #d9e0e8;
  line-height: 1.4;
  min-height: 100vh;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ---------- App shell ---------- */

.app {
  width: min(var(--max), calc(100% - 1.25rem));
  max-width: var(--max);
  margin: 0 auto;
  background: var(--white);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 28px rgba(0, 40, 85, 0.1);
}

/* ---------- Branding / logos ---------- */

.brand-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0.5rem 1.6rem 0.4rem;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
}

.brand-header-img {
  display: block;
  width: auto;
  max-width: min(100%, 920px);
  height: auto;
  max-height: 78px;
  margin-left: auto;
  object-fit: contain;
  object-position: right center;
}

/* ---------- Title banner ---------- */

.title-banner {
  background: linear-gradient(90deg, var(--navy-deep), var(--navy) 40%, var(--blue));
  color: var(--white);
  padding: 0.75rem 1.6rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.title-banner h1 {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 2.4vw, 2.05rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.15;
}

.title-banner h1 span {
  font-weight: 800;
  text-transform: uppercase;
}

.title-map {
  display: inline-block;
  height: 1.15em;
  width: auto;
  flex-shrink: 0;
  object-fit: contain;
  vertical-align: middle;
}

.region-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.6rem 0.45rem;
  color: var(--red-brand);
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
}

.region-label {
  color: var(--red-brand);
  font-weight: 700;
}

.region-select {
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--red-brand);
  border: 1px solid #e2a0a8;
  border-radius: 6px;
  padding: 0.18rem 0.7rem;
  background: #fff;
  min-width: 16rem;
  max-width: min(28rem, 80vw);
  cursor: pointer;
}

.region-select:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

.region-loading {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 26, 58, 0.28);
  backdrop-filter: blur(1.5px);
}

.region-loading[hidden] {
  display: none;
}

.region-loading-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  padding: 1.1rem 1.4rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 8px 28px rgba(0, 26, 58, 0.18);
  color: var(--navy);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.region-loading-spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid rgba(0, 40, 85, 0.18);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: region-spin 0.7s linear infinite;
}

@keyframes region-spin {
  to {
    transform: rotate(360deg);
  }
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.page-head .section-title {
  margin-bottom: 0.35rem;
}

.enla-col-title {
  margin: 0 0 0.85rem;
  color: var(--navy);
  font-size: 0.98rem;
  font-weight: 700;
}

table.data tbody tr.accent td {
  background: #fdecea !important;
}

table.data tbody tr.teal td {
  background: #e6f4f1 !important;
}

table.data td.money-red,
table.data th.money-red {
  color: var(--red-brand);
  font-weight: 700;
}

table.data td.total-blue {
  color: var(--blue-mid);
  font-weight: 800;
}

.page[data-page="1"] > .grid-3 {
  align-items: stretch;
}

.page[data-page="1"] > .grid-3 > .col {
  display: flex;
  flex-direction: column;
}

.page[data-page="6"] .infra-split {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 1.25rem;
}

/* ---------- Alertas de actualización ---------- */

.alerts-banner {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  background: #fff8e1;
  border-bottom: 1px solid #f0c36d;
}

.alerts-banner[hidden] {
  display: none !important;
}

.alert-item {
  font-size: 0.78rem;
  line-height: 1.35;
  padding: 0.45rem 0.65rem;
  border-radius: 4px;
  border-left: 4px solid #f9a825;
  background: #fff;
  color: #5a4500;
}

.alert-item.error {
  border-left-color: #c41e3a;
  background: #fff5f5;
  color: #7a1020;
}

.alert-item.warning {
  border-left-color: #ef6c00;
  background: #fff8f0;
  color: #6a3a00;
}

.alert-item strong {
  margin-right: 0.35rem;
}

/* ---------- Nav pages ---------- */

.page-nav {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.35rem;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  overflow-x: auto;
  scrollbar-width: thin;
}

.page-nav button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--gray-600);
  min-height: 2.55rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.86rem;
  font-weight: 600;
  border-radius: 6px;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.page-nav button:hover {
  background: var(--white);
  color: var(--navy);
  border-color: var(--blue-light);
}

.page-nav button.active {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}

.page-nav .pager {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--gray-600);
  font-weight: 600;
  flex-shrink: 0;
}

.page-nav .pager button {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--gray-200);
  background: var(--white);
  display: grid;
  place-items: center;
  font-size: 1rem;
}

.page-nav .pager button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ---------- Main ---------- */

.main {
  flex: 1;
  padding: 1rem 1.6rem 1.4rem;
}

.page {
  display: none;
  animation: fadeIn 0.25s ease;
}

.page.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.section-title {
  margin: 0 0 0.7rem;
  color: var(--blue);
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.section-title.roman {
  font-size: 1.05rem;
  margin-bottom: 0.55rem;
}

.subsection-title {
  margin: 0 0 0.5rem;
  color: var(--blue-mid);
  font-size: 0.95rem;
  font-weight: 650;
}

.muted {
  color: var(--gray-600);
  font-size: 0.72rem;
  line-height: 1.4;
}

.muted strong {
  color: var(--gray-800);
}

.note-block {
  margin-top: auto;
  padding-top: 1rem;
}

.note-block p {
  margin: 0.2rem 0;
  font-size: 0.72rem;
  color: var(--gray-600);
}

.note-block a {
  color: var(--gray-700);
  text-decoration: underline;
}

.note-block.alert-block {
  border-left: 3px solid #c62828;
  background: #fff5f5;
  padding: 0.45rem 0.55rem;
  margin: 0.35rem 0 0.55rem;
}

.table-scroll-eib {
  max-height: 14rem;
  overflow: auto;
}

.subsection-notes {
  margin-top: 0.35rem;
  padding-top: 0;
}

.subsection-notes.servicios-fuente {
  margin-bottom: 1rem;
}

.page[data-page="1"] .stack-tables {
  margin-top: 0.75rem;
}

.page-notes-footer {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--gray-200);
}

.page-notes-footer .note-block {
  margin-top: 0;
  padding-top: 0;
}

/* ---------- Grids ---------- */

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 2.2fr;
  gap: 1rem;
}

.page[data-page="1"] > .grid-2 {
  align-items: stretch;
  min-height: calc(100vh - 260px);
}

.page[data-page="1"] > .grid-2 > .col {
  display: flex;
  flex-direction: column;
}

.stack-tables {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.grid-2-equal {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.25rem;
}

.grid-infra {
  display: grid;
  grid-template-columns: 0.95fr 1.15fr;
  gap: 1.25rem;
  align-items: start;
}

.infra-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.7rem;
}

.infra-kpi {
  display: flex;
  gap: 0.5rem;
  min-width: 0;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: linear-gradient(180deg, #f7f9fc 0%, #ffffff 100%);
}

.infra-kpi-icon {
  flex: 0 0 auto;
  width: 1.7rem;
  height: 1.7rem;
  color: var(--navy);
}

.infra-kpi-icon svg {
  width: 100%;
  height: 100%;
}

.infra-kpi-body {
  min-width: 0;
}

.infra-kpi-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--gray-600);
  line-height: 1.25;
}

.infra-kpi-value {
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 0.1rem 0 0.15rem;
  overflow-wrap: anywhere;
}

.infra-kpi-split {
  font-size: 0.62rem;
  color: var(--gray-500);
  line-height: 1.3;
}

.infra-alerts {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.infra-alert {
  padding: 0.5rem 0.6rem 0.45rem;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: #fff;
}

.infra-alert-head {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.4rem;
  align-items: center;
}

.infra-alert-icon {
  width: 1.15rem;
  height: 1.15rem;
  color: var(--navy);
}

.infra-alert-icon svg {
  width: 100%;
  height: 100%;
}

.infra-alert-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gray-800);
}

.infra-alert-count {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--navy);
}

.infra-alert-pct {
  min-width: 3.4rem;
  text-align: right;
  font-size: 0.82rem;
  font-weight: 800;
}

.infra-alert-bar {
  height: 0.38rem;
  margin: 0.4rem 0 0.3rem;
  border-radius: 999px;
  background: var(--gray-100);
  overflow: hidden;
}

.infra-alert-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.infra-alert.tono-riesgo .infra-alert-pct {
  color: #b42318;
}

.infra-alert.tono-riesgo .infra-alert-bar span {
  background: #c62828;
}

.infra-alert.tono-alerta .infra-alert-pct {
  color: #b54708;
}

.infra-alert.tono-alerta .infra-alert-bar span {
  background: #e6a817;
}

.infra-alert-split {
  font-size: 0.62rem;
  color: var(--gray-500);
}

.grid-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem 1.5rem;
}

.col {
  min-width: 0;
}

.v-divider {
  border-left: 1px dashed var(--gray-200);
  padding-left: 1rem;
}

.h-rule {
  border: 0;
  border-top: 1px solid var(--gray-200);
  margin: 0.75rem 0;
}

/* ---------- Personas / lista nacional ---------- */

.person-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.person-item .role {
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 700;
  margin: 0;
}

.person-item .name {
  margin: 0.15rem 0 0;
  padding-left: 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.stat-pair {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.35rem;
}

.stat-pair .label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.stat-pair .value {
  padding-left: 0.85rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--red-brand);
}

.stat-pair .value.navy {
  color: var(--navy);
}

/* ---------- KPI cards ---------- */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.kpi-row.kpi-2 {
  grid-template-columns: repeat(2, 1fr);
}

.kpi-row.kpi-3 {
  grid-template-columns: repeat(3, 1fr);
}

.kpi {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.5rem;
  border-radius: 8px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.kpi.has-tip {
  cursor: help;
}

.kpi.has-tip:hover,
.kpi.has-tip:focus-visible,
.kpi.tip-open {
  background: var(--gray-50);
  box-shadow: 0 0 0 1px var(--blue-light);
}

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--blue-light);
  color: var(--navy);
}

.kpi-icon svg {
  width: 24px;
  height: 24px;
}

.kpi-body .kpi-value {
  font-size: 1.28rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.1;
}

.kpi-body .kpi-label {
  font-size: 0.78rem;
  color: var(--gray-600);
  font-weight: 600;
  margin-top: 0.1rem;
}

.kpi.compact .kpi-value {
  font-size: 1.35rem;
}

/* ---------- Service access (table + dual) ---------- */

.svc-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.svc-label .svc-icon {
  width: 22px;
  height: 22px;
  color: var(--blue-mid);
  flex-shrink: 0;
}

.pct-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--green);
  color: var(--white);
  display: inline-grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.72rem;
  vertical-align: middle;
}

td.pct-cell {
  text-align: center;
  width: 3.5rem;
}

.dual-service {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 0.4rem 0.55rem;
  align-items: center;
  margin-bottom: 0.55rem;
  font-size: 0.75rem;
}

.dual-service .dual-vals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.dual-service .dual-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.dual-service .dual-item strong {
  color: var(--navy);
  font-size: 0.95rem;
}

.section-lead {
  margin: -0.25rem 0 0.65rem;
}

.svc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-bottom: 0.65rem;
}

.svc-card {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 0.55rem 0.6rem 0.65rem;
  background: linear-gradient(180deg, #fbfcfe 0%, #f3f6fa 100%);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.svc-card.has-tip {
  cursor: help;
}

.svc-card.has-tip:hover,
.svc-card.has-tip:focus-visible,
.svc-card.tip-open {
  border-color: var(--blue-mid);
  box-shadow: 0 4px 14px rgba(0, 40, 85, 0.1);
}

.svc-card-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
}

.svc-card-head h4 {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--navy);
}

.svc-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 7px;
  color: var(--white);
  flex: 0 0 auto;
}

.svc-card-icon svg {
  width: 1rem;
  height: 1rem;
}

.svc-internet {
  grid-column: 1 / -1;
}

.svc-internet .svc-meter {
  max-width: 28rem;
}

.svc-agua .svc-card-icon {
  background: #1f6f9f;
}

.svc-desague .svc-card-icon {
  background: #3d6b5a;
}

.svc-electricidad .svc-card-icon {
  background: #b8860b;
}

.svc-internet .svc-card-icon {
  background: #2e5a9c;
}

.svc-meter + .svc-meter {
  margin-top: 0.4rem;
}

.svc-meter-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.35rem;
  margin-bottom: 0.18rem;
  font-size: 0.68rem;
  color: var(--gray-600);
}

.svc-meter-label strong {
  font-size: 0.92rem;
  font-weight: 750;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.svc-track {
  height: 0.42rem;
  border-radius: 999px;
  background: var(--gray-200);
  overflow: hidden;
}

.svc-fill {
  height: 100%;
  border-radius: inherit;
  transition: width 0.35s ease;
}

.svc-fill.tone-hi {
  background: linear-gradient(90deg, #2e7d32, #43a047);
}

.svc-fill.tone-mid {
  background: linear-gradient(90deg, #ef6c00, #f9a825);
}

.svc-fill.tone-lo {
  background: linear-gradient(90deg, #c62828, #e53935);
}

.svc-fill.tone-na {
  background: var(--gray-400);
}

.ind-edu-notas {
  margin-bottom: 0.75rem;
}

table.data-desercion th.num {
  font-size: 0.68rem;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .svc-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 0.65rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
}

.table-wrap.table-full {
  overflow: visible;
  max-height: none;
}

.page[data-page="2"] .col-presupuesto .section-title.roman {
  margin-bottom: 0.22rem;
}

.page[data-page="2"] .presupuesto-lead {
  margin: 0 0 0.2rem;
  line-height: 1.25;
}

.page[data-page="2"] .col-presupuesto .presupuesto-notas {
  margin-top: 0.28rem;
  padding-top: 0;
}

.page[data-page="2"] .col-presupuesto .presupuesto-notas p {
  margin: 0.06rem 0;
  font-size: 0.62rem;
  line-height: 1.25;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  min-width: 280px;
}

table.data th,
table.data td {
  padding: 0.42rem 0.55rem;
  border-bottom: 1px solid var(--gray-200);
  text-align: left;
  vertical-align: middle;
}

table.data th {
  background: var(--gray-100);
  color: var(--navy);
  font-weight: 700;
  white-space: nowrap;
  font-size: 0.78rem;
}

table.data th.group {
  background: var(--teal-header);
  text-align: center;
}

table.data td.num,
table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table.data tbody tr:nth-child(even) {
  background: var(--gray-50);
}

table.data tbody tr:hover {
  background: #eaf2fa;
}

table.data tbody tr.has-tip {
  cursor: help;
}

table.data tbody tr.has-tip:hover,
table.data tbody tr.has-tip:focus-visible,
table.data tbody tr.tip-open {
  background: #e3eef8 !important;
  box-shadow: inset 3px 0 0 var(--navy);
}

table.data tbody tr.has-tip:focus-visible {
  outline: 2px solid var(--blue-mid);
  outline-offset: -2px;
}

table.data tr.total td {
  font-weight: 800;
  background: var(--blue-light) !important;
  color: var(--navy);
  border-top: 2px solid var(--blue-mid);
}

table.data tr.highlight td {
  background: var(--green-soft) !important;
}

table.data td.total-col {
  background: var(--blue-light);
  font-weight: 700;
}

table.data.dense th,
table.data.dense td {
  padding: 0.32rem 0.42rem;
  font-size: 0.8rem;
}

table.data.presupuesto th,
table.data.presupuesto td {
  padding: 0.2rem 0.38rem;
  font-size: 0.76rem;
  line-height: 1.2;
}

table.data.presupuesto td:first-child {
  word-break: break-word;
}

/* Data bars inside cells */
.bar-cell {
  position: relative;
  isolation: isolate;
}

.bar-cell .bar {
  position: absolute;
  left: 0;
  top: 15%;
  bottom: 15%;
  border-radius: 2px;
  z-index: -1;
  opacity: 0.85;
}

.bar-cell .bar.red {
  background: var(--red-bar);
}

.bar-cell .bar.pink {
  background: var(--pink-bar);
}

.bar-cell .bar.blue {
  background: #90caf9;
}

.bar-cell .bar.green {
  background: #a5d6a7;
}

/* Percentage fill cells (page 5 style) */
.pct-fill {
  text-align: center !important;
  font-weight: 700;
  color: var(--white);
  min-width: 3.2rem;
}

.pct-fill.blue-100 {
  background: var(--blue-cell);
}

.pct-fill.green-hi {
  background: #2e7d62;
}

.pct-fill.green-mid {
  background: #66bb6a;
}

.pct-fill.green-lo {
  background: #a5d6a7;
  color: var(--navy);
}

.pct-fill.muted-fill {
  background: var(--gray-200);
  color: var(--gray-800);
}

/* Trend arrows */
.trend {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.trend .arrow {
  font-size: 0.7rem;
  line-height: 1;
}

.trend.up-bad .arrow,
.trend.up-bad {
  color: var(--red-dot);
}

.trend.down-good .arrow,
.trend.down-good {
  color: var(--green);
}

.trend.up-good .arrow,
.trend.up-good {
  color: var(--green);
}

.trend.down-bad .arrow,
.trend.down-bad {
  color: var(--red-dot);
}

.trend.flat {
  color: var(--gray-600);
}

/* Semáforo dots */
.semaforo {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.dot.red {
  background: var(--red-dot);
}

.dot.yellow {
  background: var(--yellow-dot);
}

.dot.orange {
  background: var(--orange-dot);
}

.dot.green {
  background: var(--green-dot);
}

.dot.green-dark {
  background: #1b5e20;
}

.legend-semaforo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  font-size: 0.7rem;
  color: var(--gray-600);
  margin-bottom: 0.5rem;
  justify-content: flex-end;
}

.legend-semaforo .item {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.legend-semaforo .title {
  font-weight: 700;
  color: var(--navy);
  margin-right: 0.25rem;
}

/* Icon + label in table */
.row-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.row-icon svg {
  width: 18px;
  height: 18px;
  color: var(--blue-mid);
  flex-shrink: 0;
}

/* ---------- ENLA stacked bars ---------- */

.chart-block {
  margin-bottom: 0.5rem;
}

.chart-block h4 {
  margin: 0 0 0.4rem;
  font-size: 0.88rem;
  color: var(--navy);
  font-weight: 700;
}

.enla-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  font-size: 0.68rem;
  margin-bottom: 0.45rem;
  color: var(--gray-600);
}

.enla-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.enla-legend i {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
}

.enla-legend i.previo {
  background: var(--enla-previo);
}

.enla-legend i.inicio {
  background: var(--enla-inicio);
}

.enla-legend i.proceso {
  background: var(--enla-proceso);
}

.enla-legend i.satisf {
  background: var(--enla-satisf);
}

.stacked-rows {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stacked-row {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: 0.45rem;
  align-items: center;
}

.stacked-row .year {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gray-600);
  text-align: right;
}

.stack {
  display: flex;
  height: 22px;
  border-radius: 3px;
  overflow: hidden;
  width: 100%;
}

.stack .seg {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 0;
}

.stack .seg.tiny {
  font-size: 0;
}

.stack .seg.previo {
  background: var(--enla-previo);
}

.stack .seg.inicio {
  background: var(--enla-inicio);
}

.stack .seg.proceso {
  background: var(--enla-proceso);
}

.stack .seg.satisf {
  background: var(--enla-satisf);
}

.stack .seg.has-tip {
  cursor: help;
}

/* ---------- Ficha de detalle (hover / tap) ---------- */

.ficha-tip {
  position: fixed;
  z-index: 12000;
  min-width: 240px;
  max-width: min(22rem, calc(100vw - 1.5rem));
  padding: 0.75rem 0.9rem 0.8rem;
  background: #fffdf8;
  color: var(--navy-deep);
  border: 1px solid #d7c9a6;
  border-radius: 10px;
  box-shadow:
    0 10px 28px rgba(0, 40, 85, 0.18),
    0 1px 4px rgba(0, 40, 85, 0.08);
  pointer-events: none;
  font-size: 0.92rem;
  line-height: 1.35;
}

.ficha-tip.ficha-tip-with-pie {
  max-width: min(28rem, calc(100vw - 1.5rem));
}

.ficha-tip[hidden] {
  display: none !important;
}

.ficha-tip-title {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--navy);
}

.ficha-tip-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.12rem 0;
  border-top: 1px solid #efe6d2;
}

.ficha-tip-row:first-of-type {
  border-top: 0;
}

.ficha-tip-row span {
  color: var(--gray-600);
}

.ficha-tip-row strong {
  font-variant-numeric: tabular-nums;
  color: var(--navy);
  text-align: right;
}

.ficha-tip-pie {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 0.55rem;
}

.ficha-tip-donut {
  width: 4.4rem;
  height: 4.4rem;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(0, 40, 85, 0.12);
}

.ficha-tip-donut::after {
  content: "";
  position: absolute;
  inset: 22%;
  border-radius: 50%;
  background: #fffdf8;
}

.ficha-tip-pie-leyenda {
  font-size: 0.82rem;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  min-width: 0;
  max-height: 11.5rem;
  overflow: auto;
}

.ficha-tip-pie.many {
  align-items: flex-start;
}

.ficha-tip-pie.many .ficha-tip-pie-leyenda {
  font-size: 0.76rem;
}

.ficha-tip-pie-leyenda .is-hi {
  font-weight: 700;
  color: var(--navy);
}

.ficha-tip-swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  margin-right: 0.35rem;
  vertical-align: -1px;
}

.ficha-tip-swatch.rural {
  background: #c45c26;
}

.ficha-tip-swatch.urbana {
  background: #2e6aa6;
}

.ficha-tip-long .ficha-tip-pie,
.ficha-tip-long .ficha-tip-pie-leyenda {
  grid-column: 1 / -1;
}

.fuente-linea {
  margin: 0 0 0.85rem;
  color: var(--navy);
  font-weight: 600;
}

.fuente-linea a {
  color: var(--blue-mid);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ficha-tip.ficha-tip-long {
  display: grid;
  grid-template-columns: repeat(2, minmax(13rem, 1fr));
  column-gap: 1rem;
  max-width: min(38rem, calc(100vw - 1.5rem));
  font-size: 0.78rem;
}

.ficha-tip-long .ficha-tip-title {
  grid-column: 1 / -1;
}

.document-date {
  margin: 0.45rem 0 0;
  padding-top: 0.4rem;
  border-top: 1px solid var(--gray-200);
  color: var(--gray-700);
  font-size: 0.72rem;
}

.document-date strong {
  color: var(--navy);
}

.ux-hint {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  color: var(--gray-600);
}

.stat-pair.has-tip,
.person-item.has-tip {
  cursor: help;
  border-radius: 6px;
  transition: background 0.15s ease;
}

.stat-pair.has-tip:hover,
.person-item.has-tip:hover,
.stat-pair.tip-open,
.person-item.tip-open {
  background: var(--gray-50);
}

@media (hover: none) {
  .ux-hint::before {
    content: "Toque un dato para ver el detalle. ";
  }
}

@media (hover: hover) and (pointer: fine) {
  .ux-hint::before {
    content: "Pase el cursor sobre un dato para ver el detalle. ";
  }
}

/* ---------- Definitions panel (page 7) ---------- */

.defs-panel {
  font-size: 0.75rem;
  color: var(--gray-600);
  line-height: 1.45;
}

.defs-panel h4 {
  margin: 0 0 0.5rem;
  color: var(--navy);
  font-size: 0.85rem;
}

.defs-panel p {
  margin: 0 0 0.55rem;
}

.defs-panel strong {
  color: var(--gray-800);
}

/* ---------- Footer ---------- */

.footer {
  margin-top: auto;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  padding: 0.65rem 1.6rem;
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  align-items: center;
}

.footer .elab {
  color: var(--red-brand);
}

.footer .mail {
  text-align: center;
  color: var(--blue);
  word-break: break-all;
}

.footer .fecha {
  text-align: right;
  color: var(--gray-800);
}

.loading,
.error-box {
  padding: 2rem;
  text-align: center;
  color: var(--gray-600);
}

.error-box {
  color: var(--red-brand);
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .grid-3 .v-divider {
    border-left: 0;
    padding-left: 0;
    border-top: 1px dashed var(--gray-200);
    padding-top: 0.85rem;
  }

  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 860px) {
  .grid-2,
  .grid-2-equal,
  .grid-infra,
  .grid-charts,
  .page[data-page="6"] .infra-split {
    grid-template-columns: 1fr;
  }

  .grid-2 .v-divider,
  .grid-infra .v-divider,
  .grid-2-equal .v-divider {
    border-left: 0;
    padding-left: 0;
    border-top: 1px dashed var(--gray-200);
    padding-top: 0.85rem;
  }

  .footer {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .footer .mail,
  .footer .fecha {
    text-align: center;
  }

  .brand-bar {
    justify-content: flex-end;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .brand-header-img {
    max-height: 56px;
  }

  .page-nav .pager {
    margin-left: 0;
  }

  .page[data-page="1"] > .grid-2 {
    min-height: 0;
  }
}

@media (max-width: 560px) {
  html {
    font-size: 14px;
  }

  .main {
    padding: 0.75rem;
  }

  .kpi-row,
  .kpi-row.kpi-2,
  .kpi-row.kpi-3 {
    grid-template-columns: 1fr;
  }

  .title-banner {
    padding: 0.65rem 0.85rem;
  }

  .region-banner {
    font-size: 1.05rem;
    padding: 0.45rem 0.85rem;
  }

  .region-select {
    font-size: 0.95rem;
    min-width: 12rem;
  }
}

@media (max-width: 720px) {
  html {
    font-size: 16px;
  }

  body {
    background: #fff;
  }

  .app {
    width: 100%;
    box-shadow: none;
  }

  .main {
    padding: 0.85rem 0.9rem 1.15rem;
  }

  .page-nav {
    padding: 0.4rem 0.7rem;
  }

  .page-nav button {
    min-height: 2.75rem;
    font-size: 0.9rem;
  }

  .ficha-tip {
    font-size: 1rem;
    pointer-events: auto;
  }

  table.data.presupuesto th,
  table.data.presupuesto td {
    font-size: 0.8rem;
    padding: 0.28rem 0.32rem;
  }
}

@media print {
  @page {
    margin: 8mm;
  }

  .ficha-tip,
  .ux-hint,
  .region-loading {
    display: none !important;
  }

  body {
    background: white;
  }

  .app {
    box-shadow: none;
    max-width: none;
  }

  .table-wrap {
    overflow: visible !important;
    max-height: none !important;
  }

  .page[data-page="2"] .grid-3 {
    gap: 0.5rem;
  }

  .page[data-page="2"] .v-divider {
    padding-left: 0.55rem;
  }

  .page[data-page="2"] .col-presupuesto .section-title.roman {
    margin-bottom: 0.15rem;
  }

  table.data.presupuesto th,
  table.data.presupuesto td {
    padding: 0.06rem 0.22rem;
    font-size: 0.58rem;
    line-height: 1.12;
  }

  .page[data-page="2"] .col-presupuesto .presupuesto-notas {
    margin-top: 0.18rem;
  }

  .page[data-page="2"] .col-presupuesto .presupuesto-notas p {
    font-size: 0.55rem;
  }

  .page-nav,
  .alerts-banner,
  .ctx-menu,
  .pdf-toast {
    display: none !important;
  }

  .region-select {
    appearance: none;
    border: 0;
    background: transparent;
    padding-left: 0;
  }

  .page {
    display: none;
    animation: none;
    break-after: page;
    page-break-after: always;
  }

  .page.active,
  body.print-all .page {
    display: block !important;
  }

  body.print-all .page:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .brand-bar,
  .title-banner,
  .footer {
    break-inside: avoid;
  }
}

/* ---------- Context menu (export PDF) ---------- */

.ctx-menu {
  position: fixed;
  z-index: 10000;
  min-width: 280px;
  max-width: min(340px, calc(100vw - 16px));
  padding: 0.45rem;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  box-shadow:
    0 8px 24px rgba(0, 40, 85, 0.14),
    0 1px 3px rgba(0, 40, 85, 0.08);
  color: var(--text);
}

.ctx-menu[hidden] {
  display: none !important;
}

.ctx-menu-title {
  margin: 0.2rem 0.55rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gray-400);
}

.ctx-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  width: 100%;
  margin: 0;
  padding: 0.55rem 0.6rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.ctx-item:hover,
.ctx-item:focus-visible {
  background: var(--blue-light);
  outline: none;
}

.ctx-item:focus-visible {
  box-shadow: inset 0 0 0 2px var(--blue-mid);
}

.ctx-icon {
  flex: 0 0 auto;
  width: 1.35rem;
  height: 1.35rem;
  margin-top: 0.1rem;
  color: var(--navy);
}

.ctx-icon svg {
  width: 100%;
  height: 100%;
}

.ctx-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.ctx-text strong {
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--navy);
}

.ctx-text small {
  font-size: 0.72rem;
  color: var(--gray-600);
  line-height: 1.3;
}

.ctx-menu-hint {
  margin: 0.35rem 0.55rem 0.25rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--gray-100);
  font-size: 0.68rem;
  color: var(--gray-400);
  line-height: 1.35;
}

.pdf-toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  z-index: 10001;
  transform: translateX(-50%);
  padding: 0.65rem 1rem;
  border-radius: 999px;
  background: var(--navy);
  color: var(--white);
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 40, 85, 0.28);
  pointer-events: none;
}

.pdf-toast[hidden] {
  display: none !important;
}

/* Captura PDF: una hoja por sección, mismo layout que en pantalla */
body.pdf-capture {
  background: #ffffff !important;
}

body.pdf-capture .app {
  width: 1760px;
  max-width: 1760px;
  min-height: 0;
  margin: 0;
  box-shadow: none;
}

body.pdf-capture .page-nav,
body.pdf-capture .ctx-menu,
body.pdf-capture .pdf-toast,
body.pdf-capture .ficha-tip,
body.pdf-capture .ux-hint,
body.pdf-capture .region-loading {
  display: none !important;
}

body.pdf-capture .table-wrap {
  overflow: visible !important;
  max-height: none !important;
}
