/* ========== 全局变量 ========== */
:root {
  --primary: #2563EB;
  --primary-light: #EFF6FF;
  --primary-dark: #1D4ED8;
  --success: #16A34A;
  --success-light: #F0FDF4;
  --warning: #F59E0B;
  --warning-light: #FFFBEB;
  --danger: #DC2626;
  --danger-light: #FEF2F2;
  --info: #6366F1;
  --info-light: #EEF2FF;

  --bg: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-sidebar: #1E293B;
  --bg-sidebar-hover: #334155;
  --bg-sidebar-active: #2563EB;

  --text: #1E293B;
  --text-secondary: #64748B;
  --text-muted: #94A3B8;
  --text-sidebar: #CBD5E1;
  --text-sidebar-active: #FFFFFF;

  --border: #E2E8F0;
  --border-light: #F1F5F9;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.05), 0 4px 6px rgba(0,0,0,0.03);

  --sidebar-width: 240px;
  --topbar-height: 60px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== 基础重置 ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; outline: none; font-family: inherit; }
input { font-family: inherit; outline: none; }

/* ========== 登录页 ========== */
.login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1E293B 0%, #334155 50%, #1E293B 100%);
}
.login-card {
  width: 400px; padding: 48px 40px;
  background: #fff; border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-icon { font-size: 48px; margin-bottom: 12px; }
.login-header h1 { font-size: 22px; color: var(--text); margin-bottom: 6px; }
.login-header p { font-size: 13px; color: var(--text-secondary); }
.login-form .form-group { margin-bottom: 18px; }
.login-form label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.login-form input {
  width: 100%; padding: 12px 14px; font-size: 15px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color var(--transition);
}
.login-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.btn-login {
  width: 100%; padding: 13px; font-size: 16px; font-weight: 600;
  color: #fff; background: var(--primary); border-radius: var(--radius-sm);
  transition: background var(--transition); margin-top: 4px;
}
.btn-login:hover { background: var(--primary-dark); }
.login-hint { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 16px; }

/* ========== 主体布局 ========== */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* ========== 侧边栏 ========== */
.sidebar {
  width: var(--sidebar-width); min-width: var(--sidebar-width);
  background: var(--bg-sidebar); color: var(--text-sidebar);
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 24px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.brand-icon { font-size: 28px; }
.brand-text { font-size: 17px; font-weight: 700; color: #fff; letter-spacing: 0.5px; }

.sidebar-nav {
  flex: 1; padding: 12px 0;
  display: flex; flex-direction: column; gap: 2px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; margin: 0 8px;
  font-size: 14px; border-radius: var(--radius-sm);
  color: var(--text-sidebar); cursor: pointer;
  transition: all var(--transition);
}
.nav-item:hover { background: var(--bg-sidebar-hover); color: #fff; }
.nav-item.active { background: var(--bg-sidebar-active); color: #fff; font-weight: 500; }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.06);
}
.user-info { font-size: 13px; color: var(--text-sidebar); margin-bottom: 10px; }
.btn-logout {
  width: 100%; padding: 8px; font-size: 13px;
  color: var(--text-sidebar); background: rgba(255,255,255,0.05);
  border-radius: var(--radius-xs);
  transition: background var(--transition);
}
.btn-logout:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* ========== 顶栏 ========== */
.topbar {
  height: var(--topbar-height); padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-card); border-bottom: 1px solid var(--border);
}
.topbar h2 { font-size: 18px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 16px; }
.topbar-time { font-size: 13px; color: var(--text-secondary); }
.topbar-badge {
  padding: 4px 12px; font-size: 12px; font-weight: 500;
  border-radius: 20px;
}

/* ========== 主内容 ========== */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.page-container { flex: 1; overflow-y: auto; padding: 24px 28px; }

/* ========== 仪表盘 ========== */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 20px 24px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
}
.stat-icon.blue { background: var(--primary-light); }
.stat-icon.green { background: var(--success-light); }
.stat-icon.orange { background: var(--warning-light); }
.stat-icon.purple { background: var(--info-light); }
.stat-info { flex: 1; min-width: 0; }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.2; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.charts-row {
  display: grid; grid-template-columns: 2fr 1fr; gap: 16px;
  margin-bottom: 24px;
}
.chart-card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 20px 24px; box-shadow: var(--shadow);
}
.chart-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; color: var(--text); }
.chart-wrapper { position: relative; height: 280px; }
.chart-wrapper canvas { width: 100% !important; height: 100% !important; }

/* ========== 表格通用样式 ========== */
.table-card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 20px 24px; box-shadow: var(--shadow);
}
.table-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.table-header h3 { font-size: 15px; font-weight: 600; }
.table-tools { display: flex; align-items: center; gap: 12px; }

/* 筛选器 */
.filter-group { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-chip {
  padding: 6px 14px; font-size: 13px; border-radius: 20px;
  border: 1.5px solid var(--border); background: #fff;
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--transition);
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary); font-weight: 500; }

.search-input {
  padding: 8px 14px; font-size: 13px;
  border: 1.5px solid var(--border); border-radius: 20px;
  width: 200px; transition: border-color var(--transition);
}
.search-input:focus { border-color: var(--primary); width: 260px; }

/* 数据表格 */
.data-table {
  width: 100%; border-collapse: collapse;
}
.data-table th {
  text-align: left; padding: 10px 12px;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border-light);
}
.data-table td {
  padding: 12px;
  font-size: 13px; color: var(--text);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.data-table tr:hover td { background: #FAFBFC; }

/* 状态标签 */
.status-badge {
  display: inline-block; padding: 3px 10px; font-size: 12px;
  border-radius: 12px; font-weight: 500;
}
.status-pending { background: #F1F5F9; color: #64748B; }
.status-producing { background: var(--info-light); color: var(--info); }
.status-ready_to_ship { background: #FEF9C3; color: #A16207; }
.status-shipping { background: var(--warning-light); color: #B45309; }
.status-installing { background: var(--primary-light); color: var(--primary); }
.status-completed { background: var(--success-light); color: var(--success); }
.status-active { background: var(--success-light); color: var(--success); }
.status-suspended { background: var(--danger-light); color: var(--danger); }

/* 操作按钮 */
.btn-sm {
  padding: 5px 12px; font-size: 12px; border-radius: 6px;
  font-weight: 500; transition: all var(--transition);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--border-light); }

/* 角色标签 */
.role-badge {
  display: inline-block; padding: 2px 10px; font-size: 12px;
  border-radius: 12px; font-weight: 500;
}
.role-sender { background: var(--primary-light); color: var(--primary); }
.role-factory { background: #FEF3C7; color: #B45309; }
.role-worker { background: var(--success-light); color: var(--success); }

/* 空状态 */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* 分页 */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; margin-top: 20px;
}
.page-btn {
  padding: 6px 12px; font-size: 13px; border-radius: var(--radius-xs);
  border: 1.5px solid var(--border); background: #fff;
  color: var(--text-secondary); cursor: pointer;
  transition: all var(--transition);
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-info { font-size: 13px; color: var(--text-muted); padding: 0 8px; }

/* ========== Toast ========== */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  padding: 12px 24px; border-radius: var(--radius-sm);
  font-size: 14px; color: #fff; font-weight: 500;
  opacity: 0; pointer-events: none; z-index: 10000;
  transition: opacity 0.3s, transform 0.3s;
  transform: translateX(-50%) translateY(-10px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--primary); }

/* ========== 加载 ========== */
.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.loading::before { content: ''; display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin-right: 8px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== 详情弹窗 ========== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 5000;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
}
.modal-card {
  background: #fff; border-radius: var(--radius);
  width: 560px; max-height: 80vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--text-muted); background: transparent;
  transition: background var(--transition);
}
.modal-close:hover { background: var(--border-light); color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-body .info-row {
  display: flex; padding: 8px 0; border-bottom: 1px solid var(--border-light);
}
.modal-body .info-label { width: 100px; font-size: 13px; color: var(--text-muted); flex-shrink: 0; }
.modal-body .info-value { font-size: 13px; color: var(--text); word-break: break-all; }

/* 响应式 */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
}
