:root {
  /* 暖米色主题（参考 boxianapp.cn / 元印广告） */
  --bg: #F6F4F0;
  --bg-soft: #F3EDE3;
  --panel: #FFFEFB;
  --panel-2: #F3EDE3;
  --border: #E8E0D5;
  --text: #2B2118;
  --text-dim: #8C7A65;
  --accent: #C9453B;
  --amber: #C8962B;
  --green: #1E9E50;
  --blue: #2F80ED;
  --red: #C9453B;
  --gray: #9A8B79;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

/* 全屏扫描页保持深色（摄像头 HUD 悬浮层） */
body.scan-fullscreen {
  --bg: #0f1420;
  --bg-soft: #171d2e;
  --panel: #1c2438;
  --panel-2: #222c44;
  --border: #2c3755;
  --text: #e7ecf5;
  --text-dim: #93a1bf;
  --accent: #4f8cff;
  --amber: #ffb020;
  --green: #2fd07c;
  --blue: #38bdf8;
  --red: #ff5d5d;
  --gray: #64748b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }

/* ---------- 布局 ---------- */
.wrap { max-width: 1560px; margin: 0 auto; padding: 20px; }

header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
header.top h1 { font-size: 22px; margin: 0; }
header.top .subtitle { color: var(--text-dim); font-size: 13px; }

.row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 16px; margin: 0 0 14px; }

.grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }

/* ---------- 统计块 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat .num { font-size: 30px; font-weight: 700; }
.stat .label { color: var(--text-dim); font-size: 13px; margin-top: 2px; }
/* 今日统计：突出；历史统计：弱化 */
.stat-today { border-color: var(--accent); }
.stat-today .num { font-size: 36px; }
.stat-history .num { font-size: 22px; color: var(--text-dim); }
.stat-history .label { font-size: 12px; }

/* 批量操作条（时间筛选 + 删除选中） */
.bulk-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.bulk-bar input[type="date"] {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-size: 13px;
}

/* ---------- 表单 ---------- */
.form-grid { display: flex; flex-direction: column; gap: 12px; }
.field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 5px; }
.field input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
}
.field input[type="text"]:focus { outline: none; border-color: var(--accent); }
.field select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
}
.field select:focus { outline: none; border-color: var(--accent); }
.field textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: "Consolas", "Courier New", monospace;
  resize: vertical;
  min-height: 84px;
}
.field textarea:focus { outline: none; border-color: var(--accent); }

/* ---------- 按钮 ---------- */
button {
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  transition: opacity .15s, transform .05s;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: .9; }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-dim); }
.btn-green { background: var(--green); color: #072713; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 14px 20px; font-size: 17px; }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--text-dim); font-weight: 600; font-size: 13px; }
tbody tr:hover { background: var(--panel-2); }

.mono { font-family: "Consolas", "Courier New", monospace; letter-spacing: .5px; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.return { background: rgba(255, 93, 93, .16); color: var(--red); }
.badge.status-pending { background: rgba(255, 176, 32, .16); color: var(--amber); }
.badge.status-found { background: rgba(47, 208, 124, .16); color: var(--green); }
.badge.status-not_found { background: rgba(100, 116, 139, .18); color: var(--gray); }
.badge.refund-yes { background: rgba(47, 208, 124, .16); color: var(--green); }
.badge.refund-no { background: rgba(100, 116, 139, .18); color: var(--gray); }
.badge.recover-yes { background: rgba(56, 189, 248, .16); color: var(--blue); }
.badge.recover-no { background: rgba(100, 116, 139, .18); color: var(--gray); }
.badge.toggle { cursor: pointer; }

/* ---------- 扫描流水 ---------- */
.feed { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow-y: auto; }
.feed li {
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.feed .time { color: var(--text-dim); font-size: 12px; margin-left: auto; }
.feed .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.feed .src { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.dot.return { background: var(--red); }
.dot.normal { background: var(--gray); }

/* ---------- 提示条 ---------- */
#banner {
  display: none;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-weight: 600;
  font-size: 16px;
}
#banner.alert { display: block; background: rgba(255, 93, 93, .15); border: 1px solid var(--red); color: var(--red); }
#banner.info { display: block; background: rgba(79, 140, 255, .12); border: 1px solid var(--accent); color: var(--accent); }

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-weight: 600;
  z-index: 100;
  animation: fadein .2s;
}
@keyframes fadein { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; } }

/* ---------- 扫描页（移动端优先） ---------- */
.scan-wrap { max-width: 560px; margin: 0 auto; padding: 16px; }
.scan-title { text-align: center; margin: 8px 0 16px; }
.scan-title h1 { font-size: 20px; margin: 0; }
.scan-title .subtitle { color: var(--text-dim); font-size: 13px; }

/* 顶部计数器：总退件数 / 还未找到 */
.counters { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.counter {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}
.counter .num { font-size: 44px; font-weight: 800; line-height: 1; }
.counter .label { color: var(--text-dim); font-size: 14px; margin-top: 8px; }
.counter.total .num { color: var(--accent); }
.counter.pending .num { color: var(--amber); }

.video-box {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.video-box video { width: 100%; height: 100%; object-fit: cover; }
.video-box .placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim);
  padding: 12px;
  text-align: center;
}
.scan-input {
  width: 100%;
  padding: 16px;
  font-size: 20px;
  text-align: center;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  letter-spacing: 2px;
}
.scan-input:focus { outline: none; border-color: var(--accent); }

/* 扫描结果 / 状态更改提示卡片 */
.result-box {
  margin-top: 16px;
  padding: 18px;
  border-radius: var(--radius);
  text-align: center;
  display: none;
}
.result-box.return { display: block; background: rgba(255, 93, 93, .15); border: 1px solid var(--red); }
.result-box.found { display: block; background: rgba(255, 176, 32, .15); border: 1px solid var(--amber); }
.result-box.miss { display: block; background: rgba(100, 116, 139, .15); border: 1px solid var(--gray); }
.result-box .big { font-size: 22px; font-weight: 700; }
.result-box .detail { color: var(--text-dim); margin-top: 6px; font-size: 14px; }
.result-box .hint { margin-top: 12px; font-size: 15px; color: var(--text); }
.result-box .actions { display: flex; gap: 12px; justify-content: center; margin-top: 14px; }

.footer-links { text-align: center; margin-top: 20px; color: var(--text-dim); font-size: 13px; }

.modal-mask {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .6);
  display: none; align-items: center; justify-content: center;
  z-index: 200;
}
.modal-mask.open { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; width: 320px; }
.modal h3 { margin: 0 0 14px; }
.modal .field { margin-bottom: 12px; }
.modal.wide { width: 420px; max-width: 92vw; }

/* ---------- 在线员工 ---------- */
#onlineBar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#onlineBar .emp { display: inline-flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
#onlineBar .dot-on { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
#onlineBar .empty { color: var(--text-dim); font-size: 13px; }
#onlineBar .emp .ver { color: var(--blue); font-size: 11px; font-weight: 600; }

/* ---------- 列表过滤/排序条 ---------- */
.filter-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filter-bar select, .filter-bar input[type="text"] {
  padding: 7px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
}
.filter-bar input[type="text"] { min-width: 170px; }
.filter-bar select:focus, .filter-bar input[type="text"]:focus { outline: none; border-color: var(--accent); }

/* ---------- 全屏扫描页（沉浸式，移动端） ---------- */
body.scan-fullscreen { overflow: hidden; background: #000; }
body.scan-fullscreen .scan-wrap { max-width: none; padding: 0; }

.scan-fullscreen .video-box {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  aspect-ratio: auto; margin: 0;
  border: none; border-radius: 0;
}
.scan-fullscreen .video-box video { width: 100%; height: 100%; object-fit: cover; }
.scan-fullscreen .video-box .placeholder { font-size: 16px; }

/* 半透明 HUD 悬浮层 */
.hud {
  position: fixed; z-index: 20;
  background: rgba(15, 20, 32, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.hud-top { top: 12px; left: 12px; right: 12px; padding: 10px 14px; }
.hud-top .counters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.hud-top .counter {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px; padding: 6px 8px; box-shadow: none; text-align: center;
}
.hud-top .counter .num { font-size: 30px; line-height: 1.1; }
.hud-top .counter .label { font-size: 12px; margin-top: 2px; }
.hud-top .conn { text-align: center; font-size: 12px; color: var(--text-dim); margin-top: 6px; }

/* 历史计数：比今日更小更淡（手机扫描页 HUD） */
.hud-top .counter.history { padding: 3px 6px; }
.hud-top .counter.history .num { font-size: 16px; font-weight: 700; color: var(--text-dim); }
.hud-top .counter.history .label { font-size: 10px; opacity: .85; }

.hud-bottom { bottom: 12px; left: 12px; right: 12px; padding: 12px; }
.hud-bottom .scan-input {
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff;
}
.hud-bottom .scan-input::placeholder { color: rgba(255, 255, 255, 0.5); }
.hud .btn-primary { background: rgba(79, 140, 255, 0.65); }
.hud .btn-green { background: rgba(47, 208, 124, 0.7); }
.hud .btn-ghost { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.2); color: var(--text); }

/* 结果卡片（半透明，浮在视频上） */
.hud-result { left: 16px; right: 16px; bottom: 150px; padding: 16px; text-align: center; display: none; }
.hud-result.show { display: block; }
.hud-result.return { background: rgba(255, 93, 93, 0.35); border-color: rgba(255, 93, 93, 0.7); }
.hud-result.found { background: rgba(255, 176, 32, 0.32); border-color: rgba(255, 176, 32, 0.7); }
.hud-result.miss { background: rgba(100, 116, 139, 0.4); border-color: rgba(100, 116, 139, 0.7); }
.hud-result .big { font-size: 22px; font-weight: 700; }
.hud-result .detail { color: rgba(255, 255, 255, 0.85); margin-top: 6px; font-size: 15px; }
.hud-result .hint { margin-top: 10px; font-size: 15px; color: #fff; }
.hud-result .actions { display: flex; gap: 12px; justify-content: center; margin-top: 14px; }

/* ---------- 登录弹窗 ---------- */
.field input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
}
.field input[type="password"]:focus { outline: none; border-color: var(--accent); }
#loginUser { color: var(--text); }

/* ---------- 类型彩色徽章（需求10） ---------- */
.badge.type-return { background: rgba(255, 93, 93, .16); color: var(--red); }
.badge.type-address-change { background: rgba(56, 189, 248, .16); color: var(--blue); }
.badge.type-other { background: rgba(100, 116, 139, .18); color: var(--gray); }

/* ---------- 状态行高亮（需求2） ---------- */
/* 待找：高亮强调（需求8） */
tr.row-pending { box-shadow: inset 5px 0 0 var(--amber); background: rgba(255, 176, 32, 0.14); }
tr.row-pending:hover { background: rgba(255, 176, 32, 0.18); }
/* 已找到：低调弱化 */
tr.row-found { box-shadow: inset 3px 0 0 rgba(47, 208, 124, 0.45); background: transparent; }
tr.row-found td { color: var(--text-dim); }

/* ---------- 扫描流水扫描人（需求1） ---------- */
.feed .scanner { color: var(--text-dim); font-size: 12px; white-space: nowrap; }

/* ---------- 找到时间列（需求11） ---------- */
.time-cell { color: var(--text-dim); font-size: 12px; white-space: nowrap; }
td .time-cell { display: inline-block; }

/* ---------- 账号管理页 ---------- */
.inline-check { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); font-size: 14px; }
.inline-check input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

/* ---------- 操作列按钮单行（需求2） ---------- */
td.actions { white-space: nowrap; }
td.actions .btn-sm { margin: 0 2px; }

/* ---------- 扫描流水：单号截断、时间固定不换行（需求4） ---------- */
.feed .tn { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed .badge { flex: none; }
.feed .scanner { flex: none; }
.feed .time { flex: none; white-space: nowrap; }

/* ---------- 退件列表日期分组行（需求5） ---------- */
tr.date-sep td { padding: 12px 12px 4px; border-bottom: none; }
tr.date-sep:hover { background: transparent; }
.date-sep-label { color: var(--text-dim); font-size: 13px; font-weight: 700; letter-spacing: .5px; }

/* ---------- 退件列表：两行卡片布局（单行太挤，改两行且紧凑） ---------- */
.order-list { display: flex; flex-direction: column; gap: 8px; }
.order-list .empty { color: var(--text-dim); text-align: center; padding: 20px 0; }

.order-item { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; background: var(--panel); }
.order-item.row-pending { box-shadow: inset 6px 0 0 var(--amber), 0 1px 6px rgba(200, 150, 43, 0.35); background: rgba(255, 176, 32, 0.22); border: 1.5px solid var(--amber); }
.order-item.row-pending .oi-tn { color: #7A4E00; font-weight: 800; font-size: 16px; }
.order-item.row-pending .badge.status-pending { background: var(--amber); color: #fff; }
.order-item.row-found { box-shadow: inset 3px 0 0 rgba(47, 208, 124, 0.45); }
.order-item.row-found .oi-detail, .order-item.row-found .oi-tn { color: var(--text-dim); }
.order-item.row-found-need-refund { box-shadow: inset 6px 0 0 var(--red), 0 1px 6px rgba(201, 69, 59, 0.35); background: rgba(201, 69, 59, 0.12); border: 1.5px solid var(--red); }
.order-item.row-found-need-refund .oi-tn { color: #A3271D; font-weight: 800; font-size: 16px; }
.order-item.row-found-need-refund .oi-detail { color: var(--text); }
.order-item.row-skipped { box-shadow: inset 4px 0 0 var(--gray); opacity: .82; }
.badge.refund-warn { background: var(--red); color: #fff; }

.oi-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.oi-top .oi-tn { font-weight: 700; font-size: 15px; }
.oi-top .row-check { width: 15px; height: 15px; flex: none; }
.oi-actions { margin-left: auto; display: flex; gap: 4px; flex-wrap: wrap; }
.oi-actions .btn-sm { margin: 0; }

.oi-detail { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 6px; color: var(--text-dim); font-size: 13px; }
.oi-doc { color: var(--text); font-weight: 600; white-space: nowrap; min-width: 140px; }
.oi-order { color: var(--text); font-weight: 600; white-space: nowrap; }
.oi-meta { white-space: nowrap; }

/* 日期分组行（卡片列表版） */
.date-sep { padding: 12px 2px 2px; border-bottom: none; }
.date-sep:first-child { padding-top: 0; }

/* 分页条 */
.pager { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.pager-info { color: var(--text-dim); font-size: 13px; margin-right: auto; }

/* 扫描流水搜索框 */
.feed-search {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  margin-bottom: 10px;
}
.feed-search:focus { outline: none; border-color: var(--accent); }

/* 状态徽章：不需要找 */
.badge.status-skipped { background: rgba(100, 116, 139, .2); color: var(--gray); }

/* 登记前扫描过 提示徽章 */
.badge.prescan { background: rgba(255, 176, 32, .18); color: var(--amber); }

/* ---------- 已找到待退款区块 —— 页面最重要部分，报警红色最凸显 ---------- */
.unrefunded-card {
  border: 2px solid var(--red);
  margin-bottom: 20px;
  background: linear-gradient(180deg, rgba(201, 69, 59, 0.16), rgba(201, 69, 59, 0.05));
  animation: alarm-pulse 2s ease-in-out infinite;
}
.unrefunded-card h2 { color: var(--red); font-size: 19px; font-weight: 800; }
.uf-count { background: var(--red); color: #fff; font-size: 15px; padding: 3px 12px; }
#unrefundedList { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow-y: auto; }
#unrefundedList .empty { color: var(--text-dim); font-size: 13px; padding: 8px 0; }
/* 待退款条目：单行布局（放不下才换行），红色高亮 */
.uf-item { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; background: rgba(201, 69, 59, 0.14); border: 1.5px solid rgba(201, 69, 59, 0.55); border-left: 5px solid var(--red); border-radius: 8px; }
.uf-tn { font-weight: 800; font-size: 16px; color: #A3271D; }
.uf-doc { color: var(--text); font-size: 12px; }
.uf-order { color: var(--text); font-size: 12px; font-weight: 700; }
.uf-actions { margin-left: auto; display: flex; gap: 4px; }
.uf-meta { color: var(--text-dim); font-size: 12px; white-space: nowrap; }

@keyframes alarm-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(201, 69, 59, 0.18), 0 2px 12px rgba(0, 0, 0, 0.06); }
  50% { box-shadow: 0 0 0 8px rgba(201, 69, 59, 0.05), 0 2px 12px rgba(0, 0, 0, 0.06); }
}

