/* ============================================================
   商用车之家 · 管理后台样式
   Design tokens + 布局 + 组件
   ============================================================ */
:root {
  --brand-50: #eef4ff;
  --brand-100: #dbe7ff;
  --brand-300: #93b4fd;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;
  --ink-900: #0f172a;
  --ink-700: #334155;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --line: #e5e9f2;
  --line-strong: #d7ddea;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #e11d48;
  --radius-lg: 16px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 6px 24px rgba(15, 23, 42, .08);
  --shadow-lg: 0 24px 64px rgba(15, 23, 42, .18);
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.55 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink-900);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--ink-500); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------- 登录 ---------------- */
.login { display: grid; grid-template-columns: 1.1fr .9fr; height: 100%; }
.login-art {
  position: relative; overflow: hidden; color: #fff;
  background: radial-gradient(1200px 600px at 10% 10%, #1e40af 0%, transparent 60%),
              radial-gradient(900px 500px at 90% 90%, #0ea5e9 0%, transparent 55%),
              linear-gradient(140deg, #0b1220, #101c33 60%, #0b1220);
  display: grid; place-items: center;
}
.login-art::after {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, .08) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(circle at 30% 30%, #000 20%, transparent 75%);
}
.login-art-inner { position: relative; max-width: 420px; padding: 40px; }
.login-art h1 { font-size: 34px; margin: 18px 0 8px; letter-spacing: .5px; }
.login-art p { color: #a9b8d4; margin: 0 0 22px; }
.login-art ul { margin: 0; padding-left: 18px; color: #c8d6ee; line-height: 2; }
.login-form {
  display: grid; align-content: center; gap: 16px; padding: 48px min(8vw, 96px);
  background: #fff;
}
.login-form h2 { margin: 0; font-size: 22px; }
.login-form .field span { font-size: 12px; color: var(--ink-500); }
.login-form .btn { margin-top: 6px; height: 44px; font-size: 15px; }
.form-error { color: var(--danger); min-height: 20px; margin: 0; font-size: 13px; }
.logo-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, #60a5fa, #2563eb); color: #fff; font-weight: 700; font-size: 18px;
  box-shadow: 0 8px 20px rgba(37, 99, 235, .35);
}
.logo-mark.lg { width: 56px; height: 56px; border-radius: 16px; font-size: 26px; }

/* ---------------- 布局 ---------------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100%; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #0b1220 0%, #101a2d 40%, #0d1526 100%);
  color: #b9c8e2; border-right: 1px solid rgba(255, 255, 255, .04);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 18px; }
.brand-text { display: grid; line-height: 1.25; }
.brand-text strong { color: #fff; font-size: 15px; letter-spacing: .4px; }
.brand-text span { color: #7f92b3; font-size: 11.5px; }
.menu { flex: 1; overflow: auto; padding: 8px 12px 16px; display: grid; gap: 2px; align-content: start; }
.menu-group { margin: 14px 8px 6px; font-size: 11px; letter-spacing: .12em; color: #5f7291; text-transform: uppercase; }
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px;
  background: none; border: 0; border-radius: 10px; color: #b9c8e2; font-size: 13.5px;
  cursor: pointer; transition: background .16s ease, color .16s ease, transform .16s ease;
  position: relative;
}
.menu button svg { opacity: .85; }
.menu button:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.menu button.active {
  background: linear-gradient(135deg, rgba(59, 130, 246, .95), rgba(37, 99, 235, .95));
  color: #fff; box-shadow: 0 8px 18px rgba(37, 99, 235, .35);
}
.menu button.active svg { opacity: 1; }
.menu .badge {
  margin-left: auto; font-size: 11px; padding: 1px 7px; border-radius: 999px;
  background: rgba(255, 255, 255, .12); color: #dbe6fb;
}
.sidebar-foot {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, .06);
}
.avatar {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #38bdf8, #6366f1); color: #fff; font-weight: 600; font-size: 13px;
}
.user-meta { display: grid; line-height: 1.2; min-width: 0; }
.user-meta strong { color: #fff; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta span { color: #7f92b3; font-size: 11px; }
.icon-btn {
  margin-left: auto; width: 30px; height: 30px; display: grid; place-items: center;
  background: rgba(255, 255, 255, .06); color: #b9c8e2; border: 0; border-radius: 8px; cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, .14); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 16px 26px; background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--ink-400); font-size: 12.5px; }
.crumbs h1 { font-size: 17px; margin: 0; color: var(--ink-900); font-weight: 650; }
.crumb-sep { width: 12px; height: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.content { padding: 22px 26px 48px; }

/* ---------------- 按钮 / 表单 ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: 10px; border: 1px solid transparent; background: #fff; color: var(--ink-700);
  font-size: 13.5px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: all .16s ease;
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: linear-gradient(135deg, #3b82f6, #2563eb); color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 235, .28); }
.btn.primary:hover { box-shadow: 0 10px 22px rgba(37, 99, 235, .34); }
.btn.ghost { border-color: var(--line-strong); color: var(--ink-700); background: #fff; }
.btn.ghost:hover { border-color: var(--brand-300); color: var(--brand-700); background: var(--brand-50); }
.btn.danger { background: #fff1f3; color: var(--danger); border-color: #ffd7de; }
.btn.danger:hover { background: #ffe4e9; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .55; pointer-events: none; }

.field { display: grid; gap: 6px; }
.field > span, .field > label { font-size: 12.5px; color: var(--ink-500); }
.field .hint { font-size: 11.5px; color: var(--ink-400); }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink-900); background: #fff;
  border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 11px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 4px var(--brand-50);
}
textarea { min-height: 96px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; line-height: 1.5; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-400) 50%), linear-gradient(135deg, var(--ink-400) 50%, transparent 50%); background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }

/* ---------------- 卡片 / 统计 ---------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  position: relative; overflow: hidden; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow-sm);
}
.stat::after {
  content: ""; position: absolute; right: -24px; top: -24px; width: 76px; height: 76px; border-radius: 50%;
  background: linear-gradient(135deg, rgba(59, 130, 246, .14), rgba(99, 102, 241, .04));
  pointer-events: none;
}
.stat .num { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.stat .label { color: var(--ink-500); font-size: 12.5px; margin-top: 2px; }
.stat .trend { margin-top: 10px; font-size: 12px; color: var(--ink-400); }
.panel {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); margin-bottom: 16px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--line);
}
.panel-head h3 { margin: 0; font-size: 14px; font-weight: 650; }
.panel-body { padding: 16px 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }

/* ---------------- 工具栏 ---------------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.toolbar select { width: auto; min-width: 108px; flex: none; height: 36px; }
#pageSize { min-width: 116px; }
.search-box { position: relative; width: min(320px, 100%); }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-400); }
.search-box input { padding-left: 34px; height: 36px; border-radius: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border-radius: 999px; background: var(--brand-50); color: var(--brand-700);
  font-size: 12px; border: 1px solid var(--brand-100);
}
.chip button { background: none; border: 0; color: inherit; cursor: pointer; padding: 0; display: grid; }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow: auto; max-height: calc(100vh - 310px); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 2; background: #f8fafd; color: var(--ink-500);
  font-weight: 600; font-size: 12px; text-align: left; padding: 11px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none;
}
thead th.sortable { cursor: pointer; }
thead th.sortable:hover { color: var(--brand-700); }
thead th .sort-ind { margin-left: 4px; color: var(--brand-600); }
tbody td { padding: 10px 12px; border-bottom: 1px solid #eef1f7; vertical-align: middle; }
tbody tr:hover td { background: #fafcff; }
tbody tr.selected td { background: var(--brand-50); }
td.actions { white-space: nowrap; text-align: right; }
td.actions .btn { height: 28px; padding: 0 9px; font-size: 12px; margin-left: 6px; }
.thumb {
  width: 44px; height: 32px; border-radius: 6px; object-fit: cover; background: #f1f4f9;
  border: 1px solid var(--line); display: block; cursor: zoom-in;
}
.thumb.empty { display: grid; place-items: center; color: var(--ink-400); font-size: 10px; cursor: default; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; background: #e8f7ee; color: #15803d; }
.tag.off { background: #f2f4f8; color: var(--ink-500); }
.tag.warn { background: #fff7e6; color: #b45309; }
.cell-ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-700); }
.cell-json { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; color: var(--ink-400); }
.empty-state { padding: 56px 20px; text-align: center; color: var(--ink-400); }
.empty-state svg { width: 46px; height: 46px; opacity: .4; margin-bottom: 10px; }

/* ---------------- 分页 ---------------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager .meta { color: var(--ink-500); font-size: 12.5px; }
.pager .pages { display: flex; align-items: center; gap: 4px; }
.pager button {
  min-width: 32px; height: 32px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: #fff; color: var(--ink-700); cursor: pointer; font-size: 12.5px;
}
.pager button:hover { border-color: var(--brand-300); color: var(--brand-700); }
.pager button.active { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.pager button[disabled] { opacity: .45; pointer-events: none; }
.pager select { width: 92px; height: 32px; }

/* ---------------- 对话框 ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(3px); display: grid; place-items: center; padding: 24px;
}
.dialog {
  width: min(920px, 100%); max-height: calc(100vh - 64px); background: #fff;
  border-radius: 18px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: 0; } to { transform: none; opacity: 1; } }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dialog-head h3 { margin: 0; font-size: 15.5px; }
.dialog-head .icon-btn { background: #f2f5fa; color: var(--ink-500); }
.dialog-head .icon-btn:hover { background: #e8edf6; color: var(--ink-900); }
.dialog-body { padding: 18px 20px; overflow: auto; }
.dialog-body.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.dialog-body .full { grid-column: 1 / -1; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: #fbfcfe; border-radius: 0 0 18px 18px; }

/* 图片输入 */
.image-field { display: flex; gap: 10px; align-items: flex-start; }
.image-field .preview {
  width: 74px; height: 54px; border-radius: 8px; border: 1px dashed var(--line-strong);
  display: grid; place-items: center; color: var(--ink-400); font-size: 11px; overflow: hidden; flex: none;
}
.image-field .preview img { width: 100%; height: 100%; object-fit: cover; }
.image-field .ops { display: grid; gap: 6px; flex: 1; }
.image-list-editor { display: grid; gap: 8px; }
.image-list-editor .row { display: flex; gap: 8px; align-items: center; }
.image-list-editor .row img { width: 52px; height: 38px; border-radius: 6px; object-fit: cover; border: 1px solid var(--line); }
.json-tools { display: flex; justify-content: space-between; align-items: center; }
.json-tools .err { color: var(--danger); font-size: 11.5px; }

/* 导入 */
.dropzone {
  border: 2px dashed var(--line-strong); border-radius: 14px; padding: 34px 20px; text-align: center;
  color: var(--ink-500); cursor: pointer; transition: all .16s ease; background: #fbfcff;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--brand-500); background: var(--brand-50); color: var(--brand-700); }
.dropzone svg { width: 34px; height: 34px; margin-bottom: 8px; }
.import-result { display: grid; gap: 10px; margin-top: 14px; }
.import-result .stats { display: flex; gap: 12px; }
.import-result .stat-line { padding: 10px 14px; border-radius: 10px; background: #f7f9fd; font-size: 13px; }
.import-result .stat-line b { font-size: 16px; }
.err-table { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.err-table table { font-size: 12px; }

/* toast / 确认 */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: #0f172a; color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 13px;
  box-shadow: var(--shadow); z-index: 60; display: flex; align-items: center; gap: 8px;
  animation: rise .2s ease;
}
.toast.error { background: var(--danger); }
@keyframes rise { from { transform: translate(-50%, 8px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* i18n */
.split { display: grid; grid-template-columns: 300px 1fr; gap: 16px; }
.picker { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.picker .head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.picker .list { max-height: calc(100vh - 340px); overflow: auto; }
.picker .item { display: flex; justify-content: space-between; gap: 8px; width: 100%; padding: 9px 14px; background: none; border: 0; border-bottom: 1px solid #f1f4f9; cursor: pointer; font-size: 12.5px; text-align: left; color: var(--ink-700); }
.picker .item:hover { background: #f8fafd; }
.picker .item.active { background: var(--brand-50); color: var(--brand-700); }
.picker .item span { color: var(--ink-400); font-size: 11.5px; }
.editor-panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.editor-panel .head { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.editor-panel .body { padding: 16px; display: grid; gap: 12px; }
.lang-block { display: grid; gap: 6px; }
.lang-block .lang-head { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--ink-500); }
.lang-block textarea { min-height: 150px; }

/* 变体 */
.variant-list { border: 1px solid var(--line); border-radius: 12px; max-height: 320px; overflow: auto; }
.variant-list table { font-size: 12.5px; }

/* 响应式 */
@media (max-width: 1180px) {
  .app { grid-template-columns: 76px 1fr; }
  .brand-text, .menu-group, .menu button span, .user-meta { display: none; }
  .menu button { justify-content: center; }
  .sidebar-foot { justify-content: center; }
  .split { grid-template-columns: 1fr; }
  .content { padding: 18px; }
}
@media (max-width: 720px) {
  .topbar { padding: 12px 14px; }
  .dialog-body.form-grid { grid-template-columns: 1fr; }
  .toolbar .search-box { width: 100%; }
}
