:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1e222c;
  --line: #2a2f3a;
  --text: #e6e8ee;
  --muted: #9aa3b2;
  --brand: #3b82f6;
  --brand2: #2563eb;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- 通用控件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 10px; cursor: pointer;
  padding: 10px 16px; font-size: 14px; font-weight: 500;
  background: var(--brand); color: #fff; transition: .15s;
}
.btn:hover { background: var(--brand2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.btn.desc { background: #1e40af; }
.btn.desc:hover { background: #1e3a8a; }
.btn.danger { background: var(--err); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.wechat { background: #07c160; }
.btn.wechat:hover { background: #06ad56; }
.btn.temp { background: var(--warn); font-weight: 600; font-size: 16.8px; padding: 13px 16px; margin-top: 16px; }
.btn.temp:hover { background: #d97706; }
.btn.quick { background: var(--err); font-weight: 600; }
.btn.quick:hover { background: #dc2626; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 14px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

input, select, textarea {
  width: 100%; background: var(--panel2); border: 1px solid var(--line);
  color: var(--text); border-radius: 10px; padding: 10px 12px; font-size: 14px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); }
/* 复选框/单选框不受文本输入框样式影响 */
input[type="checkbox"], input[type="radio"] { width: auto; padding: 0; margin: 0; accent-color: var(--brand); cursor: pointer; }
label.f { display: block; margin-bottom: 12px; }
label.f span, .f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
label.f span.req::after { content: ' *'; color: var(--err); }

/* 一行式表单（PC 后台拉宽弹窗用：标签与输入框同行） */
.f-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.f-row > span { flex: 0 0 120px; font-size: 13px; color: var(--muted); }
.f-row > span.req::after { content: ' *'; color: var(--err); }
.f-row input, .f-row select { flex: 1; min-width: 0; }
.f-row .photo-box { flex: 1; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.card.warm { background: linear-gradient(160deg, #fde68a 0%, #fcd34d 100%); border: 1px solid #f59e0b; }
.card.warm label.f span, .card.warm .f > span { color: #7c4a03; }
.card.warm .hint { color: #92400e; }
.card.warm input, .card.warm select { background: #fffbeb; border-color: #f59e0b; color: #3d2c18; }
.card.warm input:focus, .card.warm select:focus { border-color: #d97706; }
.card.warm input[readonly] { background: #fef3c7; color: #78350f; }
.card.warm .btn.ghost { background: #fffbeb; color: #78350f; border-color: #f59e0b; }
.hint { font-size: 12px; color: var(--muted); }
/* 分页条：跳转到[ ]页 → 上一页 第n/N页 下一页 共X条记录 */
.pg { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }
.pg input[type="number"] { width: 64px; padding: 6px 8px; text-align: center; }
.pg input[type="number"]::-webkit-outer-spin-button,
.pg input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pg input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
code { font-family: Consolas, Menlo, "Courier New", monospace; font-size: 12px; color: #7dd3fc; background: rgba(125,211,252,.08); padding: 1px 5px; border-radius: 4px; }
.db-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 8px 20px; }
.db-field { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed rgba(255,255,255,.06); }
.db-field .db-field-name { font-size: 13px; }
.db-field .db-field-type { font-size: 12px; color: var(--muted); flex: 0 0 auto; }
.db-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.db-table { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left; padding: 16px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; color: inherit; transition: border-color .15s, transform .15s; }
.db-table:hover { border-color: #5b8def; transform: translateY(-2px); }
.db-table .db-table-cn { font-size: 15px; font-weight: 600; }
.db-table .db-table-en { font-family: Consolas, Menlo, "Courier New", monospace; font-size: 13px; color: #7dd3fc; }
.db-table .db-table-count { font-size: 12px; color: var(--muted); }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; flex: 0 1 auto; min-height: 0; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; min-width: 700px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
/* 退款订单明细：分组间用明显实线分隔；组内退款行与原订单行之间用暗线（默认细线） */
.rf-group-top td { border-top: 2px solid var(--brand); }
.rf-merged { text-align: center; vertical-align: middle; font-weight: 600; }
th { background: var(--panel2); color: var(--muted); font-weight: 500; position: sticky; top: 0; z-index: 2; }
.rj-new.rj-grey { color: #6b7280; }
/* 只读态（审批通过/作废/待填写）：右列「修改后」控件禁用，但文字保持可读，仅弱化表达不可编辑 */
.rj-new:disabled { opacity: .72; color: var(--text); background: var(--panel2); cursor: not-allowed; }
/* 驳回「查看&修改」弹窗：顶部（驳回信息+原订单号+图例）在弹窗内滚动时吸顶 */
.rj-sticky { position: sticky; top: 0; z-index: 5; background: var(--panel); margin: -20px -20px 12px; padding: 20px 20px 10px; border-bottom: 1px solid var(--line); }
/* 表格列宽拖拽手柄（悬停表头右缘高亮） */
.col-resize { position: absolute; top: 0; right: 0; width: 7px; height: 100%; cursor: col-resize; z-index: 10; user-select: none; }
.col-resize:hover { background: var(--brand); opacity: .5; }
.col-resize.dragging { background: var(--brand); opacity: .85; }
tr:hover td { background: rgba(255,255,255,.02); }
td .imgs { display: flex; gap: 6px; flex-wrap: wrap; }
td .imgs img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; cursor: zoom-in; border: 1px solid var(--line); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; }
.badge.green { background: rgba(34,197,94,.15); color: #4ade80; }
.badge.gray { background: rgba(154,163,178,.15); color: var(--muted); }
.badge.blue { background: rgba(59,130,246,.15); color: #60a5fa; }
.badge.amber { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge.red { background: rgba(239,68,68,.15); color: #f87171; }

/* 权限矩阵（送货方式 × 环节） */
.perm-matrix { min-width: 0 !important; }
.perm-matrix th, .perm-matrix td { text-align: center; }
.perm-matrix th:first-child, .perm-matrix td:first-child { text-align: left; }
.perm-matrix th { position: static; }
.perm-matrix input[type="checkbox"] { width: 16px; height: 16px; vertical-align: middle; }

/* 标签 / 订单明细 / 地址 / 截断 */
.op-tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: var(--panel2); border: 1px solid var(--line); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.order-info-box { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 4px 12px; }
.oi-row { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.oi-row:last-child { border-bottom: none; }
.oi-k { flex: 0 0 72px; color: var(--muted); font-size: 13px; }
.oi-v { flex: 1; min-width: 0; word-break: break-all; }
.addr-readonly { padding: 10px 12px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; min-height: 42px; color: var(--muted); word-break: break-all; }
.phase-title { margin: 14px 0 6px; font-weight: 600; font-size: 14px; }
.img-slot img { width: 60px; height: 60px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }

/* ---------- 照片元信息徽标（拍摄时间/时间差） ---------- */
.pm-badge { display: inline-block; margin-top: 4px; padding: 2px 8px; border-radius: 6px; font-size: 12px; line-height: 1.5; }
.pm-ok { background: rgba(16,185,129,.14); color: #10b981; }
.pm-warn { background: rgba(245,158,11,.16); color: #f59e0b; }
.pm-bad { background: rgba(239,68,68,.15); color: #ef4444; }
.pm-unknown { background: rgba(148,163,184,.15); color: #94a3b8; }
.pm-meta-line { display: flex; flex-direction: column; gap: 4px; }

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; padding: 20px;
}
.modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.modal .actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }

/* ---------- 顶栏 ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.topbar h1 { font-size: 16px; font-weight: 600; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: #fff; color: #111; padding: 10px 18px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 99; max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; }
#toast.err { background: var(--err); color: #fff; }

/* 全局加载遮罩（OCR 进度提示） */
.loading-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 120; padding: 16px;
}
.loading-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px 28px; display: flex; flex-direction: column; align-items: center; gap: 14px;
  min-width: 180px; text-align: center;
}
.loading-box p { font-size: 14px; color: var(--text); }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.15); border-top-color: #3b82f6;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 报表统计 ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.stat-card .stat-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.stat-card .stat-val { font-size: 26px; font-weight: 700; color: var(--text); }
.stat-card .stat-val span { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.stat-card.on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand) inset; }
.chart-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 16px; margin: 10px 0 6px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.legend-item i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.amt { background: none; border: none; color: var(--brand); cursor: pointer; font-size: 13px; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.amt:hover { color: #93c5fd; }
.sort-th { cursor: pointer; user-select: none; white-space: nowrap; }
.sort-th:hover { color: var(--text); }
.sort-arrow { font-size: 11px; margin-left: 3px; color: var(--brand); }
/* 排序设置面板：已选排序条件行 */
.sort-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
tfoot td { background: var(--panel2); font-weight: 600; }
input[type="date"] { color-scheme: dark; }

/* 日统计图下方数据表（转置：列=日期，行=系列） */
.chart-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
.stat-table { table-layout: fixed; font-size: 13px; }
.stat-table th, .stat-table td { padding: 7px 8px; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--line); }
.stat-table th { background: var(--panel2); color: var(--muted); font-weight: 500; }
.stat-table th:first-child, .stat-table td:first-child { text-align: left; position: sticky; left: 0; z-index: 1; overflow: hidden; text-overflow: ellipsis; }
.stat-table td:first-child { background: var(--panel); }
.stat-table th:first-child { background: var(--panel2); }
.stat-table .s-name { color: var(--text); }
.stat-table .s-sum td { background: var(--panel2); font-weight: 600; }
.stat-table .s-sum td:first-child { background: var(--panel2); }
.lg-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }

/* ---------- 多选筛选控件（标签 + 文本框） ---------- */
.ms { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.ms-label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.ms-box { position: relative; display: flex; align-items: center; gap: 6px; min-width: 150px; max-width: 250px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; user-select: none; }
.ms-box:hover { border-color: var(--brand); }
.ms-chips { display: flex; flex-wrap: wrap; gap: 4px; min-height: 18px; align-items: center; flex: 1; min-width: 0; }
.ms-placeholder { color: var(--muted); font-size: 13px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; background: var(--panel2); border: 1px solid var(--line); border-radius: 20px; font-size: 12px; line-height: 1.4; }
.chip i { font-style: normal; color: var(--muted); cursor: pointer; font-size: 13px; }
.chip i:hover { color: var(--err); }
.ms-caret { color: var(--muted); font-size: 10px; margin-left: auto; flex: 0 0 auto; }
.ms-drop { display: none; position: absolute; top: calc(100% + 4px); left: 0; min-width: 100%; max-height: 260px; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; z-index: 40; box-shadow: 0 10px 28px rgba(0,0,0,.35); }
.ms-box.open .ms-drop { display: block; }
.ms-opt { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text); }
.ms-opt:hover { background: var(--panel2); }
.ms-opt input { width: 15px; height: 15px; accent-color: var(--brand); }
.ms-opt span { white-space: nowrap; }

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  body { font-size: 15px; }
  .modal { max-width: 100%; }
}
