:root {
  --bg: #f7f7f5;
  --card: #ffffff;
  --border: rgba(0, 0, 0, 0.09);
  --border-strong: rgba(0, 0, 0, 0.18);
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --hint: #9a9a9a;
  --accent: #2f6fed;
  --accent-soft: #eef4ff;
  --up: #d94a3d;      /* 红：正向 / 涨 */
  --down: #1d9e75;    /* 绿：负向 / 跌 */
  --amber: #b58105;
  --amber-soft: #fdf6e3;
  --radius: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 顶部导航 ---------- */
.nav {
  background: var(--card);
  border-bottom: 0.5px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.nav-inner {
  max-width: 1080px; margin: 0 auto; padding: 0 20px;
  height: 56px; display: flex; align-items: center; gap: 24px;
}
.logo { font-size: 16px; font-weight: 600; letter-spacing: 0.5px; display: flex; align-items: center; gap: 8px; }
.logo-mark {
  width: 26px; height: 26px; border-radius: 7px; background: var(--text); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-links a {
  padding: 6px 12px; border-radius: 8px; color: var(--muted); font-size: 13.5px;
}
.nav-links a:hover { background: #f2f2f0; color: var(--text); }
.nav-links a.active { color: var(--text); font-weight: 500; background: #f2f2f0; }
.nav-right { display: flex; align-items: center; gap: 10px; }

/* ---------- 布局 ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
.cols { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 0.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px 20px;
}
.card + .card { margin-top: 14px; }
.card-title { font-size: 14px; font-weight: 500; margin: 0 0 14px; }

/* ---------- 通用元素 ---------- */
.btn {
  border: 0.5px solid var(--border-strong); background: transparent; color: var(--text);
  padding: 7px 14px; border-radius: 8px; font-size: 13.5px; transition: background .12s;
  white-space: nowrap;   /* 窄屏下别把「登录 / 注册」拆成两行 */
}
.btn:hover { background: #f2f2f0; }
.btn-primary { background: var(--text); color: #fff; border-color: var(--text); }
.btn-primary:hover { opacity: .88; background: var(--text); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }
/* 破坏性操作（注销账号）。用主题里的红，别让「删除」看起来和普通按钮一样安全。 */
.btn-danger { background: var(--up); color: #fff; border-color: var(--up); }
.btn-danger:hover { opacity: .88; background: var(--up); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-block { width: 100%; text-align: center; }
/* 选中态。原来各页面靠内联 style 手动涂背景（index.html 的排序按钮），
   换成类之后新页面不用再抄一遍那三行。 */
.btn.active { background: var(--text); color: #fff; border-color: var(--text); }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 20px; font-size: 12px;
  background: #f2f2f0; color: var(--muted);
  white-space: nowrap;   /* 窄列里别把「Lv4 洞察者」截成两行 */
}
.pill-accent { background: var(--accent-soft); color: var(--accent); }
.pill-up { background: #fdeceb; color: var(--up); }
.pill-down { background: #e8f6f1; color: var(--down); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }

.muted { color: var(--muted); }
.hint { color: var(--hint); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--up); }
.down { color: var(--down); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.avatar {
  position: relative; overflow: hidden;
  width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 500; flex-shrink: 0;
}
/* 用户头像图叠在昵称首字之上。图片裂了 onerror 会把它删掉，首字自然露出来。 */
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 26px; height: 26px; font-size: 11.5px; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; }

input[type="text"], input[type="password"], input[type="email"], textarea, select {
  width: 100%; padding: 8px 11px; border: 0.5px solid var(--border-strong);
  border-radius: 8px; font: inherit; font-size: 13.5px; background: var(--card); color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }

/* ---------- 题目卡片 ---------- */
.q-title { font-size: 15.5px; font-weight: 500; line-height: 1.5; margin: 0 0 10px; }
.q-title:hover { color: var(--accent); }
.q-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.q-foot { margin-top: 14px; padding-top: 12px; border-top: 0.5px solid var(--border); }

/* ---------- 进度条 ---------- */
.bar { height: 6px; background: #ebeae7; border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--text); border-radius: 4px; }
.bar-accent > i { background: var(--accent); }

/* ---------- 分布条 ---------- */
.dist-row { margin-bottom: 10px; }
.dist-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.dist-track { height: 26px; background: #f2f2f0; border-radius: 7px; overflow: hidden; position: relative; }
.dist-fill { height: 100%; background: var(--accent-soft); border-right: 2px solid var(--accent); transition: width .3s; }
.dist-fill.mine { background: #e6f3ff; }
.dist-label {
  position: absolute; left: 10px; top: 0; height: 100%; display: flex;
  align-items: center; font-size: 12.5px; font-weight: 500;
}

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px;
     padding: 8px 10px; border-bottom: 0.5px solid var(--border); }
td { padding: 10px; border-bottom: 0.5px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr.me { background: var(--accent-soft); }
tbody tr:hover { background: #fafaf8; }

/* ---------- 空状态 / 加载 ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--hint); font-size: 13.5px; }
.loading { text-align: center; padding: 40px; color: var(--hint); font-size: 13.5px; }

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.35);
  display: none; align-items: center; justify-content: center; z-index: 60; padding: 20px;
}
.modal-mask.open { display: flex; }
.modal { background: var(--card); border-radius: var(--radius-lg); padding: 24px; width: 100%; max-width: 380px; }
.modal h3 { margin: 0 0 4px; font-size: 16px; font-weight: 500; }
.modal .sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }

.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(80px);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 9px;
  font-size: 13.5px; opacity: 0; transition: all .22s; z-index: 80; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 倒计时 ---------- */
.countdown { font-variant-numeric: tabular-nums; font-weight: 500; }
.countdown.urgent { color: var(--up); }

/* ---------- 预测输入 ---------- */
.opt-btn {
  flex: 1; border: 0.5px solid var(--border-strong); background: var(--card);
  padding: 14px 10px; border-radius: var(--radius); text-align: center;
  font-size: 14px; transition: all .12s;
}
.opt-btn:hover { background: #f7f7f5; }
.opt-btn.sel { border: 2px solid var(--accent); background: var(--accent-soft); padding: 13px 9px; }

input[type="range"] {
  -webkit-appearance: none; width: 100%; height: 6px; border-radius: 4px;
  background: #ebeae7; outline: none; margin: 14px 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--text); cursor: pointer; border: 3px solid #fff;
  box-shadow: 0 0 0 0.5px var(--border-strong);
}

.big-pct { display: flex; align-items: baseline; gap: 8px; }
.big-pct .v { font-size: 30px; font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------- 评论 ---------- */
.cmt { display: flex; gap: 10px; padding: 12px 0; border-bottom: 0.5px solid var(--border); }
.cmt:last-child { border-bottom: none; }
.cmt-body { flex: 1; min-width: 0; }
.cmt-head { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 3px; }
.cmt-text { font-size: 13.5px; line-height: 1.6; word-break: break-word; }

/* ---------- 楼中楼 ---------- */
/* 回复整块左缩进，并给回复的正文加一条左侧细线：长列表里只靠缩进，
   很难一眼看出哪几条属于同一楼。 */
.cmt-reply { margin-left: 30px; }
.cmt-reply .cmt-text { border-left: 2px solid var(--border); padding-left: 10px; }
.cmt-to { color: var(--accent); }
.cmt-act { margin-left: auto; font-size: 12px; color: var(--hint); }
.cmt-act:hover { color: var(--accent); }
/* 一条评论可能有「回复」「删除」两个动作。把右推交给外层容器，
   内部各自复位，否则两个 .cmt-act 会各自抢 margin-left:auto 而错位。 */
.cmt-acts { margin-left: auto; display: flex; gap: 10px; }
.cmt-acts .cmt-act { margin-left: 0; }
.cmt-del:hover { color: var(--up); }

/* ---------- 通知列表 ---------- */
.notif {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 13px 12px; border-bottom: 0.5px solid var(--border);
  border-radius: 8px;
}
.notif:last-child { border-bottom: none; }
/* 未读整条浅底 + 左侧主色细条 + 圆点。只靠圆点的话，长列表里滚过去就找不着了；
   浅底本身又太接近白色，加一条主色边才算「一眼看得出哪几条是新的」。 */
.notif.unread { background: var(--accent-soft); box-shadow: inset 2.5px 0 0 var(--accent); }
.notif.linkable { cursor: pointer; }
.notif.linkable:hover { background: #f2f2f0; }
.notif.unread.linkable:hover { background: #e4edff; }
.notif-mark {
  width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
  background: #f2f2f0; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 500;
}
.notif.unread .notif-mark { background: var(--text); color: #fff; }
.notif-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--up);
  display: inline-block; flex-shrink: 0;
}

/* ---------- 统计块 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; }
.stat { background: #fafaf8; border-radius: var(--radius); padding: 10px 12px; }
.stat .k { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.stat .v { font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; }

.badge-item {
  display: inline-flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px; border-radius: var(--radius); background: #fafaf8; min-width: 76px;
}
.badge-item .b-name { font-size: 12px; font-weight: 500; }
.badge-item .b-desc { font-size: 11.5px; color: var(--hint); text-align: center; }
.badge-icon {
  width: 30px; height: 30px; border-radius: 50%; background: var(--amber-soft); color: var(--amber);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 500;
}

/* ---------- 表格横向滚动容器 ---------- */
/* 榜单 8 列、后台用户表 8 列，手机宽度（390px）放不下。
   默认 table{width:100%} 会把表格压进容器，每格文字逐字换行
   （「已结算」竖成 4 行）。套一层 .tbl-wrap 让表格按内容撑开、超出时整表横向滚动。 */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl-wrap table { width: max-content; min-width: 100%; }
.tbl-wrap th { white-space: nowrap; }

/* ---------- 移动端 ---------- */
@media (max-width: 720px) {
  /* 导航原本是固定 56px 高、不换行的一行：logo + 4 个链接 + 账号按钮全靠 flex 压缩，
     每个链接被压到 38px 宽、98px 高，中文就一个字一个字竖着排，还被 56px 裁掉。
     手机改成两行：第一行 logo + 账号操作，第二行是横向滑动的 tab 条。 */
  .nav-inner { height: auto; min-height: 56px; padding: 8px 14px; flex-wrap: wrap; gap: 8px 10px; }
  .logo { flex-shrink: 0; }
  .nav-links { order: 3; flex: 1 1 100%; overflow-x: auto; }
  .nav-links a { flex: 0 0 auto; padding: 6px 10px; }
  .nav-right { margin-left: auto; flex-shrink: 0; }
  /* 昵称 + Lv 徽章会把这一行挤爆，手机上只留头像（点进去就是个人主页）。
     头像本身也是 <span class="avatar">，必须排除掉，否则整块被隐藏成 0×0。 */
  .nav-right a.row > span:not(.avatar) { display: none; }

  .wrap { padding: 16px 14px 48px; }
  .card { padding: 16px 14px; }
}
