/* Pensado y diseñado por VOC. */
/*
 * Portal de Transparencia: una sola hoja para el portal ciudadano y el backoffice.
 * Interfaz en clave de esquema: papel claro, líneas finas de tinta, sin sombras
 * ni esquinas redondeadas. El color se reserva para los datos (estados, niveles,
 * tipos) y para el juego de colores del organismo, que tiñe lo principal y el
 * degradado suave del fondo. Tipografías del sistema: no se descarga ninguna fuente.
 */
:root {
  color-scheme: light;
  --bg: #fcfcfb;
  --surface: #ffffff;
  --surface-2: #f3f3f1;
  --surface-3: #e7e7e4;
  --ink: #1c1c1c;
  --muted: #5c5c5c;
  --faint: #8b8b8b;
  /* --line: contorno de cajas; --rule: divisiones interiores */
  --line: #1c1c1c;
  --rule: #d2d2ce;
  /* color de dato */
  --ok: #16936a;
  --warn: #b87900;
  --info: #2f7fe0;
  --alt: #7b6fe0;
  /* series de los gráficos: no cambian con el juego de colores (un dato se reconoce siempre por su color) */
  --serie-1: #2a6fbb;
  --serie-1-pista: #c9dcf0;
  --serie-2: #b06a00;
  --off: #8b909c;
  --danger: #c0392b;
  /* Juego de colores (Configuración → Personalización): --acento tiñe los botones principales, el menú
     activo y los informes; --tinte, el degradado del fondo. Los demás juegos están al final de la hoja. */
  --acento: #1c1c1c;
  --acento-2: color-mix(in srgb, var(--acento) 84%, #fff);
  --tinte: #3f7f9c;
  --fondo: linear-gradient(165deg, var(--bg) 0%, color-mix(in srgb, var(--tinte) 5%, var(--bg)) 45%, color-mix(in srgb, var(--tinte) 15%, var(--bg)) 100%);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', 'SF Mono', Consolas, 'Liberation Mono', monospace;
  /* Lo que un tema de diseño cambia además de los colores (Configuración → Personalización → Tema de
     diseño). Con estos valores la interfaz es la de siempre; el backoffice no carga ningún tema. */
  --font-titulo: var(--font);      /* titulares */
  --font-etiqueta: var(--mono);    /* rótulos pequeños: migas, cabeceras de tabla, títulos de panel */
  --font-dato: var(--mono);        /* cifras de tablas y lecturas, códigos, metadatos */
  --etiqueta-caja: uppercase;      /* text-transform de los rótulos */
  --etiqueta-tracking: 1;          /* multiplicador del espaciado entre letras de los rótulos (0: ninguno) */
  --radio: 0px;                    /* esquinas de cajas, botones y campos */
  --sombra: none;                  /* sombra de las cajas */
  --sobre-acento: #fff;            /* texto sobre el color de acento */
  --ancho: 1240px;                 /* ancho máximo del contenido */
  /* marcador de posición de imagen: caja cruzada por sus diagonales */
  --cross:
    linear-gradient(to top right, transparent calc(50% - 0.5px), var(--rule) calc(50% - 0.5px), var(--rule) calc(50% + 0.5px), transparent calc(50% + 0.5px)),
    linear-gradient(to bottom right, transparent calc(50% - 0.5px), var(--rule) calc(50% - 0.5px), var(--rule) calc(50% + 0.5px), transparent calc(50% + 0.5px));
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
/* El degradado va en una capa fija detrás de todo: no se mueve al desplazar la página. */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: var(--fondo); pointer-events: none; }
a { color: inherit; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--ink); color: var(--surface); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------------------------------------------------------------- cabecera */
.top { position: sticky; top: 0; z-index: 20; background: var(--bg); border-top: 3px solid var(--acento); border-bottom: 1px solid var(--line); }
.top__in { max-width: var(--ancho); margin: 0 auto; padding: 0 16px; display: flex; align-items: stretch; gap: 20px; min-height: 46px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 600; white-space: nowrap; }
.brand svg { width: 22px; height: 22px; }
.brand img { height: 28px; max-width: 132px; object-fit: contain; }
.nav { display: flex; flex: 1; flex-wrap: wrap; min-width: 0; }
.nav a, .nav summary {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--muted);
  padding: 0 10px;
  white-space: nowrap;
  font-size: 0.93rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.nav a:hover, .nav summary:hover { color: var(--ink); }
.nav a[aria-current="page"], .nav summary[aria-current="page"] { color: var(--acento); border-bottom-color: var(--acento); font-weight: 600; }
/* administración: desplegable, para que el menú quepa siempre entero */
.nav-mas { position: relative; display: flex; margin-left: 6px; padding-left: 6px; border-left: 1px solid var(--rule); }
.nav summary { cursor: pointer; list-style: none; gap: 6px; user-select: none; }
.nav summary::-webkit-details-marker { display: none; }
.nav summary::after { content: ""; width: 5px; height: 5px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: translateY(-2px) rotate(45deg); }
.nav-mas[open] summary { color: var(--ink); }
.nav-mas__panel { position: absolute; top: 100%; left: -1px; z-index: 30; min-width: 210px; background: var(--bg); border: 1px solid var(--line); padding: 4px 0; display: flex; flex-direction: column; }
.nav-mas__panel a { padding: 8px 14px; border-bottom: 0; border-left: 2px solid transparent; margin: 0; }
.nav-mas__panel a:hover { background: var(--surface); }
.nav-mas__panel a[aria-current="page"] { border-left-color: var(--acento); }
.who { display: flex; align-items: center; gap: 8px; color: var(--muted); font: 0.8rem var(--font-dato); white-space: nowrap; }
.who .dot { width: 7px; height: 7px; background: var(--ok); }
.who a { color: var(--ink); }
.who button { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; color: var(--muted); font: inherit; }
.who button:hover { color: var(--ink); }

/* ---------------------------------------------------------------- layout */
main { flex: 1; width: 100%; max-width: var(--ancho); margin: 0 auto; padding: 22px 16px 56px; }
main:focus { outline: none; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--rule); }
.page-head h1 { margin: 0; font-family: var(--font-titulo); font-size: 1.45rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 70ch; }
.miga { font: 0.74rem var(--font-etiqueta); letter-spacing: calc(0.06em * var(--etiqueta-tracking)); text-transform: var(--etiqueta-caja); color: var(--muted); margin-bottom: 6px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 12px; align-items: start; }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 12px; align-items: start; }
@media (max-width: 900px) { .cols { grid-template-columns: 1fr; } }
/* los hijos de una rejilla pueden encoger: su contenido ancho se desplaza dentro, no ensancha la página */
.cols > *, .grid-2 > *, .stack > * { min-width: 0; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radio); box-shadow: var(--sombra); padding: 14px; }
.panel > h2, .panel > h3, .h-mono {
  margin: 0 0 10px;
  font: 600 0.72rem var(--font-etiqueta);
  letter-spacing: calc(0.08em * var(--etiqueta-tracking));
  text-transform: var(--etiqueta-caja);
  color: var(--muted);
}
.panel--flush { padding: 0; overflow-x: auto; }
.panel--flush > h2 { padding: 12px 14px 0; }
.panel--aviso { border-color: var(--warn); box-shadow: inset 4px 0 0 var(--warn); }
.panel--peligro { border-color: var(--danger); box-shadow: inset 4px 0 0 var(--danger); }

/* ---------------------------------------------------------------- controles */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radio);
  padding: 7px 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { background: var(--surface-3); }
.btn--primary { background: var(--acento); border-color: var(--acento); color: var(--sobre-acento); }
.btn--primary:hover { background: var(--acento-2); }
.btn--ghost { border-style: dashed; }
.btn--danger { color: var(--danger); border-color: var(--danger); }
.btn:disabled { color: var(--faint); border-color: var(--rule); background: var(--surface-2); cursor: not-allowed; }
.btn--sm { padding: 3px 9px; font-size: 0.84rem; }
.link { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.86rem; color: var(--muted); min-width: 0; }
.field input, .field select, .field textarea, .inp {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radio);
  padding: 7px 9px;
  color: var(--ink);
  font-size: 0.95rem;
  width: 100%;
  min-width: 0;
}
.field textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
.field small { color: var(--faint); }
.field input:disabled, .field select:disabled { background: var(--surface-2); color: var(--muted); }
.field--req > span::after { content: ' *'; color: var(--danger); }
.switch { display: inline-flex; gap: 8px; align-items: center; color: var(--ink); font-size: 0.92rem; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--ink); width: 16px; height: 16px; flex: none; }
.form { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.form > * { grid-column: span 6; }
.form > .c2 { grid-column: span 2; }
.form > .c3 { grid-column: span 3; }
.form > .c4 { grid-column: span 4; }
@media (max-width: 640px) { .form > .c2, .form > .c3, .form > .c4 { grid-column: span 6; } }
.form h3 { margin: 10px 0 0; padding-top: 12px; border-top: 1px solid var(--rule); font: 600 0.72rem var(--font-etiqueta); letter-spacing: calc(0.08em * var(--etiqueta-tracking)); text-transform: var(--etiqueta-caja); color: var(--muted); }
.form h3:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.error { color: var(--danger); font-size: 0.9rem; margin: 0; border-left: 3px solid var(--danger); padding: 4px 10px; background: var(--surface); }
.filtros { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.filtros .field { flex: 1 1 150px; max-width: 260px; }
.filtros .field--ancho { flex: 2 1 240px; max-width: 380px; }

/* ---------------------------------------------------------------- lecturas */
.readout { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 0; margin: 0; border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); }
.readout > * { padding: 8px 10px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); text-decoration: none; display: block; }
.readout a:hover { background: var(--surface-2); }
.readout dt { font: 0.68rem var(--font-etiqueta); letter-spacing: calc(0.06em * var(--etiqueta-tracking)); text-transform: var(--etiqueta-caja); color: var(--muted); margin: 0; }
.readout dd { margin: 2px 0 0; font: 500 1.15rem var(--font-dato); font-variant-numeric: tabular-nums; }
.readout dd small { font-size: 0.75rem; color: var(--muted); margin-left: 4px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 8px;
  border: 1px solid var(--rule);
  border-radius: var(--radio);
  background: var(--surface);
  font-size: 0.82rem;
  color: var(--ink);
  white-space: nowrap;
}
.chip::before { content: ''; width: 8px; height: 8px; background: var(--chip, var(--faint)); flex: none; }
.chip--ok { --chip: var(--ok); }
.chip--warn { --chip: var(--warn); }
.chip--info { --chip: var(--info); }
.chip--alt { --chip: var(--alt); }
.chip--danger { --chip: var(--danger); }
.chip--ink { --chip: var(--ink); }
.chip--off { color: var(--muted); border-style: dashed; }
.chip--off::before { background: transparent; outline: 1px solid var(--faint); outline-offset: -1px; }
.chip button { border: 0; background: none; padding: 0 0 0 2px; cursor: pointer; color: var(--muted); line-height: 1; }
.chip button:hover { color: var(--danger); }

.meter { height: 8px; background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.meter > i { display: block; height: 100%; width: 0; background: var(--bar, var(--ink)); }
.bars { display: grid; gap: 6px; }
.bars > div { display: grid; grid-template-columns: minmax(70px, 130px) 1fr 42px; align-items: center; gap: 10px; font-size: 0.86rem; }
.bars span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars output { text-align: right; font: 0.8rem var(--font-dato); font-variant-numeric: tabular-nums; color: var(--muted); }

.note { color: var(--muted); font-size: 0.88rem; margin: 0; }
.note strong { color: var(--ink); }
code, pre { font-family: var(--mono); font-size: 0.86em; }
pre { background: var(--surface-2); border: 1px solid var(--rule); padding: 10px 12px; overflow: auto; margin: 0; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 5px 16px; font-size: 0.92rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.mono { font-family: var(--mono); font-size: 0.86em; font-variant-numeric: tabular-nums; }
.empty { padding: 30px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 1.02rem; margin-bottom: 4px; }

/* ---------------------------------------------------------------- tablas */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { color: var(--muted); font: 600 0.68rem var(--font-etiqueta); letter-spacing: calc(0.06em * var(--etiqueta-tracking)); text-transform: var(--etiqueta-caja); border-bottom-color: var(--line); white-space: nowrap; }
th button { all: unset; cursor: pointer; font: inherit; letter-spacing: inherit; text-transform: inherit; }
th button:hover, th[aria-sort] button { color: var(--ink); }
th button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { font-family: var(--font-dato); font-size: 0.84rem; }
td.acc { text-align: right; white-space: nowrap; }
tr[data-href] { cursor: pointer; }
tr[data-href]:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--line); font: 0.78rem var(--font-dato); color: var(--muted); }

/* ---------------------------------------------------------------- pestañas */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs button {
  appearance: none; background: none; border: 1px solid transparent; border-bottom: 0; border-radius: var(--radio) var(--radio) 0 0;
  padding: 7px 13px; cursor: pointer; color: var(--muted); white-space: nowrap; margin-bottom: -1px; font-size: 0.93rem;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; border-color: var(--line); background: var(--surface); }

/* ---------------------------------------------------------------- diálogos y avisos */
dialog { border: 1px solid var(--line); border-radius: var(--radio); padding: 0; background: var(--surface); color: var(--ink); width: min(680px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
dialog::backdrop { background: rgba(28, 28, 28, 0.35); }
dialog > header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 14px; border-bottom: 1px solid var(--line); font: 600 0.76rem var(--font-etiqueta); letter-spacing: calc(0.06em * var(--etiqueta-tracking)); text-transform: var(--etiqueta-caja); position: sticky; top: 0; background: var(--surface); z-index: 1; }
dialog > header button { border: 0; background: none; cursor: pointer; font: 1rem var(--mono); padding: 0 4px; }
dialog > .cuerpo { padding: 14px; }
/* Visor de documentos: casi toda la pantalla; el documento ocupa lo que dejan la cabecera y la barra. */
dialog.visor { width: min(1180px, calc(100vw - 24px)); height: calc(100dvh - 24px); }
dialog.visor[open] { display: flex; flex-direction: column; }
dialog.visor > .cuerpo { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.visor__barra { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.visor__barra .note { overflow-wrap: anywhere; }
.visor__hoja { flex: 1; min-height: 0; border: 1px solid var(--rule); background: var(--surface-2); display: flex; align-items: center; justify-content: center; overflow: auto; }
.visor__hoja iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.visor__hoja img { max-width: 100%; max-height: 100%; object-fit: contain; }
.visor__hoja pre { align-self: stretch; flex: 1; border: 0; }
.visor__hoja .visor__nota { max-width: 46ch; padding: 24px 16px; text-align: center; }
/* Ventana no modal (novedades de la versión disponible): en una esquina, sin tapar ni bloquear nada. */
dialog.novedades { position: fixed; inset: auto 16px 64px auto; margin: 0; width: min(440px, calc(100vw - 32px)); max-height: min(70dvh, 560px); overflow: auto; z-index: 40; border-color: var(--warn); box-shadow: 0 8px 28px rgba(28, 28, 28, 0.18); }
dialog.novedades ul { margin: 4px 0 0; padding-left: 18px; font-size: 0.9rem; }
dialog.novedades li { margin: 3px 0; }
.avisos { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.aviso { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radio); box-shadow: inset 4px 0 0 var(--ok); padding: 8px 12px 8px 14px; font-size: 0.9rem; }
.aviso--error { box-shadow: inset 4px 0 0 var(--danger); }
.aviso--warn { box-shadow: inset 4px 0 0 var(--warn); }

/* ---------------------------------------------------------------- acceso */
.acceso { max-width: 380px; margin: 9vh auto 0; }
.acceso__logo { display: block; max-height: 76px; max-width: 240px; object-fit: contain; margin: 0 0 14px; }
.acceso h1 { font-family: var(--font-titulo); font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 4px; }
.acceso p { color: var(--muted); margin: 0 0 16px; }

.linea-tiempo { list-style: none; margin: 0; padding: 0; }
.linea-tiempo li { display: grid; grid-template-columns: 128px 1fr; gap: 12px; padding: 7px 0; border-bottom: 1px dotted var(--rule); font-size: 0.9rem; }
.linea-tiempo li:last-child { border-bottom: 0; }
.linea-tiempo time { font: 0.78rem var(--font-dato); color: var(--faint); padding-top: 2px; }
.linea-tiempo p { margin: 2px 0 0; color: var(--muted); }
@media (max-width: 560px) { .linea-tiempo li { grid-template-columns: 1fr; gap: 0; } }



footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 0.8rem; padding: 14px 16px; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Cabecera en pantallas estrechas: la navegación baja a su propia fila y, si no cabe, salta de línea. */
@media (max-width: 980px) {
  .top__in { flex-wrap: wrap; gap: 0 12px; justify-content: space-between; }
  .brand, .who { min-height: 40px; }
  .nav { order: 3; flex: 0 0 100%; border-top: 1px solid var(--rule); margin: 0 -16px; padding: 0 5px; }
  .nav a, .nav summary { min-height: 38px; }
}

/* Impresión: solo el contenido, sin cabecera, pie ni controles. */
@media print {
  .top, footer, .avisos, .no-print { display: none !important; }
  body { background: #fff; }
  body::before { display: none; }
  main { padding: 0; max-width: none; }
  .panel { border: 0; padding: 0; }
}

/* Filtro de selección múltiple */
.multi { position: relative; }
.multi > summary { list-style: none; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: var(--radio); padding: 7px 26px 7px 9px; font-size: 0.93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; }
.multi > summary::-webkit-details-marker { display: none; }
.multi > summary::after { content: ""; position: absolute; right: 10px; top: 50%; width: 5px; height: 5px; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: translateY(-70%) rotate(45deg); }
.multi__panel { position: absolute; z-index: 15; top: 100%; left: 0; min-width: 100%; max-height: 260px; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-top: 0; padding: 6px 9px; display: flex; flex-direction: column; gap: 5px; white-space: nowrap; }


/* configuración inicial: el formulario necesita más ancho que el acceso */
.acceso--ancho { max-width: 760px; margin-top: 4vh; }

/* ---------------------------------------------------------------- verificación en dos pasos */
.totp-pasos { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.totp-qr { width: 176px; height: 176px; border: 1px solid var(--line); background: #fff; image-rendering: pixelated; flex: none; }
.totp-clave { font: 0.95rem var(--mono); letter-spacing: 0.04em; overflow-wrap: anywhere; }
.totp-codigos { font: 1rem var(--mono); line-height: 1.7; margin: 0; padding: 10px 12px; border: 1px solid var(--rule); background: var(--surface); columns: 2; }

/* ---------------------------------------------------------------- actualización en curso */
.mantenimiento { position: fixed; inset: 0; z-index: 100; background: var(--bg); background-image: var(--fondo); display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; }
.mantenimiento > div { max-width: 460px; border: 1px solid var(--line); padding: 28px 24px; background: var(--surface); }
.mantenimiento h1 { font: 600 0.8rem var(--font-etiqueta); letter-spacing: calc(0.1em * var(--etiqueta-tracking)); text-transform: var(--etiqueta-caja); margin: 0 0 12px; }
.mantenimiento p { margin: 0 0 8px; }

/* ---------------------------------------------------------------- personalización */
.logo-previa { max-height: 56px; max-width: 220px; object-fit: contain; border: 1px dashed var(--rule); padding: 6px; background: var(--surface); }
.temas { display: flex; flex-wrap: wrap; gap: 8px; }
.tema { appearance: none; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--rule); border-radius: 0; background: var(--surface); padding: 6px 10px; cursor: pointer; }
.tema i { width: 18px; height: 18px; background: var(--muestra); }
.tema:hover { border-color: var(--line); }
.tema[aria-pressed="true"] { border-color: var(--line); box-shadow: inset 0 -3px 0 var(--muestra); font-weight: 600; }

/* Juegos de colores. Los mismos identificadores están en api.MarcaCtl (servidor) y en admin.js (nombres). */
[data-tema="azul"]    { --acento: #1f4e8c; --tinte: #1f4e8c; }
[data-tema="marino"]  { --acento: #1b2f52; --tinte: #27457a; }
[data-tema="rojo"]    { --acento: #b3261e; --tinte: #b3261e; }
[data-tema="granate"] { --acento: #7a1f2b; --tinte: #7a1f2b; }
[data-tema="verde"]   { --acento: #1f6b4f; --tinte: #1f6b4f; }
[data-tema="morado"]  { --acento: #5b3f8f; --tinte: #5b3f8f; }
[data-tema="teja"]    { --acento: #a84a12; --tinte: #a84a12; }

/* ================================================================ portal ciudadano */
.salto { position: absolute; left: -9999px; top: 0; z-index: 100; background: var(--ink); color: #fff; padding: 8px 14px; }
.salto:focus { left: 8px; top: 8px; }
body.portal { font-size: 16px; }
body.portal main { padding-top: 26px; }
.brand__texto { display: flex; flex-direction: column; line-height: 1.15; padding: 7px 0; }
.brand__texto small { font: 0.72rem var(--font-dato); letter-spacing: 0.04em; color: var(--muted); font-weight: 400; }
body.portal .nav { justify-content: flex-end; }
body.portal .nav a { font-size: 0.97rem; padding: 0 12px; }
/* En pantallas estrechas la cabecera del portal no se queda fija (ocuparía media pantalla) y su menú se alinea a la izquierda. */
@media (max-width: 980px) {
  body.portal .top { position: static; }
  body.portal .nav { justify-content: flex-start; }
  body.portal .nav a { padding: 0 9px; font-size: 0.93rem; }
}
nav.miga a { color: inherit; }
.texto-error { color: var(--danger); }
.trampa { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.panel--ok { border-color: var(--ok); box-shadow: inset 4px 0 0 var(--ok); }
.tabla-scroll { overflow-x: auto; }
/* Los títulos de columna largos («Importe de adjudicación (sin IVA)») se parten en vez de ensanchar la tabla. */
body.portal th, .panel--flush th { white-space: normal; vertical-align: bottom; }
.panel > .row > h2 { font: 600 0.72rem var(--font-etiqueta); letter-spacing: calc(0.08em * var(--etiqueta-tracking)); text-transform: var(--etiqueta-caja); color: var(--muted); }

.portada { padding: 18px 0 26px; border-bottom: 1px solid var(--rule); margin-bottom: 24px; }
.portada h1 { margin: 0; font-family: var(--font-titulo); font-size: clamp(1.7rem, 4vw, 2.3rem); font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.portada__lema { margin: 10px 0 18px; max-width: 62ch; color: var(--muted); font-size: 1.08rem; }
.buscador { display: flex; gap: 8px; max-width: 640px; }
.buscador .inp { flex: 1; padding: 10px 12px; font-size: 1.02rem; }
.buscador .btn { padding: 10px 20px; }

.bloque { margin: 0 0 26px; }
.h-seccion { margin: 0 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); font-family: var(--font-titulo); font-size: 1.12rem; font-weight: 600; letter-spacing: -0.01em; }
.h-seccion a { text-decoration: none; }
.h-seccion a:hover { text-decoration: underline; }

/* Cifras destacadas: el número manda; figuras proporcionales (las tabulares son para columnas). */
.cifras { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; margin: 0 0 14px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: var(--surface); }
.cifras > * { padding: 12px 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-decoration: none; display: block; min-width: 0; }
.cifras a:hover { background: var(--surface-2); }
.cifras dt { font: 0.7rem var(--font-etiqueta); letter-spacing: calc(0.06em * var(--etiqueta-tracking)); text-transform: var(--etiqueta-caja); color: var(--muted); margin: 0; }
.cifras dd { margin: 4px 0 0; font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; overflow-wrap: anywhere; }
.cifras dd small { display: block; font-size: 0.8rem; font-weight: 400; color: var(--muted); letter-spacing: 0; margin-top: 2px; }

.areas { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.area { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-content: start; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radio); box-shadow: var(--sombra); text-decoration: none; }
.area:hover { background: var(--surface-2); }
.area:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.area__cod { grid-row: span 2; width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--acento); color: var(--sobre-acento); font: 600 0.95rem var(--font-dato); border-radius: var(--radio); }
.area strong { font-size: 1.05rem; line-height: 1.25; align-self: center; }
.area__desc { color: var(--muted); font-size: 0.9rem; line-height: 1.4; }
.area .meter { grid-column: 1 / -1; height: 4px; margin-top: 8px; border-color: var(--rule); }
.area__meta { grid-column: 1 / -1; font: 0.74rem var(--font-dato); color: var(--muted); }

.items, .docs, .enlaces, .base-legal { list-style: none; margin: 0; padding: 0; }
.items { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radio); box-shadow: var(--sombra); }
.item { display: flex; gap: 14px; align-items: flex-start; padding: 12px 14px; border-bottom: 1px solid var(--rule); }
.item:last-child { border-bottom: 0; }
.item__cod { flex: none; width: 3.4em; font: 0.8rem var(--font-dato); color: var(--muted); padding-top: 3px; }
.item__cuerpo { flex: 1; min-width: 0; }
.item__cuerpo p { margin: 2px 0 0; color: var(--muted); font-size: 0.93rem; }
.item__titulo { font-weight: 600; font-size: 1.04rem; }
.item__meta, .item__cuerpo p.item__meta { font: 0.76rem var(--font-dato); color: var(--muted); margin-top: 4px; }
.item__estado { flex: none; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
@media (max-width: 640px) { .item { flex-wrap: wrap; } .item__estado { flex-direction: row; width: 100%; padding-left: calc(3.4em + 14px); } }

.docs { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radio); box-shadow: var(--sombra); }
.doc { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--rule); }
.doc:last-child { border-bottom: 0; }
.doc__cuerpo { flex: 1 1 320px; min-width: 0; }
.doc__cuerpo p { margin: 2px 0 0; color: var(--muted); font-size: 0.92rem; }
.doc__titulo { font-weight: 600; text-align: left; font-size: 1rem; }
.enlaces li { padding: 7px 0; border-bottom: 1px dotted var(--rule); }
.enlaces li:last-child { border-bottom: 0; }
.base-legal li { padding: 3px 0 3px 12px; border-left: 2px solid var(--rule); margin-bottom: 6px; font-size: 0.9rem; }
.descargas { font-size: 0.92rem; margin: 10px 0 0; }
.recargando { opacity: 0.45; transition: opacity 0.15s; }

.cols--ficha { grid-template-columns: minmax(0, 1fr) minmax(250px, 320px); gap: 20px; }
@media (max-width: 900px) { .cols--ficha { grid-template-columns: 1fr; } }
.ficha .kv { grid-template-columns: 1fr; gap: 0; }
.ficha .kv dt { font: 0.68rem var(--font-etiqueta); letter-spacing: calc(0.06em * var(--etiqueta-tracking)); text-transform: var(--etiqueta-caja); margin-top: 8px; }

/* Texto redactado (js/texto.js) */
.prosa { line-height: 1.6; }
.prosa > :first-child { margin-top: 0; }
.prosa > :last-child { margin-bottom: 0; }
.prosa p, .prosa ul { max-width: 74ch; margin: 0 0 12px; }
.prosa h3 { margin: 20px 0 8px; font-family: var(--font-titulo); font-size: 1.05rem; font-weight: 600; }
.prosa h2 + h3, .prosa h3:first-child { margin-top: 0; }
.prosa ul { padding-left: 20px; }
.prosa li { margin: 4px 0; }
.previa { min-height: 180px; }

.pie { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 0.88rem; padding: 0; text-align: left; }
.pie__in { max-width: var(--ancho); margin: 0 auto; padding: 18px 16px 22px; }
.pie p { margin: 0 0 6px; }
.pie strong { color: var(--ink); }
.pie__nota { font: 0.74rem var(--font-dato); margin-top: 10px !important; }

/* ================================================================ gráficos (js/graficos.js) */
.graficos { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(440px, 100%), 1fr)); gap: 12px; align-items: start; margin-bottom: 14px; }
.grafico { position: relative; margin: 0; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radio); box-shadow: var(--sombra); min-width: 0; }
.grafico figcaption { font-weight: 600; margin-bottom: 10px; line-height: 1.3; }
.grafico__lienzo { width: 100%; min-height: 240px; }
.grafico__lienzo svg { display: block; overflow: visible; }
.grafico__tabla { margin-top: 10px; font-size: 0.86rem; }
.grafico__tabla summary { cursor: pointer; color: var(--muted); width: fit-content; }
.grafico__tabla summary:hover { color: var(--ink); }
.grafico__tabla table { margin-top: 8px; font-size: 0.84rem; }
.grafico__tabla th[scope="row"] { font: inherit; text-transform: none; letter-spacing: 0; color: var(--ink); border-bottom-color: var(--rule); white-space: normal; }
.grafico__detalle { position: absolute; z-index: 5; pointer-events: none; background: var(--ink); color: #fff; padding: 6px 10px; font-size: 0.82rem; line-height: 1.4; max-width: 260px; }
.grafico__detalle strong { display: block; font-weight: 400; color: #cfcfcb; font-size: 0.76rem; }
.grafico__detalle div { display: flex; align-items: baseline; gap: 6px; }
.grafico__detalle b { font-weight: 600; font-size: 0.92rem; }
.grafico__detalle span { color: #cfcfcb; }

.leyenda { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0 0 10px; padding: 0; font-size: 0.82rem; color: var(--muted); }
.leyenda li { display: inline-flex; align-items: center; gap: 6px; }
.clave { display: inline-block; flex: none; width: 12px; height: 12px; background: var(--serie-1); }
.clave--2 { background: var(--serie-2); }
.clave--pista { background: var(--serie-1-pista); }
.clave--linea { height: 2px; width: 16px; align-self: center; }
.grafico__detalle .clave { outline: 1px solid rgba(255, 255, 255, 0.5); }

.barras-h { display: grid; gap: 7px; }
.barra { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; align-items: center; gap: 10px; font-size: 0.88rem; padding: 1px 0; }
.barra:hover .barra__valor, .barra:focus .barra__valor { filter: brightness(1.18); }
.barra__nombre { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.25; }
.barra__pista { position: relative; height: 14px; border-left: 1px solid var(--ink); }
.barra__pista i { position: absolute; left: 0; top: 0; height: 100%; display: block; }
.barra__total { background: var(--serie-1-pista); }
.barra__valor { background: var(--serie-1); }
.barra__cifra { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 5.5em; }
.barra__cifra small { display: block; color: var(--muted); font-size: 0.76rem; }
@media (max-width: 520px) { .barra { grid-template-columns: 1fr auto; } .barra__nombre { grid-column: 1 / -1; -webkit-line-clamp: 3; } }

.grafico svg .rejilla { stroke: var(--rule); stroke-width: 1; }
.grafico svg .eje { stroke: var(--ink); stroke-width: 1; }
.grafico svg .marca { font: 11px var(--font); fill: var(--muted); font-variant-numeric: tabular-nums; }
.grafico svg .marca--y { text-anchor: end; }
.grafico svg .marca--x { text-anchor: middle; }
.grafico svg .marca--ref { text-anchor: start; fill: var(--danger); }
.grafico svg .referencia { stroke: var(--danger); stroke-width: 1; stroke-dasharray: 5 4; }
.grafico svg .linea { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.grafico svg .linea.serie-1, .grafico svg .punto.serie-1 { stroke: var(--serie-1); }
.grafico svg .linea.serie-2, .grafico svg .punto.serie-2 { stroke: var(--serie-2); }
.grafico svg .punto { stroke: var(--surface) !important; stroke-width: 2; }
.grafico svg .punto.serie-1, .grafico svg .columna.serie-1 { fill: var(--serie-1); }
.grafico svg .punto.serie-2, .grafico svg .columna.serie-2 { fill: var(--serie-2); }
.grafico svg .valor { font: 600 11px var(--font); fill: var(--ink); text-anchor: middle; font-variant-numeric: tabular-nums; }
.grafico svg .valor--fin { text-anchor: start; }
.grafico svg .guia { stroke: var(--muted); stroke-width: 1; }
.grafico svg .franja { fill: transparent; cursor: default; outline: none; }
.grafico svg .franja:hover, .grafico svg .franja:focus-visible { fill: rgba(28, 28, 28, 0.05); }

/* ================================================================ backoffice */
.segmentos { display: flex; height: 8px; gap: 2px; min-width: 60px; }
.seg { display: block; min-width: 3px; height: 100%; }
.leyenda .seg { width: 12px; height: 8px; min-width: 12px; }
.seg--al_dia { background: var(--ok); }
.seg--por_vencer { background: var(--warn); }
.seg--vencida { background: var(--danger); }
.seg--sin_publicar { background: var(--surface-3); outline: 1px solid var(--faint); outline-offset: -1px; }
.repartos { display: grid; gap: 8px; }
.repartos > div { display: grid; grid-template-columns: minmax(110px, 42%) 1fr 64px; align-items: center; gap: 10px; font-size: 0.88rem; }
.repartos span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.repartos output { text-align: right; font: 0.8rem var(--font-dato); color: var(--muted); }

.subida { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px; padding: 22px 16px; border: 1px dashed var(--line); background: var(--surface); color: var(--muted); text-align: center; }
.subida strong { color: var(--ink); }
.subida--encima { background: var(--surface-2); border-style: solid; box-shadow: inset 0 0 0 2px var(--acento); }
.columna-propia { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 2fr) auto auto; gap: 6px; align-items: center; }
.columna-propia .inp[hidden] + label { grid-column: span 2; justify-self: start; }
.enlace-fila { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; gap: 6px; align-items: center; }
@media (max-width: 640px) { .columna-propia, .enlace-fila { grid-template-columns: 1fr; } }
.pasos { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.lista-compacta { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 0.92rem; }
.opcion { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.opcion input { margin-top: 3px; }
.giro { width: 28px; height: 28px; margin: 0 auto 12px; border: 3px solid var(--rule); border-top-color: var(--ink); border-radius: 50%; animation: giro 0.9s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }
.panel--flush > h2 + table, .panel--flush > h2 + .empty { margin-top: 8px; }

/* ---------------------------------------------------------------- anonimizador */
.anon { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .anon { grid-template-columns: 1fr; } }
.anon__panel { position: sticky; top: 60px; max-height: calc(100dvh - 76px); overflow: auto; padding-right: 2px; }
@media (max-width: 1000px) { .anon__panel { position: static; max-height: none; } }
.anon__barra { position: sticky; top: 49px; z-index: 6; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 10px; background: var(--bg); border: 1px solid var(--line); }
.anon__barra .leyenda { margin: 0 0 0 auto; }
.anon__barra .btn[aria-pressed="true"] { background: var(--ink); color: #fff; }
.anon__paginas { display: flex; flex-direction: column; gap: 20px; padding: 16px 10px 26px; background: var(--surface-2); border: 1px solid var(--line); border-top: 0; }
.anon__marco { width: 100%; max-width: 60rem; margin: 0 auto; }
.anon__marco > .note { margin-bottom: 6px; }
.anon__pagina { position: relative; width: 100%; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.anon__pagina canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.capa { position: absolute; inset: 0; touch-action: pan-y; }
.anon--dibujando .capa { cursor: crosshair; touch-action: none; }
.caja { position: absolute; outline: 2px dashed #1d70b8; background: rgba(29, 112, 184, 0.14); cursor: pointer; }
.caja:hover { background: rgba(29, 112, 184, 0.3); }
.caja--sel { outline: 1px solid #0b0c0c; background: rgba(11, 12, 12, 0.86); }
.caja--sel:hover { background: rgba(11, 12, 12, 0.65); }
.caja--duda:not(.caja--sel) { outline: 2px dotted #c2410c; background: rgba(244, 119, 56, 0.25); }
.anon--pseudo .caja--sel { outline: 1px solid #475569; background: #e2e8f0; color: #0b0c0c; }
.caja__etq { display: none; align-items: center; justify-content: center; height: 100%; padding: 0 2px; overflow: hidden; font: 700 9px/1 var(--font); white-space: nowrap; }
.anon--pseudo .caja--sel .caja__etq { display: flex; }
.caja--destello { animation: destello 1.2s ease-out 2; }
@keyframes destello { 50% { box-shadow: 0 0 0 4px #ffdd00, 0 0 0 7px #0b0c0c; } }
.caja-nueva { position: absolute; border: 2px solid #1d70b8; background: rgba(29, 112, 184, 0.18); pointer-events: none; }
.muestra { display: inline-block; flex: none; width: 22px; height: 12px; }
.muestra--sel { background: #0b0c0c; }
.muestra--nosel { border: 2px dashed #1d70b8; background: #e3edf7; }
.muestra--duda { border: 2px dotted #c2410c; background: #ffe8d9; }
.anon__dudas { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.anon__dudas li { padding-top: 10px; border-top: 1px solid var(--rule); }
.anon__dudas p { margin: 0 0 6px; }
.anon__grupo { border-top: 1px solid var(--rule); padding: 6px 0; }
.anon__grupo summary { display: flex; justify-content: space-between; gap: 10px; cursor: pointer; font-weight: 600; padding: 2px 0; }
.anon__grupo ul { list-style: none; margin: 6px 0 0; padding: 0; max-height: 240px; overflow: auto; }
.anon__grupo li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px; padding: 4px 0; font-size: 0.9rem; border-bottom: 1px dotted var(--rule); }
.anon__grupo li .switch { flex: 1 1 160px; min-width: 0; overflow-wrap: anywhere; }
.anon__grupo p { margin: 6px 0 0; font-size: 0.86rem; }
.anon__tipo { width: auto; padding: 2px 4px; font-size: 0.8rem; }