/* ============ 北京源融通汇 · 出入库管理系统 样式 ============ */
:root {
  --bg: #e9f6ec;
  --panel: #ffffff;
  --line: #cfe6d6;
  --text: #16301f;
  --muted: #3f6350;
  --brand: #16a34a;
  --brand-dark: #12813c;
  --brand-soft: #e6f7ec;
  --danger: #d81b45;
  --warn: #e08b00;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 60, 40, .06), 0 10px 26px rgba(20, 60, 40, .07);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  background-image: linear-gradient(180deg, #eefaf1 0%, #e6f4ea 100%);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
}

.layout { display: flex; min-height: 100vh; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 236px;
  flex: 0 0 236px;
  background: linear-gradient(180deg, #14563a 0%, #0e3f2a 100%);
  color: #d9eee2;
  padding: 0 0 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  padding: 22px 6px 18px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  margin-bottom: 8px;
}
.brand .co { color: #ffffff; font-size: 16px; font-weight: 800; letter-spacing: .3px; line-height: 1.45; }
.brand .sys { color: #b7e0c8; font-size: 14px; margin-top: 8px; letter-spacing: 2px; }

.nav-group { padding: 8px 10px 4px; }
.nav-group .gtitle {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; border: 0; background: transparent; cursor: pointer;
  font-size: 13px; color: #ffffff; padding: 8px 8px; letter-spacing: .5px;
  border-radius: 6px; font-family: inherit; text-align: left; font-weight: 600;
}
.nav-group .gtitle:hover { color: #ffffff; background: rgba(255, 255, 255, .08); }
.nav-group .gtitle .chev {
  width: 6px; height: 6px; flex: 0 0 6px; margin-right: 2px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg); transition: transform .18s ease;
}
.nav-group.collapsed .gtitle .chev { transform: rotate(-45deg); }
.nav-group.collapsed .gbody { display: none; }
.nav-item {
  display: block; width: 100%; text-align: left; border: 0; cursor: pointer;
  background: transparent; color: #e2f3e9; font-size: 14px; font-weight: 500;
  padding: 9px 12px; border-radius: 8px; margin-bottom: 2px;
  font-family: inherit;
}
.nav-item:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.nav-item.active { background: #22c55e; color: #fff; font-weight: 700; box-shadow: 0 4px 12px rgba(0, 0, 0, .18); }

/* ---------- 主区 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: rgba(255, 255, 255, .96);
  border-bottom: 2px solid #bfe3cb;
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 18.5px; margin: 0; font-weight: 700; color: #14523a; }
.topbar .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.topbar .right { display: flex; gap: 10px; align-items: center; }
.clock { color: var(--muted); font-size: 13px; }

.content { padding: 20px 24px 40px; }

/* ---------- 通用控件 ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 700; color: #14523a; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.card-title .hint { font-weight: 500; color: var(--muted); font-size: 12.5px; }

.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; color: #2f5440; font-weight: 600; }
.field input, .field select, .field textarea {
  height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px;
  font-family: inherit; font-size: 14px; font-weight: 500; background: #fff; color: var(--text); min-width: 120px;
}
.field input:focus, .field select:focus { outline: 2px solid rgba(34, 197, 94, .28); border-color: var(--brand); }
.field textarea { height: auto; min-height: 34px; padding: 8px 10px; }
.field.w160 input, .field.w160 select { width: 160px; }
.field.w200 input, .field.w200 select { width: 200px; }
.form-grid { display: grid; gap: 16px 18px; align-items: start; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.form-grid .field { min-width: 0; }
.form-grid .field input, .form-grid .field select { width: 100%; box-sizing: border-box; }
.form-grid .span2 { grid-column: span 2; }
@media (max-width: 1180px) { .form-grid.cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.btn {
  height: 36px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--text); cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { border-color: #9fd4b2; background: #f1faf4; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.danger { color: var(--danger); border-color: #fecdd3; }
.btn.danger:hover { background: #fff1f2; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }

/* 参数表页签：比普通按钮更大更醒目 */
.ptabs { gap: 14px; align-items: center; }
.ptabs .btn {
  height: 46px; padding: 0 24px; border-radius: 11px;
  font-size: 19px; font-weight: 700; letter-spacing: .5px;
}
.ptabs .btn.sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- 表格 ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.8px; }
table.grid thead th {
  position: sticky; top: 0; background: #e7f6ec; color: #14523a; font-weight: 700; font-size: 13.5px;
  text-align: left; padding: 11px 12px; border-bottom: 1px solid #bfe3cb; white-space: nowrap; z-index: 2;
}
table.grid tbody td { padding: 10px 12px; border-bottom: 1px solid #e4f2e9; white-space: nowrap; color: var(--text); }
table.grid tbody tr:hover { background: #f3fbf6; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tfoot td { padding: 11px 12px; font-weight: 700; color: #14523a; background: #e7f6ec; border-top: 1px solid #bfe3cb; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; }
.badge.ok { background: var(--brand-soft); color: var(--brand-dark); }
.badge.bad { background: #fff1f2; color: var(--danger); }
.badge.warn { background: #fffbeb; color: #b45309; }
.badge.gray { background: #f1f5f9; color: #475569; }

/* ---------- 统计卡片 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .k { color: #2f5440; font-size: 13px; font-weight: 600; }
.stat .v { font-size: 25px; font-weight: 800; margin-top: 6px; color: #103a25; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.stat .f { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.stat.accent { background: linear-gradient(135deg, #22c55e, #12813c); border: 0; color: #fff; box-shadow: 0 10px 24px rgba(18, 129, 60, .28); }
.stat.accent .k, .stat.accent .f { color: rgba(255, 255, 255, .9); }
.stat.accent .v { color: #fff; }

/* ---------- 录入表单 ---------- */
.entry-table { width: 100%; border-collapse: collapse; font-size: 13.8px; }
.entry-table th { background: #e7f6ec; padding: 9px 10px; font-weight: 700; color: #14523a; text-align: left; border-bottom: 1px solid #bfe3cb; }
.entry-table td { padding: 6px 8px; border-bottom: 1px solid #e4f2e9; }
.entry-table input, .entry-table select {
  width: 100%; height: 34px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: 13.5px; font-weight: 500; color: var(--text);
}
.entry-table input.computed { background: #f1faf4; color: #2f5440; }
.picker { position: relative; }
.picker-list {
  position: absolute; left: 0; right: 0; top: 36px; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: var(--shadow); max-height: 220px; overflow: auto; z-index: 30; display: none;
}
.picker-item { padding: 8px 10px; cursor: pointer; font-size: 13px; }
.picker-item:hover { background: var(--brand-soft); }
.picker-item .code { color: var(--muted); font-size: 12px; margin-left: 6px; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); font-size: 12.5px; }
.pager .grow { flex: 1; }

/* ---------- 打印单据 ---------- */
.doc {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 32px; max-width: 1000px; margin: 0 auto;
}
.doc-title { text-align: center; font-size: 20px; font-weight: 700; letter-spacing: 2px; margin-bottom: 4px; }
.doc-sub { text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 18px; }
.doc-head { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 24px; font-size: 13px; margin-bottom: 14px; }
.doc-head .item { display: flex; gap: 8px; }
.doc-head .item .k { color: var(--muted); white-space: nowrap; }
.doc-head .item .v { font-weight: 600; }
table.doc-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.doc-table th, table.doc-table td { border: 1px solid #cbd5e1; padding: 6px 8px; text-align: center; }
table.doc-table th { background: #f1f5f9; font-weight: 600; }
table.doc-table td.num { text-align: right; }
.doc-foot { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; font-size: 13px; }
.doc-foot .item { display: flex; gap: 6px; }
.doc-foot .k { color: var(--muted); }
/* 单据合计：上排「数量合计 / 金额合计」等宽两栏，下排「金额大写」整行，左右对称 */
.doc-foot.doc-total { grid-template-columns: repeat(2, 1fr); gap: 8px 24px; }
.doc-foot.doc-total .item.full { grid-column: 1 / -1; }
.doc-sign { margin-top: 26px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; font-size: 13px; }
.doc-sign .item { border-top: 1px solid #cbd5e1; padding-top: 8px; color: var(--muted); }
.doc-section-title { font-size: 13px; font-weight: 600; margin: 20px 0 8px; }

/* ---------- 提示 / 对话框 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 36px; transform: translateX(-50%) translateY(20px);
  background: #0f172a; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 13px;
  opacity: 0; transition: .25s; z-index: 99; pointer-events: none; max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #be123c; }
.toast.ok { background: #065f46; }

#modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: none;
  align-items: center; justify-content: center; z-index: 60; padding: 24px;
}
#modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 14px; width: min(720px, 96vw); max-height: 86vh; overflow: auto; box-shadow: 0 24px 64px rgba(0, 0, 0, .2); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 600; display: flex; justify-content: space-between; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: relative; }
  .sidebar .nav-group { display: inline-block; vertical-align: top; }
  .nav-item { display: inline-block; width: auto; }
  .content { padding: 14px; }
}

/* ---------- 打印 ---------- */
@media print {
  .sidebar, .topbar, .no-print, .pager { display: none !important; }
  body, html { background: #fff !important; background-image: none !important; }
  .content { padding: 0; }
  .doc { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .doc-title { font-size: 18px; }
  @page { size: A4; margin: 14mm; }
}

/* 客户出库对账单：列多，字号收紧以便 A4 一页横向铺开 */
table.doc-table.wide { font-size: 10.5px; }
table.doc-table.wide th, table.doc-table.wide td { padding: 4px 4px; white-space: normal; }
table.doc-table.wide th { line-height: 1.25; }
@media print { table.doc-table.wide { font-size: 9.5px; } table.doc-table.wide th, table.doc-table.wide td { padding: 3px 3px; } }
/* ============ 登录页 ============ */
body.login-locked { overflow: hidden; }
.login-mask {
  position: fixed; inset: 0; z-index: 5000;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, #dbf4e2 0%, #c3e8cf 45%, #a9dcbb 100%);
}
.login-card {
  width: 380px; max-width: calc(100vw - 32px);
  background: #fff; border-radius: 16px; padding: 34px 34px 26px;
  box-shadow: 0 24px 60px rgba(18, 70, 40, .25);
}
.login-co { font-size: 19px; font-weight: 700; color: #14523a; letter-spacing: .5px; text-align: center; }
.login-sys { font-size: 13px; color: #3f6350; text-align: center; margin: 6px 0 26px; letter-spacing: 2px; }
.login-row { margin-bottom: 14px; }
.login-row label { display: block; font-size: 13.5px; color: #2f5440; font-weight: 600; margin-bottom: 6px; }
.login-row input {
  width: 100%; height: 42px; padding: 0 12px; font-size: 14.5px;
  border: 1px solid #d7dde6; border-radius: 8px; outline: none; font-family: inherit;
}
.login-row input:focus { border-color: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, .14); }
.login-err { min-height: 20px; color: #e11d48; font-size: 13px; margin-bottom: 6px; }
.login-btn { width: 100%; height: 44px; font-size: 15px; letter-spacing: 4px; }
.login-tip { margin-top: 16px; font-size: 12px; color: #94a3b8; line-height: 1.6; text-align: center; }
.topbar .right .who { font-size: 12.5px; color: #64748b; margin-right: 4px; }

/* ============ 页面水印（截图/打印均可见） ============ */
.wm {
  position: fixed; inset: 0; pointer-events: none; z-index: 900;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  grid-auto-rows: 108px; overflow: hidden; align-content: start;
  color: #14523a; opacity: .07; font-size: 16px; font-weight: 600;
  user-select: none; -webkit-user-select: none;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.wm span {
  display: flex; align-items: center; justify-content: center;
  transform: rotate(-24deg); white-space: nowrap; letter-spacing: 1px;
}
@media print {
  .wm { opacity: .12; }
}
/* 服务商账单：对方开给我方的账单，打印时不带系统水印 */
body.print-no-wm .wm { display: none !important; }
