/* 车辆登记应用 - 三页统一样式，移动端友好 */

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

* { box-sizing: border-box; }

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.6;
  -webkit-font-smoothing: antialiased;
}

/* 防止组件 display 样式覆盖 hidden 属性，确保带 hidden 的元素始终隐藏 */
[hidden] { display: none !important; }

/* 顶部导航 */
.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 16px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.nav { display: flex; gap: 6px; }
.nav a {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--bg); color: var(--primary); }
.nav a.active { background: var(--primary); color: #fff; }

/* 布局容器 */
.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}
.container-narrow { max-width: 560px; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
h1 { margin: 0 0 6px; font-size: 22px; }
h2 { margin: 0 0 14px; font-size: 18px; }
.subtitle { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.required { color: var(--danger); }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, opacity .15s;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--bg); }
.btn-mini { padding: 5px 12px; font-size: 13px; border-radius: 6px; }
.btn-block { width: 100%; }

/* 表单 */
input[type="text"], input[type="tel"], input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.form-field { margin-bottom: 16px; }
.form-field label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.field-error, .form-error { margin: 6px 0 0; color: var(--danger); font-size: 13px; }

.search-form { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-form input { flex: 1 1 220px; min-width: 0; }

.feedback {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
.feedback.success { background: #dcfce7; color: #166534; }
.feedback.error { background: #fee2e2; color: #991b1b; }

/* 车辆列表（查询页） */
.vehicle-list { display: grid; gap: 12px; }
.vehicle-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  background: #fff;
}
.vehicle-item h3 { margin: 0 0 8px; font-size: 16px; }
.vehicle-meta { margin: 4px 0; font-size: 14px; color: var(--text); }
.vehicle-meta .label { display: inline-block; min-width: 52px; color: var(--muted); }
.tel-link {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
  padding: 2px 0;
}
.tel-link:hover { text-decoration: underline; color: var(--primary-dark); }
.plate-badge {
  display: inline-block;
  padding: 1px 8px;
  background: #eff6ff;
  color: var(--primary-dark);
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: .5px;
}
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 32px 12px;
  font-size: 14px;
}

/* 二维码区 */
.qr-card { text-align: center; }
.qr-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.qrcode-box { display: flex; justify-content: center; margin: 0 auto; }
.qrcode-box img, .qrcode-box canvas { max-width: 100%; height: auto !important; }
.share-url {
  word-break: break-all;
  font-size: 13px;
  color: var(--primary-dark);
  background: var(--bg);
  padding: 10px 12px;
  border-radius: 8px;
  margin: 16px auto 0;
  max-width: 480px;
  text-align: left;
}

/* 管理区 */
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.login-form { max-width: 360px; }
.table-wrap { overflow-x: auto; margin-top: 8px; }
.vehicle-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.vehicle-table th, .vehicle-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.vehicle-table th { background: var(--bg); color: var(--muted); font-weight: 600; }
.vehicle-table tbody tr:hover { background: #f9fafb; }
.row-actions { display: flex; gap: 6px; }
.btn-edit { background: #eff6ff; color: var(--primary-dark); }
.btn-delete { background: #fee2e2; color: var(--danger-dark); }
.btn-delete:hover:not(:disabled) { background: #fecaca; }

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
}
.modal-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
}
.modal-card h2 { margin-top: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* 顶部提示条 */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 8px;
  background: #374151;
  color: #fff;
  font-size: 14px;
  z-index: 300;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .25);
  max-width: 90vw;
  text-align: center;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* 移动端适配 */
@media (max-width: 600px) {
  .topbar-inner { flex-wrap: wrap; padding: 8px 12px; min-height: auto; }
  .container { padding: 16px 12px 32px; }
  .card { padding: 18px 16px; }
  .search-form { flex-direction: column; }
  .search-form input { flex: 0 0 auto; width: 100%; height: auto; min-height: 0; }
  .search-form .btn { width: 100%; }
  .section-head .btn { width: 100%; }
}

/* ===== 分格车牌输入组件（登记页） ===== */
.plate-input {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
/* 覆盖全站 input[type="text"] 的 width:100% 与基础边框 */
.plate-input .plate-slot {
  width: 44px;
  height: 52px;
  flex: 0 0 auto;
  padding: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  font-family: inherit;
  line-height: 1;
  letter-spacing: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.plate-input .plate-slot--province {
  padding: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.plate-input .plate-slot--province.is-filled {
  color: var(--text);
  border-color: var(--primary);
}
.plate-input .plate-slot:focus {
  outline: none;
  border-color: var(--primary);
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
.plate-sep {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  color: var(--muted);
  padding: 0 2px;
}
.plate-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.plate-newenergy {
  height: 52px;
  padding: 0 10px;
  border: 1px dashed #9ca3af;
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.plate-newenergy:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.plate-newenergy.is-active {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: #fff;
}
.plate-keypad {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 6px;
  max-width: 400px;
}
.plate-key {
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.plate-key:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.plate-key:active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

@media (max-width: 600px) {
  .plate-input .plate-slot { width: 36px; height: 44px; font-size: 18px; }
  .plate-input .plate-slot--province { font-size: 17px; }
  .plate-slots { gap: 4px; }
  .plate-sep { font-size: 18px; }
  .plate-newenergy { height: 44px; padding: 0 8px; font-size: 12px; }
  .plate-keypad { gap: 4px; padding: 8px; max-width: 100%; }
  .plate-key { height: 34px; font-size: 14px; }
}

/* ===== 管理区批量操作与导出（追加，不改动既有规则） ===== */
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.toolbar .selected-count {
  margin-right: auto;
  color: var(--muted);
  font-size: 14px;
}
.vehicle-table .check-col {
  width: 42px;
  text-align: center;
}
#check-all, .row-check {
  width: 16px;
  height: 16px;
  margin: 0;
  vertical-align: middle;
  cursor: pointer;
  accent-color: var(--primary);
}
.btn-batch-delete {
  background: #fee2e2;
  color: var(--danger-dark);
}
.btn-batch-delete:hover:not(:disabled) { background: #fecaca; }
.btn-export {
  background: #eff6ff;
  color: var(--primary-dark);
}
.btn-export:hover:not(:disabled) { background: #dbeafe; }

@media (max-width: 600px) {
  .toolbar .selected-count { width: 100%; }
  .toolbar .btn { flex: 1 1 auto; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .vehicle-table { min-width: 560px; }
}
