/* admin-web/public/styles.css */
:root {
  --green: #2E7D32;
  --green-dark: #1B5E20;
  --green-light: #E8F5E9;
  --bg: #F5F6F7;
  --card: #FFFFFF;
  --border: #E6E8EB;
  --text: #1F2328;
  --text-2: #6B7280;
  --text-3: #9CA3AF;
  --red: #D93025;
  --amber: #B7791F;
  --blue: #1A73E8;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ============ 登录 ============ */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #EAF3EB 0%, #F5F6F7 60%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 16px;
  padding: 36px 32px 30px;
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.08);
  text-align: center;
}

.login-logo { font-size: 40px; }
.login-title { font-size: 20px; font-weight: 600; margin: 12px 0 4px; }
.login-sub { color: var(--text-3); font-size: 13px; margin: 0 0 26px; }

.login-form { text-align: left; }

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.field-input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
.field-input:focus, .select:focus, .textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.12);
}
.textarea { resize: vertical; min-height: 72px; }

.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 10px; }
.login-hint { color: var(--text-3); font-size: 12px; margin-top: 6px; }
.captcha-row { display: flex; gap: 10px; align-items: stretch; }
.captcha-row .field-input { flex: 1; text-transform: uppercase; letter-spacing: 2px; font-weight: 600; }
.captcha-img {
  height: 42px; width: 120px; flex: none; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; background: #F3F6F4;
}
.captcha-img:hover { border-color: var(--green); }

/* ============ 按钮 ============ */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: #F7F8F9; }
.btn-primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn-primary:hover { background: var(--green-dark); border-color: var(--green-dark); }
.btn-danger { background: #fff; color: var(--red); border-color: #F3C9C6; }
.btn-danger:hover { background: #FDF3F2; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: #F7F8F9; color: var(--text); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 5px; }
.btn-warning { background: #FEF3C7; color: #92400E; border-color: #FDE68A; }
.btn-warning:hover { background: #FDE68A; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ============ 布局 ============ */
.app-view { display: flex; min-height: 100vh; }

.sidebar {
  width: 208px;
  flex-shrink: 0;
  background: #FFFFFF;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 20px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 20px; }

.nav { padding: 12px 10px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  margin-bottom: 4px;
  font-size: 14px;
}
.nav-item:hover { background: #F5F6F7; color: var(--text); }
.nav-item.active { background: var(--green-light); color: var(--green-dark); font-weight: 600; }

.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }

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

.topbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.page-title { font-size: 16px; font-weight: 600; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.current-user { color: var(--text-3); font-size: 13px; }

.content { padding: 24px; }

/* ============ 卡片 / 统计 ============ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.stat-num { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-label { color: var(--text-3); font-size: 12px; margin-top: 4px; }
.stat-num.green { color: var(--green); }
.stat-num.blue { color: var(--blue); }
.stat-num.amber { color: var(--amber); }
.stat-num.red { color: var(--red); }

/* ============ 趋势图 ============ */
.trend {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  height: 200px;
  padding: 10px 4px 0;
}
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.trend-count { font-size: 12px; color: var(--green-dark); font-weight: 600; }
.trend-bar { width: 60%; max-width: 34px; background: #EDF3EE; border-radius: 6px; height: 150px; display: flex; align-items: flex-end; overflow: hidden; }
.trend-fill { width: 100%; background: linear-gradient(180deg, #66BB6A, #2E7D32); min-height: 3px; border-radius: 6px; }
.trend-date { font-size: 11px; color: var(--text-3); }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { color: var(--text-2); font-weight: 600; background: #FAFBFC; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #FBFCFB; }
.table .muted { color: var(--text-3); }
.table .actions { display: flex; gap: 6px; flex-wrap: wrap; }

.user-cell { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #EEF0F2; object-fit: cover; flex-shrink: 0; }
.user-cell .name { font-weight: 600; }
.user-cell .sub { color: var(--text-3); font-size: 12px; }

/* ============ 标签 ============ */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 18px;
  background: #F1F3F5;
  color: var(--text-2);
}
.tag-green { background: var(--green-light); color: var(--green-dark); }
.tag-amber { background: #FEF3C7; color: #92400E; }
.tag-red { background: #FEE2E2; color: #991B1B; }
.tag-blue { background: #E0EDFD; color: #1A56B4; }
.tag-gray { background: #F1F3F5; color: var(--text-3); }

.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; }
.badge-warn { background: #FEF3C7; color: #92400E; }

/* ============ 工具条 ============ */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.toolbar .spacer { flex: 1; min-width: 8px; }
.tabs { display: flex; gap: 6px; }
.tab {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text-2);
}
.tab:hover { border-color: #D5D9DE; }
.tab.active { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 16px; color: var(--text-2); font-size: 13px; }

/* 资料库：行内权限下拉 */
.lib-perm-sel {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

/* 数量快捷选择（生成兑换码弹层） */
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: -8px; }
.chip {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--green); color: var(--green-dark); background: var(--green-light); }

.empty { text-align: center; color: var(--text-3); padding: 48px 0; }
.loading { text-align: center; color: var(--text-3); padding: 40px 0; }

/* ============ 弹层 ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(16, 24, 40, 0.2);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-close { border: none; background: transparent; font-size: 22px; line-height: 1; color: var(--text-3); cursor: pointer; }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; min-height: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; word-break: break-all; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  background: rgba(31, 35, 40, 0.92);
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 100;
  max-width: 80vw;
}

/* ============ 响应式 ============ */
@media (max-width: 820px) {
  .app-view { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; border-right: none; border-bottom: 1px solid var(--border); }
  .sidebar-brand { border-bottom: none; padding: 12px 14px; }
  .nav { display: flex; overflow-x: auto; padding: 8px; gap: 4px; }
  .nav-item { margin-bottom: 0; white-space: nowrap; }
  .sidebar-footer { border-top: none; padding: 8px 12px; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
}

/* ============ 广告管理 ============ */
.section-head { display: flex; align-items: center; margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 160px; }
.badge-ok { background: #DCFCE7; color: #166534; }
.b-thumb-wrap { width: 120px; height: 48px; border-radius: 6px; overflow: hidden; background: #F3F4F6; display: flex; align-items: center; justify-content: center; }
.b-thumb { max-width: 100%; max-height: 100%; object-fit: cover; }
.b-preview { margin: 8px 0; }
.b-preview img { max-width: 100%; max-height: 140px; border-radius: 8px; border: 1px solid var(--border); display: block; }
.checkbox-field { display: flex; align-items: center; gap: 8px; flex-direction: row; }
.checkbox-field input[type=checkbox] { width: 18px; height: 18px; flex: none; cursor: pointer; }
.field-label-inline { font-size: 14px; color: var(--text); font-weight: 500; cursor: pointer; }

/* 图文详情配图（多张） */
.b-detail-imgs { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.b-detail-img { position: relative; width: 120px; height: 90px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: #F3F4F6; }
.b-detail-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.b-detail-del { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; line-height: 20px; text-align: center; border: none; border-radius: 50%; background: rgba(0,0,0,0.6); color: #fff; font-size: 14px; cursor: pointer; padding: 0; }
.b-detail-actions { margin: 4px 0; }

/* ============ 公告管理 ============ */
.a-content-preview {
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-2);
  font-size: 13px;
}
