:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e3e6ec;
  --line-strong: #cfd5df;
  --text: #1f2430;
  --text-2: #5b6474;
  --text-3: #8b93a3;
  --primary: #1a5fb4;
  --primary-d: #144a8f;
  --primary-l: #eaf1fb;
  --ok: #1f8a4c;
  --ok-l: #e8f6ee;
  --err: #c0392b;
  --err-l: #fdecea;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(20, 30, 50, .07), 0 6px 20px rgba(20, 30, 50, .06);
}

* { box-sizing: border-box; }
/* inline-block/flex 会盖掉 hidden 的 UA 默认值，这条必须全局且最后生效 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 顶栏 ---------- */
.topbar {
  height: 52px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar .brand .dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--primary);
}
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a {
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--text-2);
  font-size: 13.5px;
}
.topbar nav a:hover { background: var(--primary-l); color: var(--primary); text-decoration: none; }
.topbar nav a.active { background: var(--primary-l); color: var(--primary); font-weight: 600; }
.topbar .who {
  color: var(--text-2);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- 布局 ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 20px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 700; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field > label, .field > .f-label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
}
/* 只读值：外观与输入框同高，但底色变浅、无边框高亮，
   "不能改"由外观直接表达，不靠一句说明文字 */
.fixed-val {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 35px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f2f3f5;
  color: var(--text-2);
  line-height: 1.3;
}
.fixed-val > span:first-child {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.field-inline {
  display: flex;
  gap: 24px;
  align-items: center;
  margin-top: 4px;
}
input[type=text], input[type=password], input[type=file], select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input[type=text]:focus, input[type=password]:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 95, 180, .12);
}
input[type=file] { padding: 6px; background: #fbfbfc; }
/* 禁用即视觉禁用：账号为空时密码框、校核项不可用，靠外观就能看出来 */
input:disabled, select:disabled {
  background: #f2f3f5;
  color: var(--text-3);
  border-color: var(--line);
  cursor: not-allowed;
}
input:disabled::placeholder { color: var(--line-strong); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.checkbox {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  color: var(--text);
}
.checkbox input { width: 15px; height: 15px; accent-color: var(--primary); }
.checkbox input:disabled + span,
.checkbox:has(input:disabled) { color: var(--text-3); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { background: #f7f8fa; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn-sm { padding: 4px 12px; font-size: 13px; }
.btn-link {
  background: none;
  border: none;
  padding: 0 4px;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--err); }

/* ---------- 表格 ---------- */
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.grid th {
  text-align: left;
  font-weight: 600;
  color: var(--text-2);
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  white-space: nowrap;
}
table.grid td {
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  vertical-align: middle;
}
table.grid tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover { background: #fbfcfe; }
table.grid .empty { text-align: center; color: var(--text-3); padding: 32px 0; }
/* 操作列：打印 / 下载 并排，不换行 */
table.grid td.act { white-space: nowrap; }
table.grid td.act > * + * { margin-left: 12px; }
/* 文件名可能很长，宁可省略也不撑破表格 */
table.grid .fname {
  display: block;
  max-width: 460px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 筛选与翻页 ---------- */
.filters { display: flex; align-items: center; gap: 8px; }
.filters input[type=date], .filters input[type=month], .filters input[type=text] {
  width: auto;
  padding: 5px 9px;
  font-size: 13px;
}
.filters input[type=text] { width: 120px; }
.filters input[type=month] { width: 150px; }
.filters input#fName { width: 170px; }
.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}
.pager .mono { font-size: 12.5px; color: var(--text-2); }
tr.row-off td { color: var(--text-3); }
tr.row-off .thumb { opacity: .55; }
.thumb {
  height: 34px;
  max-width: 116px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px;
}
.thumb-box { margin-top: 8px; min-height: 2px; }
.thumb-preview {
  height: 54px;
  max-width: 220px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px;
}
.mark-ok { color: var(--ok); font-size: 13px; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 18px;
  border: 1px solid transparent;
}
.badge-ok { background: var(--ok-l); color: var(--ok); border-color: #cbe8d8; }
.badge-off { background: #f0f1f3; color: var(--text-3); border-color: var(--line); }
.badge-warn { background: #fdf3e2; color: #b26a00; border-color: #f3e2c4; }
.badge-err { background: var(--err-l); color: var(--err); border-color: #f6d4d0; }

/* ---------- 工作区（上传页） ---------- */
.work {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 16px;
  align-items: start;
  max-width: 1320px;
}
.stage { min-width: 0; }
.side {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  position: sticky;
  top: 72px;
}
.side .field:last-of-type { margin-bottom: 8px; }
/* 签章是不可逆操作，独立成通栏按钮；位置参数不开放调整，侧栏只有选人与这一个按钮 */
.side-sign { width: 100%; margin-top: 8px; padding: 10px 16px; }

.drop {
  height: 320px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--primary); background: var(--primary-l); }
/* 预检未通过时留在落档区给出原因：没有原因的话用户只会看到"按钮又回来了" */
.drop-err {
  margin: 0;
  max-width: 560px;
  padding: 0 28px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--err);
  text-align: center;
  word-break: break-word;
}
.drop-err:empty { display: none; }

/* 上传/解析进度。两段各自诚实：字节数是真实百分比，解析排队是确定不了的，
   就只给位置和不确定态——不把"不知道"画成一条从 0 走到 100 的假进度。 */
.drop.busy #btnPick { display: none; }
.prog {
  width: 100%;
  max-width: 460px;
  padding: 0 24px;
  box-sizing: border-box;
}
.prog-track {
  position: relative;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}
.prog-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 2px;
  background: var(--primary);
  transition: width .18s linear;
}
.prog-track.indet .prog-fill {
  width: 34%;
  transition: none;
  animation: prog-indet 1.05s ease-in-out infinite;
}
@keyframes prog-indet {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(300%); }
}
.prog-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
  font-size: 12.5px;
  color: var(--text-2);
}
.prog-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prog-num { flex: none; font-variant-numeric: tabular-nums; }
.prog-meta .btn-link { flex: none; }

.viewer {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.viewer-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
}
.viewer-bar .grow { flex: 1; }
.page-info { font-size: 12.5px; color: var(--text-2); min-width: 52px; text-align: center; }
.icon-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 5px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  color: var(--text-2);
  padding: 0;
}
.icon-btn:hover { background: #f2f4f7; color: var(--text); }

.canvas-wrap {
  position: relative;
  padding: 16px;
  background: #eef0f4;
  display: flex;
  /* 不能默认 stretch：flex 会把 .page-box 拉到容器高度（约一屏），
     而画布是整页高（≈1273px），覆盖层就按一屏定位了，页脚会飘到页面三分之一处。
     必须让 box 随画布长高，页脚才是"贴着页面底边"。 */
  align-items: flex-start;
  /* safe：内容比容器宽时退回 start，否则居中会把左边缘裁掉且无法滚动过去 */
  justify-content: safe center;
  max-height: calc(100vh - 160px);
  overflow: auto;
}
.page-box { position: relative; flex: none; }
.canvas-wrap canvas {
  display: block;
  box-shadow: 0 2px 10px rgba(20, 30, 50, .12);
  background: #fff;
}
.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.ov-item {
  position: absolute;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  white-space: nowrap;
  color: #1f2430;
  pointer-events: none;
  user-select: none;
  border-bottom: 1px solid rgba(26, 95, 180, .55);
  padding-bottom: 1px;
}
.ov-label { line-height: 1; user-select: none; }
.ov-sign { display: inline-flex; align-items: flex-end; }
.ov-sign img { display: block; }
.ov-sign.empty {
  border: 1px dashed var(--primary);
  border-radius: 2px;
  background: rgba(26, 95, 180, .06);
}
.ov-ts {
  position: absolute;
  color: #666;
  font-family: Consolas, monospace;
  pointer-events: none;
}

/* ---------- 弹层 ---------- */
.mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 28, 42, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 64px 16px 30px;
  z-index: 50;
  overflow: auto;
}
.dialog {
  background: var(--panel);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(15, 25, 40, .28);
  width: 100%;
  max-width: 500px;
}
.dialog header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 14.5px;
}
.dialog .body { padding: 18px 20px 10px; }
.dialog footer {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #fbfbfc;
  border-radius: 0 0 10px 10px;
}

/* ---------- 成品预览：签完章当场看、当场打印 ---------- */
body.sp-open { overflow: hidden; }
.mask.sp { align-items: center; padding: 24px; }
.sp-shell {
  width: 100%;
  max-width: 1080px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(15, 25, 40, .32);
  overflow: hidden;
}
.sp-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
}
.sp-name {
  max-width: 44%;
  font-size: 13px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sp-grow { flex: 1; }
.sp-info { min-width: 52px; text-align: center; font-size: 12.5px; color: var(--text-2); }
.sp-bar .icon-btn:disabled { opacity: .35; cursor: default; }
.sp-doc {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #eef0f4;
  overflow: auto;
}
.sp-doc canvas { display: block; background: #fff; box-shadow: 0 2px 12px rgba(20, 30, 50, .16); }
/* 只在点打印的一瞬间填充，用完立刻清空 */
.sp-print { display: none; }
/* 打印准备进度：几十页的谱图要渲几秒，没有它就像点坏了 */
.sp-print-bar {
  flex: none;
  padding: 6px 14px;
  border-top: 1px solid var(--line);
  text-align: right;
  background: #fafbfc;
}
.sp-print-bar .mono { font-size: 12px; color: var(--text-2); }

/* 打印：只出成品页，界面一律不打印。
   全部规则挂在 body.sp-open 下，避免预览没开时按 Ctrl+P 打出一张白纸。 */
@media print {
  body.sp-open > *:not(#spMask) { display: none !important; }
  body.sp-open { overflow: visible; }
  body.sp-open .mask.sp {
    position: static;
    inset: auto;
    display: block;
    padding: 0;
    background: none;
    overflow: visible;
  }
  body.sp-open .sp-shell {
    max-width: none;
    height: auto;
    display: block;
    box-shadow: none;
    border-radius: 0;
  }
  body.sp-open .sp-bar,
  body.sp-open .sp-doc,
  body.sp-open .sp-print-bar { display: none !important; }
  body.sp-open .sp-print { display: block; }
  body.sp-open .sp-print img { display: block; page-break-after: always; }
  body.sp-open .sp-print img:last-child { page-break-after: auto; }
}

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eef2f8 0%, #f7f8fa 55%, #eef4fb 100%);
  padding: 20px;
}
.login-box {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(20, 30, 50, .1);
  padding: 32px 28px 28px;
}
.login-box h1 {
  margin: 0 0 24px;
  font-size: 19px;
  letter-spacing: .5px;
}
.login-box .btn { width: 100%; padding: 10px; margin-top: 6px; }

/* ---------- 提示 ---------- */
#toast {
  position: fixed;
  left: 50%;
  top: 22px;
  transform: translateX(-50%) translateY(-8px);
  background: #2b3340;
  color: #fff;
  padding: 9px 18px;
  border-radius: 6px;
  font-size: 13.5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  z-index: 999;
  max-width: 80vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: #b3261e; }
#toast.ok { background: #1f7a45; }

.alert {
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  display: none;
}
.alert.show { display: block; }
.alert-err { background: var(--err-l); color: var(--err); border: 1px solid #f6d4d0; }

.muted { color: var(--text-3); }

/* 字段内状态标记：直接显示输入值将被如何对待，替代说明文字 */
.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 9px;
  font-size: 11.5px;
  line-height: 17px;
  border: 1px solid transparent;
  vertical-align: 1px;
}
.tag-new { background: var(--primary-l); color: var(--primary); border-color: #cfe0f7; }
.tag-bind { background: var(--ok-l); color: var(--ok); border-color: #cbe8d8; }
.tag-err { background: var(--err-l); color: var(--err); border-color: #f6d4d0; }

/* ---------- 批量签章 ----------
   没有说明文字：有几份、到哪一步、为什么失败，全部由行内状态和按钮文案表达。
   顶部落档区在选了文件之后收成一行，把空间让给列表——列表才是这个页面的主体。 */
.drop.slim {
  height: auto;
  padding: 14px 16px;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  border-style: solid;
}
.drop.slim .prog { max-width: none; padding: 0; }
.bl-count {
  font-size: 12.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.bl-count:empty { display: none; }

.blist {
  margin-top: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.brow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.brow:last-child { border-bottom: 0; }
.brow .bdot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
}
.brow .bname {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.brow .bmeta {
  flex: 0 1 auto;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-3);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.brow .bstat {
  flex: none;
  min-width: 56px;
  text-align: right;
  color: var(--text-2);
  font-size: 12.5px;
}
.brow .btn-link, .brow a.btn-link { flex: none; }

.brow[data-st="uploading"] .bdot,
.brow[data-st="parsing"] .bdot,
.brow[data-st="signing"] .bdot {
  background: var(--primary);
  animation: bpulse 1.1s ease-in-out infinite;
}
.brow[data-st="ready"] .bdot { background: var(--primary); }
.brow[data-st="ok"] .bdot { background: var(--ok); }
.brow[data-st="fail"] .bdot,
.brow[data-st="rejected"] .bdot { background: var(--err); }
.brow[data-st="fail"] .bmeta,
.brow[data-st="rejected"] .bmeta { color: var(--err); }
@keyframes bpulse { 50% { opacity: .3; } }

/* .btn 是 inline-flex，会盖掉 hidden 的 display:none */
#btnZip { text-decoration: none; }
.brow[data-st="queued"] .bdot {
  background: var(--text-3);
  animation: bpulse 1.1s ease-in-out infinite;
}

/* ---------- 签章库分页 ----------
   数字用表格数字体对齐；禁用按钮靠 disabled 样式表达，不写说明文字 */
.pager {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: flex-end;
  padding: 10px 2px 2px;
  font-size: 12.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.pager select {
  width: auto;
  padding: 4px 6px;
  font-size: 12.5px;
}
.pager .btn-link { font-size: 12.5px; padding: 2px 4px; }
.pager .btn-link:disabled {
  color: var(--text-3);
  cursor: not-allowed;
  opacity: .6;
}
.pager .pg-num { min-width: 44px; text-align: center; }

/* ---------- 上传清单 ---------- */
.flist {
  margin-top: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.flist[hidden] { display: none; }
.flist-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.flist-head h2 { margin: 0; font-size: 14px; font-weight: 700; }
.flist-head select { width: auto; padding: 4px 8px; font-size: 12.5px; }
.flist table.grid td, .flist table.grid th { font-size: 13px; }

/* 清单底部那一行：最近 5 份时说明其余在哪、给展开入口；展开后只剩"收起"。
   与分页条同为右对齐的次要信息，不抢表格的注意力。 */
.flist-more {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 10px 2px 2px;
  font-size: 12.5px;
  color: var(--text-2);
}
.flist-more[hidden] { display: none; }
.flist-more .btn-link { font-size: 12.5px; padding: 2px 4px; }

/* ---------- 危险操作确认弹窗 ----------
   后果逐条列出，确认键用红色——按下去之前必须看得见代价 */
.btn-danger {
  background: var(--err);
  border-color: var(--err);
  color: #fff;
}
.btn-danger:hover { filter: brightness(1.08); }
.cfm-line { margin: 6px 0; font-size: 13.5px; line-height: 1.5; color: var(--text-2); }
.cfm-line strong { color: var(--text); }

/* ---------- 移动端适配 ----------
   手机竖屏是"查看"场景：单列布局、表格横向可滑、导航可滑 */
@media (max-width: 820px) {
  .work { grid-template-columns: 1fr; }
  .card { padding: 14px; overflow-x: auto; }
  .card table.grid { min-width: 560px; }
  .card-head { flex-wrap: wrap; row-gap: 8px; }
  .filters { flex-wrap: wrap; }
  .filters input[type=month],
  .filters input[type=date] { width: 145px; }
  .filters input#fName { flex: 1 1 120px; width: auto; }
  /* 操作列窄屏下不许折行：「打开/已签章」竖着排没法看 */
  .grid td.act, .flist td:last-child { white-space: nowrap; }
  /* 顶栏两行：「品牌 + 用户」一行，导航独占一行可横滑。
     手机竖屏放不下品牌 + 4 项导航 + 改密/退出，压成一行必有一方被挤没 */
  .topbar { height: auto; padding: 8px 12px; gap: 6px 10px; flex-wrap: wrap; }
  .topbar .brand { font-size: 14px; white-space: nowrap; flex: 0 1 auto; }
  .topbar nav {
    order: 3; flex: 1 1 100%;
    margin: 0 -12px; padding: 0 12px;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav a { white-space: nowrap; padding: 7px 10px; font-size: 13px; }
  .topbar .who { margin-left: auto; gap: 8px; font-size: 12.5px; white-space: nowrap; }
  .dialog { max-width: none; width: calc(100vw - 24px); }
  .drop { height: 168px; }
  .pager { flex-wrap: wrap; row-gap: 8px; }
  .flist { padding: 12px; overflow-x: auto; }
  .flist table.grid { min-width: 600px; }
  .viewer-bar { flex-wrap: wrap; row-gap: 6px; }
  /* 人员库表格原来每列写死宽度（合计 790px），手机上首屏只看得见前四列。
     窄屏改自动列宽：内容决定宽度，能多露一列是一列 */
  #tbl { table-layout: auto; min-width: 0; }
  #tbl th { width: auto !important; }
  #tbl th, #tbl td { white-space: nowrap; }
  #tbl td:nth-child(2) {
    white-space: normal; min-width: 96px;
    /* 「检测中心-分析」在窄列里会断成四行；允许在连字符后断行，最多两行 */
    word-break: keep-all; overflow-wrap: anywhere;
  }
  /* 成品预览：手机上遮罩不留边，页面能多宽就多宽 */
  .mask.sp { padding: 0; align-items: stretch; }
  .sp-shell { border-radius: 0; max-width: none; }
  /* 工具条两行：文件名独占一行（不再截成「仪器设备使…」），翻页与打印/下载在下一行 */
  .sp-bar { flex-wrap: wrap; row-gap: 8px; padding: 8px 10px; }
  .sp-name { order: -1; flex: 1 1 100%; max-width: none; font-size: 12.5px; }
  .sp-grow { display: none; }
  .sp-bar .btn { padding: 7px 12px; }
  .sp-doc { padding: 8px; }
}

@media (max-width: 480px) {
  .page { padding: 10px; }
  .card { padding: 12px 10px; }
  .card-head h2 { font-size: 15px; }
  .topbar .brand { font-size: 13px; }
  .btn { padding: 8px 12px; }
  .grid th, .grid td { padding: 7px 8px; font-size: 12.5px; }
  .side { padding: 12px; }
}

/* 通用：内容不许折行（时间、账号、编号这类短字段） */
.nowrap { white-space: nowrap; }

/* ---------- 可搜索下拉（common.js 的 searchSelect） ----------
 * 外观要与它替换掉的 <select> 一模一样，否则"换个控件"会变成"页面变了个样"。
 * 高度、圆角、边框、内边距全部对齐 .field select / 原生 select 的观感。
 * 候选层用 absolute + z-index，盖在页脚之上的任何内容上——签名人列表可能
 * 有几十条，展开时不能把"签章"按钮顶下去。 */
.ss { position: relative; }
.ss-input {
  width: 100%;
  height: 35px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.3;
}
.ss-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-l);
}
.ss-input::placeholder { color: var(--text-2); }
.ss-pop {
  position: absolute;
  z-index: 60;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 268px;
  overflow-y: auto;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.ss-opt {
  padding: 8px 10px;
  border-radius: 5px;
  font-size: 13.5px;
  color: var(--text);
  cursor: pointer;
  /* 姓名短，不做省略号；这里只防极端长名把弹层撑宽 */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 高亮同时用底色和左侧短竖条：只靠底色在浅色屏上看不出焦点在哪 */
.ss-opt.on {
  background: var(--primary-l);
  box-shadow: inset 3px 0 0 var(--primary);
}
.ss-opt:hover { background: var(--primary-l); }
.ss-empty {
  padding: 10px;
  font-size: 13px;
  color: var(--text-2);
  text-align: center;
}

/* 侧栏（.side）里宽度有限，弹层允许比输入框更宽会溢出卡片，这里夹住 */
.side .ss-pop { max-height: 220px; }
