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

:root {
  --primary:        #4f46e5;
  --primary-light:  #eef2ff;
  --primary-hover:  #4338ca;
  --success:        #059669;
  --success-light:  #d1fae5;
  --success-hover:  #047857;
  --danger:         #dc2626;
  --danger-light:   #fee2e2;
  --warning:        #d97706;
  --warning-light:  #fef3c7;
  --bg:             #f8fafc;
  --card-bg:        #ffffff;
  --text:           #0f172a;
  --text-2:         #334155;
  --muted:          #64748b;
  --border:         #e2e8f0;
  --border-2:       #cbd5e1;
  --radius:         16px;
  --radius-sm:      10px;
  --shadow-sm:      0 1px 4px rgba(0,0,0,.06);
  --shadow:         0 4px 24px rgba(0,0,0,.08);
  --shadow-lg:      0 8px 40px rgba(0,0,0,.12);
}

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 15px;
  line-height: 1.6;
}

/* ── Header ─────────────────────────────────────────────────────── */
header {
  background: linear-gradient(135deg, #312e81 0%, #4f46e5 50%, #7c3aed 100%);
  color: #fff;
  padding: 2.5rem 1.5rem 2rem;
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.logo-icon {
  font-size: 2.4rem;
  line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.3));
}

.logo-text {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.1;
}

.tagline {
  font-size: .95rem;
  opacity: .85;
  margin-top: .2rem;
}

.feature-pills {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.pill {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 999px;
  padding: .3rem .85rem;
  font-size: .8rem;
  font-weight: 500;
  backdrop-filter: blur(4px);
  white-space: nowrap;
}

/* ── Main ───────────────────────────────────────────────────────── */
main {
  flex: 1;
  max-width: 960px;
  margin: 2rem auto;
  width: 100%;
  padding: 0 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  border: 1px solid var(--border);
}

/* ── Upload Grid ────────────────────────────────────────────────── */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  align-items: start;
}

.upload-left h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: .3rem;
}

.hint { font-size: .85rem; color: var(--muted); margin-bottom: 1.25rem; }

/* ── Drop Zone ──────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius-sm);
  padding: 2rem 1rem;
  text-align: center;
  transition: border-color .2s, background .2s, transform .15s;
  cursor: pointer;
  margin-bottom: 1rem;
  background: #fafcff;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-1px);
}

.drop-anim { margin-bottom: .75rem; }
.drop-anim svg { transition: transform .2s; }
.drop-zone:hover .drop-anim svg { transform: translateY(-3px); }

.drop-main { font-size: .95rem; font-weight: 500; color: var(--text-2); margin-bottom: .25rem; }
.drop-sub   { font-size: .82rem; color: var(--muted); margin-bottom: .6rem; }
.drop-note  { font-size: .85rem; color: var(--primary); margin-top: .75rem; font-weight: 600; }

/* ── Right panel ────────────────────────────────────────────────── */
.upload-right {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  border: 1px solid var(--border);
}

.steps-mini-title {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin-bottom: 1rem;
}

.steps-mini {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .65rem;
  margin-bottom: 1.25rem;
}

.steps-mini li {
  display: flex;
  align-items: flex-start;
  gap: .6rem;
  font-size: .85rem;
  color: var(--text-2);
  line-height: 1.4;
}

.mini-num {
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: .7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: .1rem;
}

.privacy-note {
  font-size: .78rem;
  color: var(--muted);
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  line-height: 1.5;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .7rem 1.5rem;
  border-radius: 10px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all .18s;
  text-decoration: none;
  font-family: inherit;
}

.btn-icon { font-size: 1rem; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
  box-shadow: 0 4px 12px rgba(79,70,229,.3);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 6px 16px rgba(79,70,229,.4);
  transform: translateY(-1px);
}
.btn-primary:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }

.btn-outline {
  background: #fff;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

.btn-success {
  background: var(--success);
  color: #fff;
  box-shadow: 0 4px 12px rgba(5,150,105,.25);
}
.btn-success:hover {
  background: var(--success-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(5,150,105,.35);
}

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

/* ── Progress ────────────────────────────────────────────────────── */
.progress-wrap { margin-top: 1rem; }
.progress-track {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: .5rem;
}
.progress-bar {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.progress-label { font-size: .83rem; color: var(--muted); text-align: center; }

/* ── Stat Strip ──────────────────────────────────────────────────── */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.stat-icon { font-size: 1.4rem; margin-bottom: .3rem; }
.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: .78rem; color: var(--muted); margin-top: .25rem; font-weight: 500; }

/* ── Result Card ─────────────────────────────────────────────────── */
.result-card { padding: 2rem; }

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.result-header h2 { font-size: 1.4rem; font-weight: 700; }
.meta-line { color: var(--muted); font-size: .88rem; margin-top: .25rem; }

.section-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin-bottom: .6rem;
}

/* ── Column chips ─────────────────────────────────────────────────── */
.columns-preview {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .5rem;
}
.col-chip {
  background: var(--primary-light);
  color: var(--primary);
  padding: .22rem .65rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
}

/* ── Preview Table ───────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: .5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
  white-space: nowrap;
}

thead th {
  background: #f1f5f9;
  padding: .55rem .85rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

tbody tr:nth-child(even) { background: #fafafa; }
tbody tr:hover { background: var(--primary-light); }

tbody td {
  padding: .5rem .85rem;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

tbody tr:last-child td { border-bottom: none; }

/* ── Steps ───────────────────────────────────────────────────────── */
.step-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: .6rem;
  overflow: hidden;
  transition: box-shadow .15s;
}
.step-item:hover { box-shadow: var(--shadow-sm); }

.step-header {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .85rem 1.1rem;
  cursor: pointer;
  user-select: none;
  background: #fafafa;
  transition: background .15s;
}
.step-header:hover { background: #f1f5f9; }
.step-item.open .step-header { background: var(--primary-light); }

.step-num {
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: .72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.step-title { font-weight: 600; font-size: .9rem; flex: 1; color: var(--text); }

.step-badge {
  font-size: .72rem;
  padding: .18rem .5rem;
  border-radius: 999px;
  background: #fde68a;
  color: #78350f;
  flex-shrink: 0;
  font-weight: 600;
}

.step-tag {
  font-size: .68rem;
  padding: .16rem .48rem;
  border-radius: 999px;
  flex-shrink: 0;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.step-tag.prepare { background: #e0e7ff; color: #3730a3; }
.step-tag.explore { background: #fef3c7; color: #92400e; }
.step-tag.outlier { background: #fee2e2; color: #991b1b; }
.step-tag.missing { background: #d1fae5; color: #065f46; }
.step-tag.summary { background: #f1f5f9; color: #475569; }

.step-chevron {
  color: var(--muted);
  font-size: .8rem;
  transition: transform .2s;
  flex-shrink: 0;
}
.step-item.open .step-chevron { transform: rotate(180deg); }

.step-body {
  display: none;
  padding: 1.1rem;
  border-top: 1px solid var(--border);
  background: #fff;
}
.step-item.open .step-body { display: block; }

.step-desc {
  font-size: .9rem;
  line-height: 1.7;
  color: var(--text-2);
  white-space: pre-line;
}

.step-detail {
  margin-top: .85rem;
  background: #f8fafc;
  border-left: 3px solid var(--primary);
  padding: .7rem 1rem;
  border-radius: 0 8px 8px 0;
  font-size: .83rem;
  color: var(--muted);
  white-space: pre-line;
  font-family: 'Menlo', 'Consolas', monospace;
  line-height: 1.7;
}

.step-detail .warn { color: var(--danger); font-weight: 600; }
.step-detail .ok   { color: var(--success); font-weight: 600; }

/* ── Error card ──────────────────────────────────────────────────── */
.error-card { border: 1px solid #fca5a5; background: #fff5f5; }
.error-inner { display: flex; align-items: flex-start; gap: .85rem; }
.error-icon {
  font-size: 1.4rem;
  width: 40px;
  height: 40px;
  background: var(--danger-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--danger);
}
.error-card h3 { color: var(--danger); font-size: 1rem; margin-bottom: .25rem; }
.error-card p  { font-size: .88rem; color: var(--text-2); }

/* ── Result footer ───────────────────────────────────────────────── */
.result-footer {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* ── Footer ──────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1.25rem;
  font-size: .8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  background: var(--card-bg);
  margin-top: auto;
}

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

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .upload-grid { grid-template-columns: 1fr; gap: 1.5rem; }
  .stat-strip  { grid-template-columns: repeat(2, 1fr); }
  .result-header { flex-direction: column; }
  .btn-success { width: 100%; }
  header { padding: 1.5rem 1rem; }
  .logo-text { font-size: 1.5rem; }
}

@media (max-width: 420px) {
  .stat-strip { grid-template-columns: 1fr 1fr; }
  .feature-pills { display: none; }
}
