/* ============ 基础变量（浅色主题） ============ */
:root {
  --c-bg: #f4f6fb;
  --c-surface: #ffffff;
  --c-surface-2: #f8fafc;
  --c-border: #e5e9f2;
  --c-text: #1f2733;
  --c-text-soft: #66708a;
  --c-primary: #2f6df6;
  --c-primary-soft: #e8f0ff;
  --c-success: #1aa86b;
  --c-warning: #e0922b;
  --c-danger: #e0524f;
  --c-danger-soft: #fdeaea;
  --c-shadow: 0 6px 22px rgba(31, 39, 51, 0.08);
  --radius: 12px;
  --sidebar-w: 232px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI Emoji", "Apple Color Emoji",
    "Noto Color Emoji", sans-serif;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ============ 通用按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--c-border);
  border-radius: 8px;
  background: var(--c-surface);
  color: var(--c-text);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn-primary:hover { background: #235ad6; color: #fff; }
.btn-outline { background: #fff; border: 1px solid var(--c-primary); color: var(--c-primary); }
.btn-outline:hover { background: #eef4ff; color: var(--c-primary); }
.btn-danger { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }
.btn-danger:hover { background: #c8423f; color: #fff; }
.btn-warning { background: #e08a00; border-color: #e08a00; color: #fff; }
.btn-warning:hover { background: #c87900; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--c-text-soft); }
.btn-ghost:hover { background: var(--c-surface-2); color: var(--c-text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; letter-spacing: 2px; }

/* ============ 登录页 ============ */
.login-view {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2f6df6 55%, #5b8def 100%);
  overflow: hidden;
}
.login-card {
  position: relative; z-index: 2;
  width: 380px; max-width: 90vw;
  background: var(--c-surface);
  border-radius: 18px;
  padding: 40px 34px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.login-brand { text-align: center; margin-bottom: 26px; }
.login-logo { font-size: 46px; line-height: 1; }
.login-brand h1 { font-size: 21px; margin-top: 10px; }
.login-sub { color: var(--c-text-soft); font-size: 12px; letter-spacing: 1px; margin-top: 2px; }
.login-form .field { display: block; margin-bottom: 16px; }
.login-form .field span { display: block; font-size: 13px; color: var(--c-text-soft); margin-bottom: 6px; }
.login-form input {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--c-border); border-radius: 9px;
  font-size: 14px; outline: none; transition: border-color 0.15s;
}
.login-form input:focus { border-color: var(--c-primary); }
.login-error { color: var(--c-danger); font-size: 13px; margin-bottom: 10px; }
.login-form .remember-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--c-text-soft); margin-bottom: 16px; cursor: pointer;
}
.login-form .remember-row input[type="checkbox"] { width: 16px; height: 16px; flex: 0 0 auto; cursor: pointer; }
.login-tip { text-align: center; color: var(--c-text-soft); font-size: 12px; margin-top: 14px; }
.login-bg {
  position: absolute; inset: 0; z-index: 1; opacity: 0.12;
  background-image: radial-gradient(circle at 20% 20%, #fff 1px, transparent 1px),
    radial-gradient(circle at 70% 60%, #fff 1px, transparent 1px);
  background-size: 60px 60px;
}

/* ============ 登录页·手机端专属（窄屏卡片占满、输入框/按钮放大，方便手指点按） ============ */
@media (max-width: 600px) {
  .login-view { padding: 16px; align-items: flex-start; }
  .login-card {
    width: 100%;
    max-width: 100%;
    margin: 8vh auto 0;
    padding: 30px 22px;
    border-radius: 14px;
  }
  .login-logo { font-size: 40px; }
  .login-brand h1 { font-size: 19px; }
  .login-form .field { margin-bottom: 18px; }
  .login-form .field span { font-size: 14px; }
  .login-form input {
    padding: 14px 14px;      /* 更大的点按区域 */
    font-size: 16px;         /* 关键：防止 iOS Safari 自动放大输入框 */
    border-radius: 10px;
  }
  .login-form .btn-primary {
    padding: 14px;           /* 登录按钮放大，更好点 */
    font-size: 16px;
  }
  .login-tip { font-size: 12px; }
}

/* ============ 后台布局 ============ */
.app-view { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 30;
  transition: transform 0.25s ease;
}
.sidebar-head {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 22px; font-size: 18px; font-weight: 700;
  border-bottom: 1px solid var(--c-border);
}
.sidebar-logo { font-size: 24px; }
.sidebar-nav { flex: 1; padding: 14px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 9px;
  color: var(--c-text-soft); text-decoration: none; font-size: 14px;
  font-weight: 600;
  transition: all 0.15s;
}
.nav-item:hover { background: var(--c-surface-2); color: var(--c-text); }
.nav-item.active { background: var(--c-primary-soft); color: var(--c-primary); font-weight: 700; }
/* 父级（可折叠）：右侧箭头，点击展开子栏目 */
.nav-parent { justify-content: space-between; cursor: pointer; }
.nav-caret { font-size: 10px; color: var(--c-text-soft); transition: transform 0.2s; }
.nav-parent.open .nav-caret { transform: rotate(90deg); }
/* 子栏目分组：默认隐藏，父级 .open 时展开 */
.nav-subgroup { display: none; flex-direction: column; gap: 2px; }
.nav-parent.open + .nav-subgroup { display: flex; }
.nav-sub { font-size: 13px; padding-left: 30px; }
.sidebar-foot {
  padding: 16px 18px; border-top: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--c-text-soft);
}
.btn-logout {
  background: none; border: none; color: var(--c-text-soft);
  cursor: pointer; font-size: 13px;
}
.btn-logout:hover { color: var(--c-danger); }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 26px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--c-border);
}
.menu-toggle {
  display: none; background: none; border: none;
  font-size: 22px; cursor: pointer; color: var(--c-text);
}
.page-title { font-size: 18px; font-weight: 700; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 18px; color: var(--c-text-soft); font-size: 13px; }
.topbar-user { font-weight: 500; color: var(--c-text); }
.view-container { padding: 26px; }

/* ============ 卡片网格 ============ */
.dash-cutoff {
  display: inline-flex; align-items: baseline; gap: 8px;
  margin-bottom: 16px; padding: 6px 14px;
  background: var(--c-surface-2); border: 1px solid var(--c-border);
  border-radius: 999px; font-size: 13px;
}
.dash-cutoff-label { color: var(--c-text-soft); }
.dash-cutoff-value { color: var(--c-primary); font-weight: 700; font-variant-numeric: tabular-nums; }
.dash-period-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.dash-period-tip { color: var(--c-text-soft); font-size: 13px; }
.dash-year-row { margin-bottom: 16px; }
.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 18px; margin-bottom: 22px;
}
/* 专家统计（DP区域情况）统计卡网格：按可用宽度自动均分，任何卡数下都至少 2 列（窄屏覆盖见媒体查询） */
#mk-expert-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px; margin-bottom: 0;
}
.stat-card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--c-shadow);
}
.stat-card .stat-label { color: var(--c-text-soft); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.stat-card .stat-icon { font-size: 18px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; margin-top: 10px; }
.stat-card .stat-foot { font-size: 12px; color: var(--c-text-soft); margin-top: 6px; }
.stat-card.alert .stat-value { color: var(--c-danger); }

.mk-rank-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.mk-rank-table th, .mk-rank-table td { padding: 10px 12px; border-bottom: 1px solid var(--c-border); }
.mk-rank-table thead th { background: var(--c-bg-soft, #f3f4f6); color: var(--c-text-soft); font-weight: 600; white-space: nowrap; }
.mk-rank-table tbody tr:hover { background: var(--c-bg-soft, #f3f4f6); }

.panel {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--c-shadow);
  margin-bottom: 22px;
  min-width: 0;   /* 允许 grid 子项收缩到格子宽度，否则内部宽图表会把 .panel 撑宽、滚动失效 */
}
.panel-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.panel-sub { font-size: 12px; color: var(--c-text-soft); margin: -10px 0 14px; font-weight: 400; }
.panel-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.panel-grid-2 > .panel { min-width: 0; }
.panel-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.panel-grid-3 > .panel { min-width: 0; }
.chart-wrap { width: 100%; min-width: 0; overflow: hidden; }
.chart-empty { color: var(--c-text-soft); text-align: center; padding: 30px 0; font-size: 13px; }

/* SVG 文本强制使用中文字体回退链：CSS 优先级高于 SVG 的 font-family 表现属性，
   可避免部分浏览器对 SVG text 上带嵌套引号的 font-family 字符串解析失败、
   导致中文（学术经理名字等）回退到 sans-serif（如 Arial 无中文字形）渲染为方框。 */
.chart-wrap svg text,
.donut-wrap svg text {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
               "WenQuanYi Micro Hei", "Heiti SC", "Noto Sans CJK SC", sans-serif;
}

/* 图表横向滚动容器：用于柱状图。当数据多、整体图宽超过容器时向右滚动查看。 */
.chart-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;            /* 关键：永不超出父容器宽度，宽图表在内部滚动 */
  -webkit-overflow-scrolling: touch;
  padding-bottom: 6px;        /* 为底部滚动条预留空间，避免遮挡 X 轴标签 */
}
.chart-scroll > svg { display: block; }
/* 分组柱状图图例（实际 vs 目标） */
.chart-legend { display: flex; gap: 20px; align-items: center; margin-bottom: 8px; font-size: 13px; color: var(--c-text); }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
/* 自定义细滚动条（不影响其他元素） */
.chart-scroll::-webkit-scrollbar { height: 8px; }
.chart-scroll::-webkit-scrollbar-thumb { background: #d6dbe5; border-radius: 4px; }
.chart-scroll::-webkit-scrollbar-thumb:hover { background: #b9c0cd; }
.chart-scroll::-webkit-scrollbar-track { background: transparent; }
/* 省份销售排行等内部上下滚动的细滚动条 */
.chart-wrap::-webkit-scrollbar { width: 8px; }
.chart-wrap::-webkit-scrollbar-thumb { background: #d6dbe5; border-radius: 4px; }
.chart-wrap::-webkit-scrollbar-thumb:hover { background: #b9c0cd; }
.chart-wrap::-webkit-scrollbar-track { background: transparent; }


/* ============ 排行表格列 ============ */
.col-rank { width: 64px; text-align: center; color: var(--c-text-soft); }
.col-amount { text-align: right; font-weight: 700; }
.col-amount-center { text-align: center !important; }

/* ============ 工具栏 / 筛选 ============ */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin-bottom: 18px;
}
.toolbar .search {
  flex: 1; min-width: 200px; position: relative;
}
.toolbar .search input {
  width: 100%; padding: 9px 12px 9px 34px;
  border: 1px solid var(--c-border); border-radius: 8px; font-size: 13px; outline: none;
}
.toolbar .search input:focus { border-color: var(--c-primary); }
.toolbar .search::before {
  content: "🔍"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: 0.6;
}
.toolbar select {
  padding: 9px 12px; border: 1px solid var(--c-border); border-radius: 8px;
  font-size: 13px; outline: none; background: var(--c-surface); color: var(--c-text);
}
.toolbar select:focus { border-color: var(--c-primary); }
.toolbar select.filter-sup { max-width: 200px; }
.toolbar .date-range { display: inline-flex; align-items: center; gap: 6px; }
.toolbar .date-range .date-sep { color: var(--c-text-soft); font-size: 13px; }
.toolbar input[type="date"] {
  padding: 8px 10px; border: 1px solid var(--c-border); border-radius: 8px;
  font-size: 13px; outline: none; background: var(--c-surface); color: var(--c-text);
  font-family: inherit;
}
.toolbar input[type="date"]:focus { border-color: var(--c-primary); }
.spacer { flex: 1; }

/* 订单明细筛选区：多行布局（仅作用于订单页，不影响其它 .toolbar） */
.toolbar.toolbar-orders { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.toolbar.toolbar-orders .tb-row { display: flex; gap: 12px; align-items: center; }
.toolbar.toolbar-orders .tb-row-search .search { flex: 1; min-width: 0; }
.toolbar.toolbar-orders .tb-half { flex: 1 1 0; min-width: 0; width: 100%; }
.toolbar.toolbar-orders .tb-third { flex: 1 1 0; min-width: 0; width: 100%; }
/* 四级区域级联：一行 4 个下拉，各占 25% */
.toolbar.toolbar-orders .tb-quarter { flex: 1 1 0; min-width: 0; width: 100%; }
.toolbar.toolbar-orders .tb-row-region { align-items: center; }
/* 上级未选中时下级不可选（可选项依赖上级），用禁用态提示层级关系 */
.toolbar.toolbar-orders select:disabled { background: var(--c-surface-2); color: var(--c-text-soft); cursor: not-allowed; }
.toolbar.toolbar-orders .tb-row-date .date-range { flex: 1; }
.toolbar.toolbar-orders .tb-row-date .date-range input[type="date"] { flex: 1 1 0; min-width: 0; }
.toolbar.toolbar-orders .tb-row-actions { justify-content: flex-end; }
.toolbar.toolbar-orders .btn { text-align: center; }

/* ============ 学术营销 · 看板：登录人信息卡片 ============ */
.mk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 18px; }
.mk-card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: 10px; padding: 18px 20px; }
.mk-label { font-size: 12px; opacity: 0.65; margin-bottom: 8px; }
.mk-value { font-size: 20px; font-weight: 600; color: var(--c-text); }

/* ============ 表格 ============ */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--c-border); border-radius: 10px; }
/* DP 区域排行：高度与左侧「各省业绩对比」柱状图（SVG 固定 460px）保持一致，
   数据超出时内部纵向滚动；表头 sticky 不随滚动消失。 */
.table-wrap.scroll-y { max-height: 460px; overflow-y: auto; }
.table-wrap.scroll-y thead th {
  position: sticky; top: -1px; z-index: 2;
  background: var(--c-surface-2);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 13px 14px; background: var(--c-surface-2);
  color: var(--c-text-soft); font-weight: 600; white-space: nowrap;
  border-bottom: 1px solid var(--c-border);
}
tbody td { padding: 13px 14px; border-bottom: 1px solid var(--c-border); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--c-surface-2); }
.col-actions { text-align: right; }
.muted { color: var(--c-text-soft); }
.region-path { font-size: 12px; margin-top: 2px; }
.col-check { width: 40px; text-align: center; }
.col-check input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--c-primary); }
thead .col-check input { cursor: pointer; }

/* 批量操作条 */
.batch-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; margin-bottom: 16px;
  background: var(--c-surface-2); border: 1px solid var(--c-border);
  border-radius: 10px; flex-wrap: wrap;
}
.batch-bar .sel-info { font-size: 13px; color: var(--c-text-soft); font-weight: 500; }
.batch-bar .spacer { flex: 1; }
.toolbar select.pagesize { padding: 9px 10px; }

/* 订单列表上方「产品汇总」（按商品聚合销售数量合计） */
.order-summary {
  display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 14px;
  background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: 10px;
  font-size: 13px; line-height: 1.7; color: var(--c-text);
}
.order-summary .os-label { flex: 0 0 auto; font-weight: 700; color: var(--c-primary); white-space: nowrap; }
.order-summary .os-items { flex: 1 1 100%; min-width: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 24px; }
.order-summary .os-items:empty::before { content: '—'; color: var(--c-text-soft); }
.order-summary .os-items .os-pair { white-space: nowrap; }
.order-summary .os-total { flex: 1 1 100%; min-width: 0; color: var(--c-text-soft); font-variant-numeric: tabular-nums; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 24px; }
.order-summary .os-total .os-stat { white-space: nowrap; }
.order-summary .os-qty { color: #2f6df6; font-weight: 600; font-variant-numeric: tabular-nums; }

/* 学术经理排行榜「活专家」统计值：蓝色加粗（周/月/年三榜通用） */
.active-expert-num { color: #2f6df6; font-weight: 600; font-variant-numeric: tabular-nums; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.tag-ok { background: #e6f7ef; color: var(--c-success); }
.tag-low { background: #fdf2e3; color: var(--c-warning); }
.tag-out { background: var(--c-danger-soft); color: var(--c-danger); }
.tag-cat { background: var(--c-primary-soft); color: var(--c-primary); }

/* 学术经理列表「下级（专家）」数量徽标 */
.sub-count { display: inline-block; min-width: 26px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; background: var(--c-primary-soft); color: var(--c-primary); text-align: center; }

/* ============ 分页 ============ */
.pagination { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.pagination .page-info { color: var(--c-text-soft); font-size: 13px; margin-right: auto; }
.page-btn {
  min-width: 34px; height: 34px; padding: 0 8px;
  border: 1px solid var(--c-border); background: var(--c-surface);
  border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--c-text);
}
.page-btn:hover:not(:disabled) { border-color: var(--c-primary); color: var(--c-primary); }
.page-btn.active { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.page-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.page-ellipsis { color: var(--c-text-soft); padding: 0 4px; user-select: none; }
.pagination select {
  height: 34px; padding: 0 10px;
  border: 1px solid var(--c-border); background: var(--c-surface);
  border-radius: 8px; font-size: 13px; color: var(--c-text);
  cursor: pointer;
}
.pagination select:hover { border-color: var(--c-primary); color: var(--c-primary); }

/* ============ 表单 / 编辑页 ============ */
.form-card { max-width: 720px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-size: 13px; color: var(--c-text-soft); font-weight: 500; }
.form-field label .req { color: var(--c-danger); margin-left: 2px; }
.form-field input, .form-field select, .form-field textarea {
  padding: 10px 12px; border: 1px solid var(--c-border); border-radius: 8px;
  font-size: 14px; outline: none; font-family: inherit; background: var(--c-surface); color: var(--c-text);
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--c-primary); }
.form-field .hint { font-size: 12px; color: var(--c-text-soft); }
/* 系统帐号 · 模块权限多选网格 */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 14px; padding: 4px 0; }
.perm-item { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--c-text); cursor: pointer; }
.perm-item input { width: auto; margin: 0; }
.form-error { color: var(--c-danger); font-size: 12px; }
.form-actions { display: flex; gap: 12px; margin-top: 26px; }

/* ============ 空状态 ============ */
.empty-state { text-align: center; padding: 50px 0; color: var(--c-text-soft); }
.empty-state .emoji { font-size: 44px; }

/* ============ Toast ============ */
.toast {
  position: fixed; top: 22px; left: 50%; transform: translateX(-50%);
  background: #1f2733; color: #fff; padding: 11px 22px; border-radius: 9px;
  font-size: 13px; z-index: 100; box-shadow: 0 8px 26px rgba(0,0,0,0.25);
  animation: toastIn 0.2s ease;
}
.toast.success { background: var(--c-success); }
.toast.error { background: var(--c-danger); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============ 遮罩（移动端侧边栏） ============ */
.sidebar-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 25;
}

/* ============ 响应式 ============ */
@media (max-width: 1180px) {
  .panel-grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 980px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid-2 { grid-template-columns: 1fr; }
  .panel-grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0,0,0,0.2); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .topbar-date { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .view-container { padding: 18px 14px; }
}
@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr; }
  .toolbar .search { min-width: 100%; }
  /* 达成情况统计卡：窄屏也至少保持 2 列（不降到 1 列），并收一下字号/内边距防数字挤破 */
  #mk-period-grid { grid-template-columns: repeat(2, 1fr); }
  #mk-period-grid .stat-card { padding: 14px; }
  #mk-period-grid .stat-value { font-size: 20px; }
  /* 专家统计（DP区域情况）统计卡：窄屏同样至少 2 列 */
  #mk-expert-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #mk-expert-grid .stat-card { padding: 14px; }
  #mk-expert-grid .stat-value { font-size: 20px; }
}

/* ============ 环形图图例 ============ */
.donut-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.donut-wrap > svg { flex-shrink: 0; }   /* 环图本身不被压缩 */
.legend {
  width: 100%; display: flex; flex-direction: column; gap: 8px; margin-top: 4px;
  max-height: 260px;            /* 人数多时图例列表在内部纵向滚动，面板不再被顶高（与柱状图等高协调） */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;           /* 给滚动条留空隙，避免遮住文字 */
}
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.legend-item .dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-label { color: var(--c-text-soft); min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }  /* 超长名字省略号，不撑宽图例 */
.legend-val { margin-left: auto; font-weight: 600; flex-shrink: 0; }
/* 图例纵向滚动条 */
.legend::-webkit-scrollbar { width: 8px; }
.legend::-webkit-scrollbar-thumb { background: #d6dbe5; border-radius: 4px; }
.legend::-webkit-scrollbar-thumb:hover { background: #b9c0cd; }
.legend::-webkit-scrollbar-track { background: transparent; }

/* ============ 状态横向条形 ============ */
.hbar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; font-size: 13px; }
.hbar-label { width: 56px; color: var(--c-text-soft); flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { flex: 1; height: 14px; background: var(--c-surface-2); border-radius: 8px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 8px; transition: width 0.3s ease; }
.hbar-val { min-width: 60px; max-width: 80px; text-align: right; font-weight: 600; flex-shrink: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ============ 弹窗（新增 / 编辑） ============ */
.modal-mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px 16px; overflow-y: auto;
}
.modal-card {
  width: 560px; max-width: 100%;
  background: var(--c-surface);
  border-radius: 16px; box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
  animation: modalIn 0.18s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: translateY(0); } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--c-border);
}
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none; border: none; font-size: 18px; cursor: pointer;
  color: var(--c-text-soft); width: 30px; height: 30px; border-radius: 8px;
}
.modal-close:hover { background: var(--c-surface-2); color: var(--c-text); }
.modal-body { padding: 22px; }
.modal-body .form-actions .btn { flex: 1; padding: 11px; }

/* ============ Excel 导入弹窗 ============ */
.import-tip { font-size: 13px; color: var(--c-text-soft); line-height: 1.7; margin-bottom: 14px; }
.import-tip b { color: var(--c-text); }
.import-actions { margin-bottom: 14px; }
.import-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 34px 16px; border: 2px dashed var(--c-border); border-radius: var(--radius);
  background: var(--c-surface-2); cursor: pointer; transition: all 0.15s ease; text-align: center;
}
.import-drop:hover, .import-drop.drag { border-color: var(--c-primary); background: var(--c-primary-soft); }
.import-drop-icon { font-size: 34px; }
.import-drop-text { font-weight: 600; color: var(--c-text); }
.import-drop-sub { font-size: 12px; color: var(--c-text-soft); }
.import-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.is-item {
  background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: 10px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.is-item span { font-size: 12px; color: var(--c-text-soft); }
.is-item b { font-size: 16px; font-weight: 700; }
.is-item.ok b { color: var(--c-success); }
.is-item.bad b { color: var(--c-danger); }
.is-item .ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-preview-title { font-size: 13px; font-weight: 600; margin: 6px 0 8px; color: var(--c-text-soft); }
.import-preview { margin-bottom: 14px; }
.import-skips { margin-bottom: 14px; }
.skip-list { list-style: none; max-height: 150px; overflow-y: auto; background: var(--c-danger-soft); border-radius: 8px; padding: 10px 14px; }
.skip-list li { font-size: 12.5px; color: var(--c-danger); padding: 3px 0; }
/* 导入-整表替换开关（高危操作，醒目提示） */
.import-replace { margin: 6px 0 14px; }
.checkbox-warn { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; line-height: 1.6; color: var(--c-danger); background: var(--c-danger-soft); border: 1px solid var(--c-danger-border, #f3c0c0); border-radius: 8px; padding: 10px 12px; cursor: pointer; }
.checkbox-warn input { margin-top: 2px; flex: 0 0 auto; }
.replace-tip { font-size: 12px; color: var(--c-text); opacity: 0.85; line-height: 1.6; margin-top: 4px; font-weight: normal; }
.replace-tip b { color: var(--c-danger); }
/* 大文件解析 / 导入中的反馈，避免界面像卡死 */
.import-parsing { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 46px 12px; color: var(--c-text-soft); }
.import-parsing p { font-size: 13.5px; margin: 0; text-align: center; }
.import-parsing b { color: var(--c-text); word-break: break-all; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--c-border); border-top-color: var(--c-primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 560px) {
  .import-summary { grid-template-columns: repeat(2, 1fr); }
}

/* ============ 目标管理模块 ============ */
.target-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.target-edit { display: flex; align-items: center; gap: 8px; }
.target-input {
  width: 170px; padding: 8px 10px; border: 1px solid var(--c-border); border-radius: 8px;
  font-size: 14px; color: var(--c-text); background: var(--c-surface); outline: none;
}
.target-input:focus { border-color: var(--c-primary); }
.target-unit { color: var(--c-text-soft); font-size: 13px; }

/* 公司目标设置表单 */
.target-section { margin-top: 20px; }
.target-section:first-of-type { margin-top: 18px; }
.target-section-title { font-size: 13px; font-weight: 700; color: var(--c-text-soft); margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px dashed var(--c-border); }
.target-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 18px; }
.target-field { display: flex; align-items: center; gap: 16px; }
.target-label { width: 56px; flex-shrink: 0; font-size: 14px; font-weight: 600; color: var(--c-text); }
.target-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 32px; }
.target-row .target-field { flex: 0 0 auto; }
.target-row .target-label { width: auto; min-width: 56px; }
.tnum-input {
  width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid var(--c-border); border-radius: 8px;
  font-size: 14px; color: var(--c-text); background: var(--c-surface); outline: none;
}
.tnum-input:focus { border-color: var(--c-primary); }
.target-input:read-only, .tnum-input:read-only { background: var(--c-surface-2); color: var(--c-text-soft); cursor: not-allowed; box-shadow: none; }
@media (max-width: 720px) {
  .target-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .target-field { gap: 10px; }
  .target-label { width: 44px; font-size: 13px; }
}

/* 进度条（实际 / 目标） */
.prog { display: flex; align-items: center; gap: 10px; }
.prog-bar {
  flex: 1; height: 14px; background: var(--c-surface-2); border: 1px solid var(--c-border);
  border-radius: 8px; position: relative; overflow: hidden;
}
.prog-bar::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: var(--fill, 0%);
  background: var(--c-primary); border-radius: 8px;
}
.prog-bar.prog-over::after { background: var(--c-success); }
.prog-pct { font-size: 12px; color: var(--c-text-soft); min-width: 40px; text-align: right; }
.stat-value.ok { color: var(--c-success); }
.stat-value.gap-pos { color: var(--c-success); }   /* 已超额达标 */
.stat-value.gap-neg { color: var(--c-danger); }    /* 距目标仍有缺口 */
/* 环比涨跌（涨红跌绿，中国惯例）：环比上月上升用红、下降用绿 */
.mom-up { color: var(--c-danger); }     /* 环比上升：红色 */
.mom-down { color: var(--c-success); }  /* 环比下降：绿色 */

/* 各周期完成进度网格 */
.period-grid { display: flex; flex-direction: column; gap: 10px; }
.period-row { display: flex; align-items: center; gap: 12px; }
.period-label { width: 52px; flex-shrink: 0; font-size: 13px; color: var(--c-text); font-weight: 600; }
.prog-wrap { flex: 1; min-width: 0; }
.period-num { font-size: 12px; color: var(--c-text-soft); white-space: nowrap; min-width: 168px; text-align: right; }

/* 学术经理目标表格 */
.target-table-wrap { overflow-x: auto; }
.target-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.target-table th, .target-table td { padding: 10px 12px; border-bottom: 1px solid var(--c-border); text-align: left; }
.target-table th { background: var(--c-surface-2); font-weight: 600; color: var(--c-text-soft); }
.target-table .tname { font-weight: 600; }
.tinput { width: 150px; padding: 7px 9px; border: 1px solid var(--c-border); border-radius: 8px; font-size: 13px; outline: none; }
.tinput:focus { border-color: var(--c-primary); }
.tnum { color: var(--c-text-soft); white-space: nowrap; }
.target-actions { margin-top: 12px; display: flex; justify-content: flex-end; }
#aca-pick { margin: 8px 0 4px; padding: 7px 10px; border: 1px solid var(--c-border); border-radius: 8px; font-size: 13px; background: var(--c-surface); color: var(--c-text); outline: none; }
#aca-pick:focus { border-color: var(--c-primary); }

/* 目标管理-公司：Excel 导入预览 */
.target-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.import-preview { background: #fafafa; border: 1px solid #eee; border-radius: 8px; margin: 10px 0; overflow: hidden; }
.co-prev-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border-bottom: 1px solid #eee; font-size: 13px; }
.co-prev-row:last-child { border-bottom: none; }
.co-prev-row span { color: #888; }
.co-prev-row b { color: #222; }
.import-warn { margin-top: 8px; color: #c0392b; font-size: 12px; padding: 6px 10px; background: #fff4f4; border: 1px solid #f3c9c9; border-radius: 6px; }

.import-tpl-row { display:flex; align-items:center; gap:10px; margin-top:12px; padding:8px 10px; background:#f5f9ff; border:1px dashed #a8c5ee; border-radius:8px; }
.btn.btn-tpl { background:#fff; border:1px solid #a8c5ee; color:#2563b3; }
.btn.btn-tpl:hover { background:#eaf3ff; }
.import-tpl-hint { font-size:12px; color:#5d7595; }

# 学术经理目标：左侧选人 + 右侧四套目标编辑器
.aca-layout { display:flex; gap:16px; align-items:flex-start; }
.aca-pick-list { width:200px; flex:0 0 200px; max-height:600px; overflow:auto; border:1px solid #eee; border-radius:8px; padding:6px; background:#fff; }
.aca-pick-item { padding:8px 10px; border-radius:6px; cursor:pointer; font-size:13px; color:#444; transition:background .15s; }
.aca-pick-item:hover { background:#f1f5fb; }
.aca-pick-item.active { background:#2563b3; color:#fff; font-weight:600; }
.aca-editor { flex:1; min-width:0; }

/* 学术经理目标：每位经理一行（年度 / 季度 / 月度 / 周度） */
.aca-tip { font-size: 12px; color: var(--c-text-soft); margin: 4px 0 10px; }
.aca-table-wrap { overflow-x: auto; border: 1px solid var(--c-border); border-radius: 10px; }
.aca-table { border-collapse: collapse; table-layout: fixed; width: 100%; min-width: 1180px; font-size: 13px; }
.aca-table th, .aca-table td { padding: 6px 3px; border-bottom: 1px solid var(--c-border); border-right: 1px solid var(--c-border); text-align: center; vertical-align: middle; }
.aca-table th { background: var(--c-surface-2); font-weight: 600; color: var(--c-text-soft); position: sticky; top: 0; z-index: 2; font-size: 12px; }
.aca-table .aca-name, .aca-name-h { text-align: left; width: 120px; min-width: 120px; max-width: 120px; position: sticky; left: 0; z-index: 1; background: var(--c-surface); font-weight: 600; }
.aca-name-h { background: var(--c-surface-2); z-index: 3; }
.aca-sub { display: block; font-size: 11px; color: var(--c-text-soft); font-weight: 400; margin-top: 2px; }
.aca-table td input { width: 100%; min-width: 0; box-sizing: border-box; padding: 6px 3px; border: 1px solid var(--c-border); border-radius: 6px; font-size: 12px; text-align: center; outline: none; }
.aca-table td input:focus { border-color: var(--c-primary); }
.aca-hint { color: var(--c-text-soft); font-size: 12px; margin-left: 12px; }

/* 学术营销 · 业绩统计：期间切换控件（年度/月度/周度） */
.mk-period-tabs { display: inline-flex; background: var(--c-surface-2, #eef1f6); border-radius: 8px; padding: 3px; gap: 2px; margin-bottom: 14px; }
.mk-period-btn { border: none; background: transparent; color: var(--c-text-soft, #6a737d); font-size: 13px; padding: 6px 18px; border-radius: 6px; cursor: pointer; transition: all .15s; }
.mk-period-btn:hover { color: var(--c-text, #24292f); }
.mk-period-btn.active { background: var(--c-surface, #fff); color: var(--c-primary, #2f6df6); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
/* 筛选栏与上方「昨日/周度/月度/年度」分段控件同款灰底胶囊，视觉统一；宽度由 JS 实测上方 tab 栏总宽后写入容器 style.width，下拉框 width:100% 填满 */
.mk-period-filter { display: block; box-sizing: border-box; margin-bottom: 14px; background: var(--c-surface-2, #eef1f6); border-radius: 8px; padding: 3px; }
.mk-period-filter select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  box-sizing: border-box;
  display: block;
  width: 100%;
  padding: 6px 24px 6px 12px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  text-align-last: center;
  background: var(--c-surface, #fff)
              url("data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%236a737d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>")
              no-repeat right 8px center / 10px 10px;
  color: var(--c-text, #24292f);
  cursor: pointer;
  transition: all .15s;
}
.mk-period-filter select:hover { box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.mk-period-filter select:focus { outline: none; box-shadow: 0 0 0 2px var(--c-primary, #2f6df6); }
