:root {
  --primary: #1d6fe0;
  --primary-dark: #1557b0;
  --primary-light: #eaf2fd;
  --danger: #d9363e;
  --success: #12a150;
  --warning: #d98a00;
  --text: #1f2329;
  --text-2: #646a73;
  --text-3: #8f959e;
  --border: #e3e6eb;        /* 分隔线、卡片内边框 */
  --border-input: #c2c9d4;  /* 可输入控件的边框，比 --border 深，好认 */
  --bg: #f5f6f8;
  --card: #ffffff;
  --radius: 10px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 16px; /* 16px 可防止 iOS 自动放大页面 */
}

/* ---------- 顶部栏 ---------- */
.topbar {
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 500; }
.topbar .sub { font-size: 12px; opacity: .85; font-weight: 400; margin-top: 2px; }
.topbar .right { font-size: 13px; display: flex; align-items: center; gap: 12px; }
.linkbtn { background: none; border: none; color: #fff; font-size: 13px; cursor: pointer; padding: 0; }

/* ---------- 布局 ---------- */
.wrap { max-width: 720px; margin: 0 auto; padding: 16px 12px 60px; }
.wrap.wide { max-width: 1180px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.card-title {
  font-size: 15px;
  font-weight: 500;
  margin: 0 0 12px;
  padding-left: 9px;
  border-left: 3px solid var(--primary);
  line-height: 1.2;
}
.card-title .tip { font-size: 12px; color: var(--text-3); font-weight: 400; margin-left: 6px; }

/* ---------- 表单 ---------- */
/* 视觉层次：可填的输入框「白底深边」> 可点的下拉「浅蓝底 + 箭头」> 只读区「灰底虚线」*/
.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
label.field { display: block; }

/* 字段名：加粗一档，跟「可点的控件」和「浅灰说明文字」拉开层次 */
.field > span.lb {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #3f4653;
  margin-bottom: 6px;
}
.field > span.lb .req { color: var(--danger); margin-left: 2px; }
/* 字段下面的补充说明，保持浅灰，跟可点的控件明显不同 */
.field > span.lb .tip, .field .tip { font-weight: 400; color: var(--text-3); }

/* 文本框 / 数字框 / 日期框 / 文本域：白底 + 加深的边框 */
input[type=text], input[type=tel], input[type=number], input[type=password], input[type=date], textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-input);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

/* 下拉框：浅蓝底 + 右侧箭头 + 字重加粗，一眼看出「这个可以点开选」 */
select {
  width: 100%;
  padding: 10px 34px 10px 12px;
  border: 1px solid var(--border-input);
  border-radius: 8px;
  background-color: #f4f8fd;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5L6 6.5L11 1.5' fill='none' stroke='%235a6473' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
  color: var(--text);
  font-weight: 500;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
/* 未选择时占位项显浅，选了之后变深，提示「还没选」 */
select:invalid, select option[value=""] { color: var(--text-3); }

/* 聚焦：主题色边框 + 一圈柔和光晕，手机上也能明确看到焦点在哪 */
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 111, 224, .14);
}
/* 鼠标悬停（只对有鼠标的设备生效，避免手机上出现粘滞效果） */
@media (hover: hover) {
  input:hover, textarea:hover { border-color: #9aa3b2; }
  select:hover { border-color: var(--primary); background-color: #eaf2fd; }
}

/* 禁用：明显变灰，且去掉箭头，表示「现在不能选」 */
input:disabled, select:disabled, textarea:disabled {
  background: #f5f6f8;
  background-image: none;
  color: #a8adb5;
  border-color: #e0e3e8;
  cursor: not-allowed;
}

textarea { resize: vertical; min-height: 88px; }

/* 退货地址下方的提醒语（如「拒收到付件」）：只是提示，不参与复制，
   所以不用只读框的样式，改成更醒目的橙色提示条，避免被当成地址的一部分 */
.return-remark {
  margin-top: 8px;
  padding: 8px 12px;
  background: #fff7e6;
  border: 1px solid #ffd591;
  border-left: 3px solid #d98a00;
  border-radius: 6px;
  color: #ad6800;
  font-size: 13px;
}

/* 只读区：虚线 + 灰底，跟可编辑的控件彻底区分开（退货地址、工单信息展示） */
.readonly-box {
  padding: 10px 12px;
  background: #f2f3f5;
  border: 1px dashed #c2c9d4;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 14px;
  white-space: pre-wrap;
}

.btn {
  display: inline-block;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  text-align: center;
}
.btn:active { background: var(--primary-dark); }
.btn:disabled { background: #b9c4d4; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.btn.mini { width: auto; padding: 7px 14px; font-size: 14px; border-radius: 6px; }
.btn.danger { background: var(--danger); }
.btn.gray { background: #f0f1f3; color: var(--text-2); }
.btn-row { display: flex; gap: 10px; }

.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; }
.code-row button { width: 118px; flex-shrink: 0; }

.devcode {
  margin-top: 10px;
  padding: 10px 12px;
  background: #fff7e6;
  border: 1px dashed #ffc069;
  border-radius: 8px;
  color: #ad6800;
  font-size: 14px;
}
.devcode b { font-size: 18px; letter-spacing: 2px; color: #d4380d; }

.msg {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
  display: none;
}
.msg.err { display: block; background: #fff1f0; color: var(--danger); border: 1px solid #ffccc7; }
.msg.ok { display: block; background: #f6ffed; color: var(--success); border: 1px solid #b7eb8f; }

/* ---------- 工单卡片 ---------- */
.ticket {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.ticket-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.ticket-no { font-weight: 500; font-size: 15px; }
.ticket-time { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.ticket-body { margin-top: 8px; font-size: 14px; color: var(--text-2); }
.ticket-body .line { margin-bottom: 3px; word-break: break-all; }
.ticket-foot { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
}
.tag.待客户补充, .tag.s0 { background: #fff7e6; color: #d46b08; }
.tag.待受理, .tag.s1 { background: #fffbe6; color: #d48806; }
.tag.已受理, .tag.s2 { background: #e6f4ff; color: #1677ff; }
.tag.待用户寄回, .tag.s2 { background: #fff1f0; color: #cf1322; }
.tag.已收到, .tag.s3 { background: #f9f0ff; color: #722ed1; }
.tag.维修中, .tag.s4 { background: #e6fffb; color: #08979c; }
.tag.已寄出, .tag.s5 { background: #fcffe6; color: #7cb305; }
.tag.已完成, .tag.s6 { background: #f6ffed; color: #389e0d; }
.tag.已关闭, .tag.s7 { background: #f0f0f0; color: #8c8c8c; }

.empty { text-align: center; color: var(--text-3); padding: 40px 0; font-size: 14px; }

/* ---------- 图片上传 ---------- */
.img-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.img-grid img { width: 76px; height: 76px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; }
.img-pick {
  width: 76px; height: 76px;
  border: 1px dashed #c9ced6;
  border-radius: 6px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-3); font-size: 12px; cursor: pointer; background: #fafbfc;
}
.img-pick span { font-size: 22px; line-height: 1; margin-bottom: 2px; }
.img-item { position: relative; z-index: 1; }
.img-del {
  position: absolute; top: -6px; right: -6px; z-index: 2;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,.62); color: #fff;
  border: none; font-size: 14px; line-height: 20px; padding: 0; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
/* 手机上 22px 太小，往四周扩一圈透明热区（36x36），视觉不变但好点。
   外扩 7px 小于网格 gap 8px，不会盖到相邻图片。 */
.img-del::after {
  content: '';
  position: absolute; top: -7px; right: -7px; bottom: -7px; left: -7px;
}
@media (hover: hover) {
  .img-del:hover { background: rgba(0,0,0,.82); }
}

/* ---------- 输入框 + 右侧按钮（如单号 + 扫码） ---------- */
.input-row { display: flex; gap: 8px; align-items: stretch; }
.input-row input { flex: 1; min-width: 0; }
.input-row .btn { flex: none; white-space: nowrap; }

/* ---------- 物流公司自动识别候选 ---------- */
.express-guess { margin-top: 8px; }
.guess-tip { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 6px; line-height: 1.5; }
.guess-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.guess-chip {
  padding: 5px 12px; border-radius: 14px; font-size: 13px; cursor: pointer;
  background: #f2f3f5; color: var(--text-2); border: 1px solid transparent;
  -webkit-tap-highlight-color: transparent;
}
.guess-chip.on {
  background: var(--primary-light); color: var(--primary);
  border-color: var(--primary); font-weight: 500;
}

/* ---------- 扫码录入 ---------- */
/* 扫码要全屏沉浸，这里单独用 fixed，不受页面滚动影响 */
.scan-mask { position: fixed; background: rgba(0,0,0,.9); padding: 0; z-index: 90; }
/* 提高优先级，盖过后面 .mask 的 position/background/z-index，保证扫码弹窗全屏沉浸式显示 */
.mask.scan-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.92);
  z-index: 100; padding: 0; overflow: hidden;
}
.mask.scan-mask.show { display: flex; align-items: center; justify-content: center; }
.scan-box { max-width: 520px; margin: 0 auto; padding: 16px; width: 100%; }
.scan-head {
  display: flex; justify-content: space-between; align-items: center;
  color: #fff; font-size: 15px; margin-bottom: 10px;
}
.scan-close { background: none; border: none; color: #fff; font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px; }
.scan-stage {
  position: relative; width: 100%; aspect-ratio: 1 / 1; min-height: 240px;
  background: #000; border-radius: 10px; overflow: hidden;
}
.scan-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
/* 取景框只是视觉提示，不参与识别，识别范围始终是整帧 */
.scan-frame {
  position: absolute; left: 12%; right: 12%; top: 30%; bottom: 30%;
  border: 2px solid rgba(255,255,255,.85); border-radius: 8px; pointer-events: none;
}
.scan-tip { color: rgba(255,255,255,.85); font-size: 13px; text-align: center; margin-top: 12px; line-height: 1.6; }
.scan-fallback { color: #fff; font-size: 13px; text-align: center; margin-top: 12px; line-height: 1.6; }
.scan-fallback p { margin: 0 0 10px; }
.manual-row { display: flex; gap: 8px; margin-top: 10px; }
.manual-row input {
  flex: 1; min-width: 0; padding: 9px 10px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.12);
  color: #fff; font-size: 14px;
}
.manual-row input::placeholder { color: rgba(255,255,255,.55); }

/* ---------- 时间轴 ---------- */
.timeline { border-left: 2px solid var(--border); padding-left: 14px; margin-top: 6px; }
.timeline .item { position: relative; margin-bottom: 12px; }
.timeline .item::before {
  content: ''; position: absolute; left: -20px; top: 6px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--primary);
}
.timeline .t { font-size: 12px; color: var(--text-3); }
.timeline .c { font-size: 14px; }

/* ---------- 管理端 ---------- */
.nav { display: flex; gap: 4px; background: #fff; padding: 8px; overflow-x: auto; border-bottom: 1px solid var(--border); }
.nav button {
  border: none; background: none; padding: 8px 14px; font-size: 14px;
  color: var(--text-2); cursor: pointer; border-radius: 6px; white-space: nowrap;
}
.nav button.on { background: var(--primary-light); color: var(--primary); font-weight: 500; }

.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat {
  background: #fff; border-radius: var(--radius); padding: 14px 12px; text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.stat .n { font-size: 24px; font-weight: 500; }
.stat .l { font-size: 12px; color: var(--text-3); }
/* 统计卡片可点击筛选 */
.stat.clickable {
  cursor: pointer; user-select: none;
  border: 1px solid transparent;
  transition: border-color .15s, background .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
  .stat.clickable:hover { border-color: var(--primary); background: var(--primary-light); }
}
.stat.clickable:active { transform: scale(.98); }
.stat.clickable.on {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(29,111,224,.14);
}
.stat.clickable.on .l { color: var(--primary); font-weight: 500; }
.stat.clickable.on .l::after { content: ' ✕'; font-size: 11px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
/* 筛选区是横向排布，padding 要留够右侧箭头的位置，否则文字会被箭头压住 */
.filters input, .filters select { width: auto; flex: 1; min-width: 130px; padding: 8px 28px 8px 10px; font-size: 14px; }
.filters input { padding: 8px 10px; }
.filters select { background-position: right 8px center; }

/* 表格（电脑端）/ 卡片（手机端） */
.table { display: none; }
.table table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; font-size: 14px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { background: #fafbfc; color: var(--text-2); font-weight: 500; white-space: nowrap; }
.table tbody tr:hover { background: #fafcff; }
.table td.nowrap { white-space: nowrap; }

/* 弹窗 */
.mask {
  display: none; position: absolute; inset: 0; background: rgba(0,0,0,.45);
  z-index: 50; overflow-y: auto; padding: 20px 12px;
}
.mask.show { display: block; }
.modal {
  background: #fff; border-radius: 12px; max-width: 640px; margin: 0 auto; padding: 18px;
}
.modal h3 { margin: 0 0 14px; font-size: 16px; font-weight: 500; }

.login-box { max-width: 380px; margin: 8vh auto 0; padding: 24px; background: #fff; border-radius: 12px; }
.login-box h2 { margin: 0 0 4px; font-size: 20px; font-weight: 500; text-align: center; }
.login-box .sub { text-align: center; color: var(--text-3); font-size: 13px; margin-bottom: 20px; }
.login-box .field { margin-bottom: 14px; }

.hide { display: none !important; }
.muted { color: var(--text-3); font-size: 13px; }
.right-align { text-align: right; }

/* 省市区三级联动：手机上三等分一行，电脑上自动变宽 */
.region-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
/* 三个下拉并排，箭头靠更左边一点，给「内蒙古自治区」这种长名字留空间 */
.region-picker select {
  width: 100%;
  min-width: 0;
  padding: 10px 22px 10px 8px;
  font-size: 13px;
  background-position: right 6px center;
  background-size: 10px 7px;
}
.region-picker select:disabled { background-color: #f5f6f8; background-image: none; color: #b0b5bd; }

/* 短信预览框（工单详情里发给客户的通知短信） */
.sms-box { margin-top: 12px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: #fafbfc; }
.sms-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; font-weight: 500; font-size: 14px; }
.sms-preview {
  margin-top: 8px; padding: 10px 12px; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; line-height: 1.7; word-break: break-all;
}

/* 大屏适配：表单两列、显示表格 */
@media (min-width: 720px) {
  .stat-row { grid-template-columns: repeat(4, 1fr); }
  .form-grid { grid-template-columns: 1fr 1fr; gap: 14px 16px; }
  .form-grid .full { grid-column: 1 / -1; }
  .wrap { padding: 20px 20px 60px; }
}
@media (min-width: 900px) {
  .table { display: block; }
  .cards-list { display: none; }
}
