:root {
  --ink: #18221d;
  --muted: #69736c;
  --line: #d9ded7;
  --panel: #ffffff;
  --wash: #f4f6f1;
  --accent: #1d3b5a;
  --green: #1f7d45;
  --blue: #356ca8;
}

* {
  box-sizing: border-box;
}

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

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  background: var(--accent);
  color: white;
  border-radius: 8px;
  position: sticky;
  top: 0;
  z-index: 2;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 18px;
}

.topbar p {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.74);
}

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

button {
  border: 0;
  border-radius: 6px;
  min-height: 44px;
  padding: 10px 14px;
  background: #e9eee8;
  color: var(--ink);
  font-weight: 750;
  cursor: pointer;
}

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

.primary-button {
  background: var(--green);
  color: white;
  min-width: 150px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(24, 34, 29, 0.05);
}

.setup-panel {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
}

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

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
  min-height: 360px;
  line-height: 1.36;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.input-panel,
.output-panel {
  padding: 14px;
}

.section-title,
.download-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.inline-check input {
  width: auto;
}

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

.output-panel {
  margin-top: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stats-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfa;
}

.stats-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.stats-grid strong {
  display: block;
  margin-top: 2px;
  font-size: 24px;
}

.download-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.download-row button:nth-child(1) {
  background: #dbe9df;
}

.download-row button:nth-child(2) {
  background: #dbe6f1;
}

.download-row button:nth-child(3) {
  background: #eee5d3;
}

.download-row button:nth-child(4) {
  background: #e6e1ee;
}

.preview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 14px;
  margin-top: 12px;
}

.preview-grid h2 {
  margin-bottom: 8px;
}

.table-scroll {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  max-height: 360px;
}

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

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

th {
  position: sticky;
  top: 0;
  background: #eef3ed;
  font-weight: 800;
}

.review-list {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 180px;
  max-height: 360px;
  overflow: auto;
  padding: 10px;
  background: #fbfcfa;
}

.review-item {
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

.review-item:last-child {
  border-bottom: 0;
}

.review-item strong {
  display: block;
  font-size: 13px;
}

.review-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 980px) {
  .setup-panel,
  .workspace-grid,
  .preview-grid,
  .download-row,
  .stats-grid {
    grid-template-columns: 1fr;
  }

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