/* =========================================================
   月老盲盒 v2 · 全新 UI
   移动端优先，零外部依赖，纯 CSS 变量驱动主题
   ========================================================= */

:root {
  --brand: #ff4d6d;
  --brand-2: #ff8a3d;
  --brand-soft: #fff1f4;
  --ink: #16182b;
  --sub: #6b7189;
  --muted: #9aa0b4;
  --line: #edeff5;
  --bg: #f5f6fa;
  --card: #ffffff;
  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --r: 16px;
  --r-sm: 10px;
  --shadow: 0 2px 10px rgba(22, 24, 43, .06);
  --shadow-lg: 0 12px 36px rgba(22, 24, 43, .14);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: calc(64px + var(--safe-b));
  position: relative;
}

/* ---------------- 顶部栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  height: 52px; padding: 0 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: var(--shadow);
}
.topbar .back, .topbar .act {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 50%; color: #fff; flex: 0 0 auto;
}
.topbar .back:active, .topbar .act:active { background: rgba(255,255,255,.18); }
.topbar h1 { flex: 1; margin: 0; font-size: 17px; font-weight: 600; text-align: center; }
.topbar .spacer { width: 34px; }

.plain-top { background: var(--card); color: var(--ink); box-shadow: none; border-bottom: 1px solid var(--line); }
.plain-top .back, .plain-top .act { color: var(--ink); }

/* ---------------- Hero ---------------- */
.hero {
  position: relative;
  padding: 22px 16px 30px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  border-radius: 0 0 24px 24px;
}
.hero h2 { margin: 0 0 6px; font-size: 21px; font-weight: 700; letter-spacing: .5px; }
.hero p { margin: 0; opacity: .92; font-size: 13px; }
.hero .stats {
  display: flex; gap: 10px; margin-top: 16px;
}
.hero .stats div {
  flex: 1; background: rgba(255,255,255,.16);
  border-radius: var(--r-sm); padding: 10px 8px; text-align: center;
  backdrop-filter: blur(4px);
}
.hero .stats b { display: block; font-size: 20px; line-height: 1.2; }
.hero .stats span { font-size: 12px; opacity: .9; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 14px;
  margin: 12px;
}
.card.tight { padding: 10px 12px; }
.card-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 0 10px; font-size: 15px; font-weight: 600;
}
.card-title .more { font-size: 12px; color: var(--muted); font-weight: 400; }

/* ---------------- 轮播 ---------------- */
.slider { position: relative; overflow: hidden; border-radius: var(--r); margin: 12px; background: #f0f0f5; }
.slider-track { display: flex; transition: transform .4s ease; }
.slider-track img { width: 100%; flex: 0 0 100%; aspect-ratio: 2.35 / 1; object-fit: cover; }
.slider-dots {
  position: absolute; bottom: 8px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 6px;
}
.slider-dots i {
  width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.55);
  transition: width .25s;
}
.slider-dots i.on { width: 16px; background: #fff; border-radius: 3px; }

/* ---------------- 抽取入口 ---------------- */
.pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px; }
.pick {
  position: relative; overflow: hidden;
  border-radius: var(--r); padding: 18px 14px;
  color: #fff; box-shadow: var(--shadow);
  min-height: 108px;
  display: flex; flex-direction: column; justify-content: flex-end;
  border: none; text-align: left;
}
.pick.male { background: linear-gradient(140deg, #4f8cff, #2f6bff); }
.pick.female { background: linear-gradient(140deg, #ff5f9e, var(--brand)); }
.pick b { font-size: 17px; display: block; }
.pick span { font-size: 12px; opacity: .9; }
.pick em {
  position: absolute; right: -6px; top: -6px;
  font-size: 62px; opacity: .18; font-style: normal;
}
.pick:active { transform: scale(.985); }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; padding: 0 18px; border-radius: 22px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font-size: 15px; transition: transform .12s, opacity .12s;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; border: none; box-shadow: 0 6px 16px rgba(255, 77, 109, .28);
}
.btn-block { display: flex; width: 100%; }
.btn-lg { height: 50px; font-size: 16px; border-radius: 25px; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; border-radius: 17px; }
.btn-ghost { background: transparent; border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--danger); color: #fff; border: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 14px; }
.field > label {
  display: block; margin-bottom: 6px; font-size: 13px; color: var(--sub);
}
.field > label .req { color: var(--danger); margin-right: 2px; }
.input, select.input, textarea.input {
  width: 100%; height: 44px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: #fff; outline: none; transition: border-color .15s;
}
textarea.input { height: auto; padding: 10px 12px; min-height: 88px; resize: vertical; }
.input:focus { border-color: var(--brand); }
.input::placeholder { color: var(--muted); }
.seg { display: flex; gap: 10px; }
.seg label {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 44px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: #fff; cursor: pointer;
}
.seg input { display: none; }
.seg label.on { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

/* ---------------- 列表 ---------------- */
.list { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); margin: 12px; overflow: hidden; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.list-item:last-child { border-bottom: none; }
.list-item .thumb {
  width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex: 0 0 auto; background: #f0f0f5;
}
.list-item .body { flex: 1; min-width: 0; }
.list-item .body b { display: block; font-size: 15px; font-weight: 600; }
.list-item .body p { margin: 2px 0 0; font-size: 12px; color: var(--sub); }
.list-item .body p.time { color: var(--muted); }
.tag {
  display: inline-block; padding: 1px 7px; border-radius: 6px;
  font-size: 11px; background: var(--brand-soft); color: var(--brand);
}
.tag.green { background: #e8f7ee; color: var(--ok); }
.tag.gray  { background: #f0f1f5; color: var(--sub); }
.tag.warn  { background: #fff5e6; color: var(--warn); }
.tag.danger{ background: #fdecec; color: var(--danger); }

/* ---------------- Tabs ---------------- */
.tabs { display: flex; margin: 12px; background: #fff; border-radius: var(--r-sm); padding: 4px; box-shadow: var(--shadow); }
.tabs button {
  flex: 1; height: 36px; border: none; background: transparent;
  border-radius: 8px; color: var(--sub); font-size: 14px;
}
.tabs button.on { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }

/* ---------------- 空状态 ---------------- */
.empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty .ico { font-size: 46px; margin-bottom: 10px; }
.empty p { margin: 0 0 14px; font-size: 14px; }

/* ---------------- 底部导航 ---------------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  max-width: 480px; margin: 0 auto;
  display: flex; height: calc(58px + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: #fff; border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--muted); font-size: 11px;
}
.tabbar a.on { color: var(--brand); }
.tabbar svg { width: 22px; height: 22px; }

/* ---------------- 公告 ---------------- */
.notice {
  display: flex; gap: 8px; align-items: flex-start;
  margin: 12px; padding: 10px 12px;
  background: #fff8e8; border: 1px solid #ffe6b8; border-radius: var(--r-sm);
  font-size: 12.5px; color: #8a6414;
}

/* ---------------- 弹层 ---------------- */
.mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(16, 18, 32, .5);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.sheet {
  width: 100%; max-width: 480px; background: #fff;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + var(--safe-b));
  animation: up .24s cubic-bezier(.2,.8,.3,1);
}
@keyframes up { from { transform: translateY(100%) } to { transform: translateY(0) } }
.sheet h3 { margin: 0 0 14px; font-size: 16px; text-align: center; }
.sheet .close {
  position: absolute; right: 14px; top: 12px;
  width: 28px; height: 28px; border: none; background: #f2f3f7; border-radius: 50%; color: var(--sub);
}
.pay-opt {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff;
  text-align: left;
}
.pay-opt .ico {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  color: #fff; font-size: 16px; flex: 0 0 auto;
}
.pay-opt .ico.wx   { background: #22c55e; }
.pay-opt .ico.ali  { background: #1677ff; }
.pay-opt .ico.qq   { background: #12b7f5; }
.pay-opt .ico.bal  { background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.pay-opt b { display: block; font-size: 14px; font-weight: 600; }
.pay-opt span { font-size: 12px; color: var(--sub); }
.pay-amount { text-align: center; margin-bottom: 14px; }
.pay-amount b { font-size: 30px; color: var(--brand); }
.pay-amount span { font-size: 13px; color: var(--sub); display: block; }

/* Toast */
.toast-wrap {
  position: fixed; left: 0; right: 0; top: 76px; z-index: 200;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  max-width: 76%; padding: 9px 16px; border-radius: 20px;
  background: rgba(22, 24, 43, .88); color: #fff; font-size: 13.5px;
  animation: pop .2s ease;
}
.toast.ok { background: rgba(22, 163, 74, .94); }
.toast.err { background: rgba(239, 68, 68, .94); }
@keyframes pop { from { opacity: 0; transform: translateY(-8px) } to { opacity: 1; transform: none } }

/* 盲盒开箱动画 */
.box-open { text-align: center; padding: 6px 0 2px; }
.box-open img {
  width: 190px; height: 190px; margin: 0 auto 12px;
  animation: shake 1.1s ease-in-out infinite;
}
@keyframes shake {
  0%,100% { transform: rotate(-3deg) scale(1) }
  50%     { transform: rotate(3deg) scale(1.04) }
}
.result-card { text-align: center; padding: 8px 0 4px; }
.result-card .ava {
  width: 88px; height: 88px; border-radius: 50%; object-fit: cover; margin: 0 auto 10px;
  border: 3px solid var(--brand-soft);
}
.result-card h3 { margin: 0 0 4px; font-size: 18px; }
.result-card .meta { font-size: 13px; color: var(--sub); margin-bottom: 10px; }
.result-card .wx {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--brand-soft); color: var(--brand);
  border-radius: var(--r-sm); padding: 10px; margin: 10px 0;
  font-weight: 600; word-break: break-all;
}

/* ---------------- 上传头像 ---------------- */
.avatar-upload {
  width: 110px; margin: 6px auto 4px; position: relative; text-align: center;
}
.avatar-upload img {
  width: 110px; height: 110px; border-radius: 26px; object-fit: cover; background: #f0f0f5;
}
.avatar-upload .tip { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------------- 分页 ---------------- */
.pager { margin: 14px 0 4px; }
.pager ul { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; list-style: none; padding: 0; margin: 0; }
.pager li a, .pager li span {
  display: inline-block; min-width: 32px; height: 32px; line-height: 32px;
  padding: 0 8px; text-align: center; border-radius: 8px;
  background: #fff; border: 1px solid var(--line); font-size: 13px; color: var(--sub);
}
.pager li.active span { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager li.disabled span { opacity: .45; }
.pager li.total span { border: none; background: transparent; }

/* ---------------- 个人中心头部 ---------------- */
.profile-head {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; padding: 24px 16px 46px; position: relative;
}
.profile-head .row { display: flex; align-items: center; gap: 14px; }
.profile-head img {
  width: 62px; height: 62px; border-radius: 20px; object-fit: cover; border: 2px solid rgba(255,255,255,.6);
}
.profile-head h2 { margin: 0; font-size: 19px; }
.profile-head .tags { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.profile-head .tags span {
  font-size: 11px; padding: 2px 8px; border-radius: 10px; background: rgba(255,255,255,.22);
}
.wallet {
  display: flex; margin: -30px 12px 12px; background: #fff;
  border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden;
}
.wallet div {
  flex: 1; text-align: center; padding: 14px 6px; border-right: 1px solid var(--line);
}
.wallet div:last-child { border-right: none; }
.wallet b { display: block; font-size: 18px; color: var(--brand); }
.wallet span { font-size: 12px; color: var(--sub); }

.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 12px; background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 12px 4px; }
.quick a { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--sub); }
.quick .qi {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
  color: #fff; font-size: 18px;
}

/* ---------------- 后台 ---------------- */
.admin { display: flex; min-height: 100vh; background: #f4f5f9; }
.admin .side {
  width: 210px; flex: 0 0 210px; background: #1f2233; color: #c8ccdb;
  display: flex; flex-direction: column;
}
.admin .side .brand {
  padding: 18px 16px; font-size: 16px; font-weight: 700; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.admin .side a {
  padding: 11px 16px; font-size: 14px; display: flex; gap: 9px; align-items: center;
  border-left: 3px solid transparent;
}
.admin .side a:hover { background: rgba(255,255,255,.05); color: #fff; }
.admin .side a.on { background: rgba(255,255,255,.08); color: #fff; border-left-color: var(--brand); }
.admin .main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin .top {
  height: 56px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 18px;
}
.admin .content { padding: 18px; }
.admin .card { margin: 0 0 14px; }
.admin .stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.admin .stat { background: #fff; border-radius: var(--r); padding: 14px; box-shadow: var(--shadow); }
.admin .stat span { font-size: 12px; color: var(--sub); }
.admin .stat b { display: block; font-size: 22px; margin-top: 4px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; background: #fff; }
table.tbl th, table.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.tbl th { background: #fafbfe; color: var(--sub); font-weight: 600; white-space: nowrap; }
table.tbl td.nowrap { white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; }
.bar-chart .bar { flex: 1; background: linear-gradient(180deg, var(--brand), var(--brand-2)); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-chart .labels { display: flex; gap: 6px; margin-top: 6px; font-size: 11px; color: var(--muted); }
.bar-chart .labels div { flex: 1; text-align: center; overflow: hidden; }

@media (max-width: 720px) {
  .admin { flex-direction: column; }
  .admin .side { width: 100%; flex: none; flex-direction: row; overflow-x: auto; }
  .admin .side .brand { display: none; }
  .admin .side a { padding: 12px 14px; white-space: nowrap; }
}

/* 登录页 */
.login-page { max-width: 420px; margin: 0 auto; padding: 60px 20px; }
.login-page .logo { text-align: center; margin-bottom: 26px; }
.login-page .logo h1 { font-size: 24px; margin: 0 0 6px; }
.login-page .logo p { color: var(--sub); font-size: 13px; margin: 0; }
