/* ==========================================================================
   运营后台样式（与 app.css 共用设计令牌）
   风格：暖中性 / 工具感 — 墨黑主色、细线、小圆角、无渐变
   ========================================================================== */
body.admin { background: var(--bg); }

.admin-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 18px 12px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.side-brand { display: flex; align-items: center; gap: 9px; padding: 2px 8px 18px; }
.side-brand .brand-mark { width: 28px; height: 28px; border-radius: 6px; }
.side-brand .nm { font-weight: 700; font-size: 14.5px; letter-spacing: -.015em; }
.side-brand .sub { font-size: 10.5px; color: var(--muted-2); margin-top: 1px; }
.side-group {
  font-size: 10px; letter-spacing: .13em; text-transform: uppercase; color: var(--muted-2);
  padding: 16px 9px 6px; font-weight: 700;
}
.side-link {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 6px;
  color: var(--ink-2); font-size: 13px; font-weight: 500; transition: background .12s, color .12s;
  margin-bottom: 1px; position: relative;
}
.side-link:hover { background: var(--bg-2); color: var(--ink); }
/* 激活态用浅底 + 左侧细指示条，比整块黑更轻 */
.side-link.active {
  background: var(--brand-soft);
  color: var(--ink);
  font-weight: 600;
}
.side-link.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px;
  border-radius: 2px; background: var(--brand);
}
.side-link .ico { opacity: .8; flex: none; }
.side-link.active .ico { opacity: 1; }
.side-link .badge-count {
  margin-left: auto; font-size: 10.5px; font-weight: 700; background: var(--err); color: #ffffff;
  border-radius: 4px; padding: 1px 5px; min-width: 17px; text-align: center;
}
.side-link.active .badge-count { background: var(--err); }
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line-2); }
.side-wallet {
  background: #17191e;
  color: #ffffff; border-radius: 7px; padding: 13px 14px; margin-bottom: 10px;
}
.side-wallet .lab { font-size: 10.5px; opacity: .55; letter-spacing: .02em; }
.side-wallet .val { font-size: 19px; font-weight: 600; letter-spacing: -.02em; margin-top: 3px; font-variant-numeric: tabular-nums; }
.side-wallet .sub { font-size: 10.5px; opacity: .5; margin-top: 3px; }

/* ---------- 主区 ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; display: flex; align-items: center; gap: 14px; padding: 0 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.crumb { font-size: 12px; color: var(--muted-2); }
.topbar .spacer { flex: 1; }
.page { padding: 22px 24px 64px; width: 100%; max-width: 1440px; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 15px 16px;
  display: flex; gap: 12px; align-items: flex-start;
}
.kpi .ic { width: 32px; height: 32px; border-radius: 6px; display: grid; place-items: center; flex: none; }
.kpi .lab { font-size: 11.5px; color: var(--muted-2); }
.kpi .val { font-size: 21px; font-weight: 600; letter-spacing: -.025em; margin-top: 3px; font-variant-numeric: tabular-nums; line-height: 1.3; }
.kpi .sub { font-size: 11px; color: var(--muted-2); margin-top: 3px; }

/* ---------- 卡片 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.card-head { padding: 14px 16px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h3 { font-size: 13.5px; font-weight: 600; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.search-box { position: relative; }
.search-box .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted-2); }
.search-box input {
  height: 34px; width: 250px; border-radius: 5px; border: 1px solid var(--line); padding: 0 11px 0 34px;
  font-size: 12.5px; font-family: inherit; background: #ffffff; color: var(--ink);
}
.search-box input:focus { outline: none; border-color: #b6bbc4; box-shadow: 0 0 0 3px rgba(28, 29, 33, .07); }
.select-sm, .input-sm {
  height: 34px; border-radius: 5px; border: 1px solid var(--line); background: #ffffff; font-size: 12.5px;
  padding: 0 9px; font-family: inherit; color: var(--ink);
}
.input-sm { width: 100%; }
.select-sm:focus, .input-sm:focus { outline: none; border-color: #b6bbc4; box-shadow: 0 0 0 3px rgba(28, 29, 33, .07); }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl th { position: sticky; top: 0; z-index: 1; }
table.tbl td .cell-main { font-weight: 600; font-size: 12.5px; }
table.tbl td .cell-sub { font-size: 11px; color: var(--muted-2); margin-top: 2px; }
table.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl tbody tr.clickable { cursor: pointer; }
.link { color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: underline; text-decoration-color: #c9ced6; text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--ink); }

/* ---------- 图表 ---------- */
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 132px; padding-top: 8px; }
.chart-col { flex: 1; position: relative; height: 100%; }
.chart-bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 100%;
  transform-origin: bottom center; border-radius: 2px;
  background: var(--ink); transition: opacity .15s;
}
.chart-bar:hover { opacity: .72; }
.chart-bar.empty { background: #dcdfe5; }
.chart-labels { display: flex; gap: 6px; margin-top: 6px; }
.chart-labels span { flex: 1; text-align: center; font-size: 10px; color: var(--muted-2); }

/* ---------- 详情页 ---------- */
.detail-head {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 20px;
  display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap;
}
.detail-head .title { font-size: 19px; font-weight: 600; letter-spacing: -.02em; font-family: var(--mono); }
.detail-head .meta { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; gap: 14px; flex-wrap: wrap; }
.detail-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.kv-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 22px; }
.kv-line { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-2); font-size: 12.5px; }
.kv-line span { color: var(--muted-2); }
.kv-line b { font-weight: 600; text-align: right; word-break: break-all; }

/* ---------- 开关 ---------- */
.switch { position: relative; display: inline-flex; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch i {
  position: absolute; inset: 0; background: #dcdfe5; border-radius: 11px; transition: background .16s;
}
.switch i::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #ffffff;
  top: 3px; left: 3px; transition: transform .16s; box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}
.switch input:checked + i { background: var(--ink); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:disabled + i { opacity: .45; }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(23, 24, 27, .42);
  z-index: 120; display: grid; place-items: center; padding: 20px; animation: fadeIn .14s;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: #ffffff; border-radius: 10px; width: 100%; max-width: 540px; max-height: 86vh;
  overflow: auto; box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .4); animation: modalIn .16s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(6px); } }
.modal-head { padding: 17px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 14.5px; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 14px 20px 20px; display: flex; gap: 9px; justify-content: flex-end; }

/* ---------- 登录 ---------- */
.login-page {
  min-height: 100vh; display: grid; place-items: center; position: relative;
  background: var(--bg-2);
}
.login-card {
  position: relative; width: 372px; background: #ffffff;
  border: 1px solid var(--line); border-radius: 10px; padding: 32px 28px;
  box-shadow: 0 1px 2px rgba(24, 20, 16, .04), 0 18px 40px -30px rgba(24, 20, 16, .3);
}
.login-card .brand { display: flex; justify-content: center; margin-bottom: 22px; }
.login-card h2 { font-size: 19px; text-align: center; font-weight: 600; }
.login-card p.sub { text-align: center; font-size: 12.5px; color: var(--muted); margin: 6px 0 24px; }

/* ---------- 诊断 ---------- */
.diag-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); font-size: 12.5px; }
.diag-row:last-child { border-bottom: none; }
.diag-row .nm { width: 88px; color: var(--muted-2); flex: none; }
.bar-soft { height: 4px; border-radius: 2px; background: var(--line-2); overflow: hidden; }
.bar-soft i { display: block; height: 100%; border-radius: 2px; background: var(--ink); }

.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 7px; border-radius: 3px;
  font-size: 11px; font-weight: 600; background: var(--bg-2); color: var(--muted); border: 1px solid var(--line);
}
.tag-ok { background: var(--ok-soft); color: #12604a; border-color: #d7ebe3; }
.tag-warn { background: var(--warn-soft); color: #855314; border-color: #eee4cf; }
.tag-err { background: var(--err-soft); color: #993428; border-color: #f4dad5; }

.alert-box { background: #fafbfc; border: 1px dashed var(--line); border-radius: 5px; padding: 11px 13px; font-size: 12px; color: var(--muted); }

/* ---------- 响应式 ---------- */
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 240px; z-index: 60; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .18); }
  .sidebar.open { transform: none; }
  .page { padding: 16px 14px 60px; }
  .topbar { padding: 0 14px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search-box input { width: 150px; }
  .mobile-menu { display: grid !important; }
}
.mobile-menu { display: none; place-items: center; width: 34px; height: 34px; border-radius: 5px; border: 1px solid var(--line); background: #ffffff; cursor: pointer; }

/* 批量操作条 */
.bulk-bar {
  display: flex; align-items: center; gap: 12px; padding: 9px 14px; margin-bottom: 12px;
  background: #f5f6f8; border: 1px solid #dfe2e7; border-radius: 8px; font-size: 12.5px;
}
.bulk-bar b { font-weight: 600; }
