:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1f2329;
  --muted: #6b7280;
  --line: #e6e9ee;
  --primary: #2b6ce0;
  --primary-dark: #1f56bd;
  --primary-soft: #eaf1fe;
  --green: #12b76a;
  --green-soft: #e7f8f0;
  --amber: #f79009;
  --amber-soft: #fef4e6;
  --purple: #7a5af8;
  --purple-soft: #f0ecff;
  --red: #e5484d;
  --red-soft: #fdeced;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100vh; }

.loading {
  padding: 80px 20px;
  text-align: center;
  color: var(--muted);
}

/* ---------- 布局 ---------- */

.page {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px 16px 120px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
}

.topbar h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .who {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.back {
  border: 0;
  background: transparent;
  font-size: 18px;
  color: var(--text);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  line-height: 1;
}
.back:hover { background: #f1f3f6; }

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 22px 4px 10px;
  letter-spacing: .3px;
}

/* ---------- 卡片 ---------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.card.tight { padding: 12px; }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 9px 16px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: .15s;
  white-space: nowrap;
  font-family: inherit;
}

.btn:hover { background: #f7f8fa; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-danger { color: var(--red); border-color: #f3c2c3; background: #fff; }
.btn-danger:hover { background: var(--red-soft); }

.btn-ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }

.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- 徽章 ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-amber  { background: var(--amber-soft);  color: #b25e09; }
.badge-blue   { background: var(--primary-soft); color: var(--primary-dark); }
.badge-purple { background: var(--purple-soft); color: #5b3fd6; }
.badge-green  { background: var(--green-soft);  color: #0d8a51; }
.badge-gray   { background: #f1f3f6; color: var(--muted); }
.badge-red    { background: var(--red-soft); color: var(--red); }

/* ---------- 待办列表 ---------- */

.task {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  cursor: pointer;
  transition: .15s;
  border-left: 3px solid transparent;
}
.task:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(16,24,40,.10); }
.task.mine { border-left-color: var(--primary); }

.task-main { flex: 1; min-width: 0; }
.task-name {
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.task-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
}
.task-arrow { color: #c3c8d0; font-size: 18px; }

.empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
  font-size: 13.5px;
}
.empty .big { font-size: 36px; margin-bottom: 8px; opacity: .35; }

/* ---------- 标签页 ---------- */

.tabs {
  display: flex;
  gap: 4px;
  background: #eceff4;
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 16px;
}
.tab {
  flex: 1;
  text-align: center;
  padding: 8px 6px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border: 0;
  background: transparent;
  font-family: inherit;
  white-space: nowrap;
}
.tab.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(16, 24, 40, .10);
}
.tab .count {
  display: inline-block;
  min-width: 17px;
  padding: 0 5px;
  margin-left: 3px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  line-height: 17px;
}

/* ---------- 流程步骤条 ---------- */

.stepper {
  display: flex;
  align-items: flex-start;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 8px;
  margin-bottom: 14px;
  overflow-x: auto;
}
.step {
  flex: 1;
  min-width: 62px;
  text-align: center;
  position: relative;
  font-size: 11.5px;
  color: var(--muted);
}
.step .dot {
  width: 24px;
  height: 24px;
  line-height: 22px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: #fff;
  margin: 0 auto 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  position: relative;
  z-index: 1;
}
.step::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 0;
  right: 50%;
  height: 2px;
  background: var(--line);
}
.step::after {
  content: "";
  position: absolute;
  top: 12px;
  left: 50%;
  right: 0;
  height: 2px;
  background: var(--line);
}
.step:first-child::before,
.step:last-child::after { display: none; }
.step.done .dot { background: var(--green); border-color: var(--green); color: #fff; }
.step.done { color: #0d8a51; }
.step.done::before, .step.done::after { background: var(--green); }
.step.current .dot { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 0 0 4px rgba(43,108,224,.15); }
.step.current { color: var(--primary-dark); font-weight: 600; }
.step.current::before { background: var(--green); }
.step.current::after { background: var(--line); }
.step.current:first-child::before { background: transparent; }

/* ---------- 指标卡 ---------- */

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 16px;
  font-size: 13px;
}
.meta-grid .k { color: var(--muted); font-size: 12px; }
.meta-grid .v { font-weight: 500; margin-top: 1px; }

.item {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}
.item-head {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
}
.item-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.item-idx {
  width: 22px; height: 22px; line-height: 22px;
  border-radius: 6px; background: var(--primary-soft); color: var(--primary-dark);
  font-size: 12px; font-weight: 600; text-align: center; flex: none;
}
.item-title { font-weight: 600; font-size: 14.5px; flex: 1; min-width: 140px; }
.item-weight { font-size: 12px; color: var(--primary-dark); background: var(--primary-soft); padding: 1px 8px; border-radius: 999px; }

.item-body { padding: 12px 16px 14px; }
.standard {
  font-size: 13px;
  color: #4b5563;
  white-space: pre-wrap;
  line-height: 1.7;
  background: #f8f9fb;
  border-radius: 8px;
  padding: 10px 12px;
}

.answer-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}
@media (max-width: 640px) { .answer-row { grid-template-columns: 1fr; } }

.answer-block {
  margin-top: 12px;
  padding: 10px 12px;
  background: #f8f9fb;
  border-radius: 8px;
  font-size: 13px;
}
.answer-block .label { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
.answer-block .text { white-space: pre-wrap; }

/* ---------- 表单 ---------- */

.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 500;
}
.field .hint { font-size: 11.5px; color: #9aa1ab; margin-top: 4px; }

input[type="text"], input[type="number"], input[type="password"], select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43,108,224,.12);
}
textarea { resize: vertical; min-height: 60px; line-height: 1.6; }
input[readonly] { background: #f7f8fa; color: var(--muted); }

input.score {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  width: 90px;
}

.inline-input { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-input .unit { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

/* ---------- 底部操作栏 ---------- */

.actionbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.actionbar-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: center;
}
.actionbar .grow { flex: 1; }
.actionbar .hint { font-size: 12px; color: var(--muted); }

/* ---------- 结果卡 ---------- */

.result {
  background: linear-gradient(135deg, #2b6ce0 0%, #4b8ef7 100%);
  color: #fff;
  border-radius: 16px;
  padding: 22px;
  margin-bottom: 14px;
  box-shadow: 0 8px 28px rgba(43,108,224,.28);
}
.result .label { font-size: 13px; opacity: .85; }
.result .score { font-size: 44px; font-weight: 700; line-height: 1.15; letter-spacing: -1px; }
.result .score small { font-size: 15px; font-weight: 500; opacity: .85; margin-left: 4px; }
.result .row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; }
.result .grade {
  font-size: 18px; font-weight: 600;
  background: rgba(255,255,255,.2);
  padding: 5px 16px; border-radius: 999px;
  backdrop-filter: blur(4px);
}

/* ---------- 表格 ---------- */

.table-wrap { overflow-x: auto; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #f8f9fb; font-weight: 600; color: var(--muted); font-size: 12px; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
td.num, th.num { text-align: right; }
.rank-1 { color: #d4a017; font-weight: 700; }
.rank-2 { color: #8a9199; font-weight: 700; }
.rank-3 { color: #b0703c; font-weight: 700; }

/* ---------- 弹窗 ---------- */

.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fade .15s ease;
}
.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 460px;
  max-height: 86vh;
  overflow: auto;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal.modal-wide { max-width: 880px; }
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

.modal-table-wrap {
  max-height: 46vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.modal-table-wrap table { font-size: 12.5px; }
.modal-table-wrap thead th { position: sticky; top: 0; z-index: 1; }
.modal-table-wrap td { white-space: nowrap; }
.group-row td {
  background: #f8f9fb;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
}
.row-muted { color: var(--muted); }
.cand-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0;
}
.cand-toolbar .count { margin-left: auto; font-size: 12.5px; color: var(--muted); }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 提示 ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%) translateY(20px);
  background: #1f2329;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: .22s;
  z-index: 200;
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #b42318; }
.toast.ok { background: #0d8a51; }

/* ---------- 登录 ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 10%, #dfeafe 0%, transparent 42%),
    radial-gradient(circle at 85% 85%, #e6f6ee 0%, transparent 42%),
    var(--bg);
}
.login-card {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(16,24,40,.12);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
}
.login-logo {
  width: 50px; height: 50px;
  border-radius: 14px;
  background: linear-gradient(135deg, #2b6ce0, #4b8ef7);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
  margin-bottom: 16px;
}
.login-card h2 { margin: 0 0 4px; font-size: 19px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }

.user-pick {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 300px; overflow-y: auto;
  margin-bottom: 16px;
}
.user-pick .u {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: .15s;
}
.user-pick .u:hover { border-color: var(--primary); background: var(--primary-soft); }
.user-pick .u.sel { border-color: var(--primary); background: var(--primary-soft); }
.user-pick .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: #eaf1fe; color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px; flex: none;
}
.user-pick .u .n { font-weight: 500; }
.user-pick .u .p { font-size: 11.5px; color: var(--muted); }

/* ---------- 导入预览 ---------- */

.dropzone {
  border: 2px dashed #cfd6e0;
  border-radius: var(--radius);
  padding: 34px 16px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: .15s;
  background: #fbfcfd;
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }
.dropzone .icon { font-size: 30px; margin-bottom: 8px; opacity: .55; }

.preview-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 10px;
  background: #fff;
}
.preview-item .pt { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 640px) { .preview-grid { grid-template-columns: 1fr; } }
.preview-grid .full { grid-column: 1 / -1; }

/* ---------- 提示条 ---------- */

.notice {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 12px;
  line-height: 1.6;
}
.notice-amber { background: var(--amber-soft); color: #8a4b06; }
.notice-red { background: var(--red-soft); color: #a12b30; }
.notice-blue { background: var(--primary-soft); color: var(--primary-dark); }
.notice-green { background: var(--green-soft); color: #0d8a51; }

/* ---------- 日志 ---------- */

.log-list { font-size: 12.5px; color: var(--muted); }
.log-list .l { padding: 7px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 8px; }
.log-list .l:last-child { border-bottom: 0; }
.log-list .t { color: #9aa1ab; font-size: 11.5px; white-space: nowrap; }

/* ---------- 响应式 ---------- */

@media (max-width: 520px) {
  .page { padding: 12px 12px 130px; }
  .card { padding: 14px; }
  .result .score { font-size: 38px; }
  .meta-grid { grid-template-columns: 1fr 1fr; gap: 8px 12px; }
}

@media (max-width: 640px) {
  .table-wrap { position: relative; }
  .table-wrap table { font-size: 12.5px; }
  .table-wrap th, .table-wrap td { padding: 9px 7px; }
  .table-wrap td .btn { padding: 4px 7px; font-size: 11.5px; border-radius: 6px; }
  .table-wrap td .btn + .btn { margin-left: 3px; }
  .col-station { display: none; }
  .scroll-hint {
    display: block;
    font-size: 11.5px;
    color: #9aa1ab;
    text-align: right;
    margin: -4px 2px 6px;
  }
}
@media (min-width: 641px) { .scroll-hint { display: none; } }

/* ---------- 打印（导出 PDF） ---------- */

/* ---------- 评分进度条 ---------- */

.tally-card {
  background: #fff;
  border-radius: var(--radius, 14px);
  box-shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.06);
  padding: 14px 16px;
  margin-bottom: 14px;
}
.tally-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  justify-content: space-between;
}
.tally-item { display: flex; flex-direction: column; gap: 4px; }
.tally-item .k { font-size: 12px; color: var(--muted); }
.tally-item .v { font-size: 13px; color: var(--muted); }
.tally-item .v b { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1; margin-right: 3px; }
.tally-item .v small { font-size: 12px; }
.tally-bar {
  height: 6px;
  background: #eef1f6;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 12px;
}
.tally-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #2b6ce0, #4b8ef7);
  transition: width .18s ease;
}
.tally-refs {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line, #e5e7eb);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
}
.tally-refs .ref { display: flex; align-items: baseline; gap: 6px; }
.tally-refs .ref .v { display: inline-flex; align-items: baseline; gap: 5px; }
.tally-refs .k { font-size: 12.5px; color: var(--muted); }
.tally-refs b { font-size: 17px; font-weight: 700; color: #2b6ce0; }
.tally-refs small { font-size: 11.5px; color: #9aa1ab; }

#signature-pad {
  display: block;
  width: 100%;
  height: 160px;
  background: #fff;
  border: 1px dashed #c9d3e3;
  border-radius: 10px;
  touch-action: none;
  cursor: crosshair;
}
.sig-preview {
  display: block;
  max-width: 260px;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 10px;
}

.item-editable {
  border: 1px solid #bcd3f7;
  box-shadow: 0 0 0 3px rgba(43, 108, 224, .07);
}
.item-editable .item-head { background: #f3f7fe; }

.mini-bar {
  height: 4px;
  background: #eef1f6;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
  max-width: 320px;
}
.mini-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2b6ce0, #4b8ef7);
}

.req {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  color: #d93a3a;
  background: #fdecec;
  border-radius: 4px;
  padding: 0 5px;
  margin-left: 2px;
  vertical-align: 1px;
}
.muted-sm { font-size: 12px; color: var(--muted); }

@media print {
  .topbar, .actionbar, .tabs, .btn, .back, .no-print { display: none !important; }
  body { background: #fff; }
  .page { padding: 0; max-width: none; }
  .card, .item, .stepper, .result { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .result { background: #fff !important; color: #000 !important; border: 2px solid #333; }
  .result .grade { background: #eee !important; color: #000 !important; }
}
