﻿:root {
  --paper: #f4f6f3;
  --surface: #fffef9;
  --ink: #171a1f;
  --muted: #66716b;
  --line: #cfd8d0;
  --green: #174f43;
  --green-dark: #0f3932;
  --blue: #284f8f;
  --red: #b5483c;
  --gold: #c18426;
  --shadow: 0 18px 44px rgba(23, 26, 31, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23, 79, 67, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(40, 79, 143, 0.055) 1px, transparent 1px),
    var(--paper);
  background-size: 44px 44px;
  font: 16px/1.6 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(23, 26, 31, 0.2);
  border-radius: 8px;
  color: var(--surface);
  background: var(--blue);
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(23, 26, 31, 0.45);
}

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

button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.shell {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 48px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--green);
  border-radius: 8px;
  color: var(--surface);
  background: var(--green);
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
}

nav {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 0.95rem;
}

nav a {
  border-bottom: 1px solid transparent;
}

nav a:hover,
nav a[aria-current="page"] {
  color: var(--ink);
  border-color: var(--ink);
}

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

h1,
h2 {
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: 0;
}

.app-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 44px 0 28px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.6rem, 7vw, 5.2rem);
  line-height: 0.98;
}

.load-state {
  display: grid;
  gap: 8px;
  min-width: min(100%, 290px);
  color: var(--muted);
  font-size: 0.92rem;
}

.load-track {
  display: block;
  width: 100%;
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 254, 249, 0.74);
}

.load-track span {
  display: block;
  width: 18%;
  height: 100%;
  border-radius: inherit;
  background: var(--gold);
  transition: width 180ms ease, background 180ms ease;
}

.load-track span.is-ready {
  width: 100%;
  background: var(--green);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.controls,
.results,
.missing-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 254, 249, 0.94);
  box-shadow: var(--shadow);
}

.controls {
  display: grid;
  gap: 20px;
  padding: 18px;
  position: sticky;
  top: 18px;
}

.upload-target {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 104px;
  padding: 16px;
  border: 1px dashed rgba(23, 79, 67, 0.45);
  border-radius: 8px;
  background: rgba(244, 246, 243, 0.74);
  cursor: pointer;
}

.upload-target.is-dragging {
  border-color: var(--green);
  background: rgba(23, 79, 67, 0.08);
}

.upload-target strong,
.upload-target small {
  display: block;
}

.upload-target small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.upload-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  color: var(--surface);
  background: var(--green);
}

.upload-icon svg {
  width: 23px;
  height: 23px;
}

#fileInput {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.range-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 56px;
  gap: 12px;
  align-items: center;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--green);
}

output {
  display: grid;
  min-height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-weight: 800;
}

input[type="search"] {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
}

.switches {
  display: grid;
  gap: 8px;
}

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.switch input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

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

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

.stats div {
  display: grid;
  gap: 8px;
  min-height: 90px;
  padding: 16px;
  background: rgba(255, 254, 249, 0.96);
}

.stats span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stats strong {
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 1.65rem;
  font-weight: 500;
  line-height: 1;
}

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

.table-toolbar h2 {
  margin-bottom: 4px;
  font-size: 1.5rem;
  line-height: 1.1;
}

.table-toolbar p {
  margin-bottom: 0;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.actions button:last-child {
  background: var(--red);
}

.empty-state {
  display: grid;
  min-height: 360px;
  place-items: center;
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.empty-state.is-busy::after {
  width: 28px;
  height: 28px;
  margin-top: 14px;
  border: 3px solid var(--line);
  border-top-color: var(--green);
  border-radius: 50%;
  content: "";
  animation: spin 800ms linear infinite;
}

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

.table-wrap--compact {
  max-height: 420px;
  border-top: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

th,
td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(207, 216, 208, 0.86);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: #f7f8f4;
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  font-size: 0.95rem;
}

td:first-child {
  color: var(--blue);
  font-weight: 800;
}

.number-cell {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.context-cell {
  min-width: 300px;
  max-width: 620px;
  color: #3f4743;
  line-height: 1.45;
}

.missing-panel {
  margin: 18px;
  box-shadow: none;
}

.missing-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 50px;
  padding: 0 16px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 800;
}

.missing-panel summary::marker {
  color: var(--green);
}

.missing-panel summary span:last-child {
  color: var(--muted);
  font-weight: 700;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 52px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.92rem;
}

footer a {
  border-bottom: 1px solid transparent;
}

footer a:hover {
  color: var(--ink);
  border-color: var(--ink);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

  .controls {
    position: static;
  }

  .switches {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-head,
  .table-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .actions {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 28px, 1240px);
  }

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

  nav {
    flex-wrap: wrap;
    gap: 12px 16px;
  }

  .app-head {
    padding: 34px 0 22px;
  }

  .switches,
  .stats {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    max-height: 560px;
  }

  th,
  td {
    padding: 10px;
  }

  .context-cell {
    min-width: 240px;
  }
}

