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

:root {
  --navy:   #0F4C81;
  --navy-dark: #0a3560;
  --teal:   #00A67E;
  --teal-dark: #008f6b;
  --amber:  #f59e0b;
  --red:    #ef4444;
  --green:  #22c55e;
  --slate-50:  #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-900: #0f172a;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
}

html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--slate-50);
  color: var(--slate-900);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Layout ───────────────────────────────────────────────────────────────── */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
  color: white;
  padding: 0 28px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-logo {
  width: 34px; height: 34px;
  background: var(--teal);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: white;
  flex-shrink: 0;
}
.topbar-name { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.topbar-sub  { font-size: 11px; opacity: 0.65; margin-top: 1px; }

.topbar-right { display: flex; align-items: center; gap: 16px; font-size: 12px; opacity: 0.8; }
.topbar-right .migration-id { font-family: var(--mono); opacity: 0.7; }

.main { flex: 1; padding: 24px 28px; display: grid; grid-template-columns: 1fr 340px; gap: 20px; max-width: 1400px; margin: 0 auto; width: 100%; }

/* ── Status Banner ────────────────────────────────────────────────────────── */
.status-banner {
  grid-column: 1 / -1;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--slate-200);
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}
.status-left { display: flex; align-items: center; gap: 16px; }
.status-orb {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.orb-idle       { background: var(--slate-100); color: var(--slate-500); }
.orb-extracting { background: #dbeafe; color: #1d4ed8; animation: pulse 2s infinite; }
.orb-transforming{ background: #ede9fe; color: #7c3aed; animation: pulse 2s infinite; }
.orb-awaiting   { background: #fef3c7; color: #b45309; }
.orb-importing  { background: #dcfce7; color: #15803d; animation: pulse 2s infinite; }
.orb-complete   { background: #dcfce7; color: #15803d; }
.orb-failed     { background: #fee2e2; color: #dc2626; }

@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.6; } }

.status-label { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.status-sub   { font-size: 13px; color: var(--slate-500); margin-top: 2px; }

.status-right { display: flex; gap: 10px; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 13px 18px;
  border-bottom: 1px solid var(--slate-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--slate-50);
}
.card-title { font-size: 13px; font-weight: 700; color: var(--navy); text-transform: uppercase; letter-spacing: 0.05em; }
.card-body  { padding: 16px 18px; }

/* ── Progress Bars ────────────────────────────────────────────────────────── */
.phase-list { display: flex; flex-direction: column; gap: 12px; }
.phase-item {}
.phase-row  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.phase-name { font-size: 13px; font-weight: 600; }
.phase-count{ font-size: 12px; color: var(--slate-500); }
.progress-track { height: 6px; background: var(--slate-100); border-radius: 99px; overflow: hidden; }
.progress-fill  { height: 100%; background: var(--teal); border-radius: 99px; transition: width 0.4s ease; }
.progress-fill.complete  { background: var(--teal); }
.progress-fill.pending   { background: var(--slate-200); }
.progress-fill.failed    { background: var(--red); }
.progress-fill.running   { background: var(--navy); animation: shimmer 1.5s infinite; }

@keyframes shimmer {
  0%   { opacity: 1; }
  50%  { opacity: 0.6; }
  100% { opacity: 1; }
}

/* ── Object Count Grid ───────────────────────────────────────────────────── */
.object-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.obj-card {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: 6px;
  padding: 12px 14px;
}
.obj-label { font-size: 11px; font-weight: 600; color: var(--slate-500); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.obj-row   { display: flex; justify-content: space-between; font-size: 12px; color: var(--slate-600); margin-top: 3px; }
.obj-row span:last-child { font-weight: 700; color: var(--slate-900); }
.obj-row.imported span:last-child { color: var(--teal); }
.obj-row.failed   span:last-child { color: var(--red); }

/* ── Log Feed ─────────────────────────────────────────────────────────────── */
.log-feed {
  height: 320px;
  overflow-y: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.7;
  padding: 10px 14px;
  background: #0d1117;
  color: #e6edf3;
}
.log-feed::-webkit-scrollbar { width: 5px; }
.log-feed::-webkit-scrollbar-track { background: transparent; }
.log-feed::-webkit-scrollbar-thumb { background: #30363d; border-radius: 99px; }

.log-line { display: flex; gap: 8px; }
.log-ts    { color: #484f58; flex-shrink: 0; }
.log-event { color: #58a6ff; font-weight: 600; flex-shrink: 0; }
.log-body.info    { color: #e6edf3; }
.log-body.warn    { color: #d29922; }
.log-body.error   { color: #f85149; }
.log-body.success { color: #3fb950; }
.log-body.debug   { color: #484f58; }

/* ── Exceptions Panel ────────────────────────────────────────────────────── */
.exception-list { display: flex; flex-direction: column; gap: 8px; max-height: 240px; overflow-y: auto; }
.exception-item {
  display: flex; align-items: flex-start; gap: 10px;
  background: #fff8f1;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
}
.exc-icon  { font-size: 14px; flex-shrink: 0; padding-top: 1px; }
.exc-title { font-weight: 600; color: var(--slate-800); }
.exc-sub   { color: var(--slate-500); font-size: 11px; margin-top: 2px; word-break: break-all; }

/* ── Approval Panel ──────────────────────────────────────────────────────── */
.approval-panel {
  background: white;
  border: 2px solid var(--teal);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow-md);
}
.approval-panel h3 { font-size: 16px; font-weight: 700; color: var(--navy); margin-bottom: 8px; }
.approval-panel p  { font-size: 13px; color: var(--slate-500); margin-bottom: 18px; }
.approval-buttons  { display: flex; gap: 10px; justify-content: center; }

/* ── Manual Steps Panel ──────────────────────────────────────────────────── */
.checklist-compact { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; }
.cl-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: 5px; background: var(--slate-50); border: 1px solid var(--slate-200); }
.cl-check { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; accent-color: var(--teal); }
.cl-body  { flex: 1; }
.cl-title { font-size: 12px; font-weight: 600; }
.cl-priority { font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 8px; margin-left: 6px; }
.cl-priority.critical { background: #fee2e2; color: #991b1b; }
.cl-priority.high     { background: #fef3c7; color: #92400e; }
.cl-priority.medium   { background: #dbeafe; color: #1e40af; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  padding: 9px 20px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary   { background: var(--teal); color: white; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-danger    { background: white; color: var(--red); border: 2px solid var(--red); }
.btn-danger:hover  { background: #fee2e2; }
.btn-ghost     { background: white; color: var(--slate-600); border: 1px solid var(--slate-200); }
.btn-ghost:hover   { background: var(--slate-50); }
.btn:disabled  { opacity: 0.45; cursor: not-allowed; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.badge-idle      { background: var(--slate-100); color: var(--slate-600); }
.badge-running   { background: #dbeafe; color: #1d4ed8; }
.badge-complete  { background: #dcfce7; color: #15803d; }
.badge-failed    { background: #fee2e2; color: #dc2626; }
.badge-awaiting  { background: #fef3c7; color: #b45309; }

/* ── Report iframe ───────────────────────────────────────────────────────── */
.report-frame {
  width: 100%;
  border: none;
  border-radius: var(--radius);
  min-height: 600px;
  box-shadow: var(--shadow-md);
}

/* ── Empty States ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--slate-400);
  font-size: 13px;
}
.empty-state-icon { font-size: 28px; margin-bottom: 8px; }

/* ── Utilities ───────────────────────────────────────────────────────────── */
.hidden   { display: none !important; }
.flex-row { display: flex; align-items: center; gap: 8px; }
.ml-auto  { margin-left: auto; }
.text-teal  { color: var(--teal); }
.text-red   { color: var(--red); }
.text-amber { color: var(--amber); }
.text-muted { color: var(--slate-500); }
.mono { font-family: var(--mono); }
.bold { font-weight: 700; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }

/* ── Right sidebar ────────────────────────────────────────────────────────── */
.sidebar { display: flex; flex-direction: column; gap: 16px; }
.left-col { display: flex; flex-direction: column; gap: 16px; }

/* ── Report panel overlay ────────────────────────────────────────────────── */
.report-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,76,129,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.report-modal {
  background: white;
  border-radius: 10px;
  width: 100%;
  max-width: 1100px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.report-modal-header {
  padding: 14px 20px;
  background: var(--navy);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.report-modal-header h2 { font-size: 15px; font-weight: 700; }
.report-modal-body { flex: 1; overflow: auto; }

/* ── Completion Panel ────────────────────────────────────────────────────── */
.completion-panel {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-dark) 100%);
  color: white;
  border-radius: var(--radius);
  padding: 28px 32px;
  display: flex;
  align-items: center;
  gap: 24px;
  box-shadow: var(--shadow-md);
}
.completion-icon { font-size: 48px; flex-shrink: 0; }
.completion-title { font-size: 22px; font-weight: 800; }
.completion-sub   { font-size: 14px; opacity: 0.85; margin-top: 4px; }
.completion-actions { margin-left: auto; display: flex; gap: 10px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .main { grid-template-columns: 1fr; }
  .object-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .main { padding: 12px; }
  .object-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 14px; }
}

/* ── Demo mode banner ─────────────────────────────────────────────────── */
#demo-banner {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; gap: 18px;
  background: #f59e0b; color: #451a03;
  padding: 10px 16px; font-size: 14px; font-weight: 600;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.demo-run-btn {
  background: #451a03; color: #fbbf24; border: none; border-radius: 6px;
  padding: 6px 14px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.demo-run-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.demo-banner-link { color: #451a03; font-size: 13px; text-decoration: underline; }
