/* ============================================================
   AI 问卷匹配系统 —— 界面样式
   设计取向：克制、清晰、以内容为主。
   主色取偏冷的蓝，用于强调可操作元素；大面积留白，降低阅读负担。
   ============================================================ */

:root {
  --brand:        #2563eb;
  --brand-dark:   #1d4ed8;
  --brand-soft:   #eff6ff;
  --text:         #1f2937;
  --text-weak:    #6b7280;
  --text-faint:   #9ca3af;
  --line:         #e5e7eb;
  --bg:           #f7f8fa;
  --surface:      #ffffff;
  --success:      #059669;
  --success-soft: #ecfdf5;
  --warn:         #d97706;
  --warn-soft:    #fffbeb;
  --danger:       #dc2626;
  --radius:       10px;
  --radius-lg:    14px;
  --shadow:       0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lift:  0 4px 12px rgba(0,0,0,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.topbar-logo {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--brand); color: #fff;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
.topbar-nav { display: flex; gap: 4px; }
.topbar-nav button {
  background: none; border: none; cursor: pointer;
  padding: 7px 13px; border-radius: 7px;
  color: var(--text-weak); font-size: 13.5px;
  font-family: inherit;
}
.topbar-nav button:hover { background: var(--bg); color: var(--text); }
.topbar-nav button.on { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-weak); }
.topbar-user .aid {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--bg); padding: 3px 8px; border-radius: 5px;
  color: var(--text); letter-spacing: .5px;
}

/* ---------- 布局 ---------- */
.page { max-width: 940px; margin: 0 auto; padding: 28px 24px 72px; }
.page-narrow { max-width: 460px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 21px; font-weight: 600; letter-spacing: -.2px; }
.page-head p { color: var(--text-weak); margin-top: 5px; font-size: 13.5px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-tight { padding: 16px 18px; }
.card-title {
  font-size: 15px; font-weight: 600; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between;
}

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.field .req { color: var(--danger); margin-left: 2px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 14px; font-family: inherit; background: var(--surface);
  color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.field .hint { font-size: 12px; color: var(--text-faint); margin-top: 5px; }
.field .err { font-size: 12px; color: var(--danger); margin-top: 5px; display: none; }
.field.invalid input { border-color: var(--danger); }
.field.invalid .err { display: block; }

/* ---------- 按钮 ---------- */
.btn {
  padding: 9px 18px; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer;
  font-size: 14px; font-weight: 500; font-family: inherit;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:active { background: #1e40af; transform: scale(.98); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--bg); }
.btn-ghost:active { background: #eef0f3; transform: scale(.98); }
.btn-text { background: none; color: var(--brand); padding: 6px 8px; }
.btn-text:hover { background: var(--brand-soft); }
.btn-text:active { background: #dbeafe; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; align-items: center; }

/* ---------- 提示条 ---------- */
.notice {
  border-radius: var(--radius); padding: 13px 15px;
  font-size: 13px; line-height: 1.6; margin-bottom: 16px;
  border: 1px solid transparent;
}
.notice-info    { background: var(--brand-soft);   border-color: #bfdbfe; color: #1e40af; }
.notice-success { background: var(--success-soft);  border-color: #a7f3d0; color: #065f46; }
.notice-warn    { background: var(--warn-soft);     border-color: #fde68a; color: #92400e; }
.notice strong { font-weight: 600; }

/* ---------- 账号 ID 展示 ---------- */
.account-box {
  background: var(--surface); border: 2px dashed var(--brand);
  border-radius: var(--radius-lg); padding: 22px; text-align: center; margin: 18px 0;
}
.account-box .lbl { font-size: 12.5px; color: var(--text-weak); margin-bottom: 8px; }
.account-box .val {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 31px; font-weight: 700; color: var(--brand);
  letter-spacing: 5px; margin-bottom: 12px;
  /* C39：账号 ID 是一整串凭证，逐字符选反而容易漏尾。
     user-select:all 让三击/一次点击就选中全部，clipboard 不可用时（http 源、
     微信内置浏览器）手动复制这条路才走得通。 */
  -webkit-user-select: all; user-select: all; cursor: text;
}

/* ---------- 列表项 ---------- */
.item {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 11px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; transition: border-color .15s, box-shadow .15s; background: var(--surface);
}
.item:hover { border-color: #d1d5db; box-shadow: var(--shadow); }
.item-main { flex: 1; min-width: 0; }
.item-main h3 { font-size: 14.5px; font-weight: 600; margin-bottom: 4px; }
.item-meta { font-size: 12.5px; color: var(--text-weak); display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 500; background: var(--bg); color: var(--text-weak);
}
.tag-done { background: var(--success-soft); color: var(--success); }
.tag-todo { background: var(--brand-soft);   color: var(--brand); }
.tag-wait  { background: var(--warn-soft);    color: var(--warn); }

/* ---------- 题目 ---------- */
.q { padding: 20px 0; border-bottom: 1px solid var(--line); }
.q:last-child { border-bottom: none; }
.q-title { font-size: 14.5px; font-weight: 500; margin-bottom: 13px; display: flex; gap: 7px; }
.q-num { color: var(--brand); font-weight: 600; flex-shrink: 0; }
.opt {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 8px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.opt:hover { border-color: var(--brand); background: var(--brand-soft); }
.opt.sel { border-color: var(--brand); background: var(--brand-soft); }
.opt input { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }
.opt span { font-size: 14px; }

/* 评分题 */
.rating { display: flex; gap: 8px; }
.rating button {
  flex: 1; padding: 11px 0; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface);
  cursor: pointer; font-size: 14px; font-family: inherit; color: var(--text);
}
.rating button:hover { border-color: var(--brand); }
.rating button.sel { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.rating-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-faint); margin-top: 6px; }

/* ---------- 进度 ---------- */
.progress { height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.progress-bar { height: 100%; background: var(--brand); transition: width .3s; }
.progress-text { font-size: 12.5px; color: var(--text-weak); text-align: right; }

/* ---------- 分数环 ---------- */
.score-wrap { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; }
.score-ring {
  width: 116px; height: 116px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; position: relative;
}
.score-ring-inner {
  width: 92px; height: 92px; background: var(--surface); border-radius: 50%;
  display: grid; place-items: center; text-align: center;
}
.score-ring .num { font-size: 27px; font-weight: 700; line-height: 1.1; }
.score-ring .cap { font-size: 11px; color: var(--text-weak); }

/* ---------- 报告 ---------- */
.report-sec { margin-bottom: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.report-sec:first-of-type { border-top: none; padding-top: 0; }
.report-sec:last-child { margin-bottom: 0; }
.report-sec h3 {
  font-size: 14px; font-weight: 600; margin-bottom: 9px;
  display: flex; align-items: center; gap: 7px;
}
.report-sec h3::before {
  content: ''; width: 3px; height: 14px; background: var(--brand); border-radius: 2px;
}
.report-sec p { color: #374151; font-size: 13.8px; line-height: 1.85; }
.report-summary {
  background: var(--brand-soft); border-left: 3px solid var(--brand);
  padding: 14px 16px; border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 15px; font-weight: 500; color: #1e40af; margin-bottom: 20px;
}

/* ---------- 页面淡入 ---------- */
#app { animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- 加载 ---------- */
.loading { text-align: center; padding: 52px 20px; }
.spinner {
  width: 34px; height: 34px; margin: 0 auto 16px;
  border: 3px solid var(--line); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { color: var(--text-weak); font-size: 13.5px; }
.loading .sub { font-size: 12.5px; color: var(--text-faint); margin-top: 5px; }

/* ---------- 成功打钩 ---------- */
.success-check {
  width: 56px; height: 56px; margin: 0 auto;
  border-radius: 50%; background: var(--success-soft);
  color: var(--success); font-size: 28px; font-weight: 700;
  display: grid; place-items: center;
  animation: pop-in .35s cubic-bezier(.17,.67,.35,1.2);
}
@keyframes pop-in { 0% { transform: scale(0); opacity: 0 } 100% { transform: scale(1); opacity: 1 } }

/* ---------- Toast 动画 ---------- */
.notice-toast {
  animation: toast-in .25s ease-out, toast-out .3s ease-in 2.3s forwards;
}
@keyframes toast-in { 0% { opacity: 0; transform: translateX(-50%) translateY(-12px) } 100% { opacity: 1; transform: translateX(-50%) translateY(0) } }
@keyframes toast-out { 0% { opacity: 1 } 100% { opacity: 0; transform: translateX(-50%) translateY(-8px) } }

/* ---------- 空态 ---------- */
.empty { text-align: center; padding: 46px 20px; color: var(--text-faint); }
.empty-icon {
  font-size: 34px; margin-bottom: 10px; opacity: .35;
  width: 56px; height: 56px; margin: 0 auto 12px;
  border-radius: 50%; background: var(--bg);
  display: grid; place-items: center;
}
.empty p { font-size: 13.5px; }

/* ---------- 分段控件 ---------- */

/* ---------- 分栏 ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- 对照条 ---------- */
.cmp { margin-bottom: 14px; }
.cmp-q { font-size: 13px; color: var(--text-weak); margin-bottom: 6px; }
.cmp-side { flex: 1; padding: 8px 11px; border-radius: 7px; font-size: 13px; }
.cmp-a { background: var(--brand-soft); color: #1e40af; }
.cmp-b { background: #fdf4ff; color: #86198f; }
.cmp-eq { font-size: 11px; padding: 2px 7px; border-radius: 20px; flex-shrink: 0; }
.cmp-same { background: var(--success-soft); color: var(--success); }
.cmp-diff { background: var(--warn-soft); color: var(--warn); }

/* ---------- 移动端底部导航 ---------- */
.mobile-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface); border-top: 1px solid var(--line);
  z-index: 50; padding: 6px 0 env(safe-area-inset-bottom, 6px);
}
.mobile-nav-inner { display: flex; justify-content: space-around; }
.mobile-nav button {
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 12px; border-radius: 8px;
  color: var(--text-faint); font-size: 11px; font-family: inherit;
  transition: color .15s;
}
.mobile-nav button.on { color: var(--brand); }
.mobile-nav-ico { font-size: 18px; line-height: 1; }

/* ---------- 进度条吸顶阴影 ---------- */
.card[style*="position:sticky"] {
  border-bottom: 1px solid transparent;
  transition: border-color .2s, box-shadow .2s;
}
.card[style*="position:sticky"].scrolled {
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  border-bottom-color: var(--line);
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .page { padding: 18px 15px 80px; }
  .topbar { padding: 0 15px; }
  .topbar-nav { display: none; }
  .two-col { grid-template-columns: 1fr; }
  .score-wrap { justify-content: center; }
  .account-box .val { font-size: 26px; letter-spacing: 3px; }
  .mobile-nav { display: none; }
  body.logged-in .mobile-nav { display: block; }
  .item { flex-direction: column; align-items: stretch; gap: 10px; }
  .item .btn { align-self: flex-end; }
  .page-head h1 { font-size: 19px; }
  .btn-row { flex-wrap: wrap; }
}

/* ---------- 原型标注 ---------- */

/* ---------- 矩阵题 ---------- */
/* 矩阵在窄屏上容易挤成一团，因此允许横向滚动而不是压缩列宽 */
.matrix-wrap { overflow-x: auto; margin-top: 4px; }
table.matrix { border-collapse: collapse; width: 100%; min-width: 420px; font-size: 14px; }
table.matrix th, table.matrix td {
  border: 1px solid #e5e7eb; padding: 8px 10px; text-align: center;
}
table.matrix thead th { background: #f9fafb; font-weight: 600; color: #374151; }
table.matrix tbody th { text-align: left; font-weight: 500; background: #fcfcfd; min-width: 120px; }
table.matrix input[type="radio"], table.matrix input[type="checkbox"] { width: 16px; height: 16px; }
.matrix-input { width: 72px; padding: 4px 6px; border: 1px solid #d1d5db; border-radius: 6px; text-align: center; }

/* ---------- 多空填写 ---------- */
.blank-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.blank-row label { min-width: 96px; color: #4b5563; font-size: 14px; }
.blank-row input { flex: 1; }

/* ---------- 级联题 ---------- */
.cascader { display: flex; flex-wrap: wrap; gap: 12px; }
.cascader .field { flex: 1; min-width: 150px; margin-bottom: 0; }
.cascader label { display: block; margin-bottom: 4px; color: #4b5563; font-size: 13px; }

/* ---------- 展示类题目 ---------- */
.q-group { margin: 18px 0 6px; padding-left: 10px; border-left: 3px solid #4f46e5; }
.q-group h3 { margin: 0; font-size: 16px; color: #1f2937; }
.q-remark { margin: 12px 0; padding: 10px 12px; background: #f9fafb; border-radius: 8px;
  color: #4b5563; font-size: 14px; line-height: 1.7; }
hr.q-split { border: none; border-top: 1px dashed #d1d5db; margin: 18px 0; }
.q-page-tip { text-align: center; color: #9ca3af; font-size: 13px; margin: 18px 0; }

/* 报告依据的问卷此后被改动过时的标记 */
.tag-changed {
  display: inline-block; padding: 1px 8px; border-radius: 10px;
  background: #fef3c7; color: #92400e; font-size: 12px;
}

/* ------------------------------------------------------------
   让 HTML 的 hidden 属性真正生效。

   浏览器默认样式把 [hidden] 实现为 display:none，但作者样式里的
   display:flex 优先级更高，会把它盖掉。
   本项目的骨架（后台的 .admin-shell、用户端的 .topbar）都是先写在
   HTML 里、用 hidden 控制显隐的，一旦 hidden 失效，未登录时
   空骨架仍然占位，把登录框挤到页面下方，看起来就像"打开是一片白，
   要往下滚才看到登录框"。
   ------------------------------------------------------------ */
[hidden] { display: none !important; }

/* ------------------------------------------------------------
   导航待办红点
   有「待我审批」的匹配请求时出现在"匹配"页签上。
   红点必须在不重绘导航的前提下更新（见 app.js paintBadges），
   否则用户正在填写的表单会被冲掉。
   ------------------------------------------------------------ */
.nav-dot {
  display: inline-block; min-width: 16px; height: 16px; padding: 0 4px;
  margin-left: 5px; border-radius: 9px;
  background: var(--danger); color: #fff;
  font-size: 10.5px; line-height: 16px; font-weight: 600; text-align: center;
  vertical-align: middle; box-sizing: border-box;
}

/* 危险操作（注销账号等）：用户端也要能与普通按钮区分开，避免误点。
   admin.css 里有同名规则，但用户端不加载那个文件，因此这里单独给一份。 */
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; border-color: var(--danger); }


/* W7-8 解读正文 markdown-lite */
.report-sec p { margin: 0 0 10px; line-height: 1.75; }
.report-sec p:last-child { margin-bottom: 0; }
.report-sec .md-list { margin: 0 0 10px; padding-left: 20px; }
.report-sec .md-list li { margin: 4px 0; line-height: 1.7; }
.report-summary p { margin: 0 0 8px; }
.report-summary p:last-child { margin-bottom: 0; }

/* 审计波 R2（C37/C47）：小屏触控目标与 iOS 聚焦防抖 */
@media (max-width: 640px) {
  .rating { flex-wrap: wrap; gap: 6px; }
  .rating button { min-width: 44px; min-height: 44px; }
  /* 选项行是填写页最主要的点击目标，窄屏下按内容撑开只有 40px 上下，
     补足到 44px（C37，与评分按钮同一触控标准） */
  .opt { min-height: 44px; }
  .opt input { width: 20px; height: 20px; }
  .field input, .field select, .field textarea { font-size: 16px; }
}
