.auth-actions {
  position: relative !important;
  z-index: 2147483647 !important;
}

.auth-panel {
  display: none;
  width: 360px;
  max-height: calc(100vh - 76px);
  overflow: auto;
  background: #fff;
  border: 1px solid #d8dee8;
  border-radius: 14px;
  box-shadow: 0 18px 45px rgba(15,23,42,.22);
  padding: 16px;
  z-index: 2147483647 !important;
  color: #172033;
  box-sizing: border-box;
  font-family: Arial, "Segoe UI", sans-serif;
}

#authPanel,
#authPanel.open {
  position: fixed !important;
  top: 54px !important;
  right: 14px !important;
  z-index: 2147483647 !important;
}

#authPanel.open {
  display: block !important;
}

#authPanel:not(.open) {
  display: none !important;
}

.auth-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: 0;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
}

.auth-close:hover {
  color: #0f172a;
}

.auth-title {
  font-weight: 800;
  margin: 2px 34px 8px 0;
  font-size: 16px;
}

.auth-small {
  font-size: 13px;
  color: #475569;
  line-height: 1.35;
}

.auth-intro {
  margin: 0 0 12px;
}

.auth-form {
  display: none;
  flex-direction: column;
  gap: 10px;
}

.auth-form.active {
  display: flex;
}

.auth-form label,
.auth-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: #172033;
}

.auth-form label span {
  font-weight: 400;
  color: #64748b;
}

.auth-form input,
.auth-form textarea,
.auth-inline-row input {
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  padding: 9px 10px;
  font-size: 13px;
  box-sizing: border-box;
  width: 100%;
  background: #fff;
  color: #0f172a;
}

.auth-form input:focus,
.auth-form textarea:focus,
.auth-inline-row input:focus {
  outline: none;
  border-color: #2196F3;
  box-shadow: 0 0 0 3px rgba(33,150,243,.16);
}

.auth-form textarea {
  min-height: 62px;
  resize: vertical;
}

#loginIdentityDisplay:disabled {
  background: #f8fafc;
  color: #475569;
  cursor: not-allowed;
}

.auth-inline-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
}

.auth-ok {
  min-width: 58px;
  height: 36px;
  padding: 0 13px !important;
}

.auth-next-form {
  border-top: 1px solid #e2e8f0;
  padding-top: 12px;
}

.auth-free-title {
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 9px 10px;
}

.auth-check {
  flex-direction: row !important;
  align-items: flex-start;
  font-weight: 500 !important;
  line-height: 1.3;
}

.auth-check input {
  width: auto !important;
  margin-top: 1px;
}

.auth-primary,
.auth-secondary {
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.auth-primary {
  background: #2196F3;
  color: #fff;
}

.auth-primary:hover {
  background: #0b7fd1;
}

.auth-primary:disabled,
.auth-secondary:disabled {
  opacity: .65;
  cursor: wait;
}

.auth-secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.auth-secondary:hover {
  background: #e2e8f0;
}

.auth-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}

.auth-status {
  display: none;
  margin: 24px 0 10px;
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 12px;
  line-height: 1.35;
}

.auth-status.show {
  display: block;
}

.auth-status.ok {
  background: #dcfce7;
  color: #166534;
}

.auth-status.err {
  background: #fee2e2;
  color: #991b1b;
}

.auth-success-panel {
  display: none;
  text-align: center;
  padding: 8px 4px 2px;
}

.auth-success-panel.show {
  display: block;
}

.auth-success-icon {
  width: 44px;
  height: 44px;
  margin: 8px auto 10px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 900;
}

.auth-success-title {
  font-size: 17px;
  font-weight: 900;
  color: #0f172a;
  margin-bottom: 6px;
}

.auth-success-panel p {
  margin: 6px 0;
  color: #475569;
  font-size: 13px;
  line-height: 1.45;
}

.auth-success-panel .auth-primary {
  margin-top: 12px;
  width: 100%;
}

.ribbon,
.topbar,
.headerbar,
.actions {
  overflow: visible !important;
}

/* Compact lookup-first panel */
#authPanel .auth-title,
#authPanel .auth-intro {
  display: none !important;
}

#authPanel .auth-status {
  margin-top: 2px !important;
}

#authLookupForm {
  padding-top: 4px;
}

/* Save/Open required-login modal */
#authPanel.auth-required-modal,
#authPanel.auth-required-modal.open {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-50%, -50%) !important;
  display: block !important;

  width: min(380px, calc(100vw - 32px)) !important;
  max-height: calc(100vh - 48px) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;

  background: #ffffff !important;
  border: 1px solid #d8dee8 !important;
  border-radius: 14px !important;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.35) !important;
  padding: 16px !important;
  margin: 0 !important;
  z-index: 2147483647 !important;

  scrollbar-width: none !important;
}

#authPanel.auth-required-modal::-webkit-scrollbar {
  display: none !important;
}

#authPanel.auth-required-modal::before {
  content: "";
  position: fixed;
  inset: -100vmax;
  background: rgba(255, 255, 255, 0.45);
  z-index: -1;
  pointer-events: none;
}

#authPanel.auth-required-modal #authStatus.show {
  display: block !important;
  margin: 0 0 14px !important;
  padding: 10px 12px !important;
  border-radius: 10px !important;
  font-size: 13px !important;
}

@media (max-width: 520px) {
  #authPanel,
  #authPanel.open {
    right: 8px !important;
    left: 8px !important;
    width: auto !important;
  }

  #authPanel.auth-required-modal,
  #authPanel.auth-required-modal.open {
    left: 50% !important;
    right: auto !important;
    width: calc(100vw - 32px) !important;
  }
}