/* ========== 医疗器械售后巡检平台 - 样式（移动端优先，适配微信内置浏览器） ========== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --primary: #1a6ee0;
  --primary-dark: #1257b5;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1f2733;
  --text2: #6b7686;
  --line: #e6eaf0;
  --ok: #18a058; --warn: #d97706; --bad: #dc2626; --info: #2563eb; --off: #94a3b8;
  --radius: 12px;
}
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
a { color: var(--primary); text-decoration: none; }
input, select, textarea, button { font-family: inherit; font-size: 15px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--text); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 70px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--text2); margin-bottom: 4px; }

/* ---------- 顶栏 ---------- */
#topbar {
  position: sticky; top: 0; z-index: 50; background: var(--primary); color: #fff;
  padding-top: env(safe-area-inset-top);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 48px; padding: 0 14px; }
#page-title { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: none; border: none; color: #fff; padding: 6px; cursor: pointer; display: flex; align-items: center; }

/* ---------- 底部导航 ---------- */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 0 5px; font-size: 11px; color: var(--text2);
}
#tabbar a.active { color: var(--primary); }

/* ---------- 主内容 ---------- */
#view { padding: 14px; max-width: 900px; margin: 0 auto; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(20,40,80,.05); }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.muted { color: var(--text2); font-size: 13px; }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (min-width: 700px) { .grid2 { grid-template-columns: 1fr 1fr 1fr; } }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--text); cursor: pointer; font-size: 14px; white-space: nowrap;
}
.btn:active { opacity: .8; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-danger { background: #fff; border-color: var(--bad); color: var(--bad); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- 徽标 ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; line-height: 1.5; }
.b-ok { background: #e7f6ee; color: var(--ok); }
.b-warn { background: #fdf1e0; color: var(--warn); }
.b-bad { background: #fdeaea; color: var(--bad); }
.b-info { background: #e8effd; color: var(--info); }
.b-off { background: #eef1f5; color: var(--off); }
.p-紧急 { color: var(--bad); font-weight: 600; } .p-高 { color: var(--warn); font-weight: 600; }
.p-中 { color: var(--info); } .p-低 { color: var(--text2); }

/* ---------- 统计卡 ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
@media (min-width: 700px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 14px; box-shadow: 0 1px 3px rgba(20,40,80,.05); }
.stat-num { font-size: 26px; font-weight: 700; color: var(--primary); line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text2); margin-top: 2px; }

/* ---------- 列表项 ---------- */
.list-item { cursor: pointer; }
.list-item:active { background: #f8fafc; }
.dev-name { font-weight: 600; font-size: 15px; }
.meta-line { font-size: 13px; color: var(--text2); margin-top: 2px; }

/* ---------- 表单 / 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100; background: rgba(15,23,42,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 700px) { .modal-mask { align-items: center; } }
.modal {
  background: #fff; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto;
  border-radius: 16px 16px 0 0; padding: 16px;
}
@media (min-width: 700px) { .modal { border-radius: 14px; } }
.modal-wide { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; font-size: 16px; }
.modal-close { color: var(--text2); cursor: pointer; padding: 4px 8px; font-size: 16px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: 60px; left: 0; right: 0; z-index: 300; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: rgba(31,39,51,.92); color: #fff; padding: 9px 18px; border-radius: 8px;
  font-size: 14px; opacity: 0; transform: translateY(-8px); transition: all .25s; max-width: 86%;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-err { background: rgba(185,28,28,.95); }

/* ---------- 分段选择（巡检项结果） ---------- */
.chk-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.chk-name { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.seg { display: flex; gap: 6px; margin-bottom: 8px; }
.seg label { flex: 1; }
.seg input { display: none; }
.seg span {
  display: block; text-align: center; padding: 6px 0; border-radius: 6px;
  border: 1px solid var(--line); font-size: 13px; color: var(--text2); background: #fff;
}
.seg input:checked + span.r-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.seg input:checked + span.r-bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.seg input:checked + span.r-na { background: var(--off); border-color: var(--off); color: #fff; }

/* ---------- 二维码 ---------- */
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.qr-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px; text-align: center; }
.qr-card .qr-box { display: flex; justify-content: center; margin-bottom: 6px; }
.qr-card .qr-box img, .qr-card .qr-box canvas { width: 120px !important; height: 120px !important; }
.qr-label { font-size: 12px; color: var(--text); line-height: 1.4; word-break: break-all; }
.qr-single { text-align: center; }
.qr-single .qr-box { display: flex; justify-content: center; margin: 10px 0; }
.qr-single .qr-box img, .qr-single .qr-box canvas { width: 200px !important; height: 200px !important; }

/* ---------- 照片 ---------- */
.photo-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.photo-grid img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; }

/* ---------- 信息表格 ---------- */
.info-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.info-table td { padding: 7px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.info-table td:first-child { color: var(--text2); width: 92px; white-space: nowrap; }
.result-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.result-table th, .result-table td { border: 1px solid var(--line); padding: 7px 8px; text-align: left; }
.result-table th { background: #f6f8fb; font-weight: 600; }

/* ---------- 筛选栏 ---------- */
.filter-bar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filter-bar input, .filter-bar select { flex: 1; min-width: 120px; width: auto; }
.filter-bar .btn { flex-shrink: 0; }

/* ---------- 登录页 ---------- */
.login-wrap { max-width: 400px; margin: 8vh auto 0; padding: 0 6px; }
.login-logo { text-align: center; margin-bottom: 22px; }
.login-logo .logo-badge {
  width: 64px; height: 64px; border-radius: 16px; background: var(--primary); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 700;
}
.login-logo h1 { font-size: 19px; margin-top: 10px; }
.login-logo p { font-size: 13px; color: var(--text2); }
.login-tabs { display: flex; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.login-tabs span { flex: 1; text-align: center; padding: 9px 0; cursor: pointer; color: var(--text2); font-size: 15px; }
.login-tabs span.on { color: var(--primary); font-weight: 600; border-bottom: 2px solid var(--primary); }

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

/* ---------- 扫码页 ---------- */
#reader { width: 100%; border-radius: 12px; overflow: hidden; background: #000; }
#reader video { border-radius: 12px; }

/* ---------- 打印 ---------- */
#print-area { display: none; }
@media print {
  body.print-mode #app, body.print-mode #toast-root, body.print-mode #modal-root { display: none !important; }
  body.print-mode { padding: 0; background: #fff; }
  body.print-mode #print-area { display: block !important; }
}
.print-doc { font-family: "PingFang SC", "Microsoft YaHei", sans-serif; color: #111; }
.print-doc h2 { font-size: 18px; margin-bottom: 4px; }
.print-doc .print-sub { font-size: 12px; color: #555; margin-bottom: 14px; }
.print-qr-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.print-qr-card { border: 1px solid #bbb; border-radius: 6px; padding: 10px; text-align: center; page-break-inside: avoid; }
.print-qr-card img { width: 110px; height: 110px; }
.print-qr-card .t { font-size: 12px; font-weight: 600; margin-top: 4px; }
.print-qr-card .s { font-size: 11px; color: #444; word-break: break-all; }
.print-record { border: 1px solid #999; border-radius: 6px; padding: 12px; margin-bottom: 14px; page-break-inside: avoid; }
.print-record h3 { font-size: 15px; margin-bottom: 6px; }
.print-record table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 6px; }
.print-record th, .print-record td { border: 1px solid #999; padding: 4px 6px; text-align: left; }
.print-record th { background: #f0f0f0; }
