:root {
  --r: 14px;
  --blue:       #1575bc;
  --blue-dark:  #0d5a96;
  --blue-deep:  #073f6e;
  --blue-mid:   #5baee0;
  --blue-light: #e8f4fd;
}

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

html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; }

body { background: var(--blue-deep); }

.hidden { display: none !important; }

/* ─────────────────────────────
   PORTAL DE INICIO
───────────────────────────── */
#view-portal {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}

.portal-bg {
  position: fixed;
  inset: 0;
  background: linear-gradient(145deg, var(--blue-deep) 0%, var(--blue-dark) 55%, var(--blue) 100%);
  z-index: 0;
}

.portal-bg::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 28px 28px;
}

.portal-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 36px;
  padding: 40px 20px;
  width: 100%;
  max-width: 520px;
  animation: fadeUp 0.35s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.portal-header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

/* Logo en contenedor blanco */
.portal-logo-wrap {
  background: #fff;
  border-radius: 18px;
  padding: 18px 36px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

.portal-logo-img {
  display: block;
  height: 52px;
  width: auto;
}

.portal-subtitle {
  color: rgba(255,255,255,0.65);
  font-size: 14px;
  letter-spacing: 0.02em;
}

.portal-cards { display: flex; flex-direction: column; gap: 14px; width: 100%; }

.module-card {
  display: flex;
  align-items: center;
  gap: 18px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--r);
  padding: 22px 24px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  width: 100%;
  transition: background 0.22s, transform 0.2s, box-shadow 0.22s, border-color 0.22s;
}

.module-card:hover {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.32);
  transform: translateY(-3px);
  box-shadow: 0 12px 36px rgba(0,0,0,0.3);
}

.module-card:active { transform: translateY(-1px); }

.module-card:focus-visible {
  outline: 2px solid rgba(255,255,255,0.5);
  outline-offset: 3px;
}

.module-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 21px;
  flex-shrink: 0;
}

.module-card-body  { flex: 1; }
.module-card-title { color: #fff; font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.module-card-desc  { color: rgba(255,255,255,0.52); font-size: 13px; line-height: 1.4; }

.module-card-arrow {
  color: rgba(255,255,255,0.30);
  font-size: 14px;
  flex-shrink: 0;
  transition: color 0.2s, transform 0.2s;
}

.module-card:hover .module-card-arrow {
  color: rgba(255,255,255,0.75);
  transform: translateX(5px);
}

.portal-footer {
  color: rgba(255,255,255,0.30);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ─────────────────────────────
   VISTA MÓDULO (iframe)
───────────────────────────── */
#view-module {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.module-topbar {
  height: 48px;
  background: var(--blue-deep);
  border-bottom: 1px solid rgba(255,255,255,0.10);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  flex-shrink: 0;
  z-index: 9999;
}

.topbar-title {
  color: rgba(255,255,255,0.65);
  font-size: 13px;
  font-weight: 600;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.18s, color 0.18s;
  font-family: inherit;
}

.back-btn:hover {
  background: rgba(255,255,255,0.10);
  color: #fff;
}

.back-btn:focus-visible {
  outline: 2px solid rgba(255,255,255,0.4);
  outline-offset: 2px;
}

.newtab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.40);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.18s, color 0.18s;
  font-family: inherit;
}

.newtab-btn:hover {
  background: rgba(255,255,255,0.10);
  color: #fff;
}

.newtab-btn:focus-visible {
  outline: 2px solid rgba(255,255,255,0.4);
  outline-offset: 2px;
}

/* ─────────────────────────────
   LOADING SPINNER
───────────────────────────── */
.module-loading {
  position: absolute;
  inset: 48px 0 0 0;
  background: var(--blue-deep);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: rgba(255,255,255,0.4);
  font-size: 13px;
  z-index: 10;
}

.loading-ring {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.12);
  border-top-color: var(--blue-mid);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

#module-frame {
  flex: 1;
  width: 100%;
  border: none;
  min-height: 0;
}
