/* 小学心理健康测评系统 - 共享样式 */
:root {
  --bg: #eef3f8;
  --card: #ffffff;
  --ink: #243447;
  --muted: #6b7a8d;
  --line: #e2e9f1;
  --brand: #3b82c4;
  --brand-dark: #2c6ca8;
  --green: #1c9d6b;
  --green-bg: #e4f6ee;
  --amber: #c98a12;
  --amber-bg: #fdf3dd;
  --red: #cf3b3b;
  --red-bg: #fdeaea;
  --blue-bg: #e8f1fb;
  --radius: 14px;
  --shadow: 0 2px 14px rgba(30, 60, 100, .08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 15px;
}

.container { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }
.container.wide { max-width: 1700px; }
/* 后台总表：加宽后略微收紧，减少横向滚动 */
#main-table th, #main-table td { padding: 7px 8px; }
#main-table th { font-size: 12.5px; }
#main-table td { font-size: 13px; }
.page-header { text-align: center; padding: 26px 0 10px; }
.page-header h1 { font-size: 24px; color: var(--brand-dark); letter-spacing: 1px; }
.page-header .sub { color: var(--muted); font-size: 13px; margin-top: 6px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-top: 18px;
}
.card-title { font-size: 17px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; cursor: pointer; border-radius: 10px; padding: 9px 18px;
  font-size: 14px; font-family: inherit; font-weight: 600;
  background: var(--brand); color: #fff; transition: filter .15s, opacity .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: #eef3f9; color: var(--ink); }
.btn.ghost:hover { background: #e2eaf3; }
.btn.danger { background: var(--red); }
.btn.small { padding: 5px 12px; font-size: 13px; border-radius: 8px; }
.btn.ok { background: var(--green); }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fbfdff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b9d6ee; border-color: var(--brand); }
textarea { resize: vertical; min-height: 90px; }
label.field { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
label.field span { display: block; margin-bottom: 5px; color: var(--ink); font-weight: 600; }

.table-wrap { overflow-x: auto; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
th { background: #f2f6fb; color: #46586d; font-weight: 700; position: sticky; top: 0; }
tbody tr:hover { background: #f6faff; }
td.left, th.left { text-align: left; }

.sc { display: inline-block; min-width: 34px; padding: 3px 8px; border-radius: 8px; font-weight: 700; background: #eef3f9; }
.sc-warn { background: var(--amber-bg); color: var(--amber); }
.sc-bad { background: var(--red-bg); color: var(--red); }
.sc-ok { background: var(--green-bg); color: var(--green); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-ok { background: var(--green-bg); color: var(--green); }
.badge-mid { background: var(--amber-bg); color: var(--amber); }
.badge-bad { background: var(--red-bg); color: var(--red); }
.badge-gray { background: #eceff3; color: #5b6878; }

.banner { border-radius: 12px; padding: 12px 16px; margin: 12px 0; font-size: 14px; }
.banner-red { background: var(--red-bg); color: var(--red); border: 1px solid #f5c7c7; }
.banner-amber { background: var(--amber-bg); color: var(--amber); border: 1px solid #ecd29e; }
.banner-blue { background: var(--blue-bg); color: var(--brand-dark); border: 1px solid #c4dcef; }

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 120px; }
.right { margin-left: auto; }

/* 答题进度条 */
.quiz-progress { height: 10px; background: #e3eaf2; border-radius: 999px; overflow: hidden; margin: 16px 0 8px; }
.quiz-progress > div { height: 100%; background: linear-gradient(90deg, #5aa7e0, var(--brand)); border-radius: 999px; transition: width .2s; }

/* 因子条 */
.f-bar { height: 10px; background: #e7edf4; border-radius: 999px; flex: 1; overflow: hidden; }
.f-bar > div { height: 100%; border-radius: 999px; }
.f-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.f-row:last-child { border-bottom: none; }
.f-name { width: 110px; font-weight: 700; font-size: 14px; }
.f-score { min-width: 70px; text-align: right; font-weight: 700; font-size: 14px; }
.f-max { color: var(--muted); font-size: 12px; font-weight: 400; }

/* 预览页因子卡 */
.f-card { border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.f-card.warn { border-color: #ecd29e; background: #fffdf6; }
.f-card.bad { border-color: #f0bfbf; background: #fff7f7; }
.f-card .head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.f-card .head h3 { font-size: 15px; }
.f-card .mean { margin-top: 8px; font-size: 13.5px; }
.f-card .mean b { color: var(--muted); font-weight: 600; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0 4px; }
.tab { padding: 8px 18px; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); background: #e8eef5; border: none; }
.tab.active { background: var(--brand); color: #fff; }

.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #263445; color: #fff; padding: 10px 22px; border-radius: 10px; font-size: 14px; z-index: 99; box-shadow: var(--shadow); opacity: 0; transition: opacity .25s; }
.toast.show { opacity: 1; }

.login-wrap { max-width: 420px; margin: 60px auto 0; }
.login-tip { background: #fffbe9; border: 1px solid #f0e3ae; color: #8a6d1a; }

nav.topbar { display: flex; align-items: center; gap: 14px; background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 10px 18px; margin-top: 14px; flex-wrap: wrap; }
nav.topbar .brand { font-weight: 700; color: var(--brand-dark); }
nav.topbar .spacer { flex: 1; }

/* 打印 */
@page { size: A4 landscape; margin: 8mm; }
@media print {
  body { background: #fff; font-size: 11px; }
  .no-print { display: none !important; }
  .page-header .sub { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  nav.topbar, .tabs, .toast { display: none !important; }
  .container { max-width: none; padding: 0 4px; }
  .table-wrap { overflow: visible !important; }
  table { width: 100%; }
  th, td { padding: 3px 5px; font-size: 9.5px; white-space: nowrap; }
  .rem-cell { white-space: normal !important; }
  th { position: static; }
}

/* ===== 答题页：卡片式 + 答题卡 ===== */
#quiz-title { cursor: default; }

.quiz-toolbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg); padding: 10px 0 6px;
}

.q-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 12px;
  scroll-margin-top: 92px;
}
.q-card.flash { animation: flashbg 1.4s ease; }
@keyframes flashbg {
  0%, 55% { background: #fff6d8; border-color: #e8c96a; }
  100% { background: #fff; border-color: var(--line); }
}
.q-top { display: flex; gap: 10px; align-items: flex-start; }
.q-no {
  flex: none; width: 34px; height: 34px; border-radius: 10px;
  background: var(--blue-bg); color: var(--brand-dark);
  font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.q-text { flex: 1; font-size: 15px; line-height: 1.7; }
.q-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.q-options input { position: absolute; opacity: 0; pointer-events: none; }
.opt {
  text-align: center; padding: 10px 0; border-radius: 10px;
  border: 1.5px solid var(--line); font-weight: 700; font-size: 15px;
  cursor: pointer; color: var(--muted); transition: all .15s; user-select: none;
}
.opt-yes:hover { border-color: var(--green); color: var(--green); }
.opt-no:hover { border-color: var(--red); color: var(--red); }
.q-options input[value="1"]:checked + .opt-yes,
.q-options input[value="1"]:checked + .opt-yes:hover { background: var(--green); border-color: var(--green); color: #fff; }
.q-options input[value="0"]:checked + .opt-no,
.q-options input[value="0"]:checked + .opt-no:hover { background: var(--red); border-color: var(--red); color: #fff; }

/* 答题卡 */
#answer-sheet {
  position: fixed; right: 14px; top: 84px; width: 230px; z-index: 60;
  background: #fff; border-radius: var(--radius); box-shadow: 0 4px 20px rgba(30, 60, 100, .14);
  padding: 12px; display: none; flex-direction: column;
  max-height: min(62vh, 540px);
}
#answer-sheet.open { display: flex; }
.sheet-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
.sheet-grid {
  display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px;
  overflow-y: auto; margin-top: 8px; padding: 2px 1px;
}
.sheet-cell {
  border: 1px solid var(--line); background: #f3f6fa; border-radius: 6px;
  font-size: 11px; padding: 4px 0; cursor: pointer; color: var(--muted); font-weight: 700;
  transition: filter .12s;
}
.sheet-cell:not(.later):hover { filter: brightness(1.07); }
.sheet-cell.done { background: var(--green-bg); color: var(--green); border-color: #c9e4d6; }
.sheet-cell.unanswered { background: var(--red-bg); color: var(--red); border-color: #f0c4c4; }
.sheet-cell.now { background: var(--blue-bg); color: var(--brand-dark); border-color: var(--brand); }
.sheet-cell.later { opacity: .4; cursor: default; }

/* 一题一卡导航 */
.q-nav { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.q-nav .spacer { flex: 1; }

/* ===== 单题卡片新版：更饱满 ===== */
.q-card.big {
  padding: 26px 22px 18px;
  text-align: center;
  border: 1px solid #e6edf5;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  animation: cardIn .32s ease;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.q-meta { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--blue-bg); color: var(--brand-dark);
  border: 1px solid #cfe3f4; border-radius: 999px;
  padding: 4px 13px; font-size: 12.5px; font-weight: 700;
}
.chip.muted-chip { background: #f2f5f9; color: var(--muted); border-color: var(--line); }
.q-no-circle {
  width: 62px; height: 62px; margin: 2px auto 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5aa7e0, var(--brand));
  color: #fff; font-size: 24px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(59, 130, 196, .28);
}
.q-card.big .q-text {
  font-size: 19px; line-height: 1.9; font-weight: 600;
  color: var(--ink); padding: 0 4px 2px;
}
.q-card.big .q-options { grid-template-columns: 1fr 1fr; gap: 14px; margin: 20px auto 4px; max-width: 460px; }
.q-card.big .opt {
  min-height: 74px; display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 19px; border-radius: 16px; border-width: 2px;
}
.q-card.big .opt-yes { color: var(--green); border-color: #b6dfcf; background: #f2fbf7; }
.q-card.big .opt-no { color: var(--red); border-color: #edc4c4; background: #fdf4f4; }
.q-card.big .opt-yes:hover { border-color: var(--green); background: var(--green-bg); }
.q-card.big .opt-no:hover { border-color: var(--red); background: var(--red-bg); }
.q-card.big .q-options input[value="1"]:checked + .opt-yes,
.q-card.big .q-options input[value="1"]:checked + .opt-yes:hover { background: var(--green); color: #fff; border-color: var(--green); }
.q-card.big .q-options input[value="0"]:checked + .opt-no,
.q-card.big .q-options input[value="0"]:checked + .opt-no:hover { background: var(--red); color: #fff; border-color: var(--red); }
.q-card.big .q-nav { max-width: 460px; margin: 8px auto 0; }
.q-tip { margin-top: 14px; color: var(--muted); font-size: 13.5px; min-height: 22px; }

/* 工具栏进度圆环 */
.ring { width: 42px; height: 42px; flex: none; }
.ring-bg { fill: none; stroke: #dfe8f2; stroke-width: 5; }
.ring-fg {
  fill: none; stroke: var(--brand); stroke-width: 5; stroke-linecap: round;
  stroke-dasharray: 113.1; stroke-dashoffset: 113.1; transition: stroke-dashoffset .35s;
}
@media (max-width: 480px) {
  .ring { width: 34px; height: 34px; }
  .q-card.big { padding: 20px 14px 16px; }
  .q-card.big .q-text { font-size: 17px; }
  .q-card.big .opt { min-height: 62px; font-size: 17px; }
  .q-no-circle { width: 54px; height: 54px; font-size: 21px; }
}

/* 弹窗（手工录入等） */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 35, 55, .45); z-index: 90;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 14px; overflow: auto;
}
.modal {
  background: #fff; border-radius: 16px; padding: 22px;
  width: 100%; max-width: 680px;
  box-shadow: 0 16px 48px rgba(10, 25, 45, .25);
}
.f-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 14px; }
@media (max-width: 700px) { .f-grid { grid-template-columns: repeat(2, 1fr); } }

/* 页脚技术支持 */
.contact-foot {
  text-align: center; font-size: 12px; color: #9aa8b8;
  padding: 22px 16px 34px; line-height: 1.7;
}

/* 手机端适配 */
@media (max-width: 900px) {
  .page-header h1 { font-size: 20px; }
  .container { padding: 12px 10px 40px; }
  #answer-sheet { left: 10px; right: 10px; width: auto; top: 60px; max-height: 55vh; }
}