/* 慕多家具 ERP V1 - 浅色主题 */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #8b5a2b; --primary-dark: #6d4520; --bg: #f6f4f0; --card: #ffffff;
  --border: #e5e0d8; --text: #2c2a26; --muted: #8a857c; --green: #2e8b57; --red: #c0392b;
  --orange: #d97706; --blue: #2563eb;
}
body { font-family: "Microsoft YaHei", "PingFang SC", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #3d2b1f 0%, #6d4520 50%, #8b5a2b 100%); }
.login-card { background: #fff; border-radius: 12px; padding: 42px 46px; width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card h1 { font-size: 22px; text-align: center; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 28px; font-size: 13px; }
.login-card input { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.login-card button { width: 100%; padding: 12px; background: var(--primary); color: #fff; border: none; border-radius: 8px; font-size: 15px; cursor: pointer; }
.login-card button:hover { background: var(--primary-dark); }
.login-tip { margin-top: 18px; font-size: 12px; color: var(--muted); line-height: 1.8; background: #faf8f5; padding: 10px 12px; border-radius: 8px; }

/* 布局 */
.topbar { background: #fff; border-bottom: 1px solid var(--border); padding: 0 24px; display: flex; align-items: center; height: 56px; position: sticky; top: 0; z-index: 50; }
.topbar .logo { font-size: 17px; font-weight: 700; color: var(--primary); margin-right: 36px; white-space: nowrap; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { padding: 8px 16px; border-radius: 8px; cursor: pointer; color: var(--text); text-decoration: none; font-size: 14px; }
.topbar nav a:hover { background: #f1ece4; }
.topbar nav a.active { background: var(--primary); color: #fff; }
.topbar .userbox { display: flex; align-items: center; gap: 12px; }
.badge-role { background: #f1ece4; color: var(--primary-dark); font-size: 12px; padding: 2px 8px; border-radius: 10px; }
.link-plain { color: var(--muted); cursor: pointer; font-size: 13px; }
.link-plain:hover { color: var(--red); }

.container { max-width: 1280px; margin: 20px auto; padding: 0 24px; }
.page-title { font-size: 18px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }

/* 卡片/统计 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.stat-card .num { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat-card .lbl { color: var(--muted); font-size: 13px; }
.stat-card.warn .num { color: var(--orange); }
.stat-card.ok .num { color: var(--green); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 18px; }
.card h3 { font-size: 15px; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }

/* 表格 */
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; padding: 9px 10px; background: #faf8f5; border-bottom: 2px solid var(--border); font-size: 13px; color: var(--muted); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid #f0ece5; font-size: 13px; vertical-align: middle; }
.tbl tr:hover td { background: #fbfaf7; }
.tbl .r { text-align: right; }
.tbl a { color: var(--blue); text-decoration: none; cursor: pointer; }

/* 标签 */
.tag { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; white-space: nowrap; }
.tag-pending { background: #fef3c7; color: #92400e; }
.tag-approved { background: #dbeafe; color: #1e40af; }
.tag-producing { background: #ffedd5; color: #9a3412; }
.tag-warehoused { background: #ede9fe; color: #5b21b6; }
.tag-partial { background: #fce7f3; color: #9d174d; }
.tag-shipped { background: #d1fae5; color: #065f46; }
.tag-completed { background: #e2e8f0; color: #334155; }
.tag-rejected { background: #fee2e2; color: #991b1b; }
.tag-grey { background: #f1f5f9; color: #64748b; }
.tag-prod1 { background: #f1f5f9; color: #475569; }   /* 待生产 */
.tag-prod2 { background: #ffedd5; color: #9a3412; }   /* 生产中 */
.tag-prod3 { background: #d1fae5; color: #065f46; }   /* 已完成 */
.tag-prod4 { background: #ede9fe; color: #5b21b6; }   /* 已进仓 */
.tag-pay-ok { background: #d1fae5; color: #065f46; }
.tag-pay-no { background: #fee2e2; color: #991b1b; }
.tag-red { background: #fee2e2; color: #b91c1c; font-weight: 700; }

/* 按钮 */
.btn { display: inline-block; padding: 7px 16px; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 13px; color: var(--text); }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.btn-red { background: var(--red); border-color: var(--red); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 筛选条 */
.filter-bar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.filter-bar input, .filter-bar select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: #fff; }

/* 步骤条 */
.steps { display: flex; align-items: center; margin: 10px 0 4px; }
.step { display: flex; align-items: center; }
.step .dot { width: 26px; height: 26px; border-radius: 50%; background: #e7e2d9; color: #999; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.step .lbl { margin-left: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.step.done .dot { background: var(--green); color: #fff; }
.step.done .lbl { color: var(--green); }
.step.current .dot { background: var(--primary); color: #fff; }
.step.current .lbl { color: var(--primary); font-weight: 700; }
.step-line { width: 34px; height: 2px; background: #e7e2d9; margin: 0 8px; }
.step-line.done { background: var(--green); }

/* 详情网格 */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; }
.grid-2 .field .k { color: var(--muted); font-size: 12px; }
.grid-2 .field .v { font-size: 14px; margin-top: 2px; }

/* 时间线 */
.timeline { margin-top: 6px; }
.tl-item { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px dashed #eee7dc; font-size: 13px; }
.tl-item .t { color: var(--muted); white-space: nowrap; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: #fff; border-radius: 12px; width: 92%; max-width: 1080px; max-height: 92vh; overflow: auto; padding: 24px; }
.modal h2 { font-size: 17px; margin-bottom: 18px; }
.modal .form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 16px; margin-bottom: 16px; }
.modal label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
.modal input, .modal select, .modal textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.modal .span-2 { grid-column: span 2; } .modal .span-3 { grid-column: span 3; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* 明细编辑行 */
.items-edit table td input, .items-edit table td select { padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; width: 100%; min-width: 70px; }
.items-edit table td { padding: 4px 4px; }

/* toast */
#toast { position: fixed; top: 70px; right: 24px; background: #2c2a26; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px; display: none; z-index: 200; }

.muted { color: var(--muted); font-size: 12px; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.money { font-weight: 700; color: var(--primary-dark); }
.red { color: var(--red); } .green { color: var(--green); }

/* 打印订货单 */
#printArea { display: none; }
@media print {
  body * { visibility: hidden; }
  #printArea, #printArea * { visibility: visible; }
  #printArea { display: block; position: absolute; left: 0; top: 0; width: 100%; padding: 30px; }
  .no-print { display: none !important; }
}
#printArea h2 { text-align: center; letter-spacing: 8px; margin-bottom: 18px; }
#printArea .print-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 30px; font-size: 13px; margin-bottom: 14px; }

/* 最近订单表头筛选下拉 */
.col-filter { font-size: 11px; padding: 1px 4px; margin-top: 3px; max-width: 132px; border: 1px solid var(--border); border-radius: 5px; background: #fff; color: var(--text); cursor: pointer; }
.col-filter:hover { border-color: var(--primary); }

/* 订单管理：计划交货 / 交货倒计 / 操作 列不折行 */
.tbl td.nw, .tbl th.nw { white-space: nowrap; }

/* 交货倒计时高亮：≤10 天加粗高亮（黄），逾期 / 今天到期标红 */
.due { display: inline-block; white-space: nowrap; font-weight: 800; padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.due-soon { background: #fef3c7; color: #b45309; border: 1px solid #f59e0b; }
.due-late { background: #fee2e2; color: #b91c1c; border: 1px solid #ef4444; }

/* 各工厂任务概览（生产管理） */
.tbl th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.tbl th.sortable:hover { color: var(--primary); }
.tbl th.sorted { color: var(--primary-dark); }
.tbl tfoot tr.fac-total td { font-weight: 700; background: #f7f8fa; border-top: 2px solid var(--border); }
.money-due { color: #b91c1c; font-weight: 700; }
