:root {
  --bg: #f4f6fb; --card: #fff; --primary: #2f6fed; --primary-d: #2257c4;
  --text: #1f2733; --muted: #6b7785; --line: #e6eaf0;
  --green: #1ca85b; --red: #e0483a; --amber: #e6902b; --gray: #9aa5b1;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 8px; width: 100%; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
.btn { background: var(--primary); color: #fff; border: none; border-radius: 8px; padding: 10px 16px; font-size: 15px; }
.btn:hover { background: var(--primary-d); }
.btn.ghost { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.danger { background: #fff; color: var(--red); border: 1px solid var(--red); }
.card { background: var(--card); border-radius: 12px; box-shadow: 0 1px 3px rgba(20,40,80,.06); }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 360px; padding: 28px 24px; }
.login-box h1 { font-size: 20px; margin: 0 0 4px; }
.login-box .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.login-box .field { margin-bottom: 12px; position: relative; }
.login-box .err { color: var(--red); font-size: 13px; min-height: 18px; }
.login-box .field .eye { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: transparent; border: none; color: var(--primary); font-size: 13px; cursor: pointer; padding: 4px; }

/* shell */
.topbar { position: sticky; top: 0; z-index: 20; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.topbar .logo { font-weight: 700; color: var(--primary); }
.topbar .who { margin-left: auto; color: var(--muted); font-size: 13px; }
.topbar .who b { color: var(--text); }
.nav { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; background: #fff; border-bottom: 1px solid var(--line); }
.nav button { border: none; background: transparent; color: var(--muted); padding: 7px 12px; border-radius: 20px; white-space: nowrap; }
.nav button.active { background: var(--primary); color: #fff; }
.page { padding: 14px; max-width: 1080px; margin: 0 auto; }

/* grid */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { padding: 14px; }
.kpi .v { font-size: 22px; font-weight: 700; }
.kpi .l { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi.red .v { color: var(--red); } .kpi.green .v { color: var(--green); } .kpi.amber .v { color: var(--amber); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filters .f { flex: 1 1 130px; }

.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px,1fr)); gap: 12px; margin-bottom: 14px; }
.chart-box { padding: 10px 12px; height: 190px; display: flex; flex-direction: column; }
.chart-box .section-title { margin: 0 0 4px; font-size: 14px; }
.chart-box canvas { flex: 1; min-height: 0; }
.chart-box.wide { grid-column: 1 / -1; }
.chart-box.tall { height: 380px; }

/* 总监看板：按销售员 × 区域 二维透视表 */
.wide-card { grid-column: 1 / -1; padding: 10px 14px; }
.pivot-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pivot-table th, .pivot-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.pivot-table th { color: var(--muted); font-weight: 600; }
.pivot-table th.num, .pivot-table td.num { text-align: right; }
.pivot-table tbody td.owner { font-weight: 600; }
.pivot-table td.total, .pivot-table tfoot td { font-weight: 700; background: var(--bg); }
.pivot-table tfoot td { border-top: 2px solid var(--line); }
.table-wrap { overflow-x: auto; }

/* report list */
.rep { padding: 13px 14px; margin-bottom: 10px; }
.rep .top { display: flex; justify-content: space-between; gap: 8px; }
.rep { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.rep .rep-main { flex: 1; min-width: 0; }
.rep .name { font-weight: 600; }
.rep .meta { color: var(--muted); font-size: 13px; margin-top: 4px; line-height: 1.5; }
.rep .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.rep .card-actions { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.tag { font-size: 12px; padding: 3px 8px; border-radius: 12px; background: #eef2fb; color: var(--primary); }
.tag.stage { background: #eaf6ef; color: var(--green); }
.tag.overdue { background: #fdecea; color: var(--red); }
.tag.region { background: #f0f1f3; color: var(--gray); }
.tag.stale { background: #fef3e2; color: var(--amber); font-weight: 600; }
.rep.stale { border-left: 4px solid var(--amber); }
.req { color: var(--red); margin-left: 2px; }
.amount { font-weight: 700; color: var(--primary); }

/* detail */
.detail-head { padding: 16px; margin-bottom: 12px; }
.detail-head h2 { margin: 0 0 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.timeline { padding: 14px; }
.fu { border-left: 3px solid var(--primary); padding: 8px 0 8px 12px; margin-bottom: 10px; }
.fu .meta { color: var(--muted); font-size: 12px; }
.fu .c { margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.section-title { font-weight: 600; margin: 12px 0 6px; }

/* misc */
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1f2733; color: #fff;
  padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 99; opacity: 0; transition: opacity .2s; }
.toast.show { opacity: 1; }
.modal-mask { position: fixed; inset: 0; background: rgba(20,30,50,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 12px; }
/* 强制改密遮罩：最高层级、阻止点击穿透、移动端全屏 */
.force-pwd-mask { z-index: 200; background: rgba(20,30,50,.6); }
.modal { background: #fff; width: 100%; max-width: 560px; border-radius: 14px; padding: 14px 16px; max-height: 96vh; display: flex; flex-direction: column; }
.modal h3 { margin: 0 0 10px; font-size: 16px; flex-shrink: 0; }
.modal-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 2px; }
.modal-foot { flex-shrink: 0; display: flex; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.modal .field { margin-bottom: 7px; }
/* users table */
.user-table-head,
.user-row { display: grid; grid-template-columns: minmax(100px, 1fr) 110px 120px 90px; gap: 10px; align-items: center; padding: 10px 12px; }
.user-table-head { color: var(--muted); font-size: 13px; padding-bottom: 6px; }
.user-row { background: var(--card); border-radius: 12px; box-shadow: 0 1px 3px rgba(20,40,80,.06); margin-bottom: 8px; }
.user-row .u-name b { display: block; }
.user-row .u-name span { color: var(--muted); font-size: 12px; }
.user-row .u-name .u-email { color: var(--primary); text-decoration: none; word-break: break-all; }
.user-row .u-region select,
.user-row .u-role select { width: 100%; min-width: 0; padding: 5px 7px; font-size: 13px; }
.user-row .u-action { text-align: right; }
.user-row .u-action .btn { white-space: nowrap; }
@media (min-width: 720px) { .modal { border-radius: 14px; margin: auto 0; } }

/* ===== 移动端适配（仅窄屏生效，不影响桌面） ===== */
@media (max-width: 600px) {
  .page { padding: 10px; }
  .topbar { padding: 8px 10px; gap: 8px; }
  .topbar .who { font-size: 12px; }
  .nav { padding: 8px 10px; }
  .filters { gap: 6px; }
  .filters .f { flex: 1 1 calc(50% - 6px); }
  .filters .search-box { flex: 1 1 100%; }
  .charts { grid-template-columns: 1fr; }
  .rep { flex-direction: column; align-items: stretch; }
  .rep .card-actions { flex-direction: row; }
  .rep .card-actions .btn { flex: 1; }
  .row2, .form-grid { grid-template-columns: 1fr; }
  .user-table-head { display: none; }
  .user-row { grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; }
  .user-row .u-name { grid-column: 1 / -1; }
  .user-row .u-action { text-align: left; }
  .modal-mask { padding: 0; align-items: stretch; }
  .modal { max-width: 100%; border-radius: 0; max-height: 100vh; min-height: 100vh; }
  .force-pwd-mask .modal { min-height: 100vh; }
}
