/* ===== 喜宝达车牌收集软件 全局样式（浅色主题）===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #eff6ff;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1f2937;
  --text-light: #6b7280;
  --border: #e5e7eb;
  --danger: #ef4444;
  --success: #10b981;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ===== 顶部标题栏 ===== */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}
.topbar .title .brand {
  color: var(--primary);
  margin-right: 4px;
}
.topbar a.link {
  font-size: 14px;
  color: var(--text-light);
}

/* ===== 录入页表单 ===== */
.form-wrap {
  max-width: 560px;
  margin: 16px auto;
  padding: 0 14px 40px;
}
.form-card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px 18px 22px;
}
.field {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.field:last-of-type { border-bottom: none; }
.field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.field-label .req { color: var(--danger); margin-left: 2px; }
.field-hint { font-size: 12px; color: var(--text-light); margin-top: 6px; }

/* 输入框 + 扫码按钮组合 */
.input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.input-row .ctrl { flex: 1; }
.scan-btn {
  flex-shrink: 0;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0 16px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.scan-btn:active { background: var(--primary-dark); }

input[type="text"],
input[type="password"],
input[type="search"],
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 15px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
input[type="text"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 70px; }

/* 拍照上传 */
.photo-picker {
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  color: var(--text-light);
  background: #fafbfc;
  cursor: pointer;
  transition: border-color 0.15s;
}
.photo-picker:active { border-color: var(--primary); }
.photo-picker .icon { font-size: 28px; display: block; margin-bottom: 4px; }
.photo-preview {
  margin-top: 10px;
  height: 220px;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #f3f4f6;
}
.photo-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.photo-preview .re-pick {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
}

/* 提交按钮 */
.submit-btn {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  margin-top: 18px;
}
.submit-btn:active { background: var(--primary-dark); }
.submit-btn:disabled { background: #9bbbf3; }

/* ===== Toast 提示 ===== */
.toast {
  position: fixed;
  left: 50%;
  top: 20%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 12px 22px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ===== 扫码弹层 ===== */
.scan-modal {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 1000;
  display: none;
  flex-direction: column;
}
.scan-modal.show { display: flex; }
.scan-modal .scan-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  color: #fff;
  background: rgba(0, 0, 0, 0.4);
}
.scan-modal .scan-header .close { font-size: 24px; cursor: pointer; padding: 0 6px; }
.scan-modal .scan-tip { color: #fff; font-size: 13px; text-align: center; padding: 6px; }
.scan-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
#qr-reader {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
#qr-reader__scan_region {
  width: 100% !important;
  height: 100% !important;
}
#qr-reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}
#qr-shaded-region { display: none !important; }
.scan-guide {
  position: absolute;
  top: 40%;
  left: 50%;
  width: min(72vw, 72vh, 360px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}
.scan-guide::before,
.scan-guide::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 12px;
  border: 5px solid transparent;
  border-top-color: #fff;
  border-left-color: #fff;
  pointer-events: none;
}
.scan-guide::after {
  transform: rotate(180deg);
}

@media (max-width: 480px) {
  .photo-preview { height: 200px; }
}

/* ===== 登录页 ===== */
.login-wrap {
  max-width: 380px;
  margin: 60px auto;
  padding: 0 16px;
}
.login-card {
  background: var(--card);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 28px 22px;
}
.login-card h1 {
  font-size: 20px;
  text-align: center;
  margin-bottom: 22px;
}
.login-card .field { border: none; padding: 8px 0; }
.login-error {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin-bottom: 10px;
  min-height: 18px;
}

/* ===== 后台管理页 ===== */
.admin-bar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.admin-bar .who { font-size: 14px; color: var(--text-light); margin-right: auto; }
.admin-bar button,
.admin-bar a.btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 7px;
  padding: 7px 13px;
  font-size: 13px;
  color: var(--text);
}
.admin-bar button.primary,
.admin-bar a.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.admin-bar button.danger {
  color: var(--danger);
  border-color: #fecaca;
}
.page-size {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
}

.filter-bar {
  background: var(--card);
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.filter-bar input { width: auto; min-width: 120px; }
.filter-bar input[type="text"], .filter-bar input[type="search"] { flex: 1; min-width: 180px; }
.filter-bar .lbl { font-size: 13px; color: var(--text-light); }
.filter-bar .stat { font-size: 13px; color: var(--text-light); margin-left: auto; }

.table-wrap {
  padding: 14px 18px;
  overflow-x: auto;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 13px;
  min-width: 820px;
}
table.data th, table.data td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
}
table.data th {
  background: var(--primary-light);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}
table.data tbody tr:nth-child(even) { background: #fafbfc; }
table.data tbody tr:hover { background: #f0f6ff; }
table.data td.center { text-align: center; }
table.data td.thumb img { width: 70px; height: 52px; object-fit: cover; border-radius: 4px; }
table.data td.nowrap { white-space: nowrap; }
.row-check { width: 38px; text-align: center; }

.empty-row {
  text-align: center;
  color: var(--text-light);
  padding: 40px 0;
}

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 14px;
  flex-wrap: wrap;
}
.pager button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
}
.pager button:disabled { color: #ccc; cursor: not-allowed; }
.pager button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager .info { font-size: 13px; color: var(--text-light); }

/* ===== 通用弹窗 ===== */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 800;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-mask.show { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 12px;
  width: 340px;
  max-width: 92vw;
  padding: 22px;
}
.modal-box h3 { margin-bottom: 14px; font-size: 16px; }
.modal-box .field { border: none; padding: 8px 0; }
.modal-box .actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}
.modal-box .actions button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 7px;
  padding: 8px 16px;
  font-size: 13px;
}
.modal-box .actions button.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.img-preview-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 900;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.img-preview-mask.show { display: flex; }
.img-preview-mask img { max-width: 100%; max-height: 100%; border-radius: 6px; }
.img-preview-mask .close {
  position: absolute;
  top: 16px;
  right: 20px;
  color: #fff;
  font-size: 30px;
  cursor: pointer;
}
