:root {
  --bg: #f6f7f2;
  --ink: #1e2528;
  --muted: #667176;
  --line: #cfd8d3;
  --panel: #ffffff;
  --panel-alt: #eef5f0;
  --primary: #176b5d;
  --primary-dark: #0f4c42;
  --accent: #a9462d;
  --warn: #9d6b00;
  --danger: #a52828;
  --focus: #2374ab;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
}

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

.primary {
  background: var(--primary);
  color: #fff;
}

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

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

.xl {
  font-size: 20px;
  min-width: 210px;
  min-height: 58px;
}

.shell {
  min-height: 100vh;
}

.topbar h1,
.table-header h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.hidden {
  display: none !important;
}

.workspace {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto 14px;
  max-width: 1480px;
}

.topbar-actions,
.export-actions,
.entity-actions,
.table-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.columns {
  display: grid;
  grid-template-columns: minmax(330px, 0.85fr) minmax(520px, 1.45fr);
  gap: 16px;
  margin: 0 auto;
  max-width: 1480px;
}

.input-panel,
.review-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: calc(100vh - 104px);
  padding: 16px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field span,
.preview-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.field.grow {
  flex: 1;
  min-height: 220px;
}

.catalog-grid {
  display: grid;
  gap: 12px;
}

.catalog-input {
  min-height: 118px;
  font-family: Consolas, Monaco, monospace;
  font-size: 13px;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

textarea {
  line-height: 1.35;
  min-height: 180px;
  resize: vertical;
}

.grow textarea {
  flex: 1;
}

.preview,
.status-box,
.warning-box,
.empty-state {
  background: var(--panel-alt);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.preview pre {
  margin: 8px 0 0;
  max-height: 190px;
  overflow: auto;
  white-space: pre-wrap;
}

#statusList {
  margin: 8px 0 0;
  padding-left: 18px;
}

#statusList li {
  margin: 5px 0;
}

.warning-box {
  background: #fff7e2;
  border-color: #e4c878;
  color: #604000;
  margin-bottom: 14px;
}

.empty-state {
  align-items: center;
  color: var(--muted);
  display: flex;
  justify-content: center;
  min-height: calc(100vh - 138px);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 12px;
}

.entity-actions {
  margin: 14px 0 8px;
}

.table-header {
  justify-content: space-between;
  margin-top: 16px;
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 10px;
  overflow: auto;
}

table {
  border-collapse: collapse;
  min-width: 1060px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #edf1ed;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

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

td input,
td select {
  min-width: 110px;
}

.raw-input {
  min-width: 220px;
}

.match-cell {
  min-width: 230px;
}

.confidence {
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 8px;
  text-align: center;
  white-space: nowrap;
}

.confidence.high {
  background: #d9f0e7;
  color: #115b46;
}

.confidence.medium {
  background: #fff0c2;
  color: #735100;
}

.confidence.low {
  background: #ffe0dd;
  color: var(--danger);
}

.alt-list {
  color: var(--muted);
  font-size: 12px;
  margin-top: 5px;
}

.delete-row {
  background: #f3e4e0;
  border: 1px solid #e2b8ad;
  color: var(--danger);
  min-width: 40px;
  padding: 0 9px;
}

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

.output {
  margin-top: 14px;
}

#jsonOutput {
  min-height: 220px;
  font-family: Consolas, Monaco, monospace;
  font-size: 13px;
}

.invalid-note {
  color: var(--danger);
  font-size: 12px;
  margin-top: 4px;
}

@media (max-width: 960px) {
  .columns,
  .form-grid,
  .totals {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .input-panel,
  .review-panel {
    min-height: auto;
  }
}
