:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --danger: #dc2626;
  --ok: #059669;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---- 登录页 ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--panel);
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,.08);
  width: 360px;
}
.login-card h1 { margin: 0 0 8px; font-size: 20px; }
.login-card p.sub { margin: 0 0 24px; color: var(--muted); font-size: 13px; }

/* ---- 表单 ---- */
label.field { display: block; margin-bottom: 14px; }
label.field span { display: block; font-size: 13px; margin-bottom: 6px; color: var(--muted); }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }

button {
  cursor: pointer; border: none; border-radius: 6px; font-size: 14px;
  padding: 9px 16px; background: var(--primary); color: #fff;
}
button:hover { background: var(--primary-hover); }
button.ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
button.ghost:hover { background: #f3f4f6; }
button.danger { background: var(--danger); }
button.sm { padding: 4px 10px; font-size: 12px; }

/* ---- 布局 ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px; background: #111827; color: #cbd5e1; padding: 20px 0; flex-shrink: 0;
  display: flex; flex-direction: column; min-height: 100vh;
}
.sidebar .brand { padding: 0 20px 20px; font-size: 16px; font-weight: 600; color: #fff; border-bottom: 1px solid #1f2937; }
.sidebar a {
  display: block; padding: 11px 20px; color: #cbd5e1; text-decoration: none; font-size: 14px;
}
.sidebar a:hover, .sidebar a.active { background: #1f2937; color: #fff; }
.sidebar .foot { padding: 16px 20px; font-size: 12px; color: #6b7280; margin-top: auto; }
.sidebar .foot button { background: transparent; color: #cbd5e1; border: 1px solid #374151; font-size: 12px; padding: 5px 10px; }
.sidebar .foot button:hover { background: #1f2937; color: #fff; }

.main { flex: 1; padding: 28px 32px; overflow-x: auto; }
.main h2 { margin: 0 0 4px; font-size: 20px; }
.main .desc { color: var(--muted); font-size: 13px; margin: 0 0 20px; }

/* ---- 工具栏 ---- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input { width: 240px; }

/* ---- 表格 ---- */
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
th, td { padding: 11px 14px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--border); }
th { background: #f9fafb; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: none; }
td .actions { display: flex; gap: 6px; flex-wrap: wrap; }
/* 表格操作区的 ghost 按钮需有可见底色(表格本身是白底,纯白 ghost 会隐形) */
td .actions button.ghost { background: #f3f4f6; }
td .actions button.ghost:hover { background: #e5e7eb; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.tag.ok { background: #d1fae5; color: #065f46; }
.tag.off { background: #fee2e2; color: #991b1b; }
.tag.warn { background: #fef3c7; color: #92400e; }

.empty { text-align: center; padding: 40px; color: var(--muted); font-size: 14px; }

/* ---- 分页 ---- */
.pager { display: flex; gap: 8px; align-items: center; margin-top: 16px; justify-content: flex-end; font-size: 13px; color: var(--muted); }
.pager b { color: var(--text); }

/* ---- 卡片网格 ---- */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.mini-card { background: var(--panel); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.mini-card img { width: 100%; height: 120px; object-fit: cover; display: block; }
.mini-card .body { padding: 10px 12px; }
.mini-card .no { font-size: 12px; color: var(--muted); }
.mini-card .name { font-size: 14px; font-weight: 600; margin: 2px 0; }

/* ---- 统计 ---- */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric { background: var(--panel); border-radius: var(--radius); padding: 18px 20px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.metric .label { font-size: 12px; color: var(--muted); }
.metric .value { font-size: 26px; font-weight: 700; margin-top: 4px; }

/* ---- modal ---- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex;
  align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: #fff; border-radius: var(--radius); padding: 24px; width: 480px;
  max-height: 85vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 16px; }
.modal .row { margin-bottom: 12px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

.alert { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin-bottom: 16px; }
.alert.err { background: #fee2e2; color: #991b1b; }

/* ---- 规则说明区(用户管理页)---- */
.rules { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 0 0 20px; }
@media (max-width: 720px) {
  .rules { grid-template-columns: 1fr; }
}
.rule-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.rule-card .rule-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.rule-card ul { margin: 0; padding-left: 18px; }
.rule-card li { font-size: 13px; color: #374151; line-height: 1.8; }
.rule-card code { background: #f3f4f6; padding: 1px 5px; border-radius: 3px; font-size: 12px; color: var(--primary); }

img.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 4px; vertical-align: middle; }

/* ---- 图片选择器(上传到 COS)---- */
.img-picker { display: flex; gap: 12px; align-items: flex-start; }
.img-preview {
  width: 120px; height: 90px; border: 1px dashed var(--border); border-radius: 6px;
  overflow: hidden; background: #f9fafb; flex-shrink: 0;
}
.img-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.img-actions .ghost, .img-actions .danger { width: auto; }
.img-tip { font-size: 12px; color: var(--muted); }
