/* 古籍数字化工作记录系统 · 网页版样式（移动优先） */
:root {
  --ink: #1f2937;
  --ink-2: #4b5563;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f5f7fa;
  --card: #ffffff;
  --brand: #1d4ed8;
  --brand-soft: #eff4ff;
  --ok: #15803d;
  --ok-bg: #e7f6ec;
  --warn: #b45309;
  --warn-bg: #fff6e5;
  --bad: #b91c1c;
  --bad-bg: #fdecec;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

/* ---------------------------------------------------------------- 顶栏与导航 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 10px 14px;
  background: var(--brand); color: #fff;
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 600; }
.logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 7px;
  background: rgba(255,255,255,.22); font-size: 14px;
}
.brand-text { font-size: 15px; }
.who { display: flex; align-items: center; gap: 8px; }
.chip {
  background: rgba(255,255,255,.18); border-radius: 999px;
  padding: 2px 10px; font-size: 12px; display: inline-flex; gap: 6px; align-items: center;
}
.chip em { font-style: normal; opacity: .8; }
.linkbtn {
  background: none; border: 0; color: #fff; opacity: .9;
  font-size: 13px; cursor: pointer; padding: 4px 6px;
}
.linkbtn:hover { opacity: 1; text-decoration: underline; }

.mainnav {
  display: flex; gap: 4px; padding: 8px 12px 0;
  background: var(--brand); overflow-x: auto; white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}
.mainnav a {
  color: rgba(255,255,255,.82); text-decoration: none;
  padding: 7px 12px; border-radius: 8px 8px 0 0; font-size: 14px;
}
.mainnav a.on, .mainnav a:hover { background: var(--bg); color: var(--brand); font-weight: 600; }
.navsep { width: 1px; background: rgba(255,255,255,.3); margin: 6px 6px; }

/* 内容区：桌面端尽量铺开（报表宽，不靠横向滚动），手机端仍是满宽单列 */
.wrap { max-width: 1760px; margin: 0 auto; padding: 16px 18px 96px; }
@media (min-width: 1200px) {
  .wrap { padding: 18px 26px 96px; }
}
@media (min-width: 1920px) {
  .wrap { max-width: 100%; padding: 20px 32px 100px; }
}
/* 纯文字页（说明、帮助）用这个包一层，避免一行拉太长不好读 */
.wrap-narrow { max-width: 860px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 28px; }

/* 手机底部导航 */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; text-align: center; padding: 8px 0 6px;
  color: var(--muted); text-decoration: none; font-size: 12px;
}
.tabbar a span { display: block; font-size: 18px; line-height: 1.2; }
.tabbar a.on { color: var(--brand); font-weight: 600; }

/* ---------------------------------------------------------------- 通用块 */
h1 { font-size: 20px; margin: 4px 0 14px; }
h2 { font-size: 16px; margin: 22px 0 10px; }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--ink-2); }
a { color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
}
.card > h2:first-child, .card > h1:first-child { margin-top: 0; }
.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.cols-6 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

/* 统计卡 */
.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px;
}
.stat .label { font-size: 13px; color: var(--muted); }
.stat .value { font-size: 20px; font-weight: 700; margin-top: 2px; }
.stat .value small { font-size: 13px; font-weight: 400; color: var(--ink-2); }
.stat.alert { border-color: #f3c2c2; background: var(--bad-bg); }

.flash {
  border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px;
  white-space: pre-wrap;
}
.flash.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #bfe3cb; }
.flash.err { background: var(--bad-bg); color: var(--bad); border: 1px solid #f0c2c2; }
.banner {
  background: var(--warn-bg); border: 1px solid #f0d8a8; color: var(--warn);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 14px;
}

/* 表格 */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { border: 1px solid var(--line); padding: 7px 9px; text-align: left; vertical-align: top; }
th { background: #f8fafc; font-weight: 600; white-space: nowrap; }
tbody tr:nth-child(even) td { background: #fcfdfe; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* 手机号/函号这类长串自动折行，别把整张表撑宽 */
td { word-break: break-word; }
/* 宽屏下把表格压紧一点，一屏能放下更多列 */
@media (min-width: 1400px) {
  table { font-size: 13.5px; }
  th, td { padding: 6px 8px; }
}

/* 批次 × 工序 矩阵：批次会越来越多，一切以「紧凑、一行一批次」为准 */
table.matrix { font-size: 12.5px; }
table.matrix th, table.matrix td {
  text-align: center; white-space: nowrap;
  font-size: 12.5px; padding: 3px 6px; line-height: 1.55;
  font-variant-numeric: tabular-nums;
}
table.matrix thead th { font-size: 12px; background: #eef2f7; }
table.matrix td.done { background: #dcfce7; color: #166534; }
table.matrix td.part { background: #fff7e6; color: #b45309; }
table.matrix td.none { background: #f8fafc; color: #94a3b8; }
table.matrix td.batchname { background: #fff; font-weight: 600; text-align: left; }
table.matrix td.rangename { background: #fff; text-align: left; font-family: ui-monospace, Consolas, monospace; color: var(--ink-2); }
table.matrix tbody tr:nth-child(even) td.batchname,
table.matrix tbody tr:nth-child(even) td.rangename { background: #fff; }
/* 手机横向滚动时把批次列钉在左边，滚到右边也知道在看哪一批 */
table.matrix thead th:first-child { position: sticky; left: 0; z-index: 3; }
table.matrix tbody td:first-child { position: sticky; left: 0; z-index: 2; box-shadow: 1px 0 0 var(--line); }
.matrix-summary {
  background: #fef9c3; border: 1px solid #f0e2a8; padding: 10px 12px;
  border-radius: 10px; font-size: 14px; margin-top: 10px;
}

/* 紧凑表格：用于会一直变长的批次列表 */
table.compact { font-size: 13px; }
table.compact th, table.compact td { padding: 4px 8px; white-space: nowrap; vertical-align: middle; }
table.compact thead th { font-size: 12.5px; }
table.compact td.num, table.compact th.num { font-variant-numeric: tabular-nums; }

/* 行内迷你进度条（一行放得下，替代原来的 SVG 条）
   列里本来就有很多空白，条子做长一点更好读；窄屏再收回来，不把表格顶宽。 */
.minibar {
  display: inline-block; width: 92px; height: 6px; border-radius: 4px;
  background: #e8eef7; overflow: hidden; vertical-align: middle; margin-left: 6px;
}
.minibar > i { display: block; height: 100%; border-radius: 4px; background: var(--brand); }
.minibar > i.full { background: #16a34a; }
.minibar > i.zero { background: #cbd5e1; }

/* 图表容器：容器窄就横向滚动（柱子保持清晰）；容器宽时由 charts.js 放到 data-maxw，
   再宽的部分留白——图左右居中，日期少的时候不会拉成一排稀柱子。 */
.chartbox { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chartbox > svg { display: block; margin: 0 auto; }

/* 进度条长度跟着屏幕走：大屏列更宽就再长一些，手机窄屏收短，别把表格顶出屏幕 */
@media (min-width: 1600px) { .minibar { width: 118px; } }
@media (max-width: 760px) { .minibar { width: 64px; } }

/* 批次范围快捷选项 */
.quickrange { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 13px; }
.quickrange a, .quickrange .cur {
  border: 1px solid #cbd5e1; border-radius: 999px; padding: 2px 10px;
  text-decoration: none; color: var(--ink-2); background: #fff;
}
.quickrange a:hover { border-color: var(--brand); color: var(--brand); }
.quickrange .cur { background: var(--brand); border-color: var(--brand); color: #fff; }

/* 表单 */
label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid #cbd5e1; border-radius: 9px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--brand); }
textarea { min-height: 76px; resize: vertical; }
.field { margin-bottom: 12px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.checkline { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.checkline input { width: auto; }
.formgrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; font-size: 15px; font-family: inherit;
  cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: #fff; color: var(--brand); }
.btn.gray { background: #fff; color: var(--ink-2); border-color: #cbd5e1; }
.btn.ok { background: var(--ok); border-color: var(--ok); }
.btn.bad { background: var(--bad); border-color: var(--bad); }
.btn.warn { background: #d97706; border-color: #d97706; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* 填写页的工作行 */
.workrow {
  display: grid; gap: 8px; grid-template-columns: 1fr 1.6fr auto;
  align-items: end; padding: 10px; border: 1px solid var(--line);
  border-radius: 10px; margin-bottom: 8px; background: #fcfdff;
}
.workrow .rm { white-space: nowrap; }
@media (max-width: 620px) {
  .workrow { grid-template-columns: 1fr; }
}

/* 预览框 */
.preview {
  background: var(--brand-soft); border: 1px solid #cddffb;
  border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-top: 10px;
}
.preview .sum { font-weight: 600; }
.conflicts { color: var(--bad); }
.conflicts ul { margin: 6px 0 0 18px; padding: 0; }

/* 徽章 */
.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; border: 1px solid transparent; white-space: nowrap;
}
.badge.draft { background: #f1f5f9; color: var(--ink-2); border-color: #dbe2ea; }
.badge.pending { background: var(--warn-bg); color: var(--warn); border-color: #f0d8a8; }
.badge.approved { background: var(--ok-bg); color: var(--ok); border-color: #bfe3cb; }
.badge.rejected { background: var(--bad-bg); color: var(--bad); border-color: #f0c2c2; }
.badge.exc { background: #fef3c7; color: #92400e; border-color: #f2d99b; }

/* 登录页 */
.loginwrap { max-width: 380px; margin: 8vh auto 0; padding: 0 16px; }
.loginwrap .brandhead { text-align: center; margin-bottom: 20px; }
.loginwrap .brandhead .logo {
  width: 52px; height: 52px; font-size: 26px; border-radius: 14px;
  background: var(--brand); color: #fff; margin: 0 auto 10px;
}
.loginwrap h1 { font-size: 19px; margin: 0; }
.loginwrap .sub { color: var(--muted); font-size: 13px; }

/* 记录行（我的记录 / 审核） */
.rec { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; margin-bottom: 8px; }
.rec .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.rec .item { font-weight: 600; }
.rec .codes { font-family: ui-monospace, Consolas, monospace; font-size: 13px; color: var(--ink-2); word-break: break-all; }
.rec .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.rec.rejected { border-color: #f0c2c2; background: #fffafa; }
.rec .reason { color: var(--bad); font-size: 13px; margin-top: 6px; }

.daygroup { margin-bottom: 18px; }
.daygroup > h3 { background: #eef2f7; padding: 6px 10px; border-radius: 8px; margin: 0 0 8px; color: var(--ink); }

/* 手机端预览（管理员在电脑上看员工界面） */
.previewwrap { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.phonebox { flex: 0 0 auto; }
.phonetitle { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.phone {
  background: #111827; border-radius: 32px; padding: 9px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .22);
  display: inline-block;
}
.phone iframe { display: block; border: 0; border-radius: 24px; background: #fff; }
.phonefoot { text-align: center; margin-top: 6px; }

.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 14px; }
.help { font-size: 13px; color: var(--ink-2); background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.help code { background: #eef2f7; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
pre.fmt { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 10px; overflow-x: auto; font-size: 13px; line-height: 1.7; }

@media (max-width: 620px) {
  .wrap { padding: 12px 10px 90px; }
  h1 { font-size: 18px; }
  .stat .value { font-size: 18px; }
}
