* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #f7b731;
  --primary-dark: #e0a21f;
  --bg: #16162a;
  --card: #ffffff;
  --text: #2d2d44;
  --muted: #8a8aa3;
  --border: #e6e6f0;
  --danger: #e74c3c;
  --sidebar-bg: #1d1d35;
  --sidebar-active: rgba(247, 183, 49, 0.14);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ============ 登录页 ============ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 600px at 20% -10%, rgba(247, 183, 49, 0.16), transparent 60%),
    radial-gradient(1000px 500px at 90% 110%, rgba(90, 80, 240, 0.18), transparent 55%),
    var(--bg);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 20px;
  padding: 44px 36px 30px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  animation: rise .5s ease-out;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-logo { text-align: center; margin-bottom: 14px; }
.coin-icon {
  width: 72px; height: 72px;
  margin: 0 auto;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffd76a, #f0a83a);
  box-shadow: inset 0 -4px 8px rgba(0,0,0,.18), 0 10px 20px rgba(240,168,58,.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 38px;
}
.login-title { text-align: center; font-size: 22px; letter-spacing: 2px; color: var(--text); }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 8px 0 26px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 14px;
  font-size: 14px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  background: #fafafe;
}
.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(247, 183, 49, 0.2);
  background: #fff;
}

.form-err {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin-bottom: 8px;
}

.btn {
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  padding: 11px 20px;
  transition: all .2s;
  font-family: inherit;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #3d2c00;
  font-weight: 700;
  letter-spacing: 4px;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-block { width: 100%; height: 46px; margin-top: 4px; }
.btn-light {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-light:hover { border-color: var(--primary); color: var(--primary-dark); }
.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,.25);
  color: #cfcfdf;
  font-size: 13px;
  padding: 7px 14px;
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

.login-hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }

/* ============ 主界面布局 ============ */
/* 宽屏：整个工作区占满视口，左右各自固定，右侧内容超高时由 main 内部滚动，
   左侧菜单栏不再被右侧内容撑长 */
.admin-wrap { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: 240px;
  height: 100%;
  background: var(--sidebar-bg);
  color: #cfcfdf;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.side-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 22px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.coin-icon-sm { font-size: 22px; }

.menu { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 12px; }
.menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  color: #b9b9cf;
  margin-bottom: 4px;
  transition: all .2s;
  user-select: none;
}
.menu-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.menu-item.active {
  background: var(--sidebar-active);
  color: var(--primary);
  font-weight: 600;
}
.menu-icon { font-size: 17px; }

.side-user {
  padding: 16px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.side-user-name { font-size: 13px; color: #b9b9cf; }

.main {
  flex: 1;
  min-width: 0;
  background: #f4f4fa;
  padding: 28px 32px;
  overflow-x: auto;
  overflow-y: auto;
}
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px;
}
.page-head h2 { font-size: 20px; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--card);
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(22,22,42,.05);
  border-left: 4px solid var(--primary);
}
.stat-num { font-size: 30px; font-weight: 800; color: var(--text); }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 4px; }

.panel {
  background: var(--card);
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 2px 10px rgba(22,22,42,.05);
}
.panel-narrow { max-width: 460px; }
.panel-title { font-size: 15px; margin: 18px 0 12px; }
.panel hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.account-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; font-size: 14px;
}
.account-row strong { color: var(--text); }

.state-tip {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
  font-size: 14px;
}
.state-tip.error { color: var(--danger); }
.state-tip.ok { color: #1a9e5f; }
.state-tip.warn { color: #d68910; }
.help-hint { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.6; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table th { color: var(--muted); font-weight: 600; background: #fafafe; }
.table tr:hover td { background: #fffbe9; }
.table .avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: #eee;
  display: inline-block;
  vertical-align: middle;
}
.table .avatar-fallback {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #3d2c00;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  vertical-align: middle;
}
.badge-win { color: #1a9e5f; font-weight: 600; }
.badge-lose { color: #c0392b; font-weight: 600; }
.badge-warn { color: #d68910; font-weight: 600; }
.mono { font-family: Consolas, Monaco, monospace; font-size: 12px; color: var(--muted); }

.help-list { padding-left: 20px; line-height: 2; font-size: 14px; }
.help-list code {
  background: #f1f1f8;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
  color: #d35400;
}

/* ============ 分页 ============ */
.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}
.pager .btn { padding: 7px 16px; font-size: 13px; }
.pager .btn:disabled { opacity: .4; cursor: not-allowed; }
.pager-info { color: var(--muted); font-size: 13px; }

@media (max-width: 900px) {
  .admin-wrap { flex-direction: column; height: auto; overflow: visible; }
  .sidebar { width: 100%; height: auto; }
  .menu { overflow-y: visible; }
  .stats { grid-template-columns: 1fr; }
  .main { overflow: visible; padding: 20px 16px; }
}

/* ============ 商品管理 ============ */
.head-actions { display: flex; gap: 10px; }
.prod-cell { display: flex; align-items: center; gap: 10px; }
.prod-thumb {
  width: 44px; height: 44px;
  border-radius: 8px; object-fit: cover;
  background: #f1f1f8; flex-shrink: 0;
}
.prod-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.price-coin { color: #d68910; font-weight: 700; }
.row-actions { display: flex; gap: 6px; }
.row-actions .btn { padding: 6px 12px; font-size: 12px; letter-spacing: 0; }
.btn-danger { background: #fff1f0; color: #c0392b; border: 1px solid #f5c6c0; }
.btn-danger:hover { border-color: var(--danger); background: #ffe9e6; }
.sold-out-tag { color: #c0392b; font-size: 12px; font-weight: 600; }

/* 售罄开关（纯 CSS switch） */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .switch-track {
  position: absolute; inset: 0; border-radius: 24px;
  background: #d8d8e4; transition: background .2s; cursor: pointer;
}
.switch .switch-track::after {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .2s;
}
.switch input:checked + .switch-track { background: #e74c3c; }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch-row { display: flex; align-items: center; justify-content: space-between; }
.switch-label { font-size: 13px; color: var(--muted); }

/* 商品图片选择与预览 */
.img-pick { display: flex; gap: 14px; align-items: flex-start; }
.img-pick-main {
  width: 96px; height: 96px; border-radius: 10px;
  border: 1px dashed #c9c9de; background: #fafafe;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.img-pick-main img { width: 100%; height: 100%; object-fit: cover; }
.img-empty { color: #b6b6cc; font-size: 12px; }
.img-pick-actions { display: flex; flex-direction: column; gap: 8px; }
.img-pick-actions .btn { width: 110px; padding: 7px 10px; letter-spacing: 0; }
.img-list { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; min-height: 0; }
.img-list-item { position: relative; width: 84px; height: 84px; }
.img-list-item img {
  width: 100%; height: 100%; border-radius: 8px; object-fit: cover;
  border: 1px solid var(--border); background: #fafafe;
}
.img-list-item .img-del {
  position: absolute; top: -7px; right: -7px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,.68); color: #fff; border: none;
  font-size: 12px; line-height: 20px; text-align: center;
  cursor: pointer;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* 弹层 */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10, 10, 24, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-box {
  width: 100%; max-width: 460px;
  background: #fff; border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,.4);
  display: flex; flex-direction: column;
  max-height: 92vh;
}
.modal-wide { max-width: 560px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 0;
}
.modal-head h3 { font-size: 17px; color: var(--text); }
.modal-close {
  border: none; background: transparent; color: var(--muted);
  font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.modal-close:hover { background: #f1f1f8; color: var(--text); }
.modal-body { padding: 16px 22px 6px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px 20px;
}

/* ============ 兑换记录 ============ */
.search-input {
  padding: 8px 12px; border: 1px solid #e4e4f0; border-radius: 8px;
  font-size: 13px; outline: none; min-width: 220px; background: #fff; color: var(--text);
}
.search-input:focus { border-color: #b89b58; }
.muted { color: var(--muted); }
.ship-info { font-size: 12px; line-height: 1.9; color: var(--text); min-width: 190px; }
.copyable {
  cursor: pointer; padding: 1px 6px; margin-left: -6px; border-radius: 6px;
  transition: background .15s;
}
.copyable:hover { background: #f3ead2; color: #8a6d1f; }
.prod-thumb-empty {
  display: inline-flex; align-items: center; justify-content: center;
  color: #b6b6cc; font-size: 18px;
}
.tracking-wrap { display: flex; gap: 6px; align-items: center; }
.tracking-input {
  width: 150px; padding: 7px 10px; border: 1px solid #e4e4f0; border-radius: 8px;
  font-size: 12px; outline: none; background: #fff; color: var(--text);
  font-family: Consolas, Monaco, monospace;
}
.tracking-input:focus { border-color: #b89b58; }
.tracking-state { font-size: 12px; color: var(--muted); margin-top: 4px; }
.tip-toast {
  position: fixed; top: 18px; left: 50%; transform: translate(-50%, -80px);
  background: rgba(30, 30, 45, .92); color: #fff; font-size: 13px;
  padding: 9px 18px; border-radius: 999px; z-index: 9999; pointer-events: none;
  opacity: 0; transition: transform .25s, opacity .25s; max-width: 80vw;
}
.tip-toast.show { transform: translate(-50%, 0); opacity: 1; }

/* 表格较宽时容器内横向滚动（兑换记录等） */
.panel-tbl-scroll { overflow-x: auto; }
.openid-cell {
  font-family: Consolas, Monaco, monospace; font-size: 12px;
  max-width: 220px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; color: #5a5a70;
}
.openid-cell:hover { background: #f3ead2; color: #8a6d1f; text-overflow: clip; }
