:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --ink: #17212b;
  --muted: #5b6876;
  --line: #d7dee7;
  --accent: #146c63;
  --accent-strong: #0e514b;
  --warning: #9d4f00;
  --error: #b42318;
  --header: #17324d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1200px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 2px 8px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  letter-spacing: 0;
}

h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

p,
.muted,
small {
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 12px 30px rgba(23, 33, 43, 0.06);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.setup-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dropzone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 176px;
  border: 1px dashed #9facba;
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
  text-align: center;
  padding: 20px;
}

.upload-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.dropzone input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #dbeeea;
  color: var(--accent-strong);
  font-size: 30px;
  line-height: 1;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: #2a3846;
  font-size: 13px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  padding: 8px 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 108, 99, 0.15);
}

button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 750;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary {
  color: #fff;
  background: var(--accent);
  padding: 0 16px;
}

.primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
  padding: 0 12px;
}

.icon-button:hover {
  border-color: #aeb9c6;
}

.status {
  min-height: 36px;
  border-left: 3px solid var(--line);
  color: var(--muted);
  background: #f8fafc;
  padding: 9px 10px;
  font-size: 13px;
}

.status.error {
  border-color: var(--error);
  color: var(--error);
  background: #fff5f5;
}

.status.ok {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: #f2fbf8;
}

.actions-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.detected-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
}

.pill-list {
  display: flex;
  min-height: 150px;
  align-content: start;
  align-items: start;
  flex-wrap: wrap;
  gap: 8px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #f8fafc;
  padding: 12px;
}

.pill-list.has-items {
  border-style: solid;
  color: var(--ink);
  background: #fff;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid #b9d9d4;
  border-radius: 999px;
  background: #edf8f5;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 750;
  padding: 4px 10px;
}

.mapping-table-wrap,
.preview-panel {
  overflow: auto;
}

.mapping-table,
.preview-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

th {
  background: #f1f5f9;
  color: #334155;
  font-size: 12px;
  text-align: left;
  text-transform: uppercase;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px;
  vertical-align: middle;
}

.mapping-table input,
.mapping-table select {
  min-height: 36px;
}

.delete-button {
  width: 36px;
  min-height: 36px;
  color: var(--error);
  background: #fff;
  border-color: #f0cbc7;
}

.convert-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-top: 16px;
}

.preview-panel {
  min-height: 220px;
}

.preview-empty {
  display: grid;
  min-height: 150px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #f8fafc;
  text-align: center;
  padding: 18px;
}

.preview-table th {
  position: sticky;
  top: 0;
}

.preview-table td {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 880px) {
  .shell {
    width: min(100vw - 20px, 760px);
    padding: 18px 0;
  }

  .topbar,
  .grid,
  .convert-row,
  .upload-grid,
  .details-grid,
  .detected-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
  }

  .actions-row {
    flex-direction: column;
  }

  .field-row {
    grid-template-columns: 1fr;
  }
}
