:root {
  --primary: #1668DC;
  --primary-deep: #0F4FA8;
  --primary-light: #EEF4FB;
  --accent: #38B6E8;
  --text: #1F2D3D;
  --text-2: #5E6D82;
  --border: #E3EAF3;
  --bg: #F0F4FA;
  --success: #2BA471;
  --danger: #D83931;
  --warn: #E6890D;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  display: flex;
}

/* ========== 左侧导航 ========== */
.sidebar {
  width: 200px; flex: none; background: var(--primary-deep); color: #fff;
  display: flex; flex-direction: column; position: sticky; top: 0;
  height: 100vh; z-index: 20;
}
.sidebar .brand {
  padding: 20px 18px; font-size: 16px; font-weight: bold; letter-spacing: 1px;
  border-bottom: 1px solid rgba(255,255,255,.14); line-height: 1.5;
}
.menu { flex: 1; padding: 12px 10px; }
.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 8px; margin-bottom: 4px;
  color: rgba(255,255,255,.78); cursor: pointer; font-size: 14px;
}
.menu-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.menu-item.active { background: var(--primary); color: #fff; }
.menu-item .ico {
  width: 20px; text-align: center; font-weight: bold; font-size: 13px;
  opacity: .9;
}
.side-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.14); font-size: 13px; }
.side-foot .role-badge {
  display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 5px;
  background: rgba(255,255,255,.16); color: #fff; margin-left: 6px;
}
.side-foot button {
  margin-top: 10px; width: 100%; padding: 7px 0; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.35); background: transparent; color: #fff; cursor: pointer;
}
.side-foot button:hover { background: rgba(255,255,255,.1); }

/* ========== 内容区 ========== */
.main { flex: 1; min-width: 0; padding: 20px 24px; overflow-x: hidden; }
.page { display: none; }
.page.active { display: block; }
.page-title { font-size: 17px; font-weight: bold; margin-bottom: 16px; color: var(--primary-deep); }

.card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 18px 20px; box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.card h3 { font-size: 14px; margin-bottom: 12px; color: var(--text); }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.chart { width: 100%; height: 280px; }
.chart-tall { height: 340px; }

/* 指标卡 */
.stat-tile {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 18px 20px; box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.stat-tile .label { color: var(--text-2); font-size: 13px; margin-bottom: 6px; }
.stat-tile .value { font-size: 26px; font-weight: bold; color: var(--primary-deep); }
.stat-tile .value small { font-size: 13px; color: var(--text-2); font-weight: normal; }
.stat-tile .sub { font-size: 12px; color: var(--text-2); margin-top: 6px; }

/* 表单 */
.form-item { margin-bottom: 12px; }
.form-item label { display: block; margin-bottom: 4px; color: var(--text-2); font-size: 13px; }
input, select, textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; outline: none; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,104,220,.15);
}
.form-inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--text-2); line-height: 1.7; }

/* 按钮 */
.btn {
  display: inline-block; padding: 8px 20px; border-radius: 8px; border: 1px solid transparent;
  font-size: 14px; cursor: pointer; background: var(--primary); color: #fff; font-family: inherit;
  transition: background .15s;
}
.btn:hover { background: var(--primary-deep); }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: #A9C4EC; cursor: not-allowed; transform: none; }
.btn-plain { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn-plain:hover { background: var(--primary-light); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #B72D26; }
.btn-sm { padding: 4px 12px; font-size: 13px; border-radius: 5px; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: var(--primary-light); color: var(--primary-deep); font-weight: bold; }
tbody tr:hover { background: #F7FAFF; }

.badge { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 5px; }
.badge-high { background: #E8F5EE; color: var(--success); }
.badge-mid { background: var(--primary-light); color: var(--primary); }
.badge-warn { background: #FDF2E7; color: var(--warn); }
.badge-low { background: #FBECEB; color: var(--danger); }
.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-ok { background: #E8F5EE; color: var(--success); }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; }
.pager span { color: var(--text-2); font-size: 13px; }

/* 弹窗 */
.modal-mask {
  display: none; position: fixed; inset: 0; background: rgba(31,45,61,.45);
  z-index: 100; align-items: center; justify-content: center;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 10px; width: 520px; max-width: 92vw;
  max-height: 86vh; overflow-y: auto; padding: 24px;
}
.modal h3 { margin-bottom: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

#toast {
  display: none; position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 10px 24px; border-radius: 8px;
  z-index: 200; font-size: 14px;
}
#toast.err { background: var(--danger); }

.empty { text-align: center; padding: 40px 0; color: var(--text-2); }

/* 分群体系页 */
.rule-table td:first-child { font-weight: bold; color: var(--primary-deep); }
.formula {
  background: var(--primary-light); border: 1px dashed var(--primary); border-radius: 8px;
  padding: 14px 18px; font-size: 14px; line-height: 2; color: var(--primary-deep);
}

body.president .analyst-only { display: none; }

@media (max-width: 900px) {
  .grid-4, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; flex-direction: row; align-items: center; }
  .sidebar .brand { border: none; padding: 12px 14px; }
  .menu { display: flex; padding: 8px; overflow-x: auto; }
  .menu-item { white-space: nowrap; margin-bottom: 0; }
  .side-foot { display: none; }
}
