:root {
  --primary: #e8590c;
  --primary-dark: #c2410c;
  --primary-light: #fff4e6;
  --bg: #f6f5f2;
  --card: #ffffff;
  --text: #2d2a26;
  --muted: #8a847c;
  --border: #e8e4de;
  --danger: #d64545;
  --ok: #2f9e44;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---------- 顶栏 ---------- */
.topbar {
  background: linear-gradient(135deg, #2d2a26 0%, #4a4038 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  padding: 6px 10px;
  border-radius: 8px;
  letter-spacing: 1px;
}
.brand h1 { font-size: 19px; font-weight: 600; }
.tabs { display: flex; gap: 6px; }
.tab {
  background: transparent;
  color: #e8e2da;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
}
.tab:hover { background: rgba(255,255,255,.1); color: #fff; }
.tab.active { background: var(--primary); color: #fff; font-weight: 600; }
.user-box { display: flex; align-items: center; gap: 10px; }
.user-label { font-size: 13px; opacity: .92; }

/* ---------- 登录 ---------- */
.login-mask {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #2d2a26 0%, #4a4038 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.login-mask[hidden] { display: none; }
.login-box {
  background: #fff;
  border-radius: 16px;
  padding: 34px 40px 30px;
  width: 360px;
  max-width: 92vw;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
  text-align: center;
}
.login-logo {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  padding: 8px 16px;
  border-radius: 10px;
  letter-spacing: 2px;
}
.login-box h2 { margin: 14px 0 22px; font-size: 20px; color: var(--text); }
.login-box .input { width: 100%; margin-bottom: 12px; padding: 10px 14px; }
.login-error { color: var(--danger); font-size: 13px; min-height: 20px; margin-bottom: 8px; }
.login-box .btn { width: 100%; padding: 10px; font-size: 15px; }

main { max-width: 1280px; margin: 0 auto; padding: 22px 24px 60px; }
.page { display: none; }
.page.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; } }

/* ---------- 页面头 ---------- */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.page-head h2 { font-size: 20px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sep { color: var(--muted); }

/* ---------- 控件 ---------- */
.input, select.input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  outline: none;
  min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(232,89,12,.12); }
.input.search { width: 220px; }

.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.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); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); background: #fff5f5; }
.btn.small { padding: 5px 10px; font-size: 13px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card h3 { font-size: 16px; margin-bottom: 12px; }

/* ---------- 表格 ---------- */
.grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.grid-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  padding: 9px 10px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.grid-table td {
  padding: 10px;
  border-bottom: 1px solid #f0ede8;
  vertical-align: middle;
}
.grid-table tbody tr:hover { background: #faf8f5; }
.grid-table.compact th, .grid-table.compact td { padding: 7px 10px; }
.row-actions { display: flex; gap: 6px; }
.row-actions .btn { padding: 4px 10px; font-size: 13px; }
.empty {
  color: var(--muted);
  text-align: center;
  padding: 40px 10px;
}
.money { font-variant-numeric: tabular-nums; font-weight: 600; }
.tag {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 12px;
}

/* ---------- 商品页 ---------- */
.product-layout { display: grid; grid-template-columns: 230px 1fr; gap: 16px; align-items: start; }
.cat-panel { position: sticky; top: 76px; }
.cat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-weight: 600; }
.cat-list { list-style: none; }
.cat-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: background .12s;
}
.cat-list li:hover { background: #f6f3ef; }
.cat-list li.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.cat-list .count { color: var(--muted); font-size: 12px; }
.cat-list .cat-ops { display: none; gap: 4px; }
.cat-list li:hover .cat-ops { display: flex; }
.cat-ops button {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 4px;
}
.cat-ops button:hover { color: var(--primary); }
.cat-ops button.del:hover { color: var(--danger); }
.cat-filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--muted);
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- 弹窗 ---------- */
.modal-mask, .confirm-mask {
  position: fixed;
  inset: 0;
  background: rgba(30,25,20,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fade .15s ease;
}
.modal-mask[hidden], .confirm-mask[hidden] { display: none; }
.modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: auto;
  padding: 22px;
  animation: pop .18s ease;
}
.modal.wide {
  width: fit-content;
  min-width: min(900px, 94vw);
  max-width: min(1200px, 96vw);
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h3 { font-size: 17px; margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field .input, .field textarea { width: 100%; }
.field textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  outline: none;
}
.field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(232,89,12,.12); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.confirm { background: #fff; border-radius: 12px; padding: 22px; max-width: 380px; width: 100%; text-align: center; }
.confirm p { margin: 8px 0 18px; }
.confirm .btn { min-width: 90px; }

/* ---------- 订单 ---------- */
.order-detail-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.order-detail-head h3 { margin: 0; }
.qty-input {
  width: 72px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  text-align: center;
  font-size: 14px;
  outline: none;
}
.qty-input:focus { border-color: var(--primary); }
.price-input { width: 86px; }
.batch-hint { color: var(--muted); font-size: 12px; margin-top: 6px; line-height: 1.6; }
#od-batch {
  width: 100%;
  min-height: 140px;
  font-size: 14px;
  line-height: 1.7;
}
.import-preview { margin-top: 10px; border: 1px solid var(--border); border-radius: 8px; max-height: 200px; overflow: auto; }
.import-preview table { width: 100%; border-collapse: collapse; font-size: 13px; }
.import-preview td, .import-preview th { padding: 6px 10px; border-bottom: 1px solid #f0ede8; text-align: left; }
.import-preview .warn { color: var(--danger); }
.import-preview .new { color: var(--ok); }

/* ---------- 商品勾选列表（会员常用清单） ---------- */
.ws-product-list { max-height: 280px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.ws-product-list input[type="checkbox"] { accent-color: var(--primary); width: 15px; height: 15px; cursor: pointer; }

/* ---------- 生产计划 ---------- */
.pp-day { margin-bottom: 16px; }
.pp-day-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.pp-day-head strong { font-size: 15px; }
.pp-days { display: flex; flex-wrap: wrap; gap: 8px; }
.pp-day-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 14px;
  background: #fff;
  user-select: none;
}
.pp-day-chip input { accent-color: var(--primary); width: 15px; height: 15px; }
.pp-day-chip:has(input:checked) { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); font-weight: 600; }
.pp-empty-day {
  color: var(--muted);
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
}
/* ---------- 统计 ---------- */
.stats-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; align-items: start; }
.pp-qty-cards { display: flex; gap: 16px; flex-wrap: wrap; }
.pp-qty-card {
  flex: 1;
  min-width: 180px;
  background: var(--primary-light);
  border: 1px solid #ffd8bd;
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.pp-qty-label { color: var(--primary-dark); font-weight: 600; font-size: 15px; }
.pp-qty-value { font-size: 32px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.pp-qty-list { margin-top: 12px; }
.my-stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.my-stat-card { text-align: center; }
.my-stat-card h3 { font-size: 15px; color: var(--muted); font-weight: 600; margin-bottom: 10px; }
.my-stat-value { font-size: 34px; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.my-today { font-size: 18px; font-weight: 600; color: var(--primary-dark); }
@media (max-width: 900px) {
  .my-stat-grid { grid-template-columns: 1fr; }
}
.daily-chart { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding: 8px 4px 0; margin-bottom: 14px; }
.bar-col { display: flex; flex-direction: column; align-items: center; flex: 1; min-width: 0; }
.bar { width: 100%; max-width: 44px; background: linear-gradient(180deg, #ff922b, var(--primary)); border-radius: 6px 6px 2px 2px; min-height: 3px; transition: height .3s ease; }
.bar-label { font-size: 11px; color: var(--muted); margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bar-count { font-size: 12px; font-weight: 700; color: var(--primary-dark); margin-bottom: 3px; }
.table-wrap { overflow-x: auto; }
.matrix th, .matrix td { text-align: center; white-space: nowrap; }
.matrix th:first-child, .matrix td:first-child { text-align: left; font-weight: 600; }
.matrix .total-row td { background: var(--primary-light); font-weight: 700; }
.matrix .total-col { background: #f8f6f2; font-weight: 700; }
.matrix td.hot { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #2d2a26;
  color: #fff;
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  animation: slideDown .2s ease;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
@keyframes slideDown { from { transform: translateY(-12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .product-layout, .stats-grid { grid-template-columns: 1fr; }
  .cat-panel { position: static; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .tabs { width: 100%; overflow-x: auto; }
  .input.search { width: 100%; }
}
