:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-bg: #eff6ff;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #2563eb;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 14px; }
.hidden { display: none !important; }

/* ===== 登录页 ===== */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  padding: 20px;
}
.login-box {
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo { font-size: 48px; text-align: center; }
.login-title { text-align: center; font-size: 22px; margin-top: 8px; }
.login-sub { text-align: center; color: var(--text-muted); margin: 6px 0 28px; }
.login-form { display: flex; flex-direction: column; gap: 8px; }
.login-label { font-size: 13px; color: #374151; font-weight: 600; }
.login-input {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  margin-bottom: 10px;
  transition: border-color .15s;
}
.login-input:focus { border-color: var(--primary); }
.login-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 13px;
  font-size: 16px;
  font-weight: 600;
  margin-top: 8px;
  transition: background .15s;
}
.login-btn:hover { background: #1d4ed8; }
.login-error { color: var(--danger); font-size: 13px; text-align: center; margin-top: 10px; }
.login-tip { text-align: center; color: #9ca3af; font-size: 12px; margin-top: 18px; }

/* ===== 布局 ===== */
.app-view { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-icon { font-size: 24px; }
.brand-text { font-size: 18px; font-weight: 700; color: #fff; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  color: var(--sidebar-text);
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
  background: rgba(37,99,235,.25);
  color: #fff;
  border-left-color: var(--primary);
}
.nav-icon { font-size: 16px; width: 22px; text-align: center; }
.sidebar-footer {
  padding: 16px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.user-name { color: #fff; font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: #94a3b8; }
.logout-btn {
  background: rgba(255,255,255,.08);
  color: #e2e8f0;
  border: none;
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
}
.logout-btn:hover { background: rgba(255,255,255,.15); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: #fff;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.page-title { font-size: 18px; font-weight: 700; }
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text);
}
.content { padding: 24px; flex: 1; }

/* ===== 通用卡片 ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
}
.section-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  transition: opacity .15s, background .15s;
}
.btn:hover { opacity: .9; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.form-label .required { color: var(--danger); }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color .15s;
  background: #fff;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--primary); }
.form-textarea { min-height: 100px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table th { color: var(--text-muted); font-weight: 600; font-size: 12px; background: #f9fafb; }
.table tbody tr:hover { background: #f9fafb; }
.table .clickable { cursor: pointer; }

/* ===== 标签 ===== */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}
.tag-pending { background: #fef3c7; color: #b45309; }
.tag-dispatched { background: #dbeafe; color: #1d4ed8; }
.tag-processing { background: #ede9fe; color: #6d28d9; }
.tag-done { background: #d1fae5; color: #047857; }
.tag-cancel { background: #e5e7eb; color: #6b7280; }
.tag-high { background: #fee2e2; color: #b91c1c; }
.tag-mid { background: #fef3c7; color: #b45309; }
.tag-low { background: #e5e7eb; color: #4b5563; }
.tag-type { background: #e0e7ff; color: #3730a3; }

/* ===== 仪表盘 ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.stat-label { font-size: 12px; color: var(--text-muted); }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; }
.stat-value.blue { color: var(--primary); }
.stat-value.green { color: var(--success); }
.stat-value.orange { color: var(--warning); }
.stat-value.red { color: var(--danger); }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-label { width: 80px; font-size: 13px; color: var(--text-muted); flex-shrink: 0; }
.bar-track { flex: 1; background: #f3f4f6; border-radius: 6px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 6px; transition: width .4s; }
.bar-num { width: 40px; text-align: right; font-size: 13px; font-weight: 600; flex-shrink: 0; }

/* ===== 工具栏 ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar .form-input, .toolbar .form-select {
  width: auto;
  min-width: 140px;
}
.toolbar .spacer { flex: 1; }
.search-input { flex: 1; min-width: 200px; }

/* ===== 弹窗 ===== */
.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
}
.modal-panel {
  position: relative;
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  overflow-y: auto;
  z-index: 1;
}
.modal-panel.small { max-width: 420px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--text-muted); }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ===== 列表页 ===== */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 600; font-size: 14px; }
.list-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.empty-state {
  text-align: center;
  padding: 60px 0;
  color: var(--text-muted);
}
.empty-icon { font-size: 52px; margin-bottom: 12px; }
.pagination { display: flex; gap: 8px; justify-content: center; align-items: center; margin-top: 16px; }
.page-btn {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
}
.page-btn:disabled { opacity: .4; cursor: not-allowed; }
.page-info { font-size: 13px; color: var(--text-muted); }

/* ===== 详情 ===== */
.detail-head {
  background: linear-gradient(135deg, var(--primary), #3b82f6);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.detail-head .order-no { font-size: 13px; opacity: .9; }
.detail-head .detail-title { font-size: 20px; font-weight: 700; margin-top: 6px; }
.detail-tags { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.info-item { padding: 10px; background: #f9fafb; border-radius: 8px; }
.info-item .info-label { font-size: 12px; color: var(--text-muted); }
.info-item .info-value { font-size: 14px; font-weight: 600; margin-top: 4px; word-break: break-all; }
.detail-section { margin-bottom: 16px; }
.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  max-width: 80%;
  word-break: break-all;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform .25s;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mask {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 80;
  }
  .mobile-menu-btn { display: block; }
  .content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .form-input, .toolbar .form-select { width: 100%; }
}

/* 二维码容器 */
.qr-box {
  text-align: center;
  padding: 20px;
}
.qr-placeholder {
  width: 180px;
  height: 180px;
  margin: 0 auto;
  background: #f9fafb;
  border: 1px dashed var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* 图片上传网格 */
.img-upload-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}
.img-thumb-wrap {
  position: relative;
  width: 80px;
  height: 80px;
}
.img-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  background: #f3f4f6;
  cursor: pointer;
  border: 1px solid var(--border);
}
.img-thumb-del {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  line-height: 18px;
  text-align: center;
  background: rgba(0,0,0,.65);
  color: #fff;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}
