:root {
  color-scheme: light;
  --bg: #edf1ef;
  --surface: #ffffff;
  --surface-soft: #f6f8f7;
  --ink: #171b19;
  --muted: #67706b;
  --line: #d7ded9;
  --strong-line: #b8c3bc;
  --green: #16875b;
  --green-dark: #0d6844;
  --green-soft: #e4f5ed;
  --amber: #9b6200;
  --amber-soft: #fff3d7;
  --red: #b73636;
  --red-soft: #fde9e7;
  --shadow: 0 12px 34px rgba(24, 35, 29, .08);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  letter-spacing: 0;
}

button, textarea { font: inherit; letter-spacing: 0; }

button { cursor: pointer; }

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

.hidden { display: none !important; }

.topbar {
  height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #151918;
  color: #f7faf8;
  border-bottom: 3px solid var(--green);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand img { border-radius: 7px; flex: 0 0 auto; }
.brand div { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand strong { font-size: 16px; }
.brand span { color: #aeb8b2; font-size: 11px; }

.queue {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #c7d0cb;
  font-size: 12px;
  white-space: nowrap;
}

.healthDot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d89829;
  box-shadow: 0 0 0 3px rgba(216, 152, 41, .15);
}

.queue.online .healthDot { background: #45c888; box-shadow: 0 0 0 3px rgba(69, 200, 136, .15); }
.queue.offline .healthDot { background: #ee6d6d; box-shadow: 0 0 0 3px rgba(238, 109, 109, .15); }

main { max-width: 1240px; margin: 0 auto; padding: 24px 24px 56px; }

.submitBand,
.resultsBand {
  background: var(--surface);
  border: 1px solid var(--line);
}

.submitBand { box-shadow: var(--shadow); }
.resultsBand { margin-top: 18px; }

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

.eyebrow {
  display: block;
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

h1, h2 { margin: 2px 0 0; font-size: 19px; line-height: 1.25; letter-spacing: 0; }
.counter { color: var(--muted); font-variant-numeric: tabular-nums; }
.counter.bad { color: var(--red); font-weight: 700; }

.inputGrid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr);
  min-height: 250px;
}

.field { display: flex; flex-direction: column; min-width: 0; }
.field + .field { border-left: 1px solid var(--line); }
.field > span { padding: 11px 16px; font-size: 12px; font-weight: 700; background: var(--surface-soft); border-bottom: 1px solid var(--line); }

textarea {
  display: block;
  width: 100%;
  min-height: 215px;
  padding: 15px 16px;
  resize: vertical;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: var(--surface);
  line-height: 1.55;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
}

textarea:focus { box-shadow: inset 0 0 0 2px var(--green); }
textarea::placeholder { color: #929b96; }

.submitBar {
  min-height: 62px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.formStatus { color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.formStatus.error { color: var(--red); }
.actions, .modalActions { display: flex; align-items: center; gap: 8px; }

.button,
.iconButton {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 38px;
  padding: 0 15px;
  font-weight: 700;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.button.primary { background: var(--green); color: white; border-color: var(--green); }
.button.primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
.button.secondary { background: white; color: var(--ink); border-color: var(--strong-line); }
.button.secondary:hover { border-color: #7d8a82; background: #f9fbfa; }
.button.danger { background: white; color: var(--red); border-color: #e3a3a0; }
.button.danger:hover { background: var(--red-soft); }

.resultsHeading { min-height: 64px; }
.summary { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 12px; }
.summary b { color: var(--ink); font-size: 16px; font-variant-numeric: tabular-nums; }

.warnings {
  padding: 10px 18px;
  color: var(--amber);
  background: var(--amber-soft);
  border-bottom: 1px solid #efd8a6;
  line-height: 1.5;
}

.empty {
  min-height: 210px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
}

.emptyMark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--strong-line);
  border-radius: 7px;
  color: var(--green-dark);
  font-weight: 800;
}

.resultList { display: flex; flex-direction: column; }

.resultRow {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(190px, .85fr) minmax(180px, 1.2fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 92px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.resultRow:last-child { border-bottom: 0; }
.resultIdentity, .resultProgress, .resultOutput { min-width: 0; }
.resultIdentity strong, .resultOutput a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resultIdentity span, .resultProgress span, .resultOutput span { display: block; margin-top: 5px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

.state {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  background: #e9eeeb;
  color: #46504a;
  font-size: 11px;
  font-weight: 800;
}

.state.running, .state.queued, .state.canceling { color: var(--amber); background: var(--amber-soft); }
.state.success, .state.completed { color: var(--green-dark); background: var(--green-soft); }
.state.failed, .state.callback_failed, .state.callback_unconfirmed { color: var(--red); background: var(--red-soft); }

.progressTrack { height: 5px; margin-top: 8px; background: #e6ebe8; overflow: hidden; }
.progressTrack i { display: block; width: 16%; height: 100%; background: var(--green); transition: width .25s ease; }

.resultOutput a { color: var(--green-dark); text-decoration: none; }
.resultOutput a:hover { text-decoration: underline; }
.resultOutput .errorText { color: var(--red); white-space: normal; }

.rowActions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; min-width: 210px; }
.rowActions .button { min-height: 34px; padding: 0 11px; font-size: 12px; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(17, 22, 19, .68);
}

.modalPanel {
  width: min(460px, 100%);
  background: var(--surface);
  border: 1px solid var(--strong-line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .25);
}

.modalHeader { min-height: 68px; padding: 13px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.iconButton { width: 36px; min-height: 36px; padding: 0; background: white; color: var(--ink); border-color: var(--line); font-size: 23px; line-height: 1; }
.iconButton:hover { background: var(--surface-soft); }

.qrFrame {
  width: min(320px, calc(100% - 48px));
  aspect-ratio: 1;
  margin: 22px auto 14px;
  display: grid;
  place-items: center;
  background: white;
  border: 1px solid var(--line);
  overflow: hidden;
}

.qrFrame img { display: block; width: 100%; height: 100%; object-fit: contain; image-rendering: crisp-edges; }
.qrPending { color: var(--muted); font-weight: 700; }
.qrMeta { padding: 0 20px 16px; text-align: center; }
.qrMeta strong, .qrMeta span { display: block; overflow-wrap: anywhere; }
.qrMeta span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.modalActions { padding: 14px 16px; justify-content: flex-end; border-top: 1px solid var(--line); background: var(--surface-soft); }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 30;
  max-width: min(380px, calc(100vw - 40px));
  padding: 11px 14px;
  color: white;
  background: #202622;
  border-radius: 6px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .resultRow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .rowActions { min-width: 0; justify-content: flex-start; }
}

@media (max-width: 700px) {
  .topbar { height: 58px; padding: 0 15px; }
  .brand span { display: none; }
  main { padding: 14px 10px 40px; }
  .inputGrid { grid-template-columns: 1fr; }
  .field + .field { border-left: 0; border-top: 1px solid var(--line); }
  textarea { min-height: 160px; }
  .sectionHeading { padding: 13px 14px; }
  .submitBar { align-items: stretch; flex-direction: column; }
  .actions { justify-content: flex-end; }
  .summary { gap: 9px; }
  .summary span { display: flex; flex-direction: column; align-items: center; }
  .resultRow { grid-template-columns: 1fr; gap: 11px; padding: 15px 14px; }
  .rowActions { flex-wrap: wrap; }
  .modalActions { flex-wrap: wrap; }
  .modalActions .button { flex: 1 1 120px; }
}
