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

:root {
  --bg: #0a0e17;
  --surface: #111827;
  --surface-2: #1a2332;
  --border: #1e2d3d;
  --text: #e2e8f0;
  --text-dim: #8892a4;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.15);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.12);
  --yellow: #eab308;
  --yellow-dim: rgba(234, 179, 8, 0.12);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.12);
  --radius: 12px;
}

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

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.header-left { display: flex; flex-direction: column; gap: 4px; }

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
}

.logo h1 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}

.subtitle {
  font-size: 13px;
  color: var(--text-dim);
  margin-left: 38px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.poll-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--green);
  background: var(--green-dim);
  padding: 4px 10px;
  border-radius: 20px;
}

.pulse {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.last-updated {
  font-size: 12px;
  color: var(--text-dim);
}

/* Stats bar */
.stats-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-top: 6px;
}

.stat-card.completed .stat-value { color: var(--green); }
.stat-card.in-progress .stat-value { color: var(--yellow); }
.stat-card.failed .stat-value { color: var(--red); }
.stat-card.total .stat-value { color: var(--accent); }

/* Migration cards */
.migrations-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 40px;
}

.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
  font-size: 14px;
}

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-dim);
}

.empty-state svg {
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
}

/* Migration card */
.migration-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.migration-card:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}

.migration-card.status-in_progress {
  border-left: 3px solid var(--yellow);
}

.migration-card.status-completed {
  border-left: 3px solid var(--green);
}

.migration-card.status-failed {
  border-left: 3px solid var(--red);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.card-sites {
  flex: 1;
  min-width: 0;
}

.site-flow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.site-url {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-arrow {
  color: var(--accent);
  font-size: 16px;
  flex-shrink: 0;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 20px;
  flex-shrink: 0;
}

.status-badge.completed { background: var(--green-dim); color: var(--green); }
.status-badge.in_progress { background: var(--yellow-dim); color: var(--yellow); }
.status-badge.failed { background: var(--red-dim); color: var(--red); }
.status-badge.pending { background: var(--blue-dim); color: var(--blue); }

.status-badge .badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge.in_progress .badge-dot {
  animation: pulse 1.5s ease-in-out infinite;
}

/* Strategy tag */
.card-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.meta-tag {
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Phase progress */
.phases-bar {
  display: flex;
  gap: 3px;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.phase-segment {
  flex: 1;
  border-radius: 3px;
  transition: background 0.3s;
}

.phase-segment.completed { background: var(--green); }
.phase-segment.in_progress { background: var(--yellow); animation: phaseGlow 1.5s ease-in-out infinite; }
.phase-segment.pending { background: var(--border); }
.phase-segment.failed { background: var(--red); }

@keyframes phaseGlow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.phases-labels {
  display: flex;
  justify-content: space-between;
}

.phase-label {
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  flex: 1;
}

.phase-label.completed { color: var(--green); }
.phase-label.in_progress { color: var(--yellow); }

/* Timestamps */
.card-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-dim);
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  overflow-y: auto;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 700px;
  padding: 28px;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.modal-close:hover { color: var(--text); background: var(--surface-2); }

.modal h2 {
  font-size: 18px;
  margin-bottom: 20px;
  padding-right: 40px;
}

.modal .site-flow {
  margin-bottom: 20px;
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.detail-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.detail-item .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 3px;
}

.detail-item .value {
  font-size: 13px;
  word-break: break-all;
}

/* Phase detail list */
.phase-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.phase-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.phase-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

.phase-icon.completed { background: var(--green-dim); color: var(--green); }
.phase-icon.in_progress { background: var(--yellow-dim); color: var(--yellow); }
.phase-icon.pending { background: rgba(100,116,139,0.1); color: var(--text-dim); }
.phase-icon.failed { background: var(--red-dim); color: var(--red); }

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

.phase-name {
  font-size: 13px;
  font-weight: 500;
}

.phase-details {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phase-status-text {
  font-size: 11px;
  font-weight: 500;
  flex-shrink: 0;
}

.phase-status-text.completed { color: var(--green); }
.phase-status-text.in_progress { color: var(--yellow); }
.phase-status-text.pending { color: var(--text-dim); }

/* Notes section */
.notes-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.note-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.note-item .note-key {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 3px;
}

.note-item .note-value {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.4;
}

/* Responsive */
@media (max-width: 640px) {
  .stats-bar { flex-wrap: wrap; }
  .stat-card { min-width: calc(50% - 6px); }
  .site-flow { flex-direction: column; align-items: flex-start; gap: 4px; }
  .flow-arrow { transform: rotate(90deg); }
  .detail-grid { grid-template-columns: 1fr; }
  .card-header { flex-direction: column; gap: 10px; }
}
