/* NeuroForge: tema compartido.
   Tokens = mismos valores que assets/tw-config.js. Úsalo en TODAS las páginas:
   <link rel="stylesheet" href="/assets/nf-theme.css">
   Las páginas sin Tailwind usan las clases .nf-*; las que usan Tailwind solo
   aprovechan la base (fondo, tipografía, foco, toasts, badge de conexión). */
:root {
  --nf-primary: #ecb2ff;
  --nf-primary-strong: #bd00ff;
  --nf-on-primary: #520071;
  --nf-secondary: #00eefc;
  --nf-secondary-soft: #d3fbff;
  --nf-tertiary: #884fff;
  --nf-bg: #14121b;
  --nf-surface-lowest: #0f0d16;
  --nf-surface-low: #1c1a24;
  --nf-surface: #211e28;
  --nf-surface-high: #2b2933;
  --nf-surface-variant: #36333e;
  --nf-text: #e6e0ee;
  --nf-text-muted: #d4c0d7;
  --nf-outline: #9d8ba0;
  --nf-outline-soft: #4d4354;
  --nf-error: #ffb4ab;
  --nf-success: #4ade80;
  --nf-warning: #fbbf24;
  --nf-font-body: 'Hanken Grotesk', system-ui, sans-serif;
  --nf-font-display: 'Sora', system-ui, sans-serif;
  --nf-font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --nf-radius: 12px;
  --nf-radius-sm: 8px;
  --nf-glow: 0 0 24px rgba(189, 0, 255, .25);
  --nf-gutter: 16px;
}
@media (min-width: 768px) { :root { --nf-gutter: 32px; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--nf-bg);
  color: var(--nf-text);
  font-family: var(--nf-font-body);
  line-height: 1.5;
  overflow-x: hidden;
}
img, video { max-width: 100%; }
:focus-visible { outline: 2px solid var(--nf-secondary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
.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; }

/* ---------- Navegación común ---------- */
.nf-nav {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
  padding: 12px var(--nf-gutter);
  background: rgba(15, 13, 22, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--nf-outline-soft);
}
.nf-logo {
  font-family: var(--nf-font-display); font-weight: 800; letter-spacing: .02em;
  color: var(--nf-primary); text-decoration: none; font-size: 20px;
  text-shadow: 0 0 12px rgba(189, 0, 255, .5);
}
.nf-nav-links { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.nf-nav-links a {
  font-family: var(--nf-font-mono); font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--nf-text-muted); text-decoration: none;
  padding: 10px 12px; border-radius: var(--nf-radius-sm); min-height: 40px; display: inline-flex; align-items: center;
}
.nf-nav-links a:hover, .nf-nav-links a[aria-current="page"] { color: var(--nf-secondary); background: rgba(0, 238, 252, .08); }

/* ---------- Layout ---------- */
.nf-container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 24px var(--nf-gutter); }
.nf-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }

/* ---------- Tipografía ---------- */
.nf-h1 { font-family: var(--nf-font-display); font-weight: 800; font-size: clamp(28px, 6vw, 48px); line-height: 1.15; letter-spacing: -.02em; margin: 0 0 12px; }
.nf-h2 { font-family: var(--nf-font-display); font-weight: 600; font-size: clamp(20px, 4vw, 24px); line-height: 1.3; margin: 0 0 8px; }
.nf-label { font-family: var(--nf-font-mono); font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--nf-text-muted); }
.nf-muted { color: var(--nf-text-muted); }

/* ---------- Componentes ---------- */
.nf-card {
  background: var(--nf-surface); border: 1px solid var(--nf-outline-soft);
  border-radius: var(--nf-radius); padding: 20px;
}
.nf-card-link { cursor: pointer; transition: border-color .2s, transform .2s, box-shadow .2s; color: inherit; text-decoration: none; display: block; }
.nf-card-link:hover, .nf-card-link:focus-visible { border-color: var(--nf-primary); box-shadow: var(--nf-glow); transform: translateY(-2px); }

.nf-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px;
  font-family: var(--nf-font-mono); font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  border-radius: var(--nf-radius-sm); border: 1px solid transparent; cursor: pointer; text-decoration: none;
  background: var(--nf-primary-strong); color: #fff; transition: filter .15s, box-shadow .15s;
}
.nf-btn:hover { filter: brightness(1.1); box-shadow: var(--nf-glow); }
.nf-btn:disabled, .nf-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; filter: none; box-shadow: none; }
.nf-btn-secondary { background: transparent; color: var(--nf-secondary); border-color: var(--nf-secondary); }
.nf-btn-ghost { background: transparent; color: var(--nf-text-muted); border-color: var(--nf-outline-soft); }
.nf-btn-danger { background: transparent; color: var(--nf-error); border-color: var(--nf-error); }

.nf-input, .nf-select, .nf-textarea {
  width: 100%; min-width: 0; min-height: 44px; padding: 10px 14px;
  background: var(--nf-surface-lowest); color: var(--nf-text);
  border: 1px solid var(--nf-outline-soft); border-radius: var(--nf-radius-sm);
  font: inherit;
}
.nf-input:focus, .nf-select:focus, .nf-textarea:focus { border-color: var(--nf-secondary); outline: none; box-shadow: 0 0 0 3px rgba(0, 238, 252, .15); }
.nf-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }

.nf-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-family: var(--nf-font-mono); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; border: 1px solid var(--nf-outline-soft); color: var(--nf-text-muted); }
.nf-badge-on { border-color: var(--nf-secondary); color: var(--nf-secondary); }

.nf-table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.nf-table { width: 100%; border-collapse: collapse; }
.nf-table th, .nf-table td { padding: 12px; text-align: left; border-bottom: 1px solid var(--nf-outline-soft); }
.nf-table th { font-family: var(--nf-font-mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--nf-text-muted); }

.nf-progress { height: 8px; background: var(--nf-surface-high); border-radius: 999px; overflow: hidden; }
.nf-progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--nf-primary-strong), var(--nf-secondary)); }

/* Estados: carga / vacío / error */
.nf-state { padding: 32px 16px; text-align: center; color: var(--nf-text-muted); }
.nf-state-error { color: var(--nf-error); }
.nf-spinner { width: 28px; height: 28px; border: 3px solid var(--nf-outline-soft); border-top-color: var(--nf-secondary); border-radius: 50%; animation: nf-spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes nf-spin { to { transform: rotate(360deg); } }

/* Badge de conexión (NF.poll) */
.nf-conn {
  position: fixed; top: 12px; left: 50%; transform: translate(-50%, -150%); z-index: 9999;
  background: var(--nf-warning); color: #1a1300; font-family: var(--nf-font-mono); font-size: 12px; font-weight: 700;
  padding: 8px 14px; border-radius: 999px; transition: transform .25s; pointer-events: none;
}
.nf-conn.show { transform: translate(-50%, 0); }

/* Toasts (NF.toast) */
.nf-toast {
  position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); opacity: 0; z-index: 9999;
  max-width: calc(100vw - 32px);
  background: var(--nf-surface-high); color: var(--nf-text); border: 1px solid var(--nf-outline-soft);
  padding: 12px 18px; border-radius: var(--nf-radius-sm); transition: opacity .25s, transform .25s;
}
.nf-toast.show { opacity: 1; transform: translate(-50%, 0); }
.nf-toast-error { border-color: var(--nf-error); color: var(--nf-error); }
.nf-toast-ok { border-color: var(--nf-success); }

/* Modal accesible */
.nf-modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 1000; }
.nf-modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; }
