/*
 * Radar MP — extensiones de layout sobre NEXORA UI.
 * Regla: sólo tokens --nx-* y patrones del sistema; sin colores ni sombras propias.
 */

.brand-mark-radar::before {
  content: "R";
  letter-spacing: 0;
  transform: none;
}

.topbar-title .eyebrow {
  margin-bottom: 0;
}

/* Encabezados de sección */
.section-heading-aside {
  flex-shrink: 0;
  text-align: right;
}

.detail-heading {
  gap: 1.5rem;
}

.section-heading.detail-heading h1 {
  margin-bottom: 0;
  font-size: clamp(1.375rem, 2.2vw, 1.875rem);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-start;
  justify-content: flex-end;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 1rem;
  color: var(--nx-text-secondary);
  font-size: 0.8125rem;
  font-weight: 550;
  text-decoration: none;
}

.back-link:hover {
  color: var(--nx-brand);
}

/* Toolbar de listados */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--nx-border);
}

.toolbar .component-title {
  font-size: 0.875rem;
  white-space: nowrap;
}

.toolbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  flex: 1 1 auto;
  justify-content: flex-end;
  min-width: 0;
}

.toolbar-controls .search-shell {
  flex: 1 1 11rem;
}

.toolbar-controls .search-shell .form-control {
  padding-right: 0.875rem;
}

.toolbar-controls .form-select {
  width: auto;
  min-width: 9rem;
}

/* Rango de monto (desde – hasta) */
.monto-range {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--nx-text-secondary);
}

.monto-range .form-control {
  width: 8rem;
}

@media (max-width: 575.98px) {
  .monto-range {
    flex: 1 1 100%;
  }

  .monto-range .form-control {
    width: auto;
    flex: 1 1 0;
    min-width: 0;
  }
}

/* Línea de palabras clave + contador de resultados */
.keyword-bar {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding-right: 0.875rem;
  border-bottom: 1px solid var(--nx-border);
}

.keyword-bar .keyword-chips {
  flex: 1 1 auto;
  min-width: 0;
  border-bottom: 0;
}

.keyword-bar .component-title {
  flex-shrink: 0;
  padding-top: 0.75rem;
  font-size: 0.8125rem;
  white-space: nowrap;
}

/* Chips de palabras clave */
.keyword-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3125rem;
  padding: 0.5rem 0.875rem;
  border-bottom: 1px solid var(--nx-border);
}

.keyword-chip {
  min-height: 1.625rem;
  padding: 0.0625rem 0.5rem;
  font-size: 0.8125rem;
  color: var(--nx-text-secondary);
  font-weight: 550;
  background: var(--nx-surface-1);
  border: 1px solid var(--nx-border);
  border-radius: var(--nx-radius-pill);
}

.keyword-chip:hover {
  color: var(--nx-text);
  background: var(--nx-surface-2);
}

.keyword-chip.active {
  color: var(--nx-brand);
  background: color-mix(in srgb, var(--nx-brand) 8%, var(--nx-surface-1));
  border-color: color-mix(in srgb, var(--nx-brand) 30%, var(--nx-border));
}

.keyword-chip-count {
  margin-left: 0.25rem;
  color: var(--nx-text-muted);
  font-variant-numeric: tabular-nums;
}

/* Tablas de datos */

/* Los .visually-hidden (position: absolute) de celdas deben quedar dentro del scroll de la tabla;
   sin esto escapan del contenedor y ensanchan el documento en móvil. */
.table-responsive {
  position: relative;
}

.data-table th,
.data-table td {
  vertical-align: top;
}

.data-table .cell-main {
  min-width: 18rem;
  max-width: 30rem;
}

.data-table .cell-org {
  min-width: 12rem;
  max-width: 18rem;
}

.data-table .cell-sync {
  min-width: 11rem;
  max-width: 18rem;
}

.data-table td,
.data-table th {
  font-variant-numeric: tabular-nums;
}

.data-table .status-pill {
  margin-top: 0.25rem;
}

.row-link {
  color: var(--nx-text);
  font-weight: 600;
  text-decoration: none;
}

.row-link:hover,
.row-link:focus-visible {
  color: var(--nx-brand);
  text-decoration: underline;
}

.row-muted th,
.row-muted td {
  color: var(--nx-text-muted);
}

/* Detalle */
.detail-stack {
  display: grid;
  gap: 1.25rem;
  align-content: start;
}

.detail-stack > .component-panel + .component-panel {
  margin-top: 0;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.detail-subtitle {
  margin: 1.25rem 0 0.375rem;
  color: var(--nx-text);
  font-size: 0.875rem;
  font-weight: 650;
}

.detail-subtitle:first-child {
  margin-top: 0;
}

.prose p {
  margin-bottom: 0.625rem;
  color: var(--nx-text-secondary);
  overflow-wrap: anywhere;
}

.prose p:last-child {
  margin-bottom: 0;
}

.text-prewrap {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.fact-list {
  display: grid;
  gap: 0.875rem;
  margin: 0;
}

.fact dt {
  margin-bottom: 0.125rem;
  color: var(--nx-text-muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.fact dd {
  margin: 0;
  color: var(--nx-text);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.doc-list .list-group-item {
  padding-inline: 0;
  background: transparent;
}

.doc-icon {
  display: inline-grid;
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  color: var(--nx-brand);
  background: color-mix(in srgb, var(--nx-brand) 8%, var(--nx-surface-1));
  border: 1px solid color-mix(in srgb, var(--nx-brand) 20%, var(--nx-surface-1));
  border-radius: var(--nx-radius-sm);
  place-items: center;
}

.kpi-card {
  min-height: 0;
  padding: 0.75rem 1rem;
}

.kpi-card .kpi-label {
  display: block;
  padding-right: 2.25rem;
  font-size: 0.75rem;
}

.kpi-card .kpi-value {
  margin: 0.125rem 0 0;
  font-size: clamp(1.125rem, 1.8vw, 1.375rem);
  line-height: 1.2;
}

.kpi-card small {
  overflow: hidden;
  font-size: 0.75rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.kpi-card .kpi-icon {
  top: 0.625rem;
  right: 0.625rem;
  width: 1.75rem;
  height: 1.75rem;
}

.kpi-card .kpi-icon .icon {
  width: 1rem;
  height: 1rem;
}

/* Espaciado general más compacto: usa todo el ancho disponible */
.app-content {
  width: 100%;
  padding: clamp(0.75rem, 1.6vw, 1.25rem) clamp(0.75rem, 1.8vw, 1.5rem);
}

.app-content .component-grid {
  gap: 0.75rem;
}

.app-content .component-grid.mb-4 {
  margin-bottom: 0.75rem !important;
}

.app-content .section-heading {
  margin-bottom: 0.75rem;
}

.app-content .section-heading p:not(.eyebrow) {
  margin-bottom: 0;
  font-size: 0.875rem;
}

/* Aviso compacto y plegable (estado de la última actualización) */
.alert-compact {
  --bs-alert-padding-y: 0.5rem;
  --bs-alert-padding-x: 0.875rem;
  --bs-alert-margin-bottom: 0.75rem;
  font-size: 0.875rem;
}

.alert-compact details > summary {
  cursor: pointer;
  list-style: none;
}

.alert-compact details > summary::-webkit-details-marker {
  display: none;
}

.alert-compact details > summary .summary-more {
  margin-left: 0.25rem;
  text-decoration: underline;
}

.alert-compact details[open] > summary .summary-more {
  display: none;
}

.alert-compact details p {
  margin: 0.375rem 0 0;
}

.alert-compact .btn-close {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  min-width: 0;
  min-height: 0;
  padding: 0;
  background-size: 0.625rem;
}

/* Títulos de página compactos (el título ya está en la barra superior) */
.app-content .section-heading:not(.detail-heading) h1 {
  margin-bottom: 0.125rem;
  font-size: 1.375rem;
  line-height: 1.25;
}

.app-content .section-heading:not(.detail-heading) .eyebrow {
  margin-bottom: 0.125rem;
  font-size: 0.6875rem;
}

.kpi-card .kpi-value {
  padding-right: 2.75rem;
  font-size: clamp(1.375rem, 2.2vw, 1.75rem);
  overflow-wrap: anywhere;
}

/* Responsive */
@media (max-width: 767.98px) {
  .section-heading-aside {
    margin-top: 0.75rem;
    text-align: left;
  }

  .detail-actions {
    justify-content: flex-start;
    margin-top: 1rem;
  }

  .toolbar-controls {
    flex-basis: 100%;
  }

  .toolbar-controls > div,
  .toolbar-controls .form-select {
    flex: 1 1 100%;
    min-width: 0;
  }
}

/* Pasos guiados (Integraciones → Telegram) */
.setup-steps {
  display: grid;
  gap: 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.setup-step {
  display: flex;
  gap: 0.875rem;
  align-items: flex-start;
}

.setup-step-num {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--nx-border);
  border-radius: 999px;
  color: var(--nx-text-secondary);
  font-size: 0.8125rem;
  font-weight: 650;
}

.setup-step.is-active .setup-step-num {
  border-color: var(--nx-brand);
  color: var(--nx-brand);
}

.setup-step.is-done .setup-step-num {
  border-color: transparent;
  color: var(--nx-success, var(--nx-brand));
}

/* Historial de una oportunidad */
.timeline {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0 0 0 1rem;
  border-left: 2px solid var(--nx-border);
  list-style: none;
}

.timeline-item {
  position: relative;
}

.timeline-item::before {
  position: absolute;
  top: 0.4rem;
  left: calc(-1rem - 5px);
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--nx-brand);
  content: "";
}

/* Decisión «¿postulo?» en Compras Ágiles */
.decision-cell {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.375rem;
}

.decision-cell .btn {
  white-space: nowrap;
}

.decision-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border: 1px solid var(--nx-border);
  border-radius: var(--nx-radius, 0.75rem);
}

/* Responsable (asignación) en tablas */
.responsable-select {
  min-width: 9rem;
}

/* Pantalla de ingreso */
.login-wrap {
  display: grid;
  min-height: 70vh;
  place-items: center;
}

.login-card {
  width: min(100%, 26rem);
}

body.is-login .app-sidebar {
  display: none !important;
}

/* Tamaño de la torta (Compras Ágiles) */
.torta-panel .panel-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}

.torta-cuerpo {
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) minmax(0, 2fr);
  gap: 1rem;
  margin-top: 0.75rem;
}

.torta-cifras {
  display: grid;
  gap: 0.75rem;
  align-content: start;
}

.torta-cifras .kpi-label {
  font-size: 0.75rem;
  color: var(--nx-text-secondary);
}

.torta-monto {
  font-size: clamp(1.375rem, 2.4vw, 1.75rem);
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  color: var(--nx-text);
}

.torta-dias {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.375rem;
  height: 9rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.torta-dia {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.25rem;
  min-width: 0;
  text-align: center;
}

.torta-valor,
.torta-etiqueta {
  overflow: hidden;
  font-size: 0.6875rem;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--nx-text-muted);
  font-variant-numeric: tabular-nums;
}

.torta-barra-wrap {
  display: flex;
  align-items: flex-end;
  height: 100%;
  border-bottom: 1px solid var(--nx-border);
}

.torta-barra {
  width: 100%;
  border-radius: var(--nx-radius-sm) var(--nx-radius-sm) 0 0;
  background: color-mix(in srgb, var(--nx-brand) 45%, var(--nx-surface-1));
}

.torta-dia.es-hoy .torta-barra {
  background: var(--nx-brand);
}

.torta-dia.es-hoy .torta-etiqueta,
.torta-dia.es-hoy .torta-valor {
  font-weight: 600;
  color: var(--nx-text);
}

@media (max-width: 640px) {
  .torta-cuerpo {
    grid-template-columns: 1fr;
  }

  .torta-cifras {
    grid-template-columns: 1fr 1fr;
  }
}

/* Página intermedia del retorno de Google (/api/auth/google/callback). */
.google-retorno {
  display: grid;
  place-items: center;
  min-height: 90vh;
  margin: 0;
}
