:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --green: #15803d;
  --green-bg: #dcfce7;
  --green-btn: #16a34a;
  --orange: #ea580c;
  --orange-bg: #ffedd5;
  --danger: #b91c1c;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  line-height: 1.2;
}
.btn:hover { background: #f9fafb; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.btn-primary:hover { filter: brightness(0.95); background: var(--blue); }
.btn-green {
  background: var(--green-btn);
  border-color: var(--green-btn);
  color: #fff;
}
.btn-green:hover { filter: brightness(0.96); background: var(--green-btn); }
.btn-ghost { background: #fff; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.muted { color: var(--muted); font-size: 13px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }
.hl-red {
  color: #dc2626 !important;
  font-weight: 700;
}

/* ===== Login gate ===== */
.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
}
.auth-hero {
  background: linear-gradient(160deg, #0b1f3a 0%, #123a6b 45%, #1d4ed8 100%);
  color: #fff;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #fbbf24, #2563eb);
  display: grid;
  place-items: center;
  font-weight: 800;
  margin-bottom: 22px;
}
.auth-hero h1 {
  margin: 0 0 12px;
  font-size: 34px;
  letter-spacing: 0.02em;
}
.auth-hero p {
  margin: 0;
  max-width: 420px;
  color: rgba(255,255,255,0.82);
  line-height: 1.7;
  font-size: 15px;
}
.auth-points {
  margin-top: 28px;
  display: grid;
  gap: 10px;
}
.auth-point {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
  color: rgba(255,255,255,0.9);
}
.auth-point b { color: #93c5fd; min-width: 72px; }

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: #f8fafc;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 28px 26px 24px;
}
.auth-card h2 {
  margin: 0 0 6px;
  font-size: 22px;
}
.auth-tabs {
  display: flex;
  gap: 8px;
  margin: 18px 0 16px;
  border-bottom: 1px solid var(--line);
}
.auth-tab {
  border: 0;
  background: transparent;
  padding: 10px 12px;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.auth-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  font-weight: 600;
}

/* ===== Console shell ===== */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 14px 28px 0;
}
.topbar-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 12px;
}
.brand-block { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f59e0b, #2563eb);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
}
.brand-title { font-size: 18px; font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.top-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
  margin-right: 6px;
}
.nav-tabs {
  display: flex;
  gap: 4px;
}
.nav-tab {
  border: 0;
  background: transparent;
  padding: 12px 16px;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  border-bottom: 2px solid transparent;
}
.nav-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  font-weight: 600;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 20px 48px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 18px 18px;
}
.card-title {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
}
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
}
.stat-label { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.1; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }

.help-box {
  margin-top: 14px;
  line-height: 1.75;
  color: #374151;
  font-size: 14px;
}
.help-box li { margin: 6px 0; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.toolbar input, .toolbar select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 13px;
  background: #fff;
  min-width: 160px;
}
.form-row {
  display: grid;
  grid-template-columns: 1.2fr 1.4fr auto;
  gap: 12px;
  align-items: end;
}
.table-wrap { overflow: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th, table.data td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}
table.data th { color: var(--muted); font-weight: 600; background: #fafafa; }
table.data td.code {
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Admin compact order table */
table.data.admin-orders {
  table-layout: fixed;
  width: 100%;
}
table.data.admin-orders th,
table.data.admin-orders td {
  white-space: normal;
  word-break: break-all;
  padding: 10px 8px;
  vertical-align: top;
}
table.data.admin-orders .cell-sub {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  word-break: break-all;
}
table.data.admin-orders .code-cell {
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.35;
  word-break: break-all;
}
table.data.admin-orders th.col-op,
table.data.admin-orders td.col-op {
  position: sticky;
  right: 0;
  background: #fff;
  box-shadow: -6px 0 8px rgba(15, 23, 42, 0.04);
  white-space: nowrap;
  width: 108px;
  z-index: 1;
}
table.data.admin-orders th.col-op { background: #fafafa; }
table.data.admin-orders .btn { padding: 7px 10px; font-size: 12px; }
.empty {
  text-align: center;
  color: var(--muted);
  padding: 28px 8px !important;
}
.tag-pending { color: #b45309; font-weight: 600; }
.tag-paid { color: var(--green); font-weight: 600; }
.tag-expired { color: #9ca3af; font-weight: 600; }

.footer-icp {
  text-align: center;
  color: #9ca3af;
  font-size: 12px;
  padding: 8px 0 24px;
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.modal-mask.show { display: flex; }
.modal {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 18px 18px 16px;
  max-height: 90vh;
  overflow: auto;
}
.pay-box .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0;
  font-size: 14px;
}
.addr {
  font-family: Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}
.qr {
  display: block;
  width: 180px;
  height: 180px;
  margin: 12px auto 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
}
.code-box {
  font-family: Consolas, monospace;
  font-size: 14px;
  background: #f8fafc;
  border: 1px dashed #93c5fd;
  border-radius: 8px;
  padding: 14px;
  word-break: break-all;
}

@media (max-width: 960px) {
  .auth-page { grid-template-columns: 1fr; }
  .auth-hero { padding: 36px 24px; min-height: auto; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .topbar { padding: 12px 14px 0; }
  .topbar-row { flex-direction: column; align-items: flex-start; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: 1fr; }
}
