:root {
  --bg: #07100d;
  --shell: #0b1712;
  --panel: #101c17;
  --panel2: #15241e;
  --line: #57d98b;
  --line-soft: rgba(87, 217, 139, .34);
  --text: #f3fff8;
  --muted: #afbeb6;
  --muted2: #809189;
  --input: #eef4f0;
  --danger: #c4493d;
  --warn: #f0c86b;
  --blue: #98c8ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(87, 217, 139, .13), transparent 34%),
    linear-gradient(180deg, #07100d 0%, #0a1410 42%, #07100d 100%);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(7, 16, 13, .95);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brandBlock {
  display: grid;
  gap: 4px;
}

.topActions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.visuallyHiddenFile {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 25px; letter-spacing: 0; }
h2 { font-size: 18px; }
h3 { font-size: 17px; }
p { color: var(--muted); line-height: 1.45; }

main {
  padding: 12px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.eyebrow {
  color: #76ff9f;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.panel {
  border: 1px solid var(--line-soft);
  border-top: 2px solid var(--line);
  background: linear-gradient(180deg, rgba(18, 31, 25, .98), rgba(10, 20, 16, .99));
  border-radius: 7px;
  padding: 12px;
  box-shadow: 0 18px 54px rgba(0, 0, 0, .25);
}

.uploadPanel {
  display: grid;
  grid-template-columns: minmax(360px, 1.15fr) minmax(430px, .85fr);
  gap: 10px;
  align-items: stretch;
}

.uploadBox {
  border: 1px dashed var(--line);
  min-height: 82px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: rgba(238, 244, 240, .045);
  color: var(--muted);
  text-align: center;
  border-radius: 6px;
}

.uploadBox strong {
  color: var(--text);
  font-size: 17px;
}

.hasWorkbook .uploadPanel {
  padding: 8px 12px;
}

.hasWorkbook .uploadBox {
  min-height: 58px;
  flex-direction: row;
  justify-content: flex-start;
  text-align: left;
  padding: 0 14px;
}

.hasWorkbook .uploadBox strong {
  font-size: 14px;
}

.hasWorkbook .uploadBox span {
  font-size: 12px;
}

.hasWorkbook .stat {
  min-height: 52px;
  padding: 8px 10px;
}

input[type=file] {
  color: var(--muted);
  max-width: min(520px, 100%);
}

.statusBox {
  display: grid;
  grid-template-columns: 1.35fr .65fr .75fr .8fr;
  gap: 8px;
}

.stat {
  border: 1px solid rgba(255,255,255,.12);
  padding: 9px 10px;
  background: #0b1612;
  min-height: 64px;
  border-radius: 6px;
}

.stat span {
  display: block;
  color: var(--muted2);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.stat strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.apiStat {
  position: relative;
}

.apiStat::before {
  content: "";
  position: absolute;
  top: 11px;
  right: 10px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 12px rgba(240, 200, 107, .55);
}

.apiStat.api-ok::before {
  background: var(--line);
  box-shadow: 0 0 12px rgba(87, 217, 139, .65);
}

.apiStat.api-error::before {
  background: var(--danger);
  box-shadow: 0 0 12px rgba(196, 73, 61, .65);
}

.apiStat.api-auth::before {
  background: var(--blue);
  box-shadow: 0 0 12px rgba(152, 200, 255, .65);
}

.statButton {
  margin-top: 5px;
  padding: 3px 7px;
  min-height: auto;
  font-size: 10px;
  border-color: rgba(255,255,255,.18);
  background: rgba(238, 244, 240, .08);
  color: var(--muted);
}

.sectionHead {
  margin-bottom: 8px;
}

.splitHead,
.entityHeader,
.sampleHeader,
.modalHead {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.entityHeader,
.sampleHeader,
.modalHead {
  margin-bottom: 10px;
}

.modalHead {
  padding-right: 34px;
}

.actionRow {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.actionRow.compact {
  justify-content: flex-end;
  max-width: 600px;
}

#actionStatus {
  color: var(--muted);
  font-size: 13px;
}

button {
  border: 1px solid var(--line);
  background: #64db8b;
  color: #03100a;
  border-radius: 6px;
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
  min-height: 34px;
}

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

.autoSendButton {
  background: #d33d32;
  border-color: #ff8376;
  color: #fff;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 12px 24px rgba(196, 73, 61, .22);
}

.autoSendButton:hover {
  background: #ed584b;
}

.autoSendButton.ready {
  background: #64db8b;
  border-color: #9fffc1;
  color: #03100a;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 12px 24px rgba(87, 217, 139, .22);
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

#sendAllBtn {
  background: #d33d32;
  border-color: rgba(255,255,255,.18);
  color: #fff;
}

#sendAllBtn.success {
  background: #57d98b;
  color: #04110b;
  opacity: 1;
}

.sendButton {
  width: 74px;
  min-height: 26px;
  padding: 4px 7px;
  border-radius: 5px;
  border-color: rgba(255,255,255,.16);
  background: #d33d32;
  color: #fff;
  font-size: 11px;
  line-height: 1;
}

.sendButton.sending {
  background: #f0c86b;
  color: #09140f;
}

.sendButton.success {
  background: #57d98b;
  color: #04110b;
}

.sendButton.failed {
  background: #7e211b;
  color: #fff;
}

.sendButton.success:disabled {
  opacity: 1;
}

.reviewPill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.16);
  font-weight: 800;
  cursor: help;
}

.reviewPill.clear {
  color: var(--muted);
  background: rgba(238, 244, 240, .05);
}

.reviewPill.needsReview {
  color: #07100d;
  background: var(--warn);
  border-color: rgba(240, 200, 107, .75);
}

.sendErrorList {
  margin: 8px 0 0;
  color: #ffcbc6;
  line-height: 1.5;
}

.historyBody {
  display: grid;
  gap: 12px;
}

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

.historyActions button {
  min-height: 28px;
  padding: 5px 8px;
  font-size: 11px;
}

.historySuccess {
  color: #79ffa1;
  font-weight: 800;
}

.historyFailed {
  color: #ffb1a8;
  font-weight: 800;
}

.samplePanel {
  padding-bottom: 8px;
  flex: 1;
}

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

.sampleActions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.gridSummary span {
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: #08150f;
  font-weight: 800;
  font-size: 12px;
}

.sampleGrid {
  min-height: 300px;
}

.tabulator {
  border: 1px solid rgba(255,255,255,.12);
  background: #07130f;
  border-radius: 6px;
  overflow: hidden;
  font-size: 13px;
}

.tabulator .tabulator-header {
  border-bottom-color: var(--line-soft);
  background: #0b1712;
}

.tabulator .tabulator-header .tabulator-col {
  background: #0b1712;
  border-right-color: rgba(255,255,255,.1);
  color: #77ff9e;
  font-weight: 800;
}

.tabulator .tabulator-row {
  background: #0c1813;
  color: var(--text);
  border-bottom-color: rgba(255,255,255,.08);
}

.tabulator .tabulator-row:nth-child(even) {
  background: #0f1d17;
}

.tabulator .tabulator-row.tabulator-selected,
.tabulator .tabulator-row.tabulator-selected:hover {
  background: rgba(87, 217, 139, .26);
}

.tabulator .tabulator-row:hover {
  background: rgba(87, 217, 139, .13);
}

.detailGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.wide {
  grid-column: 1 / -1;
}

.comparisonSummary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.detailActionStack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  min-width: 220px;
}

.detailSendBtn {
  background: #d33d32;
  color: #fff;
  min-width: 190px;
}

.detailSendBtn:disabled {
  cursor: not-allowed;
  opacity: .75;
}

.detailSendBtn:not(:disabled) {
  background: #57d98b;
  color: #04110b;
}

.detailSendBtn.blocked {
  background: #7e211b;
  color: #fff;
}

.detailSendBtn.sent {
  background: #57d98b;
  color: #04110b;
  opacity: 1;
}

.badge {
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  background: #08150f;
}

.badge.match { color: #79ffa1; }
.badge.different { color: #ffb1a8; border-color: rgba(255, 177, 168, .55); }
.badge.sentBlank { color: #d3c2ff; border-color: rgba(211, 194, 255, .55); }
.badge.payloadOnly { color: var(--warn); border-color: rgba(247, 212, 123, .55); }
.badge.mjOnly { color: var(--blue); border-color: rgba(169, 216, 255, .55); }

.preflightSection {
  border-color: rgba(87, 217, 139, .34);
}

.preflightStatus,
.preflightPill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 900;
}

.preflightStatus {
  min-width: 148px;
  padding: 7px 12px;
  border: 1px solid rgba(255,255,255,.16);
  font-size: 12px;
}

.preflightStatus.clear,
.preflightPill.clear {
  background: #57d98b;
  color: #04110b;
}

.preflightStatus.blocked,
.preflightPill.blocked {
  background: #d33d32;
  color: #fff;
}

.preflightPill {
  min-width: 44px;
  padding: 3px 8px;
  font-size: 11px;
}

.preflightWarnings {
  color: var(--warn);
  font-size: 12px;
  margin: 8px 0;
}

.lookupPanel {
  border: 1px solid rgba(255,255,255,.1);
  background: #07130f;
  padding: 10px;
  border-radius: 6px;
}

.lookupPanel.compactLookup {
  padding: 9px;
}

.lookupEmpty {
  color: var(--muted);
  font-size: 14px;
}

.lookupStatus {
  color: #76ff9f;
  font-weight: 800;
  margin-bottom: 11px;
}

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

.lookupCard {
  border: 1px solid var(--line-soft);
  background: #0c1a14;
  padding: 9px;
  min-height: 58px;
  border-radius: 5px;
}

.lookupCard span {
  display: block;
  color: var(--muted2);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.lookupCard strong {
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.compactCards .lookupCard {
  min-height: 54px;
  padding: 8px;
}

.compactCards .lookupCard strong {
  font-size: 13px;
}

.table {
  overflow: auto;
  border: 1px solid rgba(255,255,255,.1);
  max-height: 360px;
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 8px 9px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  vertical-align: top;
}

th {
  color: #77ff9e;
  background: #0b1712;
  position: sticky;
  top: 0;
}

tr:hover td {
  background: rgba(87, 217, 139, .08);
}

.comparisonTable {
  margin-top: 10px;
  max-height: 330px;
}

.preflightTable {
  margin-top: 10px;
  max-height: 310px;
}

.comparison-match td:last-child {
  color: #79ffa1;
  font-weight: 800;
}

.comparison-different {
  background: rgba(196, 73, 61, .16);
}

.comparison-different td:last-child {
  color: #ffb1a8;
  font-weight: 800;
}

.comparison-payload-only td:last-child {
  color: var(--warn);
  font-weight: 800;
}

.comparison-sent-mj-returned-blank td:last-child {
  color: #d3c2ff;
  font-weight: 800;
}

.comparison-mj-only td:last-child {
  color: var(--blue);
  font-weight: 800;
}

pre {
  margin: 0;
  max-height: 360px;
  overflow: auto;
  background: #06100c;
  border: 1px solid rgba(255,255,255,.12);
  color: #ddffea;
  padding: 12px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.45;
}

.modal, .loading {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.68);
  display: grid;
  place-items: center;
  z-index: 40;
}

.modalCard, .loaderCard {
  width: min(760px, calc(100vw - 36px));
  background: #07110d;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  position: relative;
}

.detailModalCard {
  width: min(1180px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.modalGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modalSection {
  margin-top: 12px;
}

.modalTable {
  max-height: 260px;
}

.modalCard ol {
  color: var(--muted);
  line-height: 1.6;
}

.close {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 26px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  border-color: rgba(255,255,255,.16);
  line-height: 1;
  z-index: 2;
}

.close:hover {
  color: var(--text);
  border-color: var(--line-soft);
  background: rgba(255,255,255,.06);
}

.loaderCard {
  text-align: center;
}

.spinner {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  margin: 0 auto 18px;
  border: 4px solid rgba(118,255,159,.18);
  border-top-color: #76ff9f;
  animation: spin 1s linear infinite;
}

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

[hidden] { display: none !important; }

@media (max-width: 1050px) {
  .uploadPanel, .detailGrid, .lookupGrid, .modalGrid {
    grid-template-columns: 1fr;
  }
  .statusBox {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 780px) {
  main {
    padding: 14px;
  }
  .topbar, .splitHead, .entityHeader, .sampleHeader, .modalHead {
    align-items: flex-start;
    flex-direction: column;
  }
  .actionRow.compact, .gridSummary {
    justify-content: flex-start;
  }
}
