/* 申购单系统 —— 单文件样式 */

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e3e6ea;
  --text: #1f2328;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --ok: #047857;
  --ok-soft: #e7f6ef;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --danger: #b91c1c;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

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

.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------- 顶栏 */

.topnav {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 54px;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { font-weight: 700; font-size: 15px; color: var(--text); }
.brand:hover { text-decoration: none; }

.navlinks { display: flex; gap: 4px; }
.navlinks a {
  padding: 6px 12px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 14px;
}
.navlinks a:hover { background: var(--bg); text-decoration: none; }
.navlinks a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.navright { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); font-size: 13px; }
.inline { display: inline; }
.linkbtn {
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0;
}
.linkbtn:hover { color: var(--accent); text-decoration: underline; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }

/* ---------------------------------------------------------- 按钮 */

button, .btn-like {
  font: inherit;
  font-size: 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 8px 15px;
  cursor: pointer;
  display: inline-block;
  line-height: 1.4;
  transition: background .12s, border-color .12s;
}
button:hover, .btn-like:hover { background: #fafbfc; text-decoration: none; }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
button.primary:hover { background: #1d4ed8; }
button.ghost { background: #fff; }
button.danger { color: var(--danger); border-color: #f0c8c8; }
button.danger:hover { background: #fdf2f2; }
button.block { width: 100%; margin-top: 8px; padding: 10px; }
button.mini, .mini {
  font-size: 13px;
  padding: 3px 9px;
  border-radius: 6px;
  color: var(--muted);
  border: 1px solid var(--line);
  background: #fff;
}
.mini:hover { color: var(--accent); border-color: #c9d8ff; text-decoration: none; }

/* ---------------------------------------------------------- 统计卡 */

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card .k { font-size: 12px; color: var(--muted); }
.card .v { font-size: 24px; font-weight: 700; margin: 3px 0 1px; letter-spacing: -.5px; }
.card .m { font-size: 12px; color: var(--muted); }
.card.warn .v { color: var(--warn); }
.card.blue .v { color: var(--accent); }

/* ---------------------------------------------------------- 筛选 */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.filters input, .filters select {
  min-width: 0;
  font: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.filters input[name="q"] { flex: 1 1 240px; min-width: 160px; }
.filters button, .filters .btn-like { padding: 7px 14px; font-size: 13px; }

/* ---------------------------------------------------------- 表格 */

.tablebox {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table { border-collapse: collapse; width: 100%; }

table.list { font-size: 13.5px; min-width: 780px; }
table.list th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
  white-space: nowrap;
}
table.list td {
  padding: 11px 12px;
  border-bottom: 1px solid #f0f2f4;
  vertical-align: middle;
}
table.list tr:last-child td { border-bottom: 0; }
table.list tr:hover td { background: #fcfdff; }
table.list td.purpose {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
table.list td.ops { white-space: nowrap; }
table.list td.ops .mini { margin-right: 4px; }
td.empty { text-align: center; color: var(--muted); padding: 46px 12px; }

.badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.arr-done, .badge.inv-done { background: var(--ok-soft); color: var(--ok); }
.badge.arr-partial, .badge.inv-pending { background: var(--warn-soft); color: var(--warn); }
.badge.arr-none, .badge.inv-none { background: #f1f2f4; color: var(--muted); }

/* ---------------------------------------------------------- 移动卡片列表 */

.mob { display: none; }

.doclist { display: none; }

.doc-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 9px;
}
.dc-main { min-width: 0; color: var(--text); display: block; }
.dc-main:hover { text-decoration: none; }
.dc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.dc-no { font-size: 13px; color: var(--accent); }
.dc-amt { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dc-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.dc-purpose {
  font-size: 13px;
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dc-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 9px; }
.dc-badges { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------------------------------------------------- 编辑页 */

.editor { display: block; }

section.quick {
  background: linear-gradient(180deg, #f8faff, #fff);
  border: 1px solid #dbe6ff;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.quick-hd { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.quick-hd strong { font-size: 14px; }
.quick textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid #cfdcf7;
  border-radius: 8px;
  resize: vertical;
  background: #fff;
  line-height: 1.6;
}
.quick textarea:focus { outline: 2px solid #c7dbff; outline-offset: -1px; }
.quick-ft { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--muted); }

section.meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
section.meta label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); min-width: 0; }
section.meta label.span2 { grid-column: span 2; }
section.meta label.w2 { grid-column: span 1; }
section.meta input {
  min-width: 0;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  width: 100%;
  background: #fff;
}
section.meta input:focus { outline: 2px solid #c7dbff; outline-offset: -1px; border-color: #a9c4f7; }

.items {
  --item-cols: 34px minmax(130px, 1.7fr) minmax(88px, 1fr) 62px 54px 86px 92px 92px 92px minmax(80px, 1fr) 30px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 13.5px;
}

.it-head,
.it-row {
  display: grid;
  grid-template-columns: var(--item-cols);
  gap: 6px;
  align-items: center;
  padding: 6px 10px;
}

.it-head {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  white-space: nowrap;
}

.it-row { border-bottom: 1px solid #f2f4f6; }
.it-row:last-child { border-bottom: 0; }

.c-idx { color: var(--muted); font-size: 12px; text-align: center; }

.it-row input,
.it-row select {
  font: inherit;
  font-size: 13.5px;
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid #e7eaee;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}
.it-row input:focus,
.it-row select:focus {
  outline: 2px solid #c7dbff;
  outline-offset: -1px;
  border-color: #a9c4f7;
}
.c-amt .amount {
  display: block;
  text-align: right;
  padding-right: 2px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.c-del { text-align: center; }
.c-del .del {
  border: 0;
  background: none;
  color: #c3c8cf;
  font-size: 17px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 6px;
}
.c-del .del:hover { color: var(--danger); background: #fdf2f2; }

.sumline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 14px 0 18px;
  flex-wrap: wrap;
}
.totals { text-align: right; }
.totals #total { font-size: 20px; font-weight: 700; letter-spacing: -.5px; margin-left: 6px; }
.totals .upper { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions .danger { margin-left: auto; }

.ok {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: var(--ok);
  padding: 10px 14px;
  border-radius: 8px;
  margin: 0 0 14px;
  font-size: 13.5px;
}

.err {
  background: #fdf2f2;
  border: 1px solid #f5c2c2;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  margin: 0 0 14px;
  font-size: 13.5px;
}

/* ---------------------------------------------------------- 登录 */

.loginbox {
  max-width: 340px;
  margin: 9vh auto 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px 26px 30px;
}
.loginbox h1 { margin: 0 0 2px; font-size: 20px; letter-spacing: .5px; }
.loginbox .sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.loginbox label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.loginbox input {
  display: block;
  width: 100%;
  margin-top: 5px;
  font: inherit;
  font-size: 15px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.loginbox input:focus { outline: 2px solid #c7dbff; outline-offset: -1px; border-color: #a9c4f7; }

.msgbox {
  max-width: 460px;
  margin: 12vh auto 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 26px;
  text-align: center;
}
.msgbox h2 { margin: 0 0 8px; font-size: 18px; }
.msgbox p { color: var(--muted); }

/* ---------------------------------------------------------- 设置页 */

.setbox {
  max-width: 620px;
  margin: 4vh auto 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px 26px 22px;
}
.setbox h1 { margin: 0 0 4px; font-size: 19px; letter-spacing: .5px; }
.setbox .sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.setbox label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 15px;
}
.setbox input[type="text"],
.setbox input:not([type]) {
  display: block;
  width: 100%;
  margin-top: 6px;
  font: inherit;
  font-size: 14.5px;
  color: var(--text);
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.setbox input:focus { outline: 2px solid #c7dbff; outline-offset: -1px; border-color: #a9c4f7; }
.setbox label.chk {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text);
  margin-bottom: 20px;
}
.setbox label.chk input { width: 16px; height: 16px; margin: 0; }
.setactions { display: flex; gap: 10px; align-items: center; }
.hintbox {
  margin-top: 20px;
  padding: 12px 14px;
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.7;
}
.hintbox b { color: var(--text); }
.hintbox code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #eef1f4;
  color: #334155;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

/* ---------------------------------------------------------- 打印页（屏幕预览） */

.printbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.sheet {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 14mm 13mm;
  background: #fff;
  border: 1px solid #dfe3e8;
  border-radius: 2px;
  box-shadow: 0 2px 14px rgba(15, 23, 42, .09);
  color: #000;
  font-family: "Songti SC", "SimSun", "PingFang SC", "Microsoft YaHei", serif;
}

.sheet-hd { text-align: center; margin-bottom: 8px; }
.sheet-hd .co { font-size: 14px; letter-spacing: 2px; margin-bottom: 3px; }
.sheet-hd .tt {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 9px;
  padding-bottom: 5px;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

.sheet-no.one { justify-content: flex-end; }

.sheet-no {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  padding-bottom: 4px;
  border-bottom: 1.5px solid #000;
  margin-bottom: 7px;
}

table.sheet-meta { width: 100%; border-collapse: collapse; margin-bottom: 7px; font-size: 12.5px; }
table.sheet-meta td {
  border: 1px solid #000;
  padding: 4px 8px;
  height: 24px;
  vertical-align: middle;
}
table.sheet-meta td.lb { width: 12%; background: #f2f2f2; text-align: center; white-space: nowrap; }
table.sheet-meta td.vl { width: 38%; }

table.sheet-items { width: 100%; border-collapse: collapse; font-size: 12.5px; table-layout: fixed; }
table.sheet-items col.c1 { width: 8%; }
table.sheet-items col.c2 { width: 30%; }
table.sheet-items col.c3 { width: 22%; }
table.sheet-items col.c4 { width: 9%; }
table.sheet-items col.c5 { width: 9%; }
table.sheet-items col.c6 { width: 11%; }
table.sheet-items col.c7 { width: 15%; }

table.sheet-items th,
table.sheet-items td {
  border: 1px solid #000;
  padding: 1.5px 6px;
  height: 18px;
  line-height: 1.25;
  vertical-align: middle;
  word-break: break-all;
}
table.sheet-items thead th { background: #f2f2f2; font-weight: 700; text-align: center; }
table.sheet-items td.c { text-align: center; }
table.sheet-items td.r { text-align: right; }
table.sheet-items td.l { text-align: left; }
table.sheet-items td.strong { font-weight: 700; }
table.sheet-items tfoot td { background: #fafafa; }
table.sheet-items tbody tr { page-break-inside: avoid; }

.sheet-remark {
  border: 1px solid #000;
  border-top: 0;
  min-height: 38px;
  padding: 6px 8px;
  font-size: 12.5px;
}
.sheet-remark span { color: #333; }

.sheet-sign {
  margin-top: 14px;
  font-size: 13px;
  letter-spacing: .5px;
}
.sheet-foot {
  margin-top: 10px;
  font-size: 11px;
  color: #555;
  display: flex;
  justify-content: space-between;
}

/* ---------------------------------------------------------- 打印 */

@page {
  size: A4;
  margin: 11mm 13mm 9mm;
}

@media print {
  html, body {
    background: #fff !important;
    margin: 0;
    padding: 0;
  }
  .topnav, .printbar, .actions, .filters, .cards, script { display: none !important; }
  .wrap { max-width: none; margin: 0; padding: 0; }
  .sheet {
    width: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  table.sheet-items thead { display: table-header-group; }
  table.sheet-items tfoot { display: table-row-group; }
  a { color: #000; text-decoration: none; }
}

/* ---------------------------------------------------------- 手机 */

@media (max-width: 820px) {
  .topnav { padding: 0 12px; gap: 10px; height: 50px; }
  .brand { font-size: 14px; }
  .navlinks a { padding: 6px 9px; font-size: 13px; }
  .who { display: none; }
  .wrap { padding: 14px 12px 48px; }

  .cards { grid-template-columns: 1fr; gap: 10px; }
  .card { padding: 12px 14px; }
  .card .v { font-size: 21px; }

  section.meta { grid-template-columns: 1fr 1fr; gap: 10px; padding: 13px; }
  section.meta label.w2 { grid-column: span 2; }
  section.meta label.span2 { grid-column: span 2; }

  .filters { gap: 7px; }
  .filters > * { flex: 1 1 auto; }
  .filters input[name="q"] { flex: 1 1 100%; }
  .filters input[type="month"] { flex: 1 1 100%; }
  .filters select { flex: 1 1 calc(50% - 4px); }

  .desk { display: none !important; }
  .mob { display: block; }

  .sheet { width: 100%; min-height: 0; padding: 16px 12px; box-shadow: none; border-radius: 8px; }
  .sheet-hd .tt { font-size: 20px; letter-spacing: 6px; }
  table.sheet-items { font-size: 11.5px; }
  table.sheet-items th, table.sheet-items td { padding: 3px 3px; }

  .items { overflow: visible; background: none; border: 0; }

  .it-head { display: none; }

  .it-row {
    grid-template-columns: 1fr 1fr;
    gap: 9px 10px;
    padding: 12px 13px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 9px;
  }
  .it-row:last-child { border-bottom: 1px solid var(--line); }

  .it-row [data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 3px;
  }

  .c-idx { grid-column: span 2; text-align: left; font-size: 12px; }
  .c-idx::before { content: "第 "; }
  .c-idx::after { content: " 行"; }
  .c-name, .c-spec, .c-note { grid-column: span 2; }
  .c-del { grid-column: span 2; text-align: right; margin-top: -4px; }
  .c-del .del { font-size: 15px; padding: 6px 10px; }
  .c-amt .amount { text-align: left; }

  .totals { text-align: left; }
  .actions .danger { margin-left: 0; }
  .sumline { flex-direction: column; align-items: flex-start; gap: 8px; }
}


@media (max-width: 520px) {
  section.meta { grid-template-columns: 1fr; }
  section.meta label.span2 { grid-column: span 1; }
  section.meta label.w2 { grid-column: span 1; }
  .loginbox { margin-top: 5vh; padding: 22px 18px 24px; }
  .card .v { font-size: 19px; }
}
