:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --line: #e4e9f2;
  --line-2: #eef2f8;
  --brand: #2f6bff;
  --brand-d: #1e50d8;
  --text: #1b2431;
  --muted: #6b7688;
  --ok: #0f9d76;
  --warn: #d98200;
  --err: #d93025;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 30, 54, .04), 0 8px 24px rgba(16, 30, 54, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  height: 58px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px; padding: 0 22px;
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; }
.brand .dot {
  width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, #2f6bff, #6f9bff);
  color: #fff; display: grid; place-items: center; font-size: 14px;
}
.brand small { font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 4px; }
.topbar .spacer { flex: 1; }
.nav { display: flex; gap: 4px; }
.nav a {
  padding: 7px 14px; border-radius: 8px; color: var(--muted); font-weight: 550;
}
.nav a.on, .nav a:hover { background: #eef3ff; color: var(--brand); text-decoration: none; }
.nav a .badge {
  display: inline-block; min-width: 17px; height: 17px; line-height: 17px; padding: 0 5px;
  background: var(--err); color: #fff; border-radius: 9px; font-size: 11px; margin-left: 5px; text-align: center;
}
.userchip {
  display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 999px;
  background: #f2f5fb; font-size: 13px;
}
.userchip .av {
  width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 12px;
}
.userchip .role { color: var(--muted); font-size: 12px; }

/* ---------------- 布局 ---------------- */
.wrap { max-width: 1360px; margin: 0 auto; padding: 22px; }
.wrap.wide { max-width: 1600px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 18px; align-items: start; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.card + .card { margin-top: 16px; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-h h3 { font-size: 15px; }
.card-h .sub { color: var(--muted); font-size: 12px; }
.card-h .spacer { flex: 1; }

/* ---------------- 统计 ---------------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat .k { color: var(--muted); font-size: 12.5px; }
.stat .v { font-size: 25px; font-weight: 700; margin-top: 4px; letter-spacing: -.4px; }
.stat .v small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }

/* ---------------- 单据类型卡片 ---------------- */
.types { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 14px; }
.type-card {
  position: relative; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 16px 14px; cursor: pointer; transition: .16s; overflow: hidden;
}
.type-card:hover { border-color: #c9d8ff; transform: translateY(-2px); box-shadow: 0 12px 28px rgba(47, 107, 255, .12); }
.type-card .ico {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  font-size: 19px; margin-bottom: 10px;
}
.type-card h4 { font-size: 14.5px; margin-bottom: 4px; }
.type-card p { margin: 0; color: var(--muted); font-size: 12.5px; min-height: 38px; }
.type-card .flow { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 4px; }
.type-card .flow span {
  font-size: 11px; padding: 1px 7px; border-radius: 5px; background: #f1f4fa; color: #55617a;
}
.type-card .flow span:not(:last-child)::after { content: ""; }
.type-card .go {
  position: absolute; right: 14px; top: 14px; font-size: 12px; color: var(--brand);
  opacity: 0; transition: .16s;
}
.type-card:hover .go { opacity: 1; }

/* ---------------- 表格 ---------------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); text-align: left; }
table.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; background: #fafbfe; white-space: nowrap; }
table.tbl tbody tr:hover { background: #f8faff; }
table.tbl tr.clickable { cursor: pointer; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 34px 0; font-size: 13px; }

/* ---------------- 徽章 ---------------- */
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600;
  line-height: 19px; white-space: nowrap;
}
.tag.gray { background: #eef1f6; color: #5c667a; }
.tag.blue { background: #e8efff; color: var(--brand); }
.tag.green { background: #e3f6ef; color: var(--ok); }
.tag.red { background: #fde9e7; color: var(--err); }
.tag.orange { background: #fdf1e0; color: var(--warn); }
.tag.gold { background: #fdf6e3; color: #a1740a; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 15px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: .14s; font-family: inherit;
}
.btn:hover { border-color: #c6d2e6; background: #fafcff; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); border-color: var(--brand-d); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover { filter: brightness(.94); }
.btn.danger { background: #fff; border-color: #f3c7c3; color: var(--err); }
.btn.danger:hover { background: #fdf1f0; }
.btn.ai { background: linear-gradient(135deg, #6a5bff, #2f6bff); border: none; color: #fff; }
.btn.ai:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- 表单 ---------------- */
.section-title {
  font-size: 13px; font-weight: 700; color: #33415c; margin: 18px 0 10px;
  padding-left: 9px; border-left: 3px solid var(--brand); line-height: 1.1;
}
.section-title:first-child { margin-top: 0; }
.fgrid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 10px 14px; }
.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fld label { font-size: 12px; color: var(--muted); font-weight: 600; }
.fld input, .fld select, .fld textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
  font: inherit; font-size: 13px; color: var(--text); background: #fff; transition: .14s;
}
.fld input:focus, .fld select:focus, .fld textarea:focus {
  outline: none; border-color: #a9c0ff; box-shadow: 0 0 0 3px rgba(47, 107, 255, .1);
}
.fld input[readonly], .fld textarea[readonly], .fld select:disabled {
  background: #f6f8fc; color: #4c5a72;
}
.fld textarea { resize: vertical; min-height: 62px; }
.fld .hint { font-size: 11px; color: var(--muted); }
.fld.num input { text-align: right; font-variant-numeric: tabular-nums; }

/* 金额数字格 */
.money-grid { display: flex; gap: 0; }
.money-grid .cell {
  flex: 1; text-align: center; border: 1px solid var(--line); border-right: none;
  padding: 5px 0; font-variant-numeric: tabular-nums; background: #fff;
}
.money-grid .cell:first-child { border-radius: 8px 0 0 8px; }
.money-grid .cell:last-child { border-right: 1px solid var(--line); border-radius: 0 8px 8px 0; }
.money-grid .cell b { display: block; font-size: 13px; min-height: 19px; }
.money-grid .cell i { font-style: normal; font-size: 10px; color: var(--muted); white-space: nowrap; }
.money-grid .cell:first-child { flex: 1.25; }

.tbl-note { margin-top: 6px; font-size: 12px; color: var(--muted); }
.tbl-note b { color: var(--text); }

/* 可编辑表格 */
table.edit { width: 100%; border-collapse: collapse; font-size: 13px; }
table.edit th, table.edit td { border: 1px solid var(--line); padding: 0; text-align: left; }
table.edit th {
  background: #f7f9fd; font-size: 12px; color: #445068; padding: 7px 8px; font-weight: 600;
  white-space: nowrap; text-align: center;
}
table.edit td input, table.edit td select {
  width: 100%; border: none; padding: 7px 8px; font: inherit; font-size: 13px; background: transparent;
  color: var(--text);
}
table.edit td input:focus, table.edit td select:focus { outline: 2px solid #bcd0ff; outline-offset: -2px; }
table.edit td.num input { text-align: right; font-variant-numeric: tabular-nums; }
table.edit td.calc { text-align: right; padding: 7px 8px; background: #f8fafd; font-variant-numeric: tabular-nums; color: #33415c; font-weight: 600; }
table.edit tfoot td { background: #f7f9fd; font-weight: 700; padding: 7px 8px; }
table.edit tfoot td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.edit .rowdel {
  border: none; background: transparent; color: #b9c2d2; cursor: pointer; font-size: 15px; padding: 0 6px;
}
table.edit .rowdel:hover { color: var(--err); }

/* 合计条 */
.total-bar {
  margin-top: 14px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: linear-gradient(90deg, #f2f6ff, #fbfcff); border: 1px solid #dde6fb;
  border-radius: 10px; padding: 12px 16px;
}
.total-bar .lb { color: var(--muted); font-size: 12.5px; }
.total-bar .amt { font-size: 22px; font-weight: 750; color: var(--brand); letter-spacing: -.5px; }
.total-bar .upper { font-size: 12.5px; color: #55617a; }
.total-bar .spacer { flex: 1; }

/* ---------------- 上传 / 票据 ---------------- */
.drop {
  border: 1.5px dashed #c8d6f5; border-radius: 12px; background: #fafcff;
  padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: .15s;
}
.drop:hover, .drop.over { border-color: var(--brand); background: #f2f7ff; }
.drop b { color: var(--brand); }
.drop p { margin: 6px 0 0; font-size: 12px; }

.thumbs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.thumb {
  position: relative; width: 96px; height: 96px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); background: #f7f9fd; cursor: pointer;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .pdf { display: grid; place-items: center; height: 100%; color: #b8443a; font-weight: 700; font-size: 12px; }
.thumb .st {
  position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; text-align: center; padding: 1px 0;
  background: rgba(12, 20, 34, .62); color: #fff;
}
.thumb .del {
  position: absolute; right: 3px; top: 3px; width: 17px; height: 17px; border-radius: 50%;
  background: rgba(12, 20, 34, .6); color: #fff; border: none; cursor: pointer; font-size: 11px; line-height: 1;
}
.thumb .del:hover { background: var(--err); }

/* ---------------- 审批流程 ---------------- */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: ""; position: absolute; left: 8px; top: 6px; bottom: 12px; width: 2px; background: var(--line);
}
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item .dot {
  position: absolute; left: -24px; top: 3px; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line); background: #fff; display: grid; place-items: center;
  font-size: 10px; color: #fff;
}
.tl-item.approved .dot { background: var(--ok); border-color: var(--ok); }
.tl-item.pending .dot { background: var(--brand); border-color: var(--brand); box-shadow: 0 0 0 4px rgba(47, 107, 255, .14); }
.tl-item.rejected .dot { background: var(--err); border-color: var(--err); }
.tl-item .t { font-weight: 650; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.tl-item .m { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tl-item .cm {
  margin-top: 6px; background: #f7f9fd; border: 1px solid var(--line-2); border-radius: 8px;
  padding: 6px 10px; font-size: 12.5px; color: #40506b;
}
.tl-item.rejected .cm { background: #fdf3f2; border-color: #f6d9d6; color: #a5231a; }

/* ---------------- 校验清单 ---------------- */
.issues { display: flex; flex-direction: column; gap: 8px; }
.issue {
  display: flex; gap: 8px; padding: 9px 11px; border-radius: 9px; font-size: 12.5px;
  border: 1px solid transparent; line-height: 1.5;
}
.issue.error { background: #fdf3f2; border-color: #f6d9d6; color: #8f261c; }
.issue.warn { background: #fef8ee; border-color: #f7e4c3; color: #8a5a05; }
.issue.ok { background: #eefaf4; border-color: #cceadd; color: #0b6c52; }
.issue .ic { flex: 0 0 auto; font-weight: 700; }

/* ---------------- 弹层 ---------------- */
.mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .42); display: none;
  align-items: center; justify-content: center; z-index: 90; padding: 20px;
}
.mask.on { display: flex; }
.modal {
  background: #fff; border-radius: 14px; width: 460px; max-width: 100%; padding: 20px;
  box-shadow: 0 24px 60px rgba(9, 18, 36, .28);
}
.modal h3 { font-size: 15.5px; margin-bottom: 6px; }
.modal p.sub { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }
.modal textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font: inherit;
  font-size: 13px; min-height: 88px; resize: vertical;
}
.modal textarea:focus { outline: none; border-color: #a9c0ff; box-shadow: 0 0 0 3px rgba(47, 107, 255, .1); }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ---------------- 提示 ---------------- */
#toast { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #16233a; color: #fff; padding: 9px 16px; border-radius: 9px; font-size: 13px;
  box-shadow: 0 12px 30px rgba(9, 18, 36, .3); animation: tin .2s ease-out;
  max-width: 620px; line-height: 1.5;
}
.toast.ok { background: #0f7d5f; }
.toast.err { background: #b7291f; }
.toast.warn { background: #9a6a05; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------------- 登录 ---------------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(1100px 520px at 12% -10%, #dbe6ff 0%, transparent 60%),
              radial-gradient(900px 460px at 96% 8%, #e3f7f0 0%, transparent 55%), var(--bg);
}
.login-card {
  width: 396px; background: #fff; border-radius: 16px; padding: 30px;
  box-shadow: 0 24px 60px rgba(16, 30, 54, .13); border: 1px solid var(--line);
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card .s { color: var(--muted); font-size: 12.5px; margin-bottom: 22px; }
.login-card .fld { margin-bottom: 13px; }
.login-card .btn { width: 100%; height: 40px; font-size: 14px; margin-top: 6px; }
.demo { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 12px; }
.demo .t { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.demo .row { display: flex; flex-wrap: wrap; gap: 6px; }
.demo .usr {
  font-size: 12px; padding: 3px 9px; border-radius: 999px; background: #f2f5fb; cursor: pointer;
  border: 1px solid transparent;
}
.demo .usr:hover { border-color: #c9d8ff; color: var(--brand); }

/* ---------------- 打印 ---------------- */
.paper {
  background: #fff; width: 210mm; min-height: 297mm; margin: 0 auto; padding: 12mm 12mm;
  box-shadow: 0 6px 30px rgba(16, 30, 54, .12);
}
@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .paper { box-shadow: none; margin: 0; width: auto; min-height: auto; padding: 0; }
  .print-page { page-break-after: always; }
}

/* 打印单据排版 */
.form-doc { border: 1.4px solid #111; }
.form-doc .fd-title {
  text-align: center; font-size: 19px; font-weight: 700; letter-spacing: 6px; padding: 8px 0 6px;
  border-bottom: 1.2px solid #111;
}
.form-doc .fd-head { display: flex; border-bottom: 1px solid #111; font-size: 12px; }
.form-doc .fd-head > div { padding: 5px 8px; border-right: 1px solid #111; flex: 1; }
.form-doc .fd-head > div:last-child { border-right: none; }
.form-doc table { width: 100%; border-collapse: collapse; font-size: 12px; }
.form-doc table th, .form-doc table td {
  border: 1px solid #111; padding: 5px 6px; height: 26px; vertical-align: middle;
}
.form-doc table th { background: #f7f7f7; font-weight: 600; text-align: center; font-size: 11.5px; }
.form-doc table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.form-doc .row-kv { display: flex; border-bottom: 1px solid #111; font-size: 12px; min-height: 28px; }
.form-doc .row-kv > div {
  border-right: 1px solid #111; padding: 5px 8px; display: flex; gap: 6px; align-items: center;
}
.form-doc .row-kv > div:last-child { border-right: none; }
.form-doc .row-kv .k { color: #333; white-space: nowrap; }
.form-doc .row-kv .v { font-weight: 600; min-width: 40px; flex: 1; }
.form-doc .row-kv .v.eq { border-bottom: 1px solid #999; }
.form-doc .fd-total {
  display: flex; align-items: center; gap: 12px; padding: 7px 10px; font-size: 12.5px;
  border-bottom: 1px solid #111; font-weight: 600;
}
.form-doc .fd-total .u { font-weight: 600; letter-spacing: 1px; }
.form-doc .fd-sign {
  display: flex; flex-wrap: wrap; gap: 4px 22px; padding: 9px 10px; font-size: 12px; min-height: 34px;
}
.form-doc .fd-sign span { white-space: nowrap; }
.form-doc .fd-sign b { font-weight: 600; border-bottom: 1px solid #666; padding: 0 6px; min-width: 56px; display: inline-block; }
.form-doc .fd-foot { border-top: 1px solid #111; font-size: 11px; color: #444; padding: 4px 10px; display: flex; justify-content: space-between; }

.appr-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 10mm; }
.appr-table th, .appr-table td { border: 1px solid #111; padding: 6px 8px; }
.appr-table th { background: #f7f7f7; }
.foot-note { margin-top: 6mm; font-size: 11px; color: #555; display: flex; justify-content: space-between; }

.side-by-side { display: flex; gap: 16px; align-items: flex-start; }
.side-by-side > .left { flex: 1; min-width: 0; }
.side-by-side > .right { width: 372px; flex: 0 0 372px; }

@media (max-width: 1080px) {
  .grid-2, .side-by-side { grid-template-columns: 1fr; display: block; }
  .side-by-side > .right { width: auto; flex: none; margin-top: 16px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}


/* ---------------- 票据标注（步骤条 / 票据卡片） ---------------- */
.step { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; margin-right: 6px; vertical-align: 1px; }
.inv-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 10px; background: #fff; }
.inv-item:hover { border-color: #c8d6ee; box-shadow: 0 2px 8px rgba(47,107,255,.06); }
.inv-hd { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inv-hd .amt { color: var(--brand); font-size: 14px; }
.inv-bd { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.inv-fields { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.ifld { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--muted); }
.ifld input, .ifld select { height: 30px; border: 1px solid var(--line); border-radius: 7px; padding: 0 8px;
  font: inherit; font-size: 12.5px; color: var(--text); background: #fff; min-width: 108px; }
.ifld select { min-width: 210px; }
.ifld input:focus, .ifld select:focus { outline: 2px solid rgba(47,107,255,.18); border-color: var(--brand); }

/* ---------------- 发票池（上传→分配） ---------------- */
.pool-sel { height: 30px; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px;
  font: inherit; font-size: 12.5px; background: #fff; color: var(--text); }
.pool-tbl td { vertical-align: middle; }
.pool-tbl .rowdel { width: 22px; height: 22px; }
.pool-tbl select { height: 28px; border: 1px solid var(--line); border-radius: 7px; padding: 0 6px;
  font: inherit; font-size: 12.5px; background: #fff; min-width: 150px; }

.pool-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pool-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 340px;
  padding: 5px 8px 5px 10px; border-radius: 999px; background: #f2f5fb; border: 1px solid var(--line);
  font-size: 12px; color: var(--text); }
.pool-chip i { font-style: normal; color: var(--muted); font-size: 11.5px; }
.pool-chip.ok { background: #eefaf3; border-color: #c9ecdb; }
.pool-chip.fail { background: #fdeeee; border-color: #f3cfcf; }
.pool-chip.running { background: #eef4ff; border-color: #cddefc; }
.pool-chip.done { background: #eefaf3; border-color: #c9ecdb; }
.pool-chip.wait { background: #f7f8fb; }
.pool-chip .mini { border: none; background: #fff; border-radius: 999px; padding: 1px 7px;
  font-size: 11px; color: var(--brand); cursor: pointer; border: 1px solid var(--line); }
.pool-chip .mini:hover { background: var(--brand); color: #fff; }

/* ---------------- 票据缩略图 + 悬停放大 + 灯箱 ---------------- */
.inv-thumb { width: 58px; height: 58px; flex: 0 0 auto; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line); background: #f7f9fd; cursor: zoom-in; position: relative; }
.inv-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.inv-thumb .pdf { display: grid; place-items: center; height: 100%; color: #b8443a; font-weight: 700; font-size: 11px; }
.inv-thumb:hover { border-color: var(--brand); box-shadow: 0 2px 10px rgba(47,107,255,.22); }
.orphan-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.orphan { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted);
  background: #fbfcfe; border: 1px dashed var(--line); border-radius: 8px; padding: 6px 10px; }
.orphan b { color: var(--text); font-weight: 600; }
#zoomTip { position: fixed; z-index: 9999; display: none; padding: 6px; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 14px 38px rgba(16,24,40,.20);
  pointer-events: none; }
#zoomTip img { display: block; max-width: min(640px, 44vw); max-height: min(700px, 72vh);
  border-radius: 6px; background: #fff; }
#zoomTip .t { font-size: 12px; color: var(--muted); padding: 4px 2px 1px; }
#lightbox { position: fixed; inset: 0; z-index: 10000; display: none; background: rgba(8,12,22,.95); }
#lightbox.on { display: flex; flex-direction: column; }
.lb-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; color: #fff; font-size: 13px;
  background: rgba(0,0,0,.42); }
.lb-bar span { opacity: .85; }
.lb-x { margin-left: auto; background: rgba(255,255,255,.14); border: none; color: #fff; width: 32px;
  height: 32px; border-radius: 8px; font-size: 18px; cursor: pointer; line-height: 1; }
.lb-x:hover { background: rgba(255,255,255,.26); }
.lb-body { flex: 1; display: grid; place-items: center; padding: 0 16px 20px; overflow: auto; }
.lb-body img { max-width: 94vw; max-height: 86vh; background: #fff; border-radius: 6px; }
.lb-body iframe { width: min(1100px, 94vw); height: 86vh; border: none; background: #fff; border-radius: 6px; }

/* ---------------- 员工基础资料 ---------------- */
.emp-form { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: #fbfcfe; }
.emp-form .section-title { margin-top: 0; }
.emp-off td { color: #9aa4b2; }

/* ---------------- 顶部抬头固定（不随滚动移动） ---------------- */
#topbar { position: sticky; top: 0; z-index: 40; }
#topbar .topbar { position: relative; top: auto;
  box-shadow: 0 1px 0 var(--line), 0 6px 18px rgba(16,24,40,.05); }

/* ---------------- 设置页标签 ---------------- */
.tabs { display: flex; gap: 8px; margin-top: 12px; }
.tabs .tab { border: 1px solid var(--line); background: #fff; color: var(--text);
  height: 32px; padding: 0 14px; border-radius: 8px; font: inherit; font-size: 13px; cursor: pointer; }
.tabs .tab:hover { border-color: var(--brand); color: var(--brand); }
.tabs .tab.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* ---------------- 工作台看板 ---------------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 14px; }
.kpi { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: #fbfcfe; }
.kpi .k { font-size: 12.5px; color: var(--muted); }
.kpi .v { font-size: 24px; font-weight: 700; color: var(--text); margin: 6px 0 2px;
  font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1080px) { .kpis { grid-template-columns: repeat(2, 1fr); } .grid2 { grid-template-columns: 1fr; } }
.hbars { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.hbar { display: grid; grid-template-columns: 120px 1fr 132px; align-items: center; gap: 10px; font-size: 12.5px; }
.hbar .nm { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 10px; background: #f0f3f9; border-radius: 999px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #2f6bff, #8fb4ff); }
.hbar .val { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.hbar .val em { font-style: normal; color: var(--muted); margin-left: 6px; font-size: 11.5px; }
#trend svg { display: block; }

.grid2.solo { grid-template-columns: 1fr; }

/* ---------------- 部门设置 ---------------- */
.dept-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.dept-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 9px; background: #fbfcfe; font-size: 13px; }
.dept-row:hover { border-color: #c8d6ee; background: #fff; }
.dept-row .ico { color: #9aa4b2; font-size: 12px; width: 12px; }
.dept-row b { font-weight: 600; }

/* ---------------- 部门：拖拽 / 批量移动 ---------------- */
.dept-bar { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; }
.dept-row .grip { color: #b6bfcc; cursor: grab; font-size: 13px; user-select: none; }
.dept-row.dragging { opacity: .45; }
.dept-row.over { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(47,107,255,.15); }
.dept-ck { width: 14px; height: 14px; cursor: pointer; }

/* ---------------- 逐份识别进度 ---------------- */
.up-tip { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 8px 12px;
  background: #f0f6ff; border: 1px solid #cddefc; border-radius: 9px; font-size: 12.5px; color: #2b4a7d; }
.up-tip b { font-weight: 600; }
.drop.busy { opacity: .55; pointer-events: none; }
.spin { width: 13px; height: 13px; border: 2px solid #b9cdf3; border-top-color: #2f6bff;
  border-radius: 50%; animation: spin .8s linear infinite; flex: 0 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 页内确认框 + 危险按钮 ---------------- */
.btn.danger { color: #d93025; border-color: #f0c9c6; }
.btn.danger:hover { background: #fdeeee; border-color: #e9a9a3; }
#askBox { position: fixed; inset: 0; z-index: 10001; display: none;
  background: rgba(10,16,28,.55); place-items: center; }
#askBox.on { display: grid; }
.ask-card { background: #fff; border-radius: 12px; padding: 18px 20px 14px; width: min(420px, 90vw);
  box-shadow: 0 20px 50px rgba(16,24,40,.28); }
.ask-card .ask-t { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
#askMsg { font-size: 14px; line-height: 1.6; color: var(--text); }
.ask-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* 卡片内 spacer 生效，金额/缩略图/删除推到右侧 */
.spacer { flex: 1 1 auto; }
.inv-hd { flex-wrap: wrap; row-gap: 6px; }
.inv-hd .inv-thumb { margin-left: 2px; }

/* ---------------- 打印：纸张 A4/A5 × 纵向/横向（真实重排，不用 zoom） ---------------- */
/* .paper 宽度 = 该纸张的可打印宽度；打印时宽度交给 @page，高度由内容自然决定 */
body[data-paper="a4"][data-orient="portrait"] .paper { width: 186mm; min-height: 273mm; }
body[data-paper="a4"][data-orient="landscape"] .paper { width: 273mm; min-height: 186mm; }
body[data-paper="a5"][data-orient="portrait"] .paper { width: 142mm; min-height: 204mm; }
body[data-paper="a5"][data-orient="landscape"] .paper { width: 204mm; min-height: 142mm; }

/* A5：字号/内边距整体压到约 2/3，等价于原来的缩放，但能正确分页 */
body[data-paper="a5"] .form-doc .fd-title { font-size: 12.5px; letter-spacing: 3px; padding: 5px 0 4px; }
body[data-paper="a5"] .form-doc .fd-head { font-size: 8.5px; }
body[data-paper="a5"] .form-doc .fd-head > div,
body[data-paper="a5"] .form-doc .row-kv > div { padding: 3px 5px; }
body[data-paper="a5"] .form-doc .row-kv { font-size: 8.5px; min-height: 18px; }
body[data-paper="a5"] .form-doc table { font-size: 8.5px; }
body[data-paper="a5"] .form-doc table th { font-size: 8px; }
body[data-paper="a5"] .form-doc table th,
body[data-paper="a5"] .form-doc table td { padding: 2px 3px; height: 16px; width: auto !important; }
body[data-paper="a5"] .form-doc .fd-total { font-size: 9px; padding: 4px 6px; gap: 8px; }
body[data-paper="a5"] .form-doc .fd-sign { font-size: 8px; padding: 5px 6px; min-height: 20px; gap: 2px 12px; }
body[data-paper="a5"] .form-doc .fd-foot { font-size: 7.5px; padding: 3px 6px; }

@media print {
  .paper { width: auto !important; min-height: 0 !important; padding: 0 !important; }
}

/* 最后一页不要再多出空白页 */
.print-page:last-child { page-break-after: auto; break-after: auto; }

/* ---------------- 打印：票据影像图版（每页 1/2/4/6 张） ---------------- */
.att-head { font-size: 13px; font-weight: 700; margin-bottom: 3mm; display: flex; gap: 8px; }
.att-head .pg { font-weight: 400; color: #666; font-size: 11.5px; margin-left: auto; }
.att-grid { display: grid; gap: 3mm; align-content: start; }
.att-grid.n1 { grid-template-columns: 1fr; }
.att-grid.n2 { grid-template-columns: 1fr 1fr; }
.att-grid.n4 { grid-template-columns: 1fr 1fr; }
.att-grid.n6 { grid-template-columns: 1fr 1fr 1fr; }
.att-card { border: 1px solid #999; padding: 2mm; text-align: center; background: #fff;
  break-inside: avoid; page-break-inside: avoid; }
.att-card img { display: block; width: 100%; object-fit: contain; margin: 0 auto; }
.att-card .cap { font-size: 9.5px; color: #333; margin-top: 1.2mm; line-height: 1.3;
  overflow-wrap: break-word; word-break: normal; }
.att-grid.n6 .att-card .cap { font-size: 8.5px; }

/* 每张纸给影像卡一个「一页放得下」的高度（含标题与图注的余量） */
body[data-paper="a4"][data-orient="portrait"] .att-grid.n1 .att-card img { max-height: 218mm; }
body[data-paper="a4"][data-orient="portrait"] .att-grid.n2 .att-card img { max-height: 218mm; }
body[data-paper="a4"][data-orient="portrait"] .att-grid.n4 .att-card img { max-height: 116mm; }
body[data-paper="a4"][data-orient="portrait"] .att-grid.n6 .att-card img { max-height: 72mm; }

body[data-paper="a4"][data-orient="landscape"] .att-grid.n1 .att-card img { max-height: 140mm; }
body[data-paper="a4"][data-orient="landscape"] .att-grid.n2 .att-card img { max-height: 140mm; }
body[data-paper="a4"][data-orient="landscape"] .att-grid.n4 .att-card img { max-height: 70mm; }
body[data-paper="a4"][data-orient="landscape"] .att-grid.n6 .att-card img { max-height: 44mm; }

body[data-paper="a5"][data-orient="portrait"] .att-grid.n1 .att-card img { max-height: 158mm; }
body[data-paper="a5"][data-orient="portrait"] .att-grid.n2 .att-card img { max-height: 158mm; }
body[data-paper="a5"][data-orient="portrait"] .att-grid.n4 .att-card img { max-height: 84mm; }
body[data-paper="a5"][data-orient="portrait"] .att-grid.n6 .att-card img { max-height: 52mm; }

body[data-paper="a5"][data-orient="landscape"] .att-grid.n1 .att-card img { max-height: 100mm; }
body[data-paper="a5"][data-orient="landscape"] .att-grid.n2 .att-card img { max-height: 100mm; }
body[data-paper="a5"][data-orient="landscape"] .att-grid.n4 .att-card img { max-height: 50mm; }
body[data-paper="a5"][data-orient="landscape"] .att-grid.n6 .att-card img { max-height: 32mm; }

/* ================= 移动端自适应 ================= */
/* 手机（≤900px）：卡片收边、KPI 两列、栅格塌陷、表格横滑 */
@media screen and (max-width: 900px) {
  .wrap, .wrap.wide { max-width: 100%; padding: 12px 12px 24px; }
  .card { padding: 14px; border-radius: 12px; }
  .card + .card { margin-top: 12px; }
  .card-h { flex-wrap: wrap; gap: 6px 8px; margin-bottom: 10px; }
  .card-h h3 { font-size: 14.5px; }
  .card-h .sub { flex: 1 1 100%; font-size: 11.5px; line-height: 1.5; }
  .section-title { font-size: 13.5px; }

  .kpis { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi .v { font-size: 20px; }

  /* 表单栅格：12 列 → 2 列（内联 span 用 !important 盖掉） */
  .fgrid { grid-template-columns: 1fr 1fr !important; gap: 10px 12px; }
  .fgrid > .fld { grid-column: span 1 !important; }

  .side-by-side, .grid-2, .grid2 { display: block !important; }
  .side-by-side > .right { width: auto !important; flex: none !important; margin-top: 12px; }

  /* 列表表格：放进 .tbl-scroll 横向滚动（表头表体一起滚，不会错位） */
  .tbl-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl-scroll table.tbl { min-width: 100%; width: max-content; }
  .tbl-scroll table.tbl th, .tbl-scroll table.tbl td { white-space: nowrap; }

  /* 登录卡片按屏幕宽缩，避免右侧溢出 */
  .login-card { width: auto; max-width: 100%; padding: 22px; margin: 0 4px; }

  .hbar { grid-template-columns: 96px 1fr 108px; gap: 8px; font-size: 12px; }
  .tbl-note { font-size: 11.5px; }

  /* 看板趋势图：手机上横向滑动，不压缩失真 */
  #trend { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #trend svg { min-width: 660px; height: 250px; }

  /* 打印预览：纸面比手机宽，允许左右滑动 */
  #paper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #printBar { flex-wrap: wrap; height: auto; padding: 8px 10px; gap: 6px 8px; }
}

/* 窄手机（≤760px）：顶栏变两行，导航横向滑动 */
@media screen and (max-width: 760px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 8px 10px; gap: 6px 8px; }
  .topbar .spacer { display: none; }
  .brand { flex: 1 1 auto; min-width: 0; }
  .brand small { display: none; }
  .brand > span:last-child {
    display: block; max-width: 52vw; font-size: 13px; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
  }
  .userchip { margin-left: auto; font-size: 12px; }
  .userchip .role { display: none; }
  .nav {
    order: 9; flex: 1 1 100%; display: flex; gap: 4px; padding: 2px 0 0;
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }

  .btn { height: 32px; padding: 0 12px; font-size: 12.5px; }
  .btn.sm { height: 28px; padding: 0 9px; font-size: 12px; }
  .btn-row { flex-wrap: wrap; gap: 8px; }

  /* 输入框 16px：避免 iOS 聚焦时整页放大 */
  .fld input, .fld select, .fld textarea, .pool-sel, .p-sel { font-size: 16px; }

  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .tabs .tab { white-space: nowrap; }

  .dept-row { flex-wrap: wrap; row-gap: 6px; }
  .dept-row .spacer { display: none; }
  .dept-bar { flex-wrap: wrap; }

  .inv-item { padding: 12px; }
  .inv-hd { gap: 6px; }
  /* 票据卡里的字段：手机上并排两列，别每个字段占一行 */
  .ifld select { min-width: 150px; }
  .ifld input { min-width: 88px; }
  .ask-card { width: 92vw; }
  /* 提示条挪到底部，别盖住顶栏/工具栏 */
  #toast { top: auto; bottom: 16px; width: max-content; max-width: 92vw; }
  #toast .toast { max-width: 92vw; }
  .emp-form { padding: 12px; }
}

/* 更窄（≤480px）：表单单列、字号再收一点 */
@media screen and (max-width: 480px) {
  .fgrid { grid-template-columns: 1fr !important; }
  .fgrid > .fld { grid-column: span 1 !important; }
  .kpi .v { font-size: 18px; }
  .hbar { grid-template-columns: 76px 1fr 94px; }
  .hbar .nm { font-size: 11.5px; }
  .card-h h3 { font-size: 14px; }
  .brand > span:last-child { max-width: 44vw; font-size: 12.5px; }
  .login-card { padding: 18px; margin: 0 2px; }
  .login-card h1 { font-size: 18px; }
}
/* ================= 移动端自适应结束 ================= */
