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

:root {
  --primary: #005E54;
  --primary-dark: #004D45;
  --secondary: #11BF85;
  --tertiary: #F3E98D;
  --light: #EBF9F5;
  --white: #ffffff;
  --bg: #f8fafb;
  --text: #1a2b3c;
  --text-dim: #5f7082;
  --text-light: #8b9bab;
  --border: #e2e8f0;
  --border-light: #f0f4f8;
  --red: #e74c3c;
  --red-bg: #fef2f2;
  --yellow: #f59e0b;
  --yellow-bg: #fffbeb;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Layout ─────────────────────────────────────────────── */

.portal {
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

.portal-header {
  text-align: center;
  margin-bottom: 40px;
}

.portal-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  text-decoration: none;
  color: var(--primary);
}

.portal-logo svg {
  color: var(--secondary);
}

.portal-logo span {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.portal-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.portal-header p {
  font-size: 15px;
  color: var(--text-dim);
  line-height: 1.5;
}

/* ── Steps Indicator ────────────────────────────────────── */

.steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 36px;
}

.step-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Reached steps double as back-navigation (see goToStep). Only these get the affordance. */
.step-item.clickable {
  cursor: pointer;
  border-radius: 8px;
}

.step-item.clickable:hover .step-num {
  border-color: var(--primary);
}

.step-item.clickable:hover .step-label {
  color: var(--primary);
}

.step-item.clickable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  border: 2px solid var(--border);
  color: var(--text-light);
  background: var(--white);
  transition: all 0.3s;
  flex-shrink: 0;
}

.step-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
  transition: color 0.3s;
  white-space: nowrap;
}

.step-line {
  width: 40px;
  height: 2px;
  background: var(--border);
  margin: 0 8px;
  transition: background 0.3s;
  flex-shrink: 0;
}

.step-item.active .step-num {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--white);
}

.step-item.active .step-label {
  color: var(--primary);
}

.step-item.done .step-num {
  border-color: var(--secondary);
  background: var(--secondary);
  color: var(--white);
}

.step-item.done .step-label {
  color: var(--secondary);
}

.step-line.done {
  background: var(--secondary);
}

/* ── Card ───────────────────────────────────────────────── */

.portal-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 32px;
  margin-bottom: 20px;
}

.portal-card h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.portal-card .card-desc {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 20px;
  line-height: 1.5;
}

/* ── Form Elements ──────────────────────────────────────── */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  font-size: 15px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--white);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 94, 84, 0.1);
}

.form-group input::placeholder {
  color: var(--text-light);
}

.form-group input:disabled {
  background: var(--bg);
  color: var(--text-dim);
  cursor: not-allowed;
}

/* ── Buttons ────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 24px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--primary);
  color: var(--white);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--light);
  color: var(--primary);
  border: 1.5px solid var(--secondary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--secondary);
  color: var(--white);
}

.btn-full {
  width: 100%;
}

.btn-start {
  background: var(--secondary);
  color: var(--white);
  font-size: 16px;
  padding: 14px 32px;
}

.btn-start:hover:not(:disabled) {
  background: #0ea874;
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.btn-ghost {
  background: none;
  color: var(--text-dim);
  padding: 8px 12px;
  font-size: 13px;
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--bg);
}

/* ── Site Connect Row ───────────────────────────────────── */

.site-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.site-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

.site-row .btn {
  flex-shrink: 0;
  height: 42px;
}

/* ── Connected Badge ────────────────────────────────────── */

.site-connected {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--light);
  border: 1.5px solid var(--secondary);
  border-radius: 10px;
}

.site-connected-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--secondary);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.site-connected-info {
  flex: 1;
  min-width: 0;
}

.site-connected-info .site-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-connected-info .site-url {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.site-connected .btn-disconnect {
  font-size: 12px;
  color: var(--text-light);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.site-connected .btn-disconnect:hover {
  color: var(--red);
  background: var(--red-bg);
}

/* ── Arrow Divider ──────────────────────────────────────── */

.arrow-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  color: var(--text-light);
}

/* ── Warning Banner ─────────────────────────────────────── */

.warning-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--yellow-bg);
  border: 1px solid #fde68a;
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: 13px;
  color: #92400e;
  line-height: 1.5;
}

.warning-banner svg {
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Error Banner ───────────────────────────────────────── */

.error-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--red-bg);
  border: 1px solid #fecaca;
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: 13px;
  color: #991b1b;
  line-height: 1.5;
}

.error-banner:empty {
  display: none;
}

/* ── Migration Summary ──────────────────────────────────── */

.migration-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.summary-item {
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
}

.summary-item .label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin-bottom: 4px;
}

.summary-item .value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ── Progress View ──────────────────────────────────────── */

.progress-view {
  display: none;
}

.progress-view.active {
  display: block;
}

.progress-header {
  text-align: center;
  margin-bottom: 28px;
}

.progress-header h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.progress-header p {
  font-size: 14px;
  color: var(--text-dim);
}

.progress-bar-container {
  background: var(--border-light);
  border-radius: 8px;
  height: 8px;
  margin-bottom: 28px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.5s ease;
  width: 0%;
}

.phase-list {
  list-style: none;
}

.phase-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.phase-item:last-child {
  border-bottom: none;
}

.phase-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--bg);
  color: var(--text-light);
  border: 1.5px solid var(--border);
}

.phase-item.completed .phase-icon {
  background: var(--light);
  color: var(--secondary);
  border-color: var(--secondary);
}

.phase-item.in_progress .phase-icon {
  background: #eef4ff;
  color: var(--primary);
  border-color: var(--primary);
  animation: pulse-phase 1.5s infinite;
}

.phase-item.failed .phase-icon {
  background: var(--red-bg);
  color: var(--red);
  border-color: var(--red);
}

.phase-item.skipped .phase-icon {
  background: var(--bg);
  color: var(--text-light);
  border-color: var(--border);
}

.phase-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  flex: 1;
}

.phase-item.pending .phase-name {
  color: var(--text-light);
}

.phase-status-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 3px 8px;
  border-radius: 6px;
}

.phase-item.pending .phase-status-badge {
  background: var(--bg);
  color: var(--text-light);
}

.phase-item.in_progress .phase-status-badge {
  background: #eef4ff;
  color: var(--primary);
}

.phase-item.completed .phase-status-badge {
  background: var(--light);
  color: var(--secondary);
}

.phase-item.failed .phase-status-badge {
  background: var(--red-bg);
  color: var(--red);
}

.phase-item.skipped .phase-status-badge {
  background: var(--bg);
  color: var(--text-light);
}

/* ── Completion View ────────────────────────────────────── */

.completion-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--light);
  color: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.completion-icon.failed {
  background: var(--red-bg);
  color: var(--red);
}

/* ── Spinner ────────────────────────────────────────────── */

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border-width: 1.5px;
}

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

@keyframes pulse-phase {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ── Tracking URL Bar ───────────────────────────────────── */

.track-url-bar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.track-url-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.track-url-row {
  display: flex;
  gap: 8px;
}

.track-url-row input {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  font-family: 'SF Mono', SFMono-Regular, Menlo, monospace;
}

.btn-copy {
  padding: 8px 14px;
  font-size: 13px;
}

/* ── Migration Info Bar ─────────────────────────────────── */

.migration-info-bar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.mig-flow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.mig-site {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.mig-flow svg {
  color: var(--text-light);
  flex-shrink: 0;
}

.mig-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mig-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--light);
  color: var(--primary);
}

.mig-badge-dim {
  background: var(--bg);
  color: var(--text-dim);
}

.mig-time {
  font-size: 12px;
  color: var(--text-light);
  margin-left: auto;
}

/* ── Status Banners ─────────────────────────────────────── */

.status-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  border: 1px solid;
}

.status-banner-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.status-banner-title {
  font-size: 15px;
  font-weight: 600;
}

.status-banner-desc {
  font-size: 13px;
  margin-top: 2px;
}

.status-banner-active {
  background: #f0fdf9;
  border-color: #a7f3d0;
}

.status-banner-active .status-banner-icon {
  background: var(--light);
  color: var(--primary);
}

.status-banner-active .status-banner-title { color: var(--primary); }
.status-banner-active .status-banner-desc { color: var(--text-dim); }

.status-banner-success {
  background: var(--light);
  border-color: var(--secondary);
}

.status-banner-success .status-banner-icon {
  background: var(--secondary);
  color: var(--white);
}

.status-banner-success .status-banner-title { color: var(--primary); }
.status-banner-success .status-banner-desc { color: var(--text-dim); }

.status-banner-error {
  background: var(--red-bg);
  border-color: #fecaca;
}

.status-banner-error .status-banner-icon {
  background: var(--red);
  color: var(--white);
}

.status-banner-error .status-banner-title { color: #991b1b; }
.status-banner-error .status-banner-desc { color: #b91c1c; }

.status-banner-warning {
  background: var(--yellow-bg);
  border-color: #fde68a;
}

.status-banner-warning .status-banner-icon {
  background: var(--yellow);
  color: var(--white);
}

.status-banner-warning .status-banner-title { color: #92400e; }
.status-banner-warning .status-banner-desc { color: #a16207; }

/* ── Progress Percentage Row ────────────────────────────── */

.progress-pct-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.progress-pct {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}

.progress-phases {
  font-size: 13px;
  color: var(--text-dim);
}

/* ── Hidden ─────────────────────────────────────────────── */

.hidden {
  display: none !important;
}

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 600px) {
  .portal {
    padding: 24px 16px 60px;
  }

  .portal-card {
    padding: 24px 20px;
  }

  .portal-header h1 {
    font-size: 22px;
  }

  .step-label {
    display: none;
  }

  .step-line {
    width: 24px;
  }

  .migration-summary {
    grid-template-columns: 1fr;
  }

  .site-row {
    flex-direction: column;
    align-items: stretch;
  }

  .site-row .btn {
    height: auto;
  }
}
