:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface-elevated: #242424;
  --primary: #E53935;
  --primary-dark: #B71C1C;
  --accent: #FBC02D;
  --text: #f5f5f5;
  --text-secondary: #b0b0b0;
  --text-muted: #757575;
  --border: rgba(255, 255, 255, 0.08);
  --success: #43A047;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* Auth */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, #2a0a0a 0%, var(--bg) 60%);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  box-shadow: var(--shadow);
}

.auth-brand {
  text-align: center;
  margin-bottom: 40px;
}

.auth-logo {
  width: 100px;
  height: 100px;
  border-radius: 20px;
  margin-bottom: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  object-fit: contain;
  background: #fff;
  padding: 4px;
}

.auth-title {
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
}

.auth-subtitle {
  font-size: 16px;
  color: var(--text-secondary);
}

.auth-form {
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 24px;
}

.form-label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  transition: border-color 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.error-message {
  color: var(--primary);
  font-size: 14px;
  margin-bottom: 16px;
  min-height: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 48px;
  padding: 0 24px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(229, 57, 53, 0.3);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-sm {
  height: 36px;
  padding: 0 16px;
  font-size: 14px;
}

.btn-block {
  width: 100%;
}

.auth-footer {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* Dashboard */
.dashboard-container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: contain;
  background: #fff;
  padding: 2px;
}

.sidebar-title {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 15px;
  margin-bottom: 4px;
  transition: all 0.2s;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(229, 57, 53, 0.1);
  color: var(--text);
}

.nav-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  position: relative;
}

.dashboard-icon { background: rgba(229, 57, 53, 0.2); }
.records-icon { background: rgba(66, 165, 245, 0.2); }
.rules-icon { background: rgba(251, 192, 45, 0.2); }
.stores-icon { background: rgba(126, 87, 194, 0.2); }
.settings-icon { background: rgba(255, 255, 255, 0.1); }
.products-icon { background: rgba(38, 166, 154, 0.22); }
.qr-icon { background: rgba(251, 192, 45, 0.25); }
.qr-activ-icon { background: rgba(67, 160, 71, 0.15); }
.leads-icon { background: rgba(66, 165, 245, 0.22); }
.maintenance-icon { background: rgba(255, 152, 0, 0.22); }
.printer-icon { background: rgba(38, 166, 154, 0.2); }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.user-info {
  margin-bottom: 12px;
}

.user-name {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
}

.user-role {
  font-size: 13px;
  color: var(--text-muted);
}

.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 24px 32px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.back-btn {
  margin: 0;
  white-space: nowrap;
}

.page-title {
  font-size: 26px;
  font-weight: 700;
  color: #fff;
}

.status-badge {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}

.badge-success {
  background: rgba(67, 160, 71, 0.15);
  color: var(--success);
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(229, 57, 53, 0.15);
}

.today-icon { background: rgba(229, 57, 53, 0.15); }
.week-icon { background: rgba(251, 192, 45, 0.15); }
.total-icon { background: rgba(66, 165, 245, 0.15); }
.active-icon { background: rgba(67, 160, 71, 0.15); }

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-wide {
  grid-column: 1 / -1;
}

.panel-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
}

.panel-body {
  padding: 24px;
}

/* Chart */
.chart-placeholder {
  height: 200px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 40px;
  padding-bottom: 20px;
}

.chart-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.bar-wrap {
  width: 48px;
  height: 160px;
  background: var(--surface-elevated);
  border-radius: 8px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.bar {
  width: 100%;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 8px 8px 0 0;
  transition: height 0.5s ease;
}

.bar-label {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.bar-num {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.status-legend {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-secondary);
}

.status-legend b {
  color: var(--text);
  font-weight: 700;
}

/* City List */
.city-list {
  list-style: none;
}

.city-item {
  display: flex;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}

.city-item:last-child {
  border-bottom: none;
}

.city-item span:first-child {
  color: var(--text);
}

.city-item span:last-child {
  color: var(--primary);
  font-weight: 600;
}

/* Feature Cards */
.feature-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.feature-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  transition: transform 0.2s, border-color 0.2s;
  cursor: pointer;
}

.feature-card:hover {
  transform: translateY(-4px);
  border-color: rgba(229, 57, 53, 0.3);
}

.feature-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  margin: 0 auto 16px;
}

.feature-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 8px;
}

.feature-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.tool-input {
  height: 40px;
  padding: 0 14px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  min-width: 200px;
}

.tool-input:focus { outline: none; border-color: var(--primary); }

.qr-gen-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.qr-url-text { word-break: break-all; font-size: 11px; color: var(--text-muted); background: var(--surface-elevated); padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); }

/* Tables */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  padding: 14px 16px;
  background: var(--surface-elevated);
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}

.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

.data-table .muted { color: var(--text-muted); font-size: 12px; }

.table-foot {
  padding: 14px 16px;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

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

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
}

.badge-visc { background: rgba(229, 57, 53, 0.18); color: #ff6b6b; }
.badge-ok { background: rgba(67, 160, 71, 0.18); color: var(--success); }
.badge-warn { background: rgba(251, 192, 45, 0.18); color: var(--accent); }
.badge-danger { background: rgba(229, 57, 53, 0.22); color: #ff8a80; }
.badge-muted { background: rgba(255, 255, 255, 0.08); color: var(--text-secondary); }
.badge-perm { background: rgba(66, 165, 245, 0.16); color: #64b5f6; }

.btn-danger { color: #ff8a80; border-color: rgba(229, 57, 53, 0.3); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}

.modal-dialog {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 18px; color: #fff; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
}

.modal-body { padding: 24px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
  margin-bottom: 20px;
}

.detail-item { display: flex; flex-direction: column; gap: 4px; }
.detail-k { font-size: 12px; color: var(--text-muted); }
.detail-v { font-size: 15px; color: var(--text); font-weight: 500; }

.audit-list { list-style: none; }
.audit-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
}

/* Toast */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 12px;
  font-size: 14px;
  opacity: 0;
  transition: all 0.3s;
  z-index: 2000;
  box-shadow: var(--shadow);
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: rgba(67, 160, 71, 0.5); }
.toast.error { border-color: rgba(229, 57, 53, 0.5); }

/* Responsive */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .feature-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { width: 100%; position: relative; }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .feature-cards { grid-template-columns: 1fr; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .data-table { font-size: 12px; }
}

/* ---------- 登录角色切换 ---------- */
.role-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}
.role-opt {
  flex: 1;
  padding: 10px 0;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text-secondary);
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all .15s ease;
}
.role-opt.active {
  border-color: var(--primary);
  color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}
.auth-hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- 门店端 ---------- */
.store-mode .sidebar { display: none; }
.store-mode .main-content { margin-left: 0; }
.store-banner {
  background: rgba(66, 165, 245, 0.12);
  border: 1px solid rgba(66, 165, 245, 0.4);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  font-size: 15px;
}
.store-banner b { color: #64b5f6; }
.store-tabs { display: flex; gap: 8px; margin: 4px 0 16px; }
.store-tab { padding: 7px 16px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--text); transition: all .15s; }
.store-tab:hover { border-color: var(--accent); }
.store-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.store-back { margin-bottom: 12px; }
.lead-status { padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 12px; cursor: pointer; }
.lead-status:focus { outline: none; border-color: var(--accent); }

/* ---------- 新增：必填标记 / 部位照片 / VIN 匹配 / 保养记录 / 修改密码 ---------- */
.req { color: #ff5252; font-weight: 700; }
.photo-slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 4px; }
.photo-slot { border: 1px dashed var(--border); border-radius: 10px; padding: 10px; background: var(--surface); }
.photo-slot-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.photo-slot-label { font-size: 13px; font-weight: 600; color: var(--text); }
.photo-preview { display: flex; flex-wrap: wrap; gap: 8px; min-height: 24px; }
.photo-preview .muted { font-size: 12px; }
.photo-thumb { position: relative; display: inline-block; }
.photo-thumb img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.photo-del { position: absolute; top: -6px; right: -6px; width: 18px; height: 18px; border-radius: 50%; border: none; background: #e53935; color: #fff; font-size: 12px; line-height: 18px; cursor: pointer; }
.hidden-file { display: none; }
.vin-match { margin: 10px 0; padding: 10px 14px; border-radius: 10px; background: rgba(67, 160, 71, 0.12); color: var(--text); font-size: 13px; line-height: 1.6; }
.vin-match.hidden { display: none; }
.detail-photos { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-photo { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.maint-list { list-style: none; padding: 0; margin: 0; }
.maint-item { padding: 8px 12px; border-radius: 8px; background: var(--surface); margin-bottom: 8px; font-size: 13px; line-height: 1.6; }
.maint-item b { color: var(--accent); }
.card-form-wrap { max-width: 560px; margin: 24px auto; }
.card-form { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 24px; }
.card-form .form-group { margin-bottom: 16px; }
.inline-group { display: flex; gap: 8px; align-items: center; }
.inline-group .form-input { flex: 1; }
.inline-group .btn { white-space: nowrap; }
.toolbar-hint { font-size: 12px; color: var(--muted); margin: 8px 2px 0; }

/* ---------- 3cm 标签打印（瓶身溯源码，实物尺寸 3cm×3cm） ---------- */
.qr-label-sheet { width: 210mm; margin: 0 auto; }
.qr-label-sheet .qr-label { width: 30mm; height: 30mm; padding: 1mm; box-sizing: border-box; border: 1px dashed #bbb; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; page-break-inside: avoid; }
.qr-label-sheet .qr-label img { width: 18mm; height: 18mm; }
.qr-label-sheet .qr-label .qr-label-serial { font-size: 7pt; margin-top: 1mm; text-align: center; word-break: break-all; }

