/* Consola de Nexus · Agentemotor Design System (tokens.css). Plano, sin degradados ni sombras decorativas. */

@font-face { font-family: 'Numans'; font-weight: 400; font-display: swap; src: url(fuentes/Numans-400-latin.woff2) format('woff2'); }
@font-face { font-family: 'Nunito'; font-weight: 400; font-display: swap; src: url(fuentes/Nunito-400-latin.woff2) format('woff2'); }
@font-face { font-family: 'Nunito'; font-weight: 700; font-display: swap; src: url(fuentes/Nunito-700-latin.woff2) format('woff2'); }
@font-face { font-family: 'Nunito'; font-weight: 800; font-display: swap; src: url(fuentes/Nunito-800-latin.woff2) format('woff2'); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--am-color-surface-app); color: var(--am-color-text-primary);
  font-family: var(--am-font-body); font-size: 15px; line-height: 1.5;
}
h1, h2, h3 { font-family: var(--am-font-display); font-weight: 400; margin: 0; text-wrap: balance; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--am-violet-200); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
code, pre { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: 13px; }

/* Barra superior */
.barra { height: 60px; background: var(--am-violet-600); color: #fff; display: flex; align-items: center; gap: 12px; padding: 0 20px; }
.barra__logo { width: 28px; height: 28px; }
.barra__titulo { font-family: var(--am-font-display); font-size: 22px; }
.barra__sub { font-weight: 700; color: var(--am-violet-100); }
.barra__espacio { flex: 1; }
.barra__identidad { font-size: 12px; color: var(--am-violet-100); max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entorno { height: 26px; padding: 0 10px; border-radius: 6px; font-weight: 800; font-size: 13px; display: inline-flex; align-items: center; background: var(--am-violet-700); }
.entorno[data-destino="pruebas"] { background: var(--am-cyan-500); color: var(--am-neutral-900); }
.entorno[data-destino="produccion"] { background: var(--am-coral-500); color: var(--am-neutral-900); }
.banner { background: var(--am-violet-600); color: #fff; font-weight: 700; font-size: 14px; padding: 8px 20px; border-top: 1px solid var(--am-violet-700); }

/* Estructura */
.app { display: grid; grid-template-columns: 320px minmax(0, 1fr); min-height: calc(100% - 60px); }
.lateral { background: var(--am-color-surface-default); border-right: 1px solid var(--am-color-border-default); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.detalle { padding: 28px 32px 64px; min-width: 0; }

.buscar { position: relative; display: block; }
.buscar svg { position: absolute; left: 14px; top: 14px; color: var(--am-neutral-500); }
.buscar input { width: 100%; height: 48px; padding: 0 14px 0 44px; border: 1.5px solid var(--am-color-border-input); border-radius: 8px; background: #fff; }
.buscar input:hover { border-color: var(--am-neutral-400); }
.buscar input:focus { outline: none; border-color: var(--am-violet-600); box-shadow: 0 0 0 3px var(--am-violet-100); }

.segmentado { display: flex; background: var(--am-neutral-50); border-radius: 10px; padding: 4px; gap: 4px; }
.segmentado button { flex: 1; height: 36px; white-space: nowrap; font-size: 14px; padding: 0 8px; border: 0; background: transparent; border-radius: 8px; font-weight: 700; color: var(--am-neutral-600); cursor: pointer; }
.segmentado button[aria-checked="true"] { background: #fff; box-shadow: 0 0 0 1px var(--am-neutral-200); color: var(--am-violet-600); font-weight: 800; }
.conteo { margin: 0; font-size: 12px; font-weight: 800; color: var(--am-neutral-600); text-transform: uppercase; letter-spacing: .06em; }

.lista { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.grupo { font-size: 12px; font-weight: 800; color: var(--am-neutral-500); margin: 12px 4px 4px; }
.item { display: grid; gap: 2px; text-align: left; border: 0; background: transparent; border-radius: 8px; padding: 10px 12px; cursor: pointer; min-height: 44px; }
.item:hover { background: var(--am-neutral-50); }
.item[aria-current="true"] { background: var(--am-violet-50); }
.item__alias { font-weight: 800; color: var(--am-violet-600); font-size: 14px; word-break: break-all; }
.item__nombre { font-size: 13px; color: var(--am-neutral-600); }
.item__chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

/* Insignias */
.badge { height: 24px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge--sinpunto::before { display: none; }
.badge--violeta { background: var(--am-violet-50); color: var(--am-violet-700); }
.badge--cian { background: var(--am-info-bg); color: var(--am-info-text); }
.badge--ok { background: var(--am-success-bg); color: var(--am-success-text); }
.badge--pend { background: var(--am-warning-bg); color: var(--am-warning-text); }
.badge--error { background: var(--am-error-bg); color: var(--am-error-text); }
.badge--neutro { background: var(--am-neutral-50); color: var(--am-neutral-600); }

/* Detalle */
.cabeza { display: grid; gap: 10px; margin-bottom: 20px; }
.cabeza__alias { font-weight: 800; color: var(--am-violet-600); font-size: 14px; }
.cabeza h1 { font-size: 30px; line-height: 1.15; }
.cabeza p { margin: 0; color: var(--am-neutral-600); max-width: 72ch; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 4px 0 24px; }
.kpi { background: #fff; border: 1px solid var(--am-color-border-default); border-radius: 12px; padding: 14px 16px; display: grid; gap: 2px; }
.kpi__etiqueta { font-size: 13px; font-weight: 700; color: var(--am-neutral-600); }
.kpi__valor { font-family: var(--am-font-display); font-size: 22px; font-variant-numeric: tabular-nums; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--am-color-border-default); margin-bottom: 24px; }
.tab { height: 48px; padding: 0 16px; border: 0; background: transparent; font-weight: 700; color: var(--am-neutral-600); cursor: pointer; border-bottom: 3px solid transparent; }
.tab[aria-selected="true"] { color: var(--am-violet-600); font-weight: 800; border-bottom-color: var(--am-violet-600); }

.seccion { display: grid; gap: 12px; margin-bottom: 28px; }
.seccion h2 { font-size: 20px; }
.seccion > p { margin: 0; color: var(--am-neutral-600); }

.tabla-envoltura { overflow-x: auto; background: #fff; border: 1px solid var(--am-color-border-default); border-radius: 16px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { background: var(--am-neutral-50); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--am-neutral-600); text-align: left; padding: 12px 14px; }
td { padding: 12px 14px; border-top: 1px solid var(--am-color-border-default); vertical-align: top; }
td.campo { font-weight: 800; color: var(--am-violet-600); white-space: nowrap; }
td.regla { color: var(--am-neutral-600); }
.oblig { color: var(--am-error-strong); font-weight: 800; }

.dos { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.tarjeta { background: #fff; border: 1px solid var(--am-color-border-default); border-radius: 16px; padding: 20px; display: grid; gap: 16px; }
.tarjeta h3 { font-size: 18px; }
.fila { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }

/* Formularios */
.campo-form { display: grid; gap: 6px; }
.campo-form label, .campo-form .etiqueta { font-size: 14px; font-weight: 700; }
.campo-form small { font-size: 12px; color: var(--am-neutral-500); }
.campo-form input, .campo-form select, .campo-form textarea {
  width: 100%; min-height: 48px; padding: 0 14px; border: 1.5px solid var(--am-color-border-input); border-radius: 8px; background: #fff;
}
.campo-form textarea { padding: 12px 14px; min-height: 120px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.campo-form input:hover, .campo-form select:hover, .campo-form textarea:hover { border-color: var(--am-neutral-400); }
.campo-form input:focus, .campo-form select:focus, .campo-form textarea:focus { outline: none; border-color: var(--am-violet-600); box-shadow: 0 0 0 3px var(--am-violet-100); }
.campo-form [aria-invalid="true"] { border-color: var(--am-error-strong); }
.campo-form .error { color: var(--am-error-text); font-size: 12px; font-weight: 700; }
.casilla { display: flex; gap: 10px; align-items: center; min-height: 44px; font-weight: 700; }
.casilla input { width: 20px; height: 20px; accent-color: var(--am-violet-600); }

.boton { height: 44px; padding: 0 20px; border-radius: 8px; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; border: 0; }
.boton--primario { background: var(--am-violet-600); color: #fff; }
.boton--primario:hover { background: var(--am-violet-700); }
.boton--primario:active { background: var(--am-violet-800); }
.boton--primario[aria-busy="true"] { background: var(--am-violet-500); }
.boton--secundario { background: #fff; color: var(--am-violet-600); border: 1.5px solid var(--am-violet-600); }
.boton--secundario:hover { background: var(--am-violet-50); }
.boton--texto { background: transparent; color: var(--am-violet-600); }
.boton--texto:hover { background: var(--am-violet-50); }
.boton:disabled { background: var(--am-neutral-100); color: var(--am-neutral-400); border-color: var(--am-neutral-200); cursor: not-allowed; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid var(--am-violet-300); border-top-color: #fff; animation: girar .8s linear infinite; }
@keyframes girar { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.alerta { border-radius: 12px; padding: 16px; display: flex; gap: 12px; font-size: 14px; }
.alerta strong { display: block; font-weight: 800; }
.alerta--error { background: var(--am-error-bg); color: var(--am-error-text); }
.alerta--info { background: var(--am-info-bg); color: var(--am-info-text); }
.alerta--ok { background: var(--am-success-bg); color: var(--am-success-text); }
.alerta--pend { background: var(--am-warning-bg); color: var(--am-warning-text); }

pre.json { margin: 0; background: var(--am-neutral-900); color: var(--am-neutral-50); border-radius: 12px; padding: 16px; overflow-x: auto; line-height: 1.55; }
.resultado { display: grid; gap: 12px; }
.datos-res { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: 14px; }
.datos-res dt { font-weight: 700; color: var(--am-neutral-600); }
.datos-res dd { margin: 0; font-variant-numeric: tabular-nums; word-break: break-all; }

.historial { display: grid; gap: 6px; }
.historial button { display: flex; justify-content: space-between; gap: 12px; align-items: center; width: 100%; text-align: left; border: 1px solid var(--am-color-border-default); background: #fff; border-radius: 8px; padding: 8px 12px; cursor: pointer; min-height: 44px; }
.historial button:hover { background: var(--am-neutral-50); }

.vacio { max-width: 460px; margin: 10vh auto; text-align: center; display: grid; gap: 12px; justify-items: center; }
.vacio__icono { width: 96px; height: 96px; border-radius: 32px; background: var(--am-violet-50); color: var(--am-violet-600); display: grid; place-items: center; }
.vacio__icono svg { width: 40px; height: 40px; }
.vacio h1 { font-size: 30px; }
.vacio p { margin: 0; color: var(--am-neutral-600); }

.toast { position: fixed; right: 24px; bottom: 24px; background: var(--am-neutral-800); color: #fff; border-radius: 12px; padding: 12px 16px; box-shadow: var(--am-shadow-float); max-width: 420px; font-size: 15px; }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .lateral { border-right: 0; border-bottom: 1px solid var(--am-color-border-default); }
  .lista { max-height: 40vh; }
  .dos { grid-template-columns: minmax(0, 1fr); }
  .detalle { padding: 20px 16px 48px; }
  .barra__sub, .barra__identidad { display: none; }
}

/* Ingreso */
.ingreso { min-height: calc(100% - 60px); display: grid; place-items: center; padding: 24px 16px; }
.ingreso__tarjeta { width: 100%; max-width: 420px; padding: 28px; }
.ingreso__tarjeta h1 { font-size: 26px; }
.ingreso__tarjeta p { margin: 0; color: var(--am-neutral-600); }
.ingreso__icono { width: 48px; height: 48px; border-radius: 12px; background: var(--am-violet-50); color: var(--am-violet-600); display: grid; place-items: center; }
.ingreso__campos { display: grid; gap: 16px; }
.boton--ancho { width: 100%; justify-content: center; }
.boton--barra { height: 36px; background: var(--am-violet-700); color: #fff; padding: 0 14px; }
.boton--barra:hover { background: var(--am-violet-800); }

/* El resultado queda a la vista mientras se llena el formulario */
.dos > .resultado:last-child { position: sticky; top: 16px; }
@media (max-width: 900px) { .dos > .resultado:last-child { position: static; } }
