/* Full-screen auth shell (login → portal picker) */
body.fesmos-portal-auth-active {
  overflow: hidden;
}

body.fesmos-portal-auth-active .wrap {
  visibility: hidden;
  pointer-events: none;
}

.fesmos-portal-auth-shell {
  position: fixed;
  inset: 0;
  z-index: 50000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(180deg, #f8f6f3 0%, #efecea 100%);
}

.fesmos-portal-auth-shell[hidden] {
  display: none !important;
}

.fesmos-portal-auth-loading {
  text-align: center;
  max-width: 320px;
}

.fesmos-portal-auth-loading__spinner {
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  border: 3px solid rgba(139, 0, 0, 0.15);
  border-top-color: #8b0000;
  border-radius: 50%;
  animation: fesmos-dept-spin 0.75s linear infinite;
}

.fesmos-portal-auth-loading__title {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 600;
  color: #111010;
}

.fesmos-portal-auth-loading__sub {
  margin: 0;
  font-size: 13px;
  color: #6b6460;
}

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

/* Modal overlay (settings / in-app switch) */
.fesmos-dept-switch-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(12, 8, 8, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.fesmos-dept-switch-overlay.is-login-flow {
  z-index: 50001;
  background: linear-gradient(180deg, #f8f6f3 0%, #efecea 100%);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.fesmos-dept-switch-modal {
  width: min(440px, 100%);
  background: #fff;
  border: 1px solid #e4e0dd;
  border-radius: 18px;
  box-shadow:
    0 4px 24px rgba(40, 28, 24, 0.06),
    0 24px 60px rgba(40, 28, 24, 0.12);
  padding: 26px 24px 20px;
  animation: fesmos-dept-modal-in 0.28s ease-out;
}

.fesmos-dept-switch-overlay.is-login-flow .fesmos-dept-switch-modal {
  box-shadow:
    0 8px 32px rgba(40, 28, 24, 0.08),
    0 32px 80px rgba(40, 28, 24, 0.1);
}

@keyframes fesmos-dept-modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.fesmos-dept-switch-modal__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8b0000;
  background: rgba(139, 0, 0, 0.08);
  border-radius: 999px;
  padding: 5px 10px;
  margin-bottom: 12px;
}

.fesmos-dept-switch-modal h3 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #111010;
}

.fesmos-dept-switch-modal p {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.5;
  color: #6b6460;
}

.fesmos-dept-switch-error {
  display: none;
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  color: #991b1b;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.fesmos-dept-switch-error.is-visible {
  display: block;
}

.fesmos-dept-switch-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.fesmos-dept-switch-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 1.5px solid #e4e0dd;
  border-radius: 14px;
  padding: 14px 16px;
  background: #faf9f8;
  cursor: pointer;
  font: inherit;
  color: #111010;
  transition:
    border-color 0.15s,
    background 0.15s,
    box-shadow 0.15s;
}

.fesmos-dept-switch-option:hover {
  border-color: rgba(139, 0, 0, 0.45);
  background: #fff;
}

.fesmos-dept-switch-option.is-active {
  border-color: #8b0000;
  background: color-mix(in srgb, #8b0000 7%, #fff);
  box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.1);
}

.fesmos-dept-switch-option i.fa-building {
  color: #8b0000;
  width: 20px;
  text-align: center;
  font-size: 15px;
}

.fesmos-dept-switch-option span {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

.fesmos-dept-switch-option__check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #d4cfcc;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: transparent;
  font-size: 11px;
  transition:
    border-color 0.15s,
    background 0.15s,
    color 0.15s;
}

.fesmos-dept-switch-option.is-active .fesmos-dept-switch-option__check {
  border-color: #8b0000;
  background: #8b0000;
  color: #fff;
}

.fesmos-dept-switch-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.fesmos-dept-switch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 11px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
}

.fesmos-dept-switch-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.fesmos-dept-switch-btn--secondary {
  background: #f3f1ee;
  color: #3d3835;
  border: 1px solid #e4e0dd;
}

.fesmos-dept-switch-btn--primary {
  background: linear-gradient(135deg, #8b0000 0%, #6d0000 100%);
  color: #fff;
  min-width: 140px;
}

.fesmos-dept-switch-btn--primary:not(:disabled):hover {
  filter: brightness(1.05);
}

.fesmos-dept-switch-btn__spin {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: fesmos-dept-spin 0.65s linear infinite;
}

.fesmos-dept-switch-settings-card[hidden] {
  display: none !important;
}
