:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e5e9f2;
  --text: #1c2333;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --green: #16a34a;
  --green-soft: #ecfdf5;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 8px 24px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }

/* ---------- 布局 ---------- */
.header {
  background: linear-gradient(120deg, #4f46e5 0%, #7c3aed 100%);
  color: #fff;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.header .brand { font-size: 19px; font-weight: 700; letter-spacing: .5px; }
.header .brand small { font-weight: 400; opacity: .85; margin-left: 10px; font-size: 12px; }
.header a { color: rgba(255, 255, 255, .92); font-size: 13px; border: 1px solid rgba(255, 255, 255, .35); padding: 5px 14px; border-radius: 20px; }
.header a:hover { background: rgba(255, 255, 255, .12); }

.container { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }

.banner {
  background: var(--amber-soft);
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

.steps {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.step {
  flex: 1;
  min-width: 150px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow);
}
.step .no {
  width: 24px; height: 24px; border-radius: 50%;
  background: #e5e9f2; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px; flex: none;
}
.step.active { color: var(--primary); border-color: #c7d2fe; }
.step.active .no { background: var(--primary); color: #fff; }
.step.done { color: var(--green); }
.step.done .no { background: var(--green); color: #fff; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card h3 { font-size: 16px; margin-bottom: 14px; }
.card .sub { color: var(--muted); font-size: 12px; margin-bottom: 12px; }

/* ---------- 选择卡片 ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.pick {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  background: #fff;
  transition: all .15s;
}
.pick:hover { border-color: #c7d2fe; }
.pick.selected { border-color: var(--primary); background: var(--primary-soft); }
.pick.disabled { opacity: .55; cursor: not-allowed; }
.pick .name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.pick .desc { color: var(--muted); font-size: 12px; min-height: 18px; }
.pick .meta { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.pick .price { color: var(--red); font-weight: 700; font-size: 16px; }
.pick .price small { font-size: 12px; font-weight: 400; color: var(--muted); }
.pick .stock { font-size: 12px; color: var(--muted); }
.pick .stock.low { color: var(--amber); }
.pick .stock.out { color: var(--red); }

/* ---------- 表单 ---------- */
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 90px; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-form label.field { flex: 1; min-width: 160px; margin-bottom: 0; }

.radio-line { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-chip {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 16px;
  cursor: pointer;
  font-size: 13px;
  background: #fff;
}
.radio-chip.selected { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); font-weight: 600; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 9px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}
.btn:hover { border-color: #c7d2fe; color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--primary-hover); color: #fff; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; background: #fafbfe; }
td.wrap { white-space: normal; word-break: break-all; }
tr:hover td { background: #fafbff; }

/* ---------- 徽标 ---------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; }
.badge.pending { background: var(--amber-soft); color: var(--amber); }
.badge.paid { background: var(--blue-soft); color: var(--blue); }
.badge.completed { background: var(--green-soft); color: var(--green); }
.badge.expired { background: #f3f4f6; color: var(--muted); }
.badge.canceled { background: var(--red-soft); color: var(--red); }
.badge.gray { background: #f3f4f6; color: var(--muted); }
.badge.available { background: var(--green-soft); color: var(--green); }
.badge.occupied { background: var(--blue-soft); color: var(--blue); }
.badge.used { background: #f3f4f6; color: var(--muted); }
.badge.disabled { background: var(--red-soft); color: var(--red); }

/* ---------- 支付/收码面板 ---------- */
.pay-panel { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.qr-box { width: 240px; flex: none; text-align: center; }
.qr-box img { width: 240px; height: 240px; border: 1px solid var(--border); border-radius: 10px; }
.qr-box .tip { font-size: 12px; color: var(--muted); margin-top: 8px; }
.pay-info { flex: 1; min-width: 240px; }
.pay-info .row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.pay-info .row b { font-weight: 600; }

.phone-display {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
  color: var(--primary);
  padding: 18px 0 6px;
  user-select: all;
}
.phone-hint { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 14px; }

.code-display {
  text-align: center;
  background: var(--green-soft);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
}
.code-display .label { color: var(--green); font-size: 13px; }
.code-display .code { font-size: 40px; font-weight: 800; letter-spacing: 8px; color: var(--green); user-select: all; }

.waiting {
  text-align: center;
  padding: 18px 0;
  color: var(--muted);
}
.spinner {
  width: 26px; height: 26px;
  border: 3px solid #e5e9f2;
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 10px;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.sms-list { margin-top: 12px; }
.sms-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 13px;
}
.sms-item .meta { color: var(--muted); font-size: 12px; margin-bottom: 3px; display: flex; justify-content: space-between; }
.sms-item .content { word-break: break-all; }
.sms-item .content b { color: var(--red); }

.countdown { text-align: center; color: var(--amber); font-weight: 600; margin-bottom: 6px; }
.center-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }

/* ---------- 历史订单 ---------- */
.empty { text-align: center; color: var(--muted); padding: 24px 0; }

details.guide { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
details.guide summary { cursor: pointer; padding: 14px 20px; font-weight: 600; }
details.guide .body { padding: 0 20px 16px; color: var(--muted); font-size: 13px; white-space: pre-wrap; }
details.guide ol { padding-left: 20px; }
details.guide li { margin-bottom: 4px; }

/* ---------- 管理后台 ---------- */
.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px;
  flex: none;
  background: #1c2333;
  color: #cbd5e1;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar .logo { color: #fff; font-weight: 700; padding: 4px 10px 16px; font-size: 16px; }
.sidebar a {
  color: #cbd5e1;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.sidebar a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar a.active { background: var(--primary); color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .logout { color: #f87171; }

.admin-main { flex: 1; padding: 22px 26px; min-width: 0; }
.admin-main h2 { font-size: 18px; margin-bottom: 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat-card .v { font-size: 24px; font-weight: 700; }
.stat-card .k { color: var(--muted); font-size: 12px; }
.stat-card .v.small { font-size: 16px; }

.alert-line { border-radius: 10px; padding: 10px 14px; margin-bottom: 10px; font-size: 13px; }
.alert-line.warn { background: var(--amber-soft); border: 1px solid #fde68a; color: #92400e; }
.alert-line.info { background: var(--blue-soft); border: 1px solid #bfdbfe; color: #1e40af; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.toolbar select, .toolbar input { width: auto; min-width: 130px; }
.toolbar .grow { flex: 1; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 14px;
  width: 560px;
  max-width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px;
}
.modal h3 { margin-bottom: 14px; font-size: 16px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

.toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  background: #1c2333; color: #fff;
  border-radius: 8px; padding: 9px 20px;
  font-size: 13px; z-index: 99;
  animation: fadein .2s;
  max-width: 80vw;
}
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }
@keyframes fadein { from { opacity: 0; transform: translate(-50%, -6px); } }

.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { width: 340px; }
.login-card h2 { text-align: center; margin-bottom: 18px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } .sidebar { width: 64px; } .sidebar a span { display: none; } .sidebar .logo span { display: none; } }

.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.mono { font-family: Consolas, "Courier New", monospace; }

/* 收码页操作区：按钮一行居中可换行，说明文字独立成行 */
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; }
.btn-row .btn { margin: 0; }
#recv-actions .hint { margin-top: 8px; }

/* ---------- 项目操作提示弹窗 ---------- */
.guide-modal { width: min(640px, 92vw); }
.guide-scroll {
  max-height: 42vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.9;
  background: #fafbff;
}
.guide-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; flex-wrap: wrap; gap: 10px; }
.gm-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.gm-check input { width: auto; }

/* 教程富文本内容（HTML / 图片 / 视频 / iframe 嵌入） */
.rt-rich { white-space: normal; }
.guide-scroll img, .guide-scroll video, .guide-scroll iframe,
#guide-custom img, #guide-custom video, #guide-custom iframe {
  max-width: 100%;
  display: block;
  margin: 8px 0;
  border-radius: 8px;
}
.guide-scroll video, #guide-custom video { width: 100%; background: #000; }
.guide-scroll iframe, #guide-custom iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  background: #000;
}

/* ========== 工单系统（v1.1.32） ========== */
.header-nav { display: flex; gap: 18px; align-items: center; }
.header-nav a { font-size: 14px; }
.badge.open { background: var(--red-soft); color: var(--red); }

/* ========== 卡密系统（v1.1.33） ========== */
.badge.unused { background: var(--green-soft); color: var(--green); }
.card-stat-row { display: flex; gap: 12px; flex-wrap: wrap; }
.card-stat {
  flex: 1; min-width: 120px; background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px; text-align: center; box-shadow: var(--shadow);
}
.card-stat .num { font-size: 26px; font-weight: 700; line-height: 1.2; }
.card-stat .lbl { color: var(--muted); font-size: 12px; margin-top: 4px; }
.card-modal { width: min(460px, 94vw); }
#cd-input { font-family: monospace; letter-spacing: 1px; }

/* 工单中心弹窗 */
.ticket-modal {
  width: min(660px, 94vw);
  padding: 0;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.ticket-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.ticket-head h3 { margin: 0; }
.tk-x { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.tk-x:hover { color: var(--red); }
.ticket-body { padding: 14px 18px; overflow-y: auto; }
.tk-loading { text-align: center; color: var(--muted); padding: 30px 0; }

.tk-list-head { margin-bottom: 10px; }
.tk-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
.tk-item:hover { border-color: #c7d2fe; background: var(--primary-soft); }
.tk-item-top { display: flex; align-items: center; gap: 8px; }
.tk-item-top b { flex: 1; font-size: 14px; }
.tk-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex: none; }
.tk-item-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.tk-item-last { font-size: 13px; color: #475569; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tk-form .field { margin-bottom: 10px; display: block; }
.tk-form .field span { display: block; font-size: 13px; margin-bottom: 4px; color: #334155; }
.tk-form textarea { min-height: 96px; resize: vertical; }
.tk-form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.tk-chat-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.tk-chat {
  height: 300px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; background: #f8fafc;
  display: flex; flex-direction: column; gap: 10px;
}
.tk-bubble { max-width: 80%; }
.tk-bubble.left { align-self: flex-start; }
.tk-bubble.right { align-self: flex-end; text-align: right; }
.tk-bubble-meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.tk-bubble-body {
  display: inline-block; padding: 8px 12px; border-radius: 10px;
  font-size: 13px; white-space: pre-wrap; word-break: break-word; text-align: left;
}
.tk-bubble.left .tk-bubble-body { background: #fff; border: 1px solid var(--line); }
.tk-bubble.right .tk-bubble-body { background: var(--primary); color: #fff; }
.tk-close-line { text-align: center; margin: 10px 0; }
.tk-closed-tip { text-align: center; font-size: 12px; color: var(--muted); margin: 10px 0; }
.tk-reply { display: flex; gap: 8px; align-items: flex-end; }
.tk-reply textarea { flex: 1; resize: vertical; min-height: 44px; margin: 0; }

/* 管理端：侧边栏待处理角标 + 工单详情订单摘要 */
.nav-badge {
  background: var(--red); color: #fff;
  font-size: 11px; border-radius: 10px;
  padding: 0 6px; margin-left: 6px;
}
.tk-order-brief {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 13px; margin-bottom: 12px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px;
}
.tk-status-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
@media (max-width: 640px) { .tk-order-brief { grid-template-columns: 1fr; } }
