/* ===== 全局 ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --dim: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --mono: "Consolas", "Menlo", "Courier New", monospace;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-size: 13px; }
.dim { color: var(--dim); }
.small { font-size: 12px; }
.mt { margin-top: 12px; }

/* ===== 卡片 ===== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}
.box-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.box-hint { color: var(--dim); font-size: 13px; margin-bottom: 10px; }

/* ===== 按钮 ===== */
.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: 8px 16px; font-size: 14px; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: #f9fafb; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--dim); }
.btn-tiny { padding: 2px 8px; font-size: 12px; border-radius: 6px; }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; border-color: #fca5a5; }

/* ===== 标签 ===== */
.tag {
  display: inline-block; padding: 1px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
}
.tag-ok { background: #dcfce7; color: var(--ok); }
.tag-warn { background: #fef3c7; color: var(--warn); }
.tag-danger { background: #fee2e2; color: var(--danger); }
.tag-dim { background: #f3f4f6; color: var(--dim); }

/* ===== 输入 ===== */
input[type="text"], input[type="password"], input[type="url"], textarea, select {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 12px; font-size: 14px; background: #fff; color: var(--text);
  outline: none; transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); }
textarea { font-family: inherit; resize: vertical; }
.field-label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
.req { color: var(--danger); }

/* ===== 兑换页布局 ===== */
.buyer-app { max-width: 680px; margin: 0 auto; padding: 20px 16px 60px; }
.app-header { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.app-title { font-size: 22px; font-weight: 800; }
.header-sub { color: var(--dim); font-size: 13px; margin-top: 2px; }

.mode-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 12px; }
.mode-btn { padding: 6px 18px; font-size: 13px; border: none; background: #fff; cursor: pointer; color: var(--dim); }
.mode-btn.active { background: var(--primary); color: #fff; }

.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }
.batch-textarea { width: 100%; }
.batch-actions { display: flex; gap: 8px; margin-top: 10px; }
.msg-error { color: var(--danger); font-size: 13px; margin-top: 8px; }

/* 历史记录 */
.history-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.history-title { font-weight: 700; }
.history-hint { color: var(--dim); font-size: 12px; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; cursor: pointer; transition: border-color .15s;
}
.history-item:hover { border-color: var(--primary); }
.hi-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hi-kind-badge { font-size: 12px; }
.hi-code { font-size: 13px; word-break: break-all; }
.hi-content { font-size: 12px; color: var(--dim); word-break: break-all; margin-top: 4px; }

/* 批量结果 */
.batch-result-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.batch-summary { font-size: 13px; color: var(--dim); }
.batch-result-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; background: #fff; }
.batch-result-item.item-err { border-color: #fecaca; background: #fff5f5; }
.bri-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bri-status { font-size: 13px; font-weight: 600; }
.item-ok .bri-status { color: var(--ok); }
.item-err .bri-status { color: var(--danger); }
.bri-label { font-size: 12px; color: var(--dim); margin-top: 8px; font-weight: 600; }
.bri-content { font-size: 13px; word-break: break-all; }
.bri-error { color: var(--danger); font-size: 13px; margin-top: 6px; }
.bri-expired { color: var(--warn); font-size: 13px; margin-top: 6px; }
.bri-topup-form { margin-top: 8px; }
.bri-topup-row { display: flex; gap: 8px; margin-top: 6px; }
.bri-topup-notice { color: var(--warn); font-size: 13px; margin-top: 8px; }
.bri-topup-done { color: var(--dim); font-size: 13px; margin-top: 8px; }

/* 详情面板 */
.detail-box { border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.detail-header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.detail-kind { font-weight: 700; }
.close-btn { margin-left: auto; border: none; background: none; color: var(--dim); cursor: pointer; font-size: 16px; }
.detail-status { padding: 14px 18px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.notice-card { margin: 12px 18px 0; background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 12px 14px; }
.notice-title { font-weight: 700; color: var(--warn); margin-bottom: 6px; }
.notice-list { padding-left: 18px; color: #78350f; font-size: 13px; }
.notice-list li { margin: 3px 0; }
.notice-repeat { margin-top: 8px; color: var(--danger); font-weight: 600; font-size: 13px; }
.expired-banner { margin: 12px 18px 0; background: #fff5f5; border: 1px solid #fecaca; border-radius: 10px; padding: 12px 14px; }
.expired-banner-title { font-weight: 700; color: var(--danger); margin-bottom: 4px; }
.expired-banner-hint { font-size: 13px; color: #7f1d1d; }
.cred-block { padding: 14px 18px 0; }
.cred-label { font-size: 12px; color: var(--dim); font-weight: 600; margin-bottom: 4px; }
.copy-row { display: flex; align-items: center; gap: 10px; }
.value { font-size: 14px; word-break: break-all; flex: 1; }
.value.secret { font-family: var(--mono); font-size: 13px; }
.key-pending-hint { color: var(--warn); font-size: 13px; }
.status-query-link { display: inline-block; margin: 14px 18px 0; font-size: 13px; }

/* 提示卡 / 联系卡 */
.tips-card { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 12px; padding: 16px 18px; }
.tips-title { font-weight: 700; color: #1e40af; margin-bottom: 8px; }
.tip-row { display: flex; gap: 8px; font-size: 13px; color: #1e3a8a; margin: 4px 0; }
.tip-idx { flex-shrink: 0; font-weight: 700; }
.tip-code { font-family: var(--mono); font-size: 12px; background: #fff; border: 1px solid #bfdbfe; border-radius: 6px; padding: 2px 6px; word-break: break-all; }
.contact-card { display: flex; gap: 12px; align-items: flex-start; }
.contact-icon { font-size: 20px; }
.contact-body p { margin: 2px 0; }
.contact-bonus {
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
  animation: bonusPulse 2.4s ease-in-out infinite;
}
@keyframes bonusPulse {
  0%, 100% { box-shadow: 0 2px 8px rgba(245, 158, 11, .35); }
  50% { box-shadow: 0 2px 18px rgba(245, 158, 11, .65); }
}

/* 表单区块 */
.form-section { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 12px; }
.status-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.status-block { margin: 12px 18px 0; border-radius: 10px; padding: 12px 14px; font-size: 13px; }
.status-block.warn { background: #fffbeb; border: 1px solid #fde68a; color: #78350f; }
.status-block.ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #14532d; }
.status-block.danger { background: #fef2f2; border: 1px solid #fecaca; color: #7f1d1d; }
.link-hint { font-size: 12px; color: var(--dim); margin-top: 4px; }
.link-hint.bad { color: var(--danger); }
.reject-reason { font-weight: 700; }

/* ===== 店铺页 ===== */
.shop-app { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }
.shop-hero { text-align: center; padding: 30px 0 10px; }
.shop-hero h1 { font-size: 28px; font-weight: 800; }
.shop-intro { color: var(--dim); margin-top: 8px; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-top: 20px; }
.product-card { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 10px; transition: box-shadow .15s; }
.product-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.06); }
.product-top { display: flex; align-items: center; gap: 10px; }
.product-name { font-size: 16px; font-weight: 700; flex: 1; }
.product-price { font-size: 20px; font-weight: 800; color: var(--danger); }
.product-desc { color: var(--dim); font-size: 13px; flex: 1; }
.product-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--dim); }
.product-actions { display: flex; gap: 8px; }
.kind-badge { font-size: 12px; padding: 1px 10px; border-radius: 999px; }
.kind-account { background: #eff6ff; color: #1d4ed8; }
.kind-topup { background: #f0fdf4; color: #15803d; }
.kind-invite { background: #faf5ff; color: #7e22ce; }

/* ===== 后台 ===== */
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
  width: 200px; background: #111827; color: #e5e7eb; flex-shrink: 0;
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.admin-logo { font-size: 17px; font-weight: 800; padding: 4px 10px 16px; color: #fff; }
.admin-nav { display: flex; flex-direction: column; gap: 2px; }
.admin-nav button {
  text-align: left; background: none; border: none; color: #9ca3af; padding: 9px 12px;
  border-radius: 8px; cursor: pointer; font-size: 14px; transition: all .12s;
}
.admin-nav button:hover { color: #fff; background: #1f2937; }
.admin-nav button.active { color: #fff; background: #2563eb; }
.admin-main { flex: 1; padding: 24px; overflow-x: auto; }
.admin-title { font-size: 20px; font-weight: 800; margin-bottom: 16px; }
.admin-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.stat-label { color: var(--dim); font-size: 13px; }
.stat-value { font-size: 26px; font-weight: 800; margin-top: 4px; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data th { color: var(--dim); font-weight: 600; white-space: nowrap; background: #f9fafb; }
table.data tr:hover td { background: #f9fafb; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar select, .toolbar input { width: auto; }
.pagination { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--dim); font-size: 13px; }

.modal-mask {
  position: fixed; inset: 0; background: rgba(17,24,39,.5); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
  max-height: 86vh; overflow-y: auto; padding: 22px;
}
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.form-row { display: flex; gap: 12px; }
.form-row > div { flex: 1; }

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 32px; }
.login-title { font-size: 22px; font-weight: 800; text-align: center; margin-bottom: 20px; }

.toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #111827; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; max-width: 340px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.toast.ok { background: #15803d; }
.toast.err { background: #b91c1c; }

.empty { text-align: center; color: var(--dim); padding: 26px 0; font-size: 13px; }
/* 开关（switch） */
.contact-qr { width: 100px; height: 100px; border-radius: 10px; border: 1px solid var(--border); flex-shrink: 0; object-fit: cover; background: #fff; }
.contact-flex { display: flex; gap: 14px; align-items: flex-start; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: none; }
.setting-title { font-weight: 600; font-size: 14px; }
.setting-desc { color: var(--dim); font-size: 12px; margin-top: 2px; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0; background: #d1d5db; border-radius: 999px; transition: background .2s;
}
.switch .slider::before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch .slider.loading { opacity: .6; }

/* 用量预览（领取弹窗 before→after） */
.usage-preview-item { margin: 12px 0; }
.usage-preview-header { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.usage-preview-value { font-family: var(--mono); }
.usage-preview-after-value { color: var(--ok); font-weight: 700; }
.usage-preview-progress { position: relative; height: 8px; background: #eef0f3; border-radius: 999px; overflow: hidden; }
.usage-preview-before { position: absolute; left: 0; top: 0; height: 100%; background: #cbd5e1; border-radius: 999px; }
.usage-preview-after { position: absolute; left: 0; top: 0; height: 100%; background: var(--ok); border-radius: 999px; }

.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(0,0,0,.15); border-top-color: currentColor; border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
