/* BFG Maintenance Portal – module picker */

/* ── Auto-refresh progress bar ───────────────────────────────── */
#bfg-portal-bar-wrap {
  position: fixed; top: 0; left: 0; right: 0; height: 4px;
  z-index: 9999; background: rgba(255,255,255,.08); pointer-events: none;
}
#bfg-portal-bar {
  height: 100%; width: 0%; will-change: width;
  background: linear-gradient(90deg, #10b981, #34d399, #a7f3d0, #10b981);
  background-size: 300% 100%;
  animation: bfgPortalShimmer 2s linear infinite;
  box-shadow: 0 0 6px #10b981, 0 0 14px rgba(16,185,129,.5);
  transition: width 0.25s linear;
}
#bfg-portal-bar.bar-warn {
  background: linear-gradient(90deg, #f97316, #fb923c, #fed7aa, #f97316);
  background-size: 300% 100%;
  box-shadow: 0 0 8px #f97316, 0 0 18px rgba(249,115,22,.6);
}
#bfg-portal-bar.bar-checking {
  background: linear-gradient(90deg, #38bdf8, #7dd3fc, #bae6fd, #38bdf8);
  background-size: 300% 100%;
  box-shadow: 0 0 8px #38bdf8, 0 0 18px rgba(56,189,248,.5);
  width: 100% !important; transition: width 0.35s ease;
}
#bfg-portal-bar.bar-error {
  background: linear-gradient(90deg, #ef4444, #f87171, #fecaca, #ef4444);
  background-size: 300% 100%;
  box-shadow: 0 0 8px #ef4444, 0 0 16px rgba(239,68,68,.5);
}
@keyframes bfgPortalShimmer {
  0%   { background-position: 0%   0%; }
  100% { background-position: 300% 0%; }
}
/* ── Refresh pill – countdown number ─────────────────────────── */
.prs-num {
  font-size: 1.05rem; font-weight: 900; color: #34d399;
  min-width: 1.6rem; text-align: right;
  font-variant-numeric: tabular-nums;
}
.prs-unit { opacity: .8; }
.portal-refresh-pill.is-paused .prs-num { color: #fde68a; }
.portal-refresh-pill.is-error  .prs-num { color: #fca5a5; }

/* ── Refresh pill – countdown progress bar ───────────────────── */
.portal-refresh-pill {
  position: relative;
  overflow: hidden;
}
#bfg-portal-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  border-radius: 0 0 999px 999px;
  background: #34d399;
  width: 100%;
  transition: width 0.25s linear, background 0.3s ease;
  pointer-events: none;
}
#bfg-portal-bar.bar-checking { background: #38bdf8; width: 100% !important; }
#bfg-portal-bar.bar-warn     { background: #f59e0b; }
#bfg-portal-bar.bar-error    { background: #ef4444; width: 100% !important; }

body.page-portal {
  align-items: flex-start;
  padding-top: max(1.5rem, env(safe-area-inset-top));
}

.portal-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

.portal-top {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  color: #fff;
}

.portal-top h1 {
  font-size: clamp(1.35rem, 4vw, 1.85rem);
  font-weight: 700;
}

.portal-meta {
  font-size: 0.95rem;
  opacity: 0.9;
  margin-top: 0.25rem;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.55rem 1.1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
}

.btn-logout:hover {
  background: rgba(255, 255, 255, 0.25);
}

.portal-lead {
  color: rgba(255, 255, 255, 0.92);
  font-size: 1.05rem;
  margin-bottom: 1.25rem;
  font-weight: 500;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 1rem;
}

.module-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 18px;
  padding: 1.35rem 1.25rem;
  text-decoration: none;
  color: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  min-height: 160px;
  overflow: visible;
}

.module-card--alert {
  padding-top: 1.65rem;
  padding-right: 1.1rem;
}

.module-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

.module-icon {
  font-size: 2rem;
  line-height: 1;
}

.module-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent, #1e3a5f);
}

.module-badge-wrap {
  position: absolute;
  top: -0.55rem;
  right: -0.45rem;
  z-index: 3;
  pointer-events: none;
}

.module-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  min-width: 3.1rem;
  min-height: 3.1rem;
  padding: 0.35rem 0.55rem;
  border-radius: 16px;
  color: #fff;
  font-weight: 800;
  line-height: 1;
  border: 3px solid #fff;
  box-shadow:
    0 6px 18px rgba(15, 23, 42, 0.22),
    0 2px 6px rgba(0, 0, 0, 0.12);
}

.module-badge-num {
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.module-badge-label {
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 0.95;
  white-space: nowrap;
}

.module-badge-danger {
  background: linear-gradient(145deg, #f87171 0%, #dc2626 48%, #b91c1c 100%);
  animation: module-badge-pulse 2.4s ease-in-out infinite;
}

.module-badge-warning {
  background: linear-gradient(145deg, #fbbf24 0%, #d97706 48%, #b45309 100%);
}

@keyframes module-badge-pulse {
  0%,
  100% {
    box-shadow:
      0 6px 18px rgba(220, 38, 38, 0.35),
      0 2px 6px rgba(0, 0, 0, 0.12);
  }
  50% {
    box-shadow:
      0 8px 22px rgba(220, 38, 38, 0.5),
      0 0 0 4px rgba(248, 113, 113, 0.28),
      0 2px 6px rgba(0, 0, 0, 0.12);
  }
}

@media (max-width: 480px) {
  .module-badge-wrap {
    top: -0.45rem;
    right: -0.35rem;
  }

  .module-badge {
    min-width: 2.85rem;
    min-height: 2.85rem;
    border-width: 2.5px;
    border-radius: 14px;
  }

  .module-badge-num {
    font-size: 1.1rem;
  }
}

.module-desc {
  font-size: 0.85rem;
  color: #64748b;
  flex: 1;
  line-height: 1.45;
}

.module-go {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--accent, #1e3a5f);
  margin-top: 0.25rem;
}

.portal-empty {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 14px;
  color: #991b1b;
  text-align: center;
}

.login-register-link {
  margin-top: 1.45rem;
  text-align: center;
  color: #64748b;
  font-size: 0.86rem;
  line-height: 1.5;
}

.login-register-link a {
  color: #059669;
  font-weight: 700;
  text-decoration: none;
}

.login-register-link a:hover {
  text-decoration: underline;
}

.portal-notify-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(10px);
}

.portal-notify-overlay.is-visible {
  display: flex;
}

.portal-notify-modal {
  position: relative;
  width: min(100%, 440px);
  background: #ffffff;
  color: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 18px;
  padding: 1.45rem;
  box-shadow: 0 26px 70px rgba(15, 23, 42, 0.34);
  animation: portal-notify-pop 0.22s ease-out;
}

.portal-notify-close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.portal-notify-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  margin-bottom: 0.85rem;
  border-radius: 16px;
  background: linear-gradient(145deg, #f87171, #dc2626);
  color: #fff;
  font-size: 1.65rem;
  font-weight: 900;
  box-shadow: 0 10px 26px rgba(220, 38, 38, 0.28);
}

.portal-notify-modal h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.25;
}

.portal-notify-subtitle {
  margin: 0.35rem 0 1rem;
  color: #64748b;
  font-size: 0.92rem;
  line-height: 1.45;
}

.portal-notify-list {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 1.1rem;
}

.portal-notify-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.portal-notify-item-title {
  min-width: 0;
  font-weight: 700;
  line-height: 1.35;
}

.portal-notify-item-count {
  flex: none;
  color: #dc2626;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.portal-notify-actions {
  display: flex;
  gap: 0.65rem;
}

.portal-notify-primary,
.portal-notify-secondary {
  min-height: 44px;
  border-radius: 12px;
  padding: 0.65rem 1rem;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.portal-notify-primary {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dc2626;
  color: #fff;
  border: 1px solid #dc2626;
}

.portal-notify-secondary {
  background: #fff;
  color: #334155;
  border: 1px solid #cbd5e1;
}

@keyframes portal-notify-pop {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 480px) {
  .portal-notify-modal {
    padding: 1.2rem;
    border-radius: 16px;
  }

  .portal-notify-actions {
    flex-direction: column;
  }

  .portal-notify-secondary {
    width: 100%;
  }
}
.portal-lead-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.portal-lead-row .portal-lead {
  margin-bottom: 0;
}

.portal-refresh-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 34px;
  min-width: 176px;
  padding: 0.35rem 0.72rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

.portal-refresh-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.portal-refresh-pill.is-checking .portal-refresh-dot {
  background: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}

.portal-refresh-pill.is-error .portal-refresh-dot {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18);
}

.portal-refresh-pill.is-paused .portal-refresh-dot {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}
#portalRefreshStatus.is-checking {
  color: #e0f2fe;
}

#portalRefreshStatus.is-error {
  color: #fecaca;
}

#portalRefreshStatus.is-paused {
  color: #fde68a;
}

@media (max-width: 640px) {
  .portal-lead-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .portal-refresh-pill {
    min-width: 0;
    width: 100%;
    justify-content: center;
  }
}