:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --ink: #1f2733;
  --ink-soft: #5b6776;
  --line: #e6eaf1;
  --primary: #2f6fed;
  --primary-soft: #eaf1ff;
  --good: #e8473f;   /* 涨/高分 红 */
  --bad: #1aa260;    /* 跌/低分 绿 */
  --warn: #e6a23c;
  --shadow: 0 6px 20px rgba(31, 39, 51, .06);
  --radius: 14px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
}
h1, h2, h3 { margin: 0; }

.topbar {
  background: linear-gradient(120deg, #2f6fed, #5b8def);
  color: #fff;
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 12px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(255,255,255,.18); display: grid; place-items: center;
  font-size: 20px; font-weight: 700;
}
.brand h1 { font-size: 18px; font-weight: 700; }
.brand-sub { margin: 0; font-size: 12px; opacity: .85; }
/* 右上角导航 */
.topnav { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.topnav a { color: #fff; text-decoration: none; font-size: 16px; font-weight: 500; opacity: .9; white-space: nowrap; transition: opacity .15s; }
.topnav a:hover { opacity: 1; text-decoration: underline; }
.topnav a.active { font-weight: 800; opacity: 1; text-decoration: underline; text-underline-offset: 4px; }
.tabs { display: flex; gap: 6px; background: rgba(255,255,255,.15); padding: 4px; border-radius: 10px; }
.tab {
  border: 0; background: transparent; color: #fff; cursor: pointer;
  padding: 8px 16px; border-radius: 8px; font-size: 14px; font-weight: 600;
}
.tab.active { background: #fff; color: var(--primary); }

.container { max-width: 1080px; margin: 0 auto; padding: 20px 18px 60px; }
.view { display: none; }
.view.active { display: block; }

.card {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); margin-bottom: 18px; border: 1px solid var(--line);
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

.form-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.form-row label { width: 84px; flex: none; color: var(--ink-soft); font-size: 13px; }
.form-row input {
  flex: 1; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  font-size: 14px; background: #fbfcfe; color: var(--ink);
}
.form-row input:focus { outline: none; border-color: var(--primary); background: #fff; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  border: 1px solid var(--line); background: #fbfcfe; padding: 7px 14px;
  border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--ink-soft);
}
.seg button.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

.hint {
  margin-top: 6px; padding: 9px 11px; border-radius: 9px;
  background: #fff5e6; color: #a05a00; font-size: 13px; border: 1px solid #ffe2b3;
}

.total-card { display: flex; flex-direction: column; }
.total-score { display: flex; align-items: baseline; gap: 8px; margin: 4px 0 12px; }
.total-score #totalScore { font-size: 52px; font-weight: 800; color: var(--good); line-height: 1; }
.total-max { font-size: 18px; color: var(--ink-soft); }
.total-breakdown { font-size: 13px; color: var(--ink-soft); flex: 1; }
.total-breakdown .bd-row { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.total-breakdown .bd-row span:last-child { font-weight: 600; color: var(--ink); }
.total-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 9px 16px; border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #2a62d4; color: #fff; }

/* 维度卡片 */
.dim-card { margin-bottom: 18px; }
.dim-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.dim-head .dim-name { font-size: 15px; font-weight: 700; }
.dim-head .dim-score { font-size: 14px; color: var(--good); font-weight: 700; }
.level {
  display: grid; grid-template-columns: 28px 1fr 96px; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px;
  cursor: pointer; transition: .15s; background: #fbfcfe;
}
.level:hover { border-color: #c7d6f7; }
.level.sel { border-color: var(--primary); background: var(--primary-soft); }
.level .lv-no {
  width: 28px; height: 28px; border-radius: 50%; background: #eef1f6; color: var(--ink-soft);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.level.sel .lv-no { background: var(--primary); color: #fff; }
.level .lv-desc { font-size: 13px; color: var(--ink); }
.level .lv-range { text-align: right; font-size: 12px; color: var(--ink-soft); }
.level .slider-row { grid-column: 1 / -1; margin-top: 6px; display: none; align-items: center; gap: 10px; }
.level.sel .slider-row { display: flex; }
.slider-row input[type=range] { flex: 1; accent-color: var(--primary); }
.slider-row .sv { width: 46px; text-align: center; font-weight: 700; color: var(--good); }

.adj-box { display: flex; flex-direction: column; gap: 12px; }
.adj-item { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.adj-item .adj-label { font-weight: 600; min-width: 64px; }
.adj-item .adj-note { font-size: 12px; color: var(--ink-soft); width: 100%; }
.adj-item input[type=number] {
  width: 90px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px;
}
.adj-item .adj-val { font-weight: 700; color: var(--good); }

/* 记录表 */
.records-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar-actions input[type=search] { padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; }
.rec-count { color: var(--ink-soft); font-size: 13px; margin-left: 4px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--ink-soft); font-weight: 600; background: #fafbfe; }
tbody tr:hover { background: #f7f9fd; }
td .op { color: var(--primary); cursor: pointer; margin-right: 10px; }
td .op.del { color: var(--bad); }
.empty { text-align: center; color: var(--ink-soft); padding: 30px; }

/* 弹窗 */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; }
.modal-mask { position: absolute; inset: 0; background: rgba(15,22,35,.45); }
.modal-panel {
  position: relative; background: #fff; border-radius: 14px; width: min(720px, 92vw);
  max-height: 88vh; overflow: auto; box-shadow: var(--shadow); padding: 18px 20px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-close { border: 0; background: #f0f2f6; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 18px; }
.detail-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.detail-row span:last-child { font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: #1f2733; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 80; font-size: 13px;
  box-shadow: var(--shadow);
}

/* 打印 */
@media print {
  .topbar, .tabs, .total-actions, .toolbar-actions, .empty { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .view { display: block !important; }
}

/* ===== 打分页：模板选择条 ===== */
.tpl-select-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.tpl-select-bar label { font-weight: 600; color: var(--ink-soft); }
.tpl-select-bar select {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; min-width: 220px;
}
.tpl-select-bar .tpl-max { color: var(--ink-soft); font-size: 13px; }
.tpl-select-bar .tpl-max b { color: var(--good); }

/* ===== 打分页：维度卡片（滑块 + 档位参考） ===== */
.dim-max-badge { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.dim-max-badge b { color: var(--good); }
.score-input-row { display: flex; align-items: center; gap: 12px; margin: 8px 0 10px; }
.score-input-row input[type=range] { flex: 1; accent-color: var(--primary); }
.score-input-row .num {
  width: 92px; padding: 8px; border: 1px solid var(--line); border-radius: 9px;
  text-align: center; font-weight: 800; font-size: 16px; color: var(--good); background: #fbfcfe;
}
.score-input-row .num:focus { outline: none; border-color: var(--primary); }
.level-ref { border-top: 1px dashed var(--line); padding-top: 8px; }
.lv-row { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; font-size: 13px; }
.lv-row .lv-idx {
  width: 22px; height: 22px; border-radius: 50%; background: #eef1f6; color: var(--ink-soft);
  display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; margin-top: 1px;
}
.lv-row .lv-txt { flex: 1; color: var(--ink); }
.lv-row .lv-apply {
  border: 1px solid var(--line); background: #fbfcfe; border-radius: 7px; padding: 4px 10px;
  cursor: pointer; font-size: 12px; color: var(--primary); flex: none; white-space: nowrap;
}
.lv-row .lv-apply:hover { border-color: var(--primary); }
.lv-row .lv-apply.used { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ===== 管理页：模板卡片 / 编辑器 ===== */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tpl-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fff; box-shadow: var(--shadow); }
.tpl-card h3 { font-size: 15px; margin-bottom: 6px; }
.tpl-card .tpl-meta { font-size: 12px; color: var(--ink-soft); margin-bottom: 12px; line-height: 1.5; }
.tpl-card .tpl-actions { display: flex; gap: 8px; }
.top-actions { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.editor-card { margin-top: 18px; }
.editor-row { display: grid; grid-template-columns: 120px 1fr 96px; gap: 12px; align-items: center; margin-bottom: 12px; }
.editor-row label { font-weight: 600; }
.editor-row input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.editor-row .er-max { text-align: center; font-weight: 800; color: var(--good); }
.editor-head { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.editor-head input.name { flex: 1; min-width: 200px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 15px; font-weight: 600; }
.editor-emp { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.editor-emp .emp-field { display: flex; flex-direction: column; gap: 5px; min-width: 200px; flex: 1; }
.editor-emp .emp-field label { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.editor-emp .emp-field input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.editor-emp .emp-field input:focus { outline: none; border-color: var(--primary); }
.linkback { color: var(--primary); text-decoration: none; font-size: 13px; }
.linkback:hover { text-decoration: underline; }

/* 管理页：维度编辑器（项目/配分/评定内容） */
.dim-editor { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 14px; background: #fff; }
.dim-editor-head { display: flex; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-bottom: 10px; }
.dim-name-wrap { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 200px; }
.dim-name-wrap label, .dim-max-wrap label { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.dim-name-input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-weight: 600; }
.dim-name-input:focus { outline: none; border-color: var(--primary); background: #fff; }
.dim-max-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dim-max-input { width: 90px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-weight: 700; text-align: center; color: var(--good); }
.dim-max-input:focus { outline: none; border-color: var(--primary); }
.dim-max-wrap .er-max { font-size: 12px; color: var(--ink-soft); }
.btn-del { border-color: #f3c9c6; color: var(--bad); }
.btn-del:hover { border-color: var(--bad); color: var(--bad); }
.dim-desc-list { display: flex; flex-direction: column; gap: 8px; }
.dim-desc-item { display: flex; align-items: flex-start; gap: 8px; }
.dim-desc-item .lv-badge {
  width: 24px; height: 24px; border-radius: 50%; background: #eef1f6; color: var(--ink-soft);
  display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; margin-top: 4px;
}
.dim-desc-col { flex: 1; min-width: 220px; }
.dim-hint-col { display: flex; flex-direction: column; gap: 4px; flex: none; }
.dim-desc-input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
  font-family: inherit; color: var(--ink); resize: vertical; line-height: 1.5;
}
.dim-desc-input:focus { outline: none; border-color: var(--primary); }
.dim-hint-input {
  width: 110px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
  text-align: center; font-weight: 700; color: var(--good);
}
.dim-hint-input:focus { outline: none; border-color: var(--primary); }
.dim-hint-col .er-max { font-size: 12px; color: var(--ink-soft); text-align: center; }

/* ===== 打分页：顶部信息栏 ===== */
.score-header { padding: 16px 18px; }
.score-header-row { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.score-header-row.second { margin-top: 14px; }
.score-header .field { display: flex; flex-direction: column; gap: 5px; }
.score-header .field label { font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.score-header .field input,
.score-header .field select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; min-width: 120px;
}
.score-header .field input:focus,
.score-header .field select:focus { outline: none; border-color: var(--primary); }
.score-header .field input[readonly] { background: #f1f3f7; color: var(--ink-soft); cursor: default; border-style: dashed; }
.score-header .std-text { font-size: 14px; color: var(--ink); padding: 8px 0; }
.score-header .std-text b { color: var(--good); font-size: 16px; }

/* ===== 打分页：考核表 ===== */
.score-table-wrap { padding: 0; overflow-x: auto; }
.score-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.score-table th {
  background: #f4f7fc; color: var(--ink); font-weight: 700; padding: 12px 10px;
  border: 1px solid var(--line); text-align: center;
}
.score-table td {
  border: 1px solid var(--line); padding: 10px; vertical-align: top;
}
.score-table .col-project { width: 130px; }
.score-table .col-content { width: auto; }
.score-table .col-weight { width: 90px; text-align: center; }
.score-table .col-input { width: 110px; text-align: center; }
.score-table .cell-project { text-align: center; background: #fafbfe; }
.score-table .cell-project .dim-name { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.comment-box { width: 100%; min-height: 90px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; font-family: inherit; color: var(--ink); resize: vertical; }
.comment-box:focus { outline: none; border-color: var(--primary); }
.score-table .cell-content { display: flex; align-items: flex-start; gap: 8px; line-height: 1.5; }
.score-table .cell-content .lv-no {
  width: 22px; height: 22px; border-radius: 50%; background: #eef1f6; color: var(--ink-soft);
  display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; margin-top: 1px;
}
.score-table .cell-weight { text-align: center; color: var(--ink-soft); font-weight: 600; }
.score-table .cell-input { background: #fafbfe; }
.score-table .score-num {
  width: 80px; padding: 8px; border: 1px solid var(--line); border-radius: 8px;
  text-align: center; font-weight: 800; font-size: 16px; color: var(--good); background: #fff;
}
.score-table .score-num:focus { outline: none; border-color: var(--primary); }
.score-table .score-big .score-num { width: 90px; font-size: 20px; padding: 10px; }

/* ===== 打分页：底部汇总 ===== */
.score-footer { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.score-footer .total-score { margin: 0; }
.score-footer .total-actions { margin: 0; margin-left: auto; }

@media print {
  .score-header .field select,
  .score-footer .total-actions { display: none !important; }
  .score-table .score-num { border: none; background: transparent; }
}

@media (max-width: 760px) {
  .score-table .col-input,
  .score-table .cell-input { display: none; }
  .score-table .cell-project .dim-input { display: block; margin-top: 8px; }
}

/* ===== 企业微信登录态（右上角） ===== */
.auth-area { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.auth-user { color: #fff; font-size: 14px; font-weight: 600; white-space: nowrap; }
.auth-off { color: #fff; opacity: .6; font-size: 13px; }
.auth-btn {
  border: 1px solid rgba(255,255,255,.7); background: rgba(255,255,255,.12);
  color: #fff; padding: 6px 14px; border-radius: 8px; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.auth-btn:hover { background: rgba(255,255,255,.22); border-color: #fff; }
.auth-btn:disabled { opacity: .6; cursor: default; }
.auth-login { background: #fff; color: var(--primary); font-weight: 700; border-color: #fff; }
.auth-login:hover { background: #eef3ff; }

/* ===== 企微设置页 ===== */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-top: 8px; }
.fld { display: flex; flex-direction: column; gap: 6px; }
.fld > span { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.fld input {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; font-family: inherit;
}
.fld input:focus { outline: none; border-color: var(--primary); }
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.save-msg { font-size: 13px; }
.save-msg.ok { color: var(--bad); font-weight: 600; }
.save-msg.err { color: #c0392b; font-weight: 600; }
.kv { display: flex; flex-direction: column; gap: 10px; }
.kv > div { display: flex; gap: 12px; align-items: baseline; }
.kv > div > span { width: 96px; color: var(--ink-soft); font-size: 13px; flex: none; }
.kv code { flex: 1; background: #f4f6fb; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; word-break: break-all; color: var(--ink); }
.steps { margin: 8px 0 0; padding-left: 20px; line-height: 1.9; color: var(--ink); }
.steps code { background: #f4f6fb; padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.hint.warn { color: #b06a00; background: #fff7e8; border: 1px solid #ffe2b0; }

/* ===== 打分页：登录门禁遮罩 ===== */
.login-gate {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, .55); backdrop-filter: blur(2px);
  padding: 20px;
}
.login-gate[hidden] { display: none !important; }
.login-gate-box {
  background: #fff; border-radius: 16px; padding: 34px 38px; max-width: 400px; width: 100%;
  text-align: center; box-shadow: 0 24px 70px rgba(0, 0, 0, .3);
}
.gate-icon { font-size: 44px; line-height: 1; }
.gate-title { margin: 12px 0 8px; font-size: 21px; color: #1f2d3d; }
.gate-desc { margin: 0 0 20px; font-size: 14px; color: #667; line-height: 1.7; }
.gate-hint { margin: 16px 0 0; font-size: 12px; color: #99a; }
.gate-hint a { color: var(--primary); }

@media print {
  .login-gate { display: none !important; }
}
