/* Informes prescritos (cfg_reports): los usa la tarjeta del chat y la página /informes. */
.rpt { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.rpt-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.rpt-head h2 { font-family: var(--font-display); font-size: 20px; letter-spacing: -0.01em; margin: 0; text-wrap: balance; }
.rpt-head .meta { color: var(--muted); font-size: 12.5px; }
.rpt-desc { color: var(--ink-2); font-size: 13px; margin: -6px 0 0; max-width: 70ch; }
.rpt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.rpt-sec { grid-column: 1 / -1; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.rpt-sec.half { grid-column: span 1; }
.rpt-sec.kpis { background: none; border: none; padding: 0; }
.rpt-sec h3 { font-size: 14.5px; margin: 0 0 2px; }
.rpt-sec .note { color: var(--muted); font-size: 12px; margin: 0 0 8px; }
.rpt-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 8px; }
.rpt-kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; border-top: 3px solid var(--line-strong); }
.rpt-kpi.good { border-top-color: var(--good); } .rpt-kpi.warning { border-top-color: var(--warning); } .rpt-kpi.critical { border-top-color: var(--critical); }
.rpt-kpi .l { font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.rpt-kpi .v { font-family: var(--font-display); font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); line-height: 1.2; margin-top: 2px; }
.rpt-kpi .n { color: var(--muted); font-size: 11.5px; }
.rpt-chart { width: 100%; min-height: 60px; }
.rpt-chart .vega-embed { width: 100%; }
.rpt-chart .vega-embed summary { opacity: .5; }
.rpt-table { overflow-x: auto; }
.rpt-table table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.rpt-table th, .rpt-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rpt-table th { font-family: var(--font-mono); color: var(--muted); font-weight: 700; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.rpt-table td { white-space: nowrap; }
.rpt-table td.wide { white-space: normal; min-width: 220px; }
.rpt-table a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 2px; }
.rpt-table a:hover { text-decoration-color: currentColor; }
.rpt-list { margin: 4px 0 0; padding-left: 18px; columns: 2 220px; font-size: 13px; }
.rpt-list li { break-inside: avoid; margin-bottom: 2px; }
.rpt-empty { color: var(--muted); font-size: 12.5px; padding: 6px 0; }
.rpt-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.rpt-more { color: var(--muted); font-size: 12px; margin-top: 6px; }
.rpt-hint { color: var(--muted); font-size: 12px; margin: -6px 0 0; }
/* Filtros del tablero: selectores, rango de fechas y fichas de lo filtrado; se quedan arriba al bajar. */
.rpt-ftools { position: sticky; top: calc(60px + env(safe-area-inset-top, 0px)); z-index: 5; display: flex; flex-direction: column; gap: 8px; background: var(--bg); padding-block: 6px; }
.rpt-ftools:not(:has(.rpt-fbar)):has(.rpt-chips[hidden]) { display: none; }
.rpt-ffold > summary { cursor: pointer; width: fit-content; font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 2px 0; }
.rpt-ffold[open] > summary { margin-bottom: 6px; }
@media (min-width: 601px) { .rpt:not(.in-card) .rpt-ffold > summary { display: none; } }
.rpt.in-card .rpt-ffold > summary { font-size: 12px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--panel); color: var(--ink); }
@media (max-width: 600px) { .rpt-ffold > summary { font-size: 12px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--panel); color: var(--ink); } }
.report-card .rpt-ftools { position: static; background: none; padding-block: 0; }
.rpt-fbar { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; }
.rpt-fsel, .rpt-fdate { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.rpt-fdate { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; }
.rpt-fdate > span:first-child { width: 100%; }
.rpt-fsel > span, .rpt-fdate > span:first-child { font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.rpt-fsel select, .rpt-fdate input { font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--panel); color: var(--ink); max-width: 100%; }
.rpt-fsel select { max-width: 220px; }
.rpt-fsep { color: var(--muted); font-size: 12px; }
.rpt-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.rpt-chips[hidden] { display: none; }
.rpt-chip { display: inline-flex; align-items: center; gap: 4px; background: var(--tint); border: 1px solid var(--accent); color: var(--ink); border-radius: 999px; padding: 3px 4px 3px 10px; font-size: 12.5px; max-width: 100%; }
.rpt-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rpt-chip button { border: none; background: none; color: var(--muted); cursor: pointer; font: inherit; width: 22px; height: 22px; border-radius: 50%; line-height: 1; }
.rpt-chip button:hover, .rpt-chip button:focus-visible { background: var(--line); color: var(--ink); outline: none; }
.rpt-chips .btn { padding: 4px 10px; font-size: 12.5px; }
.rpt-kpi.filtered { border-color: var(--accent); }
.rpt-kpi.fixed { opacity: .55; }
@media (max-width: 600px) { .rpt-fsel { flex: 1 1 45%; } .rpt-fsel select { max-width: none; width: 100%; } }
.rpt-open-rec { border: none; background: none; padding: 0; font: inherit; color: var(--ink); text-align: left; cursor: pointer; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 2px; }
.rpt-open-rec:hover, .rpt-open-rec:focus-visible { text-decoration-color: currentColor; outline: none; }
.rpt-sp { color: var(--muted); text-decoration: none; font-size: 12px; white-space: nowrap; }
.rpt-sp:hover { color: var(--ink); }
.rpt-drawer-back { position: fixed; inset: 0; z-index: 1000; background: rgba(6, 20, 25, .35); display: flex; justify-content: flex-end; }
.rpt-drawer { width: min(460px, 100%); height: 100%; background: var(--panel); border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgba(0,0,0,.18); overflow-y: auto; padding: calc(16px + env(safe-area-inset-top, 0px)) 18px calc(18px + env(safe-area-inset-bottom, 0px)); position: relative; }
.rpt-drawer-x { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: 10px; border: none; background: none; font-size: 16px; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; }
.rpt-drawer-x:hover { background: var(--chip); color: var(--ink); }
.rpt-drawer h3 { font-family: var(--font-display); font-size: 18px; margin: 4px 32px 4px 0; text-wrap: balance; }
.rpt-drawer-k { font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding-right: 32px; }
.rpt-drawer-meta { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.rpt-fields { margin: 8px 0 16px; display: flex; flex-direction: column; gap: 8px; }
.rpt-fields > div { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 10px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.rpt-fields dt { color: var(--muted); font-size: 12.5px; min-width: 0; overflow-wrap: anywhere; }
.rpt-fields dd { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) { .rpt-fields > div { grid-template-columns: minmax(0, 1fr); gap: 2px; } }
.rpt-fields dd { margin: 0; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 720px) { .rpt-sec.half { grid-column: 1 / -1; } }
/* ---------- tarjeta de cálculo y alertas de reglas ---------- */
.calc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; margin: 10px 0 4px; }
.calc-card { border: 1px solid var(--line); border-left: 4px solid var(--line-strong); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--bg); display: flex; flex-direction: column; gap: 4px; animation: rpt-rise .3s ease-out both; }
.calc-card.good { border-left-color: var(--good); } .calc-card.warning { border-left-color: var(--warning); } .calc-card.high { border-left-color: var(--s2); } .calc-card.critical { border-left-color: var(--critical); }
.calc-top { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.calc-val { font-family: var(--font-display); font-size: 28px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.calc-band { font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.calc-formula { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.calc-name { font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.calc-mean { font-size: 12.5px; color: var(--ink); }
.calc-src { font-size: 11.5px; color: var(--muted); }
.calc-result { display: flex; flex-direction: column; gap: 6px; animation: rpt-rise .3s ease-out both; }
.calc-formula-full { display: flex; flex-direction: column; gap: 2px; }
.calc-formula-full code { font-family: var(--font-mono); font-size: 12.5px; background: var(--chip); border-radius: 6px; padding: 4px 8px; overflow-x: auto; white-space: pre-wrap; }
.calc-vars { display: flex; flex-direction: column; gap: 4px; margin-top: 2px; }
.calc-var { display: grid; grid-template-columns: 28px 72px 1fr; gap: 8px; align-items: baseline; font-size: 12.5px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.calc-var b { font-family: var(--font-mono); }
.calc-var .vv { font-variant-numeric: tabular-nums; font-weight: 600; }
.calc-var .dd { color: var(--ink-2); }
.rule-alerts { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 6px; }
.rule-alert { border-radius: var(--radius-sm); padding: 8px 10px; background: var(--chip); border-left: 3px solid var(--line-strong); font-size: 12.5px; }
.rule-alert.alta { border-left-color: var(--critical); } .rule-alert.media { border-left-color: var(--warning); } .rule-alert.info { border-left-color: var(--s1); }
.ra-msg { color: var(--ink); }
.ra-src { color: var(--muted); font-size: 11.5px; }
.rpt-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.rpt-card { border: 1px solid var(--line); border-top: 3px solid var(--line-strong); border-radius: var(--radius-sm); padding: 12px; background: var(--bg); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rpt-card.good { border-top-color: var(--good); } .rpt-card.warning { border-top-color: var(--warning); } .rpt-card.critical { border-top-color: var(--critical); }
.rpt-card .t { font-weight: 600; font-size: 13.5px; }
.rpt-card .vv { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.rpt-card .vv b { font-family: var(--font-display); font-size: 22px; font-variant-numeric: tabular-nums; }
.rpt-card .st { font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.rpt-card .ln { color: var(--ink-2); font-size: 12px; }
.rpt-card .ln span { color: var(--muted); }

/* ---------- calendario de obligaciones ---------- */
.ag-wrap { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 16px; align-items: start; }
.ag-months { display: flex; flex-direction: column; gap: 12px; }
.ag-mname { font-weight: 600; text-transform: capitalize; margin-bottom: 4px; font-size: 13px; }
.ag-cells { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.ag-wd { font-family: var(--font-mono); font-size: 10px; color: var(--muted); text-align: center; padding: 2px 0; }
.ag-day { border: none; background: none; font: inherit; font-size: 12.5px; color: var(--ink-2); aspect-ratio: 1; border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 0; font-variant-numeric: tabular-nums; }
.ag-day.has { background: var(--chip); color: var(--ink); cursor: pointer; font-weight: 600; }
.ag-day.has:hover, .ag-day.is-sel { outline: 2px solid var(--line-strong); }
.ag-day.is-today { box-shadow: inset 0 0 0 2px var(--primary); }
.ag-day:disabled { cursor: default; opacity: .7; }
.ag-dots { display: flex; gap: 2px; }
.ag-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--warning); }
.ag-dots i.hi { background: var(--critical); }
.ag-list { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ag-group { font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.ag-group.late { color: var(--critical); } .ag-group.today { color: var(--ink); }
.ag-item { display: grid; grid-template-columns: 44px 1fr; gap: 10px; border: 1px solid var(--line); border-left: 3px solid var(--warning); border-radius: var(--radius-sm); padding: 8px 10px; background: var(--bg); animation: rpt-rise .3s ease-out both; }
.ag-item.alta, .ag-item.vencido { border-left-color: var(--critical); } .ag-item.info { border-left-color: var(--s1); }
.ag-date { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.ag-date b { font-family: var(--font-display); font-size: 20px; font-variant-numeric: tabular-nums; }
.ag-date span { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.ag-body { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ag-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ag-tipo { font-family: var(--font-mono); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; border: 1px solid var(--line-strong); border-radius: 999px; padding: 0 7px; color: var(--ink-2); }
.ag-lista { color: var(--muted); font-size: 11.5px; }
.ag-title { font-size: 13px; color: var(--ink); text-align: left; }
.ag-src { color: var(--muted); font-size: 11.5px; }
@media (max-width: 720px) { .ag-wrap { grid-template-columns: 1fr; } .ag-month + .ag-month { display: none; } }

/* ---------- tablas como tarjetas en el celular ---------- */
@media (max-width: 600px) {
  .rpt-table table, .rpt-table tbody, .rpt-table tr, .rpt-table td { display: block; width: 100%; }
  .rpt-table thead { display: none; }
  .rpt-table tr { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 8px; background: var(--bg); }
  .rpt-table td { border: none; padding: 2px 0; white-space: normal; min-width: 0; display: grid; grid-template-columns: 110px 1fr; gap: 8px; }
  .rpt-table td::before { content: attr(data-label); color: var(--muted); font-size: 11.5px; }
  .rpt-table td.wide { min-width: 0; }
}

/* ---------- animación: ayuda a leer el dato (de dónde crece cada barra), nunca lo retrasa ---------- */
@keyframes rpt-grow-x { from { transform: scaleX(0); } }
@keyframes rpt-grow-y { from { transform: scaleY(0); } }
@keyframes rpt-fade { from { opacity: 0; } }
@keyframes rpt-rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes rpt-slide { from { transform: translateX(100%); } }
.rpt-anim .rpt-kpi { animation: rpt-rise .35s ease-out both; }
.rpt-anim .rpt-kpi:nth-child(2) { animation-delay: .04s; } .rpt-anim .rpt-kpi:nth-child(3) { animation-delay: .08s; }
.rpt-anim .rpt-kpi:nth-child(4) { animation-delay: .12s; } .rpt-anim .rpt-kpi:nth-child(5) { animation-delay: .16s; } .rpt-anim .rpt-kpi:nth-child(6) { animation-delay: .2s; }
.rpt-chart.anim-h .mark-rect path { transform-box: fill-box; transform-origin: left center; animation: rpt-grow-x .55s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--i, 0) * 40ms); }
.rpt-chart.anim-v .mark-rect path { transform-box: fill-box; transform-origin: center bottom; animation: rpt-grow-y .55s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--i, 0) * 40ms); }
.rpt-chart.anim-cells .mark-rect path { animation: rpt-fade .4s ease-out both; animation-delay: calc(var(--i, 0) * 18ms); }
.rpt-chart.anim-cells .mark-text text { animation: rpt-fade .3s ease-out .45s both; }
.rpt-table.fade { animation: rpt-fade .25s ease-out; }
.rpt-drawer { animation: rpt-slide .22s cubic-bezier(.2,.7,.2,1); }
.rpt-drawer-back { animation: rpt-fade .18s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .rpt-anim .rpt-kpi, .rpt-chart .mark-rect path, .rpt-chart .mark-text text, .rpt-table.fade, .rpt-drawer, .rpt-drawer-back { animation: none !important; }
}
.rpt-export { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rpt-export .btn:disabled { opacity: .6; cursor: progress; }
@media print {
  .rpt-sec { break-inside: avoid; box-shadow: none; }
  .rpt-anim .rpt-kpi, .rpt-chart .mark-rect path, .rpt-chart .mark-text text, .rpt-table.fade { animation: none !important; opacity: 1 !important; }
  .rpt-table { overflow: visible; }
  .rpt-table table { width: 100%; table-layout: auto; font-size: 10px; }
  .rpt-table th, .rpt-table td { white-space: normal; padding: 4px 6px; }
  .rpt-table th { letter-spacing: 0; font-size: 8.5px; }
  .rpt-table td.wide { min-width: 0; width: 26%; }
  .rpt-ftools:not(:has(.rpt-chip)), .rpt-ffold, .rpt-chip button, .rpt-chips .btn, .rpt-export, .rpt-actions, .vega-embed details, .rpt-hint, .rpt-filter, .rpt-sp { display: none !important; }
}

/* Tarjeta del chat: expandir ahí mismo e imprimir solo la tarjeta. */
.rpt-more-btn { align-self: flex-start; }
#rpt-print { display: none; }
@media print {
  body.rpt-printing > *:not(#rpt-print) { display: none !important; }
  body.rpt-printing #rpt-print { display: block; border: none; padding: 0; margin: 0; background: #fff; }
}

/* Historial del registro (libro de eventos) */
.rpt-history { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.rpt-history > summary { cursor: pointer; font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.rpt-hist { list-style: none; margin: 10px 0 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.rpt-hist-item { position: relative; font-size: 13px; }
.rpt-hist-item::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--panel); border: 2px solid var(--accent); }
.rpt-hist-item.create::before { background: var(--accent); }
.rpt-hist-when { color: var(--muted); font-size: 12px; }
.rpt-hist-what { overflow-wrap: anywhere; }
.rpt-hist-what .old { color: var(--muted); text-decoration: line-through; }
.rpt-hist-what .new { color: var(--ink); font-weight: 600; }
