:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
}

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

/* 确保 hidden 属性始终生效（避免被 display:flex/grid 等覆盖，例如大图预览层） */
[hidden] { display: none !important; }

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar h1 {
  flex: 1;
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}
.back-btn {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
}
.net-badge { font-size: 12px; color: #16a34a; }
.net-badge.off { color: #9ca3af; }

.container { max-width: 960px; margin: 0 auto; padding: 16px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 { font-size: 15px; margin: 0 0 12px; color: var(--muted); font-weight: 600; }

label { display: block; margin-bottom: 12px; font-size: 14px; color: var(--text); }
label input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  background: #fff;
}
label input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.required { color: var(--danger); }
.optional { color: var(--muted); font-weight: 400; }

.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: filter .15s;
}
.btn:active { filter: brightness(.95); }
.btn.primary { background: var(--primary); color: #fff; width: 100%; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; color: var(--primary); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { padding: 7px 12px; font-size: 13px; width: auto; }

.form-msg { font-size: 13px; margin: 8px 0 0; min-height: 18px; }
.form-msg.err { color: var(--danger); }
.form-msg.ok { color: #16a34a; }

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: var(--muted);
  margin: 8px 2px 12px;
  font-weight: 600;
}
.head-actions { display: flex; gap: 8px; }

.search-bar {
  display: flex;
  gap: 8px;
  margin: 6px 2px 12px;
}
.search-bar input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: #fff;
}
.search-bar input:focus { outline: 2px solid var(--primary); border-color: transparent; }

.product-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.product-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 13px 14px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color .15s, transform .1s;
}
.product-row:active { transform: scale(.99); }
.product-row:hover { border-color: var(--primary); }
.product-row .pr-main { min-width: 0; flex: 1; }
.product-row .pr-no { font-weight: 700; font-size: 15px; word-break: break-all; }
.product-row .pr-proj { color: var(--muted); font-size: 12px; margin-top: 3px; word-break: break-all; }
.product-row .pr-count {
  flex-shrink: 0;
  margin-left: 10px;
  font-size: 12px;
  color: var(--primary);
  background: #eff6ff;
  padding: 4px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

..empty-hint { text-align: center; color: var(--muted); padding: 30px 0; font-size: 14px; grid-column: 1 / -1; }

/* 紧凑网格视图（默认）：小卡片，一行可放更多，更省空间 */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
}
.product-card {
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 10px;
  cursor: pointer;
  text-align: center;
  border: 1px solid transparent;
  transition: border-color .15s, transform .1s;
}
.product-card:active { transform: scale(.97); }
.product-card:hover { border-color: var(--primary); }
.product-card .pc-no { font-weight: 700; font-size: 13px; word-break: break-all; line-height: 1.3; }
.product-card .pc-proj { color: var(--muted); font-size: 11px; margin-top: 3px; word-break: break-all; }
.product-card .pc-count { margin-top: 6px; font-size: 11px; color: var(--primary); }

.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.detail-product { font-size: 20px; font-weight: 700; word-break: break-all; }
.detail-project { font-size: 13px; color: var(--muted); margin-top: 2px; }
.detail-actions { display: flex; gap: 8px; flex-shrink: 0; }

.modal-box {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0,0,0,.35);
  padding: 20px;
  width: min(420px, 92vw);
  max-height: 90vh;
  overflow: auto;
}
.modal-box h2 { font-size: 16px; margin: 0 0 14px; color: var(--text); }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal-actions .btn { flex: 1; }
.modal-actions .btn.primary { width: auto; }

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 22px 16px;
  text-align: center;
  color: var(--muted);
  background: #fafbfc;
}
.drop-zone.drag { border-color: var(--primary); background: #eff6ff; }
.drop-zone p { margin: 4px 0; font-size: 14px; }
.drop-zone .hint { font-size: 12px; }

.upload-status { margin-top: 14px; font-size: 13px; color: var(--muted); }
.progress {
  height: 8px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width .2s; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}
.photo-item {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow: hidden;
  background: #eef0f3;
  cursor: pointer;
}
.photo-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-item .ph-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  flex-direction: column;
}
.lightbox img { max-width: 92%; max-height: 78%; border-radius: 8px; }
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 34px;
  color: #fff;
  cursor: pointer;
}
.lightbox-del { margin-top: 16px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17,24,39,.92);
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 60;
  max-width: 90%;
  text-align: center;
}
