:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #64748b;
  --line: #dce5f1;
  --primary: #1769e0;
  --primary-dark: #0f52b5;
  --success: #138a57;
  --warning: #b7791f;
  --danger: #c2413b;
  --sidebar: #172033;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

input,
textarea,
select,
button {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.site-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 48px;
}

.front-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.header-actions {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.front-header h1 {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.2;
}

.front-header p {
  margin: 0;
  color: var(--muted);
}

.plain-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
}

.panel,
.sub-panel,
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 34px rgba(23, 32, 51, .08);
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
  gap: 0;
  overflow: hidden;
}

.flow-panel {
  padding: 0;
  overflow: hidden;
}

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

.stepper button {
  border: 0;
  background: transparent;
  color: #5b6b82;
  padding: 16px 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.stepper button span {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e6edf7;
  color: #4b5d75;
  font-size: 12px;
}

.stepper button.active {
  color: var(--primary);
  background: #f0f6ff;
}

.stepper button.active span {
  background: var(--primary);
  color: #fff;
}

.stepper button:disabled {
  cursor: default;
  opacity: .75;
}

.flow-step {
  padding: 28px;
}

.narrow-form {
  max-width: 620px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

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

.inline-note,
.muted-line {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.confirm-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 16px;
  margin-bottom: 16px;
}

.confirm-grid {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 12px;
}

.confirm-grid span {
  color: var(--muted);
}

.mono {
  font-family: Consolas, Menlo, Monaco, "Courier New", monospace;
}

.success-btn {
  background: var(--success);
}

.success-btn:hover {
  background: #0f7348;
}

.danger-btn {
  background: var(--danger);
  color: #fff;
}

.danger-btn:hover {
  background: #9f312c;
}

.result-hero {
  text-align: center;
  margin-bottom: 16px;
}

.result-hero h2 {
  margin: 8px 0 6px;
}

.result-hero p {
  margin: 0;
  color: var(--muted);
}

.done-mark {
  display: inline-grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #e5f7ee;
  color: var(--success);
  font-size: 30px;
  font-weight: 900;
}

.query-panel {
  padding: 26px;
  margin-top: 18px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.mini-stat {
  text-align: left;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 13px;
}

.mini-stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.mini-stat strong {
  font-size: 24px;
}

.mini-stat.success {
  border-color: #b7ead1;
  background: #f2fbf6;
}

.mini-stat.warning {
  border-color: #f1d58f;
  background: #fff9eb;
}

.mini-stat.danger {
  border-color: #f2b9b5;
  background: #fff1f0;
}

.query-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.query-results {
  margin-top: 14px;
}

.front-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

.section-block {
  padding: 26px;
}

.section-block + .section-block {
  border-left: 1px solid var(--line);
}

.muted-block {
  background: #fbfcff;
}

.section-heading {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.section-heading h2,
.sub-panel h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.step-num {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  flex: 0 0 auto;
}

.form-stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
}

label > span {
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cbd7e6;
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, .13);
}

.primary-btn,
.secondary-btn,
.ghost-btn {
  border: 0;
  border-radius: 7px;
  padding: 10px 14px;
  font-weight: 800;
  min-height: 42px;
}

.primary-btn {
  background: var(--primary);
  color: #fff;
}

.primary-btn:hover {
  background: var(--primary-dark);
}

.secondary-btn {
  background: #e9f1ff;
  color: #114a9f;
  border: 1px solid #c9dcfb;
}

.ghost-btn {
  background: rgba(255, 255, 255, .08);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, .14);
}

.small {
  min-height: 36px;
  padding: 7px 12px;
}

.package-preview,
.result-box,
.notice {
  border: 1px solid #cde0fb;
  background: #f1f6ff;
  border-radius: 8px;
  padding: 14px;
  color: #1e3a5f;
}

.package-preview strong,
.result-box strong {
  display: block;
  margin-bottom: 6px;
}

.result-grid {
  display: grid;
  gap: 9px;
  margin-top: 10px;
}

.result-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px dashed #d9e4f4;
  padding-bottom: 8px;
}

.result-row span:first-child {
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}

.status.pending {
  color: #8a5a00;
  background: #fff4d8;
}

.status.processing {
  color: #114a9f;
  background: #e8f1ff;
}

.status.completed {
  color: #0d6b43;
  background: #e5f7ee;
}

.status.failed,
.status.problem,
.status.cancelled {
  color: #9f2d28;
  background: #ffe9e7;
}

.status.unused,
.status.returned {
  color: #585d08;
  background: #fbf8cc;
}

.status.disabled,
.status.expired,
.status.missing,
.status.unknown {
  color: #8b2f2a;
  background: #ffe4e1;
}

.row-ok td,
.row-completed td {
  background: #fbfffd;
}

.row-pending td {
  background: #fffdf7;
}

.row-fail td {
  background: #fffafa;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.notice {
  margin-top: 18px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 11px 14px;
  border-radius: 8px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .2);
  z-index: 50;
}

.admin-body {
  background: #eef3f9;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  display: grid;
  gap: 15px;
}

.login-card h1 {
  margin: 0;
  font-size: 24px;
}

.login-card p {
  margin: 0;
  color: var(--muted);
}

.admin-shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 18px;
  gap: 18px;
}

.brand {
  display: grid;
  gap: 5px;
}

.brand strong {
  font-size: 18px;
}

.brand span {
  color: #aab7c8;
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 6px;
  flex: 1;
}

.nav-list button {
  border: 0;
  border-radius: 7px;
  text-align: left;
  padding: 11px 12px;
  background: transparent;
  color: #cbd5e1;
  font-weight: 700;
}

.nav-list button.active,
.nav-list button:hover {
  background: rgba(255, 255, 255, .11);
  color: #fff;
}

.admin-main {
  padding: 22px;
  min-width: 0;
}

.admin-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.admin-topbar h1 {
  margin: 0 0 5px;
  font-size: 24px;
}

.admin-topbar p {
  margin: 0;
  color: var(--muted);
}

.admin-panel {
  display: grid;
  gap: 16px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.stat-card strong {
  font-size: 28px;
}

.stat-card.success strong { color: var(--success); }
.stat-card.warning strong { color: var(--warning); }
.stat-card.danger strong { color: var(--danger); }

.recent-label {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.toolbar {
  display: flex;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.toolbar input,
.toolbar select {
  max-width: 280px;
}

.table-wrap {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #edf2f7;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: #475569;
  background: #f8fafc;
  font-size: 12px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

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

.link-btn {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 0;
  font-weight: 800;
}

.danger-link {
  color: var(--danger);
}

.split-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.sub-panel {
  padding: 18px;
}

.compact-form {
  max-width: 560px;
}

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

.checkbox-row input {
  width: auto;
}

.modal {
  width: min(780px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}

.modal::backdrop {
  background: rgba(15, 23, 42, .45);
}

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

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.icon-btn {
  border: 0;
  background: #edf2f7;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 22px;
}

#orderDetailBody {
  padding: 18px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 10px 14px;
  margin-bottom: 16px;
}

.detail-grid span:nth-child(odd) {
  color: var(--muted);
}

.secret-box {
  white-space: pre-wrap;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.edit-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 14px;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

.page-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 5px;
  padding: 4px 10px;
  min-height: 30px;
  font-weight: 600;
  font-size: 13px;
}

.page-btn:hover:not([disabled]) {
  background: #f0f6ff;
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn.page-active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.page-btn[disabled] {
  opacity: 0.4;
  cursor: default;
}

.page-ellipsis {
  color: var(--muted);
  padding: 0 3px;
  font-size: 13px;
}

.page-info {
  color: var(--muted);
  font-size: 12px;
  margin-left: auto;
}

@media (max-width: 860px) {
  .two-col,
  .split-grid,
  .admin-shell,
  .form-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

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

  .section-block + .section-block {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .sidebar {
    position: static;
  }

  .toolbar {
    flex-direction: column;
  }

  .toolbar input,
  .toolbar select {
    max-width: none;
  }

  .front-header {
    flex-direction: column;
  }

  .edit-row {
    grid-template-columns: 1fr;
  }
}
