:root {
  --bg: #f5f2ec;
  --surface: #fffefa;
  --surface-soft: #f8f6f0;
  --surface-tint: #eaf2ec;
  --text: #20201d;
  --muted: #66645e;
  --line: #d9d3c8;
  --accent: #236c58;
  --accent-strong: #184f41;
  --warn: #8a5b13;
  --danger: #9b3d35;
  --info: #375f7c;
  --shadow: 0 1px 2px rgba(31, 29, 24, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  min-height: 72px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 254, 250, 0.96);
  box-shadow: var(--shadow);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0;
}

h2 {
  margin-top: 3px;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

h3 {
  margin-top: 3px;
  font-size: 16px;
  line-height: 1.25;
  letter-spacing: 0;
}

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

.topbar p {
  margin-top: 4px;
  font-size: 13px;
}

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

button,
select,
input[type="file"],
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

button {
  min-height: 40px;
  padding: 0 16px;
  cursor: pointer;
}

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

.primary {
  min-width: 148px;
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  font-weight: 700;
}

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

.secondary {
  min-width: 112px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 700;
}

.wizard-shell {
  min-height: calc(100vh - 72px);
  padding: 24px;
}

.wizard-card {
  max-width: 1240px;
  min-height: calc(100vh - 120px);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.wizard-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.wizard-step {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 72px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.wizard-step:last-child {
  border-right: 0;
}

.wizard-step span {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.wizard-step strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wizard-step.active {
  background: #edf5ef;
  color: var(--accent-strong);
}

.wizard-step.active span {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.wizard-step.done span {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.wizard-panel {
  display: none;
  min-height: 520px;
  padding: 24px;
}

.wizard-panel.active {
  display: block;
}

.panel-heading {
  max-width: 760px;
  margin-bottom: 22px;
}

.panel-heading.horizontal {
  display: flex;
  max-width: none;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-heading p {
  margin-top: 6px;
  line-height: 1.45;
}

.step-label,
label,
.label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.field {
  display: grid;
  gap: 7px;
  max-width: 820px;
  margin-bottom: 18px;
}

.field:last-child {
  margin-bottom: 0;
}

.field.compact {
  max-width: 380px;
}

select,
input[type="file"] {
  min-height: 40px;
  width: 100%;
  padding: 8px 10px;
}

textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  padding: 12px;
  line-height: 1.5;
}

.file-list {
  min-height: 30px;
  border: 1px dashed #c8c1b4;
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.file-list.has-files {
  border-style: solid;
  color: var(--text);
}

.summary-strip {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) minmax(120px, 1fr) minmax(120px, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.summary-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.summary-item strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 16px;
}

.result-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 16px;
}

.result-section {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface-soft);
}

.section-heading {
  margin-bottom: 14px;
}

.finding-list,
.replacement-list {
  display: grid;
  gap: 10px;
  max-height: 48vh;
  overflow: auto;
  padding-right: 4px;
}

.finding-card,
.replacement-card {
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 6px;
  padding: 10px;
  background: #fffefa;
}

.finding-card[data-priority="Obrigatório"],
.replacement-card[data-priority="Obrigatório"] {
  border-left-color: var(--danger);
}

.finding-card[data-priority="Recomendado"],
.replacement-card[data-priority="Recomendado"] {
  border-left-color: var(--warn);
}

.finding-card[data-priority="Opcional"],
.replacement-card[data-priority="Opcional"] {
  border-left-color: var(--info);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.finding-card p,
.replacement-card p {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.45;
}

.finding-card strong,
.replacement-card strong {
  font-size: 13px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 14px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14px;
}

#finalText {
  min-height: 360px;
  background: #fffefa;
}

.export-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.download {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

.source-details {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.source-details summary {
  cursor: pointer;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

pre {
  max-height: 260px;
  margin: 0;
  overflow: auto;
  border-top: 1px solid var(--line);
  padding: 12px;
  color: var(--muted);
  white-space: pre-wrap;
}

.wizard-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 14px 24px;
  background: rgba(255, 254, 250, 0.96);
}

@media (max-width: 900px) {
  .wizard-shell {
    padding: 12px;
  }

  .wizard-card {
    min-height: calc(100vh - 96px);
  }

  .wizard-nav,
  .summary-strip,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .wizard-step {
    min-height: 52px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .wizard-panel {
    min-height: auto;
    padding: 16px;
  }

  .panel-heading.horizontal {
    display: block;
  }

  .export-links {
    justify-content: flex-start;
    margin-top: 10px;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding: 14px;
  }

  .wizard-actions {
    display: grid;
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .primary,
  .secondary {
    width: 100%;
  }
}
