:root {
  /* ── Paleta Material-3, alineada al módulo de Aprobación OP/OC y al azul del logo ── */
  --sg-primary: #00458d;
  --sg-primary-container: #005cb9;
  --sg-primary-light: #f2f3fc;
  --sg-primary-dark: #00305f;
  --sg-secondary: #255fa5;
  --sg-tertiary: #9f4100;
  --sg-accent: #147a45;

  --sg-surface: #f9f9ff;
  --sg-surface-page: #f6f7fb;
  --sg-surface-card: #ffffff;
  --sg-surface-elevated: #ffffff;
  --sg-surface-container-low: #f2f3fc;
  --sg-surface-container: #ecedf6;
  --sg-surface-container-high: #e7e8f0;
  --sg-surface-container-highest: #e1e2ea;

  --sg-border: #c2c6d4;
  --sg-border-soft: #e1e2ea;
  --sg-border-hover: #727784;
  --sg-outline: #727784;
  --sg-outline-variant: #c2c6d4;

  --sg-text-primary: #191c21;
  --sg-text-secondary: #424752;
  --sg-text-muted: #727784;

  --sg-error: #ba1a1a;
  --sg-error-container: #ffdad6;
  --sg-success: #147a45;
  --sg-success-container: #d9fbe3;
  --sg-warning-container: #fff1c7;

  --sg-radius: 20px;
  --sg-radius-lg: 24px;
  --sg-radius-sm: 16px;
  --sg-radius-xs: 999px;
  --sg-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --sg-font: 'Inter', -apple-system, sans-serif;
  --sg-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.03);
  --sg-shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --sg-shadow-lg: 0 10px 36px rgba(15, 23, 42, 0.08);
  --sg-shadow-card: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  user-select: none
}

.material-symbols-outlined.fill {
  font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24
}

/* ═══ INTRO ANIMATION ═══ */
:root {
  --intro-bg: #f6f7fb;
  --intro-color: #005cb9;
  /* Seagate Brand Blue */
  --intro-duration: 3s;
}

#introView {
  display: none;
  position: fixed;
  inset: 0;
  background-color: var(--intro-bg);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  cursor: pointer;
}

#introView.active {
  display: flex;
}

.intro-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}


.intro-logo-wrapper {
  width: 700px;
  max-width: 90vw;
  display: flex;
  align-items: center;
  justify-content: center;
}

.intro-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

/* SVG Text Drawing Animation */
.intro-text {
  font-family: 'Nunito Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-weight: 390;
  font-size: 120px;
  letter-spacing: -2px;
  fill: transparent;
  stroke: var(--intro-color);
  stroke-width: 1px;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1200;
  stroke-dashoffset: 1200;
  paint-order: stroke;
  animation:
    introDraw 1.6s cubic-bezier(1, 0.5, 0.5, 1) 0s forwards,
    introFill 2s cubic-bezier(1, 0.5, 0.5, 1) 2s forwards;
}

/* Keyframes for outline drawing */
@keyframes introDraw {
  to {
    stroke-dashoffset: 0;
  }
}

/* Keyframes for filling text (Blue) */
@keyframes introFill {
  to {
    fill: var(--intro-color);
    stroke: transparent;
  }
}

/* Fade Out Animation */
.intro-fade-out {
  animation: introFadeOut 0.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes introFadeOut {
  from {
    opacity: 1;
    transform: scale(1);
  }

  to {
    opacity: 0;
    transform: scale(1.02);
    pointer-events: none;
  }
}

/* Responsive constraints for intro */
@media (max-width: 768px) {
  .intro-logo-wrapper {
    width: 500px;
  }

  .intro-text {
    font-size: 90px;
    letter-spacing: 12px;
  }
}

@media (max-width: 480px) {
  .intro-logo-wrapper {
    width: 320px;
  }

  .intro-text {
    font-size: 55px;
    letter-spacing: 8px;
    stroke-width: 1.5px;
  }
}



/* ═══ LOGIN ═══ */

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

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior-x: none
}

body {
  font-family: var(--sg-font);
  background:
    radial-gradient(circle at top left, rgba(0, 92, 185, 0.08), transparent 30%),
    radial-gradient(circle at bottom right, rgba(37, 95, 165, 0.08), transparent 28%),
    var(--sg-surface-page);
  background-attachment: fixed;
  color: var(--sg-text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased
}

::-webkit-scrollbar {
  width: 7px;
  height: 7px
}

::-webkit-scrollbar-track {
  background: transparent
}

::-webkit-scrollbar-thumb {
  background: var(--sg-outline-variant);
  border-radius: 999px
}

::-webkit-scrollbar-thumb:hover {
  background: var(--sg-outline)
}

/* Subtle background pattern */
.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none
}

.bg-mesh::before {
  content: '';
  position: absolute;
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, rgba(0, 92, 185, 0.04) 0%, transparent 70%);
  top: -200px;
  right: -100px;
  animation: float1 25s ease-in-out infinite
}

.bg-mesh::after {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(0, 196, 154, 0.03) 0%, transparent 70%);
  bottom: -150px;
  left: -100px;
  animation: float2 30s ease-in-out infinite
}

@keyframes float1 {

  0%,
  100% {
    transform: translate(0, 0) scale(1)
  }

  33% {
    transform: translate(50px, 40px) scale(1.05)
  }

  66% {
    transform: translate(-30px, 60px) scale(0.97)
  }
}

@keyframes float2 {

  0%,
  100% {
    transform: translate(0, 0) scale(1)
  }

  33% {
    transform: translate(-40px, -50px) scale(1.08)
  }

  66% {
    transform: translate(30px, -30px) scale(0.95)
  }
}

.noise-overlay {
  display: none
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px)
  }

  to {
    opacity: 1;
    transform: none
  }
}

@keyframes fadeIn {
  from {
    opacity: 0
  }

  to {
    opacity: 1
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg)
  }
}

@keyframes pulse-glow {

  0%,
  100% {
    box-shadow: 0 0 6px rgba(56, 161, 105, 0.3)
  }

  50% {
    box-shadow: 0 0 14px rgba(56, 161, 105, 0.5)
  }
}

.view {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 10
}

.view.active {
  display: flex
}

/* ═══ LOGIN ═══ */
#loginView {
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 32px;
  background: var(--sg-surface-page)
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 0 24px;
  animation: fadeInUp .7s cubic-bezier(.16, 1, .3, 1) forwards
}

.login-brand {
  text-align: center;
  margin-bottom: 36px
}

.login-brand-logo {
  height: 140px;
  width: auto;
  margin-bottom: 8px
}

.login-brand h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--sg-text-primary);
  letter-spacing: -.5px;
  margin-bottom: 4px
}

.login-brand p {
  font-size: 13px;
  color: var(--sg-text-secondary);
  font-weight: 500
}

.login-card {
  background: var(--sg-surface-card);
  border: 1px solid var(--sg-border);
  border-radius: var(--sg-radius);
  padding: 32px 28px;
  box-shadow: var(--sg-shadow-lg)
}

.login-card h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--sg-text-primary);
  margin-bottom: 4px
}

.login-card .subtitle {
  font-size: 13px;
  color: var(--sg-text-muted);
  margin-bottom: 24px
}

.form-group {
  margin-bottom: 18px
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--sg-text-secondary);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 6px
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  background: #F8FAFC;
  border: 1px solid var(--sg-border);
  border-radius: var(--sg-radius-xs);
  color: var(--sg-text-primary);
  font-family: var(--sg-font);
  font-size: 14px;
  font-weight: 500;
  transition: var(--sg-transition);
  outline: none
}

.form-input::placeholder {
  color: var(--sg-text-muted)
}

.form-input:focus {
  border-color: var(--sg-primary);
  box-shadow: 0 0 0 3px rgba(0, 92, 185, 0.1);
  background: #fff
}

.form-input.error {
  border-color: var(--sg-error);
  box-shadow: 0 0 0 3px rgba(229, 62, 62, 0.1)
}

.login-error {
  display: none;
  align-items: center;
  gap: 8px;
  background: #FFF5F5;
  border: 1px solid #FED7D7;
  color: #C53030;
  padding: 10px 14px;
  border-radius: var(--sg-radius-xs);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 18px;
  animation: fadeIn .3s ease
}

.login-error.show {
  display: flex
}

.btn-login {
  width: 100%;
  padding: 12px 24px;
  background: var(--sg-primary);
  color: #fff;
  border: none;
  border-radius: var(--sg-radius-xs);
  font-family: var(--sg-font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--sg-transition);
  position: relative;
  overflow: hidden
}

.btn-login:hover {
  background: var(--sg-primary-dark);
  box-shadow: var(--sg-shadow-md)
}

.btn-login:active {
  transform: translateY(0)
}

.btn-login:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none
}

.btn-login .spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto
}

.btn-login.loading .btn-text {
  display: none
}

.btn-login.loading .spinner {
  display: inline-block
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 11px;
  color: var(--sg-text-muted)
}

/* ═══ PORTAL ═══ */
#portalView {
  flex-direction: column;
  overflow: hidden;
  background: var(--sg-surface-page)
}

.portal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  border-bottom: 1px solid var(--sg-border);
  background: #fff;
  flex-shrink: 0;
  z-index: 50;
  box-shadow: var(--sg-shadow-sm)
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px
}

.topbar-logo {
  height: 55px;
  width: auto
}

.topbar-divider {
  width: 1px;
  height: 28px;
  background: var(--sg-border)
}

.topbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--sg-text-primary)
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  background: #F8FAFC;
  border: 1px solid var(--sg-border);
  border-radius: 100px
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sg-primary), var(--sg-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff
}

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--sg-text-primary)
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: #FFF5F5;
  border: 1px solid #FED7D7;
  border-radius: var(--sg-radius-xs);
  color: #C53030;
  font-family: var(--sg-font);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
  cursor: pointer;
  transition: var(--sg-transition)
}

.btn-logout:hover {
  background: #FED7D7;
  border-color: #FC8181
}

.portal-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 30px;
  overflow-y: auto
}

.portal-center {
  max-width: 1100px;
  width: 100%;
  margin: 28px auto auto;
}

.portal-welcome {
  margin-bottom: 4px;
  animation: fadeInUp .6s cubic-bezier(.16, 1, .3, 1) forwards
}

.portal-welcome h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--sg-text-primary);
  letter-spacing: -.4px;
  margin-bottom: 4px
}

.portal-welcome p {
  font-size: 13px;
  color: var(--sg-text-secondary);
  max-width: 560px;
  line-height: 1.5
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  max-width: 1100px;
  margin: 0 auto;
  text-align: left
}

/* ── Tarjeta de módulo: sobria, un solo acento, jerarquía por tipografía ── */
.module-card {
  position: relative;
  background: var(--sg-surface-card);
  border: 1px solid var(--sg-border-soft);
  border-radius: var(--sg-radius-sm);
  padding: 16px 18px 18px;
  cursor: pointer;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
  text-align: left;
  opacity: 0;
  animation: fadeInUp .45s cubic-bezier(.16, 1, .3, 1) forwards;
  animation-delay: calc(var(--i, 0) * 30ms)
}

.module-card:hover {
  border-color: var(--sg-outline-variant);
  box-shadow: 0 6px 18px rgba(15, 23, 42, .06);
  transform: translateY(-1px)
}

.module-card:focus-visible {
  outline: none;
  border-color: var(--sg-primary);
  box-shadow: 0 0 0 3px rgba(0, 69, 141, .1)
}

.module-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px
}

.module-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--sg-surface-container-low);
  color: var(--sg-text-secondary);
  transition: background-color .2s ease, color .2s ease
}

.module-icon .material-symbols-outlined {
  font-size: 20px
}

/* Respaldo para iconos heredados (emoji) */
.module-icon-glyph {
  font-size: 18px;
  line-height: 1
}

.module-card:hover .module-icon {
  background: var(--sg-primary-light);
  color: var(--sg-primary)
}

.module-card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--sg-text-primary);
  margin-bottom: 5px;
  letter-spacing: -.15px;
  line-height: 1.3
}

.module-card .module-desc {
  font-size: 12px;
  color: var(--sg-text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden
}

/* Metadatos: texto discreto, no pastillas de color */
.module-meta {
  margin-top: 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--sg-text-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis
}

/* Flecha discreta: solo al pasar el cursor */
.module-arrow {
  position: absolute;
  right: 16px;
  bottom: 14px;
  font-size: 18px;
  color: var(--sg-primary);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none
}

.module-card:hover .module-arrow,
.module-card:focus-visible .module-arrow {
  opacity: 1;
  transform: translateX(0)
}

/* ── Botón de favorito ── */
.btn-fav {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin: -4px -6px 0 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--sg-outline-variant);
  transition: color .2s ease, background-color .2s ease
}

.btn-fav .material-symbols-outlined {
  font-size: 19px
}

.btn-fav:hover {
  background: var(--sg-surface-container-low);
  color: var(--sg-text-secondary)
}

.btn-fav[aria-pressed="true"] {
  color: var(--sg-primary)
}

.btn-fav:focus-visible {
  outline: 2px solid var(--sg-primary);
  outline-offset: 1px
}

/* ---- Toolbar: buscador + chips de categoria ---- */
.portal-toolbar {
  position: sticky;
  top: -20px;
  z-index: 20;
  max-width: 1100px;
  margin: 0 auto 16px;
  padding: 12px 0 10px;
  background: rgba(246, 247, 251, .92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px)
}

.portal-toolbar.hidden {
  display: none
}

.search-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  background: var(--sg-surface);
  border: 1px solid rgba(114, 119, 132, .5);
  border-radius: 999px;
  box-shadow: var(--sg-shadow-sm);
  transition: var(--sg-transition)
}

.search-field:focus-within {
  border-color: var(--sg-primary);
  box-shadow: 0 0 0 3px rgba(0, 69, 141, .1)
}

.search-field .search-ico {
  font-size: 19px;
  color: var(--sg-text-muted);
  flex-shrink: 0
}

#moduleSearch {
  flex: 1;
  min-width: 0;
  height: 44px;
  border: none;
  background: none;
  font-family: var(--sg-font);
  font-size: 13px;
  font-weight: 500;
  color: var(--sg-text-primary)
}

#moduleSearch:focus {
  outline: none
}

/* El navegador dibuja su propio botón de limpiar en input[type=search] */
#moduleSearch::-webkit-search-cancel-button,
#moduleSearch::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none
}

#moduleSearch::placeholder {
  color: var(--sg-text-muted);
  font-weight: 500
}

.btn-clear-search .material-symbols-outlined {
  font-size: 16px
}

.btn-clear-search {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--sg-surface-container-high);
  border-radius: 999px;
  color: var(--sg-text-secondary);
  font-size: 12px;
  cursor: pointer;
  transition: var(--sg-transition)
}

.btn-clear-search.show {
  display: inline-flex
}

.btn-clear-search:hover {
  background: var(--sg-outline-variant)
}

.search-field.has-query .search-hint {
  display: none
}

.search-hint {
  flex-shrink: 0;
  padding: 2px 7px;
  border: 1px solid var(--sg-outline-variant);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--sg-text-muted)
}

.category-chips {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px
}

.category-chips::-webkit-scrollbar {
  display: none
}

.chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 13px;
  border: 1px solid var(--sg-border-soft);
  border-radius: 8px;
  background: var(--sg-surface-card);
  font-family: var(--sg-font);
  font-size: 12px;
  font-weight: 600;
  color: var(--sg-text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--sg-transition)
}

.chip .material-symbols-outlined {
  font-size: 15px
}

.chip:hover {
  background: var(--sg-surface-container-high)
}

.chip[aria-pressed="true"] {
  background: var(--sg-text-primary);
  border-color: var(--sg-text-primary);
  color: #fff
}

.chip .chip-count {
  font-size: 11px;
  font-weight: 600;
  opacity: .5
}

/* ---- Secciones ---- */
.module-sections {
  max-width: 1100px;
  margin: 0 auto;
  text-align: left
}

.module-section {
  margin-bottom: 26px
}

.module-section:last-child {
  margin-bottom: 0
}

.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px
}

.section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--sg-text-muted)
}

.section-count {
  font-size: 10px;
  font-weight: 600;
  color: var(--sg-outline-variant)
}

.section-rule {
  flex: 1;
  height: 1px;
  background: var(--sg-border-soft)
}

/* ---- Estado vacio / carga ---- */
.portal-empty {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px;
  text-align: center;
  background: var(--sg-surface-card);
  border: 1px dashed var(--sg-outline-variant);
  border-radius: var(--sg-radius-lg)
}

.portal-empty .empty-ico {
  display: block;
  font-size: 30px;
  color: var(--sg-outline-variant);
  margin: 0 auto 10px
}

.portal-empty h4 {
  font-size: 14px;
  font-weight: 800;
  color: var(--sg-text-primary);
  margin-bottom: 4px
}

.portal-empty p {
  font-size: 12px;
  color: var(--sg-text-secondary);
  margin-bottom: 14px
}

.btn-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 18px;
  border: none;
  border-radius: 999px;
  background: var(--sg-primary);
  color: #fff;
  font-family: var(--sg-font);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--sg-transition)
}

.btn-pill:hover {
  background: var(--sg-primary-container)
}

/* ═══ MODULE VIEW ═══ */
#moduleView {
  flex-direction: column;
  background: #fff
}

.module-frame-wrap {
  flex: 1;
  position: relative;
  overflow: hidden
}

.module-frame-wrap iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff
}

.btn-float-back {
  position: absolute;
  bottom: 20px;
  left: 20px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--sg-border);
  border-radius: 10px;
  color: var(--sg-text-secondary);
  font-family: var(--sg-font);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--sg-transition);
  box-shadow: var(--sg-shadow-lg)
}

body.module-hide-portal-back .btn-float-back {
  display: none;
}

.btn-float-back:hover {
  background: #fff;
  color: var(--sg-primary);
  border-color: var(--sg-primary);
  box-shadow: 0 8px 30px rgba(0, 92, 185, 0.15)
}

.module-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #fff;
  z-index: 10;
  transition: opacity .4s ease
}

.module-loader.hidden {
  opacity: 0;
  pointer-events: none
}

.module-loader .loader-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--sg-border);
  border-top-color: var(--sg-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite
}

.module-loader .loader-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--sg-text-secondary)
}

@media(max-width:768px) {
  .module-grid {
    grid-template-columns: 1fr
  }

  .portal-content {
    padding: 24px 16px
  }

  .portal-welcome h2 {
    font-size: 22px
  }

  .login-container {
    padding: 0 16px
  }

  .login-card {
    padding: 24px 20px
  }

  .portal-topbar {
    padding: 10px 14px;
    flex-wrap: nowrap;
    gap: 8px
  }

  .topbar-logo {
    height: 34px
  }

  .topbar-right {
    gap: 4px
  }

  .topbar-user {
    padding: 4px 6px
  }

  .user-name {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
  }

  .module-card {
    padding: 24px 20px
  }

}

/* ── Modal & Utilities ── */
.btn-icon {
  background: #F8FAFC;
  border: 1px solid var(--sg-border);
  color: var(--sg-text-secondary);
  padding: 7px 14px;
  border-radius: var(--sg-radius-xs);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--sg-transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-icon:hover {
  background: var(--sg-primary-light);
  border-color: var(--sg-primary);
  color: var(--sg-primary);
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  transition: all 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-content {
  background: #FFFFFF;
  border: 1px solid var(--sg-border);
  border-radius: 16px;
  width: 90%;
  max-width: 400px;
  padding: 28px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  transform: translateY(0);
  transition: all 0.3s ease;
}

.modal-overlay.hidden .modal-content {
  transform: translateY(20px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--sg-text-primary);
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--sg-text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s ease;
}

.btn-close-modal:hover {
  color: var(--sg-text-primary);
}

.login-success {
  background: #F0FFF4;
  color: #2F855A;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  border: 1px solid #C6F6D5;
  text-align: center;
  font-weight: 600;
}

.hidden {
  display: none !important;
}


/* =========================================================
   Ajustes Material-3: pills, superficies y responsive
   ========================================================= */

.portal-topbar {
  background: rgba(249, 249, 255, .88);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--sg-border-soft);
  box-shadow: var(--sg-shadow-sm)
}

.topbar-user {
  background: var(--sg-surface-container-low);
  border-color: var(--sg-outline-variant)
}

.user-avatar {
  background: linear-gradient(135deg, var(--sg-primary), var(--sg-secondary))
}

.btn-icon {
  min-height: 34px;
  padding: 0 12px;
  gap: 7px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--sg-text-secondary);
  font-size: 12px;
  font-weight: 600
}

.btn-icon .material-symbols-outlined {
  font-size: 18px
}

.btn-icon:hover {
  background: var(--sg-surface-container-low);
  border-color: var(--sg-border-soft);
  color: var(--sg-text-primary)
}

.btn-icon-danger:hover {
  background: var(--sg-error-container);
  border-color: transparent;
  color: #93000a
}

/* La barra superior no es el lugar para etiquetas largas en móvil */
@media (max-width: 640px) {
  .btn-icon-label {
    display: none
  }

  .btn-icon {
    padding: 0 9px
  }
}

.topbar-user {
  padding: 5px 12px 5px 5px;
  background: transparent;
  border-color: transparent
}

.topbar-user:hover {
  background: var(--sg-surface-container-low)
}

.btn-login {
  border-radius: 999px;
  min-height: 46px;
  font-weight: 700
}

.login-card {
  border-radius: 28px;
  border: 1px solid var(--sg-border-soft);
  box-shadow: var(--sg-shadow-card)
}

.form-input {
  border-radius: 16px;
  border-color: var(--sg-outline-variant)
}

.form-input:focus {
  border-color: var(--sg-primary);
  box-shadow: 0 0 0 3px rgba(0, 69, 141, .1)
}

.login-error,
.login-success {
  border-radius: 16px
}

.modal-content {
  border-radius: var(--sg-radius-lg);
  box-shadow: var(--sg-shadow-card)
}

.btn-close-modal {
  border-radius: 999px
}

/* ── Cierre de sesión por seguridad ── */
.login-notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--sg-primary-light);
  border: 1px solid #d6dcf0;
  color: var(--sg-primary);
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 18px;
  animation: fadeIn .3s ease
}

.login-notice.hidden {
  display: none
}

.session-modal {
  text-align: center;
  max-width: 380px
}

.session-modal-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--sg-warning-container);
  color: #8a6a3f
}

.session-modal-icon .material-symbols-outlined {
  font-size: 28px
}

.session-modal h3 {
  margin: 0 0 6px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--sg-text-primary)
}

.session-modal-text {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--sg-text-secondary)
}

.session-modal-count {
  margin: 14px 0 18px;
  font-size: 30px;
  font-weight: 800;
  color: var(--sg-primary);
  font-variant-numeric: tabular-nums
}

.session-modal-actions {
  display: flex;
  gap: 10px
}

.session-modal-actions .btn-login {
  flex: 1
}

.btn-session-secondary {
  flex: 1;
  min-height: 46px;
  border-radius: 999px;
  border: 1px solid var(--sg-border);
  background: #fff;
  color: var(--sg-text-secondary);
  font-family: var(--sg-font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--sg-transition)
}

.btn-session-secondary:hover {
  background: var(--sg-surface-container-low);
  color: var(--sg-text-primary)
}

@media (max-width: 768px) {
  .module-grid {
    grid-template-columns: 1fr
  }

  .portal-toolbar {
    top: -24px;
    padding: 10px 0 8px;
    margin-bottom: 12px
  }

  .search-hint {
    display: none
  }

  .portal-center {
    margin-top: 12px
  }

  .module-card {
    padding: 18px 16px 18px 20px
  }
}
