:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #18202a;
  --muted: #657080;
  --line: #d9dee7;
  --soft-panel: #fbfcfe;
  --table-head: #eef2f6;
  --table-head-text: #344255;
  --code-bg: #111827;
  --code-text: #eef2ff;
  --primary: #155e75;
  --primary-strong: #0e4b5d;
  --primary-soft: #e7f4f7;
  --success-bg: #e9f8ef;
  --success-text: #17613a;
  --warning-bg: #fff6db;
  --warning-text: #73510b;
  --danger-bg: #fdeeee;
  --danger-text: #9c2525;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101720;
  --panel: #17212d;
  --text: #e8edf3;
  --muted: #a5b3c3;
  --line: #304050;
  --soft-panel: #111b26;
  --table-head: #223142;
  --table-head-text: #d5dee8;
  --code-bg: #090f16;
  --code-text: #dce8f7;
  --primary: #2f9bb3;
  --primary-strong: #56b8ca;
  --primary-soft: #14313c;
  --success-bg: #123323;
  --success-text: #89d8a8;
  --warning-bg: #372b12;
  --warning-text: #f2ce7a;
  --danger-bg: #3b1c1f;
  --danger-text: #f2a0a0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
}

main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

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

h1 {
  margin-bottom: 10px;
  font-size: 2.3rem;
}

h2 {
  margin-bottom: 14px;
  font-size: 1.15rem;
}

h3 {
  margin-bottom: 10px;
  font-size: 1rem;
}

section,
details {
  margin-top: 22px;
}

button,
input,
select {
  font: inherit;
}

input[type="file"] {
  display: none;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: start;
  padding: 28px 0 10px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.8rem;
}

.intro {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

#status {
  margin: 0;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.hero-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
}

#theme-toggle {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

#theme-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.upload-grid,
.summary-grid,
.text-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.upload-panel,
.settings,
.results,
.summary-box,
details {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.drop-zone {
  display: grid;
  width: 100%;
  min-height: 150px;
  place-items: center;
  align-content: center;
  gap: 6px;
  border: 2px dashed #8a94a6;
  border-radius: 8px;
  background: var(--soft-panel);
  color: var(--text);
  cursor: pointer;
}

.drop-zone span {
  font-weight: 700;
}

.drop-zone small,
.file-name {
  color: var(--muted);
}

.drop-zone.dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.file-name {
  margin: 12px 0 0;
  overflow-wrap: anywhere;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.92rem;
}

input[type="number"],
select {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

.result-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.result-header h2 {
  margin-bottom: 0;
}

#compare-button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  background: var(--primary);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

#compare-button:hover {
  background: var(--primary-strong);
}

.report {
  border-radius: 8px;
  padding: 14px;
}

.report.empty {
  background: var(--soft-panel);
  color: var(--muted);
}

.report.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.report.warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.report.danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

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

dl div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

dl div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

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

th {
  background: var(--table-head);
  color: var(--table-head-text);
  font-size: 0.9rem;
}

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

.comparison-table {
  margin-top: 12px;
  color: var(--text);
}

.comparison-table .match td:last-child {
  color: var(--success-text);
  font-weight: 700;
}

.comparison-table .mismatch td:last-child {
  color: var(--danger-text);
  font-weight: 700;
}

.comparison-table .missing td:last-child {
  color: var(--warning-text);
  font-weight: 700;
}

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

.source-table {
  margin-top: 12px;
  font-size: 0.9rem;
}

.confidence {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.confidence.high {
  background: var(--success-bg);
  color: var(--success-text);
}

.confidence.medium {
  background: var(--warning-bg);
  color: var(--warning-text);
}

.confidence.low {
  background: var(--danger-bg);
  color: var(--danger-text);
}

summary {
  cursor: pointer;
  font-weight: 700;
}

pre {
  max-height: 360px;
  min-height: 180px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  background: var(--code-bg);
  border-radius: 8px;
  color: var(--code-text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

details .text-grid {
  margin-top: 16px;
}

@media (max-width: 780px) {
  main {
    width: min(100% - 20px, 1120px);
    padding-top: 20px;
  }

  .hero,
  .upload-grid,
  .summary-grid,
  .text-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  #status {
    white-space: normal;
  }

  .hero-actions {
    justify-items: stretch;
  }

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

  table {
    display: block;
    overflow-x: auto;
  }
}
