/* ============================================================
   物流异常订单管理工作台 —— 全局样式
   ============================================================ */
:root {
  --primary: #2f6bff;
  --primary-dark: #1f56e0;
  --danger: #e5484d;
  --danger-bg: #fdecec;
  --success: #16a34a;
  --success-bg: #e8f7ee;
  --warning: #f59e0b;
  --warning-bg: #fef4e3;
  --info-bg: #eaf1ff;
  --text: #1f2430;
  --text-2: #5b6472;
  --text-3: #8a93a2;
  --border: #e6e9ef;
  --bg: #f4f6fa;
  --card: #ffffff;
  --sidebar-bg: #141b2d;
  --sidebar-text: #aeb6c8;
  --sidebar-active: #2f6bff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
}

* { 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.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 布局骨架 ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 224px;
  flex: 0 0 224px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.brand-logo {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2f6bff, #5b8cff);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex: 0 0 40px;
}
.brand-text h1 { font-size: 15px; color: #fff; font-weight: 600; line-height: 1.3; }
.brand-text span { font-size: 11px; color: var(--sidebar-text); }

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-icon { width: 20px; text-align: center; font-size: 16px; }
.nav-label { flex: 1; }

.sidebar-foot { padding: 14px 18px; font-size: 11px; color: #5a6273; border-top: 1px solid rgba(255,255,255,.06); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.page-title { font-size: 17px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.bell {
  position: relative;
  width: 38px; height: 38px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  transition: background .15s;
}
.bell:hover { background: var(--info-bg); text-decoration: none; }

/* 红点徽标 */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.badge-red {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 0 0 2px var(--sidebar-bg);
}
.nav-item .badge-red { margin-left: auto; box-shadow: 0 0 0 2px var(--sidebar-bg); }
.bell .badge-red {
  position: absolute;
  top: -6px;
  right: -6px;
  box-shadow: 0 0 0 2px var(--card);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.content { padding: 22px 24px 40px; flex: 1; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-head h3 { font-size: 15px; font-weight: 600; }
.link-more { font-size: 13px; }

/* ---------- 统计卡片 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
}
.stat-card .stat-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex: 0 0 46px;
}
.stat-card .stat-body { flex: 1; min-width: 0; }
.stat-card .stat-label { font-size: 12px; color: var(--text-2); }
.stat-card .stat-value { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.stat-card .stat-dot {
  position: absolute; top: 14px; right: 14px;
  width: 8px; height: 8px; border-radius: 50%;
}
.icon-blue   { background: var(--info-bg); }
.icon-red    { background: var(--danger-bg); }
.icon-green  { background: var(--success-bg); }
.icon-orange { background: var(--warning-bg); }
.dot-blue   { background: var(--primary); }
.dot-red    { background: var(--danger); }
.dot-green  { background: var(--success); }
.dot-orange { background: var(--warning); }

/* ---------- 双栏 ---------- */
.grid-2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; }
@media (max-width: 1024px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- 工具栏 / 筛选 ---------- */
.module-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }

input[type="text"], input[type="search"], input[type="number"],
input[type="datetime-local"], select, textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, .12);
}
textarea { resize: vertical; }
input[type="search"] { width: 220px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg); border-color: #d3d8e1; }
.btn-danger-ghost { background: #fff; border-color: var(--border); color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table th {
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 600;
  background: #fafbfd;
}
.data-table tbody tr:hover { background: #f7f9fd; }
.data-table tbody tr:last-child td { border-bottom: none; }
.th-actions { text-align: right; }
.td-actions { text-align: right; }
.td-actions .btn { margin-left: 6px; }
.cell-main { color: var(--text); }
.cell-sub { color: var(--text-3); font-size: 12px; }
.tracking-no { font-family: "SFMono-Regular", Consolas, monospace; font-weight: 500; }

/* 状态标签 */
.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  background: var(--bg);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.status-tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-tag.pending { background: var(--warning-bg); color: #b45309; border-color: #fcd9a3; }
.status-tag.done { background: var(--success-bg); color: var(--success); border-color: #b9e6c8; }

.status-select {
  border: 1px solid transparent;
  background: transparent;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.status-select:hover { border-color: var(--border); background: #fff; }

/* 提醒标记 */
.remind-cell { display: inline-flex; align-items: center; gap: 6px; }
.remind-cell .red-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(229, 72, 77, .15);
  animation: pulse 1.6s ease-in-out infinite;
}
.remind-due { color: var(--danger); font-weight: 600; }
.remind-future { color: var(--text-3); }
.remind-none { color: var(--text-3); }

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-2);
  flex-wrap: wrap;
}
.pagination button {
  min-width: 30px; height: 30px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.pagination button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pagination button.current { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 16px;
  z-index: 100;
  overflow-y: auto;
}
.modal-mask[hidden] { display: none; }
.modal {
  background: var(--card);
  border-radius: 14px;
  width: 100%;
  max-width: 620px;
  box-shadow: var(--shadow-lg);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; }
.modal-close {
  border: none; background: none;
  font-size: 24px; line-height: 1;
  color: var(--text-3);
  cursor: pointer;
}
.modal-close:hover { color: var(--danger); }
.modal form { padding: 20px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-item { display: flex; flex-direction: column; gap: 5px; }
.form-item-wide { grid-column: 1 / -1; }
.form-item label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.form-item .req { color: var(--danger); }
.form-item .hint { color: var(--text-3); font-weight: 400; font-size: 12px; }

/* ---------- Toast ---------- */
#toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  padding: 10px 18px;
  border-radius: 8px;
  color: #fff;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .2s ease;
}
.toast.ok { background: #1f6f43; }
.toast.err { background: var(--danger); }
.toast.info { background: #334155; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- 工作台分布 ---------- */
.distribution { display: flex; flex-direction: column; gap: 14px; }
.dist-item .dist-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; margin-bottom: 6px;
}
.dist-head .dist-name { font-weight: 500; }
.dist-head .dist-num { color: var(--text-3); }
.dist-bar { height: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; display: flex; }
.dist-bar i { display: block; height: 100%; background: var(--primary); border-radius: 4px; transition: width .4s; }
.dist-bar i:not(:first-child) { border-radius: 0; }
.dist-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--text-2); }
.dist-legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.dist-legend .lg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dist-empty { color: var(--text-3); font-size: 13px; }

/* ---------- 提醒概览 ---------- */
.reminder-overview { display: flex; flex-direction: column; gap: 10px; }
.reminder-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
}
.reminder-item:hover { border-color: var(--primary); }
.reminder-item .r-icon { font-size: 16px; }
.reminder-item .r-main { flex: 1; min-width: 0; }
.reminder-item .r-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reminder-item .r-sub { font-size: 12px; color: var(--text-3); }
.reminder-item .r-time { color: var(--danger); font-weight: 600; font-size: 12px; }
.reminder-empty { color: var(--text-3); font-size: 13px; text-align: center; padding: 20px 0; }

/* ---------- 空提示 / 最近动态 ---------- */
.empty-tip { text-align: center; color: var(--text-3); padding: 30px 0; font-size: 13px; }
.module-chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 6px;
  font-size: 12px;
  background: var(--info-bg);
  color: var(--primary-dark);
  white-space: nowrap;
}

/* ---------- 设置页 ---------- */
.settings-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab-btn {
  border: 1px solid var(--border);
  background: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
}
.tab-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.status-panel .status-list {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-bottom: 16px;
}
.status-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 8px 6px 14px;
  border-radius: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
}
.status-chip .chip-del {
  border: none; background: none; cursor: pointer;
  color: var(--text-3); font-size: 15px; line-height: 1;
  border-radius: 50%;
}
.status-chip .chip-del:hover { color: var(--danger); }
.status-add { display: flex; gap: 8px; align-items: center; }
.status-add input { width: 220px; }

.hint { font-size: 12px; color: var(--text-3); }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static;
    flex-direction: row; align-items: center;
    flex-wrap: wrap; padding: 8px;
  }
  .brand { border-bottom: none; padding: 8px; }
  .nav { flex-direction: row; flex-wrap: wrap; padding: 4px; gap: 4px; }
  .nav-item { padding: 6px 10px; }
  .sidebar-foot { display: none; }
  .content { padding: 14px; }
}
