:root {
  --navy: #202850;
  --navy-2: #2c355f;
  --ink: #2b3048;
  --muted: #7c8093;
  --ivory: #f7f4ec;
  --paper: #fffdf8;
  --line: #e8e1d1;
  --line-2: #f0ebdf;
  --brass: #8f6c2e;
  --gold: #c9a25e;
  --danger: #b4483c;
  --green: #3f7a5a;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(32, 40, 80, .06);
  --shadow: 0 10px 30px rgba(32, 40, 80, .10);
  --shadow-lg: 0 24px 60px rgba(32, 40, 80, .18);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: "Songti SC", "Noto Serif SC", "SimSun", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ivory);
  color: var(--ink);
  font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.spacer { flex: 1; }

.ic {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ------------------------------------------------------------- 登录 */
.login {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 480px at 15% 0%, #2b355f 0%, transparent 60%),
    radial-gradient(700px 420px at 100% 100%, #3a2f1b 0%, transparent 55%),
    var(--navy);
  z-index: 60;
}

.login::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 44px 44px;
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 380px;
  padding: 34px 32px 26px;
  border-radius: 18px;
  background: var(--paper);
  box-shadow: var(--shadow-lg);
  z-index: 1;
}

.login-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 28px; }
.login-brand img { width: 46px; height: 46px; object-fit: contain; }
.login-brand h1 { margin: 0; font: 600 19px/1.3 var(--serif); letter-spacing: .04em; color: var(--navy); }
.login-brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; letter-spacing: .14em; }

.login-error { min-height: 20px; margin: 10px 0 4px; color: var(--danger); font-size: 12px; }
.login-hint { margin: 16px 0 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.login-hint code { background: var(--ivory); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line); }

/* ------------------------------------------------------------- 基础控件 */
.field { display: block; margin-bottom: 14px; }
.field > span {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
}
.field > span i { font-style: normal; font-weight: 400; color: var(--muted); font-size: 11.5px; }

.field input,
.field select,
.field textarea,
.select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-size: 13.5px;
}
.field textarea { resize: vertical; line-height: 1.7; }
.field input:focus,
.field select:focus,
.field textarea:focus,
.select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 162, 94, .18);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .06s, box-shadow .15s;
}
.btn:hover { background: #fbf8f0; border-color: #d9d0bb; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--navy-2); border-color: var(--navy-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink); }
.btn-ghost:hover { background: rgba(32, 40, 80, .06); border-color: transparent; }
.btn-danger { background: #fff; border-color: #eccfcb; color: var(--danger); }
.btn-danger:hover { background: #fdf3f2; border-color: #e0b4ae; }
.btn-danger-text { color: var(--danger); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; }
.btn-block { width: 100%; height: 42px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  transition: background .15s;
}
.icon-btn:hover { background: rgba(32, 40, 80, .07); }
.icon-btn.sm { width: 26px; height: 26px; font-size: 15px; color: var(--muted); }
.icon-btn.sm:hover { color: var(--navy); }

/* ------------------------------------------------------------- 主框架 */
.app { height: 100%; display: flex; flex-direction: column; }

.topbar {
  height: 64px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 20px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 210px; }
.brand img { width: 34px; height: 34px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font: 600 15px/1.3 var(--serif); letter-spacing: .05em; color: var(--navy); }
.brand-text span { color: var(--muted); font-size: 11px; letter-spacing: .18em; }

.topbar-search {
  position: relative;
  flex: 1;
  max-width: 520px;
  display: flex;
  align-items: center;
}
.topbar-search .ic { position: absolute; left: 12px; color: var(--muted); }
.topbar-search input {
  width: 100%;
  height: 38px;
  padding: 0 44px 0 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ivory);
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.topbar-search input:focus { background: #fff; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,162,94,.16); }
.topbar-search kbd {
  position: absolute;
  right: 10px;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--muted);
  font: 11px/1.6 var(--sans);
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.layout { flex: 1; display: flex; min-height: 0; }

/* ------------------------------------------------------------- 侧栏 */
.sidebar {
  width: 226px;
  flex: none;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #fbf8f1;
  min-height: 0;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 10px;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: .14em;
}

.cat-list { flex: 1; overflow: auto; padding: 0 10px 14px; }
.cat-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--ink);
  cursor: pointer;
  transition: background .12s, color .12s;
  user-select: none;
}
.cat-item:hover { background: rgba(32, 40, 80, .05); }
.cat-item.on { background: var(--navy); color: #fff; }
.cat-item.on .cat-n { color: rgba(255,255,255,.6); }
.cat-item .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--gold); flex: none; }
.cat-item .cat-t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.cat-item .cat-n { color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.cat-item .cat-edit { opacity: 0; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 6px; }
.cat-item:hover .cat-edit { opacity: .7; }
.cat-item .cat-edit:hover { background: rgba(255,255,255,.2); opacity: 1; }
.cat-item.on .cat-edit:hover { background: rgba(255,255,255,.16); }

.side-foot {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  border-top: 1px solid var(--line);
  background: var(--line);
}
.side-foot .stat { background: #fbf8f1; padding: 12px 6px; text-align: center; }
.side-foot .stat span { display: block; font: 600 17px/1.2 var(--serif); color: var(--navy); font-variant-numeric: tabular-nums; }
.side-foot .stat em { font-style: normal; color: var(--muted); font-size: 11px; }

/* ------------------------------------------------------------- 主区 */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 20px 22px 0; }

.main-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 14px; }
.main-head h2 { margin: 0; font: 600 21px/1.3 var(--serif); letter-spacing: .05em; color: var(--navy); }
.main-head p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.head-actions { margin-left: auto; display: flex; gap: 9px; align-items: center; }
.head-actions .select { width: 120px; height: 36px; padding: 0 10px; }

.draft-hint {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  padding: 8px 13px;
  border: 1px solid #e8dcc0;
  border-radius: 10px;
  background: #fdf9ef;
  color: var(--muted);
  font-size: 12.5px;
}
.draft-hint b { color: var(--brass); font-variant-numeric: tabular-nums; }
.draft-hint .btn { margin-left: auto; }

.bulkbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
  padding: 9px 14px;
  border: 1px solid #e3d5b6;
  border-radius: 10px;
  background: #fdf8ea;
  box-shadow: var(--shadow-sm);
  animation: slideDown .18s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } }
.bulkbar > span { font-size: 12.5px; color: var(--brass); }
.bulkbar b { font-variant-numeric: tabular-nums; }
.bulk-actions { display: flex; gap: 6px; margin-left: auto; }

.table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow-sm);
}

.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 11px 12px;
  background: #faf7ef;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .08em;
  text-align: left;
  white-space: nowrap;
}
.table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
  font-size: 13px;
}
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: #fdfaf3; }
.table tbody tr.sel { background: #fbf5e6; }
.table tbody tr:last-child td { border-bottom: 0; }

.c-check { width: 38px; }
.c-img { width: 62px; }
.c-cat { width: 112px; }
.c-brand { width: 84px; }
.c-price { width: 108px; }
.c-param { width: 230px; }
.c-state { width: 76px; }
.c-act { width: 74px; }

input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--navy);
  cursor: pointer;
}

.thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--ivory);
  border: 1px solid var(--line-2);
  display: block;
}
.pname { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pname strong {
  font-weight: 600;
  color: var(--navy);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 330px;
}
.pname span { color: var(--muted); font-size: 11.5px; letter-spacing: .02em; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--ivory);
  border: 1px solid var(--line);
  color: #6a6f84;
  font-size: 11.5px;
  white-space: nowrap;
}
.tag.gas { background: #f2f6fb; border-color: #dbe6f3; color: #3d6187; }

.price-cell { font-weight: 600; color: var(--brass); font-variant-numeric: tabular-nums; }
.price-cell small { color: var(--muted); font-weight: 400; }
.param-cell { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 230px; }

.state { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--green); white-space: nowrap; }
.state.off { color: var(--muted); }
.state .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.row-act { display: flex; gap: 2px; justify-content: flex-end; opacity: 0; transition: opacity .12s; }
tr:hover .row-act { opacity: 1; }
.row-act .icon-btn { width: 28px; height: 28px; }
.row-act .icon-btn:hover { background: rgba(32, 40, 80, .08); }

.empty { display: grid; place-items: center; gap: 4px; padding: 70px 0; color: var(--muted); }
.empty .ic { width: 30px; height: 30px; opacity: .5; }
.empty p { margin: 6px 0 0; font-weight: 600; color: var(--ink); }
.empty span { font-size: 12px; }
.table-wrap .empty { display: none; }
.table-wrap.is-empty .empty { display: grid; }
.table-wrap.is-empty .table { display: none; }

.pager {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 10px 2px;
  background: var(--ivory);
}
.pager .pg {
  min-width: 32px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.pager .pg:hover { border-color: var(--gold); color: var(--navy); }
.pager .pg.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.pager .pg:disabled { opacity: .4; cursor: default; }
.pager .info { margin-right: 8px; color: var(--muted); font-size: 12px; }

/* ------------------------------------------------------------- 抽屉 */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(24, 29, 52, .38);
  backdrop-filter: blur(1px);
  z-index: 20;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 520px;
  max-width: 94vw;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  box-shadow: var(--shadow-lg);
  z-index: 21;
  animation: drawerIn .22s cubic-bezier(.2, .7, .3, 1);
}
@keyframes drawerIn { from { transform: translateX(28px); opacity: .6; } }

.drawer-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h3 { margin: 0; font: 600 18px/1.35 var(--serif); letter-spacing: .04em; color: var(--navy); }
.drawer-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.drawer-head .icon-btn { margin-left: auto; }

.drawer-body { flex: 1; overflow: auto; padding: 18px 20px; }
.drawer-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 20px;
  border-top: 1px solid var(--line);
  background: #fdfaf4;
}

.img-edit { display: flex; gap: 16px; margin-bottom: 20px; }
.img-preview {
  position: relative;
  width: 132px;
  height: 132px;
  flex: none;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--ivory);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.img-preview img { width: 100%; height: 100%; object-fit: cover; display: none; }
.img-preview.has img { display: block; }
.img-preview span { color: var(--muted); font-size: 12px; }
.img-preview.has span { display: none; }
.img-meta { display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.img-meta strong { font-size: 13px; }
.img-meta p { margin: 0 0 8px; color: var(--muted); font-size: 12px; }
.img-meta .row { display: flex; gap: 7px; }
.img-meta .btn { cursor: pointer; }

/* 首页轮播图 */
.hero-hint { margin: 0 0 14px; color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.hero-editor { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; max-height: 52vh; overflow: auto; }
.hero-empty {
  padding: 22px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--ivory);
}
.hero-item {
  display: flex;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--ivory);
}
.hero-thumb {
  position: relative;
  width: 116px;
  height: 87px;
  flex: none;
  border: 1px dashed var(--line);
  border-radius: 9px;
  background: #fff;
  overflow: hidden;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.hero-thumb img { width: 100%; height: 100%; object-fit: cover; display: none; }
.hero-thumb.has img { display: block; }
.hero-thumb span { color: var(--muted); font-size: 11.5px; }
.hero-thumb.has span { display: none; }
.hero-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.hero-fields > input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  outline: none;
}
.hero-fields > input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201, 162, 94, .18); }
.hero-act { display: flex; flex-direction: column; gap: 5px; justify-content: center; flex: none; }
.hero-act .btn { height: 26px; padding: 0 9px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.span-2 { grid-column: span 2; }

.switch-row { display: flex; gap: 24px; margin: 4px 0 8px; }
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch span {
  position: relative;
  width: 38px;
  height: 21px;
  border-radius: 20px;
  background: #ddd6c6;
  transition: background .18s;
  flex: none;
}
.switch span::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .18s;
}
.switch input:checked + span { background: var(--navy); }
.switch input:checked + span::after { transform: translateX(17px); }
.switch em { font-style: normal; font-size: 12.5px; color: var(--ink); }

/* ------------------------------------------------------------- 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 29, 52, .4);
  z-index: 40;
  animation: fade .15s ease;
}
.modal-card {
  width: 420px;
  max-width: 100%;
  max-height: 88vh;
  overflow: auto;
  padding: 22px;
  border-radius: 14px;
  background: var(--paper);
  box-shadow: var(--shadow-lg);
}
.modal-card.wide { width: 720px; }
.modal-card h3 { margin: 0 0 18px; font: 600 18px/1.3 var(--serif); letter-spacing: .04em; color: var(--navy); }
.modal-foot { display: flex; align-items: center; gap: 8px; margin-top: 20px; }

.gallery {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  max-height: 56vh;
  overflow: auto;
}
.gallery button {
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: 9px;
  overflow: hidden;
  background: var(--ivory);
}
.gallery img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery button:hover { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(201,162,94,.2); }

.toast {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 70;
  animation: toastIn .2s ease;
}
.toast.err { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -8px); } }

/* ------------------------------------------------------------- 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #d9d1bf; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: #c2b69c; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1080px) {
  .c-param, .c-brand { display: none; }
  .sidebar { width: 188px; }
}
@media (max-width: 760px) {
  .c-cat, .c-price { display: none; }
  .sidebar { display: none; }
  .main { padding: 14px 12px 0; }
  .topbar { gap: 10px; padding: 0 12px; }
  .brand-text, .topbar-search kbd { display: none; }
  .topbar-actions .btn { padding: 0 9px; }
  .drawer { width: 100%; }
}
