/* ============= 重置与基础 ============= */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
               "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #1f2937;
  background: #f3f4f6;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font: inherit; }
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-weight: 600; }
table { width: 100%; border-collapse: collapse; }

/* ============= 顶栏 ============= */
.topbar {
  height: 60px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.topbar-left { display: flex; align-items: center; gap: 32px; }
.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 22px; }
.logo-text { font-size: 18px; font-weight: 700; color: #111827; }
.logo-badge {
  font-size: 11px;
  background: #fef3c7;
  color: #92400e;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}
.role-switch { display: flex; gap: 4px; background: #f3f4f6; padding: 4px; border-radius: 8px; }
.role-btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
  transition: all 0.15s;
}
.role-btn:hover { color: #111827; }
.role-btn.active { background: #fff; color: #2563eb; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.user-info { display: flex; align-items: center; gap: 8px; }
.user-avatar {
  width: 32px; height: 32px;
  background: #2563eb; color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}
.user-name { font-size: 14px; font-weight: 500; }
.user-role { font-size: 12px; color: #6b7280; }
.notif-btn {
  position: relative;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 16px;
  color: #4b5563;
}
.notif-btn:hover { background: #f3f4f6; }
.notif-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: #ef4444; color: #fff;
  font-size: 10px;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
}
.role-pick {
  padding: 6px 14px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  color: #374151;
  background: #fff;
}
.role-pick:hover { background: #f9fafb; }

/* ============= 主体 ============= */
.main {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 60px);
}

/* ============= 侧栏 ============= */
.sidebar {
  background: #fff;
  border-right: 1px solid #e5e7eb;
  padding: 16px 12px;
  overflow-y: auto;
}
.nav-section { margin-bottom: 20px; }
.nav-section-title {
  font-size: 11px;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 12px 8px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 6px;
  color: #4b5563;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 2px;
  transition: all 0.12s;
}
.nav-item:hover { background: #f3f4f6; color: #111827; }
.nav-item.active { background: #eff6ff; color: #2563eb; font-weight: 500; }
.nav-item .nav-icon { font-size: 16px; }
.nav-item .nav-count {
  margin-left: auto;
  font-size: 11px;
  background: #ef4444;
  color: #fff;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 500;
}
.nav-item.active .nav-count { background: #2563eb; }

/* ============= 内容区 ============= */
.content {
  padding: 24px 32px;
  overflow-y: auto;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title { font-size: 22px; font-weight: 600; color: #111827; }
.page-subtitle { font-size: 13px; color: #6b7280; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; }

/* ============= 卡片 ============= */
.card {
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  padding: 20px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title .count {
  font-size: 12px;
  color: #6b7280;
  font-weight: 400;
}
.card-row { display: flex; gap: 16px; flex-wrap: wrap; }

/* ============= 按钮 ============= */
.btn {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-secondary { background: #fff; color: #374151; border-color: #d1d5db; }
.btn-secondary:hover { background: #f9fafb; }
.btn-success { background: #10b981; color: #fff; }
.btn-success:hover { background: #059669; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { color: #6b7280; }
.btn-ghost:hover { color: #111827; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.link-btn { color: #2563eb; font-size: 12px; }
.link-btn:hover { text-decoration: underline; }

/* ============= 表单 ============= */
.form-row { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  color: #374151;
  font-weight: 500;
  margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  transition: border-color 0.12s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: #6b7280; margin-top: 4px; }
.form-row-inline { display: flex; gap: 12px; align-items: center; }
.form-row-inline .form-row { flex: 1; margin-bottom: 0; }

/* ============= 表格 ============= */
.tbl {
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
}
.tbl table { border-collapse: collapse; }
.tbl th, .tbl td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
}
.tbl th {
  background: #f9fafb;
  font-weight: 500;
  color: #6b7280;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: #f9fafb; }
.tbl-actions { display: flex; gap: 8px; }

/* ============= 标签/状态 ============= */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  background: #f3f4f6;
  color: #4b5563;
}
.tag-blue { background: #dbeafe; color: #1e40af; }
.tag-green { background: #d1fae5; color: #065f46; }
.tag-yellow { background: #fef3c7; color: #92400e; }
.tag-red { background: #fee2e2; color: #991b1b; }
.tag-purple { background: #e9d5ff; color: #6b21a8; }
.tag-gray { background: #e5e7eb; color: #374151; }

/* 状态色 */
.status { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; }
.status-draft { background: #f3f4f6; color: #6b7280; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-paid { background: #dbeafe; color: #1e40af; }
.status-producing { background: #e9d5ff; color: #6b21a8; }
.status-shipped { background: #d1fae5; color: #065f46; }
.status-inuse { background: #c7d2fe; color: #3730a3; }
.status-scrap { background: #fee2e2; color: #991b1b; }
.status-completed { background: #e5e7eb; color: #1f2937; }
.status-cancelled { background: #f3f4f6; color: #9ca3af; text-decoration: line-through; }

/* ============= KPI 卡片 ============= */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.kpi {
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.kpi-label { font-size: 12px; color: #6b7280; margin-bottom: 6px; }
.kpi-value { font-size: 26px; font-weight: 700; color: #111827; line-height: 1.2; }
.kpi-unit { font-size: 14px; color: #6b7280; font-weight: 400; margin-left: 4px; }
.kpi-trend { font-size: 12px; margin-top: 6px; }
.kpi-trend.up { color: #10b981; }
.kpi-trend.down { color: #ef4444; }
.kpi-accent { position: absolute; top: 0; right: 0; font-size: 36px; opacity: 0.08; }

/* ============= 模具库 ============= */
.mold-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.mold-card {
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
  transition: all 0.15s;
  cursor: pointer;
}
.mold-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); transform: translateY(-1px); }
.mold-card-img {
  height: 140px;
  background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 48px;
  color: #4338ca;
}
.mold-card-body { padding: 14px 16px; }
.mold-card-name { font-size: 15px; font-weight: 600; color: #111827; margin-bottom: 6px; }
.mold-card-meta { font-size: 12px; color: #6b7280; margin-bottom: 8px; }
.mold-card-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.mold-card-price {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px solid #f3f4f6;
}
.mold-card-price .label { font-size: 11px; color: #6b7280; }
.mold-card-price .value { font-size: 16px; font-weight: 700; color: #dc2626; }
.mold-card-price .unit { font-size: 11px; color: #6b7280; font-weight: 400; }

/* ============= 时间线 ============= */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 8px; top: 6px; bottom: 6px;
  width: 2px;
  background: #e5e7eb;
}
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -24px; top: 4px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #d1d5db;
}
.timeline-item.done::before { background: #10b981; border-color: #10b981; }
.timeline-item.current::before { background: #2563eb; border-color: #2563eb; box-shadow: 0 0 0 4px rgba(37,99,235,0.15); }
.timeline-title { font-size: 14px; font-weight: 500; color: #111827; }
.timeline-meta { font-size: 12px; color: #6b7280; margin-top: 2px; }

/* ============= 订单详情 ============= */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
}
.detail-row { display: flex; flex-direction: column; }
.detail-label { font-size: 12px; color: #6b7280; margin-bottom: 2px; }
.detail-value { font-size: 14px; color: #111827; font-weight: 500; }
.detail-value.large { font-size: 18px; }
.detail-value.danger { color: #dc2626; }

/* ============= 通知面板 ============= */
.notif-panel {
  position: absolute;
  top: 56px; right: 100px;
  width: 360px;
  max-height: 480px;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 200;
  display: flex;
  flex-direction: column;
}
.notif-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
}
.notif-panel-head h4 { font-size: 14px; }
.notif-panel-body { overflow-y: auto; flex: 1; }
.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f9fafb;
  font-size: 13px;
  cursor: pointer;
}
.notif-item:hover { background: #f9fafb; }
.notif-item.unread { background: #eff6ff; }
.notif-item.unread:hover { background: #dbeafe; }
.notif-content { color: #1f2937; margin-bottom: 4px; }
.notif-time { font-size: 11px; color: #9ca3af; }

/* ============= Modal ============= */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-mask[hidden] { display: none !important; }
.notif-panel[hidden] { display: none !important; }
.modal {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal.large { max-width: 720px; }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}
.modal-head h3 { font-size: 16px; }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 6px;
  font-size: 20px;
  color: #6b7280;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: #f3f4f6; color: #111827; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 12px 20px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ============= Toast ============= */
.toast-container {
  position: fixed;
  top: 80px; right: 24px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-left: 4px solid #2563eb;
  border-radius: 6px;
  padding: 12px 16px;
  font-size: 13px;
  min-width: 240px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  animation: slideIn 0.2s ease-out;
}
.toast.success { border-left-color: #10b981; }
.toast.error { border-left-color: #ef4444; }
.toast.warning { border-left-color: #f59e0b; }
@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============= 看板 ============= */
.kanban {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  overflow-x: auto;
}
.kanban-col {
  background: #f9fafb;
  border-radius: 8px;
  padding: 12px;
  min-height: 200px;
}
.kanban-col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}
.kanban-col-title { font-size: 13px; font-weight: 600; }
.kanban-col-count { font-size: 11px; color: #6b7280; }
.kanban-card {
  background: #fff;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 12px;
  border: 1px solid #e5e7eb;
  cursor: pointer;
}
.kanban-card:hover { box-shadow: 0 2px 6px rgba(0,0,0,0.08); }
.kanban-card-title { font-weight: 500; color: #111827; margin-bottom: 4px; }
.kanban-card-meta { color: #6b7280; font-size: 11px; }

/* ============= 筛选条 ============= */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  background: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  margin-bottom: 16px;
}
.filter-bar .form-input,
.filter-bar .form-select { width: auto; min-width: 140px; }

/* ============= 空状态 ============= */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: #9ca3af;
}
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-text { font-size: 14px; }

/* ============= 杂项 ============= */
.divider { height: 1px; background: #e5e7eb; margin: 16px 0; }
.text-muted { color: #6b7280; }
.text-success { color: #10b981; }
.text-warning { color: #f59e0b; }
.text-danger { color: #ef4444; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.between { justify-content: space-between; }
.center { align-items: center; }
.w-full { width: 100%; }
.hidden { display: none !important; }
