:root {
  --bg: #f2f4f7;
  --card: #fff;
  --line: #e2e7ee;
  --text: #1d2530;
  --muted: #6d7885;
  --brand: #1a6fd4;
  --brand-dark: #14559f;
  --ok: #128a4c;
  --ok-bg: #e6f6ec;
  --ng: #cf3535;
  --ng-bg: #fdeaea;
  --warn: #b8730d;
  --warn-bg: #fff6e5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 6px 16px rgba(16, 24, 40, .05);
}

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

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

a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, #1a6fd4, #14559f);
  color: #fff;
  padding: 12px 14px;
  box-shadow: 0 2px 10px rgba(20, 60, 120, .18);
}
.topbar .row1 { display: flex; align-items: center; gap: 10px; }
.topbar .title { font-size: 17px; font-weight: 600; }
.topbar .sub { font-size: 12px; opacity: .85; margin-top: 2px; }
.topbar .back {
  color: #fff;
  background: rgba(255, 255, 255, .16);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 13px;
  white-space: nowrap;
}
.topbar .spacer { flex: 1; }

.wrap { padding: 12px 12px 120px; max-width: 780px; margin: 0 auto; }
.wrap.narrow { max-width: 1180px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}
.card > h3 { font-size: 15px; margin-bottom: 10px; }

.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }
.info-grid > div { min-width: 0; }
.info-grid span { display: block; color: var(--muted); font-size: 12px; }
.info-grid b { font-weight: 600; font-size: 14px; word-break: break-all; }

.field { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.field:first-child { margin-top: 0; }
input[type="text"], input[type="date"], input[type="password"], input[type="search"],
input:not([type]), textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 15px;
  color: var(--text);
  background: #fff;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(26, 111, 212, .25); border-color: var(--brand); }
textarea { resize: vertical; }

.seg {
  display: inline-flex;
  background: #eef1f5;
  border-radius: 999px;
  padding: 3px;
  gap: 3px;
}
.seg button {
  border: 0;
  background: transparent;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
}
.seg button.active { background: #fff; color: var(--brand); font-weight: 600; box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }
.seg.judge button[data-status="ok"].active { background: var(--ok); color: #fff; }
.seg.judge button[data-status="ng"].active { background: var(--ng); color: #fff; }
.seg.judge button { padding: 6px 12px; font-size: 13px; }
.seg.small button { padding: 5px 12px; font-size: 13px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 9px 16px;
  border-radius: 9px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { border-color: #c9d3e0; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--ng); border-color: #f0c9c9; background: #fff; }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.row-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.row-line:last-child { margin-bottom: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chips a {
  padding: 6px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  color: var(--muted);
}
.chips a.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.line-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
  margin: 4px 2px 10px;
}
.line-title .bar { width: 4px; height: 14px; border-radius: 2px; background: var(--brand); }

.eq-list { display: grid; gap: 10px; }
.eq {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-radius: var(--radius);
  padding: 13px 14px;
  box-shadow: var(--shadow);
  color: var(--text);
  border: 1px solid transparent;
}
.eq:active { border-color: var(--brand); }
.eq-main { flex: 1; min-width: 0; }
.eq-name { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.eq-code { font-size: 11px; color: var(--muted); background: #f0f3f7; border-radius: 5px; padding: 1px 6px; font-weight: 400; }
.eq-meta { font-size: 12px; color: var(--muted); margin-top: 3px; word-break: break-all; }
.eq-status { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }

.pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #f0f3f7; color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.ng { background: var(--ng-bg); color: var(--ng); }
.pill.todo { background: #f0f3f7; color: #8a95a3; }

.progress-card { display: flex; align-items: center; gap: 12px; }
.bar-track { flex: 1; height: 8px; border-radius: 999px; background: #e6eaf0; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #1a6fd4, #34a853); border-radius: 999px; transition: width .3s; }

.alert { border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px; }
.alert.warn { background: var(--warn-bg); color: #8a5b04; border: 1px solid #f3ddb0; }
.alert.err { background: var(--ng-bg); color: #97231f; border: 1px solid #f4c9c9; }
.alert.info { background: #eaf2fd; color: #1a5ba8; border: 1px solid #cfe1f8; }
.hidden { display: none !important; }

.items { list-style: none; margin: 0; padding: 0; }
.item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; padding-bottom: 0; }
.item-top { display: flex; gap: 10px; align-items: flex-start; }
.num {
  flex: 0 0 24px;
  height: 24px;
  border-radius: 7px;
  background: #eef2f8;
  color: var(--brand);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.item-name { flex: 1; min-width: 0; font-size: 15px; font-weight: 500; }
.item-name .cycle {
  font-size: 11px;
  color: var(--muted);
  background: #f0f3f7;
  border-radius: 5px;
  padding: 1px 6px;
  margin-left: 6px;
  font-weight: 400;
}
.item-note { font-size: 12px; color: var(--muted); margin-top: 3px; white-space: pre-line; font-weight: 400; }
.item-extra { display: flex; gap: 8px; margin: 8px 0 0 34px; }
.item-extra input { font-size: 14px; padding: 7px 10px; }
.item.ng { background: linear-gradient(90deg, rgba(207, 53, 53, .05), transparent); }
.item.ng .num { background: var(--ng-bg); color: var(--ng); }
.item.ok .num { background: var(--ok-bg); color: var(--ok); }

/* ---------- 样件拍照留底 ---------- */
.photo-box {
  margin: 10px 0 2px 34px;
  padding: 10px 12px;
  border: 1px dashed #c3cddb;
  border-radius: 10px;
  background: #fafcff;
}
.photo-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.photo-title { font-size: 13px; font-weight: 600; color: var(--text); }
.photo-count { margin-left: auto; font-size: 12px; color: var(--muted); }
.photo-tag {
  font-size: 11px;
  color: var(--muted);
  background: #eef1f5;
  border-radius: 999px;
  padding: 1px 8px;
}
/* 多张照片网格 */
.photo-list { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.photo-list:empty { display: none; margin-bottom: 0; }
.photo-cell { position: relative; width: 92px; height: 92px; }
.photo-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  display: block;
}
.photo-badge {
  position: absolute;
  left: 4px;
  bottom: 4px;
  background: rgba(26, 111, 212, .92);
  color: #fff;
  font-size: 10px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 4px;
}
.photo-body { display: flex; align-items: center; gap: 10px; }
.photo-preview { position: relative; display: inline-block; }
.photo-preview img {
  display: block;
  width: 108px;
  height: 108px;
  object-fit: cover;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
}
.photo-del {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 0;
  background: var(--ng);
  color: #fff;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}
.photo-add {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border: 1px solid var(--brand);
  border-radius: 9px;
  background: #fff;
  color: var(--brand);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}
.photo-add:active { background: #eaf2fd; }
.photo-add-icon { font-size: 17px; }
.photo-tip { font-size: 12px; color: var(--muted); margin-top: 8px; }
.photo-tip.warn { color: var(--ng); }

/* 后台详情页照片相册 */
.photo-gallery { display: flex; flex-wrap: wrap; gap: 10px; }
.photo-gallery a { position: relative; display: block; }
.photo-gallery img {
  width: 150px;
  height: 150px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: block;
}
.photo-gallery .no {
  position: absolute;
  left: 5px;
  bottom: 5px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
@media (max-width: 560px) {
  .photo-gallery img { width: 104px; height: 104px; }
}

.sticky-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 30;
}
.sticky-bar .progress { font-size: 13px; color: var(--muted); flex: 1; }
.sticky-bar .progress b { color: var(--text); }
.sticky-bar .btn.primary { padding: 12px 26px; font-size: 16px; }

.modal { position: fixed; inset: 0; background: rgba(15, 23, 34, .45); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.modal-box { background: #fff; border-radius: 16px; padding: 24px; width: 100%; max-width: 360px; text-align: center; }
.ok-mark { width: 56px; height: 56px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); font-size: 30px; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; }
.ok-mark.ng { background: var(--ng-bg); color: var(--ng); }
.modal-box h2 { font-size: 18px; margin-bottom: 6px; }
.modal-box p { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* ---------- 后台 ---------- */
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h2 { font-size: 18px; }
.page-head .spacer { flex: 1; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.toolbar .f { display: flex; flex-direction: column; gap: 4px; }
.toolbar .f span { font-size: 12px; color: var(--muted); }
.toolbar input, .toolbar select { width: auto; min-width: 120px; }

table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.grid th { background: #f7f9fc; color: var(--muted); font-weight: 600; white-space: nowrap; }
table.grid tr:hover td { background: #fbfcfe; }
table.grid td.nowrap { white-space: nowrap; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: #f0f3f7; color: var(--muted); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.ng { background: var(--ng-bg); color: var(--ng); }

.dash { display: grid; gap: 10px; }
.dash-line { border-top: 1px dashed var(--line); padding-top: 10px; }
.dash-line:first-child { border-top: 0; padding-top: 0; }
.dash-eq { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 4px 0; font-size: 13px; }
.dash-eq .name { display: flex; gap: 8px; align-items: center; min-width: 0; }
.dash-eq .name span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 14px; font-size: 13px; color: var(--muted); }
.pager a, .pager span.cur { padding: 5px 12px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.pager span.cur { background: var(--brand); color: #fff; border-color: var(--brand); }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 18px; }
.kv div span { display: block; font-size: 12px; color: var(--muted); }

/* ---------- 点检内容编辑 ---------- */
table.grid.edit-grid td { padding: 6px 8px; vertical-align: middle; }
table.grid.edit-grid th { font-size: 12px; }
.edit-grid input, .edit-grid select {
  width: 100%;
  padding: 6px 8px;
  font-size: 13px;
  border-radius: 7px;
  min-width: 0;
}
.edit-grid .idx {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.edit-grid .cell-sample.muted input {
  background: #f4f6f9;
  color: #a9b3c0;
}
.edit-grid .ops { white-space: nowrap; }
.edit-grid .ops .btn { padding: 4px 8px; font-size: 12px; margin-right: 2px; }
.edit-grid .ops .btn:disabled { opacity: .35; }
.edit-grid tr.item-row:target { background: #fffbe6; }

/* ---------- 二维码打印 ---------- */
.qr-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.qr-sheet { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.qr-card {
  border: 1px dashed #b9c3d0;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  background: #fff;
  break-inside: avoid;
  page-break-inside: avoid;
}
.qr-card img { width: 100%; max-width: 190px; height: auto; }
.qr-card .n { font-size: 14px; font-weight: 600; margin-top: 4px; line-height: 1.3; }
.qr-card .m { font-size: 11px; color: var(--muted); }
.qr-card .c { font-size: 11px; color: #333; font-weight: 600; }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  .qr-sheet { gap: 6mm; }
  .qr-card { border: 1px solid #999; }
}

@media (max-width: 560px) {
  .info-grid { grid-template-columns: 1fr 1fr; }
  .wrap { padding: 10px 10px 110px; }
  .item-extra { flex-direction: column; }
  .qr-sheet { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  table.grid th:nth-child(3), table.grid td:nth-child(3) { display: none; }
}
