:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #16a34a;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  background: var(--primary);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 12px 16px 0;
}
.topbar .title {
  font-size: 18px;
  font-weight: 600;
  padding: 4px 0 12px;
}
.tabs {
  display: flex;
  gap: 4px;
}
.tab {
  flex: 1;
  border: none;
  background: transparent;
  color: #dbeafe;
  padding: 12px 0;
  font-size: 15px;
  border-bottom: 3px solid transparent;
  cursor: pointer;
}
.tab.active {
  color: #fff;
  border-bottom-color: #fff;
  font-weight: 600;
}

.tab-panel { display: none; padding: 12px; }
.tab-panel.active { display: block; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}
.card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

.field-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
}
.input:focus { outline: none; border-color: var(--primary); }

.reader {
  width: 100%;
  min-height: 160px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #000;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.reader video { width: 100%; border-radius: 8px; }

.btn-row { display: flex; gap: 10px; margin-top: 4px; }
.btn {
  flex: 1;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:active { background: var(--primary-dark); }
.btn.block { display: block; width: 100%; margin-top: 12px; }
.btn.small { flex: none; padding: 6px 12px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.hint { font-size: 12px; color: var(--muted); margin-top: 10px; line-height: 1.6; }
.hint code { background: #eef2ff; color: var(--primary); padding: 1px 5px; border-radius: 4px; }
.link { color: var(--primary); margin-left: 6px; }

.banner {
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 14px;
}
.banner.error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.banner-actions { margin-top: 8px; display: flex; gap: 8px; }

.summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 14px;
}
.summary-row span { color: var(--muted); }
.summary-row b { font-weight: 600; }
.summary-row b.accent { color: var(--primary); font-size: 18px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  gap: 8px;
}
.list li:last-child { border-bottom: none; }
.li-main { flex: 1; min-width: 0; }
.li-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.li-actions { flex: none; display: flex; gap: 6px; }
.tag {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--primary);
}
.icon-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 6px;
}
.icon-btn.danger { color: var(--danger); }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-grid label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.form-grid .input { margin-top: 0; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-box .btn-row { margin-top: 14px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 200;
  max-width: 86%;
  text-align: center;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

.hidden { display: none !important; }
.empty { color: var(--muted); text-align: center; padding: 16px 0; font-size: 14px; }

/* 标签打印页 */
.label {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid #000;
  padding: 16px;
  font-size: 13px;
}
.label h1 { font-size: 20px; margin: 0 0 12px; text-align: center; }
.label .qrcode { text-align: center; margin: 8px 0; }
.label .qrcode img { width: 120px; height: 120px; }
.label table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.label table th, .label table td { border: 1px solid #000; padding: 4px 6px; text-align: center; }
.label .kv { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin-top: 8px; }
.label .kv div { display: flex; justify-content: space-between; border-bottom: 1px dashed #999; padding: 4px 0; }
.no-print { text-align: center; margin: 16px 0; }
.no-print .input { width: 200px; display: inline-block; margin-right: 10px; }

@media print {
  body { background: #fff; }
  .no-print { display: none !important; }
  .label { border: none; max-width: 100%; }
  @page { size: 100mm 150mm; margin: 5mm; }
}
