/**
 * 明德文创 · 管理后台样式
 * 与小程序端共用同一套品牌色（学院蓝 + 烫金 + 纸张米白），保证后台/前台观感一致。
 * 原生 CSS，无构建、无依赖，直接丢进 nginx 或由 Node 服务托管即可。
 */

:root {
  --brand: #1b3c6e;
  --brand-2: #3e6ba8;
  --brand-deep: #12294c;
  --brand-soft: #eaeff7;
  --accent: #c9a253;
  --danger: #c8382f;
  --danger-soft: #fdecea;
  --ok: #2f7a56;
  --ok-soft: #e8f5ee;

  --bg: #f4f4f1;
  --surface: #ffffff;
  --muted: #fafaf8;
  --border: #ecedef;
  --border-strong: #dfe1e5;

  --text: #1a1d24;
  --sub: #6b7280;
  --weak: #9ca3af;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 16px;
  --shadow: 0 2px 12px rgba(26, 29, 36, 0.06);
  --shadow-lg: 0 12px 40px rgba(18, 41, 76, 0.18);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* ============ 通用控件 ============ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  transition: opacity 0.15s, background 0.15s;
}
.btn:hover { opacity: 0.9; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.btn--ghost { background: transparent; border-color: rgba(255, 255, 255, 0.35); color: #fff; }
.btn--ghost:hover { background: rgba(255, 255, 255, 0.12); }
.btn--plain { background: var(--surface); border-color: var(--border-strong); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn--block { width: 100%; }

.field { display: block; margin-bottom: 14px; }
.field__label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--sub); }
.field__input,
.field__select,
.field__textarea {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field__textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 72px; line-height: 1.6; }
.field__input:focus,
.field__select:focus,
.field__textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(62, 107, 168, 0.14);
}
.field__hint { margin-top: 6px; font-size: 12px; color: var(--weak); }

/* ============ 登录 ============ */

.login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(circle at 82% 12%, rgba(255, 255, 255, 0.16), transparent 46%),
    linear-gradient(160deg, var(--brand-deep) 0%, var(--brand) 52%, var(--brand-2) 100%);
}

.login__card {
  width: 100%;
  max-width: 380px;
  padding: 36px 32px 28px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.login__brand { text-align: center; margin-bottom: 26px; }

.login__logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 600;
  color: #fff;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 20px rgba(27, 60, 110, 0.28);
}

.login__title { margin: 0; font-size: 22px; letter-spacing: 2px; }
.login__sub { margin: 6px 0 0; font-size: 13px; color: var(--weak); }

.login__error {
  margin-bottom: 14px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--r-sm);
}

.login__hint { margin: 16px 0 0; font-size: 12px; line-height: 1.6; color: var(--weak); text-align: center; }

/* ============ 主框架 ============ */

.app { display: flex; min-height: 100vh; }

.sidebar {
  display: flex;
  flex-direction: column;
  width: 216px;
  flex: 0 0 216px;
  padding: 20px 14px;
  background: linear-gradient(170deg, var(--brand-deep) 0%, var(--brand) 60%, #2a5182 100%);
  color: #fff;
}

.sidebar__brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 20px; }

.sidebar__logo {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.sidebar__name { font-size: 15px; font-weight: 600; letter-spacing: 1px; }
.sidebar__sub { font-size: 11px; color: rgba(255, 255, 255, 0.6); }

.nav { flex: 1; display: flex; flex-direction: column; gap: 3px; }

.nav__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav__item:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.nav__item.is-active { background: rgba(255, 255, 255, 0.18); color: #fff; font-weight: 600; }

.nav__glyph {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.14);
}

.nav__badge {
  margin-left: auto;
  min-width: 20px;
  padding: 0 6px;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
}

.sidebar__foot { padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.14); }
.sidebar__user { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; font-size: 13px; color: rgba(255, 255, 255, 0.82); }
.sidebar__dot { width: 7px; height: 7px; border-radius: 50%; background: #6ee7a8; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 26px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar__title { margin: 0; font-size: 18px; }
.topbar__actions { display: flex; gap: 10px; flex-wrap: wrap; }

.content { flex: 1; padding: 22px 26px 40px; }

/* ============ 卡片与统计 ============ */

.card {
  background: var(--surface);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card + .card { margin-top: 18px; }

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.card__title { margin: 0; font-size: 15px; }
.card__body { padding: 18px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }

.stat {
  padding: 16px 18px;
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.stat__label { font-size: 13px; color: var(--sub); }
.stat__value { margin-top: 8px; font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat__extra { margin-top: 6px; font-size: 12px; color: var(--weak); }
.stat--brand { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.stat--brand .stat__label, .stat--brand .stat__extra { color: rgba(255, 255, 255, 0.76); }

/* ============ 表格 ============ */

.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 12px; font-weight: 600; color: var(--sub); background: var(--muted); white-space: nowrap; }
.table td { font-size: 13.5px; }
.table tbody tr:hover { background: #fbfbfa; }
.table .num { font-variant-numeric: tabular-nums; }
.table .actions { display: flex; gap: 8px; white-space: nowrap; }
.table .muted { color: var(--weak); font-size: 12px; }

.thumb {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  border-radius: 9px;
}
.cell-goods { display: flex; align-items: center; gap: 10px; }
.cell-goods__title { font-weight: 500; }
.cell-goods__sub { font-size: 12px; color: var(--weak); }

/* ============ 标签 ============ */

.tag {
  display: inline-block;
  padding: 1px 8px;
  font-size: 12px;
  line-height: 19px;
  border-radius: 4px;
  white-space: nowrap;
}
.tag--on { background: var(--ok-soft); color: var(--ok); }
.tag--off { background: #f2f2f0; color: var(--weak); }
.tag--warn { background: var(--danger-soft); color: var(--danger); }
.tag--info { background: var(--brand-soft); color: var(--brand); }
.tag--gold { background: #faf4e6; color: #8a6a24; }

/* ============ 筛选栏 ============ */

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters .field__input, .filters .field__select { width: auto; min-width: 160px; height: 34px; }
.filters__spacer { flex: 1; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tab {
  padding: 6px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--sub);
  font-size: 13px;
}
.tab.is-active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.tab__count { margin-left: 6px; font-size: 11px; opacity: 0.75; }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 14px 18px; font-size: 13px; color: var(--sub); }

/* ============ 表单网格 ============ */

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-1 { grid-column: span 1; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  font-size: 12px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
}
.chip button { border: 0; background: transparent; color: inherit; padding: 0; line-height: 1; }

/* ============ 弹窗 ============ */

.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal__mask { position: absolute; inset: 0; background: rgba(16, 18, 22, 0.5); }
.modal__panel {
  position: relative;
  width: 100%;
  max-width: 680px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal__title { margin: 0; font-size: 16px; }
.modal__close { border: 0; background: transparent; font-size: 16px; color: var(--weak); padding: 4px 8px; }
.modal__body { flex: 1; overflow-y: auto; padding: 20px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--muted); }

/* ============ 提示 ============ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 46px;
  z-index: 90;
  transform: translateX(-50%);
  max-width: 78vw;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(26, 29, 36, 0.9);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}
.toast.is-error { background: var(--danger); }

.empty { padding: 46px 20px; text-align: center; color: var(--weak); }
.empty__mark {
  width: 60px;
  height: 60px;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  border-radius: 50%;
  border: 1px dashed var(--border-strong);
  color: var(--weak);
}

.loading { padding: 40px; text-align: center; color: var(--weak); font-size: 13px; }

/* ============ 响应式 ============ */

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex: none; padding: 14px; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav__item { white-space: nowrap; }
  .nav__badge { margin-left: 6px; }
  .sidebar__foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .sidebar__user { margin-bottom: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .content { padding: 16px; }
  .topbar { padding: 14px 16px; }
}
