:root {
  --bg: #eef2f8;
  --card: #ffffff;
  --ink: #1a2333;
  --ink-2: #5b6779;
  --ink-3: #8f9bb0;
  --line: #dfe5ee;
  --brand: #2f5bd7;
  --brand-2: #4a7cf0;
  --ok: #0f9d6e;
  --warn: #e8912d;
  --bad: #dc4a4a;
  --radius: 14px;
  --shadow: 0 2px 14px rgba(30, 50, 90, .07);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

body::before {
  content: ""; position: fixed; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, #2f5bd7, #4a7cf0 55%, #6f9bf5);
  z-index: 99;
}

.wrap { max-width: 880px; margin: 0 auto; padding: 0 16px 48px; }
.wrap-narrow { max-width: 520px; margin: 0 auto; padding: 0 16px 48px; }

/* ---------- 页头 ---------- */
.hero { text-align: center; padding: 30px 0 22px; }
.hero h1 { margin: 0; font-size: 26px; font-weight: 600; letter-spacing: .5px; }
.hero p { margin: 8px 0 0; color: var(--ink-3); font-size: 15px; }
.hero .meta { margin-top: 14px; font-size: 13px; color: var(--ink-3); }
.hero .meta span { margin: 0 6px; }
.hero .meta b { color: var(--brand); font-weight: 600; }

.topbar {
  max-width: 1180px; margin: 0 auto; padding: 22px 16px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar .logo { font-size: 17px; font-weight: 600; letter-spacing: .3px; }
.topbar .logo small { display: block; font-size: 12px; color: var(--ink-3); font-weight: 400; }
.topbar nav a {
  color: var(--ink-2); text-decoration: none; font-size: 14px; margin-left: 18px;
}
.topbar nav a:hover { color: var(--brand); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 26px 24px; margin-bottom: 18px;
}
.card-title {
  font-size: 15px; font-weight: 600; margin: 0 0 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-title small { font-weight: 400; font-size: 13px; color: var(--ink-3); }

/* ---------- 扫码入口 ---------- */
.qr-card { text-align: center; padding: 34px 24px 30px; }
.qr-box {
  width: 260px; height: 260px; margin: 0 auto 22px;
  border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  background: #fff; display: flex; align-items: center; justify-content: center;
}
.qr-box canvas, .qr-box img { width: 100%; height: 100%; display: block; }
.qr-lead { font-size: 20px; font-weight: 600; color: var(--brand); margin: 0 0 6px; }
.qr-stat { font-size: 14px; color: var(--ink-3); margin: 0 0 18px; }
.qr-tip { border-top: 1px solid var(--line); padding-top: 16px; font-size: 13px; color: var(--ink-3); }
.qr-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 11px 22px; border-radius: 10px; font-size: 15px; font-weight: 500;
  cursor: pointer; text-decoration: none; transition: .15s; font-family: inherit;
}
.btn:hover { border-color: #c6d0e0; background: #fafbfd; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-lg { padding: 15px 30px; font-size: 16px; border-radius: 12px; }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 8px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--brand); }
.btn-ghost:hover { background: #eef3fe; border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 7px; }
.field label .req { color: var(--bad); margin-left: 2px; }
.field .hint { font-size: 12px; color: var(--ink-3); font-weight: 400; margin-top: 4px; }
input[type=text], input[type=password], input[type=date], select, textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 15px; font-family: inherit;
  background: #f7f9fc; color: var(--ink); transition: .15s; -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-2); background: #fff;
  box-shadow: 0 0 0 3px rgba(74, 124, 240, .13);
}
input[readonly] { background: #f1f3f7; color: var(--ink-2); }
select {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%238f9bb0' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 34px;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.7; }

.alert { padding: 11px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; }
.alert-err { background: #fdecec; color: #b03030; border: 1px solid #f6cfcf; }
.alert-ok { background: #e8f7f1; color: #0b7a56; border: 1px solid #c3ebdb; }

/* ---------- 问卷 ---------- */
.survey-head { position: sticky; top: 0; z-index: 20; background: var(--bg); padding-top: 22px; }
.backlink { font-size: 14px; color: var(--ink-2); text-decoration: none; }
.backlink:hover { color: var(--brand); }

.q-progress {
  display: flex; gap: 16px; align-items: center; font-size: 13px;
  color: var(--ink-3); padding: 10px 4px 14px; flex-wrap: wrap;
}
.q-progress .tag {
  background: #e8eef9; color: #3a5ba8; border-radius: 20px;
  padding: 3px 12px; font-weight: 500; font-size: 12px;
}
.q-progress .tag.warn { background: #fdf0dc; color: #96651a; }
.q-progress .tag.bad { background: #fdecec; color: #b03030; }

.sec-card { margin-bottom: 14px; }
.sec-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 18px;
  font-size: 16px; font-weight: 600;
}
.sec-head .no {
  background: var(--brand); color: #fff; width: 24px; height: 24px;
  border-radius: 7px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex: none;
}
.sec-head .cnt { margin-left: auto; font-size: 12px; color: var(--ink-3); font-weight: 400; }

.q-item { padding: 14px 0; border-top: 1px dashed var(--line); }
.q-item:first-of-type { border-top: none; }
.q-title { font-size: 14.5px; margin-bottom: 11px; display: flex; gap: 8px; }
.q-title .no { color: var(--ink-3); font-size: 13px; flex: none; font-variant-numeric: tabular-nums; }
.opts { display: flex; gap: 8px; flex-wrap: wrap; }
.opt {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: #fff; font-size: 16px; font-weight: 500; cursor: pointer;
  transition: .12s; font-family: inherit; color: var(--ink-2);
}
.opt:hover { border-color: var(--brand-2); color: var(--brand); }
.opt.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

.sticky-bar {
  position: sticky; bottom: 0; background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px); border-top: 1px solid var(--line);
  padding: 14px 0; margin-top: 8px; z-index: 30;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.sticky-bar .grow { flex: 1; min-width: 180px; }
.pbar { height: 5px; background: #e8ecf3; border-radius: 3px; overflow: hidden; margin-top: 7px; }
.pbar i { display: block; height: 100%; background: var(--brand); border-radius: 3px; transition: width .25s; }

/* ---------- 表格 ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th, table.tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
table.tbl th { font-size: 13px; color: var(--ink-2); font-weight: 500; background: #f7f9fc; white-space: nowrap; }
table.tbl td.num { font-variant-numeric: tabular-nums; }
table.tbl tbody tr:hover { background: #fafbfd; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-ok { background: #e8f7f1; color: #0b7a56; }
.badge-warn { background: #fdf0dc; color: #96651a; }
.badge-bad { background: #fdecec; color: #b03030; }
.badge-off { background: #eef0f4; color: #6b7484; }

/* ---------- 看板 ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.kpi .k { font-size: 12.5px; color: var(--ink-3); }
.kpi .v { font-size: 26px; font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 13px; color: var(--ink-3); font-weight: 400; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.chart { width: 100%; height: 300px; }

/* ---------- 后台布局 ---------- */
.adm { max-width: 1180px; margin: 0 auto; padding: 0 16px 60px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 20px; overflow-x: auto; }
.tabs button {
  border: none; background: none; padding: 11px 16px; font-size: 14.5px;
  color: var(--ink-2); cursor: pointer; border-bottom: 2px solid transparent;
  font-family: inherit; white-space: nowrap;
}
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.toolbar { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar select, .toolbar input { width: auto; min-width: 148px; padding: 8px 12px; font-size: 14px; }

.sec-editor { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; background: #fbfcfe; }
.sec-editor .se-head { display: flex; gap: 8px; margin-bottom: 10px; }
.sec-editor .se-head input { flex: 1; }
.q-row { display: flex; gap: 8px; margin-bottom: 7px; }
.q-row input { flex: 1; }
.q-row .del { flex: none; }

/* ---------- 打印 ---------- */
.pg { background: var(--bg); padding: 20px 16px 50px; }
.sheet {
  background: #fff; max-width: 900px; margin: 0 auto; padding: 42px 48px;
  box-shadow: var(--shadow); border-radius: 6px;
}
.sheet h1 { text-align: center; font-size: 23px; margin: 0 0 6px; letter-spacing: 1px; }
.sheet .sub { text-align: center; color: var(--ink-2); font-size: 14px; margin-bottom: 6px; }
.sheet .meta-row { text-align: center; font-size: 13px; color: var(--ink-3); margin-bottom: 24px; }
.sheet h2 {
  font-size: 15.5px; margin: 26px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--line); font-weight: 600;
}
.sheet table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-bottom: 6px; }
.sheet th, .sheet td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.sheet th { background: #f7f9fc; font-weight: 600; }
.sheet td.num { text-align: center; width: 88px; font-variant-numeric: tabular-nums; }
.sheet .sig {
  display: flex; justify-content: space-between; gap: 30px;
  margin-top: 46px; font-size: 13.5px; color: var(--ink-2);
}
.sheet .sig div { flex: 1; border-top: 1px solid var(--ink-3); padding-top: 7px; }
.sheet .sig div[contenteditable] { cursor: text; min-height: 1.6em; }
.sheet .sig div[contenteditable]:hover { background: #f5f8ff; }
.sheet .sig div[contenteditable]:focus {
  outline: 2px dashed var(--brand-2); outline-offset: 3px; background: #f5f8ff;
}
.sheet .conclusion {
  font-size: 13.5px; line-height: 1.9; color: var(--ink); background: #fafbfd;
  border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; margin-top: 8px;
}
.sheet .note {
  font-size: 12px; line-height: 1.8; color: #6b7688;
  margin: 6px 0 0; padding: 7px 10px;
  border-left: 3px solid var(--line); background: #fafbfd;
}
.print-only { display: none; }

@media print {
  @page { size: A4; margin: 12mm; }
  html, body { background: #fff !important; width: auto !important; overflow: visible !important; }
  body::before, .no-print, .topbar, .tabs, .toolbar { display: none !important; }
  .print-only { display: block; }
  .pg { padding: 0; background: #fff; max-width: 100%; }
  .sheet {
    box-shadow: none; padding: 0; max-width: 100%; width: 100%;
    border-radius: 0; box-sizing: border-box;
    /* 不要 overflow:hidden：border-collapse 表格宽度取整会超出内容盒 <1pt，
       裁切会把最外侧右边框整条切掉（2026-10-19 打印预览右边框缺失的根因） */
    overflow: visible;
  }
  .sheet, .sheet * { box-sizing: border-box; }
  /* 防表格超出 A4 可打印区域：锁定总宽、允许断词、像素列宽失效 */
  .sheet table { width: 100% !important; table-layout: fixed; }
  .sheet th, .sheet td { word-wrap: break-word; overflow-wrap: break-word; }
  .sheet td.num { width: auto !important; }
  .sheet h2 { break-after: avoid; }
  .sheet table { break-inside: auto; }
  .sheet tr { break-inside: avoid; }
  .noprint { display: none !important; }
}

@media (max-width: 640px) {
  .hero h1 { font-size: 22px; }
  .card { padding: 20px 16px; }
  .qr-box { width: 216px; height: 216px; }
  .topbar nav a { margin-left: 12px; font-size: 13px; }
  .sheet { padding: 24px 20px; }
}

/* 平板（641-1024） */
@media (min-width: 641px) {
  .opt { width: 48px; height: 48px; font-size: 17px; }
  .q-title { font-size: 15.5px; }
  .card { padding: 28px 28px; }
}
@media (min-width: 768px) and (max-width: 1100px) {
  .wrap { max-width: 780px; }
  .wrap-narrow { max-width: 560px; }
  .hero h1 { font-size: 28px; }
  .qr-box { width: 300px; height: 300px; }
  .sticky-bar { padding: 16px 0; }
}

/* 桌面（>1100）：问卷居中收窄，阅读动线更聚焦 */
@media (min-width: 1101px) {
  .wrap { max-width: 820px; }
  .hero { padding-top: 44px; }
  .hero h1 { font-size: 30px; }
}

.muted { color: var(--ink-3); font-size: 13px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb8 { margin-bottom: 8px; }
.right { text-align: right; }
.hide { display: none !important; }