/* ==========================================================
   知命 · Admin 运营后台样式（独立于前台水墨风格）
   ========================================================== */
:root {
  --bg: #f5f6f8;
  --side-bg: #23272e;
  --side-text: #aab2bd;
  --card: #ffffff;
  --line: #e5e8ee;
  --ink: #24292f;
  --ink-soft: #57606a;
  --ink-faint: #8b949e;
  --brand: #8a6d3b;
  --brand-soft: #f6f1e7;
  --ok: #2da44e;
  --warn: #bf8700;
  --err: #cf222e;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 24, 30, 0.07);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}
.hidden { display: none !important; }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 按钮 ---------- */
.abtn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13.5px;
  transition: 0.15s;
}
.abtn:hover { border-color: var(--brand); color: var(--brand); }
.abtn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.abtn.primary:hover { opacity: 0.9; color: #fff; }
.abtn.danger:hover { border-color: var(--err); color: var(--err); }
.abtn.small { padding: 4px 10px; font-size: 12.5px; }
.abtn:disabled { opacity: 0.5; cursor: wait; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #eef0f3 0%, #e8e3d8 100%);
}
.login-card {
  width: 360px;
  max-width: 92vw;
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(30, 34, 40, 0.12);
  padding: 34px 32px 24px;
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-seal {
  display: inline-flex;
  width: 46px; height: 46px;
  align-items: center; justify-content: center;
  background: var(--brand);
  color: #fff;
  border-radius: 12px;
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 10px;
}
.login-brand h1 { font-size: 18px; }
.login-brand p { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }
.login-note { font-size: 11.5px; color: var(--ink-faint); text-align: center; margin-top: 14px; }

.afield { margin-bottom: 14px; }
.afield label { display: block; font-size: 12.5px; color: var(--ink-soft); margin-bottom: 5px; }
.afield input, .afield select, .afield textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fbfcfd;
  color: var(--ink);
}
.afield input:focus, .afield select:focus, .afield textarea:focus {
  outline: none;
  border-color: var(--brand);
}
.afield textarea { resize: vertical; min-height: 70px; }
.al-msg {
  font-size: 12.5px;
  border-radius: 8px;
  padding: 8px 11px;
  margin-bottom: 12px;
}
.al-msg.err { background: #fff1f0; color: var(--err); }
.al-msg.ok { background: #f0fff4; color: var(--ok); }

/* ---------- 外壳布局 ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 216px;
  flex: 0 0 216px;
  background: var(--side-bg);
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid #2f343c;
}
.side-seal {
  display: inline-flex;
  width: 32px; height: 32px;
  align-items: center; justify-content: center;
  background: var(--brand);
  color: #fff;
  border-radius: 8px;
  font-size: 17px;
  font-weight: 600;
}
.side-name { color: #e6e8eb; font-size: 14.5px; font-weight: 600; }
.side-nav { flex: 1; padding: 10px 10px; }
.side-nav a {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 2px;
  color: var(--side-text);
}
.side-nav a:hover { background: #2c313a; color: #e6e8eb; }
.side-nav a.active { background: var(--brand); color: #fff; }
.nav-group {
  font-size: 11px;
  color: #6b7280;
  letter-spacing: 2px;
  padding: 14px 12px 6px;
}
.side-foot { padding: 14px 16px; border-top: 1px solid #2f343c; }
.side-admin { font-size: 12px; color: var(--side-text); margin-bottom: 10px; word-break: break-all; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 14px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar h2 { font-size: 16.5px; }
.topbar-right { font-size: 12.5px; color: var(--ink-faint); }
.content { padding: 22px 26px 40px; flex: 1; }

/* ---------- 统计卡片 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.stat-v { font-size: 24px; font-weight: 700; letter-spacing: -0.5px; }
.stat-k { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.stat-v.small { font-size: 19px; }

/* ---------- 面板 / 表格 ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-head h3 { font-size: 14.5px; }
.panel-head .ph-tools { display: flex; gap: 8px; align-items: center; }
.panel-body { padding: 14px 16px; }
.panel-body.flush { padding: 0; }

.atable { width: 100%; border-collapse: collapse; font-size: 13px; }
.atable th {
  text-align: left;
  font-size: 12px;
  color: var(--ink-faint);
  font-weight: 600;
  padding: 10px 14px;
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.atable td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}
.atable tr:last-child td { border-bottom: none; }
.atable tr:hover td { background: #fafbfc; }
.atable .t-sub { font-size: 11.5px; color: var(--ink-faint); }
.td-actions { white-space: nowrap; display: flex; gap: 6px; }

.badge {
  display: inline-block;
  font-size: 11.5px;
  border-radius: 20px;
  padding: 2px 10px;
  background: #eef0f3;
  color: var(--ink-soft);
  white-space: nowrap;
}
.badge.ok { background: #f0fff4; color: var(--ok); }
.badge.warn { background: #fff8e6; color: var(--warn); }
.badge.err { background: #fff1f0; color: var(--err); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }

.empty-tip { text-align: center; color: var(--ink-faint); font-size: 13px; padding: 30px 0; }
.section-note {
  font-size: 12.5px;
  color: var(--ink-soft);
  background: var(--brand-soft);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  line-height: 1.7;
}

/* ---------- 分页 ---------- */
.pager { display: flex; gap: 8px; align-items: center; padding: 12px 16px; font-size: 12.5px; color: var(--ink-soft); }

/* ---------- 图表 ---------- */
.chart-box { padding: 16px; }
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.bar-label { width: 76px; font-size: 11.5px; color: var(--ink-soft); text-align: right; white-space: nowrap; }
.bar-track { flex: 1; height: 16px; background: #f0f2f5; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 4px; min-width: 1px; }
.bar-val { width: 52px; font-size: 11.5px; color: var(--ink-soft); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- 商品图 ---------- */
.p-img {
  width: 40px; height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--brand-soft);
  display: block;
}
.p-img-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand);
  font-weight: 600;
}
.img-editor { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.img-cell { position: relative; width: 74px; height: 74px; }
.img-cell img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.img-cell .img-del {
  position: absolute;
  top: -6px; right: -6px;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: none;
  background: var(--err);
  color: #fff;
  font-size: 12px;
  line-height: 1;
}
.img-upload-hint { font-size: 11.5px; color: var(--ink-faint); margin-top: 6px; }

/* ---------- 弹窗 ---------- */
.a-modal-wrap {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 30, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px 16px;
  z-index: 50;
  overflow-y: auto;
}
.a-modal {
  width: 560px;
  max-width: 96vw;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 12px 48px rgba(20, 24, 30, 0.2);
}
.a-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  font-weight: 600;
}
.a-modal-head button {
  border: none;
  background: none;
  font-size: 20px;
  color: var(--ink-faint);
}
.a-modal-body { padding: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ---------- Toast ---------- */
.a-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: #24292f;
  color: #fff;
  font-size: 13px;
  border-radius: 8px;
  padding: 9px 18px;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
  z-index: 99;
}
.a-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 设置页 ---------- */
.settings-grid { max-width: 560px; }
.switch-line { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.switch-line input[type="checkbox"] { width: 16px; height: 16px; }

/* ---------- 移动端 ---------- */
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .side {
    width: 100%;
    flex: none;
    height: auto;
    position: static;
  }
  .side-nav { display: flex; flex-wrap: wrap; gap: 2px; padding: 8px; }
  .side-nav a { padding: 6px 10px; }
  .nav-group { display: none; }
  .content { padding: 16px 14px 40px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
