:root {
  --primary: #8b5a3c;
  --primary-light: #b8864a;
  --primary-dark: #5e4029;
  --primary-bg: #faf6f1;
  --primary-bg-2: #f3ead9;
  --celadon: #5d9482;
  --celadon-bg: #e6f0eb;
  --rust: #b05036;
  --rust-bg: #f5e3dc;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --info: #2563eb;
  --info-bg: #dbeafe;
  
  --ink: #1f1b18;
  --ink-soft: #4b4541;
  --ink-light: #8a8580;
  --ink-lighter: #b8b3ae;
  
  --border: #e8e2db;
  --border-light: #f0ebe4;
  --bg: #f9f7f4;
  --white: #ffffff;
  
  --shadow-xs: 0 1px 2px rgba(31, 27, 24, 0.04);
  --shadow-sm: 0 1px 3px rgba(31, 27, 24, 0.06), 0 1px 2px rgba(31, 27, 24, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(31, 27, 24, 0.08), 0 2px 4px -2px rgba(31, 27, 24, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(31, 27, 24, 0.08), 0 4px 6px -4px rgba(31, 27, 24, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(31, 27, 24, 0.1), 0 8px 10px -6px rgba(31, 27, 24, 0.06);
  
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  
  --sidebar-w: 220px;
  --topbar-h: 60px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============ 侧边栏 ============ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.logo {
  padding: 20px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-light);
}

.logo-mark {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Noto Serif SC', serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--white);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(139, 90, 60, 0.25);
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.logo-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.5px;
}

.logo-text small {
  font-size: 10px;
  color: var(--ink-light);
  margin-top: 3px;
  letter-spacing: 1.5px;
}

.nav-menu {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--ink-soft);
  text-decoration: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
}

.nav-item:hover {
  background: var(--primary-bg);
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary-bg-2);
  color: var(--primary-dark);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--border);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-badge-red {
  background: var(--danger);
  color: var(--white);
}

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 6px;
}

.btn-export, .btn-import {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-export:hover, .btn-import:hover {
  background: var(--primary-bg);
  border-color: var(--primary-light);
  color: var(--primary);
}

.btn-export svg, .btn-import svg {
  width: 14px;
  height: 14px;
}

/* ============ 主内容区 ============ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.topbar-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.date-display {
  font-size: 13px;
  color: var(--ink-light);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(139, 90, 60, 0.3);
}

.btn-primary svg {
  width: 16px;
  height: 16px;
}

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ============ 工作台首页 ============ */
.dashboard {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  transition: all 0.3s ease;
  cursor: pointer;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--ink-light);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-card .stat-value {
  font-family: 'Noto Serif SC', serif;
  font-size: 28px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.2;
}

.stat-card .stat-trend {
  font-size: 11px;
  color: var(--ink-light);
  margin-top: 4px;
}

.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.info .stat-value { color: var(--info); }

.dashboard-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
}

.card-body {
  padding: 12px 20px 20px;
}

/* 订单列表 */
.order-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.order-item {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr 80px;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  align-items: center;
  border: 1px solid transparent;
}

.order-item:hover {
  background: var(--primary-bg);
  border-color: var(--primary-light);
}

.order-item .order-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.order-item .order-no {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.order-item .order-name {
  font-size: 12px;
  color: var(--ink-light);
}

.order-item .order-customer {
  font-size: 12px;
  color: var(--ink-soft);
}

.order-item .order-qty {
  font-size: 12px;
  color: var(--ink-soft);
}

.order-item .order-date {
  font-size: 12px;
  color: var(--ink-light);
}

.order-item .order-status {
  font-size: 11px;
  text-align: center;
}

/* 标签 */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  white-space: nowrap;
}

.tag-blue { background: var(--info-bg); color: var(--info); }
.tag-green { background: var(--success-bg); color: var(--success); }
.tag-orange { background: var(--warning-bg); color: var(--warning); }
.tag-red { background: var(--danger-bg); color: var(--danger); }
.tag-purple { background: #f3e8ff; color: #7c3aed; }
.tag-cyan { background: #cffafe; color: #0891b2; }
.tag-gray { background: #f3f4f6; color: #6b7280; }
.tag-yellow { background: #fef9c3; color: #ca8a04; }
.tag-clay { background: var(--primary-bg-2); color: var(--primary-dark); }

/* 预警列表 */
.alert-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border-left: 3px solid;
  cursor: pointer;
  transition: all 0.2s ease;
}

.alert-item:hover {
  transform: translateX(2px);
}

.alert-item.red {
  background: var(--danger-bg);
  border-left-color: var(--danger);
}

.alert-item.orange {
  background: var(--warning-bg);
  border-left-color: var(--warning);
}

.alert-item.yellow {
  background: #fef9c3;
  border-left-color: #ca8a04;
}

.alert-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-item.red .alert-icon { color: var(--danger); }
.alert-item.orange .alert-icon { color: var(--warning); }
.alert-item.yellow .alert-icon { color: #ca8a04; }

/* 预警区域闪烁高亮动画 */
@keyframes flashHighlight {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(141, 110, 99, 0);
    background-color: transparent;
  }
  25%, 75% {
    box-shadow: 0 0 0 4px rgba(141, 110, 99, 0.25);
    background-color: var(--primary-bg-2);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(141, 110, 99, 0.15);
    background-color: var(--primary-bg);
  }
}

.alert-section {
  transition: box-shadow .3s ease, background-color .3s ease;
  border-radius: 12px;
}

.alert-section.flash-highlight {
  animation: flashHighlight 0.6s ease-in-out 1;
}

.alert-content {
  flex: 1;
  min-width: 0;
}

.alert-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 2px;
}

.alert-desc {
  font-size: 12px;
  color: var(--ink-soft);
}

.alert-time {
  font-size: 11px;
  color: var(--ink-light);
  margin-top: 4px;
}

/* 今日清单 */
.checklist-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.checklist-item {
  display: flex;
  gap: 12px;
  padding: 14px;
  background: var(--bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--primary);
  transition: all 0.2s ease;
  cursor: pointer;
}

.checklist-item:hover {
  background: var(--white);
  box-shadow: var(--shadow-xs);
  border-color: var(--border);
}

.checklist-item.completed {
  opacity: 0.55;
}

.checklist-item.completed .checklist-title {
  text-decoration: line-through;
  color: var(--ink-light);
}

.checklist-item.priority-red { border-left-color: var(--danger); }
.checklist-item.priority-orange { border-left-color: var(--warning); }
.checklist-item.priority-yellow { border-left-color: var(--info); }

.checklist-checkbox {
  width: 22px;
  height: 22px;
  min-width: 22px;
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--white);
  margin-top: 2px;
}

.checklist-checkbox:hover {
  border-color: var(--primary);
}

.checklist-item.completed .checklist-checkbox {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

.checklist-checkbox svg {
  width: 14px;
  height: 14px;
}

.checklist-content {
  flex: 1;
  min-width: 0;
}

.checklist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.checklist-type {
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 500;
}

.checklist-priority {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.badge-danger { background: #fef2f2; color: var(--danger); }
.badge-warning { background: #fffbeb; color: var(--warning); }
.badge-info { background: #eff6ff; color: var(--info); }

.checklist-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
  line-height: 1.4;
}

.checklist-desc {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.5;
  margin-bottom: 8px;
}

.checklist-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============ 订单管理 ============ */
.page-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a8580' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E") 10px center no-repeat;
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(184, 134, 74, 0.1);
}

.filter-group {
  display: flex;
  gap: 4px;
  padding: 3px;
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.filter-btn {
  padding: 5px 12px;
  background: transparent;
  border: none;
  border-radius: 5px;
  font-size: 12px;
  color: var(--ink-light);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  color: var(--ink-soft);
}

.filter-btn.active {
  background: var(--primary-bg-2);
  color: var(--primary-dark);
  font-weight: 500;
}

/* 表格 */
.table-wrap {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  background: var(--bg);
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.sortable-header {
  cursor: pointer;
  user-select: none;
  transition: color .15s;
}
.sortable-header:hover {
  color: var(--primary);
}
.sort-icon {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  opacity: .6;
  min-width: 10px;
  text-align: center;
}
.sortable-header:hover .sort-icon {
  opacity: 1;
}
.sortable-header .sort-icon.active {
  color: var(--primary);
  opacity: 1;
  font-weight: 700;
}

.table td {
  padding: 12px;
  font-size: 13px;
  color: var(--ink);
  border-bottom: 1px solid var(--border-light);
}

.table tbody tr {
  cursor: pointer;
  transition: background 0.15s ease;
}

.table tbody tr:hover {
  background: var(--primary-bg);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table .col-no { font-weight: 600; }
.table .col-num { text-align: right; font-variant-numeric: tabular-nums; }
.table .col-center { text-align: center; }
.table .col-mono { font-family: 'SF Mono', 'Menlo', 'Consolas', monospace; font-size: 12px; color: var(--ink-soft); white-space: nowrap; }

/* 主从表 */
.master-table .master-row {
  background: var(--white);
}

.master-table .master-row:hover {
  background: var(--primary-bg);
}

.master-table .master-row.expanded {
  background: var(--primary-bg);
  border-bottom: 1px solid var(--border);
}

.expand-cell {
  text-align: center;
  padding: 0 8px !important;
}

.expand-icon {
  width: 18px;
  height: 18px;
  color: var(--ink-light);
  transition: transform 0.2s ease;
  display: inline-block;
  vertical-align: middle;
}

.master-row.expanded .expand-icon {
  transform: rotate(90deg);
  color: var(--primary);
}

.detail-row {
  background: var(--bg);
}

.detail-row > td {
  padding: 0 !important;
  border-bottom: 1px solid var(--border);
}

.detail-content {
  padding: 16px 24px 16px 48px;
}

/* 批次区块 */
.batch-section {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  overflow: hidden;
}

.batch-section:last-child {
  margin-bottom: 0;
}

.batch-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--primary-bg);
  border-bottom: 1px solid var(--border-light);
}

.batch-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-soft);
  flex-wrap: wrap;
}

.batch-index {
  background: var(--primary);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  font-size: 11px;
}

.batch-ship {
  font-weight: 600;
  color: var(--primary-dark);
}

.batch-divider {
  color: var(--border);
}

.batch-summary {
  font-size: 12px;
  color: var(--ink-light);
  font-weight: 500;
}

/* 子表 */
.sub-table {
  margin: 0;
  border: none;
}

.sub-table th {
  background: transparent;
  font-size: 11px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
}

.sub-table td {
  padding: 8px 12px;
  font-size: 12px;
  border-bottom: 1px solid var(--border-light);
}

.sub-table tr:last-child td {
  border-bottom: none;
}

.sub-table .sub-row {
  cursor: pointer;
}

.sub-table .sub-row:hover {
  background: var(--bg);
}

.action-link {
  color: var(--primary);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}

.action-link:hover {
  text-decoration: underline;
}

.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-light);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 14px;
}

/* ============ 抽屉 ============ */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 540px;
  max-width: 100vw;
  height: 100vh;
  z-index: 1000;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  pointer-events: none;
}

.drawer.open {
  transform: translateX(0);
  pointer-events: auto;
}

.drawer.maximized {
  width: 96vw;
}

.drawer.maximized .drawer-content {
  width: 100%;
}

.drawer-mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(31, 27, 24, 0.4);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.drawer.open .drawer-mask {
  opacity: 1;
}

.drawer-content {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  background: var(--white);
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
}

.drawer-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-header h3 {
  font-family: 'Noto Serif SC', serif;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}

.drawer-close, .modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--ink-light);
  cursor: pointer;
  transition: all 0.2s ease;
}

.drawer-close:hover, .modal-close:hover {
  background: var(--bg);
  color: var(--ink);
}

.drawer-close svg, .modal-close svg {
  width: 18px;
  height: 18px;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* 详情字段 */
.detail-section {
  margin-bottom: 24px;
}

.detail-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 6px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-field.full {
  grid-column: span 2;
}

.detail-field label {
  font-size: 11px;
  color: var(--ink-light);
  font-weight: 500;
}

.detail-field .value {
  font-size: 13px;
  color: var(--ink);
  font-weight: 500;
}

.detail-field .value.number {
  font-variant-numeric: tabular-nums;
}

/* 进度条 */
.progress-section {
  margin-bottom: 20px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.progress-label .label {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 500;
}

.progress-label .percent {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
}

.progress-bar {
  height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-light), var(--primary));
  border-radius: 3px;
  transition: width 0.5s ease;
}

.progress-fill.warning { background: linear-gradient(90deg, #fbbf24, var(--warning)); }
.progress-fill.danger { background: linear-gradient(90deg, #f87171, var(--danger)); }
.progress-fill.success { background: linear-gradient(90deg, #4ade80, var(--success)); }

/* ============ 模态框 ============ */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-mask {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(31, 27, 24, 0.5);
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 640px;
  max-height: 88vh;
  background: var(--white);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px);
  transition: transform 0.2s ease;
}

.modal.open .modal-content {
  transform: translateY(0);
}

.modal.maximized .modal-content {
  width: 96vw;
  max-width: 96vw;
  max-height: 96vh;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-family: 'Noto Serif SC', serif;
  font-size: 18px;
  font-weight: 600;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* 表单 */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field.full {
  grid-column: span 2;
}

.form-field label {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 500;
}

.form-field label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-input, .form-select, .form-textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
  background: var(--white);
  color: var(--ink);
  outline: none;
  transition: all 0.2s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(184, 134, 74, 0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
  user-select: none;
}

.checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

.form-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn-secondary {
  padding: 8px 16px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--bg);
  border-color: var(--ink-light);
}

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 10px 20px;
  background: var(--ink);
  color: var(--white);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s ease;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

/* ============ 样品管理 ============ */
.sample-card-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.sample-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
}

.sample-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--primary-light);
}

.sample-card-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sample-no {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.sample-card-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sample-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.sample-row .label {
  color: var(--ink-light);
}

.sample-row .value {
  color: var(--ink-soft);
  font-weight: 500;
}

.sample-card-footer {
  padding: 10px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--ink-light);
}

/* ============ 工厂管理 ============ */
.factory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.factory-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  transition: all 0.3s ease;
}

.factory-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.factory-name {
  font-family: 'Noto Serif SC', serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}

.factory-fullname {
  font-size: 12px;
  color: var(--ink-light);
  margin-bottom: 12px;
}

.factory-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
}

.factory-info-row {
  display: flex;
  justify-content: space-between;
}

.factory-info-row .label {
  color: var(--ink-light);
}

.factory-info-row .value {
  color: var(--ink-soft);
  font-weight: 500;
}

/* ============ 跟单规则 ============ */
.rules-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rule-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.rule-header {
  padding: 14px 20px;
  background: var(--primary-bg);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rule-name {
  font-family: 'Noto Serif SC', serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--primary-dark);
}

.rule-body {
  padding: 16px 20px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.7;
}

.rule-body ul {
  margin-left: 20px;
  margin-top: 6px;
}

.rule-body li {
  margin-bottom: 4px;
}

/* ============ 响应式 ============ */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .dashboard-row {
    grid-template-columns: 1fr;
  }
  .form-grid, .detail-grid {
    grid-template-columns: 1fr;
  }
  .form-field.full, .detail-field.full {
    grid-column: span 1;
  }
}

@media (max-width: 768px) {
  .sidebar {
    width: 60px;
  }
  .logo-text, .nav-item span, .sidebar-footer span {
    display: none;
  }
  .nav-badge {
    position: absolute;
    top: 4px;
    right: 4px;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .topbar-actions .date-display {
    display: none;
  }
}

/* 滚动条 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ink-lighter);
}

input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type=number] {
  -moz-appearance: textfield;
}
