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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f4f6fb;
  color: #1a1a2e;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Hero ── */
.hero {
  background: linear-gradient(135deg, #1565c0 0%, #1976d2 50%, #42a5f5 100%);
  color: #fff;
  padding: 3rem 1rem 2.5rem;
  text-align: center;
}
.hero-inner { max-width: 640px; margin: auto; }
.hero-icon  { font-size: 2.8rem; display: block; margin-bottom: .5rem; }
.hero h1    { font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 700; margin-bottom: .6rem; }
.hero p     { font-size: 1rem; opacity: .9; line-height: 1.6; }

/* ── Container ── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
  flex: 1;
}

/* ── Step Headers ── */
.step-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: 1.05rem;
  font-weight: 700;
  margin: 2rem 0 1rem;
  color: #1565c0;
}
.config-hint {
  font-size: .85rem;
  color: #555;
  background: #f0f4ff;
  border-left: 3px solid #1976d2;
  padding: .6rem .9rem;
  border-radius: 0 8px 8px 0;
  margin-bottom: 1.25rem;
}

.hint-box {
  margin-top: 1rem;
  padding: .75rem 1rem;
  background: #f9fbe7;
  border: 1px solid #dce775;
  border-radius: 8px;
  font-size: .82rem;
  color: #555;
  line-height: 1.7;
}
.hint-cols { color: #1565c0; font-weight: 500; }

.input-wrap { position: relative; }

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #1565c0;
  color: #fff;
  font-size: .85rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ── Upload Grid ── */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 700px) {
  .upload-grid { grid-template-columns: 1fr; }
  .divider-arrow { text-align: center; }
}

.upload-card {
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
  transition: box-shadow .2s;
}
.upload-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.11); }

.upload-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 600;
  font-size: .95rem;
  margin-bottom: 1rem;
}
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  font-size: .75rem;
  font-weight: 700;
  color: #fff;
}
.badge-blue   { background: #1976d2; }
.badge-orange { background: #f57c00; }
.badge-tag {
  font-size: .72rem;
  font-weight: 500;
  background: #e3f2fd;
  color: #1565c0;
  border-radius: 20px;
  padding: 2px 8px;
  margin-left: auto;
}
.tag-orange { background: #fff3e0; color: #e65100; }

/* Drop Zone */
.drop-zone {
  border: 2px dashed #90caf9;
  border-radius: 12px;
  padding: 1.75rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  user-select: none;
}
.drop-zone:hover, .drop-zone.dragover { background: #e3f2fd; border-color: #1976d2; }
.drop-icon { font-size: 1.8rem; margin-bottom: .4rem; }
.drop-text { font-size: .88rem; color: #555; margin-bottom: .2rem; }
.drop-sub  { font-size: .76rem; color: #aaa; }
.link { color: #1976d2; font-weight: 600; text-decoration: underline; }

.file-info {
  margin-top: .75rem;
  padding: .55rem .9rem;
  background: #e8f5e9;
  border-radius: 8px;
  font-size: .83rem;
  color: #2e7d32;
  display: flex;
  align-items: center;
  gap: .4rem;
}

/* Mini column tags below upload card */
.col-mini-preview {
  margin-top: .75rem;
}
.mini-label {
  font-size: .75rem;
  color: #888;
  font-weight: 600;
  display: block;
  margin-bottom: .35rem;
}
.mini-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
}
.mini-tag {
  background: #e3f2fd;
  color: #1565c0;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: .75rem;
  font-weight: 500;
}

.divider-arrow {
  font-size: 2rem;
  color: #90caf9;
  padding-top: 4rem;
  text-align: center;
}

/* ── Column Config Card ── */
.col-config-card {
  background: #fff;
  border-radius: 16px;
  padding: 1.75rem 2rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
  margin-bottom: 1.5rem;
}
.col-loading {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .88rem;
  color: #666;
  margin-bottom: 1rem;
}

.config-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 1rem;
  align-items: end;
}
@media (max-width: 600px) { .config-grid { grid-template-columns: 1fr; } }

.config-group { display: flex; flex-direction: column; gap: .4rem; }
.config-label {
  font-size: .88rem;
  font-weight: 600;
  color: #333;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.config-sub { font-size: .75rem; font-weight: 400; color: #888; }

.config-select, .config-input {
  width: 100%;
  padding: .6rem .8rem;
  border: 1.5px solid #cfd8dc;
  border-radius: 8px;
  font-size: .9rem;
  background: #fafafa;
  color: #1a1a2e;
  outline: none;
  transition: border-color .15s;
}
.config-select:focus, .config-input:focus { border-color: #1976d2; background: #fff; }

.config-eq {
  font-size: 1.4rem;
  font-weight: 300;
  color: #90caf9;
  text-align: center;
  padding-bottom: .4rem;
}
.config-divider {
  height: 1px;
  background: #e8ecf1;
  margin: 1.25rem 0;
}

/* ── Buttons ── */
.action-row { display: flex; justify-content: center; margin: 1.25rem 0; }

.btn-primary, .btn-success {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  border: none;
  border-radius: 10px;
  padding: .85rem 2.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .2s, transform .1s, box-shadow .2s;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, #1565c0, #1976d2);
  color: #fff;
  box-shadow: 0 4px 14px rgba(21,101,192,.35);
}
.btn-primary:disabled { background: #b0bec5; box-shadow: none; cursor: not-allowed; opacity: .7; }
.btn-primary:not(:disabled):hover { opacity: .9; transform: translateY(-1px); }
.btn-primary:not(:disabled):active { transform: translateY(0); }

.btn-success {
  background: linear-gradient(135deg, #2e7d32, #43a047);
  color: #fff;
  box-shadow: 0 4px 14px rgba(46,125,50,.35);
}
.btn-success:hover { opacity: .9; transform: translateY(-1px); }

/* ── Spinner ── */
[hidden] { display: none !important; }

#spinner, #col-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  padding: 1.5rem;
  color: #666;
  font-size: .9rem;
}
.spinner-ring {
  width: 46px; height: 46px;
  border: 4px solid #e3f2fd;
  border-top-color: #1976d2;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner-ring.small { width: 28px; height: 28px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Alerts ── */
.alert {
  border-radius: 10px;
  padding: .9rem 1.2rem;
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-error { background: #fde8e8; color: #c62828; border-left: 4px solid #e53935; }

/* ── Stats ── */
.section-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; }
.preview-note  { font-size: .8rem; font-weight: 400; color: #888; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 600px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 1.2rem 1rem;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
  border-top: 3px solid #b0bec5;
}
.stat-card.green { border-top-color: #43a047; }
.stat-card.red   { border-top-color: #e53935; }
.stat-card.blue  { border-top-color: #1976d2; }

.stat-num { font-size: 2rem; font-weight: 700; line-height: 1.1; color: #1a1a2e; }
.stat-card.green .stat-num { color: #2e7d32; }
.stat-card.red   .stat-num { color: #c62828; }
.stat-card.blue  .stat-num { color: #1565c0; }
.stat-lbl { font-size: .78rem; color: #777; margin-top: .3rem; }

/* ── Unmatched ── */
.unmatched-details {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 10px;
  padding: .75rem 1rem;
  font-size: .9rem;
  cursor: pointer;
}
.unmatched-details summary { font-weight: 600; color: #e65100; list-style: none; }
.unmatched-details summary::-webkit-details-marker { display: none; }
.unmatched-list {
  margin-top: .75rem;
  padding-left: 1.2rem;
  columns: 3;
  column-gap: 1rem;
  color: #555;
  line-height: 1.9;
}

/* ── Table ── */
.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,.07);
}
table { width: 100%; border-collapse: collapse; background: #fff; font-size: .84rem; }
thead tr { background: #1976d2; color: #fff; }
thead th { padding: .7rem 1rem; text-align: left; font-weight: 600; white-space: nowrap; }
tbody tr:nth-child(even) { background: #f9fbff; }
tbody tr:hover { background: #e3f2fd; }
tbody td { padding: .6rem 1rem; border-bottom: 1px solid #e8ecf1; }
td.highlight   { background: #e8f5e9 !important; font-weight: 600; color: #2e7d32; }
th.highlight-th { background: #2e7d32 !important; }

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 1.2rem;
  font-size: .78rem;
  color: #aaa;
  background: #fff;
  border-top: 1px solid #e8ecf1;
}
