/* ============================================================
   欢乐积分 · 统一设计系统（蓝色专业风）
   主色 #1677ff ｜ 系统字体 ｜ 移动端优先
   ============================================================ */

:root {
  --brand: #1677ff;
  --brand-dark: #0958d9;
  --brand-light: #4096ff;
  --brand-tint: #e6f4ff;
  --brand-tint-2: #f0f7ff;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1a1a1a;
  --text-2: #5c6166;
  --text-3: #9aa0a6;
  --border: #e8eaed;
  --success: #52c41a;
  --success-tint: #f0fdf4;
  --warning: #d46b08;
  --warning-tint: #fff7e6;
  --danger: #ff4d4f;
  --danger-tint: #fff1f0;
  --radius: 16px;
  --radius-s: 10px;
  --shadow: 0 1px 4px rgba(16, 24, 40, .05);
  --shadow-lg: 0 6px 20px rgba(16, 24, 40, .08);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

.wrap { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--bg); }
.wrap.pad-bottom { padding-bottom: 24px; }

/* ---------- 顶部栏 ---------- */
.topbar {
  background: var(--brand);
  color: #fff;
  padding: 15px 16px;
  display: flex;
  align-items: center;
  gap: 4px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .back {
  color: #fff; font-size: 22px; line-height: 1; padding: 0 8px 0 0;
  display: flex; align-items: center; justify-content: center;
}
.topbar .back svg { width: 22px; height: 22px; }
.topbar .t { font-size: 16px; font-weight: 600; flex: 1; }
.topbar .act {
  background: rgba(255,255,255,.2); color: #fff; border: none;
  padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 600;
}
.topbar .act:active { background: rgba(255,255,255,.3); }

/* ---------- 业务员首页 Hero ---------- */
.hero {
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-light) 100%);
  color: #fff;
  padding: 18px 20px 64px;
}
.hero .bar { display: flex; align-items: center; justify-content: space-between; }
.hero .bar .who { display: flex; align-items: center; gap: 8px; }
.hero .name { font-size: 17px; font-weight: 600; }
.hero .role {
  font-size: 11px; background: rgba(255,255,255,.22); border-radius: 4px;
  padding: 2px 8px;
}
.hero .logout {
  background: rgba(255,255,255,.18); color: #fff; border: none;
  padding: 7px 14px; border-radius: 8px; font-size: 13px;
}
.hero .bal-label { font-size: 13px; opacity: .85; margin-top: 24px; text-align: center; }
.hero .bal-num { text-align: center; margin-top: 2px; }
.hero .bal-num .num { font-size: 54px; font-weight: 700; letter-spacing: 1px; }
.hero .bal-num .unit { font-size: 15px; opacity: .85; margin-left: 6px; }

/* 悬浮统计卡（叠在 Hero 与内容之间） */
.hero-stats {
  background: var(--card);
  border-radius: var(--radius);
  margin: -40px 16px 14px;
  padding: 16px 8px;
  box-shadow: var(--shadow-lg);
  position: relative;
  display: flex;
}
.hero-stats .stat { flex: 1; text-align: center; }
.hero-stats .stat .n { font-size: 22px; font-weight: 700; color: var(--brand); }
.hero-stats .stat .l { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.hero-stats .stat + .stat { border-left: 1px solid var(--border); }

/* ---------- 卡片 / 区块 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  margin: 0 16px 14px; padding: 18px 18px;
  box-shadow: var(--shadow);
}
.card .title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card .title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.card .title svg { width: 17px; height: 17px; color: var(--brand); }
.card .more { font-size: 13px; color: var(--brand); }

/* ---------- 入口网格 ---------- */
.entries { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 0 16px 14px; }
.entries.three { grid-template-columns: repeat(3, 1fr); }
.entry {
  background: var(--card); border-radius: var(--radius); padding: 18px 16px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
}
.entry .ic {
  width: 40px; height: 40px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-tint); color: var(--brand);
}
.entry .ic svg { width: 21px; height: 21px; }
.entry .t { font-size: 15px; font-weight: 600; }
.entry .d { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ---------- 列表行 ---------- */
.urow {
  display: flex; align-items: center; padding: 13px 0;
  border-bottom: 1px solid #f5f6f8;
}
.urow:last-child { border-bottom: none; }
.urow .nm { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; }
.urow .sub { font-size: 12px; color: var(--text-3); margin-right: 12px; }
.urow .bal { font-size: 17px; font-weight: 700; color: var(--brand); }
.urow .arr { color: #c9cdd4; margin-left: 8px; }

/* 流水 / 面访条目 */
.tx-item { display: flex; align-items: center; padding: 13px 0; border-bottom: 1px solid #f5f6f8; }
.tx-item:last-child { border-bottom: none; }
.tx-item .info { flex: 1; min-width: 0; }
.tx-item .r { font-size: 14px; word-break: break-all; }
.tx-item .t { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.tx-item .amt { font-size: 16px; font-weight: 700; margin-left: 12px; }
.amt.in { color: var(--success); }
.amt.out { color: var(--danger); }
.amt.fix { color: var(--warning); }

.v-item { padding: 13px 0; border-bottom: 1px solid #f5f6f8; }
.v-item:last-child { border-bottom: none; }
.v-item .row1 { display: flex; justify-content: space-between; align-items: baseline; }
.v-item .cname { font-size: 15px; font-weight: 600; }
.v-item .pts { color: var(--brand); font-weight: 700; font-size: 15px; }
.v-item .row2 { margin-top: 5px; font-size: 12px; color: var(--text-2); display: flex; justify-content: space-between; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 5px;
  font-size: 11px; font-weight: 600; line-height: 1.6;
}
.tag.on { color: var(--brand); background: var(--brand-tint); }
.tag.off { color: var(--text-3); background: #f0f2f5; }
.tag.ok { color: var(--success); background: var(--success-tint); }
.tag.warn { color: var(--warning); background: var(--warning-tint); }
.tag.danger { color: var(--danger); background: var(--danger-tint); }
.tag.policy { color: var(--warning); background: var(--warning-tint); }

/* ---------- 表单 ---------- */
.label { font-size: 13px; color: var(--text-2); margin: 12px 0 6px; }
.field {
  width: 100%; padding: 13px 14px; border: 1px solid #d9dde3; border-radius: var(--radius-s);
  font-size: 16px; outline: none; background: #fff; color: var(--text);
}
.field:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
select.field { appearance: none; }
/* 统一日期/月份选择器（date-picker.js 接管后） */
.dp-input.field, .filter .dp-input {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa0a6' stroke-width='2' stroke-linecap='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='3'/%3E%3Cpath d='M16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 18px;
}
.dp-input.field { padding-right: 46px; }
.date-row { display: flex; gap: 10px; align-items: center; }
.date-row .field { flex: 1; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 14px; border: none; border-radius: var(--radius-s);
  font-size: 16px; font-weight: 600; transition: opacity .15s;
}
.btn:active { opacity: .85; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.ghost { background: #f0f2f5; color: var(--text-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { width: auto; padding: 9px 16px; font-size: 13px; }

/* 行内小按钮 */
.ibtn {
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; font-size: 13px; color: var(--text-2);
}
.ibtn.primary { color: var(--brand); border-color: #b5d4f4; }
.ibtn.danger { color: var(--danger); border-color: #ffccc7; }

/* ---------- Tab ---------- */
.tabs { display: flex; background: var(--card); border-bottom: 1px solid var(--border); }
.tab {
  flex: 1; text-align: center; padding: 13px 0; font-size: 15px;
  color: var(--text-2); border-bottom: 2px solid transparent; cursor: pointer;
}
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* 筛选条 */
.filter {
  background: var(--card); padding: 12px 16px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.filter input[type=month], .filter .dp-input, .filter select {
  flex: 1; padding: 9px 12px; border: 1px solid #d9dde3; border-radius: 8px;
  font-size: 14px; outline: none; background: #fff;
}
.filter .clear { font-size: 13px; color: var(--brand); border: none; background: none; padding: 6px; white-space: nowrap; }

/* ---------- 弹层（底部） ---------- */
.mask { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 100; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; background: #fff;
  border-radius: 18px 18px 0 0; padding: 20px 20px 28px;
  max-width: 480px; margin: 0 auto; z-index: 101; display: none;
  max-height: 86vh; overflow-y: auto;
}
.sheet h3 { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.sheet .ops { display: flex; gap: 10px; margin-top: 18px; }
.sheet .ops .btn { flex: 1; }

/* 方向选择（加分/扣分） */
.dir-row { display: flex; gap: 10px; margin: 12px 0; }
.dir {
  flex: 1; text-align: center; padding: 12px; border: 1px solid #d9dde3;
  border-radius: var(--radius-s); font-size: 15px; font-weight: 600; cursor: pointer; color: var(--text-2);
}
.dir.active.add { border-color: var(--brand); color: var(--brand); background: var(--brand-tint); }
.dir.active.sub { border-color: var(--danger); color: var(--danger); background: var(--danger-tint); }

/* ---------- 提示 ---------- */
.msg { font-size: 13px; text-align: center; margin-top: 12px; min-height: 18px; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--success); }
.msg.warn { color: var(--warning); }

.empty { text-align: center; color: var(--text-3); padding: 32px 0; font-size: 14px; }
.empty svg { width: 40px; height: 40px; opacity: .4; margin-bottom: 8px; }

.hint { font-size: 12px; color: var(--text-3); text-align: center; margin-top: 10px; }
.note {
  font-size: 12px; color: var(--text-2); background: var(--warning-tint);
  border-radius: 10px; padding: 10px 14px; margin: 12px 14px 0; line-height: 1.6;
}

/* ---------- Toast ---------- */
#toast {
  display: none; position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  background: rgba(26,26,26,.9); color: #fff; padding: 10px 20px;
  border-radius: 8px; font-size: 13px; z-index: 200; max-width: 82vw;
}
#toast.err { background: var(--danger); }
#toast.ok { background: var(--success); }

/* ---------- 登录 / 注册（居中卡片） ---------- */
.auth-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: linear-gradient(160deg, #0f5fd7 0%, #1677ff 60%, #4096ff 100%);
}
.auth-box {
  background: #fff; padding: 36px 32px 30px; border-radius: 18px;
  box-shadow: 0 12px 40px rgba(16, 24, 40, .18); width: 100%; max-width: 380px;
}
.auth-box .logo { text-align: center; font-size: 22px; font-weight: 700; color: var(--brand); }
.auth-box .logo-sub { text-align: center; color: var(--text-3); font-size: 13px; margin: 6px 0 26px; }
.auth-box .field { margin-bottom: 14px; }
.auth-box .btn { margin-top: 6px; }
.auth-box .auth-foot { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-2); }
.auth-box .auth-foot a { color: var(--brand); }

/* ---------- 二维码卡 ---------- */
.qr-card {
  background: var(--card); border-radius: var(--radius); margin: -40px 16px 14px;
  padding: 20px; text-align: center; box-shadow: var(--shadow-lg); position: relative;
}
.qr-card .tip { font-size: 13px; color: var(--text-2); margin-bottom: 14px; }
.qr-card img { width: 190px; height: 190px; border: 1px solid var(--border); border-radius: 10px; }
.qr-card .qr-note { font-size: 12px; color: var(--text-3); margin-top: 12px; }
.qr-card .token-box {
  margin-top: 12px; font-size: 13px; color: var(--text-2); background: var(--brand-tint-2);
  border-radius: 8px; padding: 8px 10px; word-break: break-all;
}

/* ============================================================
   PC 响应式布局（≥900px）：桌面端加宽 + 双列仪表盘
   手机端（<900px）完全不受以下规则影响
   ============================================================ */
@media (min-width: 900px) {
  /* ---- 通用：容器与组件加宽 ---- */
  .wrap { max-width: 1000px; }
  .topbar { padding: 15px 32px; }
  .hero { padding: 26px 32px 78px; border-radius: 0 0 22px 22px; }
  .hero-stats { margin: -48px 32px 16px; }
  .entries { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin: 0 32px 16px; gap: 16px; }
  .card { margin: 0 32px 16px; padding: 20px 22px; }
  .note { margin: 12px 32px 0; }
  .filter { padding: 12px 32px; }

  /* 底部弹层 → PC 上变为居中对话框 */
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 18px; width: 480px; max-width: 92vw;
    box-shadow: 0 16px 48px rgba(16, 24, 40, .22);
  }

  /* 登录卡片在 PC 上稍微放大 */
  .auth-box { max-width: 400px; }

  /* ---- 管理端仪表盘（manager.html）：双列布局 ---- */
  .dash-admin {
    display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px;
    max-width: 1060px;
  }
  .dash-admin > .hero,
  .dash-admin > .hero-stats,
  .dash-admin > .entries { grid-column: 1 / -1; }
  .dash-admin > .hero-stats { margin: -48px 0 16px; }
  .dash-admin > .entries { margin: 0 0 16px; }
  .dash-admin > .card { margin: 0 0 16px; }
  .dash-admin > .card:nth-child(4) { grid-row: span 2; } /* 成员积分卡占左侧两行 */

  /* ---- 业务员端仪表盘（agent.html）：左个人码 + 右内容 ---- */
  .dash-agent { display: grid; grid-template-columns: 380px 1fr; column-gap: 20px; }
  .dash-agent > .hero,
  .dash-agent > .hero-stats { grid-column: 1 / -1; }
  .dash-agent > .hero-stats { margin: -48px 0 16px; }
  .dash-agent > .qr-card { margin: 0 0 16px; grid-row: span 2; }
  .dash-agent > .entries { grid-template-columns: repeat(2, 1fr); margin: 0 0 16px; }
  .dash-agent > .card { margin: 0 0 16px; }
}
