/* ============================================================
   设备使用记录助手 · 参考「远程控制 App」视觉风格
   蓝渐变顶栏 + 白色状态卡（运行中/指标列/浅蓝波纹规格带）
   + 控制面板式图标网格 + 底部 Tab
   桌面端将 #app 当成一台"手机"居中展示
   ============================================================ */

:root {
  --primary: #0a6cff;
  --primary-deep: #0a5fe0;
  --header-grad: linear-gradient(135deg, #3b8bff 0%, #0a5fe0 100%);
  --bg: #eef1f6;
  --card: #ffffff;
  --text-1: #1d2129;
  --text-2: #4e5969;
  --text-3: #9098a6;
  --line: #ebedf2;
  --line-soft: #f3f4f7;
  --soft-blue: #eaf1ff;
  --soft-blue-deep: #d8e6ff;
  --success: #22c55e;
  --warning: #ff8f1f;
  --danger: #ff4d4f;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 2px 14px rgba(16, 28, 54, .06);
  --shadow-press: 0 1px 3px rgba(16, 28, 54, .08);
  --nav-h: 52px;
  --tab-h: 58px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text-1);
  padding-bottom: 0;
  -webkit-user-select: none; user-select: none;
  -webkit-font-smoothing: antialiased;
}
input, textarea, select { -webkit-user-select: text; user-select: text; font-family: inherit; }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ============================================================
   手机框：桌面端居中成一台"手机"，移动端全宽
   ============================================================ */
#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ---------------- 顶部导航栏（蓝渐变） ---------------- */
#topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--nav-h);
  background: var(--header-grad);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 600; letter-spacing: .5px;
  box-shadow: 0 2px 12px rgba(10, 95, 224, .30);
}
#topbar-title { position: relative; display: flex; align-items: center; }
#btn-scan {
  position: absolute; right: 12px;
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255, 255, 255, .18); border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: #fff; line-height: 1;
  transition: background .15s ease, transform .12s ease;
}
#btn-scan:active { background: rgba(255, 255, 255, .32); transform: scale(.92); }
.scan-ico { line-height: 1; }
#btn-back {
  position: absolute; left: 10px; font-size: 16px; border: none; background: none;
  color: #fff; font-weight: 600; padding: 4px 6px;
}
.sync-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  margin-left: 8px; vertical-align: middle; background: #94a3b8; transition: all .3s;
}
.sync-dot.on { background: #4ade80; box-shadow: 0 0 6px rgba(74, 222, 128, .9); }
.sync-dot.off { background: rgba(255, 255, 255, .7); }

/* ---------------- 主容器 ---------------- */
#page-container {
  flex: 1 1 auto;
  padding: 14px 14px calc(var(--tab-h) + 16px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.section-title {
  font-size: 13px; font-weight: 600; color: var(--text-3);
  margin: 18px 4px 10px; letter-spacing: .3px;
}
.section-title:first-child { margin-top: 4px; }
.hint { font-size: 12px; color: var(--text-3); margin-top: 8px; padding: 0 2px; line-height: 1.6; }

/* ============================================================
   状态概览卡（仿远程控制 App 的"运行中"状态卡）
   ============================================================ */
.hero {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px;
}
.hero-top { display: flex; align-items: center; padding: 15px 16px 6px; }
.hero-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--success);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, .16); margin-right: 9px;
}
.hero-status { font-size: 15px; font-weight: 700; color: var(--text-1); }
.hero-chevron { margin-left: auto; color: #c5cad6; font-size: 20px; font-weight: 300; }
.hero-metrics { display: grid; grid-template-columns: repeat(2, 1fr); padding: 4px 6px 18px; }
.hero-metric { text-align: center; }
.hero-num {
  font-size: 27px; font-weight: 800; color: var(--primary);
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.hero-num.warn { color: var(--warning); }
.hero-label { font-size: 12px; color: var(--text-3); margin-top: 5px; }

/* ---------------- 卡片（白卡） ---------------- */
.card-list { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.card:active { transform: scale(.985); background: #f7f9fc; box-shadow: var(--shadow-press); }
.card .card-title { font-size: 16px; font-weight: 600; color: var(--text-1); }
.card .card-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; line-height: 1.5; }
.card .card-arrow { color: #c9cdd4; font-size: 20px; font-weight: 300; }
.card-ico {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; margin-right: 13px; flex-shrink: 0;
  background: var(--soft-blue); color: var(--primary);
}
.card-body { display: flex; align-items: center; flex: 1; min-width: 0; }

/* ---------------- 首页并排小栏（今日值班 / 已填编号） ---------------- */
.mini-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.mini-row.single { grid-template-columns: 1fr; }
.mini-card {
  display: flex; align-items: center; gap: 9px; min-width: 0;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 11px 12px; box-shadow: var(--shadow); cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.mini-card:active { transform: scale(.98); background: #f7f9fc; box-shadow: var(--shadow-press); }
.mini-card .mini-ico {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
  background: var(--soft-blue);
}
.mini-card.mini-specimen .mini-ico { background: #e8f8ee; }
.mini-txt { min-width: 0; flex: 1; }
.mini-label { font-size: 11px; color: var(--text-3); line-height: 1.4; }
.mini-value {
  font-size: 14px; font-weight: 700; color: var(--text-1); line-height: 1.5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mini-card.mini-duty .mini-value { color: var(--primary-deep); }
.mini-chev { flex-shrink: 0; font-size: 16px; color: #c9cdd4; line-height: 1; }
@media (hover: hover) { .mini-card:hover { border-color: #cfe0ff; } }

/* 批量填写：通栏一行 */
.quick-row {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow); margin-bottom: 14px; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.quick-row:active { transform: scale(.985); background: #f7f9fc; box-shadow: var(--shadow-press); }
.quick-row .quick-ico {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  background: var(--soft-blue);
}
.quick-txt { flex: 1; min-width: 0; }
.quick-row .quick-title { font-size: 14px; font-weight: 700; color: var(--text-1); }
.quick-row .quick-sub { font-size: 11px; color: var(--text-3); line-height: 1.5; }
.quick-chev { flex-shrink: 0; font-size: 17px; color: #c9cdd4; line-height: 1; }
@media (hover: hover) { .quick-row:hover { border-color: #cfe0ff; } }

/* ============================================================
   控制面板（记录类型网格，仿远程控制 App 的按钮面板）
   ============================================================ */
.panel {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 14px 16px; margin-bottom: 14px;
}
.panel-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 700; color: var(--text-1);
  padding: 2px 2px 12px;
}
.panel-ico { font-size: 16px; }
.panel-chev { margin-left: auto; color: var(--text-3); font-size: 18px; }

/* ---------------- 设置页：分类折叠面板（沿用填写页面板风格） ---------------- */
.set-panel { padding: 0; overflow: hidden; }
.set-panel > .panel-head {
  padding: 14px 15px; margin: 0; cursor: pointer;
  transition: background .12s ease;
}
.set-panel > .panel-head:active { background: #f7f9fc; }
.set-panel .panel-sub {
  margin-left: auto; font-size: 12px; font-weight: 400; color: var(--text-3);
  max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.set-panel .panel-sub + .panel-chev { margin-left: 8px; }
.set-panel .panel-chev {
  margin-left: auto; color: #c9cdd4; font-size: 16px; line-height: 1;
  transition: transform .18s ease;
}
.set-panel.open .panel-chev { transform: rotate(90deg); }
.set-panel .panel-body { display: none; padding: 0 15px 15px; }
.set-panel.open .panel-body { display: block; }
.set-panel .panel-body .form-group,
.set-panel .panel-body .about-box {
  background: transparent; border: none; box-shadow: none;
  padding: 0; margin-bottom: 12px;
}
.set-panel .panel-body .form-group:last-child,
.set-panel .panel-body .about-box:last-child { margin-bottom: 0; }
.set-panel.open > .panel-head { border-bottom: 1px solid var(--line-soft); margin-bottom: 12px; }
#page-settings .btn-primary { margin-top: 4px; }
#page-settings #today-duty.duty-today {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--soft-blue); border: 1px solid #cfe0ff; border-radius: 20px;
  padding: 2px 10px; margin: 5px 0 0; font-size: 13px; line-height: 1.7;
}
#page-settings #set-device-order > div:last-child { border-bottom: none; }
#page-settings #set-templates > div:last-child { border-bottom: none; }

#type-list.card-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
#type-list .card {
  background: #f4f6fa; border: 1px solid #eef1f6; border-radius: 16px;
  flex-direction: column; align-items: center; text-align: center; padding: 18px 12px;
  box-shadow: none;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
#type-list .card:active { transform: scale(.97); background: #eef2f8; }
#type-list .card .card-body { flex-direction: column; align-items: center; gap: 0; }
#type-list .card .card-ico {
  width: 48px; height: 48px; border-radius: 14px; font-size: 24px;
  margin: 0 0 10px; background: #fff; color: var(--primary);
  box-shadow: 0 2px 6px rgba(16, 28, 54, .06);
}
#type-list .card .card-title { font-size: 15px; }
#type-list .card .card-sub { font-size: 12px; }
#type-list .card .card-arrow { display: none; }

/* ---------------- 表单 ---------------- */
.form-group {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 8px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 12px; font-size: 16px; outline: none; background: #fff; color: var(--text-1);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus,
#stats-sample-input:focus, #history-search:focus {
  border-color: var(--primary); background: #fff;
  box-shadow: 0 0 0 3px rgba(10, 108, 255, .14); outline: none;
}

/* ---------------- 按钮 ---------------- */
.btn-primary {
  width: 100%; padding: 14px; border: none; border-radius: var(--radius);
  background: var(--primary); color: #fff; font-size: 16px; font-weight: 600;
  margin-top: 6px;
  box-shadow: 0 4px 14px rgba(10, 108, 255, .30);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn-primary:active { transform: translateY(1px); filter: brightness(.96); box-shadow: 0 2px 7px rgba(10, 108, 255, .26); }
.btn-secondary {
  width: 100%; padding: 13px; border: 1px solid var(--primary); border-radius: var(--radius);
  background: #fff; color: var(--primary); font-size: 15px; font-weight: 600;
  margin-top: 10px; transition: background .12s ease;
}
.btn-secondary:active { background: var(--soft-blue); }
.btn-danger {
  width: 100%; padding: 13px; border: 1px solid #ffccc7; border-radius: var(--radius);
  background: #fff; color: var(--danger); font-size: 15px; font-weight: 600;
  margin-top: 10px; transition: background .12s ease;
}
.btn-danger:active { background: #fff4f4; }
.btn-small {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 6px 14px; font-size: 15px; color: var(--text-2); transition: background .12s ease;
}
.btn-small:active { background: #f2f3f5; }
.btn-export {
  width: 100%; padding: 12px; border: 1px solid var(--primary); border-radius: var(--radius-sm);
  background: #fff; color: var(--primary); font-size: 15px; font-weight: 500;
  margin-bottom: 10px; transition: background .12s ease;
}
.btn-export:active { background: var(--soft-blue); }

/* ---------------- 底部导航 ---------------- */
#tabbar {
  position: sticky; bottom: 0; z-index: 30;
  background: #fff; border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -1px 0 rgba(0, 0, 0, .02);
}
.tab-btn {
  flex: 1; border: none; background: none; padding: 7px 0 8px;
  font-size: 12px; color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  position: relative; transition: color .15s ease;
}
.tab-btn::before {
  content: ""; width: 24px; height: 24px; margin-bottom: 2px;
  -webkit-mask-position: center; mask-position: center;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-size: contain; mask-size: contain;
  background: #9098a6; transition: background .15s ease;
}
.tab-btn[data-tab="fill"]::before {
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 013 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>');
  mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.12 2.12 0 013 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>');
}
.tab-btn[data-tab="stats"]::before {
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round"><line x1="4" y1="20" x2="4" y2="11"/><line x1="10" y1="20" x2="10" y2="4"/><line x1="16" y1="20" x2="16" y2="14"/><line x1="21" y1="20" x2="2" y2="20"/></svg>');
  mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round"><line x1="4" y1="20" x2="4" y2="11"/><line x1="10" y1="20" x2="10" y2="4"/><line x1="16" y1="20" x2="16" y2="14"/><line x1="21" y1="20" x2="2" y2="20"/></svg>');
}
.tab-btn[data-tab="history"]::before {
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg>');
  mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg>');
}
.tab-btn[data-tab="settings"]::before {
  -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round"><line x1="4" y1="6" x2="20" y2="6"/><circle cx="9" cy="6" r="2.5"/><line x1="4" y1="12" x2="20" y2="12"/><circle cx="15" cy="12" r="2.5"/><line x1="4" y1="18" x2="20" y2="18"/><circle cx="7" cy="18" r="2.5"/></svg>');
  mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round"><line x1="4" y1="6" x2="20" y2="6"/><circle cx="9" cy="6" r="2.5"/><line x1="4" y1="12" x2="20" y2="12"/><circle cx="15" cy="12" r="2.5"/><line x1="4" y1="18" x2="20" y2="18"/><circle cx="7" cy="18" r="2.5"/></svg>');
}
.tab-btn.active { color: var(--primary); font-weight: 600; }
.tab-btn.active::before { background: var(--primary); }

/* ---------------- 历史记录 ---------------- */
#history-month-nav, #stats-month-nav {
  display: flex; align-items: center; gap: 12px; justify-content: center; margin: 4px 0 14px;
}
#history-month-label, #stats-month-label { font-size: 16px; font-weight: 700; min-width: 110px; text-align: center; }
#history-month-nav button, #stats-month-nav button {
  width: 38px; height: 38px; border-radius: 50%; background: #fff;
  border: 1px solid var(--line); color: var(--text-1); font-size: 16px;
  box-shadow: var(--shadow); transition: background .12s ease;
}
#history-month-nav button:active, #stats-month-nav button:active { background: var(--soft-blue); }

.record-group {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden;
}
.record-group .group-title {
  font-size: 14px; color: var(--text-1); font-weight: 600;
  background: #fafbfc; border-bottom: 1px solid var(--line-soft);
  padding: 12px 14px; margin: 0;
  display: flex; align-items: center; gap: 6px;
}
.record-group .group-title .g-arrow { color: var(--primary); font-size: 12px; }
.record-group .group-title .g-count { color: var(--text-3); font-weight: 400; font-size: 12px; margin-left: auto; }
.group-body { padding: 4px 10px 6px; }
.group-table { margin: 8px 0 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.group-table table { margin: 0 auto; }
.group-table .print-doc { padding: 8px; }
.group-actions { display: flex; gap: 8px; padding: 8px 0 12px; }
.group-actions .btn-export { margin-bottom: 0; }

.record-item {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center; font-size: 13px;
  box-shadow: var(--shadow-press);
}
.record-item .rec-main { flex: 1; line-height: 1.6; }
.record-actions { display: flex; gap: 8px; flex-shrink: 0; }
.rec-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  font-size: 12px; padding: 5px 11px; color: var(--text-2);
}
.rec-btn.edit { color: var(--primary); border-color: transparent; background: var(--soft-blue); }
.rec-btn.del { color: var(--danger); border-color: transparent; background: #fff1f1; }
.empty-tip { color: var(--text-3); font-size: 14px; text-align: center; padding: 30px 0; }
.empty-tip::before { content: "🗂"; display: block; font-size: 38px; margin-bottom: 8px; opacity: .5; }

/* ---------------- 运行记录定时点 ---------------- */
.timepoint-item {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px;
  box-shadow: var(--shadow-press);
  display: flex; justify-content: space-between; align-items: center;
}
.timepoint-item .tp-label { font-size: 14px; font-weight: 500; }
.tp-status-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  font-size: 14px; padding: 6px 16px; font-weight: 600; color: var(--text-2);
  transition: all .12s ease;
}
.tp-status-btn.ok { border-color: var(--success); color: var(--success); background: #f0fff4; }
.tp-status-btn.bad { border-color: var(--danger); color: var(--danger); background: #fff4f4; }

/* ---------------- 今日值班 ---------------- */
#fill-today { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; margin-bottom: 14px; }
#fill-today > * { margin-bottom: 0 !important; }
.duty-today {
  display: flex; align-items: center; gap: 8px;
  background: var(--soft-blue); border: 1px solid #cfe0ff;
  border-radius: var(--radius); padding: 12px 14px; font-size: 14px; color: var(--primary-deep);
}

/* ---------------- 设备运行状态徽章 ---------------- */
.state-badge { font-size: 12px; padding: 6px 10px; border-radius: 6px; margin-bottom: 8px; }
.state-badge.running { background: #fff1f0; border: 1px solid #ffccc7; color: #cf1322; }
.state-badge.idle { background: var(--line-soft); border: 1px solid var(--line); color: var(--text-2); }

/* ---------------- 关于 / 模板管理 ---------------- */
.about-box {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 16px; font-size: 13px;
  color: var(--text-2); line-height: 1.9; box-shadow: var(--shadow);
}
#storage-info { color: var(--text-3); font-size: 12px; }
#storage-info.storage-warn { color: var(--warning); font-weight: 600; }
#set-templates > div { padding: 12px 4px; border-bottom: 1px solid var(--line-soft); }
#set-templates > div:last-child { border-bottom: none; }
#btn-add-template {
  width: 100%; padding: 15px; background: var(--soft-blue); color: var(--primary);
  border: 1.5px dashed #9cc1ff; border-radius: var(--radius); font-weight: 600;
  margin-bottom: 12px; transition: background .12s ease;
}
#btn-add-template:active { background: #dce8ff; }

/* ---------------- 统计 / 样品追踪 ---------------- */
#stats-equip > div, #stats-env > div, #stats-sample-search {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 12px;
}
#stats-equip > div > div:first-child, #stats-env > div > div:first-child {
  font-size: 15px; font-weight: 600; color: var(--text-1); margin-bottom: 12px;
}
#stats-equip div[style*="background:#f2f3f5"],
#stats-equip div[style*="background:#eef3ff"] {
  background: #eef3ff !important; border-radius: 8px !important; height: 16px !important;
}
#stats-equip div[style*="background:#3370ff"] {
  background: linear-gradient(90deg, #4a8bff, var(--primary)) !important;
  border-radius: 8px !important; transition: width .6s ease;
}
#stats-equip b, #stats-env b { color: var(--primary); font-size: 15px; }
#stats-sample-search { padding: 14px 16px; }
#stats-sample-input {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 13px 15px; font-size: 16px; width: 100%; outline: none; color: var(--text-1);
  transition: border-color .15s, box-shadow .15s;
}
#stats-sample-input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(10, 108, 255, .14);
}
#stats-sample-result { display: block; margin-top: 4px; }
.sample-row {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; margin-bottom: 8px; font-size: 13px; background: #fff; box-shadow: var(--shadow-press);
}
.sample-chip { color: var(--primary); text-decoration: underline; margin-right: 5px; }

/* ---------------- 试样编号：弹窗列表 + 编号详情 ---------------- */
.specimen-item {
  display: flex; align-items: center; gap: 12px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 10px; cursor: pointer;
  box-shadow: var(--shadow-press);
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.specimen-item:active { transform: scale(.99); background: #f7f9fc; border-color: #cfe0ff; }
.specimen-item .specimen-badge {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: var(--soft-blue);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.specimen-item .specimen-main { flex: 1; min-width: 0; }
.specimen-item .specimen-no {
  font-size: 16px; font-weight: 700; color: var(--text-1);
  font-variant-numeric: tabular-nums; letter-spacing: .3px;
}
.specimen-item .specimen-meta { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.specimen-item .specimen-side { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.specimen-count {
  background: var(--soft-blue); color: var(--primary); font-size: 12px; font-weight: 600;
  border-radius: 20px; padding: 3px 10px; font-variant-numeric: tabular-nums;
}
.specimen-arrow { color: #c9cdd4; font-size: 18px; }

/* 已填编号：按月折叠分组 */
.sp-group { margin-bottom: 10px; }
.sp-group-head {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 13px; cursor: pointer; box-shadow: var(--shadow-press);
  transition: background .12s ease, border-color .12s ease;
}
.sp-group-head:active { background: #f7f9fc; border-color: #cfe0ff; }
.sp-group-head .sp-folder { font-size: 15px; line-height: 1; }
.sp-group-head .sp-month { font-size: 14px; font-weight: 700; color: var(--text-1); }
.sp-group-head .sp-count {
  font-size: 11px; color: var(--text-3); background: var(--line-soft);
  border-radius: 20px; padding: 2px 8px; font-variant-numeric: tabular-nums;
}
.sp-group-head .sp-caret {
  margin-left: auto; color: #c9cdd4; font-size: 16px; line-height: 1;
  transition: transform .18s ease;
}
.sp-group.open .sp-caret { transform: rotate(90deg); }
.sp-group-body { display: none; padding-top: 10px; }
.sp-group.open .sp-group-body { display: block; }
.sp-group.open .sp-group-head { border-color: #cfe0ff; }
.specimen-record .sr-tag {
  font-size: 10px; font-weight: 600; color: var(--primary);
  background: var(--soft-blue); border-radius: 4px; padding: 1px 5px;
}

/* ---------------- 值班表（点首页「今日值班」打开） ---------------- */
.modal-sub { font-size: 12px; font-weight: 400; color: var(--text-3); margin-left: 6px; }
.duty-row {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 11px 14px; margin-bottom: 8px;
}
.duty-row.on { background: var(--soft-blue); border-color: #cfe0ff; }
.duty-row .duty-date {
  font-size: 14px; color: var(--text-1); font-variant-numeric: tabular-nums;
  display: flex; align-items: center; gap: 8px;
}
.duty-row .duty-wk { font-size: 12px; color: var(--text-3); }
.duty-row .duty-tag {
  font-size: 11px; font-weight: 600; color: #fff; background: var(--primary);
  border-radius: 20px; padding: 2px 8px;
}
.duty-row .duty-person { font-size: 14px; font-weight: 700; color: var(--primary-deep); }
.duty-row.on .duty-person { color: var(--primary); }

.specimen-record {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow-press);
}
.specimen-record .sr-top { display: flex; align-items: baseline; gap: 8px; }
.specimen-record .sr-dev { font-size: 14px; font-weight: 600; color: var(--text-1); }
.specimen-record .sr-date { font-size: 12px; color: var(--text-3); margin-left: auto; font-variant-numeric: tabular-nums; }
.specimen-record .sr-body { font-size: 12.5px; color: var(--text-2); line-height: 1.75; margin-top: 6px; }
.specimen-record .sr-body span { display: block; }
.specimen-record .sr-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* ---------------- 设备 / 批量列表：一行一台，等高对齐 ---------------- */
.equip-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 6px 4px 10px;
}
.equip-head .section-title { margin: 0; }
.equip-count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }

#equipment-list, #batch-list { display: flex; flex-direction: column; gap: 10px; }
.equip-row {
  display: flex; align-items: center; gap: 11px;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  padding: 11px 12px; box-shadow: var(--shadow); cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
}
.equip-row:active { transform: scale(.99); background: #f7f9fc; box-shadow: var(--shadow-press); }
@media (hover: hover) { .equip-row:hover { border-color: #cfe0ff; } }
.equip-ico {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; line-height: 1;
  background: var(--soft-blue);
}
.equip-ico.t-run_log { background: #e8f8ee; }
.equip-ico.t-aging_test { background: #fff0ef; }
.equip-ico.t-env_monitor { background: #fff3e6; }
.equip-ico.t-sample_prep { background: #f2ecfe; }
.equip-ico.ok { background: #e9f9ef; color: #12a150; font-size: 15px; font-weight: 700; }
.equip-txt { flex: 1; min-width: 0; }
.equip-name {
  font-size: 15px; font-weight: 600; color: var(--text-1); line-height: 1.35;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.equip-meta {
  font-size: 11.5px; color: var(--text-3); line-height: 1.45; margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.equip-meta.none { color: #f0a03c; }
.equip-acts { display: flex; gap: 6px; flex: none; }
.equip-btn {
  height: 30px; padding: 0 11px; border-radius: 9px;
  font-size: 12.5px; font-weight: 500; line-height: 1;
  background: #fff; color: var(--text-2); border: 1px solid var(--line);
  transition: background .12s ease, border-color .12s ease;
}
.equip-btn.fill { background: #eef4ff; color: #2b6ae0; border-color: #d6e4ff; }
.equip-btn:active { background: #eef2f8; }
.equip-btn.fill:active { background: #e2ecff; }
.equip-tag {
  flex: none; font-size: 11.5px; line-height: 1; padding: 6px 9px; border-radius: 20px;
  color: var(--text-3); background: #f4f6fa;
}
.equip-tag.ok { color: #12a150; background: #e9f9ef; }
.equip-chev { flex: none; font-size: 18px; font-weight: 300; color: #c9cdd4; line-height: 1; }
.equip-row.done { background: #fbfdfc; border-color: #e3f1e9; }

#batch-list .equip-row.done .equip-name { color: var(--text-2); }

/* ---------------- 环境监控温湿度 ---------------- */
.env-temp, .env-hum { font-variant-numeric: tabular-nums; }

/* ---------------- 打印视图 ---------------- */
#print-area { display: none; }

/* ============================================================
   模态弹层
   ============================================================ */
.modal-mask { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.5); z-index: 100; }
.modal {
  position: fixed; top: 6%; left: 50%; transform: translateX(-50%);
  width: calc(100% - 32px); max-width: 398px; max-height: 88%;
  background: #fff; z-index: 101; border-radius: 18px;
  box-shadow: 0 12px 40px rgba(20,40,90,.22); display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  font-weight: 600; font-size: 15px; color: var(--text-1);
}
.modal-head > span {
  flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.modal-head .btn-small { flex: none; white-space: nowrap; }
.modal-body { flex: 1; overflow: auto; padding: 16px; -webkit-overflow-scrolling: touch; background: #fbfcfe; }

/* 预览弹窗: 按 A4 原版式（794px = 210mm）渲染，再整页等比缩放到弹窗宽度
   —— 只缩放不重排: 列宽比例、字体、行高、合并格都与文件一致 */
#preview-body { padding: 12px; }
#pv-stage { overflow: hidden; }
#pv-page { width: 794px; transform-origin: top left; }
#pv-page .print-doc {
  background: #fff; border: 1px solid #e6eaf2; border-radius: 8px;
  box-shadow: 0 2px 12px rgba(20, 40, 90, .07);
}
/* 预览里的表格结构与字号由模板 docx 决定（列宽/合并/行高/字号均取自文件），
   这里只做视觉容器，不覆盖任何尺寸，避免与文件版式打架 */
#pv-page .print-doc { box-sizing: border-box; }
/* 运行记录超容量提示 */
.tbl-note {
  font-size: 11px; line-height: 1.5; color: #cf1322;
  background: #fff1f0; border: 1px solid #ffa39e; border-radius: 6px;
  padding: 6px 8px; margin: 4px 0 6px;
}
/* 编辑页: 空行保持文件里的行高，否则空行挤成一片细线，看起来不像纸质表格 */
#edit-table-wrap .print-doc table td { height: 20px; }
#edit-table-wrap .print-doc table th { height: 22px; }

/* 1:1 原尺寸: 不缩放, 页内左右查看 */
#preview-body.raw #pv-stage { overflow-x: auto; overflow-y: hidden; }
/* 预览打开时隐藏下方页面内容, 避免遮罩下半透明地透出编辑页表格（看着像重复渲染） */
body.preview-open #page-container { visibility: hidden; }

#edit-tpl-modal .form-group, #confirm-modal .form-group { box-shadow: none; }
#et-required { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 10px; }
#et-required label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 400; color: var(--text-1); margin: 0; cursor: pointer; }
#et-required input { width: auto; }

/* 模板必填字段：胶囊式选择 + 自己添加 */
#et-required .et-chip {
  background: #f4f6fa; border: 1px solid var(--line); border-radius: 20px;
  padding: 6px 12px; font-size: 13px; color: var(--text-2);
  transition: background .12s ease, border-color .12s ease, color .12s ease;
  user-select: none; -webkit-user-select: none;
}
#et-required .et-chip input { display: none; }
#et-required .et-chip.on {
  background: var(--soft-blue); border-color: #cfe0ff; color: var(--primary); font-weight: 600;
}
#et-required .et-chip .et-chip-x {
  width: 16px; height: 16px; border-radius: 50%; background: #e5e8ef; color: #7a8496;
  font-size: 12px; line-height: 16px; text-align: center; padding: 0;
}
#et-required .et-chip.on .et-chip-x { background: #cddffb; color: var(--primary); }
.et-add-row { display: flex; gap: 8px; align-items: center; }
.et-add-row input {
  flex: 1; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 11px; font-size: 15px; outline: none; background: #fff; color: var(--text-1);
}
.et-add-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(10, 108, 255, .14); }
.et-add-row .btn-secondary { width: auto; flex-shrink: 0; padding: 9px 14px; font-size: 14px; }
.req-star { color: var(--danger); font-weight: 700; }

#scan-modal .modal-box {
  background: #fff; border-radius: 18px; padding: 20px 18px;
  width: min(86vw, 340px); margin: 15vh auto 0; box-shadow: 0 12px 40px rgba(20,40,90,.22);
}
#scan-qr { display: flex; justify-content: center; margin: 6px 0; }
#scan-qr img, #scan-qr canvas { width: 200px !important; height: 200px !important; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 24px); transform: translateX(-50%);
  background: rgba(20, 24, 32, .88); color: #fff; border-radius: 22px;
  padding: 11px 20px; font-size: 13px; z-index: 200; max-width: 88%;
  text-align: center; line-height: 1.6; box-shadow: 0 6px 24px rgba(0,0,0,.25);
}

/* ============================================================
   屏幕上的表格视图（编辑页 / 预览弹窗 / 历史页展开）
   去掉 A4 打印留白(20mm 12mm)，让表格按屏幕宽度铺满，手机上无需左右拖拽
   ============================================================ */
@media screen {
  #edit-table-wrap .print-doc { padding: 0 0 10px !important; }
  #edit-table-wrap .print-table-wrap { overflow: visible; }
  #edit-table-wrap table { max-width: 100%; }
  #edit-table-wrap td { word-break: break-word; }
}

/* ============================================================
   打印规则
   ============================================================ */
@media print {
  body { background: #fff; padding: 0; }
  #topbar, #tabbar, #page-container, #print-area, .modal, .modal-mask, #toast { display: none !important; }
  #print-area { display: block !important; }
  /* 纸面边距由 @page margin 提供, 文档容器不再叠加内边距 */
  .print-doc { width: 100%; padding: 0 !important; box-shadow: none !important; border: 0 !important; }
  .print-doc table { border-collapse: collapse; width: 100% !important; }
  .print-doc tr { page-break-inside: avoid; }
  .print-doc th, .print-doc td { border: 1px solid #000 !important; }
  .print-table-wrap.page-break { page-break-before: always; }
}

/* ============================================================
   宽屏（平板 / 电脑）: 弹窗更宽，A4 页面尽量 1:1 显示（不缩放）
   ============================================================ */
@media (min-width: 760px) {
  #preview-body { padding: 18px; }
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cfd6e0; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #b8c1cf; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================
   桌面端：把 #app 当成一台手机居中展示
   ============================================================ */
@media (min-width: 480px) {
  body {
    height: 100vh; overflow: hidden;
    background: #e3e7ee;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
  }
  #app {
    width: 430px; max-width: 430px; height: 100vh; max-height: 920px;
    border-radius: 30px; overflow: hidden; transform: translateZ(0);
    box-shadow: 0 24px 70px rgba(15,23,42,.28), 0 0 0 1px rgba(0,0,0,.06);
  }
  #topbar { position: relative; }
  #page-container { padding-bottom: 16px; }
  #tabbar { position: relative; }
  /* 预览: 临时跳出手机壳（去掉 #app 的 transform），让弹窗按 A4 版式居中于整屏 */
  body.preview-open #app { transform: none; }
  body.preview-open #preview-modal {
    top: 3vh; left: 50%; transform: translateX(-50%);
    width: 94vw; max-width: 920px; max-height: 94vh;
  }
  @media (hover: hover) {
    .card:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(10,108,255,.10); }
    #history-list .record-group:hover { box-shadow: 0 6px 20px rgba(20,24,40,.08); }
  }
}

@media (max-width: 380px) {
  /* 小屏让出一点宽度给设备名，避免"可程序恒温恒湿试验机"这类长名被截断 */
  .equip-row { padding: 11px 11px; }
  .equip-btn { padding: 0 9px; font-size: 12px; }
  .equip-name { font-size: 14px; }
  .equip-ico { width: 34px; height: 34px; border-radius: 10px; font-size: 16px; }
}

@media (max-width: 360px) {
  #type-list.card-list { grid-template-columns: 1fr; }
  #fill-today { grid-template-columns: 1fr; }
}

/* ============================================================
   设备关联（老化方式 ↔ 后续设备）
   清爽浅色：白卡 + 浅蓝提示条，不用深色/发光
   ============================================================ */
.label-note { font-weight: 400; font-size: 12px; color: var(--text-3); }

/* 老化方式：分段选择 */
.seg-row { display: flex; gap: 8px; }
.seg-btn {
  flex: 1; min-width: 0; padding: 11px 6px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #f7f9fc; color: var(--text-2);
  font-size: 15px; font-weight: 500;
  transition: background .12s ease, border-color .12s ease;
}
.seg-btn.active {
  background: var(--soft-blue); border-color: #9dc0ff;
  color: var(--primary-deep); font-weight: 600;
}
.seg-btn:active { transform: scale(.985); }

/* 表单里的关联提示 */
.assoc-hint {
  background: #f5f9ff; border: 1px solid #dbe8ff; border-radius: 12px;
  padding: 10px 12px; margin: -4px 0 14px;
  font-size: 12.5px; line-height: 1.7; color: var(--text-2);
}
.assoc-hint-head { font-weight: 600; color: var(--primary-deep); margin-bottom: 5px; }
.assoc-hint-step { display: flex; gap: 6px; margin-top: 2px; }
.assoc-hint-no {
  flex: none; width: 16px; height: 16px; margin-top: 3px;
  border-radius: 50%; background: var(--soft-blue-deep); color: var(--primary-deep);
  font-size: 11px; line-height: 16px; text-align: center;
}
.assoc-hint-foot { margin-top: 6px; font-size: 11.5px; color: var(--text-3); }

/* 首页「关联待办」 */
.panel.assoc-panel { padding-bottom: 2px; }
.assoc-count {
  margin-left: auto; font-size: 12px; font-weight: 500; color: var(--primary);
  background: var(--soft-blue); padding: 2px 9px; border-radius: 9px;
}
.assoc-list { padding: 0; }
.assoc-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--line-soft);
}
.assoc-item:first-child { border-top: none; }
.assoc-item:active { background: #f7f9fc; }
.assoc-ico {
  flex: none; width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
  background: #eef4ff;
}
.assoc-ico.is-test { background: #eefaf1; }
.assoc-main { flex: 1; min-width: 0; }
.assoc-title {
  font-size: 14px; font-weight: 600; color: var(--text-1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.assoc-sub {
  font-size: 12px; color: var(--text-2); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.assoc-when { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.assoc-go {
  flex: none; font-size: 12px; color: var(--primary);
  background: var(--soft-blue); padding: 6px 10px; border-radius: 8px;
}

/* 设置页：关联规则行 */
.assoc-rule {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px;
}
.assoc-rule-name { font-size: 14px; font-weight: 600; color: var(--text-1); margin-bottom: 6px; }
.assoc-rule-idx {
  flex: none; width: 20px; height: 20px; border-radius: 50%;
  background: #eef1f6; color: var(--text-2); font-size: 12px; line-height: 20px; text-align: center;
}
