/* Componentes compartidos por la aplicación y el informe PDF (hallazgos, matriz, mapa de calor, gráficos, impresión). */

:root {
  --noche: #0B1830;
  --tarjeta: #FFFFFF;
  --borde: #E6E0D2;
  --radio-g: 14px;
  --radio-m: 10px;
  --sombra-1: 0 1px 2px rgba(11, 24, 48, .06), 0 2px 8px rgba(11, 24, 48, .05);
}

/* ───── Hallazgos (v2) ───── */
.hallazgos { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.hallazgo { display: block; background: var(--tarjeta); border: 1px solid var(--borde); border-left: 4px solid var(--ambar); border-radius: var(--radio-g); box-shadow: var(--sombra-1); padding: 20px 22px; position: relative; }
.hallazgo__cabecera { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.hallazgo__prioridad { background: var(--noche); color: #fff; border-radius: 8px; min-width: 28px; height: 28px; display: inline-grid; place-items: center; font-family: var(--fuente-titulo); font-weight: 800; font-size: .95rem; line-height: 1; }
.hallazgo__tipo { font-size: .78rem; font-weight: 700; color: var(--tinta-suave); letter-spacing: .02em; }
.hallazgo__ambito { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--fondo-suave); color: var(--tinta-suave); }
.hallazgo .hallazgo__titulo { font-family: var(--fuente-texto, inherit); font-size: 1.02rem; font-weight: 650; line-height: 1.45; margin: 0 0 10px; letter-spacing: 0; text-wrap: pretty; }
.hallazgo__datos { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.hallazgo__datos .dato { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; padding: 3px 10px; border-radius: 999px; background: var(--fondo-suave); color: var(--tinta); }
.hallazgo__detalle { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; padding-top: 14px; border-top: 1px solid var(--borde); }
.hallazgo__bloque p { margin: 4px 0 0; font-size: .92rem; line-height: 1.55; }
.hallazgo__rotulo { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--tinta-suave); }
.hallazgo__citas { grid-column: 1 / -1; display: grid; gap: 6px; }
.hallazgo__cita { margin: 0; padding: 8px 12px; border-left: 3px solid #7FBF9A; background: #F1F7F2; border-radius: 0 8px 8px 0; font-size: .88rem; font-style: italic; color: var(--tinta); }
.hallazgo__cita::before { content: "«"; } .hallazgo__cita::after { content: "»"; }
.hallazgo__cita--contra { border-left-color: #D98A84; background: #FBF0EF; }
.hallazgo__medida { grid-column: 1 / -1; margin: 0; font-size: .82rem; color: var(--tinta-suave); }
.hallazgo__pie { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-top: 16px; }
.hallazgo__pie form { margin: 0; }
.hallazgo__pie a { font-size: .9rem; font-weight: 600; }
.hallazgos--compactos .hallazgo { padding: 16px 18px; box-shadow: none; }
.hallazgos--compactos .hallazgo__detalle { grid-template-columns: 1fr; }
.hallazgo__plegable summary { cursor: pointer; font-size: .88rem; font-weight: 600; color: var(--tinta); }
.hallazgo__plegable[open] summary { margin-bottom: 12px; }
@container (max-width: 620px) { .hallazgo__detalle { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .hallazgo__detalle { grid-template-columns: 1fr; } }

/* ───── Matriz de atributos (v2: mapa de color compacto) ───── */
.matriz-bloque .leyenda { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 0 0 14px; padding: 0; list-style: none; font-size: .82rem; }
.leyenda__item { display: inline-flex; align-items: center; gap: 8px; color: var(--tinta); }
.leyenda__muestra { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--estado-fondo, var(--fondo-suave)); color: var(--estado-color); border-left: 3px solid var(--estado-color); }
.leyenda__ayuda { color: var(--tinta-suave); }
@media screen and (max-width: 1100px) { .leyenda__ayuda { display: none; } }
.matriz-envoltorio { background: var(--tarjeta); }
table.matriz { table-layout: fixed; min-width: 760px; width: 100%; font-size: .85rem; }
.matriz thead th { min-width: 0; max-width: none; padding: 12px 10px; font-family: var(--fuente-texto); font-size: .85rem; font-weight: 700; border-bottom: 1px solid var(--borde); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.matriz thead th:first-child, .matriz tbody th { width: 190px; }
.matriz tbody th { min-width: 0; max-width: none; padding: 8px 14px; font-weight: 600; font-size: .86rem; vertical-align: middle; border-bottom: 1px solid var(--borde); }
.matriz td { border-left: 0; border-bottom: 1px solid var(--borde); padding: 4px; vertical-align: middle; }
.matriz__celda { min-height: 0; margin: 0; padding: 7px 10px; border-radius: 7px; border-left-width: 3px; display: grid; gap: 2px; }
.matriz__celda.estado-desconocido { background: transparent; border-left-color: var(--borde); }
.matriz__celda.estado-desconocido .matriz__estado { color: var(--tinta-suave); font-weight: 500; }
.matriz__estado { font-size: .8rem; }
.matriz__resumen { margin: 0; font-size: .78rem; line-height: 1.35; color: var(--tinta); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.matriz__ventaja { margin: 0; font-size: .72rem; font-weight: 700; }
.matriz__ventaja--ventaja { color: #1F7A45; }
.matriz__ventaja--desventaja { color: #B3261E; }
.matriz tbody tr:hover th { background: var(--fondo-suave); }
.fichas { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
@media (max-width: 720px) { table.matriz { min-width: 0; } .matriz thead th:first-child, .matriz tbody th { width: auto; } }
.kpi__nota .pildora { margin-top: 6px; }
.titular-informe { font-size: clamp(1.45rem, 1rem + 1vw, 1.9rem); max-width: 52ch; }
.rejilla > .tarjeta, .rejilla > section, .rejilla > aside { margin-top: 0; }
.ficha { min-width: 0; }
.ficha__segmentos { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 8px 0; list-style: none; }
.ficha__segmentos .insignia { white-space: normal; max-width: 100%; line-height: 1.3; padding: 3px 9px; }

/* ───── Mapa de oportunidades: mapa de calor ───── */
table.mapa { table-layout: fixed; min-width: 760px; }
.mapa thead th:first-child, .mapa tbody th { width: 34%; min-width: 0; max-width: none; }
.mapa thead th { min-width: 0; font-family: var(--fuente-texto); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mapa td { border-left: 0; padding: 4px; }
.mapa__celda { min-height: 50px; border-radius: 8px; margin: 0; background: color-mix(in srgb, var(--marca-color, var(--tinta)) var(--calor, 0%), #fff); transition: transform .1s; }
.mapa__celda:hover { background: color-mix(in srgb, var(--marca-color, var(--tinta)) var(--calor, 0%), #fff); outline: 2px solid var(--tinta); outline-offset: -2px; }
.mapa__celda--intensa, .mapa__celda--intensa .mapa__vacio { color: #fff; }
.mapa__celda--ausente { background: transparent; border: 1px dashed var(--borde); }
.mapa__celda--ausente .mapa__vacio { font-size: .8rem; }
.mapa__celda--oportunidad { box-shadow: inset 0 0 0 2px var(--ambar); }
.mapa__fila--oportunidad th { border-left: 4px solid var(--ambar); }
.mapa__tipo { font-weight: 600; font-size: .78rem; }
.tabla-fuentes td:not(:first-child), .tabla-fuentes th { white-space: nowrap; }
.tabla-fuentes td:first-child { width: 100%; }
.rejilla > *, .series > *, .fichas > *, .kpis > * { margin-top: 0 !important; margin-bottom: 0; }
.rejilla { align-items: start; }
.contenedor > .titular, .contenedor > h1.titular { font-size: clamp(1.7rem, 1.2rem + 1.3vw, 2.4rem); max-width: 34ch; }
.panel-evidencia h2 .marca-etiqueta, .cabeza-detalle__titulo .marca-etiqueta { font: inherit; }
.panel-evidencia h2 { font-size: 1.5rem; }
.cabeza-detalle { margin: 16px 0 20px; }
.cabeza-detalle__titulo { font-size: clamp(1.5rem, 1.1rem + 1vw, 2rem); margin: 0 0 6px; }
.panel-evidencia + .panel-evidencia { margin-top: 16px; }

/* ───── Impresión / PDF A4 ───── */
@media print {
  table.matriz, table.mapa { min-width: 0 !important; table-layout: fixed; }
  .matriz thead th:first-child, .matriz tbody th { width: 120px; }
  .mapa thead th:first-child, .mapa tbody th { width: 34%; }
  .matriz thead th, .mapa thead th { white-space: normal; }
  .matriz__resumen { display: block; -webkit-line-clamp: unset; overflow: visible; }
  .matriz__celda, .mapa__celda { padding: 4px 6px; }
  .mapa__celda { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .matriz__estado { font-size: 7.5pt; }
  body.informe td, body.informe th { overflow-wrap: normal; word-break: normal; hyphens: manual; }
}
body.informe .tabla td:first-child { min-width: 110px; }
.mapa__celda--intensa, .mapa__celda--intensa:hover { background: var(--marca-color, var(--tinta)); }
@media print {
  *, *::before, *::after { box-shadow: none !important; text-shadow: none !important; backdrop-filter: none !important; filter: none !important; }
}

.ficha__segmentos .insignia { border-radius: 8px; }

/* ───── Informe A4: cifras en filas y extractos en línea ───── */
body.informe .cifras-fila { display: grid; grid-template-columns: 1fr; gap: 0; margin: 8px 0 18px; }
body.informe .cifra { display: grid; grid-template-columns: minmax(0, 1fr) 5em 8em auto; gap: 2px 12px; align-items: baseline; padding: 5px 0; border-bottom: 1px solid #E4DED0; min-width: 0; }
body.informe .cifra__valor { font-size: 11pt; text-align: right; }
body.informe .cifra__etiquetas { display: flex; gap: 4px; }
body.informe .cifra a, body.informe .cifra details { display: none; }
body.informe .extracto { display: inline; padding: 0 2px; margin: 0; border: 0; background: #FCEFC7; font-size: inherit; line-height: inherit; font-style: italic; }
body.informe .cifra { display: block; }
body.informe .cifra > * { display: inline; margin-right: 8px; }
body.informe .cifra__etiqueta { font-size: 9.5pt; }
body.informe .cifra__valor { font-size: 11pt; }
body.informe .cifra__etiquetas { display: inline-flex; vertical-align: middle; }
.barras__fila { grid-template-columns: minmax(120px, 180px) minmax(0, 1fr) 7.5em; }
.barras__dato { text-align: right; }
@media print {
  .matriz thead th:first-child, .matriz tbody th { width: 168px; white-space: nowrap; font-size: 8pt; }
  .matriz__celda.estado-desconocido { border-left-color: #E4DED0 !important; }
}

/* ───── Gráficos de barras (aplicación e informe) ───── */
.barras { display: grid; gap: 14px; }
.barras__fila { display: grid; grid-template-columns: minmax(120px, 190px) 1fr auto; gap: 14px; align-items: center; }
.barras__nombre { font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.barras__nombre span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barras__pista { position: relative; height: 26px; background: var(--fondo-suave); border-radius: 7px; overflow: hidden; }
.barras__relleno { position: absolute; inset: 0 auto 0 0; background: var(--marca-color, var(--tinta)); border-radius: 7px; min-width: 2px; }
.barras__intervalo { position: absolute; top: 50%; height: 2px; background: rgba(11, 24, 48, .55); transform: translateY(-50%); }
.barras__intervalo::before, .barras__intervalo::after { content: ""; position: absolute; top: -5px; width: 2px; height: 12px; background: rgba(11, 24, 48, .55); }
.barras__intervalo::before { left: 0; } .barras__intervalo::after { right: 0; }
.barras__fila--propia .barras__nombre { color: var(--tinta); }
.barras__fila--propia .barras__pista { box-shadow: inset 0 0 0 2px var(--marca-color); }
.barras__dato { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; font-size: .92rem; }
.barras__dato strong { font-size: 1.05rem; }
.barras__leyenda { font-size: .82rem; color: var(--tinta-suave); margin-top: 12px; }
.mini-barra { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.mini-barra__pista { flex: 1; height: 8px; background: var(--fondo-suave); border-radius: 4px; overflow: hidden; }
.mini-barra__pista span { display: block; height: 100%; background: var(--marca-color, var(--tinta)); }
.barras { container-type: inline-size; }
@container (max-width: 560px) {
  .barras__fila { grid-template-columns: 1fr auto; gap: 6px 12px; }
  .barras__pista { grid-column: 1 / -1; grid-row: 2; }
}

/* ───── Informe A4: tablas ───── */
body.informe .tabla .discreto, body.informe .tabla .suave { font-size: 7.5pt; line-height: 1.4; }
body.informe .tabla { table-layout: fixed; }
body.informe .tabla td.num { text-align: center; }
body.informe .barras__fila { grid-template-columns: 150px minmax(0, 1fr) 7em; }
body.informe .barras__pista { height: 14px; }
body.informe .barras__fila { grid-template-columns: 150px minmax(0, 1fr) 9.5em; }
body.informe .barras__dato, body.informe .barras__dato strong { font-size: 9pt; }
body.informe .cifra .pildora, body.informe .cifra .insignia { font-size: 7pt; padding: 1px 6px; }
body.informe .aviso-honesto { break-inside: avoid; }
/* Nombres largos: el punto de color se alinea con la primera línea; el dominio no se parte por el guion */
.ficha h3 .marca-etiqueta { align-items: flex-start; }
.ficha h3 .marca-etiqueta__punto { margin-top: .35em; }
.ficha p > span.suave { white-space: nowrap; }
