:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #667085;
  --line: #d8dee8;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

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

button,
select,
input {
  font: inherit;
}

.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
}

.toolbar p,
.muted,
#statusText {
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  padding: 0 14px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: var(--accent-dark);
}

button.secondary {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
}

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

button.full {
  width: 100%;
  margin-top: 8px;
}

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

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.controls {
  padding: 16px;
  display: grid;
  gap: 16px;
  position: sticky;
  top: 16px;
}

.drop-zone {
  display: grid;
  gap: 6px;
  min-height: 118px;
  padding: 20px;
  place-content: center;
  text-align: center;
  border: 1px dashed #9aa6b8;
  border-radius: 8px;
  background: #fbfcfe;
  cursor: pointer;
}

.drop-zone input {
  display: none;
}

.drop-title {
  font-weight: 700;
}

.drop-hint {
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-size: 13px;
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  padding: 0 10px;
}

.rule-group {
  display: grid;
  gap: 10px;
}

.rule-group label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
}

.rule-note {
  margin-top: -4px;
  padding-left: 24px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.column-checks {
  display: grid;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
  padding-right: 4px;
}

.content {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
}

.stats div {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.stats span {
  display: block;
  font-size: 24px;
  font-weight: 800;
}

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

.preview-panel {
  min-height: 520px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow: auto;
  max-height: 650px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid #edf0f4;
  border-right: 1px solid #edf0f4;
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  min-width: 120px;
  max-width: 280px;
  overflow-wrap: anywhere;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef6f5;
  font-weight: 800;
}

td.index,
th.index {
  min-width: 54px;
  width: 54px;
  text-align: right;
  color: var(--muted);
  background: #f8fafc;
}

.empty {
  color: var(--muted);
  padding: 28px;
  text-align: center;
}

@media (max-width: 860px) {
  .app-shell {
    padding: 16px;
  }

  .toolbar,
  .workspace {
    display: grid;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .controls {
    position: static;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
