:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #17233d;
  --ink-2: #5b6b8c;
  --ink-3: #8b98b3;
  --line: #e6ebf5;
  --primary: #2b6cf6;
  --primary-dark: #1f55c9;
  --primary-soft: #eaf1ff;
  --green: #12a15f;
  --green-soft: #e6f7ee;
  --red: #e04545;
  --red-soft: #fdecec;
  --orange: #d97706;
  --orange-soft: #fef3e2;
  --sidebar: #101c33;
  --sidebar-2: #172647;
  --shadow: 0 8px 24px rgba(23, 35, 61, 0.06);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 14px;
}

.hidden { display: none !important; }

/* ---------------- 登录页 ---------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(43, 108, 246, 0.22), transparent 60%),
    radial-gradient(800px 500px at 90% 90%, rgba(16, 28, 51, 0.28), transparent 55%),
    linear-gradient(135deg, #0d1830 0%, #16294d 100%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 18px;
  padding: 38px 34px 30px;
  box-shadow: 0 24px 60px rgba(5, 15, 35, 0.35);
}

.login-logo {
  font-size: 12px;
  letter-spacing: 3px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 14px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 24px;
  letter-spacing: 1px;
}

.login-sub {
  margin: 0 0 26px;
  color: var(--ink-3);
  font-size: 12px;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field span {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  color: var(--ink-2);
}

.field input,
.field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: #fbfcff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(43, 108, 246, 0.12);
}

.login-hint {
  margin: 18px 0 0;
  color: var(--ink-3);
  font-size: 12px;
  text-align: center;
  line-height: 1.6;
}

/* ---------------- 通用按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover { border-color: #c9d6ee; background: #f8faff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn.ghost { background: transparent; }

.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; }

.btn.danger { color: var(--red); border-color: #f3c9c9; background: #fff; }
.btn.danger:hover { background: var(--red-soft); }

.btn.success { color: var(--green); border-color: #bfe8d3; background: #fff; }
.btn.success:hover { background: var(--green-soft); }

.btn.tiny { padding: 4px 9px; font-size: 12px; border-radius: 7px; }

/* ---------------- 主体布局 ---------------- */
.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #cdd7ec;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #4b86ff, #2b6cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 19px;
  box-shadow: 0 6px 14px rgba(43, 108, 246, 0.4);
}

.brand-name { color: #fff; font-weight: 700; letter-spacing: 0.6px; }
.brand-sub { font-size: 11px; color: #7e8dab; margin-top: 3px; }

.nav { display: flex; flex-direction: column; gap: 6px; padding: 18px 0; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #b6c3dd;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  transition: all 0.15s;
}

.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 8px 18px rgba(43, 108, 246, 0.34); }

.badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #ff5b5b;
  color: #fff;
  font-size: 11px;
  line-height: 20px;
  text-align: center;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 14px;
  font-size: 12px;
  color: #8d9cb9;
}

.admin-name { margin-bottom: 10px; }
.admin-name strong { color: #fff; }

.main {
  flex: 1;
  min-width: 0;
  padding: 26px 30px 40px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.topbar h1 { margin: 0 0 5px; font-size: 22px; letter-spacing: 0.5px; }
.page-sub { margin: 0; color: var(--ink-3); font-size: 13px; }

/* ---------------- 数据看板 ---------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  border: 1px solid #eef2fa;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  right: -26px;
  top: -26px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--primary-soft);
}

.stat-label { color: var(--ink-2); font-size: 13px; }
.stat-card strong { display: block; font-size: 38px; margin: 10px 0 6px; letter-spacing: 1px; }
.stat-foot { color: var(--ink-3); font-size: 12px; }

.panel {
  background: var(--panel);
  border: 1px solid #eef2fa;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-head h2 { margin: 0; font-size: 16px; }
.panel-note { color: var(--ink-3); font-size: 12px; }

.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.mini-item {
  background: #f8faff;
  border: 1px solid #edf2fc;
  border-radius: 11px;
  padding: 15px 18px;
}

.mini-item span { color: var(--ink-2); font-size: 12px; }
.mini-item strong { display: block; font-size: 24px; margin-top: 7px; }

.hint {
  margin: 16px 0 0;
  padding: 11px 14px;
  background: #f7f9fe;
  border: 1px dashed #dbe4f5;
  border-radius: 10px;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.7;
}

/* ---------------- 工具栏 / 筛选 ---------------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.filter-group { display: flex; gap: 9px; }

.tabs {
  display: inline-flex;
  background: #f3f6fd;
  padding: 4px;
  border-radius: 10px;
  gap: 2px;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  padding: 7px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

.tab.active {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(23, 35, 61, 0.08);
}

.search-input,
.select {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 12px;
  background: #fff;
  outline: none;
  color: var(--ink);
}

.search-input { width: 220px; }
.search-input:focus, .select:focus { border-color: var(--primary); }

/* ---------------- 表格 ---------------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid #eef2fa;
  border-radius: 11px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.table th,
.table td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid #f0f4fb;
  vertical-align: middle;
}

.table th {
  background: #f8faff;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
}

.table tbody tr:hover { background: #fbfcff; }
.table tbody tr:last-child td { border-bottom: 0; }

.table .empty {
  text-align: center;
  color: var(--ink-3);
  padding: 46px 20px;
}

.col-action { min-width: 132px; }

.user-cell strong { display: block; font-size: 14px; letter-spacing: 0.3px; }
.user-cell span { display: block; color: var(--ink-3); font-size: 11px; margin-top: 4px; }

.car-title { font-weight: 600; max-width: 260px; }
.car-sub { color: var(--ink-3); font-size: 12px; margin-top: 4px; }

.thumb-row { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }

.thumb {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #e8eef9;
  cursor: zoom-in;
  background: #f2f5fb;
}

.thumb-count { color: var(--ink-3); font-size: 11px; }

.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  white-space: nowrap;
}

.tag.nev { background: var(--green-soft); color: var(--green); }
.tag.fuel { background: var(--orange-soft); color: var(--orange); }
.tag.gray { background: #f1f4fa; color: var(--ink-2); }
.tag.blue { background: var(--primary-soft); color: var(--primary); }
.tag.red { background: var(--red-soft); color: var(--red); }

.reason-text {
  max-width: 170px;
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
}

.row-actions { display: flex; gap: 7px; flex-wrap: wrap; }

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  color: var(--ink-2);
  font-size: 13px;
}

.pager .page-info { margin-right: auto; color: var(--ink-3); font-size: 12px; }

/* ---------------- 品牌车型树 ---------------- */
.dict-stats {
  display: flex;
  gap: 20px;
  color: var(--ink-2);
  font-size: 13px;
  flex-wrap: wrap;
}

.dict-stats strong { color: var(--ink); }

.tree {
  border: 1px solid #eef2fa;
  border-radius: 11px;
  overflow: hidden;
}

.tree .empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--ink-3);
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border-bottom: 1px solid #f2f5fc;
  background: #fff;
}

.tree-row:hover { background: #fbfcff; }
.tree-row.brand { font-weight: 600; }
.tree-row.series { padding-left: 40px; background: #fcfdff; }
.tree-row.model { padding-left: 70px; font-size: 13px; color: var(--ink-2); }

.tree-toggle {
  width: 20px;
  height: 20px;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  transition: transform 0.15s;
}

.tree-toggle.open { transform: rotate(90deg); }
.tree-toggle.placeholder { visibility: hidden; }

.tree-name { flex: 1; min-width: 0; word-break: break-all; }
.tree-meta { color: var(--ink-3); font-size: 12px; font-weight: 400; }

.tree-actions { display: flex; gap: 6px; opacity: 0.35; transition: opacity 0.15s; }
.tree-row:hover .tree-actions { opacity: 1; }

.tree-children { background: #fff; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 34, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal {
  width: 100%;
  max-width: 460px;
  background: #fff;
  border-radius: 15px;
  box-shadow: 0 28px 60px rgba(5, 14, 32, 0.3);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 20px;
  border-bottom: 1px solid #eef2fa;
}

.modal-head h3 { margin: 0; font-size: 16px; }

.icon-btn {
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-3);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}

.icon-btn:hover { background: #f2f5fb; color: var(--ink); }

.modal-body { padding: 20px; max-height: 62vh; overflow-y: auto; }

.modal-desc {
  margin: 0 0 15px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.7;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 15px 20px;
  border-top: 1px solid #eef2fa;
  background: #fbfcff;
}

/* ---------------- 车源详情弹窗（只读） ---------------- */
#modal-mask.car-detail .modal { max-width: 880px; }

#modal-mask.car-detail .modal-body { max-height: 70vh; }

.detail-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid #eef2fa;
}

.detail-cover {
  width: 132px;
  height: 92px;
  object-fit: cover;
  border-radius: 10px;
  background: #f1f4fa;
  cursor: zoom-in;
  flex-shrink: 0;
}

.detail-hero-info { min-width: 0; }

.detail-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.detail-price {
  margin-top: 10px;
  color: var(--red);
  font-size: 18px;
  font-weight: 700;
}

.detail-section { padding-top: 16px; }

.detail-section h4 {
  margin: 0 0 10px;
  font-size: 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  background: #f8faff;
  border-radius: 8px;
  font-size: 13px;
}

.detail-item span {
  color: var(--ink-3);
  flex-shrink: 0;
}

.detail-item strong {
  font-weight: 600;
  text-align: right;
  word-break: break-all;
}

.detail-desc {
  margin: 0;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.detail-gallery img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: #f1f4fa;
  cursor: zoom-in;
}

.detail-attach { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.detail-link {
  display: block;
  padding: 9px 10px;
  background: #f8faff;
  border-radius: 8px;
  color: var(--primary);
  font-size: 12px;
  text-decoration: none;
  word-break: break-all;
}

/* ---------------- 图片预览 ---------------- */
.preview-mask {
  position: fixed;
  inset: 0;
  background: rgba(6, 11, 22, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.preview-mask img {
  max-width: 82vw;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.preview-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 70px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
}

.preview-nav:hover { background: rgba(255, 255, 255, 0.26); }
.preview-nav.prev { left: 26px; }
.preview-nav.next { right: 26px; }

.preview-close {
  position: absolute;
  top: 20px;
  right: 24px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.preview-count {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  color: #dfe7f8;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.12);
  padding: 5px 14px;
  border-radius: 20px;
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 520px;
  background: #17233d;
  color: #fff;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(5, 14, 32, 0.3);
  z-index: 300;
}

.toast.success { background: #12a15f; }
.toast.error { background: #d64545; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 980px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: none;
    height: auto;
    position: static;
    padding: 16px;
  }
  .brand-block { padding-bottom: 14px; }
  .nav { flex-direction: row; flex-wrap: wrap; padding: 12px 0; }
  .nav-item { width: auto; }
  .sidebar-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .admin-name { margin: 0; }
  .main { padding: 20px 16px 30px; }
  .stat-grid { grid-template-columns: 1fr; }
  .mini-grid { grid-template-columns: 1fr; }
  .search-input { width: 100%; }
  .toolbar-right { width: 100%; }
}

/* 系统配置 */
.settings-panel { margin-top: 16px; }
.settings-panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
  color: #1a2233;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px 16px;
  margin-bottom: 14px;
}
.settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #4a5568;
}
.settings-grid input,
.settings-grid select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid #dfe5ee;
  border-radius: 6px;
  font-size: 13px;
  color: #1a2233;
  background: #fff;
}
