:root {
  color-scheme: light;
  --ink: #1f211d;
  --muted: #666b60;
  --paper: #fbfaf6;
  --surface: #f1efe7;
  --line: #d8d3c2;
  --line-strong: #a9a28d;
  --accent: #2f6f63;
  --accent-ink: #f9fff7;
  --risk: #9d432f;
  --good: #286544;
  --blueprint: #294f7a;
  --shadow: 0 18px 55px rgba(60, 55, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Aptos", "Segoe UI", sans-serif;
  font-size: 15px;
}

button,
input {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  padding: 0 14px;
}

button:hover {
  background: #34362f;
}

button.secondary {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--ink);
}

button.secondary:hover {
  background: var(--surface);
}

.app-shell {
  width: min(1540px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 22px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blueprint);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 4.2rem);
  font-weight: 500;
  line-height: 0.95;
}

.subhead {
  max-width: 48rem;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

h2 {
  font-size: 1rem;
  font-weight: 750;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.status-strip span {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  background: #fffdf7;
  color: var(--muted);
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
  gap: 16px;
  padding-top: 16px;
}

.input-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  box-shadow: var(--shadow);
}

.input-panel {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 14px;
}

.dropzone {
  display: grid;
  gap: 8px;
  min-height: 128px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.dropzone.dragging {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--surface) 80%, var(--accent) 20%);
}

.dropzone-title {
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 780;
}

.dropzone-file {
  color: var(--muted);
  word-break: break-word;
}

.control-row {
  display: grid;
  grid-template-columns: 1fr 112px;
  align-items: center;
  gap: 10px;
}

.control-row label {
  color: var(--muted);
  font-weight: 650;
}

.control-row input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  padding: 6px 8px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-row.compact {
  justify-content: flex-end;
}

.quality-panel {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.quality-panel h2 {
  margin-bottom: 10px;
}

.privacy-note {
  margin: -4px 0 0;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 8%, #fffdf7);
  color: var(--accent);
  font-weight: 750;
  padding: 9px 10px;
}

.offer-panel {
  display: grid;
  gap: 6px;
  border: 1px solid color-mix(in srgb, var(--blueprint) 32%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--blueprint) 6%, #fffdf7);
  padding: 12px;
}

.offer-panel h2 {
  font-size: 0.95rem;
}

.offer-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.42;
}

.offer-panel .eyebrow {
  color: var(--blueprint);
}

dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

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

dd {
  margin: 0;
  font-weight: 750;
  text-align: right;
}

.output-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 16px;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.variance-panel,
.memo-panel {
  grid-column: 1 / -1;
}

.driver-panel {
  grid-column: 2;
  grid-row: 1;
}

.diagnostic-panel {
  grid-column: 2;
  grid-row: 2;
}

.variance-panel {
  grid-column: 1;
  grid-row: 1;
}

.preview-panel {
  grid-column: 1;
  grid-row: 2;
}

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

.memo-head {
  align-items: start;
}

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

.table-wrap.small {
  max-height: 220px;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f6f3e9;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

td {
  background: #fffdf7;
}

.import-audit {
  display: grid;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  background: #fbf7ec;
  padding: 12px 14px;
}

.import-audit p {
  margin: 0;
}

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

.diagnostic-summary span {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffdf7;
  padding: 8px 10px;
}

.diagnostic-summary strong {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.mapped-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.mapped-fields span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffdf7;
  padding: 4px 8px;
  white-space: nowrap;
}

.audit-good {
  color: var(--good);
  font-weight: 720;
}

.audit-warning {
  color: var(--risk);
  font-weight: 720;
}

.audit-muted {
  color: var(--muted);
  font-size: 0.86rem;
}

.empty-row td {
  color: var(--muted);
  text-align: center;
}

.good {
  color: var(--good);
  font-weight: 780;
}

.watch {
  color: var(--risk);
  font-weight: 780;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.78rem;
  font-weight: 760;
  text-transform: capitalize;
  white-space: nowrap;
}

.pill.favorable {
  background: color-mix(in srgb, var(--good) 14%, white);
  color: var(--good);
}

.pill.unfavorable {
  background: color-mix(in srgb, var(--risk) 14%, white);
  color: var(--risk);
}

.note-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 14px;
  list-style: none;
}

.note-list li {
  display: grid;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.note-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.note-kind {
  color: var(--blueprint);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.diagnostic-mode-output {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.diagnostic-mode-output p,
.diagnostic-mode-output ul {
  margin: 0;
}

.diagnostic-block {
  display: grid;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.diagnostic-block:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.diagnostic-block h3 {
  margin: 0;
  color: var(--blueprint);
  font-size: 0.76rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.diagnostic-block ul {
  display: grid;
  gap: 6px;
  padding-left: 18px;
}

pre {
  min-height: 330px;
  max-height: 520px;
  margin: 0;
  overflow: auto;
  background: #272923;
  color: #f3eedf;
  font-family: "Cascadia Mono", "Consolas", monospace;
  font-size: 0.88rem;
  line-height: 1.58;
  padding: 16px;
  white-space: pre-wrap;
}

@media (max-width: 980px) {
  .workspace,
  .output-grid {
    grid-template-columns: 1fr;
  }

  .diagnostic-summary {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .variance-panel,
  .driver-panel,
  .diagnostic-panel,
  .preview-panel,
  .memo-panel {
    grid-column: 1;
    grid-row: auto;
  }

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

  .status-strip {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 18px, 1540px);
    padding-top: 10px;
  }

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

  .panel-head {
    align-items: start;
    flex-direction: column;
  }

  .button-row.compact {
    justify-content: flex-start;
  }

  .diagnostic-summary {
    grid-template-columns: 1fr;
  }
}
