* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1E3A5F;
  --primary-light: #2D4E7A;
  --accent: #F59E0B;
  --ok: #10B981;
  --danger: #EF4444;
  --bg: #F5F7FA;
  --card: #FFFFFF;
  --border: #E5E7EB;
  --text: #1F2937;
  --text-sub: #6B7280;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }

/* ===== 布局 ===== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 210px;
  flex-shrink: 0;
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-name { font-size: 16px; font-weight: 600; letter-spacing: .5px; }
.brand-sub { font-size: 11px; color: rgba(255,255,255,.45); margin-top: 3px; letter-spacing: .5px; }

.nav { flex: 1; overflow-y: auto; padding: 10px 0 20px; }
.nav-group { margin-bottom: 4px; }
.nav-group-title {
  font-size: 11px; color: rgba(255,255,255,.4);
  padding: 12px 18px 6px; letter-spacing: 1px;
}
.nav-item {
  display: block; padding: 9px 18px 9px 26px;
  font-size: 13.5px; color: rgba(255,255,255,.78);
  border-left: 3px solid transparent;
  transition: all .15s;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  border-left-color: var(--accent);
  font-weight: 500;
}

.sidebar-foot { padding: 12px 18px; border-top: 1px solid rgba(255,255,255,.1); }
.ver { font-size: 11px; color: rgba(255,255,255,.35); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 56px; background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 15px; font-weight: 600; flex: 1; }

/* 汉堡按钮（仅移动端显示） */
.nav-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 4px;
  width: 32px; height: 32px; padding: 6px; margin-right: 10px;
  background: none; border: none; cursor: pointer; flex-shrink: 0;
}
.nav-toggle span {
  display: block; height: 2px; width: 100%;
  background: var(--primary); border-radius: 1px;
}
.nav-mask { display: none; }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.role-tag {
  background: #EEF2F7; color: var(--primary);
  padding: 3px 9px; border-radius: 3px; font-size: 12px;
}
.user-name { color: var(--text-sub); }
.btn-text { color: var(--text-sub); font-size: 13px; }
.btn-text:hover { color: var(--danger); }

.content { padding: 20px 22px 40px; flex: 1; }

/* ===== flash ===== */
.flash-wrap { padding: 12px 22px 0; }
.flash {
  padding: 10px 14px; border-radius: 4px; margin-bottom: 8px; font-size: 13px;
}
.flash-error { background: #FEF2F2; color: #B91C1C; border-left: 3px solid var(--danger); }
.flash-ok    { background: #ECFDF5; color: #047857; border-left: 3px solid var(--ok); }

/* ===== 历史账期提示条 ===== */
.view-banner {
  margin: 12px 22px 0; padding: 9px 14px;
  background: #FFFBEB; border: 1px solid #FDE68A; border-radius: 4px;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: #92400E;
}
.view-banner strong { color: #78350F; }
.view-banner a { margin-left: auto; color: #B45309; font-size: 12.5px; }
.view-banner-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #F59E0B; flex-shrink: 0;
}

/* ===== 卡片 ===== */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 6px; padding: 18px 20px; margin-bottom: 16px;
}
.card-title {
  font-size: 14px; font-weight: 600; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between;
}
.card-title .sub { font-size: 12px; font-weight: 400; color: var(--text-sub); }

/* ===== 指标卡 ===== */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 6px; padding: 16px 18px;
  position: relative;
}
a.kpi {
  display: block; color: inherit; cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
a.kpi:hover {
  border-color: var(--primary);
  box-shadow: 0 3px 12px rgba(30,58,95,.10);
  transform: translateY(-1px);
}
a.kpi:hover .kpi-go { opacity: 1; }
.kpi-go {
  position: absolute; top: 14px; right: 16px;
  font-size: 12px; color: var(--primary); opacity: 0;
  transition: opacity .15s;
}
.kpi-label { font-size: 12px; color: var(--text-sub); margin-bottom: 8px; }
.kpi-value { font-size: 24px; font-weight: 600; color: var(--primary); font-variant-numeric: tabular-nums; }
.kpi-value.warn { color: var(--accent); }
.kpi-unit { font-size: 13px; font-weight: 400; color: var(--text-sub); margin-left: 3px; }

/* 待办小卡 */
.todo-row { display: flex; gap: 14px; flex-wrap: wrap; }
a.todo-item {
  flex: 0 0 auto; min-width: 150px;
  border: 1px solid var(--border); border-radius: 6px;
  padding: 12px 16px; color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
a.todo-item:hover { border-color: var(--primary); box-shadow: 0 3px 12px rgba(30,58,95,.08); }
.todo-num { font-size: 22px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.todo-num.warn { color: var(--accent); }

/* TOP5 */
.rank-list { display: flex; flex-direction: column; gap: 2px; }
.rank-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: 4px; color: inherit;
}
.rank-item:hover { background: #FAFBFC; }
.rank-no {
  width: 20px; height: 20px; flex: 0 0 20px;
  border-radius: 50%; background: #EEF2F7; color: var(--text-sub);
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.rank-item:nth-child(1) .rank-no { background: var(--accent); color: #fff; }
.rank-name { flex: 1; font-size: 13.5px; }
.rank-val { font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rank-sub { font-size: 12px; color: var(--text-sub); margin-left: 8px; }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }
.table-wrap::-webkit-scrollbar { height: 8px; }
.table-wrap::-webkit-scrollbar-thumb { background: #D5DBE3; border-radius: 4px; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: #BFC7D2; }
.table-wrap::-webkit-scrollbar-track { background: #F1F3F6; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.data th {
  text-align: left; padding: 10px 12px;
  background: #F9FAFB; color: var(--text-sub);
  font-weight: 500; font-size: 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td {
  padding: 10px 12px; border-bottom: 1px solid #F3F4F6;
  vertical-align: middle;
}
table.data tbody tr:hover { background: #FAFBFC; }
table.data.fixed { table-layout: fixed; min-width: 900px; }
table.data.fixed th,
table.data.fixed td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data td.num.pos { color: var(--danger); }
table.data th.num { text-align: right; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.center { text-align: center; }
table.data th.center { text-align: center; }
table.data tfoot td { font-weight: 600; background: #F9FAFB; }

/* ===== 空状态 ===== */
.empty {
  text-align: center; padding: 56px 20px; color: var(--text-sub);
}
.empty-icon { font-size: 34px; opacity: .3; margin-bottom: 12px; }
.empty-text { font-size: 14px; margin-bottom: 6px; }
.empty-hint { font-size: 12.5px; color: #9CA3AF; }

/* ===== 标签 ===== */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 3px;
  font-size: 12px; line-height: 18px;
}
.tag-pending   { background: #F3F4F6; color: #6B7280; }
.tag-uploading { background: #EFF6FF; color: #1D4ED8; }
.tag-calc      { background: #FFFBEB; color: #B45309; }
.tag-review    { background: #FEF3C7; color: #92400E; }
.tag-locked    { background: #ECFDF5; color: #047857; }
.tag-open      { background: #FEF2F2; color: #B91C1C; }
.tag-done      { background: #ECFDF5; color: #047857; }
.tag-ignored   { background: #F3F4F6; color: #6B7280; }

/* ===== 按钮 ===== */
.btn {
  display: inline-block; padding: 7px 15px; border-radius: 4px;
  font-size: 13px; border: 1px solid transparent; cursor: pointer;
  background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-light); }
.btn-ghost {
  background: #fff; color: var(--text); border-color: var(--border);
}
.btn-ghost:hover { background: #F9FAFB; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ===== 表单 ===== */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 14px;
}
.filter-bar select,
.filter-bar input[type=text],
.filter-bar input[type=month],
.filter-bar input[type=date] {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 13px; background: #fff; min-width: 130px;
  font-family: inherit;
}
.filter-bar label { font-size: 13px; color: var(--text-sub); }
form.filter-bar { margin: 0 0 14px; }
.filter-bar select { cursor: pointer; }
.filter-bar select:focus,
.filter-bar input:focus { border-color: var(--primary); outline: none; }
.filter-bar .fld {
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; flex: 0 0 auto;
}
.filter-bar .fld > label { flex: 0 0 auto; }
.filter-bar .btn { padding: 7px 14px; }
.filter-bar .f-year  { min-width: 92px; }
.filter-bar .f-month { min-width: 82px; }
.filter-bar .f-team  { min-width: 118px; }
.filter-bar .f-staff { min-width: 128px; }
.filter-bar .chk {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12.5px; color: var(--text-sub); cursor: pointer;
  font-weight: 500; letter-spacing: 0;
}
.filter-bar .chk input { width: auto; margin: 0; cursor: pointer; }

/* 矩阵页窄屏提示 */
.matrix-hint {
  display: none;
  font-size: 12px; color: #B45309; background: #FFFBEB;
  border: 1px solid #FDE68A; border-radius: 5px;
  padding: 6px 10px; margin: 0 0 8px;
}
@media (max-width: 900px) {
  .matrix-hint { display: block; }
}

/* ===== 上传区 ===== */
.upload-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.upload-card {
  border: 1px dashed #CBD5E1; border-radius: 6px;
  padding: 16px 18px; background: #FCFDFE;
}
.upload-card.done { border-style: solid; border-color: #BBF7D0; background: #F6FEF9; }
.upload-card.fail { border-style: solid; border-color: #FECACA; background: #FFF8F8; }
.upload-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.upload-name { font-size: 13.5px; font-weight: 600; }
.upload-desc { font-size: 12px; color: var(--text-sub); margin-top: 3px; }
.upload-drop {
  border: 1px dashed #CBD5E1; border-radius: 4px;
  padding: 18px; text-align: center; color: #94A3B8; font-size: 12.5px;
  background: #fff; cursor: pointer;
}
.upload-drop:hover { border-color: var(--primary); color: var(--primary); }
.upload-files { margin-top: 10px; font-size: 12.5px; }
.upload-file-row {
  display: flex; justify-content: space-between; padding: 6px 0;
  border-bottom: 1px solid #F3F4F6;
}
.upload-file-row:last-child { border-bottom: none; }

/* ===== 差异标签页 ===== */
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 8px 14px; font-size: 13px; color: var(--text-sub);
  border-bottom: 2px solid transparent; cursor: pointer;
  text-decoration: none; display: inline-block;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }
.tab-count { font-size: 11px; opacity: .7; margin-left: 3px; }

/* ===== 登录页 ===== */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1E3A5F 0%, #2D4E7A 100%);
}
.login-box {
  width: 360px; background: #fff; border-radius: 8px;
  padding: 36px 32px 30px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-title { font-size: 20px; font-weight: 600; text-align: center; color: var(--primary); }
.login-sub { font-size: 12.5px; color: var(--text-sub); text-align: center; margin: 8px 0 26px; }
.login-field { margin-bottom: 14px; }
.login-field label { display: block; font-size: 12.5px; color: var(--text-sub); margin-bottom: 6px; }
.login-field input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 4px; font-size: 14px; font-family: inherit;
}
.login-field input:focus { outline: none; border-color: var(--primary); }
.login-btn {
  width: 100%; padding: 11px; background: var(--primary); color: #fff;
  border: none; border-radius: 4px; font-size: 14.5px; cursor: pointer;
  margin-top: 6px; font-family: inherit;
}
.login-btn:hover { background: var(--primary-light); }
.login-err {
  background: #FEF2F2; color: #B91C1C; padding: 9px 12px;
  border-radius: 4px; font-size: 12.5px; margin-bottom: 14px;
}
.login-foot { text-align: center; font-size: 11.5px; color: #9CA3AF; margin-top: 22px; }

/* ===== 提示条 ===== */
.notice {
  background: #FFFBEB; border-left: 3px solid var(--accent);
  padding: 11px 14px; border-radius: 4px; font-size: 12.5px;
  color: #92400E; margin-bottom: 14px;
}
.notice-soft {
  background: #F0F9FF; border-left: 3px solid #0284C7;
  color: #075985;
}

/* ===== 响应式 ===== */
@media (max-width: 1200px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .upload-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 200;
    height: 100vh; max-height: 100vh; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 4px 0 18px rgba(0,0,0,.18);
  }
  .sidebar.open { transform: translateX(0); }
  .nav-mask.show {
    display: block; position: fixed; inset: 0;
    background: rgba(0,0,0,.35); z-index: 150;
  }
  .nav-toggle { display: flex; }
  .content { padding: 14px; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 20px; }
  .topbar { padding: 0 14px; }
  .topbar-right .user-name { display: none; }
  .card { padding: 14px; }
  .view-banner { margin: 10px 14px 0; font-size: 12.5px; padding: 8px 12px; }
  .view-banner a { font-size: 12px; }
  table.data { font-size: 12.5px; }
  table.data th, table.data td { padding: 8px 8px; }
  table.matrix { font-size: 12px; }
  table.matrix th, table.matrix td { padding: 6px 7px; }
  table.matrix .mx-cat { min-width: 108px; }
  table.matrix .mx-num { min-width: 72px; }
}

/* ==================== 提成矩阵（业务员 × 类目） ==================== */
.matrix-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.matrix {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
  min-width: 100%;
}
table.matrix th,
table.matrix td {
  white-space: nowrap;
  padding: 7px 9px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--line);
}
table.matrix thead th {
  background: #F7F9FC;
  font-weight: 600;
  color: var(--primary);
  position: sticky;
  top: 0;
  z-index: 2;
}
table.matrix thead tr:nth-child(2) th { top: 33px; }
table.matrix .mx-cat {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #fff;
  text-align: left;
  min-width: 132px;
  border-right: 1px solid var(--line);
}
table.matrix thead .mx-cat { z-index: 5; background: #F7F9FC; }
table.matrix .mx-rate { min-width: 56px; color: var(--text-sub); }
table.matrix .mx-num { min-width: 82px; }
table.matrix .mx-grp { text-align: center; border-left: 1px solid var(--line); }
table.matrix .mx-sum { background: #FBFCFE; font-weight: 600; }
table.matrix tbody tr:hover td { background: #F6F9FD; }
table.matrix tbody tr:hover .mx-cat { background: #EFF4FB; }
table.matrix tfoot td {
  background: #F1F4F9;
  font-weight: 700;
  border-top: 2px solid #DDE3EC;
}
table.matrix tfoot .mx-cat { background: #F1F4F9; z-index: 4; }


/* ===== 趋势折线图图例 ===== */
.trend-legend {
  display: flex; align-items: center; gap: 18px;
  margin: -2px 0 6px; padding-left: 4px;
}
.trend-legend .lg {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-sub);
}
.trend-legend .lg i {
  width: 16px; height: 3px; border-radius: 2px; display: inline-block;
}
.trend-legend .lg-net i  { background: #1E3A5F; }
.trend-legend .lg-comm i { background: #D98E3A; }


/* ===== 业务员提成分析 ===== */
.ana-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 860px) {
  .ana-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.ana-cell {
  background: #F8FAFC;
  border: 1px solid #E8EDF3;
  border-radius: 7px;
  padding: 13px 15px;
}
.ana-k {
  font-size: 12px;
  color: var(--text-sub);
  margin-bottom: 7px;
  letter-spacing: 0.2px;
}
.ana-v {
  font-size: 25px;
  font-weight: 700;
  color: #1E3A5F;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.ana-v i {
  font-size: 12.5px;
  font-style: normal;
  font-weight: 500;
  color: #8A93A0;
  margin-left: 3px;
}
.ana-s {
  font-size: 11.5px;
  color: #9CA3AF;
  margin-top: 6px;
}
.ana-s .up   { color: #15803D; font-weight: 600; }
.ana-s .down { color: #B91C1C; font-weight: 600; }

.down { color: #B91C1C; }
.dim  { color: #8A93A0; font-size: 12.5px; }

.flag {
  display: inline-block;
  font-size: 11px;
  line-height: 1.5;
  padding: 1px 6px;
  margin: 1px 3px 1px 0;
  border-radius: 4px;
  background: #FEF3C7;
  color: #B45309;
  border: 1px solid #FDE68A;
  white-space: nowrap;
}

/* 单量占比 vs 提成占比 对比条 */
.bars { padding-top: 5px; padding-bottom: 5px; }
.bar-row {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 13px;
  margin: 1px 0;
}
.bar-lab {
  flex: 0 0 auto;
  width: 12px;
  font-size: 10px;
  color: #9CA3AF;
  text-align: center;
}
.bar-bg {
  flex: 1 1 auto;
  min-width: 44px;
  height: 7px;
  background: #F1F4F8;
  border-radius: 4px;
  overflow: hidden;
}
.bar-fill {
  display: block;
  height: 100%;
  border-radius: 4px;
  transition: width .2s;
}
.bar-o { background: #2D4E7A; }
.bar-c { background: #D98E3A; }
.bar-num {
  flex: 0 0 auto;
  width: 40px;
  text-align: right;
  font-size: 10.5px;
  color: #9CA3AF;
  font-variant-numeric: tabular-nums;
}

.eff-hi { color: #15803D; font-weight: 700; }
.eff-lo { color: #B91C1C; font-weight: 700; }

/* 排序切换 */
.sort-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  margin: -2px 0 10px;
  padding: 3px 0;
}
.sort-tabs .sort-lab {
  font-size: 12px;
  color: var(--text-sub);
  margin-right: 4px;
}
.sort-tabs a {
  display: inline-block;
  font-size: 12.5px;
  padding: 4px 11px;
  border-radius: 5px;
  color: #4B5563;
  background: #F3F5F8;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all .15s;
}
.sort-tabs a:hover { background: #E8EDF3; }
.sort-tabs a.active {
  background: #1E3A5F;
  color: #fff;
  font-weight: 600;
}
th .vs {
  font-size: 10px;
  color: #B9C0CA;
  font-weight: 400;
  margin: 0 1px;
}

.ana-note {
  font-size: 12px;
  line-height: 1.85;
  color: #6B7280;
  background: #F8FAFC;
  border: 1px solid #E8EDF3;
  border-radius: 7px;
  padding: 12px 16px;
  margin-top: 4px;
}
.ana-note b { color: #4B5563; }


/* 自动结论块 */
.ana-insight {
  background: linear-gradient(180deg, #F4F8FD 0%, #FAFCFF 100%);
  border: 1px solid #D9E4F0;
  border-left: 4px solid #1E3A5F;
  border-radius: 7px;
  padding: 14px 18px 13px;
  margin-bottom: 14px;
}
.ana-insight-h {
  font-size: 12.5px;
  font-weight: 700;
  color: #1E3A5F;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
}
.ana-insight ul {
  margin: 0;
  padding-left: 17px;
  list-style: none;
}
.ana-insight li {
  position: relative;
  font-size: 13px;
  line-height: 1.95;
  color: #374151;
}
.ana-insight li::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 11px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #9BB3CE;
}
