/* ==========================================================================
   心理普查结果反馈书 · 公共样式（手机优先）
   ========================================================================== */

:root {
  --bg: #eef2f7;
  --card: #ffffff;
  --ink: #17212e;
  --muted: #6b7a8d;
  --line: #e3e9f1;
  --brand: #1668dc;
  --brand-dark: #0f4fa8;
  --brand-soft: #eaf2ff;
  --warn: #c0392b;
  --ok: #0f8a5f;
  --radius: 14px;
  --shadow: 0 6px 22px rgba(16, 42, 74, .09);
  --doc-font: "Songti SC", "SimSun", "宋体", "Noto Serif CJK SC", serif;
}

* { 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, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

.app { max-width: 860px; margin: 0 auto; padding: 0 14px 40px; }

/* ---------------- 顶部栏 ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 2px;
  background: linear-gradient(180deg, var(--bg) 70%, rgba(238, 242, 247, 0));
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.logo {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--brand), #3f97ff);
  color: #fff; font-weight: 700; font-size: 18px;
  box-shadow: 0 4px 12px rgba(22, 104, 220, .3);
}
.brand b { display: block; font-size: 16px; line-height: 1.3; }
.brand small { display: block; color: var(--muted); font-size: 12px; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  margin-bottom: 14px;
}
.card h2 { margin: 0 0 4px; font-size: 19px; }
.card h3 { margin: 0 0 10px; font-size: 16px; }
.muted { color: var(--muted); font-size: 13.5px; margin: 4px 0 0; }
.err { color: var(--warn); font-size: 13.5px; margin: 10px 0 0; }

/* ---------------- 表单 ---------------- */
.inputRow { display: flex; gap: 10px; margin-top: 14px; }
input[type="text"], input[type="tel"], input[type="password"], select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: #f8fafd; border: 1.5px solid var(--line);
  border-radius: 11px; padding: 12px 13px; outline: none;
  transition: border-color .15s, background .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); background: #fff; }
#classInput {
  font-size: 24px; font-weight: 700; letter-spacing: 3px;
  text-align: center; padding: 12px 8px;
}
textarea { min-height: 92px; line-height: 1.7; resize: vertical; }
select { appearance: none; background-image: none; }

button {
  font: inherit; cursor: pointer; border: none; border-radius: 11px;
  padding: 12px 18px; transition: transform .06s, background .15s, color .15s;
}
button:active { transform: scale(.98); }
button.primary { background: var(--brand); color: #fff; font-weight: 600; white-space: nowrap; }
button.primary:hover { background: var(--brand-dark); }
button.ghost {
  background: var(--brand-soft); color: var(--brand-dark);
  font-weight: 600; padding: 9px 14px; font-size: 14px;
}
button.ghost:hover { background: #dceaff; }
button.gray { background: #eef1f5; color: #46566b; font-weight: 600; }
button:disabled { opacity: .5; cursor: not-allowed; }

.yearRow { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.yearRow label { color: var(--muted); font-size: 14px; white-space: nowrap; }

/* ---------------- 班级选择 ---------------- */
.tabs { display: flex; gap: 8px; margin: 16px 0 10px; flex-wrap: wrap; }
.tab {
  padding: 7px 14px; border-radius: 999px; font-size: 14px; font-weight: 600;
  background: #f1f4f9; color: #55657a;
}
.tab.active { background: var(--brand); color: #fff; }
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.chip {
  padding: 10px 4px; border-radius: 10px; text-align: center;
  background: #f5f8fc; border: 1.5px solid var(--line);
  font-size: 15px; font-weight: 600; color: #33465e;
}
.chip:hover { border-color: var(--brand); color: var(--brand); background: #fff; }
.chip.has-data { background: var(--brand-soft); border-color: #bcd7ff; color: var(--brand-dark); }

.recent { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.recent .row { display: flex; align-items: center; gap: 10px; }
.recent .row .muted { flex: 1; margin: 0; }

/* ---------------- 文档 ---------------- */
.pagebar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0 12px;
}
.pagebar-title { flex: 1; text-align: center; font-weight: 700; font-size: 15px; }

.doc {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px 20px 30px;
  font-family: var(--doc-font);
  font-size: 15.5px; line-height: 1.95; color: #101a26;
}
.docTitle {
  text-align: center; font-family: "SimHei", "黑体", sans-serif;
  font-size: 25px; letter-spacing: 2px; margin: 0 0 18px; font-weight: 700;
}
.docMeta {
  display: flex; flex-wrap: wrap; gap: 6px 22px;
  justify-content: space-between;
  font-size: 15px; padding-bottom: 10px; border-bottom: 2px solid #101a26;
  margin: 0 0 16px;
}
.docMeta b { font-family: "SimHei", "黑体", sans-serif; font-size: 17px; letter-spacing: 1px; }
.doc h3 { margin: 18px 0 8px; font-family: "SimHei", "黑体", sans-serif; font-size: 16.5px; }
.doc p { margin: 9px 0; text-align: justify; }
.doc .indent { text-indent: 2em; }

.docTable { width: 100%; border-collapse: collapse; margin: 14px 0 6px; font-size: 15px; }
.docTable th, .docTable td {
  border: 1px solid #101a26; padding: 9px 10px; vertical-align: middle;
}
.docTable th { background: #f4f6f9; font-family: "SimHei", "黑体", sans-serif; font-weight: 600; text-align: center; }
.docTable td:first-child, .docTable td:last-child { text-align: center; white-space: nowrap; width: 1%; }
.docTable .names { line-height: 1.9; word-break: break-all; }
.docTable .names .none { color: #8b98a8; }
.docTable .names .nm {
  display: inline-block; margin: 1px 9px 1px 0;
  padding: 0 2px; border-bottom: 1px dotted #98a6b6;
}
.docTable tr.h70 .nm { border-bottom-color: #d99d9d; }

.docNote { color: #46566b; font-size: 14px; margin-top: 2px; }
.docHr { border: none; border-top: 1px solid #cfd8e3; margin: 20px 0; }
.docFlow { margin: 9px 0; }
.docEnd { border-bottom: none; padding-bottom: 0; }

.docSign {
  display: flex; flex-wrap: wrap; gap: 10px 40px; justify-content: flex-end;
  margin-top: 30px; font-size: 15px;
}
.docSign span { display: inline-block; min-width: 130px; border-bottom: 1px solid #101a26; }

/* ---------------- 签字确认卡 ---------------- */
.signCard { margin-top: 14px; }
#signPad {
  width: 100%; height: 150px; margin-top: 10px;
  background: #fbfdff; border: 1.5px dashed #c3d3e6; border-radius: 12px;
  touch-action: none; display: block;
}
.signActions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.signActions button { flex: 1; min-width: 96px; }
.doneBadge {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px;
  background: #e8f7ef; color: var(--ok); font-weight: 600;
  padding: 8px 12px; border-radius: 10px; font-size: 14px;
}

.foot { text-align: center; color: var(--muted); font-size: 12.5px; padding: 6px 0 0; line-height: 1.8; }

/* ---------------- 管理页 ---------------- */
.clsGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; margin-top: 12px; }
.clsGrid .chip { position: relative; }
.clsGrid .chip .dot {
  position: absolute; top: 5px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%; background: #c9d4e2;
}
.clsGrid .chip.has-data .dot { background: var(--ok); }
.clsGrid .chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.field { margin-top: 14px; }
.field > label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field .hint { color: var(--muted); font-size: 12.5px; font-weight: 400; margin-left: 6px; }
.statBar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.stat {
  flex: 1; min-width: 90px; background: #f6f9fd; border-radius: 11px;
  padding: 10px 12px; text-align: center;
}
.stat b { display: block; font-size: 20px; color: var(--brand-dark); }
.stat span { font-size: 12.5px; color: var(--muted); }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: #17212e; color: #fff; padding: 11px 20px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 99;
  max-width: 86vw; text-align: center;
}
.toast.show { opacity: .95; transform: translateX(-50%) translateY(0); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.toolbar button { flex: 1; min-width: 110px; }

/* ---------------- 二维码页 ---------------- */
.qrWrap { text-align: center; padding: 6px 0 10px; }
.qrBox {
  display: inline-block; padding: 14px; background: #fff;
  border-radius: 14px; border: 1px solid var(--line);
}
.qrBox img, .qrBox canvas { display: block; width: 220px; height: 220px; }
.qrUrl {
  margin-top: 12px; font-size: 13px; color: var(--muted);
  word-break: break-all; background: #f6f9fd; border-radius: 10px; padding: 10px;
}
.yearBadge {
  display: inline-block; background: var(--brand-soft); color: var(--brand-dark);
  border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600; margin-bottom: 6px;
}

/* ---------------- 打印 ---------------- */
@page { size: A4; margin: 16mm 15mm; }

@media print {
  body { background: #fff; font-size: 12pt; }
  .no-print, .topbar, .pagebar, .signCard, .foot, .toast { display: none !important; }
  .app { max-width: none; padding: 0; }
  .doc {
    box-shadow: none; border-radius: 0; padding: 0;
    font-size: 12pt; line-height: 1.8; color: #000;
  }
  .docTitle { font-size: 20pt; }
  .docTable th, .docTable td { border-color: #000; }
  .docMeta { border-bottom-color: #000; }
  .docSign span { border-bottom-color: #000; }
  .doc, .docTable tr { page-break-inside: avoid; }
}

@media (max-width: 420px) {
  .doc { padding: 20px 14px 24px; font-size: 15px; }
  .docTitle { font-size: 21px; }
  .chips { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
}
