/* Estilos base y componentes compartidos por las páginas del operador. Sólo usa tokens de tokens.css.
   Referencia: Siklops · Anexo de interfaces 2026 (secciones entre paréntesis). */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--text-md);
  line-height: 1.5;
}

/* Pie con el logo de Siklops: chico y tenue, siempre al final de la página (el contenido empuja el pie hacia abajo). */
body.has-footer {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body.has-footer > .app-main {
  flex: 1 0 auto;
  width: 100%;
  box-sizing: border-box; /* en columna flex, el margen automático achicaría el contenido */
}
.app-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end; /* a la derecha, alineado con el borde del contenido */
  gap: var(--space-2);
  padding: var(--space-5) var(--space-6) var(--space-6);
  color: var(--ink-muted);
  font-size: var(--text-xs);
  letter-spacing: 0.02em;
  opacity: 0.75;
}
.app-footer .siklops-logo {
  height: 24px; /* el logo incluye su área de resguardo: a esta altura «SIKLOPS» se lee */
  width: auto;
}

/* Mientras se carga la traducción no se muestra la página (boot.js la libera a los 2 s si algo falla). */
.i18n-pending body {
  visibility: hidden;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Foco (8): anillo de 3 px separado 3 px. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

a {
  color: inherit;
}

.muted,
.help {
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

/* Títulos grandes en Figtree 650 con interletrado de −1 %; los menores en Figtree SemiBold (4). */
.display-title {
  font-family: var(--font-display);
  font-weight: var(--heading-weight);
  letter-spacing: var(--heading-tracking);
}

/* ---------- Logos según el tema ---------- */
.logo--on-light {
  display: none;
}
[data-theme='paper'] .logo--on-dark {
  display: none;
}
[data-theme='paper'] .logo--on-light {
  display: block;
}

/* ---------- Encabezado y navegación (11): índigo, ítem activo blanco SemiBold con subrayado teal claro ---------- */
.app-header {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  min-height: 64.8px;
  padding: var(--space-3) var(--space-6);
  background: var(--surface-sector);
  border-bottom: 1px solid var(--divider-soft);
}
.app-header .logo-link {
  flex: none;
  /* Flex y no block: la imagen en línea dejaba debajo el espacio de los descendentes y el logo quedaba alto. */
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
}
/* Logo de Action Wall con SIKLOPS debajo (a pedido, aunque mida menos de los 190 px que recomienda el manual). */
.app-header .logo {
  height: 27px;
  width: auto;
}
.app-header .spacer {
  flex: 1;
}
.app-nav {
  display: flex;
  gap: var(--space-2);
}
.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 39.6px;
  padding: 0 var(--space-3);
  border-bottom: 3px solid transparent;
  color: var(--ink-soft);
  text-decoration: none;
  white-space: nowrap;
}
.nav-link:hover {
  color: var(--ink);
  background: var(--hover-bg);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.nav-link[aria-current='page'] {
  color: var(--ink);
  border-bottom-color: var(--accent-text);
  font-weight: 600;
}
.account-btn {
  min-width: 0;
  text-decoration: none;
}
.account-btn .user-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 198px;
}
.app-header .btn {
  flex: none;
}

/* ---------- Contenido ---------- */
.app-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--space-6);
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.page-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-h2);
  line-height: 36px;
  font-weight: var(--heading-weight);
  letter-spacing: var(--heading-tracking);
}

/* ---------- Tarjetas (12): pizarra noche, radio 12, borde blanco 6 % ---------- */
.card {
  background: var(--surface-raised);
  border: 1px solid var(--divider-soft);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.card h2 {
  margin: 0 0 var(--space-3);
  font-size: var(--text-h3);
  line-height: 28.8px;
  font-weight: 600;
}

/* ---------- Campos (9): etiqueta arriba, fondo abismo, borde acero, foco teal claro con halo ---------- */
.field {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}
.field > label {
  font-weight: 600;
}
.field input:not([type='checkbox']):not([type='radio']),
.field select {
  height: 43.2px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  color: var(--ink);
  font: inherit;
  width: 100%;
}
.field select {
  cursor: pointer;
}
.field input:not([type='checkbox']):not([type='radio']):focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  outline: none;
  border: 2px solid var(--accent-text);
  box-shadow: 0 0 0 3.6px var(--focus-halo);
}
.field input:disabled,
.field select:disabled {
  background: var(--disabled-bg);
  border-color: var(--divider);
  color: var(--disabled-ink);
}
.field .help {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}
.field--inline {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.field--inline > label {
  font-weight: 400;
}

/* Interruptor (10): pista teal con perilla negra (en papel, teal oscuro con perilla blanca); apagado, borde y perilla acero. */
.switch {
  appearance: none;
  flex: none;
  width: 43.2px;
  height: 25.2px;
  margin: 7.2px 0;
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  background: transparent;
  position: relative;
  cursor: pointer;
  transition: background-color var(--motion);
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16.2px;
  height: 16.2px;
  border-radius: 50%;
  background: var(--border);
  transition: transform var(--motion);
}
.switch:checked {
  background: var(--control);
  border-color: var(--control);
}
.switch:checked::after {
  background: var(--on-control);
  transform: translateX(18px);
}
.switch:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
input[type='checkbox']:not(.switch),
input[type='radio'] {
  accent-color: var(--control);
}

/* ---------- Botones (8): alto 48 (40 compacto), radio 8, Figtree SemiBold ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 43.2px;
  padding: 0 var(--space-5);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--motion), border-color var(--motion), color var(--motion);
}
.btn svg {
  flex: none;
  width: 18px;
  height: 18px;
}
.btn--compact {
  min-height: 36px;
  padding: 0 var(--space-4);
}
.btn--block {
  width: 100%;
}
.btn--primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn--primary:hover {
  background: var(--accent-hover);
}
.btn--primary:active {
  background: var(--accent-pressed);
  color: var(--on-accent-pressed);
}
.btn--secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--border);
}
.btn--text {
  background: transparent;
  color: var(--ink);
  text-decoration: underline;
}
.btn--secondary:hover,
.btn--text:hover {
  background: var(--hover-bg);
}
.btn--secondary:active,
.btn--text:active {
  background: var(--pressed-bg);
}
.btn--danger {
  background: var(--danger);
  color: var(--on-danger);
}
.btn--danger:hover {
  background: var(--danger-hover);
}
.btn--danger:active {
  background: var(--danger-pressed);
  color: var(--white);
}
.btn:disabled {
  background: var(--disabled-bg);
  border-color: transparent;
  color: var(--disabled-ink);
  cursor: not-allowed;
}
.btn--secondary:disabled {
  background: transparent;
  border-color: var(--divider);
}
.btn--text:disabled {
  background: transparent;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 39.6px;
  height: 39.6px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--hover-bg);
}
.icon-btn svg {
  width: 18px;
  height: 18px;
}

/* ---------- Estados (3): fondo al 12 %, borde 1 px al 55 %, ícono y palabra en su color ---------- */
.banner,
.toast,
.tag,
.field-error {
  --tone: var(--info);
}
.banner--success, .toast--success, .tag--success { --tone: var(--success); }
.banner--error, .toast--error, .tag--error, .field-error { --tone: var(--error); }
.banner--warning, .toast--warning, .tag--warning { --tone: var(--warning); }
.banner--info, .toast--info, .tag--info { --tone: var(--info); }

.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-5);
  border: 1px solid color-mix(in srgb, var(--tone) 55%, transparent);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--tone) 12%, transparent);
  color: var(--ink);
}
.banner svg {
  flex: none;
  width: 21.6px;
  height: 21.6px;
  color: var(--tone);
}
.banner p {
  margin: 0;
}
.banner p > strong:first-child {
  color: var(--tone);
  font-weight: 600;
}
.banner .btn--secondary,
.banner .btn--text {
  margin-top: var(--space-2);
}

/* ---------- Etiquetas (12): 12 px, mayúsculas, SemiBold, radio 4 ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--tone) 14%, transparent);
  color: var(--tone);
  font-size: var(--text-xs);
  line-height: 18px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}
.tag svg {
  width: 14.4px;
  height: 14.4px;
}
/* En pausa / sin pantalla: borde acero, texto bruma. */
.tag--neutral {
  background: transparent;
  color: var(--ink-soft);
  box-shadow: inset 0 0 0 1px var(--steel);
}
/* En vivo: teal oscuro con texto blanco. */
.tag--accent {
  background: var(--accent);
  color: var(--on-accent);
}

/* ---------- Tablas ---------- */
.table-wrap {
  position: relative; /* contiene los rótulos ocultos (.visually-hidden, absolutos): si no, ensanchan la página en el celular */
  overflow-x: auto;
  border: 1px solid var(--divider-soft);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th {
  font-size: var(--text-xs);
  line-height: 14.4px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: left;
  color: var(--ink-muted);
  padding: var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--divider);
  white-space: nowrap;
}
.table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
}
.table td:first-child {
  min-width: 162px;
}
.table tr:last-child td {
  border-bottom: 0;
}
.table .tag-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1);
}
.table .actions {
  display: flex;
  flex-wrap: wrap; /* si no entran en una línea, los botones bajan en vez de forzar el desplazamiento horizontal */
  gap: var(--space-2);
  justify-content: flex-end;
}
.table .actions .btn,
.table .nowrap {
  white-space: nowrap;
}
.table .cell-sub {
  display: block;
  font-size: var(--text-sm);
  color: var(--ink-muted);
}
.table tr.is-inactive td:not(.col-actions) {
  opacity: 0.6;
}

/* ---------- Diálogos (13): máx. 560 px, radio 12, nivel 3, velo negro al 70 % ---------- */
.dialog {
  width: min(504px, calc(100vw - 28.8px));
  max-height: calc(100vh - 28.8px);
  padding: var(--space-5);
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  color: var(--ink);
  box-shadow: var(--shadow-dialog);
}
.dialog::backdrop {
  background: var(--veil);
}
.dialog h2 {
  margin: 0 0 var(--space-4);
  font-size: var(--text-h3);
  line-height: 28.8px;
  font-weight: 600;
}
.dialog h3 {
  margin: 0 0 var(--space-4);
  font-size: var(--text-lg);
  font-weight: 600;
}
.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}
.dialog-header h2 {
  margin-bottom: var(--space-2);
}
.dialog-section {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--divider);
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-5);
}
.secret {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--input-bg);
  font-size: var(--text-h4);
  letter-spacing: 0.08em;
  user-select: all;
}
.secret code {
  flex: 1;
  font-family: var(--font-mono);
}

/* ---------- Notificaciones breves (13): abajo, 5 s ---------- */
.toast-region {
  position: fixed;
  left: var(--space-5);
  bottom: var(--space-5);
  display: grid;
  gap: var(--space-3);
  z-index: 1000;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: 378px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid color-mix(in srgb, var(--tone) 55%, transparent);
  border-left: 3.6px solid var(--tone);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--ink);
  box-shadow: var(--shadow-raised);
  animation: toast-in var(--motion);
}
.toast svg {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--tone);
}
.toast p {
  margin: 0;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(7.2px);
  }
}

/* ---------- Responsive (5) ---------- */
@media (max-width: 767px) {
  .app-header {
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
  }
  .app-header .logo {
    height: 23px;
  }
  .app-nav {
    order: 10;
    width: 100%;
    overflow-x: auto;
  }
  .app-main {
    padding: var(--space-5) var(--space-4);
  }
  .toast-region {
    left: var(--space-4);
    right: var(--space-4);
    justify-items: center;
  }
}
@media (max-width: 479px) {
  /* Sólo ícono a la vista; el texto sigue disponible para lectores de pantalla. */
  .account-btn .user-name,
  .app-header .btn-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* Teléfono: el menú principal entra completo (sin desplazarse), con letra y márgenes más chicos. */
@media (max-width: 480px) {
  .app-nav {
    gap: 0;
    justify-content: space-between;
  }
  .nav-link {
    padding: 0 var(--space-2);
    font-size: 12.6px;
  }
}
@media (max-width: 340px) {
  .nav-link {
    padding: 0 5.4px;
    font-size: 11.7px;
  }
}

/* Aviso de respaldo para los administradores, debajo del encabezado de cualquier página. */
.backup-alert {
  margin-bottom: var(--space-5);
}
.backup-alert p {
  flex: 1;
}
.backup-alert a {
  color: inherit;
  font-weight: 600;
}
