:root {
  --red: #cb141c;
  --red-dark: #a11117;
  --red-bg: #fdecec;
  --navy: #2d2f91;
  --ink: #202020;
  --ink-soft: #666666;
  --paper: #f5f5f5;
  --surface: #ffffff;
  --line: #dddddd;
  --warn: #b45309;
  --warn-bg: #fdf1de;
  --focus: #2d2f91;
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Lato", -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
  padding: 2.5rem 1.25rem 5rem;
}
.wrap { max-width: 900px; margin: 0 auto; }

header.masthead {
  border-bottom: 4px solid var(--red);
  padding-bottom: 1.1rem;
  margin-bottom: 2rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--surface);
  padding: 1.25rem 1.5rem 1.1rem;
  border-radius: 4px;
}
.masthead-brand {
  display: flex;
  align-items: center;
  gap: 1.1rem;
}
.masthead-brand .logo {
  height: 48px;
  width: auto;
  flex-shrink: 0;
}
h1 {
  font-family: "Lato", sans-serif;
  font-weight: 900;
  font-size: 1.55rem;
  margin: 0;
  color: var(--navy);
  letter-spacing: -0.01em;
}
.masthead p {
  margin: 0.3rem 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  max-width: 46ch;
}
.lote-tag {
  font-family: "Lato", monospace;
  font-size: 0.78rem;
  color: var(--ink-soft);
  text-align: right;
  line-height: 1.6;
}

section { margin-bottom: 2.5rem; }
h2 {
  font-family: "Lato", sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0 0 0.9rem;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-left: 6px solid var(--red);
  padding-left: 0.6rem;
}

.section-note {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-top: -0.5rem;
}

.intake {
  border: 2px dashed #c9c9c9;
  border-radius: 4px;
  padding: 1.75rem;
  text-align: center;
  background: var(--surface);
}
.intake.dragover { border-color: var(--red); background: var(--red-bg); }
.intake p { margin: 0 0 1rem; color: var(--ink-soft); font-size: 0.9rem; }
.file-list {
  text-align: left;
  font-family: "Lato", monospace;
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-top: 1rem;
  display: none;
}
.file-list.has-files { display: block; }
.file-list div { padding: 0.15rem 0; }

button {
  font-family: "Lato", sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 3px;
  padding: 0.7rem 1.3rem;
  cursor: pointer;
  border: 2px solid var(--red);
  background: var(--red);
  color: #fff;
  transition: background-color 0.15s ease, color 0.15s ease;
}
button:hover { background-color: var(--red-dark); border-color: var(--red-dark); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.secondary { background: transparent; color: var(--navy); border-color: var(--navy); }
button.secondary:hover { background: var(--navy); color: #fff; }
button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
#fileInput { display: none; }

.actions { display: flex; gap: 0.7rem; justify-content: center; margin-top: 1.1rem; flex-wrap: wrap; }
.actions-left { justify-content: flex-start; margin-top: 1rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.stat {
  padding: 0.9rem 1rem;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.stat:last-child { border-right: none; }
.stat .n {
  font-family: "Lato", sans-serif;
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--navy);
  display: block;
}
.stat .l {
  font-size: 0.74rem;
  color: var(--ink-soft);
  margin-top: 0.15rem;
}
.stat.warn .n { color: var(--warn); }

table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
thead th {
  text-align: left;
  font-weight: 700;
  color: #fff;
  background: var(--navy);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.5rem 0.6rem;
}
tbody td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--red-bg); }
td.num, th.num { text-align: right; font-family: "Lato", monospace; white-space: nowrap; }
td.code, th.code { font-family: "Lato", monospace; color: var(--ink-soft); white-space: nowrap; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 4px; }

details.file-card {
  border: 1px solid var(--line);
  border-radius: 4px;
  margin-bottom: 0.7rem;
  background: var(--surface);
}
details.file-card summary {
  cursor: pointer;
  padding: 0.8rem 1rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  border-left: 4px solid var(--navy);
}
details.file-card summary::-webkit-details-marker { display: none; }
.summary-main { font-weight: 700; color: var(--navy); }
.summary-meta { font-size: 0.78rem; color: var(--ink-soft); font-family: "Lato", monospace; }
details.file-card .file-body { padding: 0 1rem 1rem; }

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.4rem 1.2rem;
  padding: 0.8rem 0;
  margin-bottom: 0.8rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.82rem;
}
.meta-grid dt {
  color: var(--ink-soft);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.meta-grid dd { margin: 0.05rem 0 0; }

.divergence-block {
  border: 1px solid var(--warn);
  border-left: 4px solid var(--warn);
  border-radius: 4px;
  background: var(--warn-bg);
  padding: 1rem;
  margin-bottom: 0.7rem;
}
.divergence-block .head {
  display: flex;
  justify-content: space-between;
  font-family: "Lato", monospace;
  font-weight: 700;
  font-size: 0.82rem;
  margin-bottom: 0.5rem;
  color: var(--warn);
}
.divergence-block ul { margin: 0; padding-left: 1.1rem; font-size: 0.85rem; }
.divergence-block li { margin-bottom: 0.2rem; }

.empty-state {
  color: var(--ink-soft);
  font-size: 0.88rem;
  padding: 1.5rem;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
}
.hidden { display: none !important; }

footer.note {
  color: var(--ink-soft);
  font-size: 0.78rem;
  border-top: 4px solid var(--red);
  padding-top: 1rem;
  margin-top: 3rem;
}
