/* Design tokens. Light is the default; dark overrides live in the media block
   and are also reachable via [data-theme] if a manual toggle is ever added. */
:root {
  --surface: #fcfcfb;
  --page: #f9f9f7;
  --ink: #0b0b0b;
  --ink-secondary: #52514e;
  --muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;

  /* Data-quality status colors — used ONLY in the Calidad de datos view,
     always paired with an icon + text label, never color alone. */
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;

  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface: #1a1a19;
    --page: #0d0d0d;
    --ink: #ffffff;
    --ink-secondary: #c3c2b7;
    --muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
  }
}

/* Explicit theme overrides win in both directions. */
:root[data-theme="light"] {
  --surface: #fcfcfb; --page: #f9f9f7; --ink: #0b0b0b;
  --ink-secondary: #52514e; --muted: #898781; --gridline: #e1e0d9; --baseline: #c3c2b7;
}
:root[data-theme="dark"] {
  --surface: #1a1a19; --page: #0d0d0d; --ink: #ffffff;
  --ink-secondary: #c3c2b7; --muted: #898781; --gridline: #2c2c2a; --baseline: #383835;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--page);
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.tabular { font-variant-numeric: tabular-nums; }

.theme-toggle {
  position: absolute;
  top: 20px;
  right: 24px;
  appearance: none;
  border: 1px solid var(--gridline);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 1.15rem;
  cursor: pointer;
  transition: background .12s;
  line-height: 1;
}
.theme-toggle:hover { background: var(--page); }

/* Sits to the left of the theme toggle, in the same absolute header row. */
.logout-btn {
  position: absolute;
  top: 20px;
  right: 76px;
  appearance: none;
  border: 1px solid var(--gridline);
  background: var(--surface);
  color: var(--ink-secondary);
  border-radius: 8px;
  padding: 6px 12px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background .12s;
  line-height: 1.35;
}
.logout-btn:hover { background: var(--page); color: var(--ink); }
.logout-btn[hidden] { display: none; }

header.app-header {
  position: relative;
  padding: 20px 24px 0;
  max-width: 1200px;
  margin: 0 auto;
}
header.app-header h1 {
  font-size: 1.35rem;
  margin: 0 0 2px;
  font-weight: 650;
}
header.app-header p.sub {
  margin: 0;
  color: var(--ink-secondary);
  font-size: 0.9rem;
}

nav.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--gridline);
  margin: 16px 0 0;
  padding: 0 0 0;
}
nav.tabs button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font: inherit;
  font-size: 0.95rem;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
nav.tabs button:hover { color: var(--ink); }
nav.tabs button[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: #2a78d6;
  font-weight: 600;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px 60px;
}

.view[hidden] { display: none; }

.panel {
  background: var(--surface);
  border: 1px solid var(--gridline);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.panel h2 { font-size: 1.05rem; margin: 0 0 4px; font-weight: 620; }
.panel h3 { font-size: 0.95rem; margin: 0 0 8px; font-weight: 600; }
.note {
  color: var(--ink-secondary);
  font-size: 0.85rem;
  margin: 6px 0 0;
}
.derived-tag {
  display: inline-block;
  font-size: 0.72rem;
  color: var(--ink-secondary);
  border: 1px solid var(--gridline);
  border-radius: 999px;
  padding: 1px 8px;
  vertical-align: middle;
}

/* --- Filters bar --- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.field select, .field input {
  font: inherit;
  font-size: 0.92rem;
  padding: 7px 10px;
  border: 1px solid var(--gridline);
  border-radius: 8px;
  background: var(--page);
  color: var(--ink);
  min-width: 170px;
}

/* --- 9-box --- */
.ninebox-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 1fr);
  gap: 20px;
  align-items: start;
}
@media (max-width: 860px) {
  .ninebox-layout { grid-template-columns: 1fr; }
  .ninebox-wrap { grid-template-columns: auto 1fr !important; }
}

/* 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;
}
.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: #2a78d6; }
.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-box h3 { margin-top: 0; }
.legend-code {
  font-weight: 700;
  font-size: 1.1rem;
}
.legend-bands { color: var(--ink-secondary); font-size: 0.85rem; margin: 2px 0 8px; }
.legend-text {
  font-size: 0.9rem;
  border-left: 3px solid #2a78d6;
  padding-left: 10px;
  color: var(--ink);
}
.legend-arqu { font-style: italic; color: var(--ink-secondary); font-size: 0.85rem; margin-top: 6px; }

.people-list { margin-top: 14px; }
.empty-hint { color: var(--muted); font-size: 0.88rem; }

/* --- Tables --- */
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
table.data th, table.data td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--gridline);
}
table.data th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }

/* --- Charts --- */
.chart-box { position: relative; height: 340px; }
.chart-box.tall { height: 380px; }
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 18px;
}

/* --- Banner (matriz missing) --- */
.banner {
  border: 1px solid var(--baseline);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  background: var(--page);
}
.banner strong { display: block; font-size: 1.05rem; margin-bottom: 4px; }
.banner span { color: var(--ink-secondary); font-size: 0.9rem; }

/* --- 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: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  background: var(--page);
  padding: 1px 5px;
  border-radius: 4px;
}

/* --- 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);
}
.search-results {
  border: 1px solid var(--gridline);
  border-radius: 8px;
  margin-top: 6px;
  max-height: 240px;
  overflow-y: auto;
}
.search-results button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--gridline);
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  padding: 8px 12px;
  cursor: pointer;
}
.search-results button:hover { background: var(--page); }
.search-results .ced { color: var(--muted); font-variant-numeric: tabular-nums; }

.loading { color: var(--muted); font-size: 0.9rem; padding: 8px 0; }
.legend-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--ink-secondary);
  margin-top: 10px;
}
.legend-inline .swatch {
  display: inline-block;
  width: 22px; height: 3px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 5px;
}

/* --- View toggle (Matriz / Comparativo) --- */
.ninebox-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.view-toggle {
  display: inline-flex;
  border: 1px solid var(--gridline);
  border-radius: 8px;
  overflow: hidden;
}
.view-toggle .toggle-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-secondary);
  font: inherit;
  font-size: 0.85rem;
  padding: 7px 18px;
  cursor: pointer;
  border-right: 1px solid var(--gridline);
  transition: background .12s, color .12s;
}
.view-toggle .toggle-btn:last-child { border-right: none; }
.view-toggle .toggle-btn:hover { color: var(--ink); background: var(--page); }
.view-toggle .toggle-btn.active {
  background: #2a78d6;
  color: #fff;
  font-weight: 600;
}

/* --- Chip selector (multi-period) --- */
.chip-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 170px;
}
.chip-selector .chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  padding: 4px 10px;
  border: 1px solid var(--gridline);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  color: var(--ink-secondary);
  transition: background .12s, border-color .12s, color .12s;
}
.chip-selector .chip:hover { border-color: var(--baseline); color: var(--ink); }
.chip-selector .chip.active {
  background: #2a78d6;
  border-color: #2a78d6;
  color: #fff;
  font-weight: 600;
}
.chip-selector .chip .chip-x {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-left: 2px;
}
.chip-field label { margin-bottom: 6px; display: block; }
.sort-field { margin-left: auto; }

/* --- 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: #2a78d6; }
.comp-table td.code-cell.selected { color: #2a78d6; }

.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;
}

/* --- Summary cards (comparative) --- */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.summary-card {
  background: var(--surface);
  border: 1px solid var(--gridline);
  border-radius: 8px;
  padding: 14px;
}
.summary-card h4 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.summary-card .card-value {
  font-weight: 700;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}
.summary-card .card-sub {
  font-size: 0.82rem;
  color: var(--ink-secondary);
  margin-top: 2px;
}
.summary-card .card-trend {
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 4px;
}
.trend-up { color: #0ca30c; }
.trend-down { color: #d03b3b; }
.trend-flat { color: var(--muted); }

/* 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 #2a78d6;
  outline-offset: -2px;
}
.config-legend-table .save-btn {
  appearance: none;
  border: 1px solid #2a78d6;
  background: #2a78d6;
  color: #fff;
  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; }
.upload-btn {
  appearance: none;
  border: 1px solid #2a78d6;
  background: #2a78d6;
  color: #fff;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .12s;
}
.upload-btn:hover { opacity: 0.85; }
.upload-btn:disabled { opacity: 0.5; cursor: default; }

/* --- Reports (redesigned) --- */
.rpt-filter-bar {
  margin-bottom: 12px;
}
.rpt-filters {
  gap: 14px;
  align-items: flex-end;
}
.btn-reset {
  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;
  transition: border-color .12s, color .12s;
}
.btn-reset:hover { border-color: var(--ink-secondary); color: var(--ink); }

/* KPI cards */
.kpi-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--gridline);
  border-radius: 8px;
  padding: 14px 16px;
}
.kpi-card .kpi-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 4px;
}
.kpi-card .kpi-value {
  font-weight: 700;
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}
.kpi-card .kpi-sub {
  font-size: 0.8rem;
  color: var(--ink-secondary);
  margin-top: 2px;
}

/* Strengths / Opportunities panels */
.str-opp-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 16px 0;
}
@media (max-width: 700px) { .str-opp-panels { grid-template-columns: 1fr; } }
.str-panel, .opp-panel {
  background: var(--surface);
  border: 1px solid var(--gridline);
  border-radius: 8px;
  padding: 14px 16px;
}
.str-panel h4 { color: #0ca30c; margin: 0 0 8px; font-size: 0.9rem; }
.opp-panel h4 { color: #d03b3b; margin: 0 0 8px; font-size: 0.9rem; }
.str-item, .opp-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--gridline);
  font-size: 0.88rem;
}
.str-item:last-child, .opp-item:last-child { border-bottom: none; }
.str-item .item-icon { color: #0ca30c; margin-right: 6px; }
.opp-item .item-icon { color: #d03b3b; margin-right: 6px; }

/* Category sections */
.rpt-category-section {
  margin-bottom: 16px;
}
.rpt-category-section .cat-header {
  font-size: 0.85rem;
  font-weight: 620;
  color: var(--ink-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--gridline);
}
.rpt-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}

/* Competency KPI card */
.comp-kpi {
  background: var(--surface);
  border: 1px solid var(--gridline);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .12s;
}
.comp-kpi:hover { border-color: var(--baseline); }
.comp-kpi .comp-name {
  font-weight: 620;
  font-size: 0.85rem;
  margin-bottom: 4px;
}
.comp-kpi .comp-value {
  font-weight: 700;
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}
.comp-kpi .comp-trend {
  font-size: 0.78rem;
  font-weight: 600;
  margin-top: 2px;
}
.comp-kpi .comp-bar-wrap {
  margin-top: 6px;
  height: 5px;
  background: var(--page);
  border-radius: 3px;
  overflow: hidden;
}
.comp-kpi .comp-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .3s;
}
.comp-kpi details {
  margin-top: 8px;
  font-size: 0.82rem;
}
.comp-kpi details summary {
  cursor: pointer;
  color: #2a78d6;
  font-size: 0.8rem;
  font-weight: 600;
}
.comp-kpi details .chart-box {
  height: 340px;
  margin-top: 8px;
}
.comp-kpi:has(details[open]) {
  grid-column: span 2;
}

/* Insights panel */
.rpt-insights {
  margin: 16px 0;
}
.rpt-insights .insight-item {
  padding: 6px 0;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--gridline);
}
.rpt-insights .insight-item:last-child { border-bottom: none; }
.rpt-insights .insight-icon { margin-right: 6px; }
.insight-up { color: #0ca30c; }
.insight-down { color: #d03b3b; }
.insight-neutral { color: var(--ink-secondary); }

/* Heatmap table */
.rpt-heatmap-wrap { margin: 16px 0; }
.rpt-heatmap {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.rpt-heatmap th, .rpt-heatmap td {
  text-align: center;
  padding: 5px 10px;
  border: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums;
}
.rpt-heatmap th {
  background: var(--page);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}
.rpt-heatmap td:first-child {
  text-align: left;
  font-weight: 600;
  font-size: 0.82rem;
}
.rpt-heatmap th:first-child { text-align: left; }

.compare-chart-wrap {
  margin-bottom: 16px;
}
.compare-chart-wrap .chart-box {
  height: 360px;
}
.radar-chart-wrap .chart-box {
  height: 420px;
}
