:root {
  --tenant-primary: #0f838d;
  --tenant-secondary: #006d77;
  --bg-deep: #081126;
  --bg-soft: #f4f8ff;
  --text-main: #13233f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Outfit", sans-serif;
  min-height: 100vh;
  color: var(--text-main);
  background: radial-gradient(circle at 12% 20%, #e6efff 0%, #f7f9ff 40%, #ffffff 100%);
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(6px);
  opacity: 0.35;
  z-index: 0;
  animation: float 8s ease-in-out infinite;
}

.bg-orb-a {
  width: 260px;
  height: 260px;
  background: var(--tenant-primary);
  top: -60px;
  right: -40px;
}

.bg-orb-b {
  width: 320px;
  height: 320px;
  background: var(--tenant-secondary);
  bottom: -140px;
  left: -80px;
  animation-delay: 1.5s;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(640px, 95vw);
  margin: 28px auto;
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.brand-header-text {
  flex: 1;
}

.btn-change-tenant {
  flex-shrink: 0;
  font-size: 0.85rem;
  padding: 8px 14px;
}

.brand-header h1 {
  margin: 0 0 2px;
  line-height: 1.1;
}

.brand-header p {
  margin: 0;
  line-height: 1.2;
  color: #6b7280;
}

.logo-wrap {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--tenant-primary), var(--tenant-secondary));
  display: grid;
  place-items: center;
  box-shadow: 0 18px 30px rgba(13, 20, 40, 0.25);
}

.tenant-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
}

.logo-fallback {
  color: #fff;
  font-weight: 700;
  letter-spacing: 1px;
}

.hidden {
  display: none;
}

.notice-warning {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fefce8;
  border-left: 4px solid #eab308;
  border-radius: 8px;
  padding: 11px 16px;
  margin-bottom: 18px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #713f12;
}

.notice-icon {
  font-size: 1.1rem;
  color: #eab308;
  flex-shrink: 0;
}

.card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(24, 35, 70, 0.08);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 12px 35px rgba(10, 18, 34, 0.12);
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
  font-weight: 500;
  align-content: start;
  position: relative;
}

input,
select {
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid #ccd8ef;
  background: #f9fbff;
  font: inherit;
  height: 44px;
  transition: border-color 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

/* Remove ícones nativos de autofill/senha do Chrome */
input::-webkit-contacts-auto-fill-button,
input::-webkit-credentials-auto-fill-button,
input::-webkit-strong-password-auto-fill-button {
  display: none !important;
  visibility: hidden;
  pointer-events: none;
}

input:focus,
select:focus {
  outline: 2px solid color-mix(in srgb, var(--tenant-primary) 55%, #fff);
  border-color: transparent;
  background: #fff;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #f9fbff inset;
  box-shadow: 0 0 0 1000px #f9fbff inset;
  -webkit-text-fill-color: var(--text-main);
  border-color: #ccd8ef;
  transition: background-color 0s 99999s;
}

input.input-invalid,
select.input-invalid {
  border-color: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.18);
}

.input-wrap {
  position: relative;
}

.input-wrap input,
.input-wrap select {
  width: 100%;
  padding-right: 36px;
}

.input-wrap select {
  appearance: none;
  -webkit-appearance: none;
  background: #f9fbff;
  cursor: pointer;
}

.input-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9aa5be;
  pointer-events: none;
  font-size: 0.88rem;
}

.btn-label {
  display: grid;
  gap: 6px;
}

.btn-label .btn-primary {
  width: 100%;
}

.field-error {
  position: absolute;
  top: 100%;
  left: 0;
  font-size: 0.72rem;
  color: #dc2626;
  line-height: 1;
  margin-top: 2.5px;
  white-space: nowrap;
}

.btn-primary,
.btn-ghost {
  border: 0;
  padding: 12px 16px;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, var(--tenant-primary), var(--tenant-secondary));
  color: #fff;
  border: 1px solid transparent;
  padding: 11px 16px;
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-ghost {
  background: #ebf0ff;
  color: #1d2c4a;
}

.feedback {
  margin-top: 14px;
  font-weight: 600;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(4, 12, 30, 0.55);
  backdrop-filter: blur(3px);
  z-index: 5;
}

.modal.is-open {
  display: grid;
}

.modal-card {
  width: min(560px, 90vw);
  background: #fff;
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 20px 45px rgba(6, 18, 45, 0.35);
  animation: pop 180ms ease-out;
}

.tenant-options {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.tenant-item {
  border: 1px solid #dde5f7;
  background: #fff;
  color: #12233f;
  border-radius: 12px;
  padding: 11px;
  text-align: left;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tenant-item:hover {
  border-color: var(--tenant-primary);
  transform: translateY(-1px);
}

/* Skeleton de carregamento dos tenants */
.tenant-skeleton {
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(90deg, #eef1f8 25%, #dde3f0 50%, #eef1f8 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.3s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@media (max-width: 760px) {
  .grid-form {
    grid-template-columns: 1fr;
  }

  .app-shell {
    margin-top: 14px;
  }
}

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

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(12px);
  }
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #131c32;
  color: #dde5f7;
  border-radius: 10px;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.92rem;
  font-weight: 500;
  box-shadow: 0 8px 28px rgba(4, 12, 30, 0.5);
  z-index: 999;
  min-width: 260px;
  max-width: min(480px, 90vw);
  pointer-events: auto;
  cursor: default;
  animation: toast-in 220ms ease-out;
}

.toast.toast-out {
  animation: toast-out 300ms ease-in forwards;
}

.toast-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.toast-dot-success {
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.65);
}

.toast-dot-error {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.65);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
}

/* =========================================================
   Success / Already-Exists Popup
   ========================================================= */

.success-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(4, 12, 30, 0.72);
  backdrop-filter: blur(6px);
  z-index: 200;
  animation: so-fade-in 220ms ease-out;
}

.success-overlay.is-closing {
  animation: so-fade-out 200ms ease-in forwards;
}

.success-card {
  position: relative;
  width: min(440px, 92vw);
  background: #fff;
  border-radius: 28px;
  padding: 40px 32px 30px;
  box-shadow: 0 28px 70px rgba(4, 12, 30, 0.45);
  text-align: center;
  overflow: hidden;
  animation: so-pop 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.success-overlay.is-closing .success-card {
  animation: so-pop-out 200ms ease-in forwards;
}

.success-confetti-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.success-icon-wrap {
  width: 92px;
  height: 92px;
  margin: 0 auto 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  animation: so-icon-pop 360ms cubic-bezier(0.34, 1.56, 0.64, 1) 80ms both;
}

.success-icon-wrap.is-success {
  background: linear-gradient(135deg, #22c55e, #15803d);
  box-shadow: 0 14px 36px rgba(34, 197, 94, 0.42);
}

.success-icon-wrap.is-existing {
  background: linear-gradient(135deg, #f59e0b, #b45309);
  box-shadow: 0 14px 36px rgba(245, 158, 11, 0.42);
}

.success-icon-wrap svg {
  width: 46px;
  height: 46px;
  color: #fff;
}

.success-title {
  font-size: 1.55rem;
  font-weight: 700;
  color: #0f1b2e;
  margin: 0 0 6px;
  line-height: 1.2;
}

.success-subtitle {
  font-size: 0.92rem;
  color: #6b7280;
  margin: 0 0 24px;
}

.success-codcli-wrap {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: #f4f8ff;
  border: 1.5px solid #ccd8ef;
  border-radius: 16px;
  padding: 12px 20px;
  margin-bottom: 26px;
}

.success-codcli-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}

.success-codcli-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #9aa5be;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.success-codcli-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--tenant-primary);
  letter-spacing: -0.03em;
  line-height: 1;
}

.success-copy-btn {
  background: none;
  border: 1.5px solid #ccd8ef;
  border-radius: 10px;
  cursor: pointer;
  padding: 8px 10px;
  color: #9aa5be;
  transition: color 150ms, border-color 150ms, background 150ms;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.success-copy-btn:hover {
  color: var(--tenant-primary);
  border-color: var(--tenant-primary);
  background: #f0f7ff;
}

.success-copy-btn.copied {
  color: #22c55e;
  border-color: #22c55e;
  background: #f0fdf4;
}

.success-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.success-actions .btn-primary {
  flex: 1;
  max-width: 200px;
}

.success-actions .btn-ghost {
  flex: 1;
  max-width: 150px;
}

@keyframes so-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes so-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes so-pop {
  from {
    transform: scale(0.82) translateY(20px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

@keyframes so-pop-out {
  from {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
  to {
    transform: scale(0.9) translateY(10px);
    opacity: 0;
  }
}

@keyframes so-icon-pop {
  from {
    transform: scale(0);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

