.topstep-file-panel {
  position: relative;
  overflow: hidden;
  scroll-margin-top: 150px;
}

.topstep-file-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 229, 138, .8), rgba(34, 211, 238, .65), transparent);
  pointer-events: none;
}

.topstep-file-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.topstep-file-title-wrap {
  display: flex;
  align-items: center;
  gap: 11px;
}

.topstep-file-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(0, 229, 138, .28);
  border-radius: 8px;
  color: var(--accent);
  background: rgba(0, 229, 138, .07);
}

.topstep-file-mark svg {
  width: 20px;
  height: 20px;
}

.topstep-file-title {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}

.topstep-file-sub {
  max-width: 660px;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.55;
}

.topstep-free-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid rgba(0, 229, 138, .28);
  border-radius: 999px;
  color: var(--accent);
  background: rgba(0, 229, 138, .06);
  font: 650 10px/1 'Geist Mono', monospace;
  white-space: nowrap;
}

.topstep-free-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 9px rgba(0, 229, 138, .5);
}

.topstep-file-drop {
  position: relative;
  min-height: 154px;
  display: grid;
  place-items: center;
  padding: 22px;
  border: 1px dashed rgba(34, 211, 238, .32);
  border-radius: 8px;
  color: var(--text-muted);
  background:
    linear-gradient(135deg, rgba(0, 229, 138, .035), transparent 45%),
    rgba(255, 255, 255, .012);
  text-align: center;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .18s ease;
}

.topstep-file-drop:hover,
.topstep-file-drop.drag-over {
  border-color: rgba(0, 229, 138, .65);
  background:
    linear-gradient(135deg, rgba(0, 229, 138, .08), transparent 55%),
    rgba(34, 211, 238, .025);
  transform: translateY(-1px);
}

.topstep-file-drop svg {
  width: 30px;
  height: 30px;
  margin-bottom: 11px;
  color: var(--accent);
}

.topstep-file-drop strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}

.topstep-file-drop span {
  display: block;
  margin-top: 5px;
  font-size: 10px;
  line-height: 1.5;
}

.topstep-file-input { display: none; }

.topstep-file-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.topstep-file-step {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(255, 255, 255, .015);
}

.topstep-file-step span {
  display: block;
  color: var(--accent);
  font: 650 9px/1 'Geist Mono', monospace;
  text-transform: uppercase;
}

.topstep-file-step strong {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-size: 11px;
  line-height: 1.4;
}

.topstep-repeat-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(34, 211, 238, .18);
  border-radius: 7px;
  color: var(--text-muted);
  background: rgba(34, 211, 238, .025);
  font-size: 10px;
  line-height: 1.5;
}

.topstep-repeat-note svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  color: #22d3ee;
}

.topstep-preview {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.topstep-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .018);
}

.topstep-preview-title {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.topstep-preview-file {
  max-width: 600px;
  overflow: hidden;
  margin-top: 3px;
  color: var(--text-muted);
  font: 500 10px/1.4 'Geist Mono', monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topstep-preview-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.topstep-preview-pill {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, .02);
  font: 600 9px/1 'Geist Mono', monospace;
}

.topstep-preview-pill.new {
  border-color: rgba(0, 229, 138, .25);
  color: var(--accent);
}

.topstep-preview-pill.duplicate {
  border-color: rgba(255, 181, 71, .28);
  color: var(--amber);
}

.topstep-preview-pill.invalid {
  border-color: rgba(255, 77, 109, .3);
  color: var(--red);
}

.topstep-preview-table-wrap {
  overflow-x: auto;
}

.topstep-preview-table {
  width: 100%;
  min-width: 670px;
  border-collapse: collapse;
}

.topstep-preview-table th,
.topstep-preview-table td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.topstep-preview-table th {
  color: var(--text-muted);
  font: 650 8px/1 'Geist Mono', monospace;
  text-transform: uppercase;
}

.topstep-preview-table td {
  color: var(--text-muted);
  font-size: 10px;
}

.topstep-preview-table tr:last-child td { border-bottom: 0; }
.topstep-preview-table strong { color: var(--text); }
.topstep-preview-table .positive { color: var(--accent); }
.topstep-preview-table .negative { color: var(--red); }

.topstep-file-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, .012);
}

.topstep-file-message {
  min-height: 18px;
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
}

.topstep-file-message.error { color: var(--red); }
.topstep-file-message.success { color: var(--accent); }

.topstep-history {
  margin-top: 16px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}

.topstep-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}

.topstep-history-title {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.topstep-history-list {
  display: grid;
  gap: 6px;
}

.topstep-history-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: rgba(255, 255, 255, .014);
}

.topstep-history-file {
  overflow: hidden;
  color: var(--text);
  font-size: 10px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topstep-history-time,
.topstep-history-result {
  color: var(--text-muted);
  font: 500 9px/1.2 'Geist Mono', monospace;
  white-space: nowrap;
}

.topstep-history-result strong { color: var(--accent); }

.topstep-local-note {
  display: flex;
  gap: 9px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(0, 229, 138, .16);
  border-radius: 7px;
  color: var(--text-muted);
  background: rgba(0, 229, 138, .025);
  font-size: 10px;
  line-height: 1.5;
}

.topstep-local-note svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  color: var(--accent);
}

.topstep-mapping {
  border-top: 1px solid var(--border);
  background: rgba(34, 211, 238, .018);
}

.topstep-mapping summary {
  padding: 11px 12px;
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  list-style-position: inside;
}

.topstep-mapping[open] summary {
  border-bottom: 1px solid var(--border);
}

.topstep-mapping-body {
  padding: 12px;
}

.topstep-mapping-copy {
  display: grid;
  gap: 4px;
  margin-bottom: 11px;
}

.topstep-mapping-copy strong {
  color: var(--text);
  font-size: 12px;
}

.topstep-mapping-copy span {
  max-width: 760px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.5;
}

.topstep-mapping-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.topstep-mapping-field {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.topstep-mapping-field > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  color: var(--text-muted);
  font-size: 9px;
}

.topstep-mapping-field em {
  color: var(--accent);
  font: 600 7px/1 'Geist Mono', monospace;
  font-style: normal;
  text-transform: uppercase;
}

.topstep-mapping-field select {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  background: var(--surface-2, #171c25);
  font-size: 10px;
}

.topstep-mapping-field select:focus {
  border-color: rgba(0, 229, 138, .55);
  outline: 2px solid rgba(0, 229, 138, .12);
}

.topstep-mapping-apply {
  margin-top: 11px;
}

@media (max-width: 760px) {
  .topstep-file-head,
  .topstep-preview-head {
    align-items: stretch;
    flex-direction: column;
  }
  .topstep-file-steps {
    grid-template-columns: 1fr;
  }
  .topstep-file-drop {
    min-height: 140px;
    padding: 18px 14px;
  }
  .topstep-history-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .topstep-history-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .topstep-history-time {
    grid-column: 1 / -1;
  }
  .topstep-file-actions .btn {
    flex: 1;
  }
  .topstep-mapping-grid {
    grid-template-columns: 1fr;
  }
  .topstep-mapping-apply {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .topstep-file-drop { transition: none; }
}
