/* ============================================================
   中央商品库 · 后台样式（单文件，无外部依赖）
   ============================================================ */

:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --bg: #f3f5f9;
  --card: #fff;
  --line: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --ok: #059669;   --ok-bg: #ecfdf5;
  --err: #dc2626;  --err-bg: #fef2f2;
  --warn: #b45309; --warn-bg: #fffbeb;
  --info: #1d4ed8; --info-bg: #eff6ff;
  --radius: 10px;
  --sidebar-w: 190px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------- 登录页 ---------------- */
.login-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #3b82f6 100%);
}
.login-card {
  background: #fff; width: 380px; max-width: 92vw; padding: 38px 34px;
  border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.25);
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; text-align: center; }
.login-sub { margin: 0 0 22px; text-align: center; color: var(--muted); font-size: 13px; }
.login-hint {
  margin: 18px 0 0; text-align: center; color: var(--muted); font-size: 12px;
  background: #f8fafc; border: 1px dashed var(--line); border-radius: 8px; padding: 8px;
}

/* ---------------- 表单基础 ---------------- */
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; outline: none; transition: .15s;
  font-family: inherit; background: #fff; color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.field input:disabled { background: #f3f4f6; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 18px; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-block; border: 0; border-radius: 8px; padding: 8px 16px;
  font-size: 14px; cursor: pointer; background: #eef2f7; color: var(--text);
  transition: .15s; line-height: 1.4; font-family: inherit; text-decoration: none !important;
}
.btn:hover { filter: brightness(.96); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: #fee2e2; color: var(--err); }
.btn-small { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; }
.btn-disabled { opacity: .5; pointer-events: none; }

/* ---------------- 后台布局 ---------------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: #0f1e33; color: #cbd5e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.side-brand { padding: 20px 18px; font-weight: 700; color: #fff; font-size: 15px; border-bottom: 1px solid rgba(255,255,255,.08); }
.side-nav { flex: 1; padding: 10px 8px; }
.side-nav a {
  display: block; padding: 10px 14px; margin: 2px 0; border-radius: 8px;
  color: #cbd5e1; font-size: 14px;
}
.side-nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.side-nav a.active { background: var(--primary); color: #fff; }
.side-foot { padding: 14px 18px; font-size: 12px; color: #64748b; border-top: 1px solid rgba(255,255,255,.08); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px; background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; position: sticky; top: 0; z-index: 50;
}
.page-title { font-size: 16px; margin: 0; font-weight: 600; }
.topbar-actions { display: flex; gap: 8px; }
.content { padding: 20px 22px; max-width: 1280px; width: 100%; }

/* ---------------- 提示 ---------------- */
.alert { border-radius: 8px; padding: 11px 14px; margin: 0 0 14px; font-size: 14px; }
.alert-ok   { background: var(--ok-bg);   color: var(--ok);   border: 1px solid #a7f3d0; }
.alert-err  { background: var(--err-bg);  color: var(--err);  border: 1px solid #fecaca; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #fde68a; }
.alert-info { background: var(--info-bg); color: var(--info); border: 1px solid #bfdbfe; }
.muted { color: var(--muted); font-size: 13px; }

/* ---------------- 卡片与区块 ---------------- */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px;
}
.panel h2 { font-size: 15px; margin: 0 0 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; flex-wrap: wrap; gap: 10px; }
.panel-head h2 { margin: 0; }

/* ---------------- 表格 ---------------- */
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: #f8fafc; color: var(--muted); font-weight: 500; font-size: 12px; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fafbfe; }
.table .nowrap { white-space: nowrap; }
.table .thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #f8fafc; display: block; }
.table .thumb-empty { width: 46px; height: 46px; border-radius: 6px; border: 1px dashed var(--line); display: flex; align-items: center; justify-content: center; color: #c0c7d2; font-size: 11px; }

/* 标签 */
.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag-ok    { background: #d1fae5; color: #047857; }
.tag-off   { background: #fee2e2; color: #b91c1c; }
.tag-draft { background: #fef3c7; color: #b45309; }
.tag-gray  { background: #f1f5f9; color: #64748b; }

/* ---------------- 工具条 ---------------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar input[type=text], .toolbar select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
  outline: none; font-family: inherit; background: #fff;
}
.toolbar input[type=text]:focus, .toolbar select:focus { border-color: var(--primary); }
.spacer { flex: 1; }

/* ---------------- 分页 ---------------- */
.pager { display: flex; align-items: center; gap: 6px; margin-top: 14px; flex-wrap: wrap; font-size: 13px; }
.pager a, .pager span {
  display: inline-block; padding: 5px 11px; border: 1px solid var(--line);
  border-radius: 7px; background: #fff; color: var(--text);
}
.pager a:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.pager .cur { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager .info { border: 0; background: none; color: var(--muted); }

/* ---------------- 空状态 ---------------- */
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------------- 工作台统计 ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stat-card .num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ---------------- 图片网格 ---------------- */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.img-card {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff;
  position: relative; transition: .15s;
}
.img-card:hover { box-shadow: 0 4px 16px rgba(15,30,51,.10); }
.img-card .img-box { height: 130px; background: #f8fafc; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.img-card .img-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.img-card .img-meta { padding: 8px 10px; }
.img-card .img-name { font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.img-card .img-sub { font-size: 11px; color: var(--muted); margin-top: 2px; display: flex; justify-content: space-between; }
.img-card .img-check {
  position: absolute; top: 8px; left: 8px; width: 18px; height: 18px; cursor: pointer;
  accent-color: var(--primary);
}
.img-card .img-del {
  position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.55); color: #fff;
  border: 0; border-radius: 6px; padding: 2px 7px; font-size: 12px; cursor: pointer; opacity: 0; transition: .15s;
}
.img-card:hover .img-del { opacity: 1; }
.img-card .ref-badge {
  position: absolute; bottom: 40px; right: 8px; background: #d1fae5; color: #047857;
  font-size: 10px; padding: 1px 7px; border-radius: 10px;
}

/* 文件夹树 */
.img-layout { display: flex; gap: 16px; align-items: flex-start; }
.folder-panel { width: 200px; flex-shrink: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.folder-panel h3 { font-size: 13px; margin: 0 0 10px; color: var(--muted); }
.folder-tree { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.folder-tree li { padding: 0; margin: 1px 0; }
.folder-tree a { display: block; padding: 6px 9px; border-radius: 7px; color: var(--text); }
.folder-tree a:hover { background: #f1f5f9; text-decoration: none; }
.folder-tree a.cur { background: var(--primary); color: #fff; }
.folder-tree .sub { padding-left: 16px; }
.folder-ops { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }

/* 上传区 */
.upload-zone {
  border: 2px dashed var(--line); border-radius: 10px; padding: 22px;
  text-align: center; color: var(--muted); cursor: pointer; transition: .15s;
  background: #fbfcfe; margin-bottom: 14px;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--primary); background: #eff6ff; color: var(--primary); }
.upload-zone input[type=file] { display: none; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 12px; width: 860px; max-width: 96vw; max-height: 88vh;
  display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.modal-head {
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 15px;
}
.modal-head .x { border: 0; background: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; padding: 0 4px; }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 12px 20px; border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.modal .picker-toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.modal .picker-toolbar select, .modal .picker-toolbar input {
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; font-family: inherit; outline: none;
}
.modal .img-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.modal .img-card .img-box { height: 100px; }

/* ---------------- 编辑表单 ---------------- */
.form-panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 16px; }
.form-panel h2 { font-size: 15px; margin: 0 0 16px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; }

/* 主图选择 */
.pic-picker { display: flex; align-items: center; gap: 12px; }
.pic-preview {
  width: 90px; height: 90px; border: 1px dashed var(--line); border-radius: 10px;
  display: flex; align-items: center; justify-content: center; overflow: hidden; background: #f8fafc; flex-shrink: 0;
}
.pic-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pic-preview .none { font-size: 12px; color: #b0b8c4; }

/* 轮播列表 */
.gallery-list { display: flex; flex-wrap: wrap; gap: 10px; }
.gallery-item { position: relative; width: 96px; height: 96px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.gallery-item .ops { position: absolute; inset: auto 0 0 0; background: rgba(15,23,42,.6); display: flex; justify-content: space-between; }
.gallery-item .ops button { flex: 1; border: 0; background: none; color: #fff; font-size: 11px; padding: 3px 0; cursor: pointer; }

/* 参数行 */
.attr-rows { display: flex; flex-direction: column; gap: 8px; }
.attr-row { display: flex; gap: 8px; align-items: center; }
.attr-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; font-family: inherit; outline: none; }
.attr-row input.name { max-width: 220px; }
.attr-row .del { border: 0; background: #fee2e2; color: var(--err); border-radius: 7px; padding: 8px 11px; cursor: pointer; font-size: 13px; }

/* 富文本区域 */
.editor-wrap { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.editor-toolbar-extra { display: flex; gap: 8px; margin-bottom: 8px; }

/* 简版编辑器容器 */
#editor-content { min-height: 240px; }
.w-e-text-container { min-height: 240px !important; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: column; }
  .side-nav { display: flex; flex-wrap: wrap; }
  .side-nav a { margin: 2px; }
  .side-foot { display: none; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .img-layout { flex-direction: column; }
  .folder-panel { width: 100%; }
}
/* ---------------- 分类 / 行业 拖拽排序 ---------------- */
tr[data-cat], tr[data-ind] { cursor: grab; }
tr[data-cat]:active, tr[data-ind]:active { cursor: grabbing; }
tr[data-cat].dragging, tr[data-ind].dragging { opacity: .45; }
.drag-handle { color: #b6bfcc; margin-right: 6px; font-weight: 700; user-select: none; display: inline-block; }
tr[data-cat]:hover .drag-handle, tr[data-ind]:hover .drag-handle { color: var(--primary); }
