/* 共益星球 · 管理后台
   设计基准：品牌蓝 #4A8CFF，深色侧栏 + 浅色内容区 */

:root {
  --brand: #4A8CFF;
  --brand-deep: #2F6BE0;
  --brand-soft: #EAF2FF;
  --navy: #0B1222;
  --navy-2: #121A2E;
  --navy-line: #1F2A44;
  --bg: #F5F7FB;
  --card: #FFFFFF;
  --text: #1A1D26;
  --text-2: #6B7280;
  --hint: #9AA1AC;
  --line: #E5E8EE;
  --green: #48C78E;
  --red: #E5484D;
  --orange: #F5A623;
  --purple: #7B61FF;
  --radius: 12px;
  --shadow: 0 4px 16px rgba(26, 29, 38, .05);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-deep); text-decoration: none; }
button { font-family: inherit; }

/* ---------- 登录 ---------- */
.login {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 90% at 50% 0%, #16233F 0%, #0B1222 62%, #070D18 100%);
}

.login-box {
  width: 380px;
  padding: 38px 34px 32px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--navy-line);
  border-radius: 20px;
  backdrop-filter: blur(8px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .38);
}

.login-logo {
  width: 56px; height: 56px; margin: 0 auto 16px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  background: linear-gradient(135deg, #4A8CFF, #2F6BE0);
  box-shadow: 0 10px 26px rgba(74, 140, 255, .38);
}

.login h1 {
  margin: 0 0 6px;
  font-size: 21px;
  color: #fff;
  text-align: center;
  letter-spacing: .5px;
}

.login .sub {
  margin: 0 0 26px;
  text-align: center;
  font-size: 13px;
  color: #7C879C;
}

.login label {
  display: block;
  margin-bottom: 14px;
  font-size: 12px;
  color: #8B97AD;
}

.login input {
  width: 100%;
  margin-top: 7px;
  padding: 12px 14px;
  font-size: 14px;
  color: #fff;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--navy-line);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s;
}

.login input:focus { border-color: var(--brand); }
.login .err { margin: 0 0 10px; font-size: 12px; color: #FF7A7E; min-height: 16px; }

.login .btn-primary { width: 100%; padding: 13px; margin-top: 6px; font-size: 15px; }

.login .tip {
  margin: 18px 0 0;
  font-size: 12px;
  line-height: 1.7;
  color: #6C7891;
  text-align: center;
}

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.layout[hidden] { display: none; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 236px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #0E1729 0%, #0B1222 100%);
  border-right: 1px solid var(--navy-line);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
}

.brand-mark {
  width: 34px; height: 34px; flex: none;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  background: linear-gradient(135deg, #4A8CFF, #2F6BE0);
}

.brand-text b { display: block; font-size: 15px; color: #fff; letter-spacing: .5px; }
.brand-text span { font-size: 11px; color: #66738C; letter-spacing: 1.2px; }

.nav { flex: 1; overflow-y: auto; padding: 4px 12px 20px; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: #1E2A44; border-radius: 3px; }

.nav-group {
  margin: 16px 0 6px;
  padding: 0 10px;
  font-size: 11px;
  color: #5B677F;
  letter-spacing: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 2px;
  border-radius: 9px;
  color: #A7B2C6;
  cursor: pointer;
  font-size: 13.5px;
  transition: background .15s, color .15s;
}

.nav-item:hover { background: rgba(255, 255, 255, .045); color: #E8EDF7; }

.nav-item.active {
  background: linear-gradient(90deg, rgba(74, 140, 255, .22), rgba(74, 140, 255, .06));
  color: #fff;
  box-shadow: inset 2px 0 0 var(--brand);
}

.nav-item .ico { width: 18px; text-align: center; font-size: 15px; }
.nav-item .dot {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

.sidebar-foot {
  padding: 14px 18px 18px;
  border-top: 1px solid var(--navy-line);
  font-size: 11.5px;
  color: #5B677F;
  line-height: 1.8;
}

.main { flex: 1; margin-left: 236px; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 26px;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar h2 { margin: 0; font-size: 17px; font-weight: 600; }
.topbar .crumb { font-size: 12.5px; color: var(--text-2); }
.topbar .spacer { flex: 1; }

.demo-flag {
  padding: 4px 10px;
  border-radius: 999px;
  background: #FFF6E5;
  color: #B26A00;
  font-size: 11.5px;
  border: 1px solid #FFE2B0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 5px;
  border-radius: 999px;
  background: #F2F5FA;
  cursor: pointer;
  font-size: 13px;
}

.user-chip .av {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4A8CFF, #2F6BE0);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
}

.view { padding: 22px 26px 40px; }

/* ---------- 卡片 / 网格 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}

.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }

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

.kpi { padding: 16px 18px; }
.kpi .label { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.kpi .value { margin-top: 9px; font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.kpi .value small { font-size: 13px; font-weight: 500; color: var(--hint); margin-left: 4px; }
.kpi .foot { margin-top: 7px; font-size: 12px; color: var(--hint); }
.kpi .trend { color: var(--green); }
.kpi .trend.down { color: var(--red); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th, td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  font-weight: 500;
  font-size: 12px;
  color: var(--text-2);
  background: #FAFBFD;
}

tbody tr:hover { background: #F8FAFF; }
tbody tr:last-child td { border-bottom: none; }

td .sub { display: block; margin-top: 3px; font-size: 11.5px; color: var(--hint); }
td.num { font-variant-numeric: tabular-nums; }
td.right, th.right { text-align: right; }

.empty {
  padding: 48px 0;
  text-align: center;
  color: var(--hint);
  font-size: 13px;
}

.empty .big { font-size: 30px; display: block; margin-bottom: 10px; opacity: .55; }

/* ---------- 按钮 / 标签 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
}

.btn:hover { border-color: #C9D3E4; background: #F8FAFF; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 12px rgba(74, 140, 255, .28);
}

.btn-primary:hover { filter: brightness(1.04); background: linear-gradient(135deg, var(--brand), var(--brand-deep)); }

.btn-danger { color: var(--red); border-color: #F3C7C9; background: #FFF6F6; }
.btn-danger:hover { background: #FFEDED; border-color: #EFB1B4; }

.btn-ghost { border-color: transparent; background: transparent; color: var(--brand-deep); padding: 0 8px; height: 28px; }
.btn-ghost:hover { background: var(--brand-soft); border-color: transparent; }

.btn-sm { height: 27px; padding: 0 10px; font-size: 12px; border-radius: 7px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 21px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  background: #EEF1F6;
  color: var(--text-2);
}

.badge.green { background: #E9F8F0; color: #1F9254; }
.badge.red { background: #FDEDED; color: #C62B30; }
.badge.blue { background: var(--brand-soft); color: var(--brand-deep); }
.badge.orange { background: #FFF5E6; color: #B26A00; }
.badge.purple { background: #F1EEFF; color: #5B45D6; }

/* ---------- 工具条 ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.toolbar .spacer { flex: 1; }

.field, .select {
  height: 32px;
  padding: 0 11px;
  font-size: 13px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.field:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(74, 140, 255, .12); }
.field.search { width: 230px; }
.select { cursor: pointer; }

textarea.field {
  height: auto;
  min-height: 84px;
  padding: 9px 11px;
  line-height: 1.6;
  resize: vertical;
  width: 100%;
}

/* ---------- 分页 ---------- */
.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--text-2);
}

.pager .spacer { flex: 1; }

.pager button {
  min-width: 30px;
  height: 29px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
}

.pager button.on { border-color: var(--brand); color: var(--brand-deep); background: var(--brand-soft); }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; }

.tab {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
}

.tab:hover { background: #F2F5FA; }
.tab.on { background: var(--brand-soft); color: var(--brand-deep); font-weight: 500; }
.tab .n { margin-left: 4px; font-size: 11.5px; opacity: .8; }

/* ---------- 开关 ---------- */
.switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex: none;
  border-radius: 999px;
  background: #D7DCE5;
  cursor: pointer;
  transition: background .18s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
  transition: transform .18s;
}

.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(18px); }

/* ---------- 图表 ---------- */
.chart { width: 100%; height: 220px; display: block; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-2); }
.chart-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }

/* ---------- 列表条目 ---------- */
.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.item-row:last-child { border-bottom: none; }
.item-row .grow { flex: 1; min-width: 0; }
.item-row .title { font-size: 13.5px; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-row .meta { font-size: 12px; color: var(--hint); }

.avatar {
  width: 34px; height: 34px; flex: none;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  background: #EAF2FF;
}

/* ---------- 弹窗 ---------- */
.mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(12, 18, 32, .46);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade .14s ease;
}

@keyframes fade { from { opacity: 0; } }

.modal {
  width: 460px;
  max-width: 100%;
  max-height: 86vh;
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .26);
  animation: pop .16s ease;
}

@keyframes pop { from { transform: translateY(8px) scale(.985); opacity: .6; } }

.modal.wide { width: 620px; }

.modal-head {
  display: flex;
  align-items: center;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 { margin: 0; font-size: 15.5px; font-weight: 600; }
.modal-head .spacer { flex: 1; }

.modal-head .x {
  width: 28px; height: 28px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--hint);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}

.modal-head .x:hover { background: #F2F5FA; color: var(--text); }
.modal-body { padding: 20px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}

/* ---------- 表单 ---------- */
.form-row { margin-bottom: 15px; }
.form-row > label { display: block; margin-bottom: 6px; font-size: 12.5px; color: var(--text-2); }
.form-row > label b { color: var(--red); font-weight: 400; margin-left: 2px; }
.form-row .field, .form-row .select { width: 100%; }
.form-hint { margin-top: 6px; font-size: 11.5px; color: var(--hint); line-height: 1.6; }
.form-inline { display: flex; gap: 12px; }
.form-inline > * { flex: 1; min-width: 0; }

/* ---------- 详情抽屉 ---------- */
.detail-list { display: grid; grid-template-columns: 96px 1fr; gap: 0; font-size: 13px; }
.detail-list dt { padding: 9px 0; color: var(--text-2); }
.detail-list dd { margin: 0; padding: 9px 0; border-bottom: 1px dashed #EEF1F6; word-break: break-all; }
.detail-list dt:last-of-type, .detail-list dd:last-of-type { border-bottom: none; }

/* ---------- 提示 ---------- */
#toast-root {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: 42px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(16, 22, 36, .92);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .24);
  animation: toastIn .18s ease;
}

.toast.ok { background: rgba(31, 146, 84, .95); }
.toast.err { background: rgba(197, 40, 45, .95); }

@keyframes toastIn { from { transform: translateY(6px); opacity: 0; } }

/* ---------- 空态 / 提示条 ---------- */
.notice-bar {
  display: flex;
  gap: 10px;
  padding: 12px 15px;
  border: 1px solid #FFE2B0;
  border-radius: 10px;
  background: #FFFBF2;
  color: #8A5A00;
  font-size: 12.5px;
  line-height: 1.7;
}

.notice-bar.info { border-color: #CFE0FF; background: #F4F8FF; color: #2C5CA8; }

/* 卡片内的提示条（自身负责与下方内容间距） */
.card > .notice-bar { margin-bottom: 14px; }
.view > .notice-bar, .grid > .notice-bar { margin-bottom: 16px; }

.section-title {
  margin: 26px 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.section-title:first-child { margin-top: 0; }

.muted { color: var(--hint); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.gap-8 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- 响应式 ---------- */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2-1 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .brand { padding: 18px 0; justify-content: center; }
  .brand-text, .nav-group, .nav-item span.name, .sidebar-foot, .nav-item .dot { display: none; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .nav-item .ico { font-size: 17px; }
  .main { margin-left: 64px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .view { padding: 16px 14px 32px; }
  .topbar { padding: 0 14px; }
  .crumb { display: none; }
  .field.search { width: 150px; }
}
