/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand-primary: #1a1a2e;
  --brand-accent:  #e94560;
  --brand-light:   #f4f6fb;
  --text-dark:     #1a1a2e;
  --text-mid:      #555e6d;
  --text-light:    #8a92a2;
  --border:        #e2e8f0;
  --success:       #22c55e;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --white:         #ffffff;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
  --shadow-md:     0 4px 16px rgba(0,0,0,.10);
  --radius:        12px;
  --radius-sm:     8px;
  --transition:    0.2s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--brand-light);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Layout ─────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
}

main.container {
  flex: 1;
  padding-top: 32px;
  padding-bottom: 48px;
}

/* ── Header ─────────────────────────────────────────────────── */
.site-header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 14px;
}

.site-header .logo {
  height: 32px;
  width: auto;
}

.header-tagline {
  font-size: 14px;
  color: var(--text-mid);
  font-weight: 500;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.card-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

/* ── Welcome Card ───────────────────────────────────────────── */
.welcome-card h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.welcome-card p {
  color: var(--text-mid);
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.progress-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#progressText {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-accent);
}

.progress-bar-wrapper {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-accent), #ff6b6b);
  border-radius: 99px;
  transition: width 0.6s ease;
}

/* ── Integrations Grid ──────────────────────────────────────── */
.integrations-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.integration-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  border: 1.5px solid var(--border);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.integration-card.is-connected {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.integration-card.is-failed {
  border-color: #fecaca;
  background: #fff5f5;
}

.integration-card.is-progress {
  border-color: #fde68a;
  background: #fffbeb;
}

.integration-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.integration-logo {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.integration-info {
  flex: 1;
}

.integration-info h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 2px;
}

.integration-desc {
  font-size: 13px;
  color: var(--text-light);
}

/* Status badges */
.status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

.status-pending    { background: #f1f5f9; color: var(--text-light); }
.status-in_progress { background: #fef9c3; color: #854d0e; }
.status-completed  { background: #dcfce7; color: #166534; }
.status-failed     { background: #fee2e2; color: #991b1b; }

/* Account info (shown after connect) */
.integration-account {
  margin: 12px 0 0 54px;
  font-size: 13px;
  color: var(--text-mid);
}

.integration-account:empty { display: none; }

/* Actions */
.integration-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity var(--transition), transform var(--transition);
  text-decoration: none;
}

.btn:hover  { opacity: 0.88; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }

.btn-connect {
  background: var(--brand-accent);
  color: var(--white);
}

.btn-reconnect {
  background: transparent;
  color: var(--brand-accent);
  border: 1.5px solid var(--brand-accent);
  font-size: 13px;
  padding: 7px 16px;
}

.btn-done {
  background: var(--success);
  color: var(--white);
  pointer-events: none;
}

/* ── Done Card ──────────────────────────────────────────────── */
.done-card {
  text-align: center;
  padding: 40px 28px;
  border: 1.5px solid #bbf7d0;
  background: #f0fdf4;
}

.done-card h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 10px;
  color: #166534;
}

.done-card p {
  color: var(--text-mid);
  font-size: 15px;
  line-height: 1.6;
}

/* ── Error Page ─────────────────────────────────────────────── */
.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--brand-light);
}

.error-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 40px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-md);
}

.error-card .logo {
  height: 40px;
  margin-bottom: 24px;
}

.error-card h1 {
  font-size: 22px;
  margin-bottom: 12px;
  color: var(--text-dark);
}

.error-card p {
  color: var(--text-mid);
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 8px;
}

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 16px 0;
  margin-top: auto;
}

.site-footer p {
  font-size: 12px;
  color: var(--text-light);
  text-align: center;
}

.site-footer a {
  color: var(--text-light);
  text-decoration: none;
}
.site-footer a:hover { color: var(--brand-accent); }

/* ── Toast notification ─────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text-dark);
  color: var(--white);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  transition: transform 0.3s ease;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.toast-success { background: #166534; }
.toast.toast-error   { background: #991b1b; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 480px) {
  .card, .integration-card { padding: 18px 16px; }
  .integration-account { margin-left: 0; }
  .integration-header { flex-wrap: wrap; }
  .integration-status { order: -1; width: 100%; margin-bottom: 6px; }
}
