:root {
  --paper: #f3f3f3;
  --ink: #111111;
  --line: #2c2c2c;
  --red: #e60000;
  --blue: #0078ff;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.12);
  --font-latin: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, Helvetica, "Liberation Sans";
  --font-cjk: "Noto Sans CJK SC", "Source Han Sans SC", "Noto Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB";
  --font-ui: var(--font-latin), var(--font-cjk), sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  font-family: var(--font-ui);
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-ui);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

/* 登录门禁 */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
}

.login-card {
  width: 300px;
  display: grid;
  gap: 10px;
  padding: 18px;
  background: #fff;
  border: 2px solid var(--blue);
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  text-align: left;
}

.login-card input {
  height: 38px;
  padding: 6px 10px;
  border: 1px solid #bfc4ca;
  outline: none;
}

.login-card button {
  height: 38px;
  border: 0;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.login-error {
  min-height: 18px;
  margin: 0;
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
}

/* 后台外壳 */
.admin-shell {
  min-height: 100vh;
}

.admin-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 2px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-header strong {
  font-size: 18px;
}

.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nav-btn {
  height: 34px;
  min-width: 92px;
  padding: 0 14px;
  border: 1px solid #c8c8c8;
  background: #f1f1f1;
  font-weight: 700;
}

.nav-btn.active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.welcome-text {
  margin-left: auto;
  font-weight: 800;
}

.ghost-link,
.ghost-btn {
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid #c8c8c8;
  background: #fff;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}

.admin-main {
  max-width: 1680px;
  margin: 0 auto;
  padding: 20px;
}

.admin-tab.hidden {
  display: none;
}

.admin-tab {
  overflow-x: auto;
}

.table-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.table-toolbar input {
  height: 36px;
  min-width: 260px;
  padding: 6px 10px;
  border: 1px solid #bfc4ca;
  outline: none;
}

.table-toolbar input[type="file"],
.table-toolbar select {
  min-width: 180px;
  height: 36px;
  padding: 6px 10px;
  border: 1px solid #bfc4ca;
  background: #fff;
}

.table-toolbar button {
  height: 36px;
  min-width: 86px;
  padding: 0 14px;
  border: 1px solid #c8c8c8;
  background: #f3f3f3;
  font-weight: 700;
}

.toolbar-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.toolbar-check input {
  width: 16px;
  min-width: 16px;
  height: 16px;
  margin: 0;
}

.toolbar-link {
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.pager {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 8px;
  white-space: nowrap;
}

.pager .page-jump {
  width: 70px;
  min-width: 70px;
  height: 36px;
  padding: 6px 8px;
  border: 1px solid #bfc4ca;
  text-align: center;
}

.hint-text {
  margin: 0 0 12px;
  font-size: 13px;
  color: #555;
}

.hint-text em {
  color: var(--red);
  font-style: normal;
  font-weight: 800;
}

.data-table {
  width: 100%;
  min-width: 1280px;
  border-collapse: collapse;
  background: #fff;
  box-shadow: var(--shadow);
  table-layout: fixed;
}

.vehicle-table {
  min-width: 1520px;
}

.vehicle-table .vehicle-col-id {
  width: 72px;
}

.vehicle-table .vehicle-col-config {
  width: 360px;
}

.vehicle-table .vehicle-col-brand,
.vehicle-table .vehicle-col-model {
  width: 130px;
}

.vehicle-table .vehicle-col-price {
  width: 112px;
}

.vehicle-table .vehicle-col-select,
.vehicle-table .vehicle-col-sort {
  width: 96px;
}

.vehicle-table .vehicle-col-actions {
  width: 128px;
}

.data-table th,
.data-table td {
  border: 1px solid #d8d8d8;
  padding: 6px 8px;
  text-align: center;
  font-size: 13px;
  vertical-align: middle;
}

.data-table th {
  background: #eef3fb;
  font-weight: 800;
  white-space: nowrap;
}

.data-table .filter-row th {
  background: #f8fafc;
  padding: 4px 6px;
}

.data-table .filter-row input,
.data-table .filter-row select {
  height: 28px;
  min-width: 0;
  font-size: 12px;
  font-weight: 400;
}

.data-table tfoot td {
  background: #fbfbf0;
}

.data-table input,
.data-table select,
.data-table textarea {
  width: 100%;
  min-width: 64px;
  height: 30px;
  padding: 2px 6px;
  border: 1px solid #cfcfcf;
  text-align: center;
  outline: none;
}

.data-table textarea {
  min-height: 48px;
  height: auto;
  line-height: 1.35;
  resize: vertical;
  overflow: hidden;
}

.vehicle-table .v-config,
.vehicle-table #newVehicleConfig {
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.data-table th:last-child,
.data-table td:last-child {
  width: 128px;
}

.data-table input:focus,
.data-table select:focus,
.data-table textarea:focus {
  border-color: var(--blue);
}

.row-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  justify-content: center;
}

.row-actions button {
  height: 28px;
  min-width: 48px;
  padding: 0 10px;
  border: 1px solid #c8c8c8;
  background: #f1f1f1;
  font-weight: 700;
  font-size: 12px;
  line-height: 28px;
}

.row-actions button.danger {
  border-color: var(--red);
  background: #fdeaea;
  color: var(--red);
}

.row-dirty td {
  background: #fff8e1;
}

.status-tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 800;
}

.status-tag.on {
  background: #e5f7e9;
  color: #1a8a3d;
}

.status-tag.off {
  background: #f4f4f4;
  color: #888;
}

/* ── 新增1：车型图片管理 ─────────────────────────────────────────── */
.image-manage-block {
  margin-bottom: 22px;
  padding: 12px 14px;
  border: 1px solid #cfe0f3;
  background: #f6faff;
}

.block-title {
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 800;
}

.block-title small {
  margin-left: 8px;
  color: #667;
  font-size: 12px;
  font-weight: 400;
}

.toolbar-hint {
  color: #667;
  font-size: 12px;
}

.image-table {
  min-width: 860px;
}

.image-table td:first-child {
  text-align: left;
  padding-left: 12px;
}

.img-thumb {
  width: 128px;
  height: 84px;
  object-fit: contain;
  background: #fff;
  border: 1px solid #ddd;
  display: inline-block;
}

.img-placeholder {
  display: inline-block;
  width: 128px;
  height: 84px;
  line-height: 84px;
  border: 1px dashed #bbb;
  background: #fafafa;
  color: #999;
  font-size: 12px;
}

.upload-label {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border: 1px solid #0078ff;
  background: #eaf3ff;
  color: #0078ff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.upload-label.upload-add {
  border-color: #1a8a3d;
  background: #e5f7e9;
  color: #1a8a3d;
}

/* ── 新增3：消息中心 ────────────────────────────────────────────── */
.message-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 14px;
  min-height: 520px;
}

.conversation-panel {
  border: 1px solid #d8d8d8;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 640px;
}

.conversation-panel .block-title {
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid #e5e5e5;
}

.conversation-list {
  overflow: auto;
  flex: 1;
}

.conversation-item {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid #efefef;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.conversation-item:hover {
  background: #f4f8ff;
}

.conversation-item.active {
  background: #e5f1ff;
  border-left: 3px solid var(--blue);
}

.conv-name {
  font-weight: 800;
  font-size: 13px;
}

.conv-name em {
  color: #888;
  font-style: normal;
  font-weight: 400;
}

.conv-info {
  color: #555;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-meta {
  color: #999;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.conv-note {
  color: #aaa;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-empty {
  padding: 30px 12px;
  color: #999;
  text-align: center;
}

.chat-panel {
  border: 1px solid #d8d8d8;
  background: #fff;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 520px;
  max-height: 640px;
}

.chat-header {
  padding: 10px 14px;
  border-bottom: 1px solid #e5e5e5;
  font-weight: 800;
  font-size: 14px;
  background: #f8fafc;
}

.chat-messages {
  flex: 1;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fbfcfe;
}

.chat-empty {
  margin: auto;
  color: #aaa;
}

.chat-bubble {
  max-width: 72%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-bubble.from-user {
  align-self: flex-start;
  background: #eef1f5;
  border: 1px solid #dfe3e9;
}

.chat-bubble.from-admin {
  align-self: flex-end;
  background: #0d65c7;
  color: #fff;
}

.chat-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid #e5e5e5;
  background: #f8fafc;
}

.chat-input-row textarea {
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid #bfc4ca;
  resize: vertical;
  font: inherit;
}

.chat-input-row button {
  height: 40px;
  align-self: end;
  padding: 0 20px;
  border: 0;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.unread-badge {
  display: inline-block;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #e60000;
  color: #fff;
  font-size: 11px;
  text-align: center;
}

.nav-badge {
  display: inline-block;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 8px;
  background: #e60000;
  color: #fff;
  font-size: 10px;
  vertical-align: top;
}

.nav-badge.hidden {
  display: none;
}

/* ── 广播管理 ──────────────────────────────────────────────────── */
#tab-broadcasts .table-toolbar {
  align-items: stretch;
}

#tab-broadcasts .table-toolbar input,
#tab-broadcasts .table-toolbar textarea {
  min-width: 0;
}

#tab-broadcasts .table-toolbar input {
  width: 220px;
}

#tab-broadcasts .table-toolbar textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #bfc4ca;
  font: inherit;
}

.left-cell {
  text-align: left;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  .admin-main {
    padding: 14px;
  }

  .welcome-text {
    margin-left: 0;
  }

  .pager {
    margin-left: 0;
  }
}
