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

:root {
  --bg: #090B10;
  --card-bg: #1A1D24;
  --card-border: rgba(255, 255, 255, 0.05);
  --accent: #00c2a8;
  --accent-hover: #00a891;
  --text: #ffffff;
  --text-muted: #8C99A8;
  --input-bg: #0e1116;
  --input-border: rgba(255, 255, 255, 0.1);
  --input-focus: #00c2a8;
  --error: #ff5c5c;
  --success: #00c2a8;
  --radius: 24px;
  --radius-btn: 8px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background-image: radial-gradient(circle at center, rgba(0, 194, 168, 0.03) 0%, rgba(9, 11, 16, 1) 70%);
}

.container {
  width: 100%;
  max-width: 480px;
}

/* ── Screens ── */
.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.screen.hidden {
  display: none;
}

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

/* ── Card ── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
}

/* ── Logo ── */
.logo-area {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 0 0 16px;
}

.logo {
  height: 40px;
  max-width: 100%;
  object-fit: contain;
}

/* ── Label/Tag ── */
.tag {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: -16px;
}

/* ── Typography ── */
h1 {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.01em;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
}

/* ── Form ── */
form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}

.input-group {
  width: 100%;
}

input[type="text"],
input[type="tel"] {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-btn);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  padding: 16px;
  outline: none;
  transition: all 0.2s ease;
}

input[type="text"]:focus,
input[type="tel"]:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(0, 194, 168, 0.15);
}

input::placeholder {
  color: #4a5568;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 16px 24px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: #000;
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 8px 24px rgba(0, 194, 168, 0.2);
}

.btn-outline {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-muted);
}

.btn-outline:hover {
  border-color: var(--text);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 8px 16px;
  margin-top: 8px;
}

.btn-ghost:hover {
  color: var(--accent);
}

/* ── Method selector ── */
.method-selector {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.method-buttons {
  display: flex;
  gap: 12px;
  width: 100%;
}

.btn-method {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-muted);
  border-radius: 12px;
  padding: 18px 12px;
  flex-direction: column;
  gap: 10px;
  font-size: 0.9rem;
}

.btn-method:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Instance badge ── */
.instance-name-badge {
  background: rgba(0, 194, 168, 0.1);
  border: 1px solid rgba(0, 194, 168, 0.2);
  border-radius: var(--radius-btn);
  padding: 8px 16px;
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
}

/* ── Connect content ── */
.connect-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.connect-content.hidden {
  display: none;
}

/* ── Loader ── */
.loader-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.loader-area.hidden { display: none; }

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(0, 194, 168, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

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

/* Loader inline em botões */
.btn-loader {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(0,0,0,0.15);
  border-top-color: #000;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

.btn-loader.hidden { display: none; }

/* ── QR Code ── */
.qr-wrapper {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(255,255,255,0.05);
}

#qr-image {
  width: 240px;
  height: 240px;
  display: block;
}

.status-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
}

.timer-text {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 500;
  text-align: center;
  margin-top: -8px;
}

/* ── Pair code ── */
.paircode-display {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-btn);
  padding: 24px;
  text-align: center;
  width: 100%;
}

#paircode-value {
  font-family: 'Courier New', Courier, monospace;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.2em;
}

/* ── Success ── */
#content-success {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
  padding: 16px 0;
}

.success-icon {
  width: 80px;
  height: 80px;
  background: rgba(0, 194, 168, 0.1);
  border: 2px solid var(--success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--success);
  margin-bottom: 8px;
  box-shadow: 0 0 24px rgba(0, 194, 168, 0.2);
}

/* ── Error ── */
.error-msg {
  font-size: 0.85rem;
  color: var(--error);
  text-align: left;
  padding: 0 4px;
  margin-top: -8px;
  align-self: flex-start;
}

.error-msg.hidden { display: none; }

.error-icon {
  width: 64px;
  height: 64px;
  background: rgba(255, 92, 92, 0.1);
  border: 2px solid var(--error);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: var(--error);
}

.error-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── Hidden utility ── */
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 480px) {
  .card {
    padding: 40px 24px;
  }

  h1 { font-size: 1.75rem; }

  #paircode-value {
    font-size: 2rem;
  }

  #qr-image {
    width: 200px;
    height: 200px;
  }
}
