/* ==========================================================================
   Synthetic User V2 — Hoja de Estilos Oficial y Refinada
   Portal Documental, Arquitectura y Plan de Construcción
   Propiedad de jsadsAI · Jose Santamaria (jsadsai.com)
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-muted: #e2e8f0;
  
  --border-light: #e2e8f0;
  --border-color: #cbd5e1;
  --border-dark: #94a3b8;
  
  --text-main: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  --primary-dark: #075985;
  --primary-gradient: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --info: #2563eb;
  --info-light: #dbeafe;
  
  --topbar-height: 64px;
  --sidebar-width: 290px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 8px -2px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 20px -4px rgba(15, 23, 42, 0.1), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
  --shadow-card: 0 2px 6px rgba(15, 23, 42, 0.04), 0 0 0 1px rgba(226, 232, 240, 0.8);
  --shadow-flyout: 0 16px 32px rgba(15, 23, 42, 0.16);
}

/* Resets y tipografía base */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text-body);
  background-color: var(--bg-app);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.25;
  margin-top: 1.6rem;
  margin-bottom: 0.8rem;
  letter-spacing: -0.015em;
}

h1 { font-size: 2.1rem; }
h2 { font-size: 1.55rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--border-light); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }

p, ul, ol, dl, table, blockquote, pre {
  margin-top: 0;
  margin-bottom: 1.25rem;
}

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

code:not(pre code) {
  background-color: var(--bg-subtle);
  color: #0f172a;
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
}

pre {
  background-color: #0f172a;
  color: #f8fafc;
  padding: 1.1rem 1.3rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
}
pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  border: none;
}

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

.skip-link {
  position: absolute;
  top: -40px;
  left: 10px;
  background: var(--primary);
  color: #ffffff;
  padding: 8px 16px;
  z-index: 2000;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 10px;
}

/* --------------------------------------------------------------------------
   Top Bar (Navegación Superior)
   -------------------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--topbar-height);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.85);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  gap: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-main);
  flex-shrink: 0;
}
.brand:hover {
  text-decoration: none;
}
.brand-logo-img {
  height: 34px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  display: block;
}
.brand-text {
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  line-height: 1.1;
  color: var(--text-main);
}
.brand-tag {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(2, 132, 199, 0.2);
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text-main);
  background-color: var(--bg-subtle);
  transition: all 0.15s ease;
}
.nav-toggle:hover {
  background-color: var(--border-light);
}
.nav-toggle-bars {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  position: relative;
}
.nav-toggle-bars::before, .nav-toggle-bars::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background: currentColor;
}
.nav-toggle-bars::before { top: -5px; }
.nav-toggle-bars::after { bottom: -5px; }

/* Buscador en Topbar */
.topbar-center {
  flex: 1;
  max-width: 520px;
  display: flex;
  justify-content: center;
}
.top-search {
  position: relative;
  width: 100%;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.85rem;
  color: var(--text-muted);
  pointer-events: none;
}
.top-search input[type="search"] {
  width: 100%;
  padding: 8px 36px 8px 34px;
  font-size: 0.88rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  background-color: var(--bg-subtle);
  color: var(--text-main);
  outline: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.top-search input[type="search"]:focus {
  background-color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.16);
}
.search-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72rem;
  font-family: var(--font-mono);
  font-weight: 600;
  background: #ffffff;
  border: 1px solid var(--border-color);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  pointer-events: none;
}

.qs-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-flyout);
  max-height: 420px;
  overflow-y: auto;
  z-index: 1100;
  padding: 6px 0;
}
.qs-item {
  display: block;
  padding: 9px 16px;
  color: var(--text-main);
  text-decoration: none;
  border-bottom: 1px solid var(--bg-subtle);
  transition: background 0.12s;
}
.qs-item:last-child {
  border-bottom: none;
}
.qs-item:hover, .qs-item:focus {
  background-color: var(--primary-light);
  text-decoration: none;
}
.qs-item-title {
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.qs-item-snippet {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Enlaces del Topbar */
.top-links {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}
.top-nav-item {
  color: var(--text-body);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}
.top-nav-item:hover {
  color: var(--primary);
  background-color: var(--bg-subtle);
  text-decoration: none;
}
.top-nav-item[aria-current="page"] {
  color: var(--primary);
  background-color: var(--primary-light);
  font-weight: 600;
}

/* Menú de Usuario desplegable */
.user-menu {
  position: relative;
}
.user-menu-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-light);
  user-select: none;
  transition: all 0.15s ease;
}
.user-menu-summary::-webkit-details-marker {
  display: none;
}
.user-menu-summary:hover {
  background-color: var(--border-light);
}
.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
}
.user-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-main);
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-arrow {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 240px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-flyout);
  z-index: 1100;
  padding: 8px 0;
}
.user-menu-header {
  padding: 8px 16px 4px;
}
.user-menu-name {
  font-weight: 700;
  font-size: 0.92rem;
  margin: 0;
  color: var(--text-main);
}
.badge-role {
  text-transform: uppercase;
  font-size: 0.68rem;
  font-weight: 700;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}
.user-menu-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 6px 0;
}
.user-menu-panel a,
.user-menu-panel button {
  display: block;
  width: 100%;
  padding: 8px 16px;
  color: var(--text-body);
  text-align: left;
  font-size: 0.88rem;
  background: none;
  border: none;
  cursor: pointer;
  box-sizing: border-box;
  text-decoration: none;
  transition: background 0.12s;
}
.user-menu-panel a:hover,
.user-menu-panel button:hover {
  background-color: var(--bg-subtle);
  color: var(--primary);
  text-decoration: none;
}
.user-menu-panel .admin-link {
  color: #7c3aed;
  font-weight: 600;
}
.user-menu-panel .logout-btn {
  color: var(--danger);
  font-weight: 500;
}
.user-menu-panel .logout-btn:hover {
  background-color: var(--danger-light);
  color: var(--danger);
}

/* --------------------------------------------------------------------------
   Estructura Principal (Shell + Sidebar + Main)
   -------------------------------------------------------------------------- */
.shell {
  display: flex;
  flex: 1;
  min-height: calc(100vh - var(--topbar-height));
  position: relative;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border-light);
  overflow-y: auto;
  position: sticky;
  top: var(--topbar-height);
  height: calc(100vh - var(--topbar-height));
  flex-shrink: 0;
  padding: 1.25rem 0.75rem 2rem;
  box-shadow: 1px 0 0 rgba(226, 232, 240, 0.6);
}

.nav-root {
  list-style: none;
  padding: 0;
  margin: 0;
}
.nav-home {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-main);
  border-radius: var(--radius-sm);
  margin-bottom: 0.6rem;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-light);
  transition: all 0.15s ease;
}
.nav-home:hover {
  background-color: var(--primary-light);
  color: var(--primary);
  text-decoration: none;
}
.nav-home[aria-current="page"] {
  background-color: var(--primary-light);
  color: var(--primary-dark);
  border-color: rgba(2, 132, 199, 0.3);
}

.nav-group {
  margin-bottom: 0.8rem;
}
.nav-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  padding: 6px 8px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}
.nav-group-toggle:hover {
  color: var(--text-main);
}
.nav-group-toggle::after {
  content: "▾";
  font-size: 0.8rem;
  transition: transform 0.2s ease;
}
.nav-group-toggle[aria-expanded="false"]::after {
  transform: rotate(-90deg);
}

.nav-docs {
  list-style: none;
  padding: 0 0 0 4px;
  margin: 4px 0 0 0;
  border-left: 1px solid var(--border-light);
}
.nav-docs li {
  margin-bottom: 2px;
}
.nav-docs a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 6px 10px;
  font-size: 0.86rem;
  color: var(--text-body);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.12s ease;
}
.nav-docs a:hover {
  background-color: var(--bg-subtle);
  color: var(--primary);
  text-decoration: none;
}
.nav-docs a[aria-current="page"] {
  background-color: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}
.nav-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.nav-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-state {
  font-size: 0.8rem;
  color: var(--success);
}
.nav-state.upd {
  color: var(--warning);
}

/* Área de Contenido Principal (Texto que fluye bajo el menú) */
.main {
  flex: 1;
  min-width: 0;
  padding: 2.5rem 3rem 4rem;
  max-width: 1120px;
  margin: 0 auto;
}

/* --------------------------------------------------------------------------
   Hero de Bienvenida Mejorado
   -------------------------------------------------------------------------- */
.welcome-container {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.hero-enhanced {
  background: linear-gradient(180deg, #ffffff 0%, var(--bg-subtle) 100%);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.hero-enhanced::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary-gradient);
}

.hero-brand-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
}
.hero-logo-img {
  height: 56px;
  width: auto;
  max-width: 260px;
  object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(15, 23, 42, 0.08));
}
.hero-pill-version {
  display: inline-flex;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid rgba(2, 132, 199, 0.25);
}

.hero-title {
  font-size: 2.35rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
  color: var(--text-main);
  max-width: 900px;
  margin: 0 auto 1.2rem;
}
.hero-lead {
  font-size: 1.15rem;
  line-height: 1.65;
  color: var(--text-body);
  max-width: 820px;
  margin: 0 auto 2.2rem;
}
.hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.8rem;
}

/* Bento Grid */
.cards-bento {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1.5rem;
}
.card-bento {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
}
.card-bento:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.card-bento-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}
.bento-icon {
  font-size: 1.4rem;
}
.card-bento h3 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--text-main);
}
.metric {
  font-size: 2.4rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
  margin: 0.5rem 0 0.8rem;
  font-variant-numeric: tabular-nums;
}
.metric small {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
}
.bento-footer-date {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 1rem;
  margin-bottom: 0;
  border-top: 1px solid var(--border-light);
  padding-top: 0.6rem;
}
.bento-action-link {
  margin-top: 0.8rem;
  margin-bottom: 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.progressbar {
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  height: 8px;
  overflow: hidden;
  margin: 0.5rem 0 0.8rem;
}
.progressbar > span {
  display: block;
  height: 100%;
  background: var(--primary-gradient);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.entities-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.6rem 0;
}
.chip {
  font-size: 0.8rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-body);
}

/* Sección Pilares */
.section-header {
  margin-bottom: 1.5rem;
}
.section-header h2 {
  font-size: 1.6rem;
  border-bottom: none;
  margin-bottom: 0.2rem;
}
.section-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
}

.pillars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.2rem;
}
.pillar-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-decoration: none;
  box-shadow: var(--shadow-card);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.pillar-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.pillar-card-top {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}
.pillar-badge {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 0.8rem;
  padding: 3px 8px;
  background: var(--primary-gradient);
  color: #ffffff;
  border-radius: var(--radius-sm);
}
.pillar-title {
  font-size: 1.15rem;
  color: var(--text-main);
}
.pillar-desc {
  font-size: 0.9rem;
  color: var(--text-body);
  line-height: 1.5;
  margin-bottom: 1rem;
}
.pillar-link {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  margin-top: auto;
}

/* Paquetes de Trabajo (Work Packages) */
.wp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.wp-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.wp-code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  display: inline-block;
  align-self: flex-start;
  margin-bottom: 0.4rem;
}
.wp-title {
  margin: 0.2rem 0 0.4rem;
  font-size: 1.02rem;
  color: var(--text-main);
}
.wp-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 0.8rem;
}
.wp-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
}

/* Ruta de Lectura */
.reading-path-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.path-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 1rem 1.4rem;
  gap: 1rem;
  transition: all 0.15s;
}
.path-step:hover {
  border-color: var(--border-dark);
}
.path-step-content {
  flex: 1;
}
.path-step-title {
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--text-main);
  display: block;
}
.path-step-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 2px 0 0 0;
}

/* Decisiones y Listas de Entidades */
.cards-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.card-plain {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}
.section-title-sm {
  font-size: 1.2rem;
  margin-top: 0;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.5rem;
}
.entity-list-styled {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.entity-list-styled a {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 0.88rem;
  color: var(--text-body);
}
.entity-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.entity-badge.adr { background: #f3e8ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.entity-badge.blk { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.entity-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entity-more-link {
  margin-top: 1rem;
  margin-bottom: 0;
  font-size: 0.88rem;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Documentos (Lectura y Prosa)
   -------------------------------------------------------------------------- */
.doc-header {
  margin-bottom: 2.2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-light);
}
.doc-breadcrumbs {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}
.doc-header h1 {
  margin-top: 0;
  margin-bottom: 0.8rem;
}
.doc-lead {
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--text-body);
  margin-bottom: 1.2rem;
}
.doc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
}
.doc-toolbar-left, .doc-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.doc-layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 2.5rem;
  align-items: start;
}

.doc-body.prose {
  font-size: 1.02rem;
  line-height: 1.75;
  color: #1e293b;
}
.doc-body.prose h2 {
  margin-top: 2.5rem;
  font-size: 1.55rem;
}
.doc-body.prose h3 {
  margin-top: 2rem;
  font-size: 1.25rem;
}
.doc-body.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.92rem;
}
.doc-body.prose th, .doc-body.prose td {
  padding: 10px 14px;
  border: 1px solid var(--border-light);
  text-align: left;
}
.doc-body.prose th {
  background: var(--bg-subtle);
  color: var(--text-main);
  font-weight: 700;
}
.doc-body.prose tr:nth-child(even) {
  background: #fafbfd;
}

.doc-toc-wrap {
  position: sticky;
  top: calc(var(--topbar-height) + 1.5rem);
  max-height: calc(100vh - var(--topbar-height) - 3rem);
  overflow-y: auto;
}
.doc-toc-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 1rem 1.2rem;
}
.doc-toc-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-top: 0;
  margin-bottom: 0.6rem;
}
.doc-toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.toc-item a {
  display: block;
  font-size: 0.82rem;
  padding: 3px 0;
  color: var(--text-muted);
}
.toc-item a:hover {
  color: var(--primary);
  text-decoration: none;
}
.toc-level-3 { padding-left: 0.7rem; }
.toc-level-4 { padding-left: 1.4rem; }

/* --------------------------------------------------------------------------
   Botones y Elementos Interactivos
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease-in-out;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(2, 132, 199, 0.2);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);
}
.btn-outline {
  background: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: var(--bg-subtle);
  border-color: var(--border-dark);
}
.btn-subtle {
  background: var(--bg-subtle);
  color: var(--text-body);
  border-color: var(--border-light);
}
.btn-subtle:hover {
  background: var(--border-light);
  color: var(--text-main);
}
.btn-lg {
  padding: 10px 20px;
  font-size: 0.98rem;
  border-radius: var(--radius-md);
}
.btn-sm {
  padding: 5px 10px;
  font-size: 0.82rem;
}

/* Badges e Insignias */
.tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  background-color: var(--bg-subtle);
  color: var(--text-muted);
}
.tag-ok {
  background-color: var(--success-light);
  color: var(--success);
  font-weight: 600;
}
.tag-info {
  background-color: var(--info-light);
  color: var(--info);
  font-weight: 600;
}

/* Badges de Evidencia */
.evidence {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  margin: 0 2px;
  vertical-align: baseline;
}
.evidence-dp { background: #fef08a; color: #854d0e; border: 1px solid #fde047; }
.evidence-hv { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.evidence-af { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }
.evidence-pa { background: #f3e8ff; color: #6b21a8; border: 1px solid #e9d5ff; }
.evidence-hp { background: #fed7aa; color: #9a3412; border: 1px solid #fdba74; }
.evidence-il { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* --------------------------------------------------------------------------
   Footer Oficial con Logo del Propietario (jsadsAI)
   -------------------------------------------------------------------------- */
.footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-light);
  padding: 2.5rem 2rem 2rem;
  margin-top: auto;
}

.footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 2rem;
}

.footer-brand-section {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.footer-owner-link {
  display: block;
  flex-shrink: 0;
  transition: opacity 0.2s;
}
.footer-owner-link:hover {
  opacity: 0.85;
}
.footer-owner-logo {
  height: 42px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  display: block;
}
.footer-owner-info {
  display: flex;
  flex-direction: column;
  line-height: 1.4;
}
.footer-owner-title {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-main);
}
.footer-owner-subtitle {
  margin: 2px 0 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.footer-meta-section {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
  gap: 0.4rem;
}
.footer-meta-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  flex-wrap: wrap;
}
.meta-pill {
  font-size: 0.78rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-body);
}
.footer-disclaimer {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 520px;
}
.footer-copy {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-light);
}

/* --------------------------------------------------------------------------
   Páginas de Autenticación (Login / Activación)
   -------------------------------------------------------------------------- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0b1329 0%, #1e293b 100%);
  padding: 1.5rem;
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}
.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-logo-img {
  height: 48px;
  width: auto;
  max-width: 220px;
  margin: 0 auto 0.6rem;
  display: block;
}
.auth-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin: 0;
}
.auth-title {
  font-size: 1.5rem;
  text-align: center;
  margin-top: 0;
  margin-bottom: 1.5rem;
}
.auth-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 1.8rem 0 1.2rem;
}
.auth-footer-owner {
  text-align: center;
}
.auth-owner-logo {
  height: 32px;
  width: auto;
  margin: 0 auto 0.4rem;
  display: block;
}
.auth-owner-text {
  font-size: 0.82rem;
  color: var(--text-body);
  margin: 0;
}
.auth-owner-copy {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 2px 0 0 0;
}

/* --------------------------------------------------------------------------
   Responsive Design (Móvil, Tablet y Desktop)
   -------------------------------------------------------------------------- */
@media (max-width: 960px) {
  .nav-toggle {
    display: block;
  }
  .sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: -100%;
    width: 290px;
    height: calc(100vh - var(--topbar-height));
    z-index: 1050;
    transition: left 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open {
    left: 0;
  }
  .nav-backdrop {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1040;
  }
  .doc-layout-grid {
    grid-template-columns: 1fr;
  }
  .doc-toc-wrap {
    display: none;
  }
  .cards-2 {
    grid-template-columns: 1fr;
  }
  .top-links > a.top-nav-item:not([aria-current="page"]) {
    display: none;
  }
}

@media (max-width: 768px) {
  :root {
    --topbar-height: 58px;
  }
  .topbar {
    padding: 0 1rem;
  }
  .brand-text {
    font-size: 0.95rem;
  }
  .brand-tag {
    display: none;
  }
  .topbar-center {
    max-width: 200px;
  }
  .main {
    padding: 1.5rem 1rem 3rem;
  }
  .hero-enhanced {
    padding: 2rem 1.25rem;
  }
  .hero-title {
    font-size: 1.7rem;
  }
  .hero-lead {
    font-size: 1rem;
    margin-bottom: 1.5rem;
  }
  .hero-actions {
    flex-direction: column;
    width: 100%;
  }
  .hero-actions .btn {
    width: 100%;
  }
  .cards-bento {
    grid-template-columns: 1fr;
  }
  .pillars-grid {
    grid-template-columns: 1fr;
  }
  .wp-grid {
    grid-template-columns: 1fr;
  }
  .footer-inner {
    flex-direction: column;
    text-align: center;
    align-items: center;
  }
  .footer-brand-section {
    flex-direction: column;
    text-align: center;
  }
  .footer-meta-section {
    align-items: center;
    text-align: center;
  }
  .footer-meta-line {
    justify-content: center;
  }
}
