:root {
  --bg: #0f172a;
  --card: #ffffff;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-d: #1d4ed8;
  --ok: #059669;
  --warn: #d97706;
  --bad: #dc2626;
  --a: #2563eb;
  --b: #059669;
  --radius: 14px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: #f1f5f9;
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  overscroll-behavior-y: contain;
}

a { color: var(--brand); }

/* ---------------- 布局 ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg);
  color: #fff;
  box-shadow: 0 2px 10px rgba(15, 23, 42, .25);
}
.topbar .title { font-weight: 700; font-size: 17px; flex: 1; }
.topbar .who { font-size: 13px; opacity: .85; }
.topbar .role {
  display: inline-block; padding: 1px 8px; border-radius: 20px;
  font-size: 12px; font-weight: 700; background: var(--brand); color: #fff;
}
.topbar .role.B { background: var(--b); }
.topbar button {
  background: rgba(255, 255, 255, .14); color: #fff; border: 0;
  border-radius: 9px; padding: 7px 11px; font-size: 13px;
}

.wrap { max-width: 900px; margin: 0 auto; padding: 14px 12px 96px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .10);
  padding: 14px;
  margin-bottom: 12px;
}
.card h2 { margin: 0 0 10px; font-size: 15px; color: var(--muted); font-weight: 600; }

/* ---------------- 表单 ---------------- */
input[type=text], input[type=password], textarea, select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 16px;      /* 16px 以上 iOS 不会自动放大 */
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; min-height: 76px; }
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }

button {
  font-family: inherit;
  font-size: 16px;
  border: 0;
  border-radius: 11px;
  padding: 12px 16px;
  background: #e2e8f0;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}
button:active { transform: scale(.985); }
button:disabled { opacity: .5; }
button.primary { background: var(--brand); color: #fff; }
button.ok { background: var(--ok); color: #fff; }
button.bad { background: #fee2e2; color: var(--bad); }
button.ghost { background: #f1f5f9; color: var(--ink); border: 1px solid var(--line); }
button.big { width: 100%; padding: 16px; font-size: 18px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 0; min-width: 120px; }

/* ---------------- 登录页 ---------------- */
.login {
  max-width: 420px; margin: 0 auto; padding: 28px 16px;
}
.login h1 { font-size: 24px; margin: 8px 0 2px; text-align: center; }
.login .sub { text-align: center; color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.rolebtn {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 18px; margin-bottom: 12px; text-align: left;
  border-radius: var(--radius); background: #fff; border: 2px solid var(--line);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
}
.rolebtn .ico { font-size: 30px; }
.rolebtn b { display: block; font-size: 17px; }
.rolebtn small { color: var(--muted); font-weight: 400; }
.rolebtn.sel-a { border-color: var(--a); }
.rolebtn.sel-b { border-color: var(--b); }

/* ---------------- 缩略图 ---------------- */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.thumb { position: relative; width: 86px; height: 86px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .x {
  position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; line-height: 20px;
  text-align: center; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 14px;
}

/* ---------------- 消息流 ---------------- */
.msg { display: flex; gap: 9px; margin-bottom: 12px; align-items: flex-start; }
.msg .av {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
  background: var(--brand); color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.msg.role-B .av, .msg.role-server .av { background: var(--b); }
.msg.role-server .av { background: #475569; }
.msg .body { flex: 1; min-width: 0; }
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.bubble {
  background: #fff; border-radius: 4px 12px 12px 12px; padding: 9px 12px;
  box-shadow: 0 1px 3px rgba(15,23,42,.08); word-break: break-word; white-space: pre-wrap;
}
.msg.role-server .bubble { background: #ecfdf5; border: 1px solid #a7f3d0; }
.bubble img { max-width: 100%; border-radius: 8px; display: block; margin-top: 6px; }

/* 一张卡片里的文字 + 多图 */
.msgtext { white-space: pre-wrap; word-break: break-word; margin-bottom: 2px; }
.imgs { display: grid; grid-template-columns: 1fr; gap: 6px; margin-top: 6px; }
.imgs.multi { grid-template-columns: repeat(2, 1fr); }
.shotlink { position: relative; display: block; line-height: 0; }
.imgs img { width: 100%; border-radius: 8px; display: block; margin: 0; }
.picno {
  position: absolute; left: 6px; top: 6px; line-height: 1.5;
  background: rgba(15, 23, 42, .78); color: #fff;
  font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 20px;
}
/* 发送卡片上的识别状态 */
.groupstatus {
  margin-top: 8px; padding-top: 7px; border-top: 1px dashed var(--line);
  font-size: 13px; font-weight: 600; color: var(--ok);
}
.groupstatus.pending { color: var(--brand); }
.groupstatus.failed { color: var(--bad); }

/* 卡片下方的操作（删除等） */
.groupacts { display: flex; gap: 8px; margin-top: 7px; flex-wrap: wrap; }
.groupacts button { padding: 7px 13px; font-size: 13px; }

/* 卡片标题行右侧的操作按钮 */
.msg .meta { display: flex; align-items: center; gap: 8px; }
.msg .meta .metatext { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .meta .spacer { flex: 1; }
.msg .meta .act {
  padding: 5px 11px; font-size: 12.5px; border-radius: 8px; font-weight: 700;
  background: #fee2e2; color: var(--bad); flex: 0 0 auto;
}
.msg .meta .act[disabled] { opacity: .5; }

/* ---------------- 工单卡片 ---------------- */
.rec { border-left: 4px solid var(--warn); }
.rec.confirmed { border-left-color: var(--ok); }
.rec.pending { border-left-color: var(--brand); }
.rec.failed { border-left-color: var(--bad); }
.rec .hd { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.rec .hd .no { font-weight: 700; }
.badge {
  font-size: 12px; padding: 2px 8px; border-radius: 20px; font-weight: 700;
  background: #fef3c7; color: #92400e;
}
.badge.confirmed { background: #d1fae5; color: #065f46; }
.badge.pending { background: #dbeafe; color: #1e40af; }
.badge.failed { background: #fee2e2; color: #991b1b; }
/* 工序 / 产品状态 */
.badge.proc { background: #e0e7ff; color: #3730a3; }
.badge.prog-doing { background: #fde68a; color: #92400e; }
.badge.prog-done { background: #bbf7d0; color: #065f46; }
.kv { display: grid; grid-template-columns: 88px 1fr; gap: 4px 10px; font-size: 14px; margin: 6px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; white-space: pre-wrap; }
.kv dd.empty { color: #cbd5e1; }
.rec .thumbimg { max-width: 130px; border-radius: 8px; border: 1px solid var(--line); margin-top: 4px; }
.rec .recimgs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.rec .recimgs a { line-height: 0; }
.batchnote {
  background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af;
  border-radius: 8px; padding: 7px 10px; font-size: 13px; margin: 6px 0 8px;
  white-space: pre-wrap; word-break: break-word;
}

/* 卡片标题 = A 端发图时写的说明 */
.rectitle {
  background: #eff6ff; border-left: 4px solid var(--brand);
  color: #1e3a8a; font-weight: 700; font-size: 16px; line-height: 1.45;
  padding: 9px 12px; border-radius: 8px; margin: 0 0 10px;
  white-space: pre-wrap; word-break: break-word;
}

/* 识别结果表格（整体加粗，手机上看得更清楚） */
.rectable { width: 100%; border-collapse: collapse; font-size: 15px; font-weight: 700; table-layout: fixed; }
.rectable th, .rectable td {
  border: 1px solid var(--line); padding: 7px 9px;
  vertical-align: top; text-align: left; word-break: break-word;
  font-weight: 700;
}
.rectable th {
  background: #eef2f7; color: #475569;
  width: 104px; line-height: 1.35;
}
.rectable td { color: #0f172a; white-space: pre-wrap; line-height: 1.5; }
.rectable td.empty { color: #cbd5e1; }

/* 工单原图 */
.recimg { display: block; margin: 0 0 10px; line-height: 0; }
.recimg img {
  width: 100%; max-height: 260px; object-fit: contain;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 10px;
}
.rec .acts { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.rec .acts button { padding: 9px 13px; font-size: 14px; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-top: 6px; }
details.more pre { white-space: pre-wrap; font-size: 13px; background: #f8fafc; padding: 10px; border-radius: 8px; }

/* ---------------- 标签页 ---------------- */
.tabs { display: flex; gap: 6px; padding: 10px 12px 0; max-width: 900px; margin: 0 auto; }
.tabs button { flex: 1; background: #e2e8f0; font-size: 15px; padding: 11px 6px; }
.tabs button.on { background: var(--bg); color: #fff; }
.page { display: none; }
.page.on { display: block; }

/* ---------------- 其他 ---------------- */
.empty { text-align: center; color: var(--muted); padding: 34px 10px; font-size: 14px; }
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: rgba(15,23,42,.92); color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 14px; z-index: 99; max-width: 88vw; text-align: center;
}
.spin { display: inline-block; width: 13px; height: 13px; border: 2px solid #cbd5e1;
  border-top-color: var(--brand); border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -1px; }
@keyframes sp { to { transform: rotate(360deg); } }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
/* 原图按保留期清理掉了：用中性提示代替破图，别让人以为坏了 */
.purged {
  display: inline-block; font-size: 12px; color: #64748b;
  background: #f1f5f9; border: 1px dashed #cbd5e1; border-radius: 8px;
  padding: 6px 10px; margin-top: 8px;
}
.modal {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 50;
  display: none; align-items: flex-end; justify-content: center;
}
.modal.on { display: flex; }
.modal .sheet {
  background: #f8fafc; width: 100%; max-width: 900px; max-height: 92vh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 16px;
}
.modal .sheet h3 { margin: 0 0 12px; }
.sticky-send {
  position: fixed; left: 0; right: 0; bottom: 0; background: rgba(241,245,249,.96);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line);
  max-width: 900px; margin: 0 auto;
}
.files li { margin-bottom: 8px; display: flex; gap: 10px; align-items: center; }
.files .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.files .dt { color: var(--muted); font-size: 12px; }

/* ---------------- 开关 ---------------- */
.switch {
  display: flex; align-items: center; gap: 10px;
  margin-top: 12px; font-size: 14px; color: var(--muted); cursor: pointer;
}
.switch input { width: 20px; height: 20px; accent-color: var(--brand); flex: 0 0 20px; }

/* ---------------- 三个选项（日期 / 工序 / 状态） ---------------- */
.pickrow { margin-bottom: 14px; }
.picklabel {
  font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 7px;
}
.datesel { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 15px; }
.datesel select {
  width: auto; flex: 0 0 auto; padding: 11px 10px; font-size: 16px; font-weight: 700;
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.shake { animation: shake .4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.chip {
  padding: 12px 20px; border-radius: 11px; font-size: 16px; font-weight: 700;
  background: #fff; color: var(--ink); border: 2px solid var(--line);
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.on.green { background: var(--ok); border-color: var(--ok); }
.chip.miss { border-color: var(--bad); background: #fef2f2; }

/* ---------------- 提示块 ---------------- */
.notice {
  margin-top: 12px; padding: 11px 13px; border-radius: 10px;
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  font-size: 13px; line-height: 1.7;
}
.notice b { color: #78350f; }

/* ---------------- 网页内相机 ---------------- */
.campane {
  background: #000; padding: 0; display: flex; flex-direction: column;
  border-radius: 16px 16px 0 0; overflow: hidden;
}
.cam-view { position: relative; background: #000; line-height: 0; }
.campane video { width: 100%; max-height: 56vh; background: #000; object-fit: contain; display: block; }
.cam-flash {
  position: absolute; inset: 0; background: #fff; opacity: 0;
  pointer-events: none; transition: opacity .1s;
}
.cam-flash.on { opacity: .85; }

/* 已拍缩略图条 */
.cam-thumbs {
  display: none; gap: 6px; padding: 8px 12px; background: #0b1220;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.cam-thumbs.on { display: flex; }
.cam-thumbs img {
  width: 48px; height: 48px; object-fit: cover; border-radius: 6px;
  border: 2px solid #334155; flex: 0 0 48px;
}
.cam-thumbs .n { color: #94a3b8; font-size: 13px; align-self: center; padding-left: 4px; white-space: nowrap; }

.cam-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); background: #0f172a;
}
.cam-bar .ghost { background: rgba(255, 255, 255, .16); color: #fff; border: 0; font-size: 14px; }
.cam-bar .ghost.send { background: var(--brand); font-weight: 700; }
.shot {
  width: 72px; height: 72px; border-radius: 50%; flex: 0 0 72px;
  background: #fff; border: 5px solid #94a3b8; box-shadow: 0 0 0 2px rgba(255, 255, 255, .25);
}
.shot:active { background: #cbd5e1; }
.shot.attn { animation: attn .7s ease-in-out 2; }
@keyframes attn {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 255, 255, .25); transform: scale(1); }
  50% { box-shadow: 0 0 0 12px rgba(37, 99, 235, .45); transform: scale(1.06); }
}
.cam-tip { color: #94a3b8; font-size: 13px; text-align: center; padding: 0 14px 14px; background: #0f172a; }
