:root {
  --primary: #1565c0;
  --primary-dark: #0d47a1;
  --accent: #0097a7;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1f2d3d;
  --muted: #7a8aa0;
  --line: #e6ebf2;
  --danger: #e53935;
  --ok: #2e9e5b;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(20, 40, 80, 0.06);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
/* 数据汇总（PC / 大屏）时放宽宽度 */
body.wide #app { max-width: 1240px; }

.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 2px 12px rgba(21, 101, 192, 0.25);
}
.appbar-title { display: flex; align-items: baseline; gap: 8px; }
.brand { font-weight: 700; font-size: 18px; letter-spacing: 1px; }
.subtitle { font-size: 13px; opacity: 0.9; }
.icon-btn {
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
}
.icon-btn.active { background: #fff; color: var(--primary); border-color: #fff; font-weight: 600; }
.icon-btn[style*="none"] { display: none; }

/* ---------- 视图通用 ---------- */
.view { padding: 16px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 14px;
}
.section-head h2 { margin: 0; font-size: 18px; }
.text-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 15px;
  cursor: pointer;
  padding: 6px 4px;
  font-weight: 600;
}

/* ---------- 生产线列表 ---------- */
.line-list { display: flex; flex-direction: column; gap: 12px; }
.line-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.line-main { flex: 1; min-width: 0; }
.line-name { font-size: 17px; font-weight: 600; }
.line-meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.line-actions { display: flex; gap: 8px; }
.enter-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.mini {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.mini.danger { color: var(--danger); border-color: #f3c2c0; }
.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
  font-size: 15px;
}

/* ---------- 表单 ---------- */
.form-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.back-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 17px;
  cursor: pointer;
  padding: 4px 0;
}
.form-title { font-size: 18px; font-weight: 700; }
.form-body { display: flex; flex-direction: column; gap: 18px; padding-bottom: 24px; }

.field {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.field > label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
}
.field input[type="text"],
.field input[type="number"],
.field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 16px;
  background: #fff;
  color: var(--text);
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
}
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.hint b { color: var(--primary); }

/* 人员输入 */
.name-input-row { display: flex; gap: 8px; }
.name-input-row input { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip {
  background: #e8f1fb;
  color: var(--primary);
  border-radius: 16px;
  padding: 6px 10px 6px 14px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chip button {
  border: none;
  background: none;
  color: var(--primary);
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
}

/* 时长 */
.duration-row { display: flex; align-items: center; gap: 8px; }
.duration-row select { width: auto; flex: 1; }
.duration-row span { color: var(--muted); font-size: 15px; }

/* 子列表（问题 / 不良品） */
.sublist { display: flex; flex-direction: column; gap: 10px; }
.sub-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.sub-row select { flex: 0 0 90px; }
.sub-row input { flex: 1; }
.sub-row .del {
  flex: 0 0 auto;
  border: none;
  background: #fdecea;
  color: var(--danger);
  border-radius: 8px;
  width: 38px;
  height: 44px;
  font-size: 18px;
  cursor: pointer;
}
.add-sub {
  margin-top: 10px;
  width: 100%;
  border: 1px dashed var(--primary);
  background: #f5f9ff;
  color: var(--primary);
  border-radius: 10px;
  padding: 11px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
}
.defect-total { font-size: 13px; color: var(--muted); margin-top: 8px; }
.defect-total b { color: var(--danger); }

/* 按钮 */
.primary-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.primary-btn.small { padding: 12px 16px; }
.primary-btn.block { width: 100%; padding: 15px; font-size: 17px; margin-top: 4px; }
.primary-btn:active { background: var(--primary-dark); }

/* ---------- 记录明细列表（line detail） ---------- */
.rec-list { display: flex; flex-direction: column; gap: 12px; }
.rec-item {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.rec-main { flex: 1; min-width: 0; }
.rec-time { font-size: 15px; font-weight: 600; }
.rec-sub { font-size: 13px; color: var(--text); margin-top: 3px; }
.rec-tags { font-size: 12px; color: var(--muted); margin-top: 3px; }
.rec-actions { display: flex; flex-direction: column; gap: 8px; }

/* ---------- 数据汇总（PC / 大屏） ---------- */
.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.summary-head h2 { margin: 0; font-size: 22px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.kpi-val { font-size: 26px; font-weight: 700; color: var(--primary); }
.kpi-label { font-size: 13px; color: var(--muted); margin-top: 4px; }
.kpi.danger .kpi-val { color: var(--danger); }

.sum-cols {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.sum-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.sum-card h3 { margin: 0 0 12px; font-size: 16px; }

/* 横向条形 */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar-label { flex: 0 0 64px; font-size: 13px; color: var(--text); }
.bar-track { flex: 1; background: #eef2f7; border-radius: 6px; height: 18px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 6px; }
.bar-fill.alt { background: linear-gradient(90deg, #ef6c5b, #e53935); }
.bar-num { flex: 0 0 36px; text-align: right; font-size: 13px; font-weight: 600; color: var(--muted); }
.empty-sm { color: var(--muted); font-size: 14px; padding: 8px 0; }

/* 表格 */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.data-table th, .data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.data-table th { color: var(--muted); font-weight: 600; background: #fafbfd; position: sticky; top: 0; }
.data-table tbody tr:hover { background: #f7fafe; }

/* ---------- 底部导航 ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 720px;
  display: flex;
  background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 20;
}
body.wide .bottom-nav { max-width: 1240px; }
.nav-item {
  flex: 1;
  border: none;
  background: none;
  padding: 12px 0;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}
.nav-item.active { color: var(--primary); font-weight: 700; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 45, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}
.modal-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}
.modal-card h3 { margin: 0 0 14px; font-size: 17px; }
.modal-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 16px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

/* ---------- 占位 / Toast ---------- */
.placeholder {
  text-align: center;
  color: var(--muted);
  padding: 80px 16px;
  font-size: 15px;
}
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 30, 50, 0.92);
  color: #fff;
  padding: 12px 22px;
  border-radius: 24px;
  font-size: 15px;
  z-index: 60;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

/* ---------- 每日问题记录 ---------- */
.daily-list { display: flex; flex-direction: column; gap: 14px; }
.daily-group {
  background: #fafbfc;
  border-radius: 12px;
  padding: 12px 14px;
  border-left: 4px solid var(--primary);
}
.daily-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 8px;
}
.daily-count {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}
.daily-row {
  display: grid;
  grid-template-columns: 52px 110px 80px 1fr;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.daily-row:last-child { border-bottom: none; }
.daily-row .t { color: var(--muted); white-space: nowrap; }
.daily-row .line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.daily-row .cat {
  background: #eeeeee;
  color: var(--text);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
}
.daily-row .desc { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-sm { color: var(--muted); font-size: 14px; padding: 8px 0; }

/* ---------- 大屏适配 ---------- */
@media (min-width: 768px) {
  .sum-cols { grid-template-columns: 1fr 1fr; }
  .kpi-grid { grid-template-columns: repeat(6, 1fr); }
}

/* ---------- 时长分段切换 ---------- */
.seg {
  display: flex;
  background: #eef2f7;
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 12px;
}
.seg-btn {
  flex: 1;
  border: none;
  background: none;
  padding: 9px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}
.seg-btn.active {
  background: #fff;
  color: var(--primary);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.duration-range {
  display: flex;
  align-items: center;
  gap: 8px;
}
.duration-range input[type="time"] {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 16px;
  background: #fff;
  color: var(--text);
}
.duration-range input[type="time"]:focus { outline: none; border-color: var(--primary); }
.duration-range span { color: var(--muted); font-size: 15px; }

/* 合并后的问题行 */
.issue-row .def { color: var(--danger); font-weight: 600; }
.def {
  color: var(--danger);
  font-weight: 600;
}

/* ---------- 顶栏右侧：用户标识 / 按钮 ---------- */
.appbar-right { display: flex; align-items: center; gap: 8px; }
.user-chip {
  font-size: 13px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 16px;
  padding: 5px 12px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 登录浮层 ---------- */
.login-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.login-card {
  background: #fff;
  border-radius: 18px;
  padding: 32px 26px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-brand { font-size: 24px; font-weight: 800; color: var(--primary); text-align: center; letter-spacing: 2px; }
.login-sub { font-size: 14px; color: var(--muted); text-align: center; margin-bottom: 8px; }
.login-card input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 14px;
  font-size: 16px;
  background: #fff;
  color: var(--text);
}
.login-card input:focus { outline: none; border-color: var(--primary); }
.login-err { color: var(--danger); font-size: 13px; text-align: center; min-height: 16px; }

/* ---------- 账号管理 ---------- */
.ac-actions { display: flex; gap: 6px; flex-wrap: wrap; white-space: nowrap; }

/* ---------- 新增用户弹窗字段 ---------- */
.um-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-top: 12px;
  margin-bottom: 6px;
  color: var(--text);
}
.um-label:first-of-type { margin-top: 0; }
#userModal select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 16px;
  background: #fff;
  color: var(--text);
}
#userModal input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font-size: 16px;
  background: #fff;
  color: var(--text);
}
#userModal input:focus, #userModal select:focus { outline: none; border-color: var(--primary); }

/* ---------- 扫码浮层 ---------- */
.scan-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 25, 45, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 110;
  padding: 24px;
}
.scan-card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.scan-card h3 { margin: 0; font-size: 17px; color: var(--primary); }
.scan-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 320px;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}
.scan-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.scan-video.hidden { display: none; }
.scan-line {
  position: absolute;
  left: 0; right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 8px var(--accent);
  animation: scanmove 2s linear infinite;
}
@keyframes scanmove {
  0% { top: 4%; }
  50% { top: 92%; }
  100% { top: 4%; }
}
.scan-status {
  font-size: 14px;
  color: var(--text);
  text-align: center;
  min-height: 20px;
  line-height: 1.4;
}
