:root {
  color-scheme: light;
  --azul: #002c7a;
  --oro: #f5ad00;
  --texto: #14213d;
  --muted: #667085;
  --linea: #d0d5dd;
  --fondo: #f5f7fb;
  --panel: #ffffff;
  --shadow-sm: 0 8px 18px rgba(20, 33, 61, 0.08);
  --shadow-md: 0 16px 34px rgba(20, 33, 61, 0.12);
  --radius: 8px;
  font-family: "Century Gothic", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: #f3f6fb;
  color: var(--texto);
}
button, input, select {
  font: inherit;
}
.shell {
  min-height: 100vh;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  background: var(--azul);
  color: white;
  box-shadow: 0 8px 22px rgba(0, 44, 122, 0.22);
  position: relative;
  z-index: 2;
}
.topbar h1 {
  margin: 0;
  font-size: 22px;
}
.topbar p {
  margin: 4px 0 0;
  color: #dce6ff;
}
button {
  border: 0;
  background: var(--azul);
  color: white;
  padding: 10px 14px;
  cursor: pointer;
  border-radius: 6px;
  transition: background-color 220ms ease, box-shadow 220ms ease, transform 160ms ease;
}
button:hover,
button:focus-visible {
  background: #00388f;
  box-shadow: 0 8px 16px rgba(0, 44, 122, 0.18);
  outline: 2px solid var(--oro);
  outline-offset: 1px;
}
button:active {
  transform: translateY(1px);
  box-shadow: 0 3px 8px rgba(0, 44, 122, 0.16);
}
.topbar button {
  background: var(--oro);
  color: #1f2937;
  font-weight: 700;
}
.topbar button:hover,
.topbar button:focus-visible {
  background: #ffc43d;
  box-shadow: 0 8px 18px rgba(245, 173, 0, 0.24);
  outline-color: white;
}
.layout-shell {
  display: grid;
  gap: 16px;
  padding: 20px;
  animation: fadeIn 260ms ease-out;
}
.layout {
  display: grid;
  grid-template-columns: minmax(260px, .75fr) minmax(360px, 1.1fr) minmax(340px, 1fr);
  gap: 20px;
}
.view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 8px;
}
.view-tab {
  background: #eef2f7;
  color: var(--texto);
  min-height: 38px;
  padding: 9px 14px;
  font-weight: 700;
}
.view-tab:hover,
.view-tab:focus-visible {
  background: #e4ebf7;
}
.view-tab-active,
.view-tab-active:hover,
.view-tab-active:focus-visible {
  background: var(--azul);
  color: white;
}
.panel {
  min-height: 280px;
  background: var(--panel);
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  overflow: auto;
  animation: panelEnter 260ms ease-out;
}
.panel-full {
  overflow-x: auto;
}
.panel-dashboard {
  display: grid;
  gap: 16px;
  overflow: visible;
}
.dashboard-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}
.dashboard-header h2 {
  margin: 0;
  color: var(--azul);
  font-size: 24px;
}
.dashboard-eyebrow {
  margin: 0 0 4px;
  color: var(--oro);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.dashboard-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
}
.dashboard-export {
  flex: 0 0 auto;
  background: var(--oro);
  color: #1f2937;
  font-weight: 700;
}
.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 12px;
}
.dashboard-kpi {
  display: grid;
  gap: 8px;
  min-height: 96px;
  padding: 14px;
  background: white;
  border-radius: var(--radius);
  border-top: 4px solid var(--azul);
  box-shadow: 0 6px 18px rgba(20, 33, 61, 0.08);
  transition: transform 160ms ease, box-shadow 180ms ease;
}
.dashboard-kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.dashboard-kpi span,
.dashboard-capa-metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.dashboard-kpi strong {
  color: var(--azul);
  font-size: 27px;
}
.dashboard-kpi-verde { border-top-color: #16845b; }
.dashboard-kpi-ambar { border-top-color: #d79000; }
.dashboard-kpi-rojo { border-top-color: #b42318; }
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1.05fr) repeat(2, minmax(260px, 1fr));
  gap: 14px;
}
.dashboard-hero,
.dashboard-card {
  background: #fbfcff;
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(208, 213, 221, 0.7);
  padding: 16px;
}
.dashboard-hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: center;
  border-left: 5px solid var(--azul);
}
.dashboard-hero-verde { border-left-color: #16845b; }
.dashboard-hero-ambar { border-left-color: #d79000; }
.dashboard-hero-rojo { border-left-color: #b42318; }
.dashboard-semaforo {
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 8px 20px rgba(20, 33, 61, 0.12);
}
.luz {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: block;
}
.luz-verde,
.dashboard-bar-verde,
.dashboard-progress-verde { background: #16845b; }
.luz-ambar,
.dashboard-bar-ambar,
.dashboard-progress-ambar { background: #d79000; }
.luz-rojo,
.dashboard-bar-rojo,
.dashboard-progress-rojo { background: #b42318; }
.dashboard-bar-sin-datos { background: #98a2b3; }
.dashboard-hero-copy {
  display: grid;
  gap: 3px;
}
.dashboard-hero-copy span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.dashboard-hero-copy strong {
  color: var(--azul);
  font-size: 25px;
}
.dashboard-hero-copy p {
  margin: 0;
  color: var(--muted);
}
.dashboard-progress-wrap {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
}
.dashboard-progress-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.dashboard-progress,
.dashboard-bar-track {
  position: relative;
  min-height: 12px;
  overflow: hidden;
  background: #e8edf5;
  border-radius: 999px;
}
.dashboard-progress-bar,
.dashboard-bar {
  display: block;
  height: 100%;
  border-radius: inherit;
}
.dashboard-progress-marker {
  position: absolute;
  top: -4px;
  width: 3px;
  height: 20px;
  background: var(--azul);
  transform: translateX(-1px);
}
.dashboard-card h3 {
  margin: 0 0 12px;
  color: var(--azul);
  font-size: 16px;
}
.dashboard-bars,
.dashboard-actions,
.dashboard-alert-list {
  display: grid;
  gap: 10px;
  margin: 0;
}
.dashboard-bar-row {
  display: grid;
  gap: 5px;
}
.dashboard-bar-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}
.dashboard-bar-label strong {
  color: var(--azul);
}
.dashboard-bar-row small {
  color: var(--muted);
}
.dashboard-alert-list {
  padding: 0;
  list-style: none;
}
.dashboard-alert {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 8px;
  align-items: start;
  padding: 10px;
  border-radius: 8px;
  background: white;
}
.dashboard-alert span {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fef3c7;
  color: #7a4a00;
  font-weight: 700;
}
.dashboard-alert-alta span {
  background: #fee4e2;
  color: #991b1b;
}
.dashboard-alert p {
  margin: 0;
}
.dashboard-ok {
  margin: 0;
  color: #065f46;
  background: #ecfdf3;
  padding: 12px;
  border-radius: 8px;
}
.dashboard-actions {
  padding-left: 22px;
}
.dashboard-actions li {
  padding-left: 4px;
}
.dashboard-capa-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.dashboard-capa-metric {
  display: grid;
  gap: 4px;
  background: white;
  border-radius: 8px;
  padding: 12px;
}
.dashboard-capa-metric strong {
  color: var(--azul);
  font-size: 21px;
}
.dashboard-capa-riesgo {
  border-left: 5px solid #b42318;
}
.dashboard-capa-ok {
  border-left: 5px solid #16845b;
}
.panel > h2,
.subpanel-title,
.subpanel > h2,
.panel-preview > h2,
.panel-explorador > h2 {
  color: var(--azul);
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 18px;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--oro);
}
.panel-preview > h2,
.panel-explorador > h2 {
  margin-bottom: 18px;
}
.panel-explorador {
  resize: horizontal;
  min-width: 240px;
  max-width: 520px;
}
.subpanel {
  margin-top: 24px;
  padding: 18px;
  background: #fbfcff;
  border-left: 4px solid rgba(0, 44, 122, 0.22);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(208, 213, 221, 0.55);
}
.subpanel:first-child {
  margin-top: 0;
}
.subpanel-body {
  display: grid;
  gap: 14px;
}
.filtros {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) repeat(4, minmax(120px, 1fr));
  gap: 16px;
  align-items: end;
}
.filtros label {
  display: grid;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.filtros input, .filtros select {
  min-width: 0;
  border: 1px solid var(--linea);
  background: white;
  color: var(--texto);
  padding: 10px;
  border-radius: 6px;
}
.filtros-acciones {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #e8edf5;
}
.filtros-acciones button {
  min-height: 34px;
  padding: 8px 10px;
}
.rce-resumen {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.rce-resumen div {
  display: grid;
  gap: 3px;
  border: 0;
  border-radius: 8px;
  padding: 12px;
  background: white;
  box-shadow: 0 4px 14px rgba(20, 33, 61, 0.07);
}
.rce-resumen strong {
  color: var(--azul);
  font-size: 18px;
}
.rce-resumen span {
  color: var(--muted);
  font-size: 12px;
}
.rce-sugerencias {
  border: 1px solid #fde68a;
  background: #fffbeb;
  margin-bottom: 10px;
  padding: 10px;
}
.rce-sugerencias h3 {
  margin: 0 0 6px;
  font-size: 14px;
}
.rce-sugerencias ul {
  margin: 0;
  padding-left: 18px;
}
.rce-sugerencias li {
  margin: 4px 0;
  overflow-wrap: anywhere;
}
.rce-tabla {
  display: grid;
  min-width: 760px;
}
.rce-header, .rce-row {
  display: grid;
  grid-template-columns: 150px minmax(180px, 1.2fr) minmax(180px, 1fr) minmax(180px, 1fr) 90px;
  gap: 8px;
  align-items: start;
  padding: 8px 0;
  border-bottom: 1px solid #eef2f6;
}
.rce-header {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.rce-row {
  font-size: 13px;
}
.rce-cubierto div:last-child {
  color: #065f46;
  font-weight: 700;
}
.rce-parcial div:last-child {
  color: #92400e;
  font-weight: 700;
}
.rce-faltante div:last-child {
  color: #991b1b;
  font-weight: 700;
}
.capa-metricas {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.capa-metricas div {
  display: grid;
  gap: 3px;
  border: 0;
  border-radius: 8px;
  padding: 12px;
  background: white;
  box-shadow: 0 4px 14px rgba(20, 33, 61, 0.07);
}
.capa-metricas strong {
  color: var(--azul);
  font-size: 18px;
}
.capa-metricas span {
  color: var(--muted);
  font-size: 12px;
}
.capa-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.capa-form label {
  display: grid;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.capa-form input, .capa-form select {
  min-width: 0;
  border: 1px solid var(--linea);
  padding: 8px;
}
.capa-lista {
  display: grid;
  min-width: 720px;
}
.capa-header, .capa-row {
  display: grid;
  grid-template-columns: 120px 120px 110px 140px 110px 120px;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #eef2f6;
}
.capa-header {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.capa-row {
  font-size: 13px;
}
.tree {
  display: grid;
  gap: 8px;
}
.tree-group {
  display: grid;
  gap: 4px;
}
.tree-children {
  display: grid;
  gap: 6px;
  margin-left: 20px;
  border-left: 3px solid rgba(0, 44, 122, 0.16);
  padding-left: 12px;
}
.tree-toggle, .tree-version {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  background: transparent;
  color: var(--texto);
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
}
.tree-toggle:hover, .tree-version:hover,
.tree-toggle:focus-visible, .tree-version:focus-visible {
  outline: 2px solid var(--oro);
  outline-offset: 1px;
  background: #f3f7ff;
  box-shadow: none;
}
.tree-toggle[aria-expanded="true"] {
  background: #eef4ff;
  box-shadow: inset 3px 0 0 var(--azul);
}
.tree-label {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.tree-caret {
  width: 20px;
  color: var(--azul);
  font-weight: 700;
  font-size: 15px;
}
.tree-version {
  font-size: 13px;
  padding-left: 24px;
}
.preview-resumen {
  display: grid;
  gap: 8px;
  border-bottom: 1px solid var(--linea);
  padding-bottom: 10px;
  margin-bottom: 12px;
}
.preview-resumen h3 {
  margin: 0;
  font-size: 16px;
}
.preview-texto, .preview-markdown, .preview-metadatos {
  max-height: 420px;
  overflow: auto;
  border: 0;
  border-radius: 8px;
  background: #fcfcfd;
  padding: 16px;
  box-shadow: inset 0 0 0 1px #e4e7ec;
}
.preview-empty {
  min-height: 260px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  text-align: center;
  color: var(--muted);
  background: #fbfcff;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px #e8edf5;
  padding: 24px;
}
.preview-empty-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #eaf1ff;
  color: var(--azul);
  font-weight: 700;
}
.preview-empty strong {
  color: var(--texto);
  font-size: 17px;
}
.preview-empty p {
  max-width: 320px;
  margin: 0;
}
.preview-texto {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.preview-pdf {
  width: 100%;
  min-height: 520px;
  border: 1px solid #e4e7ec;
}
.preview-imagen {
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  border: 1px solid #e4e7ec;
  background: #fcfcfd;
}
.preview-metadatos {
  display: grid;
  gap: 8px;
}
.preview-metadatos div {
  display: grid;
  gap: 4px;
}
.detalle-inline {
  margin-top: 16px;
  border-top: 1px solid var(--linea);
  padding-top: 12px;
}
.tabla-header, .tabla-row {
  display: grid;
  grid-template-columns: 110px 1fr 130px 110px 80px;
  gap: 8px;
  align-items: center;
}
.document-card-list {
  display: grid;
  gap: 12px;
}
.document-card {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: white;
  color: var(--texto);
  text-align: left;
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 5px 16px rgba(20, 33, 61, 0.08);
}
.document-card:hover,
.document-card:focus-visible {
  background: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.document-card-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}
.document-code {
  color: var(--azul);
  font-size: 16px;
}
.document-title {
  color: var(--texto);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.document-meta {
  color: var(--muted);
  font-size: 12px;
}
.document-status {
  flex: 0 0 auto;
}
.empty-inline {
  margin: 0;
  padding: 14px;
  text-align: center;
  background: white;
  border-radius: 8px;
}
.tabla-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--linea);
  padding: 8px 0;
}
.tabla-row {
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--texto);
  border-bottom: 1px solid #eef2f6;
  padding: 10px 0;
}
.tabla-row:hover {
  background: #f8fafc;
}
.chip {
  display: inline-block;
  padding: 6px 10px;
  border: 0;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}
.chip-borrador { color: #344054; background: #e8edf3; }
.chip-enrevision { color: #7a4a00; background: #fff1c2; }
.chip-aprobado { color: #002c7a; background: #dfeaff; }
.chip-publicado { color: #065f46; background: #d9f7e8; }
.chip-obsoleto { color: #7f1d1d; background: #fef2f2; }
.form-alta {
  display: grid;
  gap: 16px;
}
.form-alta label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}
.form-alta input, .form-alta select {
  min-width: 0;
  border: 1px solid var(--linea);
  padding: 10px;
  background: white;
  border-radius: 6px;
}
.detalle-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.detalle-meta div {
  display: grid;
  gap: 4px;
  border: 1px solid #eef2f6;
  padding: 8px;
}
.integridad {
  margin: 12px 0;
  padding: 12px 14px;
  font-weight: 700;
  border-radius: 8px;
  box-shadow: inset 4px 0 0 currentColor;
}
.integridad.ok { background: #ecfdf3; color: #065f46; }
.integridad.alerta { background: #fef2f2; color: #991b1b; }
.muted { color: var(--muted); }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes panelEnter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .layout-shell {
    padding: 14px;
  }
  .dashboard-kpis,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .dashboard-header {
    flex-direction: column;
  }
  .dashboard-hero {
    grid-template-columns: 1fr;
  }
  .filtros {
    grid-template-columns: 1fr;
  }
  .rce-resumen {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .capa-metricas, .capa-form {
    grid-template-columns: 1fr;
  }
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media print {
  body {
    background: white;
  }
  .topbar,
  .view-tabs,
  .dashboard-export {
    display: none;
  }
  .layout-shell,
  .panel-dashboard {
    padding: 0;
  }
  .panel,
  .dashboard-card,
  .dashboard-hero,
  .dashboard-kpi {
    box-shadow: none;
  }
}
