/* Avances MT · Hoja única del portal interior */
:root {
  --bg: #fafafa;
  --panel: #ffffff;
  --ink: #171717;
  --ink-2: #3f3f46;
  --muted: #71717a;
  --subtle: #a1a1aa;
  --line: #ebebeb;
  --line-2: #dedede;
  --hover: rgba(0, 0, 0, 0.04);
  --sel: rgba(0, 0, 0, 0.065);
  --indigo: #3B2DB8;
  --indigo-2: #3226a0;
  --indigo-soft: #f1effc;
  --amber: #d48a1c;
  --amber-soft: #fdf6ea;
  --r: 10px;
  --r-sm: 6px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
body.mesa:not(.lista) { visibility: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--indigo); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nota, .ns-texto { color: var(--muted); font-size: 13px; }
.ns-texto { margin: 0 0 12px; max-width: 62ch; }

/* ---------- Estructura principal ---------- */
.ventana {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  background: var(--bg);
}
#nav { display: contents; }
#main {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

/* ---------- Barra lateral ---------- */
.lat {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.lat-marca {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  flex: none;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}
.lat-marca img { width: 22px; height: 22px; display: block; }
.lat-marca b { display: block; font-size: 13px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.1; }
.lat-marca small { display: block; font-size: 11px; color: var(--muted); line-height: 1.2; }

.lat-nav {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.lat-item,
.lat-fam {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease;
}
.lat-item:hover, .lat-fam:hover { background: var(--hover); color: var(--ink); }
.lat-item.activo, .lat-fam.activo { background: var(--sel); color: var(--ink); }
.lat-ico {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--muted);
}
.lat-item.activo .lat-ico { color: var(--indigo); }
.lat-titulo {
  margin: 18px 10px 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--subtle);
}
.lat-fam b {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: none;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  background: var(--panel);
}
.lat-fam.activo b { border-color: var(--indigo); color: var(--indigo); }
.lat-fam span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lat-fam em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.lat-sub {
  display: flex;
  flex-direction: column;
  margin: 2px 0 6px 19px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}
.lat-sub-item {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}
a.lat-sub-item:hover { color: var(--ink); background: var(--hover); }
.lat-sub-item.activo { color: var(--ink); font-weight: 500; }
.lat-sub-item.activo::before {
  content: "";
  position: absolute;
  left: -13px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--indigo);
}
.lat-sub-item.apagado { color: #c8c8cc; cursor: default; }
.bloqueado { opacity: 0.4; pointer-events: none; cursor: default; }

.lat-pie {
  position: relative;
  flex: none;
  padding: 8px;
  border-top: 1px solid var(--line);
}
button.ns-perfil {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 500;
}
button.ns-perfil:hover { background: var(--hover); }
.ns-perfil i {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo), #180D5B);
  color: #fff;
  font-style: normal;
  font-size: 12px;
  font-weight: 600;
}
.ns-perfil span { flex: 1; min-width: 0; }
.ns-perfil span b, .ns-perfil span small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ns-perfil span b { font-size: 13px; font-weight: 500; }
.ns-perfil span small { font-size: 11px; color: var(--muted); font-weight: 400; }
.ns-perfil-menu {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 8px;
  right: 8px;
  z-index: 30;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
.ns-perfil-menu button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 500;
}
.ns-perfil-menu button:hover { background: var(--hover); }

/* ---------- Controles y utilidades ---------- */
.ns-col { padding: 24px 28px 36px; }
.ns-col h2, .ns-card h2 {
  margin: 0 0 14px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.ns-kicker {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--indigo);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}
button:hover { background: var(--indigo-2); }
button:disabled { opacity: 0.5; cursor: default; }
button.secundario {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--line-2);
}
button.secundario:hover { background: #f7f7f7; border-color: #cfcfcf; }
button.ns-guardado, button.ns-guardado:disabled {
  background: #e8f7f5;
  color: #11786d;
  border-color: #bfe9e3;
  opacity: 1;
}

input:not([type]), input[type="text"], input[type="number"], input[type="search"], select, textarea {
  padding: 7px 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--panel);
  font-size: 13px;
  color: var(--ink);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(59, 45, 184, 0.12);
}
textarea { width: 100%; min-height: 72px; }
input[type="checkbox"] { accent-color: var(--indigo); }
input[type="file"] { font-size: 13px; color: var(--muted); max-width: 100%; }
input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 6px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: #f7f7f7; }

.ns-caja {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 12px;
}
.ns-caja strong { display: block; margin-top: 4px; overflow-wrap: anywhere; }
.ns-caja ul { margin: 8px 0 0; padding-left: 18px; }
.ns-flag {
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid #f1dcb6;
  border-radius: var(--r);
  background: var(--amber-soft);
  color: #8a5a10;
  font-size: 13px;
}
.ns-ok {
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: #f7f7f8;
  font-size: 13px;
}
.ns-subir {
  padding: 16px;
  margin-bottom: 12px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r);
  background: var(--panel);
}
.ns-subir.sobre { border-color: var(--indigo); background: var(--indigo-soft); }
.ns-subir-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ns-subir p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.ns-ruta {
  margin: 0 0 12px;
  padding: 10px 12px;
  background: #f4f4f5;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 600;
}
.ns-ruta small { display: block; margin-bottom: 2px; font-size: 11px; font-weight: 500; color: var(--muted); }
.ns-guia { margin: 8px 0 12px; padding-left: 18px; }
.ns-guia li { margin: 6px 0; }
.ns-historial { list-style: none; margin: 8px 0 0; padding: 0; }
.ns-historial li {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 8px;
  padding: 8px 0;
  border-top: 1px solid #f2f2f2;
  font-size: 13px;
}
.ns-historial time { color: var(--muted); font-family: var(--mono); font-size: 11px; }

/* ---------- Inicio ---------- */
.ns-tablero {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 32px max(32px, calc((100% - 1120px) / 2)) 40px;
}
.ns-encabezado h1 { margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.025em; }
.ns-encabezado p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.ns-consulta-nota { margin: 0; color: var(--muted); font-size: 13px; }
.ns-tablero-main { display: flex; flex-direction: column; gap: 20px; }

.ns-dona {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.ns-hero-pct {
  display: flex;
  flex-direction: column;
  padding: 20px 22px;
  border-right: 1px solid var(--line);
}
.ns-hero-pct span { font-size: 13px; font-weight: 500; color: var(--muted); }
.ns-hero-pct strong {
  display: block;
  margin: 10px 0 14px;
  font-size: 44px;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.ns-hero-pct p { margin: 12px 0 0; color: var(--muted); font-size: 12px; max-width: 34ch; }
.ns-progreso { display: block; height: 4px; border-radius: 99px; background: #efefef; overflow: hidden; }
.ns-progreso em { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--indigo), #6a5ce0); }

.ns-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.ns-kpi { padding: 20px 18px; }
.ns-kpi + .ns-kpi { border-left: 1px solid var(--line); }
.ns-kpi span { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.ns-kpi strong { display: block; margin-top: 10px; font-size: 24px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.ns-kpi em { display: block; margin-top: 6px; font-style: normal; font-size: 12px; color: var(--subtle); }

.ns-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.ns-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.ns-card-head h2 { margin: 0; font-size: 15px; letter-spacing: -0.01em; }
.ns-card-head .nota { margin: 2px 0 0; }
.ns-sort {
  display: flex;
  flex-shrink: 0;
  padding: 2px;
  background: #f4f4f5;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.ns-sort button {
  padding: 5px 10px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}
.ns-sort button:hover { background: transparent; color: var(--ink); }
.ns-sort button.activo {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 0 0 1px var(--line);
}

.ns-barras { display: flex; flex-direction: column; }
.ns-barra {
  display: grid;
  grid-template-columns: 22px minmax(140px, 240px) minmax(0, 1fr) 72px;
  gap: 14px;
  align-items: center;
  min-height: 44px;
  padding: 0 20px;
  border-bottom: 1px solid #f2f2f2;
  text-decoration: none;
  color: var(--ink);
  font-size: 13px;
}
.ns-barra:last-child { border-bottom: 0; }
.ns-barra:hover { background: #fafafa; }
.ns-barra b {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}
.ns-barra span { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ns-barra i { display: block; height: 4px; border-radius: 99px; background: #f0f0f0; overflow: hidden; }
.ns-barra em { display: block; height: 100%; border-radius: 99px; background: var(--indigo); }
.ns-barra.alto em { background: linear-gradient(90deg, var(--indigo), #6a5ce0); }
.ns-barra strong { text-align: right; font-family: var(--mono); font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
.ns-barra.vacio span { color: var(--muted); font-weight: 400; }
.ns-barra.vacio strong { font-family: var(--font); color: var(--subtle); font-weight: 400; }

/* ---------- Resumen de familia ---------- */
.ns-familia { display: flex; flex-direction: column; gap: 16px; max-width: 1180px; }
.ns-familia h2 { margin: 0; font-size: 24px; }
.ns-avance {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  overflow: hidden;
}
.ns-avance .ns-hero-pct { justify-content: center; }
.ns-leyenda-caja { padding: 20px 24px; display: flex; align-items: center; }
.ns-leyenda-kpi { display: flex; flex-wrap: wrap; gap: 28px; width: 100%; }
.ns-leyenda-kpi div { flex: 1; min-width: 150px; }
.ns-leyenda-kpi span { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.ns-leyenda-kpi strong { display: block; margin: 8px 0 4px; font-size: 22px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.ns-leyenda-kpi em { display: block; font-style: normal; color: var(--subtle); font-size: 12px; }

.ns-kpis-top { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.ns-kpi-tile {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  text-decoration: none;
  color: var(--ink);
}
.ns-kpi-tile span { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.ns-kpi-tile strong { display: block; margin: 8px 0 4px; font-size: 24px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.ns-kpi-tile em { font-style: normal; color: var(--subtle); font-size: 12px; }
a.ns-kpi-tile.ns-ir:hover { border-color: var(--indigo); }
a.ns-kpi-tile.ns-ir em { color: var(--indigo); }
a.ns-kpi-tile.ns-ir em::after { content: " →"; }

a.ns-pendiente {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  align-items: center;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  text-decoration: none;
  color: var(--ink);
}
a.ns-pendiente:hover { border-color: #e9c98f; }
.ns-pendiente b {
  min-width: 56px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: var(--amber-soft);
  color: #8a5a10;
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.ns-pendiente strong { display: block; font-size: 14px; font-weight: 600; }
.ns-pendiente em { display: block; margin-top: 4px; font-style: normal; color: var(--muted); font-size: 13px; }

.ns-detalles > .ns-kicker { margin-bottom: 8px; }
.ns-tarjetas { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
a.ns-tarjeta {
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 140ms ease;
}
a.ns-tarjeta:hover { border-color: #cfcfcf; }
.ns-tarjeta header { display: flex; flex-direction: column; gap: 2px; }
.ns-tarjeta header b { font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--muted); }
.ns-tarjeta header span { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.ns-tarjeta dl { margin: 10px 0 0; }
.ns-tarjeta dl div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid #f2f2f2;
  font-size: 13px;
}
.ns-tarjeta dt { color: var(--muted); }
.ns-tarjeta dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 500; }
.ns-tarjeta footer {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  margin-top: auto;
  padding-top: 10px;
}
.ns-tarjeta footer span { color: var(--muted); font-size: 12px; }
.ns-tarjeta footer strong { font-family: var(--mono); font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
.ns-tarjeta footer i { grid-column: 1 / -1; display: block; height: 4px; margin-top: 6px; background: #f0f0f0; border-radius: 99px; overflow: hidden; }
.ns-tarjeta footer em { display: block; height: 100%; background: var(--indigo); border-radius: 99px; }

/* ---------- Tabla de artículos y filtros ---------- */
.filtros { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 14px; }
.filtros input[type="search"] { flex: 1 1 260px; max-width: 340px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }

.tabla-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid #f2f2f2; vertical-align: middle; }
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fafafa;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  border-bottom: 1px solid var(--line);
}
tr.fila { cursor: pointer; }
tbody tr:hover td { background: #fafafa; }
td.mono button[data-codigo] {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--indigo);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
}
td.mono button[data-codigo]:hover { background: transparent; text-decoration: underline; text-underline-offset: 3px; }

.etiqueta {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid #d6d1f5;
  border-radius: 999px;
  background: var(--indigo-soft);
  color: var(--indigo);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.etiqueta.inactivo { border-color: var(--line-2); background: #f4f4f5; color: var(--muted); }
.etiqueta.alerta { border-color: #f1dcb6; background: var(--amber-soft); color: #8a5a10; }

/* ---------- Modal / Ficha ---------- */
dialog {
  width: min(860px, calc(100% - 24px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.14);
}
dialog::backdrop { background: rgba(10, 10, 20, 0.28); }
#instruccion { width: min(480px, calc(100% - 24px)); }
.ficha { padding: 20px; }
.ficha h2 { margin: 4px 0; font-family: var(--mono); font-size: 18px; }
.ficha h3 { margin: 16px 0 8px; font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.ficha-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ficha-grid .ancho { grid-column: 1 / -1; }
.campo { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.campo select, .campo input { width: 100%; }
.ctor-par { display: flex; gap: 8px; }
.ctor-par input { flex: 1; min-width: 0; }
.ctor-par select { width: 80px; flex: none; }
.ctor-previa { padding: 12px 14px; margin: 10px 0 14px; background: #fafafa; border: 1px solid var(--line); border-radius: var(--r); }
.ctor-previa p { margin: 4px 0; font-size: 13px; }
.ctor-previa b { font-family: var(--mono); font-weight: 500; }
.botones { display: flex; flex-wrap: wrap; gap: 8px; }
button.cerrar {
  float: right;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
}
button.cerrar:hover { background: var(--hover); color: var(--ink); }

/* ---------- Actualizar ---------- */
.ns-actualizar { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 14px; align-items: start; max-width: 1100px; }
.ns-actualizar-lado { position: sticky; top: 0; }
.ns-actualizar-lado .ns-historial div { overflow-wrap: anywhere; }
.ns-filtros { width: 100%; margin: 8px 0 4px; }
.ns-filtros td:last-child { font-family: var(--mono); font-size: 12px; }
.ns-rev-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin: 18px 0 12px; }
.ns-rev-head h3 { margin: 0 0 4px; }
.ns-rev-head .nota { margin: 0; }
.ns-rev-tabla { max-height: min(520px, 60vh); }
.ns-rev-marca { width: 44px; text-align: center; }

/* ---------- Análisis ---------- */
.ns-titular { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; max-width: 760px; margin-bottom: 16px; }
.ns-titular h2 { margin-bottom: 4px; }
.ns-titular .ns-texto { margin: 0; }
.ns-titular button { flex: none; }

.an-nuevo {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  max-width: 760px;
  margin: 0 0 16px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.an-nuevo label { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 140px; font-size: 12px; font-weight: 500; color: var(--muted); }
.an-nuevo input { width: 100%; }
.an-nuevo input[name="grupo"] { text-transform: uppercase; }
.an-nuevo .nota { flex-basis: 100%; margin: 0; }
.an-nuevo .nota:empty { display: none; }

.an-grupos {
  display: flex;
  flex-direction: column;
  max-width: 760px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.an-grupo {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 14px;
  align-items: baseline;
  padding: 12px 18px;
  border-bottom: 1px solid #f2f2f2;
  text-decoration: none;
  color: inherit;
  transition: background 120ms ease;
}
.an-grupo:last-child { border-bottom: 0; }
.an-grupo:hover { background: #fafafa; }
.an-grupo b { grid-column: 1; grid-row: 1; font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--muted); }
.an-grupo span { grid-column: 2; grid-row: 1; color: var(--ink); font-weight: 500; }
.an-grupo strong { grid-column: 3; grid-row: 1 / span 2; align-self: center; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.an-grupo small { grid-column: 2; grid-row: 2; color: var(--subtle); font-size: 12px; }

.an-marco { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; max-width: 1180px; }
.an-marco.solo { grid-template-columns: minmax(0, 1fr); }
.an-principal { min-width: 0; }
.an-principal h2 { margin-bottom: 4px; }
.an-fecha { margin: 0 0 12px; font-size: 14px; font-weight: 500; color: var(--ink-2); }
.an-bloque { margin: 0 0 22px; }
.an-bloque h3 { margin: 4px 0 12px; font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.an-mix { display: flex; height: 32px; border-radius: var(--r-sm); overflow: hidden; background: #f0f0f0; }
.an-mix span { display: flex; align-items: center; justify-content: center; min-width: 4px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.an-mix-leyenda { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.an-mix-leyenda li { display: inline-flex; align-items: baseline; gap: 6px; font-size: 13px; }
.an-mix-leyenda i { width: 9px; height: 9px; border-radius: 50%; align-self: center; }
.an-mix-leyenda b, .an-mix-leyenda em { font-variant-numeric: tabular-nums; }
.an-mix-leyenda em { font-style: normal; color: var(--muted); }

.an-globales { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0 0 22px; }
.an-globales div { padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.an-globales b { display: block; font-size: 28px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.an-globales span { display: block; margin-top: 8px; font-weight: 600; font-size: 13px; }
.an-globales small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }

.an-etapas { display: flex; flex-direction: column; gap: 10px; }
.an-etapa { padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.an-etapa header { display: grid; grid-template-columns: 10px 1fr auto auto; gap: 8px; align-items: baseline; }
.an-etapa header i { width: 9px; height: 9px; border-radius: 50%; align-self: center; }
.an-etapa header b { font-size: 16px; font-variant-numeric: tabular-nums; }
.an-etapa header em { font-style: normal; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: right; }
.an-etapa-barra { height: 4px; margin: 10px 0 4px; background: #f0f0f0; border-radius: 99px; overflow: hidden; }
.an-etapa-barra span { display: block; height: 100%; }
.an-etapa ul { list-style: none; margin: 8px 0 0; padding: 0; }
.an-etapa li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0 6px 18px; border-top: 1px solid #f2f2f2; font-size: 13px; color: var(--ink-2); }
.an-etapa li b { font-variant-numeric: tabular-nums; color: var(--ink); }
.an-etapa p { margin: 8px 0 0; color: var(--muted); font-size: 12px; }

.an-bitacora { padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.an-bitacora ol { list-style: none; margin: 12px 0 0; padding: 0; }
.an-bitacora li + li { margin-top: 14px; padding-top: 14px; border-top: 1px solid #f2f2f2; }
.an-bitacora time { display: block; font-size: 14px; font-weight: 600; }
.an-bitacora dl { margin: 8px 0 0; }
.an-bitacora dl div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-top: 1px solid #f5f5f5; font-size: 13px; }
.an-bitacora dt { color: var(--muted); }
.an-bitacora dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; }
.an-bitacora p { margin: 8px 0 0; color: var(--muted); font-size: 12px; }

.an-acciones { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); }
.ns-acciones { display: flex; flex-wrap: wrap; gap: 8px; }
.an-embebido { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); gap: 24px; align-items: start; }
.ns-pasos { display: grid; gap: 6px; margin: 14px 0; }
.ns-paso { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid transparent; border-radius: var(--r-sm); font-size: 13px; }
.ns-paso span { color: var(--muted); font-variant-numeric: tabular-nums; }
.ns-paso.ahora { border-left-color: var(--indigo); }
.ns-cifra { margin: 0 0 4px; font-size: 40px; font-weight: 600; letter-spacing: -0.04em; line-height: 1; }
.ns-cifra small { display: block; margin-top: 6px; font-size: 13px; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.ns-herramientas { display: flex; align-items: flex-end; gap: 12px; margin: 14px 0; }
.ns-tamano { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.ns-tamano input { width: 5.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.ns-iconos { display: flex; gap: 6px; }
button.ns-ico, button.ns-info {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--ink-2);
}
button.ns-info { width: 26px; height: 26px; font-weight: 600; }
button.ns-ico svg { width: 17px; height: 17px; }
button.ns-ico:hover, button.ns-ico.lleno, button.ns-info:hover { background: var(--indigo-soft); color: var(--indigo); border-color: #d6d1f5; }
button.ns-como { padding: 3px 9px; border-radius: 999px; border-color: #d6d1f5; background: var(--indigo-soft); color: var(--indigo); font-size: 11px; font-weight: 600; }
button.ns-como:hover { background: #e6e2fb; }
.ns-codigos { margin: 0; max-height: 240px; overflow: auto; white-space: pre; font-family: var(--mono); font-size: 12px; padding: 10px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.ns-head-clas { display: flex; align-items: center; gap: 10px; }
.ns-head-clas h2 { margin: 0; }
.ns-listo { margin: 8px 0 14px; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.ns-listo p:last-child { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
button.ns-clasificar { width: 100%; margin-top: 8px; padding: 11px 16px; font-size: 14px; font-weight: 600; }
.ns-clases { width: 100%; margin-top: 12px; font-size: 13px; }

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
  .ns-dona, .ns-avance { grid-template-columns: 1fr; }
  .ns-hero-pct { border-right: 0; border-bottom: 1px solid var(--line); }
  .ns-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ns-kpi + .ns-kpi { border-left: 0; }
  .ns-kpi { border-bottom: 1px solid var(--line); }
  .ns-tarjetas { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .an-marco, .ns-actualizar, .an-embebido { grid-template-columns: 1fr; }
  .ns-actualizar-lado { position: static; }
}

@media (max-width: 860px) {
  body { overflow: auto; height: auto; }
  .ventana { height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .lat { border-right: 0; border-bottom: 1px solid var(--line); }
  .lat-nav { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; padding: 8px; gap: 4px; }
  .lat-titulo, .lat-sub, .lat-pie { display: none; }
  .lat-item, .lat-fam { flex: none; }
  .lat-fam span { display: none; }
  #main { grid-column: 1; grid-row: 2; }
  .ns-tablero { padding: 20px 16px; }
  .ns-kpis { grid-template-columns: 1fr 1fr; }
  .ns-barra { grid-template-columns: 22px minmax(0, 1fr) 64px; padding: 10px 16px; }
  .ns-barra i { grid-column: 2 / -1; grid-row: 2; }
  .ns-col { padding: 20px 16px; }
  .ns-tarjetas, .ns-kpis-top, .an-globales, .ficha-grid { grid-template-columns: 1fr 1fr; }
}
