:root {
  --ink: #172033;
  --muted: #64748b;
  --line: #e2e8f0;
  --panel: rgba(255, 255, 255, .78);
  --slate: #0f172a;
  --blue: #2563eb;
  --indigo: #4f46e5;
  --green: #059669;
  --green-soft: #ecfdf5;
  --rose: #e11d48;
  --rose-soft: #fff1f2;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --shadow: 0 22px 54px rgba(148, 163, 184, .36);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; overflow-x: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at -10% -10%, rgba(96, 165, 250, .20), transparent 38%),
    radial-gradient(circle at 110% 18%, rgba(99, 102, 241, .18), transparent 34%),
    #f8fafc;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .55; cursor: not-allowed; }

.appShell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
  display: grid;
  gap: 26px;
}

.dashboardHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 24px;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 24px;
  background: rgba(255, 255, 255, .72);
  backdrop-filter: blur(18px);
  box-shadow: 0 12px 30px rgba(148, 163, 184, .16);
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}
.brand img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  box-shadow: 0 14px 24px rgba(37, 99, 235, .20);
}
.brand b {
  display: block;
  color: #0f172a;
  font-size: 23px;
  line-height: 1.1;
  font-weight: 900;
}
.brand small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.queueTicker {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.queueTicker::-webkit-scrollbar { display: none; }
.queueMini,
.server {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  border-radius: 999px;
  padding: 7px 11px;
  white-space: nowrap;
  background: rgba(255, 255, 255, .78);
  border: 1px solid rgba(226, 232, 240, .92);
  color: #475569;
  font-size: 13px;
  font-weight: 900;
}
.queueMini b { color: var(--green); }
.server i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}
.server.ready i { background: var(--green); }

.exchangeTerminal,
.batchTool {
  border: 1px solid rgba(255, 255, 255, .88);
  border-radius: 26px;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.terminalInner { padding: clamp(22px, 4vw, 40px); }
.stepBlock + .stepBlock,
.jobMeta {
  margin-top: 34px;
}
.stepTitle {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 22px;
  color: #1e293b;
  font-size: 21px;
  line-height: 1.25;
  font-weight: 900;
}
.stepTitle span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 10px;
  background: #eef2ff;
  color: var(--indigo);
  font-size: 15px;
  font-weight: 900;
}
body[data-card="locked"] #cardStepBadge {
  background: #dcfce7;
  color: var(--green);
}

.workflowGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 38px;
}
.workflowTile {
  position: relative;
  min-height: 136px;
  padding: 20px;
  overflow: hidden;
  border: 2px solid #eef2f7;
  border-radius: 18px;
  background: #fff;
  cursor: pointer;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease, background .2s ease;
}
.workflowTile:hover {
  border-color: #c7d2fe;
  background: #f8fafc;
}
.workflowTile input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.workflowTile:has(input:checked) {
  transform: translateY(-3px);
  border-color: var(--indigo);
  background: rgba(238, 242, 255, .38);
  box-shadow: 0 14px 26px rgba(79, 70, 229, .10);
}
.workflowTile:has(input:checked)::after {
  content: "✓";
  position: absolute;
  right: 16px;
  top: 16px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--indigo);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
}
.workflowTile i {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--blue), var(--indigo));
  color: #fff;
  font-style: normal;
  font-weight: 900;
}
.workflowTile b {
  display: block;
  color: #1f2937;
  font-size: 16px;
}
.workflowTile small {
  display: inline-flex;
  margin-top: 8px;
  border-radius: 7px;
  background: #f1f5f9;
  color: #64748b;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}
body[data-card="locked"] .workflowTile {
  pointer-events: none;
  opacity: .62;
}

.field {
  display: grid;
  gap: 8px;
}
.field > span {
  color: #334155;
  font-size: 13px;
  font-weight: 900;
}
.inputShell {
  position: relative;
  max-width: 760px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border: 2px solid #e2e8f0;
  border-radius: 18px;
  background: #fff;
  padding: 8px;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.inputShell:focus-within {
  border-color: var(--indigo);
  box-shadow: 0 18px 30px rgba(79, 70, 229, .10);
}
body[data-card="locked"] .inputShell {
  border-color: rgba(16, 185, 129, .55);
  background: rgba(236, 253, 245, .36);
}
.field input,
.field textarea,
.batchInputPanel textarea {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
.inputShell input {
  min-height: 50px;
  border: 0;
  padding: 0 14px;
  font-size: 17px;
  font-family: Consolas, "SFMono-Regular", monospace;
}
.field textarea {
  max-width: 760px;
  min-height: 112px;
  padding: 16px;
  resize: vertical;
  background: #f8fafc;
  font-family: Consolas, "SFMono-Regular", monospace;
  line-height: 1.5;
}
.field textarea:focus,
.batchInputPanel textarea:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, .08);
}
.field textarea.inputError {
  border-color: rgba(225, 29, 72, .58);
  background: #fff1f2;
  box-shadow: 0 0 0 4px rgba(225, 29, 72, .08);
}

.darkButton,
.ghostButton,
.primary,
.secondary,
.dangerButton,
.metricButton,
.sessionLink,
.verifyLink a {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  border: 0;
  padding: 0 16px;
  font-weight: 900;
  cursor: pointer;
  text-decoration: none;
  transition: background .18s ease, transform .18s ease, border-color .18s ease;
}
.darkButton {
  min-width: 118px;
  background: var(--slate);
  color: #fff;
}
.darkButton.full { width: 100%; margin-top: 14px; }
.darkButton:hover,
.primary:hover { transform: translateY(-1px); }
.ghostButton {
  color: #64748b;
  background: #fff;
}
.ghostButton:hover { background: #f1f5f9; }
.primary {
  min-width: 180px;
  background: linear-gradient(135deg, #10b981, var(--green));
  color: #fff;
  box-shadow: 0 12px 22px rgba(5, 150, 105, .20);
}
.secondary {
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #475569;
}
.dangerButton {
  background: var(--rose-soft);
  border: 1px solid rgba(225, 29, 72, .18);
  color: var(--rose);
}
.metricButton,
.sessionLink {
  background: #eef2ff;
  border: 1px solid #e0e7ff;
  color: var(--indigo);
}

.notice {
  max-width: 760px;
  margin-top: 12px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #475569;
  padding: 12px 14px;
  line-height: 1.55;
  font-size: 14px;
}
.notice.collapsed {
  display: none;
}
.notice.ok {
  border-color: rgba(5, 150, 105, .20);
  background: var(--green-soft);
  color: #047857;
}
.notice.error {
  border-color: rgba(225, 29, 72, .20);
  background: var(--rose-soft);
  color: var(--rose);
}
.notice.warn {
  border-color: rgba(217, 119, 6, .22);
  background: var(--amber-soft);
  color: var(--amber);
}

.sessionStep {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  margin-top: 0;
  border-top: 1px solid transparent;
  transform-origin: top;
  transition: max-height .55s ease, opacity .3s ease, margin-top .35s ease, padding-top .35s ease, border-color .35s ease;
}
body[data-card="locked"] .sessionStep,
body[data-process="failed"] .sessionStep,
body[data-process="pending"] .sessionStep,
body[data-process="processing"] .sessionStep,
body[data-process="done"] .sessionStep {
  max-height: 760px;
  opacity: 1;
  pointer-events: auto;
  margin-top: 34px;
  padding-top: 26px;
  border-color: #f1f5f9;
}
.sessionHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.sessionHead .stepTitle { margin: 0; }
.secureBadge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--indigo);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}
.sessionGuide {
  max-width: 760px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}
.accountLine {
  max-width: 760px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  padding: 11px 14px;
}
.accountLine span { color: var(--muted); font-size: 13px; font-weight: 900; }
.accountLine b { word-break: break-all; }
.actionRow {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.statusBanner {
  max-width: 760px;
  margin-top: 12px;
  display: none;
  align-items: center;
  min-height: 48px;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #64748b;
  padding: 12px 14px;
  line-height: 1.5;
  font-weight: 800;
}
body[data-card="locked"] .statusBanner,
body[data-process="pending"] .statusBanner,
body[data-process="processing"] .statusBanner,
body[data-process="done"] .statusBanner,
body[data-process="failed"] .statusBanner,
body[data-process="cancelled"] .statusBanner {
  display: flex;
}
.statusBanner.ok { background: var(--green-soft); border-color: rgba(5, 150, 105, .20); color: #047857; }
.statusBanner.error { background: var(--rose-soft); border-color: rgba(225, 29, 72, .20); color: var(--rose); }
.statusBanner.warn { background: var(--amber-soft); border-color: rgba(217, 119, 6, .22); color: var(--amber); }

.jobMeta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid #f1f5f9;
}
.jobMeta > div {
  min-width: 0;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: rgba(248, 250, 252, .78);
  padding: 12px;
}
.jobMeta span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.jobMeta b {
  display: block;
  margin-top: 6px;
  color: #1e293b;
  word-break: break-word;
}
.jobMeta .wide {
  grid-column: 1 / -1;
}
.bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}
.bar span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--green));
  transition: width .25s ease;
}
#step3ProgressText {
  margin: 10px 0;
  color: var(--muted);
  font-size: 13px;
}
.resultBox {
  color: #475569;
  line-height: 1.55;
}

.supportGrid {
  display: grid;
  grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
  gap: 18px;
}
.verifyLink,
.queuePanel {
  border: 1px solid rgba(226, 232, 240, .86);
  border-radius: 22px;
  background: rgba(255, 255, 255, .70);
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 30px rgba(148, 163, 184, .16);
  padding: 22px;
}
.verifyLink {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.verifyLink h2,
.queuePanel h2,
.batchHeader h2 {
  margin: 0;
  color: #1e293b;
}
.verifyLink p,
.queuePanel p,
.batchHeader p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}
.verifyLink a {
  flex: 0 0 auto;
  background: #eef2ff;
  color: var(--indigo);
  border: 1px solid #e0e7ff;
}
.panelHead {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.queueSummary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.queueSummary div,
.queueCard {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}
.queueSummary span,
.queueCard span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}
.queueSummary b,
.queueCard b {
  display: block;
  margin-top: 6px;
  color: #1e293b;
  font-size: 20px;
}
.queueGrid {
  display: grid;
  gap: 10px;
}
.queueCard.active {
  border-color: rgba(79, 70, 229, .36);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, .06);
}
.queueCard span {
  margin-top: 5px;
  line-height: 1.45;
  font-weight: 700;
}

.batchHeader {
  padding: 24px 28px;
  border-bottom: 1px solid #f1f5f9;
  background: rgba(248, 250, 252, .70);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.batchStats {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  padding: 9px 12px;
  color: #475569;
  font-size: 14px;
  font-weight: 800;
}
.batchStats b { color: #1e293b; }
.batchBody {
  display: grid;
  grid-template-columns: minmax(260px, .42fr) minmax(0, .58fr);
}
.batchInputPanel {
  padding: 22px;
  background: #fff;
  border-right: 1px solid #f1f5f9;
}
.batchInputPanel textarea {
  min-height: 260px;
  padding: 14px;
  resize: vertical;
  background: #f8fafc;
  font-family: Consolas, "SFMono-Regular", monospace;
  line-height: 1.5;
}
.batchResultPanel {
  padding: 22px;
  background: rgba(248, 250, 252, .46);
}
.emptyResult {
  min-height: 260px;
  display: grid;
  place-items: center;
  border: 2px dashed #e2e8f0;
  border-radius: 18px;
  background: rgba(255, 255, 255, .56);
  color: #94a3b8;
  font-size: 14px;
  font-weight: 800;
}
.batchTableWrap {
  max-height: 340px;
  overflow: auto;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  background: #fff;
}
.batchTableWrap table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  font-size: 13px;
}
.batchTableWrap th,
.batchTableWrap td {
  padding: 11px 12px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
}
.batchTableWrap th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(248, 250, 252, .94);
  color: #64748b;
  font-weight: 900;
}
.statusPill {
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 900;
}
.statusPill.ok { background: var(--green-soft); color: #047857; }
.statusPill.warn { background: #f1f5f9; color: #64748b; }
.statusPill.error { background: var(--rose-soft); color: var(--rose); }
.useButton {
  min-height: 30px;
  border: 0;
  border-radius: 8px;
  background: #eef2ff;
  color: var(--indigo);
  padding: 0 10px;
  font-weight: 900;
  cursor: pointer;
}
.useButton:disabled { opacity: .5; cursor: not-allowed; }

.maintenancePage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #f8fafc, #eef6f4);
}
.maintenancePanel {
  width: min(100%, 520px);
  border: 1px solid rgba(226, 232, 240, .92);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .12);
  padding: 34px;
  text-align: center;
}
.maintenancePanel img {
  width: 54px;
  height: 54px;
}
.maintenancePanel span {
  display: block;
  margin-top: 14px;
  color: #0f766e;
  font-size: 13px;
  font-weight: 900;
}
.maintenancePanel h1 {
  margin: 8px 0 10px;
  color: #0f172a;
  font-size: 30px;
  line-height: 1.2;
}
.maintenancePanel p {
  margin: 0;
  color: #475569;
  line-height: 1.7;
  font-weight: 800;
}

.verificationModal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, .46);
}
.verificationModal[hidden] {
  display: none;
}
.verificationDialog {
  position: relative;
  width: min(100%, 520px);
  border: 1px solid rgba(226, 232, 240, .92);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .24);
  padding: 26px;
}
.verificationClose {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: #f1f5f9;
  color: #475569;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.modalEyebrow {
  margin: 0 0 8px;
  color: #047857;
  font-size: 13px;
  font-weight: 900;
}
.verificationDialog h2 {
  margin: 0;
  color: #0f172a;
  font-size: 24px;
  line-height: 1.25;
}
.verificationDialog p {
  margin: 12px 0 0;
  color: #475569;
  line-height: 1.55;
  font-weight: 800;
}
#verificationSessionText {
  width: 100%;
  min-height: 118px;
  margin-top: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  color: #334155;
  padding: 12px;
  resize: vertical;
  font: 13px/1.45 Consolas, "SFMono-Regular", monospace;
}
.verificationActions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

@media (max-width: 900px) {
  .appShell {
    width: min(100% - 24px, 1120px);
    padding-top: 14px;
    gap: 14px;
  }
  .dashboardHeader {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
    padding: 14px;
    border-radius: 18px;
  }
  .queueTicker {
    width: 100%;
    justify-content: flex-start;
  }
  .terminalInner { padding: 18px; }
  .workflowGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .supportGrid,
  .batchBody {
    grid-template-columns: 1fr;
  }
  .batchInputPanel {
    border-right: 0;
    border-bottom: 1px solid #f1f5f9;
  }
}

@media (max-width: 560px) {
  .brand b { font-size: 18px; }
  .brand small { font-size: 12px; }
  .queueTicker { gap: 8px; }
  .queueMini, .server { font-size: 12px; }
  .exchangeTerminal,
  .batchTool {
    border-radius: 18px;
  }
  .workflowGrid,
  .jobMeta,
  .queueSummary {
    grid-template-columns: 1fr;
  }
  .workflowTile {
    min-height: 110px;
    padding: 14px;
  }
  .stepTitle {
    font-size: 19px;
    overflow-wrap: anywhere;
  }
  .inputShell {
    grid-template-columns: 1fr;
  }
  .darkButton,
  .ghostButton,
  .primary,
  .secondary,
  .dangerButton,
  .sessionLink,
  .verifyLink a {
    width: 100%;
  }
  .sessionHead,
  .sessionGuide,
  .actionRow,
  .verifyLink,
  .batchHeader {
    align-items: stretch;
    flex-direction: column;
  }
  .batchStats {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }
}
