/* Views: rules scoped to a single view (9-box, calidad, persona, comparativo,
   configuracion, cargar, reportes). Moved verbatim, in the original order, so
   later view rules keep overriding the earlier component rules exactly as before. */

/* --- 9-box ---
   M4a: the legend lost its permanent right-hand column (it now lives in the
   tooltip, the drawer header and the "Ver leyenda" popover), so the grid gets
   the whole width instead of sharing it with a panel nobody was reading. */
.nb-toolbar { position: relative; }
.nb-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.nb-grid-panel { max-width: 900px; }

/* wrapper adds axis titles around the 3x3 grid */
.ninebox-wrap {
  display: grid;
  grid-template-columns: 28px 1fr;
  grid-template-rows: 1fr 28px;
  gap: 6px;
}
.axis-y {
  grid-column: 1; grid-row: 1;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-align: center;
  align-self: center;
  color: var(--ink-secondary);
  font-size: 0.8rem;
  font-weight: 600;
}
.axis-x {
  grid-column: 2; grid-row: 2;
  text-align: center;
  color: var(--ink-secondary);
  font-size: 0.8rem;
  font-weight: 600;
}
.ninebox {
  grid-column: 2; grid-row: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 8px;
  aspect-ratio: 3 / 2.4;
}
/* role="row" wrappers exist for assistive tech; the cells still lay themselves
   out on the parent grid, so the rows must not become grid items themselves. */
.nb-row { display: contents; }
.cell {
  position: relative;
  border: 1px solid var(--gridline);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: outline-color .12s ease, transform .12s ease;
  outline: 2px solid transparent;
  outline-offset: -2px;
  overflow: hidden;
}
.cell:hover, .cell:focus-visible { transform: translateY(-1px); }
.cell[aria-pressed="true"] { outline-color: var(--color-primary); }
.cell .code {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}
.cell .count {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.cell .bands { font-size: 0.72rem; opacity: 0.9; }
.cell.not-observed::after {
  content: "no observado";
  position: absolute;
  top: 8px; right: 8px;
  font-size: 0.62rem;
  color: var(--muted);
  border: 1px dashed var(--baseline);
  border-radius: 999px;
  padding: 0 6px;
}
/* text color driven by JS per ramp shade via --cell-ink */
.cell { color: var(--cell-ink, var(--ink)); }

/* Legend fragments, reused by the tooltip, the drawer header and the popover. */
.legend-code {
  font-weight: 700;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.legend-bands { color: var(--ink-secondary); font-size: 0.85rem; margin: 2px 0 8px; }
.legend-text {
  font-size: 0.9rem;
  border-left: 3px solid var(--color-primary);
  padding-left: 10px;
  color: var(--ink);
}
.legend-arqu { font-style: italic; color: var(--ink-secondary); font-size: 0.85rem; margin-top: 6px; }

/* A7 / M4 / B1: never observed in real data. This is not an empty cell. */
.nb-placeholder-note {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--ink-secondary);
  border-left: 3px dashed var(--status-serious, #fab219);
  padding-left: var(--space-2);
}
.nb-tag {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border: 1px dashed var(--baseline);
  border-radius: 999px;
  padding: 0 6px;
  white-space: nowrap;
}

/* --- 9-box: contextual legend popover ("Ver leyenda") --- */
.nb-legend-toggle {
  appearance: none;
  border: 1px solid var(--gridline);
  background: transparent;
  color: var(--ink-secondary);
  font: inherit;
  font-size: 0.82rem;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.nb-legend-toggle:hover { border-color: var(--ink-secondary); color: var(--ink); }
.nb-legend-toggle[aria-expanded="true"] {
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.nb-legend-pop {
  margin-top: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--gridline);
  border-radius: 10px;
  background: var(--page);
}
.nb-legend-pop h3 { margin: 0 0 var(--space-3); font-size: 0.95rem; }
.nb-legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--space-3);
}
.nb-legend-item {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--gridline);
  border-radius: 8px;
  background: var(--surface);
}
.nb-legend-item.is-placeholder { border-style: dashed; }

/* --- 9-box: cell tooltip (hover AND :focus — the cells are buttons) --- */
.nb-tooltip {
  position: absolute;
  z-index: 60;
  max-width: 320px;
  padding: var(--space-3);
  border: 1px solid var(--gridline);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
  pointer-events: none;
  font-size: var(--text-sm);
}
.nb-tooltip[hidden] { display: none; }
.nb-tip-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}
.nb-tip-code { font-weight: 700; font-size: 1rem; }
.nb-tip-arqu { color: var(--ink-secondary); font-size: var(--text-xs); font-style: italic; }
.nb-tip-stats {
  display: flex;
  gap: var(--space-3);
  align-items: baseline;
  flex-wrap: wrap;
}
.nb-tip-stats strong { font-size: 1.15rem; }
.nb-tip-delta { margin-top: 2px; font-size: var(--text-xs); color: var(--ink-secondary); }
.nb-tip-bands {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--ink-secondary);
}
.nb-tip-legend {
  margin-top: var(--space-2);
  padding-left: var(--space-2);
  border-left: 3px solid var(--color-primary);
  font-size: var(--text-xs);
}

/* --- 9-box: cell drawer --- */
.nb-drawer-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--gridline);
  margin-bottom: var(--space-3);
}
.nb-drawer-stats {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--ink-secondary);
}
.nb-drawer-stats strong { font-size: 1.2rem; color: var(--ink); }
.nb-drawer-bar {
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.nb-drawer-bar .fp-search { flex: 1 1 160px; }
.nb-people-count { margin: 0 0 var(--space-2); }
.nb-person {
  border: 1px solid var(--gridline);
  border-radius: 8px;
  margin-bottom: var(--space-2);
  background: var(--surface);
}
.nb-person.is-open { border-color: var(--color-primary); }
.nb-person-head {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-align: left;
  background: none;
  border: none;
  font: inherit;
  color: var(--ink);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border-radius: 8px;
}
.nb-person-head:hover { background: var(--page); }
.nb-person-head:focus-visible {
  outline: 2px solid var(--focus-ring-color);
  outline-offset: -2px;
}
.nb-person-name { font-weight: 600; font-size: var(--text-sm); flex: 1 1 auto; }
.nb-person-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  font-size: var(--text-xs);
  color: var(--muted);
}
.nb-person-caret { color: var(--muted); transition: transform .12s ease; }
.nb-person.is-open .nb-person-caret { transform: rotate(180deg); }
.nb-person-detail { padding: 0 var(--space-3) var(--space-3); }
.nb-person-detail[hidden] { display: none; }
.nb-person-actions { margin-top: var(--space-2); }
.nb-preview {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
}
.nb-spark { flex: 0 0 auto; }
.nb-prev-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: var(--space-2);
  flex: 1 1 180px;
}
.nb-prev-cell { display: flex; flex-direction: column; gap: 1px; }
.nb-prev-period { font-size: 0.62rem; color: var(--muted); }
.nb-prev-val { font-weight: 600; font-size: var(--text-sm); }
.nb-prev-cell .sin-eval { font-size: 0.68rem; }

@media (max-width: 860px) {
  .ninebox-wrap { grid-template-columns: auto 1fr; }
}

/* --- Data quality --- */
.dq-group { margin-bottom: 16px; }
.dq-group > summary {
  cursor: pointer;
  font-weight: 620;
  padding: 10px 12px;
  background: var(--page);
  border: 1px solid var(--gridline);
  border-radius: 8px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.dq-group > summary::-webkit-details-marker { display: none; }
.dq-count {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--ink-secondary);
  font-variant-numeric: tabular-nums;
}
.dq-finding {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--gridline);
  align-items: flex-start;
}
.dq-finding .sev {
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.sev-info { color: var(--status-good); border: 1px solid var(--status-good); }
.sev-warn { color: var(--status-serious); border: 1px solid var(--status-serious); }
.sev-error { color: var(--status-critical); border: 1px solid var(--status-critical); }
.dq-finding .detail { font-size: 0.88rem; }
.dq-finding .meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.dq-callout {
  border: 1px solid var(--status-serious);
  border-left: 4px solid var(--status-serious);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  background: var(--surface);
}
.dq-callout h3 { margin-top: 0; }
.dq-callout code {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 0.85em;
  background: var(--page);
  padding: 1px 5px;
  border-radius: 4px;
}
.dq-callout ul { margin: 10px 0; padding-left: 20px; }
.dq-callout li { margin-bottom: 8px; line-height: 1.45; }

/* --- Health center (M4b) --- */
.dq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: var(--space-4, 16px);
  margin-top: var(--space-4, 16px);
}
.dq-health {
  display: flex;
  align-items: center;
  gap: var(--space-6, 24px);
  flex-wrap: wrap;
}
/* The dial is one conic-gradient arc: a whole chart library to draw a ring would
   be 200KB for a single number. --dial-pct is the score, set inline. */
.dq-dial {
  --dial-color: var(--status-serious);
  flex: 0 0 auto;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(
    var(--dial-color) calc(var(--dial-pct) * 1%),
    var(--gridline) 0
  );
}
.dq-dial.is-good { --dial-color: var(--status-good); }
.dq-dial.is-warn { --dial-color: var(--status-serious); }
.dq-dial.is-critical { --dial-color: var(--status-critical); }
.dq-dial-inner {
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
}
.dq-dial-score {
  font-size: 1.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.dq-dial-of { font-size: 0.72rem; color: var(--muted); }
.dq-health-side { flex: 1 1 260px; min-width: 240px; }
.dq-band {
  display: inline-block;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid currentColor;
}
.dq-band.is-good { color: var(--status-good); }
.dq-band.is-warn { color: var(--status-serious); }
.dq-band.is-critical { color: var(--status-critical); }
.dq-health-sub { margin: 8px 0; font-size: 0.85rem; color: var(--ink-secondary); }
.dq-explain > summary {
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-primary);
}
.dq-explain p { font-size: 0.84rem; margin: 8px 0; }
.dq-formula {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.8rem;
  background: var(--page);
  border: 1px solid var(--gridline);
  border-radius: 6px;
  padding: 8px 10px;
  overflow-x: auto;
}
.dq-explain-cap { color: var(--status-critical); }
.dq-counters {
  display: flex;
  gap: var(--space-2, 8px);
  flex-wrap: wrap;
  margin-top: var(--space-4, 16px);
}
.dq-summary-table td.num, .dq-summary-table th.num,
.dq-history-table td.num, .dq-history-table th.num { text-align: right; }
.dq-summary-table tr.is-danger td:first-child {
  border-left: 3px solid var(--status-critical);
}
.dq-summary-table tr.is-warning td:first-child {
  border-left: 3px solid var(--status-serious);
}
.dq-summary-table tr.is-info td:first-child {
  border-left: 3px solid var(--color-info);
}
.dq-history-table tr.is-current { background: var(--color-primary-subtle); }
.dq-history-table tr.is-current td { font-weight: 600; }
.dq-file { max-width: 320px; overflow-wrap: anywhere; }
.dq-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--color-primary);
  color: var(--color-primary-fg);
}
.dq-tech > summary {
  cursor: pointer;
  font-weight: 620;
  font-size: 0.88rem;
  color: var(--color-primary);
  margin-bottom: 12px;
}

/* --- Person timeline --- */
.person-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.person-head h2 { margin: 0; }
.conflict-flag {
  color: var(--status-serious);
  border: 1px solid var(--status-serious);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
}
.sin-eval { color: var(--muted); font-style: italic; }
.matriz-chip {
  display: inline-block;
  font-weight: 700;
  border-radius: 6px;
  padding: 1px 7px;
  font-size: 0.82rem;
  border: 1px solid var(--gridline);
}

/* --- Comparative table --- */
.comparative-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: start;
  margin-top: 18px;
}
@media (max-width: 900px) {
  .comparative-layout { grid-template-columns: 1fr; }
}

.comp-table-wrap {
  overflow-x: auto;
}
.comp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.comp-table th, .comp-table td {
  text-align: center;
  padding: 7px 10px;
  border-bottom: 1px solid var(--gridline);
}
.comp-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.comp-table th.code-col { text-align: left; width: 60px; }
.comp-table th.period-col { min-width: 80px; }
.comp-table th.delta-col { min-width: 65px; }

.comp-table td.code-cell {
  text-align: left;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: color .12s;
}
.comp-table td.code-cell:hover { color: var(--color-primary); }
.comp-table td.code-cell.selected { color: var(--color-primary); }

.comp-table td.heat-cell {
  font-variant-numeric: tabular-nums;
  padding: 6px 8px;
  transition: background .15s;
}
.comp-table td.heat-cell .cell-count {
  font-weight: 700;
  font-size: 1rem;
}
.comp-table td.heat-cell .cell-pct {
  font-size: 0.72rem;
  opacity: 0.75;
  display: block;
}

.comp-table td.delta-cell {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}
.comp-table td.delta-pos { color: #0ca30c; }
.comp-table td.delta-neg { color: #d03b3b; }
.comp-table td.delta-zero { color: var(--muted); }

.comp-table tr.total-row td {
  border-top: 2px solid var(--baseline);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ink);
}

/* --- Dynamic legend (comparative) --- */
.comp-legend {
  grid-column: 2;
}
@media (max-width: 900px) { .comp-legend { grid-column: 1; } }

.comp-legend .legend-header {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 4px;
}
.comp-legend .legend-bands {
  color: var(--ink-secondary);
  font-size: 0.85rem;
  margin-bottom: 4px;
}
.comp-legend .legend-arqu {
  font-style: italic;
  color: var(--ink-secondary);
  font-size: 0.82rem;
  margin-bottom: 12px;
}
.comp-legend .legend-history {
  font-size: 0.85rem;
  color: var(--ink-secondary);
}
.comp-legend .legend-history li {
  padding: 3px 0;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.comp-legend .legend-change {
  margin-top: 8px;
  font-weight: 700;
  font-size: 0.9rem;
}

/* Trend chart wrapper */
.comp-chart-wrap {
  margin: 18px 0;
}
.comp-chart-wrap .chart-box {
  height: 240px;
}

/* --- Config: legend editing --- */
.config-group > summary {
  cursor: pointer;
  list-style: none;
}
.config-group > summary::-webkit-details-marker { display: none; }
.config-group > summary h2 {
  display: inline;
  font-size: 1rem;
}

.config-legend-table table { width: 100%; }
.config-legend-table td, .config-legend-table th {
  text-align: left;
  padding: 6px 8px;
  vertical-align: top;
}
.config-legend-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  font-weight: 600;
}
.config-legend-table td.code-col {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}
.config-legend-table td.band-col {
  font-size: 0.82rem;
  color: var(--ink-secondary);
  white-space: nowrap;
}
.config-legend-table textarea, .config-legend-table input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 0.85rem;
  padding: 6px 8px;
  border: 1px solid var(--gridline);
  border-radius: 6px;
  background: var(--page);
  color: var(--ink);
  resize: vertical;
}
.config-legend-table textarea { min-height: 48px; }
.config-legend-table textarea:focus, .config-legend-table input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}
.config-legend-table .save-btn {
  appearance: none;
  border: 1px solid var(--color-primary-solid);
  background: var(--color-primary-solid);
  color: var(--color-primary-fg);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .12s;
}
.config-legend-table .save-btn:hover { opacity: 0.85; }
.config-legend-table .save-btn:disabled { opacity: 0.5; cursor: default; }
.config-legend-table .saved-msg {
  font-size: 0.75rem;
  color: #0ca30c;
  margin-left: 8px;
  white-space: nowrap;
}

/* --- Cargar datos --- */
.upload-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.upload-controls input[type="file"] {
  font: inherit;
  font-size: 0.88rem;
  padding: 7px 10px;
  border: 1px solid var(--gridline);
  border-radius: 8px;
  background: var(--page);
  color: var(--ink);
  max-width: 100%;
}
.upload-controls input[type="file"]:disabled { opacity: 0.5; }

/* ===== Reportes: the catalog (M4d) ===================================== */
/* The old Reportes page was one long scroll of every chart at once, with its own
   KPI cards, heatmap, radar and per-competency grid. It is now a catalog of four
   cards -> one report per screen, so this file lost ~150 lines of markup-specific
   CSS along with the markup. Layout only; every color is a semantic token. */

.rp-catalog-head h2 { margin: 0 0 4px; }

.rp-catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.rp-card .ui-card-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  height: 100%;
}
.rp-card-desc {
  margin: 0;
  color: var(--ink-secondary);
  font-size: 0.86rem;
  line-height: 1.45;
}
.rp-card-preview {
  display: flex;
  align-items: center;
  min-height: 40px;
  color: var(--color-primary);
}
.rp-preview-text { color: var(--muted); font-size: 0.82rem; }
.rp-spark { display: block; overflow: visible; }

.rp-card-actions { margin-top: auto; }

/* Favorite star: it lives in the Card's action slot. */
.rp-fav {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 6px;
  color: var(--muted);
}
.rp-fav:hover { color: var(--ink); background: var(--page); }
.rp-fav.is-fav { color: #e0a800; }
.rp-fav:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* --- Report detail --- */
.rp-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.rp-detail-title h2 { margin: 2px 0 0; }
.rp-back {
  color: var(--color-primary);
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
}
.rp-back:hover { text-decoration: underline; }
.rp-detail-actions { display: flex; gap: var(--space-2); }

.rp-trend-spark {
  color: var(--color-primary);
  margin: var(--space-3) 0;
}
/* A small sample is not a ranking: one person must not become "the top area". */
.rp-warn { color: var(--color-warning, #b45309); font-size: 0.78rem; }
/* A placeholder code (A7 / M4 / B1) is not an empty cell. */
.matriz-chip.is-placeholder {
  border-style: dashed;
  opacity: 0.75;
}

/* --- Report bodies (M4e) -------------------------------------------------
   The catalog is the door, not the house: a report is the full analysis. The
   layout below is the one the pre-catalog view had, restyled on the M1 tokens.
   No color literal appears here -- the heatmap shades and the competency bar
   hues are set from core/tokens.js (blueRamp / categoricalHues), so the CSS
   ramp stays the single definition. */

.rp-report { display: flex; flex-direction: column; gap: var(--space-4); }

.rp-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
}
/* "Variacion vs anterior" carries its direction in the value itself. */
.rp-kpis .ui-stat-value.trend-up { color: var(--color-success); }
.rp-kpis .ui-stat-value.trend-down { color: var(--color-danger); }
.rp-kpis .ui-stat-value.trend-flat { color: var(--muted); }

/* Fortalezas / Oportunidades */
.str-opp-panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-4);
}
.str-panel, .opp-panel {
  padding: var(--space-4);
  border: 1px solid var(--gridline);
  border-left-width: 4px;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.str-panel { border-left-color: var(--color-success); }
.opp-panel { border-left-color: var(--color-warning); }
.str-panel h4, .opp-panel h4 {
  margin: 0 0 var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
}
.str-panel h4 { color: var(--color-success); }
.opp-panel h4 { color: var(--color-warning); }
.str-item, .opp-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  font-size: var(--text-sm);
  border-top: 1px solid var(--gridline);
}
.str-item:first-of-type, .opp-item:first-of-type { border-top: 0; }
.item-icon { margin-right: var(--space-2); }
.str-item .item-icon { color: var(--color-success); }
.opp-item .item-icon { color: var(--color-warning); }

/* Competencias por Categoria */
.rpt-category-section { margin-top: var(--space-4); }
.rpt-category-section:first-of-type { margin-top: 0; }
.cat-header {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-secondary);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--gridline);
}
.rpt-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: var(--space-3);
}
.comp-kpi {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-3);
  border: 1px solid var(--gridline);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.comp-name {
  font-size: var(--text-xs);
  color: var(--ink-secondary);
  line-height: var(--leading-tight);
}
.comp-value {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: var(--font-weight-semibold);
}
.comp-trend { font-size: var(--text-xs); font-family: var(--font-mono); }
.comp-trend.trend-up { color: var(--color-success); }
.comp-trend.trend-down { color: var(--color-danger); }
.comp-trend.trend-flat { color: var(--muted); }
.comp-bar-wrap {
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--page);
  overflow: hidden;
  margin-top: var(--space-1);
}
.comp-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width var(--motion-base);
}
.comp-kpi details { margin-top: var(--space-2); }
.comp-kpi summary {
  cursor: pointer;
  font-size: var(--text-xs);
  color: var(--color-primary);
}
.comp-kpi summary:focus-visible { outline: 2px solid var(--focus-ring-color); outline-offset: 2px; }
.comp-kpi .chart-box { height: 220px; margin-top: var(--space-2); }
@media (prefers-reduced-motion: reduce) {
  .comp-bar-fill { transition: none; }
}

/* Heatmap de Evolucion. Cell backgrounds come from blueRamp() at render time. */
.rpt-heatmap {
  border-collapse: separate;
  border-spacing: 2px;
  width: 100%;
  font-size: var(--text-xs);
}
.rpt-heatmap th {
  font-weight: var(--font-weight-semibold);
  color: var(--ink-secondary);
  text-align: center;
  padding: var(--space-1) var(--space-2);
  white-space: nowrap;
}
.rpt-heatmap td {
  padding: var(--space-2);
  text-align: center;
  font-family: var(--font-mono);
  border-radius: var(--radius-sm);
  min-width: 56px;
}
/* The row label is not a value: it never takes a ramp shade. */
.rpt-heatmap td:first-child {
  text-align: left;
  font-family: var(--font);
  color: var(--ink);
  background: transparent;
  white-space: nowrap;
}
/* "sin evaluacion" is a hole in the data, not a low score: no shade at all. */
.rpt-heatmap td.is-empty {
  background: transparent;
  border: 1px dashed var(--gridline);
  color: var(--muted);
}

/* ===== Dashboard (M3) ================================================== */
/* Layout only. Every color comes from the semantic tokens in tokens.css, so
   light/dark and any future rebrand flow through without touching this file. */

.dash-body { display: flex; flex-direction: column; gap: var(--space-4); }

.dash-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-4);
  align-items: start;
}

/* --- Performance distribution --- */
.dash-dist { display: flex; flex-direction: column; gap: var(--space-2); }
.dash-dist-row {
  display: grid;
  grid-template-columns: 7.5rem 1fr 2.5rem 3.5rem;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
}
.dash-dist-label { color: var(--ink-secondary); }
.dash-dist-bar {
  background: var(--color-neutral-subtle);
  border-radius: var(--radius-pill);
  height: 10px;
  overflow: hidden;
}
.dash-dist-fill { display: block; height: 100%; border-radius: var(--radius-pill); }
.dash-dist-fill.is-good { background: var(--color-success); }
.dash-dist-fill.is-normal { background: var(--color-primary-fill); }
.dash-dist-fill.is-bad { background: var(--color-danger); }
/* "Sin matriz" is an absence, not a performance band: it is deliberately grey,
   so it can never be mistaken for a low score in a screenshot. */
.dash-dist-fill.is-none { background: var(--color-neutral); }
.dash-dist-num, .dash-dist-pct { text-align: right; color: var(--ink-secondary); }

/* --- Mini 9-box --- */
.dash-mini9 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.dash-mini9-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-height: 74px;
  padding: var(--space-2);
  border: 1px solid var(--gridline);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.dash-mini9-cell:hover { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.dash-mini9-cell:focus-visible { outline: 2px solid var(--focus-ring-color); outline-offset: 1px; }
.dash-mini9-code { font-weight: 650; font-size: var(--text-sm); }
.dash-mini9-count { font-size: var(--text-lg); font-weight: 600; line-height: 1.1; }
.dash-mini9-pct { font-size: var(--text-xs); opacity: 0.85; }
.dash-mini9-delta { font-size: var(--text-xs); opacity: 0.85; }
/* A7 / M4 / B1: never observed in real data, legend still "(PENDIENTE CONFIRMAR
   RRHH)". Hatched so they read as "not a real zero" at a glance. */
.dash-mini9-cell.is-placeholder {
  background-image: repeating-linear-gradient(45deg,
    rgba(128, 128, 128, 0.22) 0 5px, transparent 5px 10px);
}
.dash-mini9-flag {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  opacity: 0.9;
}

/* --- Insights ("Hallazgos") ---
   Shared by the dashboard and every report (views/insights_list.js): one
   finding, one look, wherever it is read. */
.insight-list { display: flex; flex-direction: column; gap: var(--space-2); }
.insight-item {
  display: grid;
  grid-template-columns: 1.5rem 1fr auto;
  align-items: start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--gridline);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.insight-item.is-critical { border-left-color: var(--color-danger); background: var(--color-danger-subtle); }
.insight-item.is-warning { border-left-color: var(--color-warning); background: var(--color-warning-subtle); }
.insight-item.is-positive { border-left-color: var(--color-success); background: var(--color-success-subtle); }
.insight-item.is-neutral { border-left-color: var(--color-neutral); background: var(--color-neutral-subtle); }
.insight-item.is-clickable { cursor: pointer; }
.insight-item.is-clickable:hover { border-color: var(--baseline); }
.insight-item.is-clickable:focus-visible { outline: 2px solid var(--focus-ring-color); outline-offset: 1px; }
.insight-icon { font-size: var(--text-base); line-height: 1.4; }
.insight-title { font-weight: 600; font-size: var(--text-sm); }
.insight-detail { font-size: var(--text-xs); color: var(--ink-secondary); margin-top: 2px; }

/* --- Latest import --- */
.dash-import { display: flex; flex-direction: column; gap: var(--space-1); margin: 0 0 var(--space-3); }
.dash-import > div { display: grid; grid-template-columns: 6rem 1fr; gap: var(--space-2); font-size: var(--text-sm); }
.dash-import dt { color: var(--muted); }
.dash-import dd { margin: 0; word-break: break-word; }
.dash-findings { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-2); }

.linklike {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: var(--text-sm);
  color: var(--color-primary);
  text-decoration: underline;
  cursor: pointer;
}
.linklike:focus-visible { outline: 2px solid var(--focus-ring-color); outline-offset: 2px; }

.dash-trend-box { height: 320px; }

/* ===================== Cognia narrative preview ===================== */

.cg-narrative { display: flex; flex-direction: column; gap: var(--space-2); }
.cg-narrative h3 {
  font-size: var(--text-base);
  margin: var(--space-3) 0 var(--space-1);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--gridline);
}
.cg-narrative h4 { font-size: var(--text-sm); margin: var(--space-2) 0 2px; }
.cg-narrative p { font-size: var(--text-sm); line-height: 1.55; margin: 0 0 var(--space-1); }
.cg-finding { margin-bottom: var(--space-2); }

.cg-head { display: flex; align-items: center; gap: var(--space-2); }
.cg-badge {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.cg-badge-ai { color: var(--color-primary); background: var(--color-primary-subtle, var(--surface)); border: 1px solid var(--color-primary); }
.cg-badge-tpl { color: var(--muted); background: var(--surface); border: 1px solid var(--gridline); }

.cg-caveat { color: var(--color-warning); font-style: italic; }
.cg-draft { color: var(--muted); font-style: italic; }

.ai-notice {
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  line-height: 1.5;
  border: 1px solid var(--color-primary);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  background: var(--color-primary-subtle, var(--surface));
  color: var(--ink-secondary);
}

/* ===================== Cargar datos -- import wizard (M4c) ===================== */

.wz-head { padding-bottom: var(--space-4); }

.wz-steps {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
}
.wz-step {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 12px;
  border: 1px solid var(--gridline);
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--muted);
  background: var(--page);
}
.wz-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-size: 0.7rem;
  font-weight: 700;
}
.wz-step.is-current {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-subtle);
  font-weight: 600;
}
.wz-step.is-done { color: var(--color-success); border-color: var(--color-success); }

.wz-stage { margin-top: var(--space-4); }

/* --- Step 1: dropzone --- */
.wz-drop {
  border: 2px dashed var(--baseline);
  border-radius: 12px;
  padding: var(--space-6, 28px) var(--space-4);
  text-align: center;
  cursor: pointer;
  transition: border-color .12s, background .12s;
  background: var(--page);
}
.wz-drop:hover,
.wz-drop.is-over,
.wz-drop:focus-visible {
  border-color: var(--color-primary);
  background: var(--color-primary-subtle);
  outline: none;
}
.wz-drop-icon { font-size: 2rem; color: var(--color-primary); }
.wz-drop-title { margin: var(--space-2) 0 0; font-weight: 600; }
.wz-drop-sub { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; }

.wz-picked:empty { display: none; }
.wz-file-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-3);
  padding: 10px 14px;
  border: 1px solid var(--color-primary);
  border-radius: 8px;
  background: var(--color-primary-subtle);
}
.wz-file-name { font-weight: 600; word-break: break-all; }
.wz-file-size { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }

/* --- Shared --- */
.wz-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-5);
  flex-wrap: wrap;
}
.upload-btn.is-ghost {
  background: transparent;
  color: var(--ink-secondary);
  border-color: var(--gridline);
}
.upload-btn.is-danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: var(--color-danger-fg);
}

.wz-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
}

.wz-period-table .wz-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
}
.wz-tag.is-new { background: var(--color-success-subtle); color: var(--color-success); }
.wz-tag.is-replace { background: var(--color-warning-subtle); color: var(--ink-secondary); }

.wz-callout {
  border-radius: 10px;
  padding: var(--space-4);
  margin-top: var(--space-4);
  border: 1px solid var(--gridline);
}
.wz-callout h3 { margin-top: 0; }
.wz-callout p:last-child { margin-bottom: 0; }
.wz-callout.is-warn {
  background: var(--color-warning-subtle);
  border-color: var(--color-warning);
}
.wz-callout.is-info {
  background: var(--color-info-subtle);
  border-color: var(--color-info);
}

/* --- The blocking confirmation. Loud on purpose: this box is the only thing
       standing between a stray click and the permanent deletion of a period. --- */
.wz-danger {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border: 2px solid var(--color-danger);
  border-left-width: 6px;
  border-radius: 10px;
  background: var(--color-danger-subtle);
}
.wz-danger-title {
  margin: 0 0 var(--space-2);
  color: var(--color-danger);
  font-size: 1.05rem;
}
.wz-danger code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 4px;
}
.wz-danger-list { margin: var(--space-2) 0; padding-left: 20px; }
.wz-danger-list li { margin-bottom: 4px; }

.wz-ack {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding: var(--space-3);
  border: 1px solid var(--color-danger);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  line-height: 1.45;
}
.wz-ack input { margin-top: 3px; flex: none; }

.wz-ack-type {
  display: block;
  margin-top: var(--space-3);
  font-size: 0.85rem;
  font-weight: 600;
}
.wz-ack-input {
  width: 100%;
  max-width: 260px;
  margin-top: 6px;
  padding: 8px 10px;
  font: inherit;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--color-danger);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
.wz-ack-hint { margin: 6px 0 0; font-size: 0.8rem; color: var(--ink-secondary); }

/* --- Step 4: indeterminate progress (openpyxl reports none, so we invent none) --- */
.wz-progress { text-align: center; padding: var(--space-5) 0; }
.wz-progress-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--gridline);
  overflow: hidden;
}
.wz-progress-fill {
  height: 100%;
  width: 35%;
  border-radius: 999px;
  background: var(--color-primary-solid);
  animation: wz-slide 1.3s ease-in-out infinite;
}
@keyframes wz-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}
@media (prefers-reduced-motion: reduce) {
  .wz-progress-fill { animation: none; width: 100%; opacity: 0.5; }
}
.wz-progress-text { margin-top: var(--space-3); font-weight: 600; }

.wz-link { color: var(--color-primary); font-weight: 600; }
