/*
 * Sistema de diseño — Plataforma de Agentes Workanda
 * Depende de tokens.css, que debe cargarse antes.
 *
 * Es el rediseño de 2026 (prototipo «Rediseño UX Workanda»): la misma marca que el
 * servidor de acceso —Quicksand y Fredoka One, botones en píldora, el primario
 * #b0012e— con una navegación lateral única, tarjetas de 16px casi sin borde y
 * pantallas que dicen primero qué necesita atención.
 *
 * Aquí viven los componentes comunes. Lo que sólo usa una pantalla va en
 * styles/pages/<zona>.css, que app.js importa después de esta hoja.
 *
 * Los nombres de clase anteriores al rediseño (.card__header, .badge, .table...)
 * se conservan con el aspecto nuevo: una pantalla aún sin migrar se ve coherente
 * con las migradas.
 */

/* ============================================================
   Base
   ============================================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  /* El prototipo usa el interlineado natural de Quicksand; los párrafos largos lo
     amplían a 1.55 donde hace falta (.fact__value, .prose). */
  line-height: 1.3;
  color: var(--text-primary);
  background: var(--surface-sunken);
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: var(--leading-tight);
  color: var(--text-primary);
}

h1 {
  font-size: 30px;
  color: var(--text-heading);
}
h2 {
  font-size: 17px;
}
h3 {
  font-size: 15px;
}
h4 {
  font-size: 14px;
}

p {
  margin: 0 0 var(--space-4);
}

a {
  color: var(--brand-primary);
  text-decoration: none;
}

a:hover {
  color: var(--brand-primary-dark);
}

button,
input,
select,
textarea {
  font-family: inherit;
}

code,
pre,
kbd,
.mono {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

:not(pre) > code {
  background: var(--neutral-100);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.86em;
  color: var(--neutral-600);
}

pre {
  margin: 0;
  background: var(--surface-code);
  color: var(--neutral-100);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  font: 12.5px/1.6 var(--font-mono);
  overflow-x: auto;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: 700 11px var(--font-sans);
  color: var(--text-muted);
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

hr {
  border: 0;
  height: 1px;
  background: var(--divider);
  margin: var(--space-4) 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

/* La franja de marca: arriba de la barra lateral y de las pantallas sin ella. */
.brand-strip {
  height: 4px;
  flex-shrink: 0;
  background: var(--brand-gradient);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  white-space: nowrap;
}

.brand:hover {
  color: var(--text-primary);
}

.brand img {
  height: 26px;
  width: auto;
  display: block;
}

.brand__app {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--text-secondary);
  border-left: 1px solid var(--border);
  padding-left: 10px;
}

/* Pie de las pantallas sueltas (entrar, vincular cuenta). */
.site-footer {
  flex-shrink: 0;
  padding: 18px var(--space-6);
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.site-footer a {
  font-weight: 700;
}

.site-footer__separator {
  margin: 0 6px;
}

/* ============================================================
   Estructura: barra lateral + zona principal
   ============================================================ */

.shell {
  display: flex;
  min-height: 100vh;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* El contenedor de casi todas las pantallas: 1160px centrados. */
.page {
  width: 100%;
  max-width: calc(var(--content-max) + 2 * var(--page-pad-x));
  margin: 0 auto;
  padding: 40px var(--page-pad-x) 72px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.page > * {
  min-width: 0;
}

/* Pantallas de lectura o de una sola columna (Estado del sistema, vinculaciones). */
.page--narrow {
  max-width: calc(960px + 2 * var(--page-pad-x));
}

.page--slim {
  max-width: calc(820px + 2 * var(--page-pad-x));
}

.page--loose {
  gap: 32px;
}

/* Sin contenedor: la pantalla gestiona su propio ancho (conversaciones). */
.main--bleed .page {
  max-width: none;
  padding: 0;
  gap: 0;
}

/* ---- Barra lateral ---- */

.sidebar {
  position: sticky;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border-subtle);
  z-index: 30;
}

.sidebar__brand {
  padding: 20px 20px 16px;
}

.sidebar__search {
  padding: 0 12px 12px;
}

.search-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-sunken);
  font: 500 13.5px var(--font-sans);
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
}

.search-trigger:hover {
  border-color: var(--border-strong);
  background: var(--surface);
}

.search-trigger span {
  flex: 1;
}

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  padding: 4px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-group__label {
  padding: 0 12px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-item {
  position: relative;
  line-height: 1.25;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--neutral-600);
  transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}

.nav-item:hover {
  background: var(--surface-hover);
  color: var(--brand-primary);
}

.nav-item[aria-current="page"] {
  font-weight: 700;
  color: var(--brand-primary);
  background: linear-gradient(90deg, var(--brand-primary-bg), var(--neutral-25));
}

/* La marca de la sección actual, pegada al borde de la columna. */
.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  width: 3px;
  height: 20px;
  margin-top: -10px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--brand-primary), var(--brand-orange));
}

.nav-item__icon {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
  opacity: 0.75;
}

.nav-item[aria-current="page"] .nav-item__icon {
  opacity: 1;
}

.nav-item__label {
  flex: 1;
  min-width: 0;
}

.nav-item__count {
  min-width: 20px;
  text-align: center;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: var(--brand-primary-bg);
  color: var(--brand-primary);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.nav-item[aria-current="page"] .nav-item__count {
  background: var(--brand-primary);
  color: #fff;
}

/* «Hay una respuesta nueva»: un punto, como en los chats de siempre. */
.nav-item__dot {
  width: 8px;
  height: 8px;
  margin-left: auto;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--brand-primary);
}

/* Usuario y su menú, al pie de la barra. */
.sidebar__user {
  position: relative;
  border-top: 1px solid var(--border-subtle);
  padding: 12px;
}

.user-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.user-button:hover,
.user-button[aria-expanded="true"] {
  background: var(--surface-sunken);
}

.user-button__text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.user-button__name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.user-button__role {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.sidebar__user .menu {
  left: 12px;
  right: 12px;
  bottom: 70px;
}

/* Botón de menú en pantallas estrechas. */
.mobile-bar {
  display: none;
}

/* ============================================================
   Menú desplegable (usuario, «más acciones»)
   ============================================================ */

.menu {
  position: absolute;
  z-index: 40;
  min-width: 200px;
  display: flex;
  flex-direction: column;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
}

.menu form {
  margin: 0;
  display: contents;
}

.menu__item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  font: 600 14px var(--font-sans);
  color: var(--text-primary);
  cursor: pointer;
}

.menu__item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.menu__item--danger,
.menu__item--danger:hover {
  color: var(--danger);
}

.menu__item--danger:hover {
  background: var(--danger-bg);
}

.menu__sep {
  height: 1px;
  background: var(--border-subtle);
  margin: 4px 6px;
}

/* <details class="dropdown"> abre un .menu sin JavaScript. */
.dropdown {
  position: relative;
}

.dropdown > summary {
  list-style: none;
}

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

.dropdown > .menu {
  top: calc(100% + 6px);
  right: 0;
}

/* ============================================================
   Buscador (⌘K)
   ============================================================ */

.palette {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 12vh;
  background: rgb(61 61 61 / 0.28);
}

.palette__box {
  width: min(600px, 92vw);
  background: var(--surface);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgb(61 61 61 / 0.25);
  overflow: hidden;
}

.palette__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.palette__input {
  flex: 1;
  border: 0;
  outline: 0;
  font: 500 16px var(--font-sans);
  color: var(--text-primary);
  background: transparent;
}

.palette__list {
  max-height: 380px;
  overflow-y: auto;
  padding: 8px;
}

.palette__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 14.5px;
  font-weight: 600;
}

.palette__item:hover,
.palette__item.is-selected {
  background: var(--brand-primary-bg);
  color: var(--brand-primary);
}

.palette__label {
  flex: 1;
}

.palette__kind {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.palette__empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ============================================================
   Avisos flotantes (los flash de Symfony)
   ============================================================ */

.toasts {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(420px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  animation: toast-in var(--duration) var(--ease);
}

.toast__dot {
  width: 8px;
  height: 8px;
  margin-top: 7px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  background: var(--brand-primary);
}

.toast--success .toast__dot { background: var(--success); }
.toast--warning .toast__dot { background: var(--warning); }
.toast--danger .toast__dot { background: var(--danger); }

/* El aviso lleva también .alert--<tipo> para que lo encuentre quien busca el aviso en la
   página (las pruebas, por ejemplo), pero se pinta como aviso flotante, no como banda. */
.toast.alert--success,
.toast.alert--info,
.toast.alert--warning,
.toast.alert--danger {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-primary);
}

.toast.toast--danger {
  border-color: var(--danger-border);
}

.toast__body {
  flex: 1;
  min-width: 0;
}

.toast__close {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ============================================================
   Cabecera de página
   ============================================================ */

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 0;
}

.breadcrumb a {
  color: var(--text-secondary);
}

.breadcrumb a:hover {
  color: var(--brand-primary);
}

.breadcrumb__sep {
  color: var(--text-muted);
}

.breadcrumb__current {
  color: var(--text-primary);
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.page-header__text {
  min-width: 0;
  flex: 1 1 420px;
}

.page-header__eyebrow {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.page-header__title {
  margin: 0;
  font-size: 30px;
}

.page-header__lead {
  margin: 6px 0 0;
  font-size: 15px;
  color: var(--text-secondary);
}

/* Entradillas largas junto a acciones a la derecha (Revisión, Contexto de empresa). */
.page-header__lead--short {
  max-width: 70ch;
}

.page-header__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Cabecera de ficha (agente, base de conocimiento...): banda blanca con pestañas. */
.hero {
  background: var(--surface);
  border-bottom: 1px solid var(--border-subtle);
}

.hero__inner {
  max-width: calc(var(--content-max) + 2 * var(--page-pad-x));
  margin: 0 auto;
  padding: 28px var(--page-pad-x) 0;
}

.hero__row {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.hero__text {
  flex: 1;
  min-width: 240px;
}

.hero__title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.hero__title {
  margin: 0;
  font-size: 28px;
}

.hero__lead {
  margin: 4px 0 0;
  font-size: 15px;
  color: var(--text-secondary);
}

.hero__actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.hero .tabs {
  margin-top: 22px;
  border-bottom: 0;
}

/* Título de sección dentro de una pantalla («Necesita atención 4 avisos»). */
.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.section-head__title {
  margin: 0;
  font-size: 19px;
}

.section-head__meta {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.section-head__action {
  margin-left: auto;
  font-size: 13.5px;
  font-weight: 700;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Etiqueta en versalitas sobre un dato («OBJETIVO», «POR QUÉ LO PROPONE»). */
.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ============================================================
   Botones
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border: 1px solid var(--brand-primary);
  border-radius: var(--radius-full);
  background: var(--brand-primary);
  color: #fff;
  font: 600 14px/1.4 var(--font-sans);
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease),
    border-color var(--duration-fast) var(--ease),
    color var(--duration-fast) var(--ease);
}

.btn:hover {
  color: #fff;
  background: var(--brand-primary-dark);
  border-color: var(--brand-primary-dark);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
}

/* Neutro: blanco con borde suave y texto oscuro («Nueva conversación», «Nueva base»). */
.btn--secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-primary);
}

.btn--secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

/* Contorno con texto de marca: la acción de una fila («Ver detalle», «Probar»). */
.btn--outline {
  background: var(--surface);
  border-color: var(--border);
  color: var(--brand-primary);
  font-weight: 700;
}

.btn--outline:hover:not(:disabled) {
  background: var(--brand-primary-bg);
  border-color: var(--brand-primary-bg-strong);
  color: var(--brand-primary);
}

/* Relleno rosa: la acción amable de una tarjeta («Conversar»). */
.btn--soft {
  background: var(--brand-primary-bg);
  border-color: var(--brand-primary-bg);
  color: var(--brand-primary);
  font-weight: 700;
}

.btn--soft:hover:not(:disabled) {
  background: var(--brand-primary-bg-strong);
  border-color: var(--brand-primary-bg-strong);
  color: var(--brand-primary);
}

/* Sin borde ni fondo, texto gris («Descartar cambios», «Cancelar»). */
.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: transparent;
  color: var(--text-primary);
}

/* Enlace con forma de botón: «Editar», «Ver todas». */
.btn--link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand-primary);
  font-weight: 700;
  font-size: 13.5px;
}

.btn--link:hover:not(:disabled) {
  background: transparent;
  color: var(--brand-primary-dark);
}

.btn--danger {
  background: var(--surface);
  border-color: var(--danger-button-border);
  color: var(--danger);
  font-weight: 700;
}

.btn--danger:hover:not(:disabled) {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}

.btn--danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.btn--danger-solid:hover:not(:disabled) {
  background: #8f1f2a;
  border-color: #8f1f2a;
  color: #fff;
}

.btn--sm {
  padding: 6px 14px;
  font-size: 13px;
}

.btn--lg {
  padding: 12px 22px;
  font-size: 15px;
}

/* Botón redondo con sólo un icono («…», plegar el panel). */
.btn--icon {
  width: 40px;
  height: 40px;
  padding: 0;
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-secondary);
}

.btn--icon:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--border);
  color: var(--text-primary);
}

.btn--icon.btn--sm {
  width: 32px;
  height: 32px;
}

.btn__icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.btn--block {
  width: 100%;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.btn-row--end {
  justify-content: flex-end;
}

form.inline {
  display: inline;
  margin: 0;
}

/* ============================================================
   Tarjetas
   ============================================================ */

.card {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}

/* Tarjeta que es en sí un enlace o tiene uno principal: se levanta al pasar. */
.card--interactive {
  transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
  color: inherit;
}

.card--interactive:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-hover);
  color: inherit;
}

.card--selected {
  border-color: var(--brand-primary);
}

/* Hueco para crear uno nuevo, al final de una rejilla de tarjetas. */
.card--add {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 190px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--brand-primary);
  font-weight: 700;
  font-size: 14.5px;
  background: transparent;
  box-shadow: none;
}

.card--add:hover {
  background: var(--surface);
  border-color: var(--brand-primary);
}

.card--add .card--add__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: grid;
  place-items: center;
  background: var(--brand-primary-bg);
}

.card__header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 18px 22px 10px;
}

.card__header--ruled {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--divider);
}

.card__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 17px;
  color: var(--text-primary);
}

.card__subtitle {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.card__header-actions,
.card__action {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
}

.card__body {
  padding: 22px;
}

.card__header + .card__body {
  padding-top: 8px;
}

.card__footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 12px 20px;
  border-top: 1px solid var(--divider);
}

/* Rejillas */
.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.grid--cards {
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
}

.grid--wide {
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}

/* Dos columnas que se apilan solas: la composición habitual de una ficha. */
.split {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  align-items: start;
}

/* Columna principal + lateral de 360-400px. */
.with-aside {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
  align-items: start;
}

.sticky-aside {
  position: sticky;
  top: 24px;
}

/* ============================================================
   Métricas
   ============================================================ */

.stats {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.stats--compact {
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 20px 22px;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  color: var(--text-primary);
}

a.stat:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
}

/* Las antiguas .card.stat no deben duplicar el borde. */
.card.stat {
  padding: 20px 22px;
}

.stat__label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
}

.stat__value {
  font-family: var(--font-display);
  font-size: 32px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--brand-magenta);
}

.stat__unit {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
}

.stat__meta,
.stat__hint {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.stat--sm {
  gap: 2px;
  padding: 16px 18px;
  border-radius: 14px;
  box-shadow: none;
}

.stat--sm .stat__label {
  font-size: 12.5px;
}

.stat--sm .stat__value {
  font-size: 24px;
  margin-top: 2px;
}

.stat--sm .stat__meta {
  font-size: 12px;
}

/* Barra de progreso: gasto, carga, parecido de una búsqueda. */
.meter {
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--neutral-100);
  overflow: hidden;
}

.meter--lg {
  height: 8px;
}

.meter--sm {
  height: 4px;
}

.meter__fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--brand-gradient-bar);
}

.meter__fill--danger {
  background: var(--brand-orange-dark);
}

.meter__fill--warning {
  background: #e0a63a;
}

/* ============================================================
   Filtros y pestañas
   ============================================================ */

/* Segmentado gris: filtros de un listado («Todos 7 · Listos 4 · …»). */
.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--neutral-100);
  border-radius: var(--radius-full);
}

.seg__item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border: 0;
  border-radius: var(--radius-full);
  background: transparent;
  font: 700 13px var(--font-sans);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}

.seg__item:hover {
  color: var(--brand-primary);
}

.seg__item[aria-current="true"],
.seg__item[aria-current="page"],
.seg__item[aria-pressed="true"],
.seg__item.is-active {
  background: var(--surface);
  color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
}

.seg__count {
  opacity: 0.6;
  font-variant-numeric: tabular-nums;
}

/* Pestañas subrayadas: apartados de una misma cosa (ficha, canales, coste). */
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border-subtle);
}

.tabs__item {
  display: inline-flex;
  align-items: center;
  padding: 11px 14px;
  border: 0;
  background: transparent;
  font: 700 14px var(--font-sans);
  white-space: nowrap;
  color: var(--text-secondary);
  cursor: pointer;
}

.tabs__item:hover {
  color: var(--brand-primary);
}

.tabs__item[aria-current="page"],
.tabs__item[aria-selected="true"],
.tabs__item.is-active {
  color: var(--brand-primary);
  box-shadow: inset 0 -2px 0 var(--brand-primary);
}

.tabs__count {
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: var(--brand-primary-bg);
  color: var(--brand-primary);
  font-size: 11px;
}

/* Fichas con contorno: filtros por tipo con su número («Memoria 4»). */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface);
  font: 600 14px var(--font-sans);
  color: var(--text-primary);
  cursor: pointer;
}

.chip:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.chip[aria-current="true"],
.chip[aria-pressed="true"],
.chip.is-active {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  background: var(--neutral-25);
}

.chip__count {
  min-width: 20px;
  padding: 0 7px;
  border-radius: var(--radius-full);
  background: var(--neutral-100);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  color: var(--text-secondary);
}

.chip.is-active .chip__count,
.chip[aria-current="true"] .chip__count,
.chip[aria-pressed="true"] .chip__count {
  background: var(--brand-primary-bg);
  color: var(--brand-primary);
}

/* Barra de herramientas de un listado: filtros a la izquierda, buscador a la derecha. */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar__end {
  margin-left: auto;
}

/* Buscador en píldora con lupa. */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  min-width: 260px;
  color: var(--text-muted);
}

.search:focus-within {
  border-color: var(--brand-primary);
  outline: 2px solid var(--focus-ring);
}

.search__input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  font: 500 14px var(--font-sans);
  color: var(--text-primary);
  background: transparent;
}

/* ============================================================
   Etiquetas, estados y avatares
   ============================================================ */

.tag,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: var(--neutral-100);
  color: var(--neutral-600);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}

.tag--outline {
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-weight: 600;
}

.tag--brand,
.badge--info,
.badge--brand {
  background: var(--brand-primary-bg);
  color: var(--brand-primary-dark);
}

.tag--neutral,
.badge--neutral {
  background: var(--neutral-100);
  color: var(--neutral-600);
}

.tag--success,
.badge--success {
  background: var(--success-bg);
  color: var(--success);
}

.tag--warning,
.badge--warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.tag--danger,
.badge--danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.tag--sm {
  padding: 1px 8px;
  font-size: 11px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Estado con punto: «● Listo», «● Parado». El color sale del modificador. */
.status {
  --status: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--status);
  white-space: nowrap;
}

.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--status);
  flex-shrink: 0;
}

.status--ok { --status: var(--success); }
.status--warning { --status: var(--warning); }
.status--alert { --status: var(--brand-orange-dark); }
.status--danger { --status: var(--danger); }
.status--busy { --status: var(--brand-primary); }
.status--off { --status: var(--text-muted); }

/* Variante en píldora, junto a un título («Soporte CPD ● Listo»). */
.status--pill {
  padding: 3px 11px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  background: var(--neutral-100);
}

.status--pill.status--ok { background: var(--success-bg); }
.status--pill.status--warning { background: var(--warning-bg); }
.status--pill.status--alert,
.status--pill.status--danger { background: var(--danger-bg); }
.status--pill.status--busy { background: var(--brand-primary-bg); }

/* Punto suelto, para leyendas y filas compactas. */
.dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  display: inline-block;
  background: var(--text-muted);
}

.dot--on { background: var(--success); }
.dot--off { background: var(--neutral-300); }
.dot--warn { background: var(--brand-orange-dark); }
.dot--error { background: var(--danger); }
.dot--busy { background: var(--brand-primary); }

/* Iniciales de un agente o una persona. */
.avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--brand-primary-bg);
  color: var(--brand-primary-dark);
  font-weight: 700;
  font-size: 15px;
  text-transform: uppercase;
}

.avatar--xs { width: 28px; height: 28px; border-radius: 9px; font-size: 11px; }
.avatar--sm { width: 32px; height: 32px; border-radius: 10px; font-size: 13px; }
.avatar--md { width: 38px; height: 38px; border-radius: 12px; font-size: 14px; }
.avatar--lg { width: 56px; height: 56px; border-radius: 18px; font-size: 19px; }

.avatar--round { border-radius: var(--radius-full); }
.avatar--brand { background: var(--brand-gradient-avatar); color: #fff; }

/* Icono en un cuadrado de color: avisos, herramientas, contextos. */
.icon-box {
  --icon-bg: var(--brand-primary-bg);
  --icon-fg: var(--brand-primary-dark);
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--icon-bg);
  color: var(--icon-fg);
}

.icon-box svg {
  width: 17px;
  height: 17px;
}

.icon-box--lg { width: 42px; height: 42px; border-radius: 12px; }
.icon-box--sm { width: 32px; height: 32px; border-radius: 10px; }
.icon-box--danger { --icon-bg: var(--danger-bg); --icon-fg: var(--danger); }
.icon-box--warning { --icon-bg: var(--warning-bg); --icon-fg: var(--warning); }
.icon-box--success { --icon-bg: var(--success-bg); --icon-fg: var(--success); }
.icon-box--muted { --icon-bg: var(--neutral-75); --icon-fg: var(--brand-primary-dark); }

.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ============================================================
   Listas
   ============================================================ */

/* Filas dentro de una tarjeta, con hover suave («Tus agentes»). */
.rows {
  display: flex;
  flex-direction: column;
  padding: 0 10px 10px;
}

.row-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 12px;
  border-radius: 12px;
  color: var(--text-primary);
  min-width: 0;
}

a.row-item:hover,
.row-item--hover:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.row-item__main {
  flex: 1;
  min-width: 0;
  color: var(--text-primary);
}

a.row-item__main:hover {
  color: var(--text-primary);
}

.row-item__title {
  font-weight: 700;
  font-size: 14.5px;
}

.row-item__meta {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Lista con separadores a lo ancho de la tarjeta («Necesita atención», tareas). */
.list {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.list__item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--divider);
  color: var(--text-primary);
  min-width: 0;
}

.list__item:last-child {
  border-bottom: 0;
}

a.list__item:hover,
.list__item--hover:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.list__main {
  flex: 1;
  min-width: 0;
}

.list__title {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-primary);
}

.list__text {
  margin-top: 2px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.list__meta {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.list__aside {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Cronología («Actividad reciente»). */
.feed {
  display: flex;
  flex-direction: column;
  padding: 4px 22px 18px;
}

.feed__item {
  display: flex;
  gap: 12px;
  padding: 9px 0;
}

.feed__dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--border-strong);
  margin-top: 7px;
  flex-shrink: 0;
}

.feed__text {
  font-size: 14px;
  color: var(--text-primary);
}

.feed__when {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
}

/* Lista de comprobación («Estado de la configuración»). */
.checklist {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: var(--text-primary);
}

a.check:hover {
  color: var(--text-primary);
}

a.check:hover .check__label {
  color: var(--brand-primary);
}

.check__icon {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--success-bg);
  color: var(--success);
}

.check__icon svg {
  width: 12px;
  height: 12px;
}

.check--warning .check__icon { background: var(--warning-bg); color: var(--warning); }
.check--danger .check__icon { background: var(--danger-bg); color: var(--danger); }
.check--todo .check__icon { background: var(--neutral-100); color: var(--text-muted); }

.check__label {
  display: block;
  font-size: 14px;
  font-weight: 700;
}

.check__text {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Texto corrido: descripciones largas, respuestas, explicaciones. */
.prose {
  font-size: 14.5px;
  line-height: 1.55;
}

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

/* Bloque de dato con su etiqueta en versalitas. */
.fact + .fact {
  margin-top: 14px;
}

.fact__value {
  margin: 4px 0 0;
  font-size: 14.5px;
  line-height: 1.55;
}

/* Listas de descripción (vistas de detalle). */
.dl {
  display: grid;
  grid-template-columns: minmax(140px, auto) 1fr;
  gap: 10px 20px;
  margin: 0;
  font-size: 14px;
}

.dl dt {
  font-weight: 700;
  color: var(--text-secondary);
}

.dl dd {
  margin: 0;
  min-width: 0;
}

/* ============================================================
   Tablas
   ============================================================ */

.table-wrap {
  /* relative: los .sr-only de las cabeceras quedan dentro de la caja con scroll y no
     ensanchan la página en el móvil. */
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-xs);
}

.card > .table-wrap {
  border: 0;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: none;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  padding: 14px 20px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--divider);
}

.table thead th {
  padding-top: 12px;
  padding-bottom: 12px;
  background: var(--neutral-25);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover td {
  background: var(--neutral-25);
}

.table .table__num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table .table__actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.table__primary {
  font-weight: 700;
  color: var(--text-primary);
}

a.table__primary:hover {
  color: var(--brand-primary);
}

.table__secondary {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.table__empty {
  color: var(--border-strong);
}

/* ============================================================
   Formularios
   ============================================================ */

.form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field + .field {
  margin-top: 18px;
}

.form > .field + .field,
.form-grid .field + .field,
.field-row .field + .field {
  margin-top: 0;
}

.field__label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.field__required {
  color: var(--danger);
}

.field__hint {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.field__error {
  font-size: 13px;
  font-weight: 600;
  color: var(--danger);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  font: 500 14.5px/1.5 var(--font-sans);
  color: var(--text-primary);
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--border-strong);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 0;
  border-color: var(--brand-primary);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-muted);
}

.input[aria-invalid="true"],
.select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.input--sm,
.select--sm {
  padding: 7px 12px;
  font-size: 13.5px;
}

.input--pill,
.select--pill {
  border-radius: var(--radius-full);
}

.textarea {
  min-height: 96px;
  resize: vertical;
}

.textarea--code {
  font: 13px/1.75 var(--font-mono);
  min-height: 180px;
}

.select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%233d3d3d' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' d='M4.5 6.5 8 10l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--brand-primary);
  width: 16px;
  height: 16px;
}

/* Casilla o radio con su texto, en una caja que se puede pulsar entera. */
.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
}

.option:hover {
  border-color: var(--border);
}

.option:has(input:checked) {
  border-color: var(--brand-primary);
  background: var(--neutral-25);
}

.option input {
  margin-top: 3px;
  flex-shrink: 0;
}

.option__label {
  display: block;
  font-size: 14px;
  font-weight: 700;
}

.option__hint {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
}

.options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.options--grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

/* Fila de campos que se apila sola en pantallas estrechas */
.field-row,
.form-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.form-actions--start {
  justify-content: flex-start;
}

/* Barra de guardar pegada al fondo en formularios largos. */
.form-footer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0;
  background: linear-gradient(to bottom, rgb(250 247 247 / 0), var(--surface-sunken) 30%);
}

.form-footer__note {
  margin-right: auto;
  font-size: 13.5px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Interruptor */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.switch__input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch__track {
  width: 36px;
  height: 20px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--neutral-300);
  transition: background var(--duration) var(--ease);
  position: relative;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: #fff;
  box-shadow: 0 1px 2px rgb(61 61 61 / 0.2);
  transition: transform var(--duration) var(--ease);
}

.switch__input:checked + .switch__track {
  background: var(--brand-primary);
}

.switch__input:checked + .switch__track::after {
  transform: translateX(16px);
}

.switch__input:focus-visible + .switch__track {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Zona de soltar ficheros. */
.dropzone {
  display: block;
  padding: 22px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 14px;
  background: var(--neutral-25);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease);
}

.dropzone:hover,
.dropzone.is-over {
  border-color: var(--brand-primary);
  background: var(--brand-primary-bg);
}

.dropzone__title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.dropzone__hint {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ============================================================
   Avisos dentro de la página
   ============================================================ */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
}

.alert + .alert {
  margin-top: 12px;
}

.alert--success {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success);
}
.alert--warning {
  background: var(--warning-bg);
  border-color: var(--warning-border);
  color: var(--warning);
}
.alert--danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}
.alert--info {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info);
}

.alert__body {
  flex: 1;
  min-width: 0;
}

.alert__title {
  font-weight: 700;
  margin-bottom: 2px;
}

.alert__actions {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  align-self: center;
}

.alert .btn--outline,
.alert .btn--secondary {
  background: var(--surface);
}

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

/* Nota al pie de una pantalla («Probar no gasta: …»). */
.footnote {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
}

/* Bloque de explicación en una tarjeta blanca («De instrucciones. …»). */
.explainer {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  padding: 20px 22px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.explainer strong {
  color: var(--text-primary);
}

/* ============================================================
   Estado vacío
   ============================================================ */

.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-secondary);
}

.empty__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.empty__text {
  margin: 6px auto 18px;
  max-width: 48ch;
  font-size: 14px;
  color: var(--text-secondary);
}

/* ============================================================
   Paneles superpuestos
   ============================================================ */

/* Panel lateral (detalle de tarea, edición de una skill). Es un <dialog>. */
.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  margin: 0 0 0 auto;
  width: min(560px, 100vw);
  max-width: 100vw;
  height: 100vh;
  max-height: 100vh;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--border-subtle);
  background: var(--surface);
  box-shadow: -16px 0 40px rgb(61 61 61 / 0.12);
  overflow-y: auto;
}

.drawer::backdrop,
.modal::backdrop {
  background: rgb(61 61 61 / 0.28);
}

.drawer__head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 22px 24px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
}

.drawer__title {
  flex: 1;
  margin: 0;
  font-size: 19px;
}

.drawer__body {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal {
  width: min(520px, 92vw);
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgb(61 61 61 / 0.25);
}

.modal__body {
  padding: 24px;
}

.modal__title {
  margin: 0 0 6px;
  font-size: 19px;
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 24px 24px;
}

/* Bloque plegable con flecha (herramientas, servicios). */
.disclosure > summary {
  list-style: none;
  cursor: pointer;
}

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

.disclosure__chevron {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  transition: transform var(--duration) var(--ease);
  flex-shrink: 0;
}

.disclosure[open] > summary .disclosure__chevron {
  transform: rotate(180deg);
}

/* Comando para copiar («docker compose up -d queue  [Copiar]»). */
.command {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-code);
  color: #fff;
  font: 13px var(--font-mono);
}

.command code {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  white-space: pre;
  background: transparent;
  color: inherit;
  padding: 0;
}

.command .btn {
  background: #fff;
  border-color: #fff;
  color: var(--text-primary);
  font-family: var(--font-sans);
}

/* Valor de código en una caja clara (URL, clave enmascarada). */
.code-box {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-sunken);
  font: 700 13px var(--font-mono);
  color: var(--text-primary);
  overflow-x: auto;
  white-space: nowrap;
}

/* ============================================================
   Identificarse y pantallas sueltas
   ============================================================ */

.standalone {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.standalone__main {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 40px 16px;
}

.login {
  width: 100%;
  max-width: 420px;
}

.login__panel {
  padding: 40px 36px 36px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  box-shadow: 0 12px 40px rgb(61 61 61 / 0.08);
}

.login__logo {
  height: 34px;
  width: auto;
}

.login__heading {
  margin: 18px 0 6px;
  font-size: 26px;
  color: var(--text-heading);
}

.login__lead {
  margin: 0 0 24px;
  font-size: 15px;
  color: var(--text-secondary);
}

.login__panel .alert {
  margin-bottom: 16px;
  text-align: left;
}

.login__note {
  margin: 18px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ============================================================
   Utilidades mínimas
   ============================================================ */

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stack--sm {
  gap: 8px;
}

.stack--lg {
  gap: 20px;
}

.stack--xl {
  gap: 32px;
}

/* Las antiguas .stack basadas en margen: que no sumen el hueco dos veces. */
.stack > * + * {
  margin-top: 0;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.row--wrap {
  flex-wrap: wrap;
}

.row--between {
  justify-content: space-between;
}

.row--top {
  align-items: flex-start;
}

.grow {
  flex: 1;
  min-width: 0;
}

.ml-auto {
  margin-left: auto;
}

.text-secondary {
  color: var(--text-secondary);
}

.text-muted {
  color: var(--text-muted);
}

.text-brand {
  color: var(--brand-primary);
}

.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

.text-sm {
  font-size: 13.5px;
}

.text-xs {
  font-size: 12.5px;
}

.text-strong {
  font-weight: 700;
}

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

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.m-0 {
  margin: 0;
}

/* ============================================================
   Pantallas estrechas
   ============================================================ */

@media (max-width: 1100px) {
  :root {
    --page-pad-x: 28px;
  }

  .with-aside {
    grid-template-columns: minmax(0, 1fr);
  }

  .sticky-aside {
    position: static;
  }
}

@media (max-width: 900px) {
  :root {
    --page-pad-x: 16px;
  }

  .shell {
    flex-direction: column;
  }

  /* La barra lateral se convierte en un panel que se abre desde la barra superior. */
  .mobile-bar {
    position: sticky;
    top: 0;
    z-index: 35;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-subtle);
  }

  .mobile-bar__toggle {
    margin-left: auto;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    transition: transform var(--duration) var(--ease);
    box-shadow: var(--shadow-lg);
  }

  .shell.is-nav-open .sidebar {
    transform: none;
  }

  .page {
    padding-top: 24px;
    padding-bottom: 48px;
  }

  .page-header__title,
  h1 {
    font-size: 24px;
  }

  .hero__title {
    font-size: 24px;
  }

  .search {
    min-width: 0;
    flex: 1 1 100%;
  }

  .toolbar__end {
    margin-left: 0;
    flex: 1 1 100%;
  }

  .list__item {
    flex-wrap: wrap;
  }

  .toasts {
    right: 16px;
    bottom: 16px;
  }

  /* Por debajo de 16px Safari en iOS hace zoom al enfocar una caja. */
  .input,
  .select,
  .textarea,
  .search__input {
    font-size: 16px;
  }
}

/* ------------------------------------------------------------------------------------
   Model picker (ModelPickerType + model_picker_controller.js): the agent's model chosen
   from the connection's catalog, with an icon per capability. Shared by the agent page,
   the wizard and the Capacidades tab, so it lives here and not in a page sheet.
   ------------------------------------------------------------------------------------ */
.model-picker {
  position: relative;
  display: grid;
  gap: 6px;
}

.model-picker__control {
  position: relative;
}

.model-picker.is-enhanced .model-picker__control .input {
  padding-right: 40px;
}

.model-picker__toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  transform: translateY(-50%);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.model-picker__toggle:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.model-picker__popup {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 22rem;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
}

.model-picker__group {
  padding: 8px 10px 4px;
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
}

.model-picker__option {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.model-picker__option[aria-selected="true"],
.model-picker__option:hover {
  background: var(--surface-hover);
}

.model-picker__option.is-current .model-picker__name::after {
  content: " ✓";
  color: var(--brand-primary);
}

.model-picker__option.is-limited {
  opacity: 0.6;
}

.model-picker__line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 8px;
  min-width: 0;
}

.model-picker__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

.model-picker__id {
  font: 12px var(--font-mono);
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.model-picker__meta {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.model-picker__tag {
  padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--warning-bg);
  color: var(--warning);
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
}

.model-picker__more {
  padding: 8px 10px;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.model-picker__summary:empty,
.model-picker__status:empty {
  display: none;
}

.model-picker__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.model-picker__summary.is-warning {
  color: var(--warning);
}

.model-picker__status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.model-picker__refresh {
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand-primary);
  font: inherit;
  font-weight: var(--weight-bold);
  cursor: pointer;
}

.model-picker__refresh:hover {
  text-decoration: underline;
}

/* One capability: icon in a soft chip, the label in its `title` and for screen readers. */
.cap-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 3px;
}

.cap-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  background: var(--brand-primary-bg);
  color: var(--brand-primary);
  flex-shrink: 0;
}

.cap-icon--unknown {
  background: var(--surface-sunken);
  color: var(--text-muted);
}

.model-legend__summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--text-secondary);
}

.model-legend__list {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.model-legend__item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

/* ============================================================
   Avisos (/avisos)
   ============================================================ */

.notification-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.notification-item + .notification-item {
  border-top: 1px solid var(--border-subtle);
}

.notification-item__link {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  color: var(--text-primary);
}

.notification-item__link:hover {
  background: var(--neutral-25, var(--brand-primary-bg));
}

.notification-item__icon {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--text-muted);
}

.notification-item__text {
  flex: 1;
  min-width: 0;
}

.notification-item__title {
  display: block;
  font-weight: 600;
}

.notification-item.is-unread .notification-item__title {
  font-weight: 700;
}

.notification-item__body {
  display: block;
  margin-top: 2px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.notification-item__when {
  flex-shrink: 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.notification-item .nav-item__dot {
  margin: 6px 0 0;
}

/* A toast that leads somewhere (a notice pushed by the realtime channel). */
.toast__link {
  font-weight: 700;
  color: inherit;
}
