/* 应用界面样式 */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #f3f4f6;
  color: #1f2937;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, Arial, sans-serif;
  font-size: 14px;
}

button { font-family: inherit; cursor: pointer; }

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

/* ---------- 侧栏 ---------- */
.sidebar {
  width: 198px;
  flex: 0 0 198px;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { padding: 20px 18px 14px; }
.brand b { display: block; font-size: 15px; letter-spacing: .01em; }
.brand span { display: block; font-size: 11px; color: #9ca3af; margin-top: 3px; letter-spacing: .06em; }

nav { padding: 4px 0; }
nav button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 10px 18px;
  background: none;
  border: 0;
  border-left: 3px solid transparent;
  font-size: 13.5px;
  color: #4b5563;
}
nav button[hidden] { display: none !important; }
nav button:hover { background: #f9fafb; }
nav button.active { background: #eef2ff; color: #1e3a8a; border-left-color: #1e3a8a; font-weight: 600; }
nav button .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .35; }

.side-foot { margin-top: auto; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.side-foot .hint { font-size: 11px; color: #9ca3af; line-height: 1.6; padding: 0 2px 4px; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 9px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.topbar .spacer { flex: 1; }

select.order-select {
  min-width: 260px;
  max-width: 340px;
  font-size: 13px;
  padding: 7px 9px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
}

.btn {
  padding: 7px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #fff;
  color: #374151;
  font-size: 13px;
  line-height: 1.2;
}
.btn:hover { border-color: #9ca3af; background: #f9fafb; }
.btn.primary { background: #1e3a8a; border-color: #1e3a8a; color: #fff; }
.btn.primary:hover { background: #1b3479; }
.btn.danger { color: #b91c1c; border-color: #fca5a5; }
.btn.danger:hover { background: #fef2f2; }
.btn.sm { padding: 5px 9px; font-size: 12px; }

.save-state { font-size: 12px; color: #9ca3af; }
.save-state.err { color: #b91c1c; }

.panel { padding: 18px; display: none; }
.panel.active { display: block; }

/* ---------- 表单 ---------- */
.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 15px 17px 17px;
  margin-bottom: 14px;
}
.card > h3 {
  margin: 0 0 13px;
  font-size: 13.5px;
  font-weight: 600;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card > h3 .tip { font-size: 11.5px; font-weight: 400; color: #9ca3af; }
.card > h3 .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }

.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px 13px; }
.grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.span4 { grid-column: span 4; }

label.f { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: #6b7280; min-width: 0; }
label.f > span { padding-left: 1px; }

input, select, textarea {
  width: 100%;
  border: 1px solid #d5d9e0;
  border-radius: 6px;
  padding: 6.5px 8px;
  font-size: 13px;
  font-family: inherit;
  color: #111827;
  background: #fff;
  min-width: 0;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #1e3a8a;
  box-shadow: 0 0 0 3px rgba(30, 58, 138, .07);
}
textarea { resize: vertical; line-height: 1.5; }
input[readonly] { background: #f9fafb; color: #6b7280; }
input[type="color"] { width: 92px; padding: 3px; height: 34px; cursor: pointer; }
table.lib td .btn { margin-right: 2px; white-space: nowrap; }

/* ---------- 明细表 ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.items { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 1030px; }
table.items th {
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-align: left;
  padding: 6px 4px;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}
table.items td { padding: 4px 2px; border-bottom: 1px solid #f1f2f4; vertical-align: middle; }
table.items td input { padding: 5px 5px; font-size: 12px; }
table.items td.num input { text-align: right; }
table.items tr:hover td { background: #fafbfc; }

.thumb {
  width: 40px; height: 40px; border: 1px dashed #d1d5db; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  cursor: pointer; background: #fbfbfc; position: relative;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb span { font-size: 10px; color: #b0b4bb; }

.row-del {
  border: 0; background: none; color: #c3c7cf; font-size: 16px; padding: 2px 6px; line-height: 1;
}
.row-del:hover { color: #b91c1c; }

.empty {
  padding: 26px;
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
  border: 1px dashed #e2e5ea;
  border-radius: 8px;
  background: #fbfbfc;
}

/* ---------- 预览 ---------- */
.preview-bar {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 9px 12px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  position: sticky;
  top: 52px;
  z-index: 20;
}
.doc-tabs { display: flex; gap: 4px; background: #f3f4f6; padding: 3px; border-radius: 8px; }
.doc-tabs button {
  border: 0; background: none; padding: 6px 12px; border-radius: 6px;
  font-size: 12.5px; color: #4b5563;
}
.doc-tabs button.active { background: #fff; color: #1e3a8a; font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.preview-stage {
  background: #e6e8ec;
  border-radius: 10px;
  padding: 26px;
  overflow: auto;
  display: flex;
  justify-content: center;
  min-height: 70vh;
}
.scaler { transform-origin: top center; }

/* ---------- 库 ---------- */
.lib-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.lib-toolbar .grow { flex: 1; }
table.lib { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
table.lib th { text-align: left; font-size: 12px; color: #6b7280; font-weight: 600; padding: 9px 10px; border-bottom: 1px solid #e5e7eb; white-space: nowrap; }
table.lib td { padding: 9px 10px; border-bottom: 1px solid #f1f2f4; color: #374151; }
table.lib tr:hover td { background: #fafbfc; }

/* ---------- 设置 ---------- */
.img-upload {
  display: flex; gap: 12px; align-items: center;
  border: 1px dashed #d1d5db; border-radius: 8px; padding: 10px; background: #fbfbfc;
}
.img-upload .prev {
  width: 100px; height: 56px; background: #fff; border: 1px solid #e5e7eb; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; overflow: hidden; font-size: 11px; color: #b0b4bb;
}
.img-upload .prev img { max-width: 100%; max-height: 100%; object-fit: contain; }
.img-upload .prev.stamp { width: 76px; height: 76px; }

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .35);
  display: none; align-items: center; justify-content: center; z-index: 100;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 12px; padding: 18px 20px; width: 560px; max-width: 92vw;
  max-height: 84vh; overflow: auto; box-shadow: 0 18px 50px rgba(0,0,0,.2);
}
.modal h3 { margin: 0 0 14px; font-size: 15px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #111827; color: #fff; font-size: 13px; padding: 9px 16px;
  border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 200;
}
.toast.show { opacity: .94; }

@media (max-width: 1100px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span3, .span4 { grid-column: span 2; }
}


/* ---------- 用户区 / 引导遮罩 / 业务单列表 ---------- */
.side-foot .user-box {
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 9px;
  margin-bottom: 10px;
  background: #f8fafc;
}
.user-box .user-name { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.user-box .user-name b { font-size: 13px; color: #111827; }
.role-badge {
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em;
  padding: 1.5px 7px; border-radius: 99px;
  background: #1e3a8a; color: #fff;
}
.role-badge.user { background: #64748b; }
.user-box .user-actions { display: flex; gap: 6px; }

.boot-mask {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(255,255,255,0.94);
  display: none; align-items: center; justify-content: center;
}
.boot-mask.show { display: flex; }
.boot-box { text-align: center; font-size: 13.5px; color: #475569; }
.boot-spin {
  width: 34px; height: 34px; margin: 0 auto 12px;
  border: 3px solid #e2e8f0; border-top-color: #1e3a8a;
  border-radius: 50%;
  animation: bootspin 0.8s linear infinite;
}
@keyframes bootspin { to { transform: rotate(360deg); } }

#order-list-body td { vertical-align: middle; }
#order-list-body .ol-title { font-weight: 600; color: #111827; cursor: pointer; }
#order-list-body .ol-title:hover { color: #1e3a8a; text-decoration: underline; }
#order-list-body .ol-amt { text-align: right; font-weight: 600; color: #111827; }
#order-list-body .muted { color: #9ca3af; font-size: 12px; }
.tag-open { font-size: 10.5px; color: #64748b; border: 1px solid #e5e7eb; border-radius: 99px; padding: 1px 8px; }

.muted2 { color: #9ca3af; font-size: 12px; }

/* ================================================================
   视觉升级 v2：深藏青侧栏 + 数据看板
   ================================================================ */

/* ---------- 全局底色与卡片质感 ---------- */
body { background: #f1f4f9; }
.card {
  border: 1px solid #e7ebf2;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.card > h3 { letter-spacing: .01em; }

.btn.primary {
  background: linear-gradient(180deg, #274c9e 0%, #1e3a8a 100%);
  border-color: #1e3a8a;
  box-shadow: 0 1px 2px rgba(30, 58, 138, .25);
}
.btn.primary:hover { background: linear-gradient(180deg, #244694 0%, #1b3479 100%); }
.btn.ghost { border-color: transparent; background: transparent; color: #475569; }
.btn.ghost:hover { background: rgba(255, 255, 255, .12); color: #fff; }

/* ---------- 深藏青侧栏 ---------- */
.sidebar {
  background: linear-gradient(180deg, #10203c 0%, #0c1830 100%);
  border-right: 0;
  color: #c6d2e4;
}
.brand { padding: 22px 18px 16px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.brand b { color: #fff; font-size: 15.5px; }
.brand span {
  color: #7f92b0;
  white-space: nowrap;
  font-size: 10px;
  letter-spacing: .04em;
  overflow: hidden;
  text-overflow: ellipsis;
}
nav { padding: 10px 0; }
nav button { color: #b9c6db; border-left: 3px solid transparent; padding: 11px 18px; }
nav button:hover { background: rgba(255, 255, 255, .06); color: #e8eefb; }
nav button.active {
  background: rgba(93, 134, 220, .16);
  color: #fff;
  border-left-color: #6d9bff;
  font-weight: 600;
}
nav button .dot { opacity: .5; }
.side-foot { border-top: 1px solid rgba(255, 255, 255, .08); }
.side-foot .hint { color: #7f92b0; }
.side-foot .user-box {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .1);
}
.user-box .user-name b { color: #fff; }
.role-badge { background: #6d9bff; color: #0c1830; }
.role-badge.user { background: rgba(255, 255, 255, .22); color: #e8eefb; }
.side-foot .btn {
  background: rgba(255, 255, 255, .07);
  border-color: rgba(255, 255, 255, .14);
  color: #d7e1f2;
}
.side-foot .btn:hover { background: rgba(255, 255, 255, .13); border-color: rgba(255, 255, 255, .22); }

/* ---------- 顶栏 ---------- */
.topbar { box-shadow: 0 1px 2px rgba(16, 24, 40, .03); }

/* ---------- 数据看板 ---------- */
.dash-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 20px 22px;
  margin-bottom: 16px;
  border-radius: 14px;
  background: linear-gradient(115deg, #12244a 0%, #1e3a8a 58%, #27549e 100%);
  color: #fff;
  box-shadow: 0 8px 22px rgba(20, 45, 110, .22);
  position: relative;
  overflow: hidden;
}
.dash-hero::after {
  content: '';
  position: absolute;
  right: -60px;
  top: -80px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(109, 155, 255, .35) 0%, rgba(109, 155, 255, 0) 70%);
  pointer-events: none;
}
.dash-hi { font-size: 21px; font-weight: 700; letter-spacing: .01em; }
.dash-sub { font-size: 12.5px; color: #b9cbf2; margin-top: 5px; }
.dash-actions { display: flex; gap: 8px; position: relative; z-index: 1; }
.dash-actions .btn { border-color: rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .1); color: #fff; }
.dash-actions .btn:hover { background: rgba(255, 255, 255, .2); }
.dash-actions .btn.primary { background: #fff; color: #1e3a8a; border-color: #fff; box-shadow: none; }
.dash-actions .btn.primary:hover { background: #eef2ff; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.kpi {
  background: #fff;
  border: 1px solid #e7ebf2;
  border-radius: 12px;
  padding: 16px 17px;
  display: flex;
  gap: 13px;
  align-items: flex-start;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
  transition: box-shadow .15s, transform .15s;
}
.kpi:hover { box-shadow: 0 6px 16px rgba(16, 24, 40, .08); transform: translateY(-1px); }
.kpi-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 40px;
}
.kpi-body { min-width: 0; }
.kpi-value {
  font-size: 24px; font-weight: 700; color: #0f172a; line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.kpi-label { font-size: 12.5px; color: #64748b; margin-top: 2px; }
.kpi-sub { font-size: 11.5px; color: #94a3b8; margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-delta { font-size: 11.5px; font-weight: 600; }
.kpi-delta.up { color: #15803d; }
.kpi-delta.down { color: #b91c1c; }

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.dash-side { display: flex; flex-direction: column; gap: 14px; }
.dash-side .card { margin-bottom: 0; }

/* 图表 */
.dash-chart { width: 100%; height: auto; display: block; }
.cbar-val { font-size: 12px; font-weight: 700; fill: #1e293b; }
.cbar-amt { font-size: 10px; fill: #eef2ff; font-weight: 600; }
.cbar-month { font-size: 11px; fill: #64748b; }
.cbar-zero { font-size: 11px; fill: #cbd5e1; }
.chart-legend { font-size: 11.5px; color: #94a3b8; margin-top: 8px; text-align: center; }
.chart-empty {
  padding: 44px 20px;
  text-align: center;
  color: #94a3b8;
  font-size: 13px;
  line-height: 2;
  border: 1px dashed #dbe2ec;
  border-radius: 10px;
  background: #fafbfe;
}

/* 快捷出单 */
.quick-docs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.qdoc {
  text-align: left;
  border: 1px solid #e7ebf2;
  background: #fafbfe;
  border-radius: 10px;
  padding: 10px 13px;
  transition: border-color .15s, background .15s, transform .15s;
}
.qdoc:hover { border-color: #6d9bff; background: #f0f4ff; transform: translateY(-1px); }
.qdoc b { display: block; font-size: 13.5px; color: #1e3a8a; }
.qdoc span { display: block; font-size: 11px; color: #94a3b8; margin-top: 3px; }

/* 最近业务单 */
.recent-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 6px;
  border-bottom: 1px solid #f1f4f9;
  cursor: pointer;
  border-radius: 8px;
}
.recent-row:last-child { border-bottom: 0; }
.recent-row:hover { background: #f6f8fd; }
.rr-main { min-width: 0; }
.rr-main b { display: block; font-size: 13px; color: #111827; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rr-main span { display: block; font-size: 11.5px; color: #94a3b8; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rr-amt { font-size: 13px; font-weight: 700; color: #0f766e; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* 新手引导 */
.onboarding { border: 1px solid #dbe7ff; background: linear-gradient(180deg, #f5f8ff 0%, #fff 100%); }
.ob-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.ob-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 13px;
  border: 1px solid #e7ebf2;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.ob-step:hover { border-color: #6d9bff; transform: translateY(-1px); }
.ob-step.done { border-color: #bbf7d0; background: #f0fdf4; }
.ob-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: #1e3a8a; color: #fff;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 24px;
}
.ob-step.done .ob-num { background: #16a34a; }
.ob-step b { display: block; font-size: 13px; color: #111827; }
.ob-step span { display: block; font-size: 11.5px; color: #94a3b8; margin-top: 3px; line-height: 1.5; }

@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: 1fr; }
  .ob-steps { grid-template-columns: 1fr; }
}
