/* 物流管理系统 - 本地样式表（无任何外网依赖） */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #1f6feb;
  --primary-dark: #1857bb;
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e3e8ef;
  --text: #1f2937;
  --muted: #6b7280;
  --green: #16a34a;
  --orange: #ea8a0b;
  --red: #dc2626;
  --purple: #7c3aed;
  --sidebar: #16233a;
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, 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; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 208px;
  flex: 0 0 208px;
  background: var(--sidebar);
  color: #cbd5e1;
  padding: 18px 0;
}
.sidebar .brand {
  padding: 0 20px 18px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid #26364f;
  margin-bottom: 12px;
}
.sidebar .brand small { display: block; font-size: 11px; color: #8ea1bd; font-weight: 400; margin-top: 4px; }
.sidebar nav a {
  display: block;
  padding: 11px 20px;
  color: #cbd5e1;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: #1e2c45; color: #fff; text-decoration: none; }
.sidebar nav a.active { background: #1e2c45; color: #fff; border-left-color: var(--primary); font-weight: 600; }
.sidebar .foot { padding: 16px 20px; font-size: 11px; color: #7c8ba5; }

/* 侧边栏底部登录信息（后台登录后显示） */
.sidebar .user-box {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 6px 14px 0; padding: 9px 10px;
  background: #1e2c45; border-radius: 8px;
  font-size: 12px; color: #cbd5e1;
}
.sidebar .user-box .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .user-box a.logout { color: #ffd18a; font-size: 12px; white-space: nowrap; }

/* ---------- 后台登录页 ---------- */
.login-body {
  min-height: 100vh;
  background: linear-gradient(160deg, #16233a 0%, #1f3a63 55%, #16233a 100%);
}
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card); border-radius: 12px; padding: 26px 24px 20px;
  box-shadow: 0 18px 40px rgba(4, 12, 26, 0.38);
}
.login-brand { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 18px; }
.login-brand small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 6px; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; }
.login-card input[type="text"], .login-card input[type="password"] {
  width: 100%; padding: 10px 12px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 8px; background: #fbfcfe; color: var(--text);
}
.login-card input:focus { outline: none; border-color: var(--primary); background: #fff; }
.login-card button {
  width: 100%; margin-top: 18px; padding: 11px 12px;
  font-size: 15px; letter-spacing: 1px; color: #fff; cursor: pointer;
  background: var(--primary); border: 0; border-radius: 8px;
}
.login-card button:hover { background: var(--primary-dark); }
.login-err {
  padding: 9px 12px; font-size: 13px; border-radius: 8px;
  color: #9a1c1c; background: #fdeaea; border: 1px solid #f5c2c2;
}
.login-tip { margin-top: 16px; font-size: 12px; color: var(--muted); line-height: 1.9; }
.login-tip code { background: #f1f3f8; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.main { flex: 1; padding: 20px 24px 60px; min-width: 0; }

.page-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.page-head h1 { font-size: 21px; }
.page-head .sub { color: var(--muted); font-size: 12px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  /* 允许卡片在窄屏被压缩，宽表格交给 .table-wrap 内部横向滚动 */
  min-width: 0;
  max-width: 100%;
}
.card h2 { font-size: 15px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card h2 .tag { font-size: 11px; font-weight: 400; color: var(--muted); }

.grid { display: grid; gap: 14px; }
/* 网格子项默认 min-width:auto，会被宽表格撑开整页，这里统一收敛 */
.grid > * { min-width: 0; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1180px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  /* 手机窄屏：必须用 minmax(0, 1fr) 而不是 1fr —— 1fr 的最小值取内容宽度，
     会被表格等宽内容撑成整页横向溢出（375px 视口下首页看板的缺陷根因） */
  .grid-4, .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .main { padding: 14px 12px 40px; }
  .card { padding: 12px; }
  .chart { gap: 6px; }
  .chart .bar-in, .chart .bar-out { width: 10px; }
  .chart-cap-row { gap: 6px; }
}

/* ---------- KPI ---------- */
.kpi {
  background: var(--card);
  /* 装饰圆改为背景渐变：原先用 ::after 绝对定位溢出 18px，会把卡片 scrollWidth 撑大 */
  background-image: radial-gradient(circle 30px at calc(100% - 12px) 12px, rgba(31,111,235,.07) 99%, rgba(31,111,235,0) 100%);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
  min-width: 0;
}
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 25px; font-weight: 700; margin-top: 4px; letter-spacing: .5px; }
.kpi .unit { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 3px; }
.kpi .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.kpi::after { content: none; }
.kpi.blue .value { color: var(--primary); }
.kpi.green .value { color: var(--green); }
.kpi.orange .value { color: var(--orange); }
.kpi.red .value { color: var(--red); }
.kpi.purple .value { color: var(--purple); }

/* ---------- 标签页 ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a {
  padding: 9px 15px;
  font-size: 13.5px;
  color: #475569;
  border-bottom: 2px solid transparent;
  border-radius: 6px 6px 0 0;
}
.tabs a:hover { background: #eef3fb; color: var(--primary); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; background: #f2f7ff; }
.tabs .badge-dot { display: inline-block; margin-left: 5px; font-size: 10px; padding: 0 5px; border-radius: 8px; background: var(--red); color: #fff; line-height: 15px; vertical-align: 1px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; max-width: 100%; min-width: 0; }
table { width: 100%; border-collapse: collapse; font-size: 13px; background: #fff; }
th, td { padding: 9px 11px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #f8fafc; font-weight: 600; color: #475569; font-size: 12.5px; position: sticky; top: 0; }
tbody tr:hover { background: #f9fbff; }
td.wrap { white-space: normal; min-width: 220px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-empty { padding: 26px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- 表单 ---------- */
.form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 130px; }
.field label { font-size: 12px; color: var(--muted); }
input, select, textarea {
  font-family: inherit;
  font-size: 13px;
  padding: 7px 9px;
  border: 1px solid #cfd8e3;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31,111,235,.12); }
textarea { resize: vertical; width: 100%; min-height: 120px; line-height: 1.5; }
input[type="checkbox"], input[type="radio"] { width: auto; }

.btn {
  display: inline-block;
  padding: 7px 14px;
  font-size: 13px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn.ghost { background: #fff; color: var(--primary); }
.btn.ghost:hover { background: #eef4ff; color: var(--primary-dark); }
.btn.gray { background: #fff; color: #475569; border-color: #cfd8e3; }
.btn.gray:hover { background: #f1f5f9; color: #334155; }
.btn.danger { background: #fff; color: var(--red); border-color: #f0b6b6; }
.btn.danger:hover { background: #fef2f2; color: var(--red); }
.btn.sm { padding: 4px 9px; font-size: 12px; }

/* ---------- 徽标 ---------- */
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; line-height: 18px; border: 1px solid transparent; }
.badge.gray { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.badge.green { background: #e9f9ef; color: #15803d; border-color: #bbf0ce; }
.badge.orange { background: #fff5e6; color: #b45309; border-color: #fbe0b4; }
.badge.red { background: #fdeeee; color: #b91c1c; border-color: #f7cccb; }
.badge.blue { background: #eaf2ff; color: #1d4ed8; border-color: #c9dcfd; }
.badge.purple { background: #f4ecff; color: #6d28d9; border-color: #ddd0fb; }

/* ---------- 提示条 ---------- */
.alert { padding: 9px 13px; border-radius: 7px; font-size: 13px; margin-bottom: 14px; border: 1px solid; }
.alert.ok { background: #effaf3; border-color: #bfe9cd; color: #15803d; }
.alert.err { background: #fdf1f1; border-color: #f4c9c9; color: #b91c1c; }
.alert.info { background: #eff5ff; border-color: #c9dcfd; color: #1d4ed8; }

/* ---------- 进度条 ---------- */
.bar { height: 7px; background: #eef1f6; border-radius: 5px; overflow: hidden; min-width: 70px; }
.bar > i { display: block; height: 100%; background: var(--primary); }
.bar > i.warn { background: var(--orange); }
.bar > i.full { background: var(--red); }
.bar > i.ok { background: var(--green); }

/* ---------- 图表（纯 CSS） ---------- */
.chart { display: flex; align-items: flex-end; gap: 14px; height: 170px; padding: 10px 4px 0; border-bottom: 1px solid var(--border); }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; }
.chart .pair { display: flex; align-items: flex-end; gap: 5px; height: 100%; }
.chart .bar-in, .chart .bar-out { width: 15px; border-radius: 3px 3px 0 0; min-height: 2px; }
.chart .bar-in { background: #4c8ff0; }
.chart .bar-out { background: #f0a24c; }
.chart .cap { font-size: 11px; color: var(--muted); margin-top: 6px; text-align: center; }
.chart-cap-row { display: flex; gap: 14px; margin-top: 6px; }
.chart-cap-row .cap { flex: 1; min-width: 0; text-align: center; font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }

/* ---------- 面单 ---------- */
.label-sheet { display: flex; flex-wrap: wrap; gap: 14px; }
.waybill-label {
  width: 380px;
  border: 1.5px solid #000;
  padding: 10px 12px;
  background: #fff;
  font-size: 12px;
  color: #000;
  page-break-after: always;
}
.waybill-label .lb-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #000; padding-bottom: 6px; }
.waybill-label .lb-head .co { font-size: 17px; font-weight: 700; letter-spacing: 1px; }
.waybill-label .lb-head .code { font-size: 11px; }
.waybill-label .lb-barcode { display: flex; align-items: flex-end; height: 46px; margin: 8px 0 2px; }
.waybill-label .lb-barcode i { display: block; height: 100%; background: #000; }
.waybill-label .lb-barcode span { display: block; height: 100%; }
.waybill-label .lb-no { text-align: center; font-size: 12px; letter-spacing: 2px; margin-bottom: 6px; }
.waybill-label .lb-line { display: flex; gap: 6px; padding: 3px 0; border-bottom: 1px dashed #999; }
.waybill-label .lb-line b { flex: 0 0 52px; font-weight: 400; color: #333; }
.waybill-label .lb-line span { flex: 1; word-break: break-all; }
.waybill-label .lb-foot { display: flex; justify-content: space-between; margin-top: 6px; font-size: 11px; }
.waybill-label .lb-cod { font-size: 14px; font-weight: 700; }

@media print {
  .sidebar, .tabs, .no-print, .page-head .sub { display: none !important; }
  .main { padding: 0; }
  body { background: #fff; }
  .card { border: none; padding: 0; margin: 0; }
  .waybill-label { page-break-inside: avoid; }
}

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.muted { color: var(--muted); font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb8 { margin-bottom: 8px; }

/* 侧边栏菜单右侧未处理数红点（如「客服留言」） */
.sidebar nav a .badge-dot {
  float: right; margin-top: 3px; padding: 0 6px; border-radius: 8px;
  background: var(--red); color: #fff; font-size: 10px; line-height: 15px;
}

/* 后台表单下拉框（与 .field input 视觉一致） */
.field select {
  padding: 7px 10px; border: 1px solid #cfd8e3; border-radius: 8px;
  background: #fff; color: #334155; font-size: 13.5px; font-family: inherit; outline: none;
}
.field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 111, 235, .12); }

/* ---------- 后台：客服留言列表 ---------- */
.msg-admin {
  margin-top: 12px; padding: 12px 13px; border: 1px solid var(--border);
  border-radius: 10px; background: #fff;
}
.msg-admin:first-of-type { margin-top: 6px; }
.msg-admin-info { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 7px; color: #334155; font-size: 13px; }
.msg-admin-body {
  margin-top: 8px; padding: 9px 11px; border-radius: 8px; background: #f8fafc;
  color: #1e293b; font-size: 13.5px; line-height: 1.7; word-break: break-word; white-space: pre-wrap;
}
.msg-admin-reply {
  margin-top: 8px; padding: 8px 11px; border-radius: 8px; background: #f1f7ff;
  color: #1d4ed8; font-size: 12.5px; line-height: 1.7; word-break: break-word; white-space: pre-wrap;
}
.msg-admin-reply b { display: block; margin-bottom: 3px; font-weight: 600; }
.msg-admin-form { margin-top: 9px; }
.msg-admin-form textarea {
  width: 100%; min-height: 62px; padding: 8px 10px; border: 1px solid #cfd8e3;
  border-radius: 8px; font-size: 13.5px; font-family: inherit; line-height: 1.6; outline: none; resize: vertical;
}
.msg-admin-form textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 111, 235, .12); }
.msg-admin .row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.msg-admin .row-actions form { display: inline; }
.inline { display: inline; }

/* 购物前台付款凭证（订单列表内联查看） */
.proof-link-inline { display: inline-flex; align-items: center; gap: 5px; color: var(--primary); text-decoration: none; }
.proof-link-inline:hover { text-decoration: underline; }
.proof-thumb-sm { width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 6px; object-fit: cover; background: #fff; }

/* 后台：营销中心（积分规则 / 券模板 / 发券 / 记录） */
.kv-row { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.kv-row:last-of-type { border-bottom: none; }
.kv-row > b { flex: 0 0 auto; font-weight: 400; color: var(--muted); }
.kv-row > span { flex: 1; text-align: right; word-break: break-all; color: #334155; }
.field textarea { padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; font-family: inherit; resize: vertical; }
.field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(31, 111, 235, .12); }
