:root {
  --bg: #f2f4f7;
  --card: #fff;
  --primary: #2f6fed;
  --primary-d: #2456c4;
  --ok: #1aa260;
  --warn: #e8870c;
  --danger: #e23c3c;
  --text: #1f2733;
  --muted: #8a94a6;
  --line: #e6e9ef;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
.hidden { display: none !important; }
.screen { min-height: 100vh; }

/* 登录 */
.login-card {
  max-width: 380px;
  margin: 12vh auto 0;
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: 0 8px 30px rgba(20,40,80,.08);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .sub { color: var(--muted); margin: 0 0 18px; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.login-card input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 15px; outline: none;
}
.login-card input:focus { border-color: var(--primary); }
.role-pick { display: flex; gap: 10px; }
.role-btn {
  flex: 1; padding: 11px 0; border: 1px solid var(--line); background: #fff;
  border-radius: 10px; cursor: pointer; font-size: 14px; color: var(--text);
}
.role-btn.active { border-color: var(--primary); background: #eef3ff; color: var(--primary-d); font-weight: 600; }
.login-card .primary { width: 100%; margin-top: 18px; }
.hint { margin-top: 14px; font-size: 12px; color: var(--muted); }

/* 顶栏 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 17px; }
.me { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.tag { background: #eef3ff; color: var(--primary-d); padding: 2px 8px; border-radius: 20px; font-size: 12px; }
.me .ghost { padding: 4px 10px; font-size: 12px; }

/* 导航 */
.nav { display: flex; gap: 8px; padding: 10px 12px; overflow-x: auto; background: var(--bg); }
.nav button {
  white-space: nowrap; padding: 8px 14px; border: 1px solid var(--line);
  background: #fff; border-radius: 20px; cursor: pointer; font-size: 14px; color: var(--text);
}
.nav button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 主体 */
.main { padding: 12px; max-width: 760px; margin: 0 auto; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  margin-bottom: 12px; box-shadow: 0 2px 10px rgba(20,40,80,.04);
}
.card h3 { margin: 0 0 10px; font-size: 16px; }
.row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; }
.row .k { color: var(--muted); }
.row .v { text-align: right; font-weight: 500; }

button { font-family: inherit; }
.primary {
  background: var(--primary); color: #fff; border: none; padding: 11px 16px;
  border-radius: 10px; cursor: pointer; font-size: 15px; font-weight: 600;
}
.primary:active { background: var(--primary-d); }
.ghost {
  background: #fff; color: var(--text); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 10px; cursor: pointer; font-size: 14px;
}
.danger { background: #fff; color: var(--danger); border: 1px solid #f3c2c2; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.wecom {
  width: 100%; margin-top: 10px; background: #2aae67; color: #fff; border: none;
  padding: 11px 16px; border-radius: 10px; cursor: pointer; font-size: 15px; font-weight: 600;
}
.wecom:active { background: #229a5a; }

label.field { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
input, textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 15px; outline: none; font-family: inherit;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 64px; }

/* 订单列表项 */
.order-item { cursor: pointer; }
.order-item .title { font-weight: 600; font-size: 16px; display: flex; justify-content: space-between; align-items: center; }
.badge { font-size: 12px; padding: 2px 9px; border-radius: 20px; font-weight: 600; }
.badge.doing { background: #fff4e3; color: var(--warn); }
.badge.done { background: #e6f7ee; color: var(--ok); }
.badge.need { background: #ffeaea; color: var(--danger); }
.stats { display: flex; gap: 14px; margin-top: 8px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }

/* 序列号记录 */
.serial-item { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.serial-item .sn { font-weight: 600; }
.serial-item .meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.chips { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 6px; }
.chip.ok { background: #e6f7ee; color: var(--ok); }
.chip.no { background: #f3f5f8; color: var(--muted); }
.chip.mat { background: #fff4e3; color: var(--warn); }
.chip.rc { background: #ede9ff; color: #6b4fd8; }
.serial-actions { margin-top: 8px; }

/* 建议 / 物流 */
.feed-item { border-left: 3px solid var(--primary); padding: 8px 10px; background: #f8faff; border-radius: 0 8px 8px 0; margin-bottom: 8px; }
.feed-item .who { font-size: 12px; color: var(--muted); }
.feed-item .ct { margin-top: 2px; }
.logi-item { border: 1px dashed var(--line); padding: 10px; border-radius: 8px; margin-bottom: 8px; }
.locked { color: var(--muted); font-size: 13px; font-style: italic; }

/* 日报 */
.daily-box { background: #0f1830; color: #d8e2ff; border-radius: 10px; padding: 14px; white-space: pre-wrap; font-size: 14px; line-height: 1.7; }
.daily-hist { margin-top: 10px; }
.daily-hist .dh { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }

.section-title { font-size: 14px; font-weight: 700; margin: 16px 0 8px; color: var(--text); }
.empty { color: var(--muted); text-align: center; padding: 30px 0; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  background: rgba(30,40,60,.92); color: #fff; padding: 10px 18px;
  border-radius: 24px; font-size: 14px; z-index: 99; max-width: 80%;
}

/* 自定义确认弹窗 */
.confirm-mask {
  position: fixed; inset: 0; background: rgba(15,24,48,.45);
  display: flex; align-items: center; justify-content: center; z-index: 120;
}
.confirm-box {
  background: #fff; width: 84%; max-width: 320px; border-radius: var(--radius);
  padding: 20px 18px 16px; box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.confirm-msg { font-size: 15px; color: var(--text); margin-bottom: 18px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions button { flex: 1; }

/* 返修情况统计 */
.st-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.st-head b { font-size: 15px; }
.st-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 4px;
}
.st-cell {
  background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 6px; text-align: center;
}
.st-cell b { display: block; font-size: 18px; color: var(--primary); }
.st-cell span { font-size: 11px; color: var(--muted); }
.st-row {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px;
  background: #fff;
}
.st-row.warn { border-color: #f3c2c2; background: #fff8f8; }
.st-row .r1 { font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.st-row .r2 { font-size: 12px; color: var(--muted); margin-top: 4px; }
@media (max-width: 360px) {
  .st-grid { grid-template-columns: repeat(2, 1fr); }
}

/* 导航“待接单”红色数字角标 */
#nav button { position: relative; }
.nav-badge {
  position: absolute; top: -6px; right: -6px;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--danger, #e5484d); color: #fff;
  border-radius: 999px; font-size: 11px; line-height: 18px;
  text-align: center; font-weight: 700;
  box-shadow: 0 0 0 2px #fff;
}
.badge.prog { background: #ede9ff; color: #6b4fd8; }

/* 仅更新程序：进度条与每日记录 */
.pg-bar {
  height: 10px; background: #eef1f6; border-radius: 999px; overflow: hidden; margin: 10px 0 8px;
}
.pg-fill { height: 100%; background: linear-gradient(90deg, #3b6cf6, #6b4fd8); transition: width .3s; }
.pg-hist { margin-top: 12px; }
.pg-hist .dh { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }

/* 返修品照片：缩略图与补传 */
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumb {
  width: 64px; height: 64px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); cursor: pointer; background: #f3f5f8;
}
.photo-up { margin-top: 10px; }
.photo-up .up-tip { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.photo-up input[type="file"] { font-size: 12px; }

/* 表单多行输入 */
textarea {
  width: 100%; min-height: 72px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 14px; font-family: inherit; resize: vertical;
  box-sizing: border-box; background: #fff; color: var(--text);
}
