body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: #f4f6f9;
  color: #2c3345;
  font-size: 14px;
}

/* ---------- top bar ---------- */
.topbar { background: #1f3a5f; box-shadow: 0 2px 6px rgba(0,0,0,.12); position: sticky; top: 0; z-index: 50; }
.topbar-inner { max-width: 1320px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 0 14px; height: 54px; }
.logo { color: #fff; font-size: 15px; font-weight: 700; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.logo img { height: 30px; border-radius: 3px; }
.topbar nav { display: flex; gap: 2px; flex-wrap: wrap; }
.topbar nav a { color: #c6d3e6; text-decoration: none; padding: 5px 9px; border-radius: 5px; font-size: 13px; white-space: nowrap; }
.topbar nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.topbar nav a.active { background: #2d5591; color: #fff; }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: #c6d3e6; white-space: nowrap; }
.userbox .uname { color: #fff; font-weight: 600; }
.userbox a { color: #ffd9a0; text-decoration: none; }

.container { max-width: 1320px; margin: 20px auto 60px; padding: 0 16px; }

/* ---------- cards / stats ---------- */
.card { background: #fff; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.08); padding: 18px 20px; margin-bottom: 18px; }
.card h2 { font-size: 16px; margin: 0 0 12px; color: #1f3a5f; border-left: 4px solid #2d5591; padding-left: 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(172px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.08); padding: 16px 18px; min-width: 0; }
.stat .num { font-size: 23px; font-weight: 700; color: #1f3a5f; line-height: 1.28; overflow-wrap: break-word; }
.stat .label { color: #7a8499; font-size: 13px; margin-top: 4px; line-height: 1.35; }
.stat.money .num { color: #c0392b; font-size: 21px; font-variant-numeric: tabular-nums; }
a.stat { display: block; color: inherit; }
a.stat.bucket-click { cursor: pointer; transition: transform .12s, box-shadow .12s, border-color .12s; border: 2px solid transparent; }
a.stat.bucket-click:hover { transform: translateY(-2px); box-shadow: 0 3px 10px rgba(47,111,237,.18); border-color: #2f6fed; }
a.stat.bucket-active { border: 2px solid #2f6fed; background: #f0f6ff; box-shadow: 0 2px 8px rgba(47,111,237,.15); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid #eef0f4; text-align: left; }
th { background: #f8f9fb; color: #5a6478; font-size: 13px; white-space: nowrap; }
tr:hover td { background: #fafbfd; }
.num-cell { text-align: right; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; color: #fff; }
.tag-IN { background: #27ae60; } .tag-OUT { background: #e67e22; } .tag-SALE { background: #2980b9; }
.tag-EST { background: #8e44ad; } .tag-GRAY { background: #8a93a5; }
.warn { color: #c0392b; font-weight: 700; }

/* ---------- forms ---------- */
label { display: block; font-size: 13px; color: #5a6478; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid #d4d9e2;
  border-radius: 6px; font-size: 14px; font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #2d5591; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-form > div { flex: 1; min-width: 130px; }

.btn {
  display: inline-block; border: none; border-radius: 6px; padding: 8px 18px;
  font-size: 14px; cursor: pointer; text-decoration: none; font-family: inherit;
  background: #2d5591; color: #fff; white-space: nowrap;
}
.btn:hover { background: #24467a; }
.btn.green { background: #27ae60; } .btn.green:hover { background: #1f8c4d; }
.btn.orange { background: #e67e22; } .btn.orange:hover { background: #c9661a; }
.btn.gray { background: #8a93a5; } .btn.gray:hover { background: #737c8d; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { background: #c0392b; } .btn.danger:hover { background: #a02f23; }

.alert-error { background: #fdecea; color: #b03a2e; border: 1px solid #f5b7b1; border-radius: 6px; padding: 10px 14px; margin-bottom: 14px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input { width: 220px; }

/* ---------- doc form rows ---------- */
.doc-items-table input, .doc-items-table select { padding: 5px 7px; font-size: 13px; }
.doc-items-table td { padding: 4px 5px; }
.doc-items-table th { font-size: 12px; padding: 6px 5px; }

.empty { color: #98a1b3; text-align: center; padding: 26px 0; }

/* ---------- 导入区 ---------- */
.import-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #f2f6fc; border: 1px dashed #b8c8de; border-radius: 8px;
  padding: 10px 12px; margin-bottom: 12px;
}
.import-bar .ib-title { font-weight: 700; color: #1f3a5f; }
.import-bar .ib-hint { color: #7a8499; font-size: 12px; flex: 1 1 300px; line-height: 1.5; }
label.btn { cursor: pointer; margin-bottom: 0; }
.doc-items-table tr.import-bad td { background: #fdecea; }
.doc-items-table tr.import-bad:hover td { background: #fbdcd8; }
.doc-items-table select.import-bad,
.doc-items-table tr.import-bad select { border-color: #c0392b; color: #b03a2e; background: #fff6f5; }

/* ---------- print page ---------- */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .print-sheet { box-shadow: none; border: none; padding: 0 6mm; max-width: none; }
  @page { size: A4 landscape; margin: 10mm; }
  /* 销售单：打印时单号一行（日期靠右），客户单独另起一行放在单号下面 */
  .print-meta-sale { flex-wrap: wrap; }
  .print-meta-sale .m-no { order: 1; }
  .print-meta-sale .m-date { order: 2; }
  .print-meta-sale .m-party { order: 3; flex: 0 0 100%; margin-top: 3px; }
  /* 内部成本溯源信息不打印（对应入库单提醒、仅剩该提醒的空行） */
  .print-in-doc { display: none !important; }
  .print-in-doc-row { display: none !important; }
}
.print-sheet {
  background: #fff; max-width: 1000px; margin: 0 auto; padding: 28px 34px;
  box-shadow: 0 2px 10px rgba(0,0,0,.1); border: 1px solid #e3e6ec; position: relative;
}
.print-head { position: relative; min-height: 82px; margin-bottom: 8px; }
.print-logo { position: absolute; left: 0; top: 0; height: 82px; }
.print-title {
  text-align: center; font-size: 23px; font-weight: 700; letter-spacing: 5px;
  line-height: 82px; color: #111;
}
.print-meta { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 6px; color: #222; font-size: 13px; }
.print-note { margin-top: 10px; font-size: 13px; color: #222; }
.print-table { border-collapse: collapse; width: 100%; margin-top: 6px; }
.print-table th, .print-table td { border: 1px solid #333; padding: 4px 5px; font-size: 12px; }
.print-table th { background: #f0f0f0; text-align: center; }
.print-sign { display: flex; justify-content: space-between; color: #222; margin-top: 40px; font-size: 13px; }
.print-due-plan { margin-top: 12px; }
.print-due-title { font-size: 13px; font-weight: 700; color: #222; margin-bottom: 4px; }
.print-due-table { border-collapse: collapse; width: 100%; }
.print-due-table th, .print-due-table td { border: 1px solid #333; padding: 3px 6px; font-size: 12px; }
.print-due-table th { background: #f0f0f0; text-align: center; }
.print-actions { max-width: 1000px; margin: 16px auto; display: flex; gap: 10px; justify-content: flex-end; }

/* 打印分页：每页独立块，页脚右下角页码 */
.print-page { page-break-after: always; }
.print-page:last-child { page-break-after: auto; }
.print-page .print-head { margin-bottom: 8px; }
.print-page-no { text-align: right; font-size: 12px; color: #333; margin-top: 6px; }
.alert-ok { background: #e8f6ef; color: #1e7e50; border: 1px solid #b7e4d0; border-radius: 6px; padding: 10px 14px; margin-bottom: 14px; }

/* ---------- 首页业务导图 ---------- */
.flow { display: flex; align-items: stretch; gap: 10px; flex-wrap: wrap; }
.flow-step {
  flex: 1 1 200px; min-width: 190px; background: #f8fafc; border: 1px solid #e2e8f0;
  border-top: 3px solid #2d5591; border-radius: 8px; padding: 12px 14px 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.flow-step.step-in { border-top-color: #27ae60; }
.flow-step.step-sale { border-top-color: #2980b9; }
.flow-step.step-out { border-top-color: #e67e22; }
.flow-step.step-pay { border-top-color: #c0392b; }
.flow-head { display: flex; align-items: center; gap: 8px; }
.flow-no {
  flex: none; width: 24px; height: 24px; border-radius: 50%; background: #2d5591; color: #fff;
  font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.step-in .flow-no { background: #27ae60; }
.step-sale .flow-no { background: #2980b9; }
.step-out .flow-no { background: #e67e22; }
.step-pay .flow-no { background: #c0392b; }
.flow-title { font-size: 14px; font-weight: 700; color: #1f3a5f; }
.flow-body { display: flex; flex-wrap: wrap; gap: 6px; }
.flow-body a, .flow-chip {
  display: inline-block; padding: 3px 9px; border-radius: 12px; font-size: 12.5px;
  background: #eef3fb; color: #2d5591; text-decoration: none; border: 1px solid #dbe5f3;
}
.flow-body a:hover { background: #2d5591; color: #fff; border-color: #2d5591; }
.flow-hint { font-size: 12px; color: #7a8499; line-height: 1.6; margin-top: auto; }
.flow-arrow { flex: none; display: flex; align-items: center; color: #b6c1d4; font-size: 20px; font-weight: 700; }
.flow-branch {
  margin-top: 6px; padding: 8px 10px; background: #f6f0fb; border: 1px dashed #c9a7e6;
  border-radius: 6px; font-size: 12.5px; color: #6c3f8f; line-height: 1.7;
}
.flow-branch a { color: #8e44ad; font-weight: 700; text-decoration: none; }
.flow-branch a:hover { text-decoration: underline; }
@media (max-width: 900px) { .flow-arrow { display: none; } .flow-step { flex: 1 1 100%; } }

/* ---------------- 可搜索下拉（输入关键字筛选） ---------------- */
.combo { position: relative; width: 100%; }
.combo .combo-input { width: 100%; font-size: 13px; padding: 7px 22px 7px 9px; background: #fff; }
.combo .combo-input::placeholder { color: #a8b1c2; }
.combo .combo-caret {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  font-size: 10px; color: #8a93a5; pointer-events: none;
}
.combo.combo-open .combo-input { border-color: #2d5591; box-shadow: 0 0 0 2px rgba(45,85,145,.10); }
.combo .combo-panel {
  display: none; position: absolute; z-index: 1200; left: 0; top: calc(100% + 3px);
  width: 100%; min-width: 100%; max-height: 268px; overflow-y: auto;
  background: #fff; border: 1px solid #d7dbe3; border-radius: 7px;
  box-shadow: 0 8px 22px rgba(20,35,60,.16); padding: 4px 0;
}
.combo .combo-item {
  padding: 7px 11px; font-size: 13px; line-height: 1.45; color: #22303f;
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.combo .combo-item:hover, .combo .combo-item.active { background: #eaf1fb; color: #1f3a5f; }
.combo .combo-item mark { background: #fff2b8; color: #a35a00; padding: 0 1px; border-radius: 2px; }
.combo .combo-empty { padding: 9px 11px; font-size: 12.5px; color: #a0a8b8; }
.doc-items-table .combo .combo-input { padding: 4px 20px 4px 6px; font-size: 12.5px; }
.doc-items-table .combo .combo-input.import-bad { border-color: #c0392b; background: #fff6f5; color: #b03a2e; }
.doc-items-table .combo .combo-caret { right: 5px; font-size: 9px; }
