/* 电池信息查询工具 — 新版页面公共样式（H5 移动端优先，PC 居中限宽） */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background-color: #ecf4ee;
  color: #333;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 76px; /* 底部导航留白 */
}

/* ---------- 顶部 ---------- */
.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 72px 12px; /* 左右各预留语言切换按钮空间，标题居中且不被遮挡 */
}
.page-title {
  text-align: center;
  font-size: 21px;
  font-weight: 700;
  color: #173526;
  letter-spacing: .5px;
  padding: 24px 16px 16px;
}
.topbar .page-title { padding: 0; font-size: 19px; letter-spacing: .2px; }
.lang-btn {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  padding: 6px 16px;
  font-size: 13px;
  color: #0a8f57;
  background: #e2f4ea;
  border: none;
  border-radius: 999px;
  cursor: pointer;
}
.lang-btn:active { background: #cdeedc; }
.lang-btn.lang-fixed { position: fixed; top: 10px; right: 10px; z-index: 999; }

/* ---------- 卡片 ---------- */
.card {
  background: #fff;
  border-radius: 16px;
  margin: 0 14px 14px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .03);
}
.sec-title {
  display: flex;
  align-items: center;
  font-size: 16px;
  font-weight: 700;
  color: #1d382b;
  margin-bottom: 12px;
}
.sec-title svg { width: 18px; height: 18px; margin-right: 7px; flex-shrink: 0; }
.sec-title svg path { fill: #0a8f57; }
.grid-item svg path { fill: #0a8f57; }
.guide-text { font-size: 14px; color: #666; line-height: 1.7; }
.guide-tip {
  text-align: center;
  font-size: 13px;
  color: #9aa0a8;
  padding: 0 16px 14px;
}

/* 语音提示条 */
.voice-tip {
  display: flex;
  align-items: flex-start;
  background: #fff7e8;
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 12px;
}
.voice-tip .v-icon { font-size: 16px; margin-right: 8px; line-height: 1.5; }
.voice-tip .v-txt { font-size: 13px; color: #8a6d3b; line-height: 1.6; }
.copy-link {
  border: none; background: none; padding: 0;
  color: #fa8c16; font-size: 13px; cursor: pointer;
}

/* ---------- 输入区 ---------- */
.input-box {
  background: #f0f4f1;
  border-radius: 10px;
  padding: 13px 14px;
}
.input-box input, .input-box select {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 15px;
  color: #333;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.input-box input::placeholder { color: #b8bcc4; }
.input-box:focus-within { box-shadow: 0 0 0 3px rgba(10, 141, 87, .14); }
.input-box select { color: #333; }
.input-box select.placeholder { color: #b8bcc4; }
.char-count {
  text-align: right;
  font-size: 12px;
  color: #999;
  margin: 8px 0 14px;
}

/* ---------- 按钮 ---------- */
.btn-row { display: flex; gap: 12px; }
.btn {
  flex: 1;
  height: 46px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-green { background: #0aa35e; color: #fff; }
.btn-green:active { background: #08914f; }
.btn-lightblue { background: #e2f4ea; color: #0a8f57; }
.btn-grey { background: #e8ede9; color: #333; font-weight: 600; }
.btn-grey:active { background: #dfe6e1; }
.btn-danger-plain { background: #fff; color: #f5222d; border: 1px solid #ffd6d6; }
.btn-pill { border-radius: 24px; height: 50px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-center { display: flex; justify-content: center; margin: 6px 0 14px; }
.btn-center .btn { flex: 0 0 62%; }

/* ---------- 宫格 ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-item {
  background: #eef2ef;
  border-radius: 12px;
  padding: 18px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  font-size: 14px;
  font-weight: 600;
  color: #333;
}
.grid-item:active { background: #e1e8e3; }
.grid-item svg { width: 22px; height: 22px; margin-bottom: 8px; }

/* ---------- 页脚 ---------- */
footer {
  margin-top: 10px;
  border-top: 1px solid #dce6df;
  padding: 0 14px 12px;
}
.foot-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 14px 0 6px;
  font-size: 13px;
}
.foot-links a { color: #8a8f99; text-decoration: none; }
.foot-links .sep { color: #c8ccd4; }
.copyright {
  text-align: center;
  font-size: 12px;
  color: #a9b3ab;
  padding: 8px 0 18px;
}

/* ---------- 底部导航 ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  background: #fff;
  display: flex;
  border-top: 1px solid #eee;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 0 7px;
  color: #9aa0a8;
  font-size: 12px;
  cursor: pointer;
  border: none;
  background: none;
  text-decoration: none;
}
.nav-item.active { color: #0aa35e; }
.nav-item svg { width: 24px; height: 24px; margin-bottom: 2px; fill: currentColor; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(0, 0, 0, .78);
  color: #fff;
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 300;
  max-width: 82%;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 查询结果 ---------- */
.rescard { background: #fff; border-radius: 16px; margin: 0 14px 14px; padding: 16px; }
.res-badge {
  display: inline-block;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}
.res-badge.db { background: #e8f8ef; color: #0aa35e; }
.res-badge.nodb { background: #fff7e8; color: #fa8c16; }
.res-code { font-size: 16px; font-weight: 700; word-break: break-all; color: #173526; }
.res-sub { font-size: 12px; color: #999; margin-top: 4px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-top: 14px; }
.kv__item { background: #f7f8fa; border-radius: 10px; padding: 10px 12px; }
.kv__item--wide { grid-column: 1 / -1; }
.kv__k { font-size: 12px; color: #999; margin-bottom: 4px; }
.kv__v { font-size: 14px; font-weight: 600; color: #333; word-break: break-all; }
.kv__v.accent { color: #0aa35e; }
.mrow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 2px;
  border-bottom: 1px solid #e3eae4;
  font-size: 14px;
}
.mrow:last-child { border-bottom: none; }
.mrow__k { color: #777; }
.mrow__v { font-weight: 600; color: #1d382b; }
.mrow__u { font-size: 12px; color: #999; margin-left: 3px; font-weight: 400; }
.bd-chain { display: flex; flex-wrap: wrap; gap: 3px; margin: 12px 0; }
.bd-cell {
  width: 19px; height: 26px;
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.bd-cell small { font-size: 8px; opacity: .8; margin-top: 2px; font-weight: 400; }
.bd-legend { display: flex; flex-direction: column; gap: 6px; }
.bd-row { display: flex; align-items: center; font-size: 12px; color: #666; }
.bd-swatch { width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; flex-shrink: 0; }
.bd-row b { color: #333; margin-right: 6px; }
.nodata { text-align: center; color: #999; font-size: 13px; padding: 14px 0; line-height: 1.8; }
.res-sec-title { font-size: 14px; font-weight: 700; color: #333; margin: 14px 0 8px; }

/* ---------- 列表卡片（历史 / 扫码记录） ---------- */
.list-count { text-align: center; font-size: 13px; color: #999; margin: -8px 0 16px; }
.rec-card { background: #fff; border-radius: 14px; margin: 0 14px 12px; padding: 14px 16px; }
.rec-code { font-size: 15px; font-weight: 700; color: #173526; word-break: break-all; line-height: 1.5; }
.rec-code .lbl { font-weight: 400; color: #555; }
.rec-line { font-size: 13px; color: #888; margin-top: 6px; }
.rec-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #e3eae4;
}
.rec-src {
  font-size: 12px;
  color: #0a8f57;
  background: #e2f4ea;
  padding: 3px 10px;
  border-radius: 6px;
}
.rec-time { font-size: 12px; color: #b0b5bd; }
.empty-tip { text-align: center; color: #9aa0a8; font-size: 14px; padding: 60px 0; }

/* ---------- 计算器 ---------- */
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.calc-cell { background: #ecf0ed; border-radius: 10px; padding: 10px 12px; }
.calc-cell .c-k { font-size: 12px; color: #888; margin-bottom: 5px; }
.calc-cell input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 15px;
  font-weight: 600;
  color: #1d382b;
  outline: none;
}
.calc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.calc-head .sec-title { margin-bottom: 0; }
.mini-select {
  border: none;
  background: #e2f4ea;
  color: #0a8f57;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  outline: none;
}

/* ---------- 表单（代码生成器） ---------- */
.form-label { font-size: 13px; color: #888; margin: 12px 0 6px; }
.form-row { display: flex; gap: 12px; align-items: stretch; }
.form-row .input-box { flex: 1; }
.form-row .btn { flex: 0 0 108px; }
.form-note {
  background: #fdf6d8;
  color: #7a8b1f;
  font-size: 13px;
  border-radius: 8px;
  padding: 9px 12px;
  margin-top: 12px;
  line-height: 1.6;
}
.gen-result {
  background: #f7f8fa;
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 14px;
}
.gen-code { font-size: 15px; font-weight: 700; word-break: break-all; color: #173526; line-height: 1.6; }
.gen-meta { font-size: 12px; color: #999; margin-top: 6px; line-height: 1.7; }

/* ========== 扫码取景（微信「扫一扫」风格） ========== */
.cscan {
  position: fixed; inset: 0; background: #000; z-index: 200;
  display: flex; flex-direction: column; align-items: center;
}
.cscan-tip {
  color: #e8f7ff; font-size: 14px; margin: 20px 16px 14px; text-align: center;
  letter-spacing: .5px; opacity: .92;
}
.cscan-stage {
  position: relative; width: 100%; max-width: 560px; flex: 1; min-height: 280px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.cscan-src, .cscan-src video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
/* 取景框：四周压暗、框中透明露出画面 */
.cscan-frame {
  position: absolute; z-index: 2;
  width: min(76vw, 258px); height: min(76vw, 258px);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .52);
  transition: box-shadow .18s ease;
}
/* 四角角标（微信那种白色圆角括号） */
.cscan-corner {
  position: absolute; width: 27px; height: 27px;
  border: 0 solid #7cf0a8;
}
.cscan-corner.tl { top: -2px; left: -2px; border-top-width: 4px; border-left-width: 4px; border-top-left-radius: 10px; }
.cscan-corner.tr { top: -2px; right: -2px; border-top-width: 4px; border-right-width: 4px; border-top-right-radius: 10px; }
.cscan-corner.bl { bottom: -2px; left: -2px; border-bottom-width: 4px; border-left-width: 4px; border-bottom-left-radius: 10px; }
.cscan-corner.br { bottom: -2px; right: -2px; border-bottom-width: 4px; border-right-width: 4px; border-bottom-right-radius: 10px; }
/* 扫描线：上下往复 */
.cscan-scanline {
  position: absolute; left: 5%; right: 5%; top: 10px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, #a7ffce, transparent);
  filter: drop-shadow(0 0 5px #7cf0a8);
  animation: cscanline 1.9s ease-in-out infinite;
}
@keyframes cscanline {
  0%   { top: 12px; }
  50%  { top: calc(100% - 14px); }
  100% { top: 12px; }
}
/* 识别成功：取景框整框变绿 */
.cscan-frame.is-ok {
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .5), 0 0 0 2.5px #2be06e, 0 0 26px rgba(43, 224, 110, .95);
}
.cscan-frame.is-ok .cscan-scanline { animation: none; top: auto; bottom: 12px; background: #2be06e; }
.cscan-frame.is-ok .cscan-corner { border-color: #2be06e; }
.cscan-close {
  margin: 22px 0; padding: 10px 30px; border: 0; border-radius: 24px;
  background: #fff; color: #16211c; font-size: 14px;
}
/* 取景框容器（识别内核是 Html5QrcodeScanner，外观为原「扫一扫」） */
.cscan-scanner-fix {
  position: relative;
  width: min(76vw, 280px); aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: 12px; overflow: hidden; background: #000;
}
.cscan-scanner-fix video { width: 100%; height: 100%; object-fit: cover; }
.cscan-scanner-fix select { display: none !important; }
.cscan-scanner-fix .cscan-corner { z-index: 3; }
.cscan-scanner-fix .cscan-scanline { z-index: 3; }
.cscan-scanner-fix.is-ok {
  box-shadow: 0 0 0 2.5px #2be06e, 0 0 26px rgba(43, 224, 110, .95);
}
.cscan-scanner-fix.is-ok .cscan-corner { border-color: #2be06e; }
/* --- Html5QrcodeScanner 适配：取景框沿用原有「扫一扫」样式 ---
   识别核心是 Scanner（保证能识别），但界面隐藏它自带的相机下拉、按钮、
   扫描结果提示等控件，让摄像头画面铺满取景框，外观与原来一致。 */
.cscan-src video {
  position: absolute; inset: 0;
  width: 100% !important; height: 100% !important; object-fit: cover;
}
.cscan-src select, .cscan-src input, .cscan-src button,
.cscan-src .html5-qrcode-element, .cscan-src .html5-qrcode-scanned {
  display: none !important;
}
/* --- 全屏取景：视频铺满屏幕(cover 保证不变形)，中央悬浮取景框四角+扫描线，遮暗四周 --- */
.cscan-stage {
  position: relative; width: 100%; flex: 1; min-height: 300px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.cscan-src, .cscan-src video {
  position: absolute; inset: 0; width: 100% !important; height: 100% !important; object-fit: cover;
}
.cscan-src select, .cscan-src button, .cscan-src input { display: none !important; }
#qr-shaded-region, .qr-canvas-visible, .html5-qrcode-canvas { display: none !important; }
.cscan-frame {
  position: absolute; width: min(78vw, 300px); height: min(78vw, 300px); z-index: 3;
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .6), 0 0 0 1px rgba(124, 240, 168, .2);
}
/* 识别成功：取景框整框变绿 + 扫描线定格收到底部 */
.cscan-frame.is-ok {
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55), 0 0 0 3px #2be06e, 0 0 40px rgba(43, 224, 110, 1);
}
.cscan-frame.is-ok .cscan-scanline { animation: none; top: auto; bottom: 12px; background: #2be06e; opacity: 1; }
.cscan-frame.is-ok .cscan-corner { border-color: #2be06e; }
