:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --dim: #9ca3af;
  --line: #e5e7eb;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --red: #ef4444;
  --green: #16a34a;
  --amber: #d97706;
  --sidebar: #111827;
  --radius: 8px;
  --sw: 232px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text); background: var(--bg); font-size: 14px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 布局 */
.layout { min-height: 100vh; display: flex; }
.layout.no-side { display: block; }
.sidebar { width: var(--sw); background: var(--sidebar); color: #fff;
  position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; }
.brand { font-size: 17px; font-weight: 700; line-height: 1.35; padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar nav { flex: 1; overflow-y: auto; padding: 12px 12px; }
.nav-group { margin-top: 14px; }
.nav-group:first-child { margin-top: 0; }
.nav-group > .label { font-size: 11px; letter-spacing: .05em; color: #6b7280; padding: 0 12px 4px; }
.nav-item { display: block; padding: 11px 12px; margin: 2px 0; border-radius: 8px;
  color: #cbd2dc; font-size: 14.5px; border-left: 3px solid transparent; transition: background .12s, color .12s; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(37,99,235,.20); color: #fff; font-weight: 600; border-left-color: #3b82f6; }
.side-foot { border-top: 1px solid rgba(255,255,255,.12); padding: 14px 16px; font-size: 13px; color: #9ca3af;
  display: flex; align-items: center; gap: 8px; }
.side-foot b { color: #fff; font-weight: 600; }
.side-foot .out { margin-left: auto; color: #9ca3af; }
.side-foot .out:hover { color: #fff; }

.main { margin-left: var(--sw); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.no-side .main { margin-left: 0; }
.topbar { height: 62px; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 28px;
  position: sticky; top: 0; z-index: 10; }
.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; }
.badge { display: inline-flex; align-items: center; height: 24px; border-radius: 999px; padding: 0 10px;
  background: var(--blue-soft); color: #1e40af; font-size: 12px; font-weight: 600; }
.topbar .user { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 13px; }
.content { padding: 24px 28px 40px; max-width: 1160px; width: 100%; }

.section-title { margin: 0 0 6px; font-size: 20px; }
.hint { color: var(--muted); margin: 0 0 18px; line-height: 1.7; }
.muted { color: var(--muted); } .small { font-size: 12px; } .dim { color: var(--dim); }

/* KPI 卡片 */
.cards { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card > label, .card .clabel { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.card > .num { font-size: 30px; font-weight: 750; letter-spacing: -0.02em; }
.cards .card { transition: box-shadow .14s, transform .14s; }
.cards .card:hover { box-shadow: 0 4px 14px rgba(16,24,40,.08); transform: translateY(-1px); }
.card > .num.warn { color: var(--amber); } .card > .num.bad { color: var(--red); } .card > .num.up { color: var(--green); }

/* 工具条 / 表单 */
.toolbar { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 16px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
input, select, textarea { border: 1px solid #d1d5db; border-radius: 6px; padding: 9px 11px;
  font: inherit; background: #fff; min-height: 38px; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
textarea { width: 100%; min-height: 120px; resize: vertical; }
.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field label { color: #374151; font-weight: 600; font-size: 14px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-row > div { display: flex; flex-direction: column; gap: 6px; min-width: 140px; }
.form-row label { color: #374151; font-weight: 600; font-size: 13px; }
.form-row input, .form-row select { width: 100%; }
.btn { border: 0; border-radius: 7px; background: var(--blue); color: #fff; padding: 10px 16px;
  font-weight: 600; cursor: pointer; min-height: 38px; font-family: inherit; font-size: 14px;
  box-shadow: 0 1px 2px rgba(37,99,235,.25); transition: filter .12s, box-shadow .12s; }
.btn:hover { filter: brightness(1.06); box-shadow: 0 2px 8px rgba(37,99,235,.30); }
.btn.secondary { background: #f3f4f6; color: #111827; border: 1px solid var(--line); }
.btn.danger { background: var(--red); }
.btn.small { padding: 6px 12px; min-height: auto; font-size: 13px; }
.btn-link { color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; } .actions form { margin: 0; }

/* 表格 */
table.grid, table { width: 100%; border-collapse: collapse; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
th { background: #f9fafb; color: #4b5563; font-weight: 700; font-size: 13px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fcfcfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.up { color: var(--green); font-weight: 600; }
td.title a { font-weight: 600; color: var(--text); } td.title a:hover { color: var(--blue); }
.ellipsis { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 状态标签 */
.status { display: inline-flex; align-items: center; height: 24px; border-radius: 999px; padding: 0 9px; font-size: 12px; font-weight: 600; }
.status.ok { background: #dcfce7; color: #166534; }
.status.warn { background: #fef3c7; color: #92400e; }
.status.bad { background: #fee2e2; color: #991b1b; }
.status.info { background: #dbeafe; color: #1e40af; }
.tag { display: inline-flex; align-items: center; height: 22px; border-radius: 6px; padding: 0 8px;
  background: #eef2ff; color: #3730a3; font-size: 12px; font-weight: 500; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.form-panel h2 { font-size: 16px; margin: 0 0 14px; }

/* 简易柱状图 */
.simple-chart { height: 190px; display: flex; gap: 10px; align-items: end; padding: 16px 16px 30px;
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.bar { flex: 1; min-width: 18px; background: #93c5fd; border-radius: 5px 5px 0 0; position: relative; }
.bar > .v { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); color: var(--muted); font-size: 11px; }
.bar > span { position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%); color: var(--dim); font-size: 11px; }

.flash { background: #dcfce7; color: #166534; padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.filter-bar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar a { padding: 7px 14px; border-radius: 8px; font-size: 13px; color: var(--muted); border: 1px solid var(--line); background: #fff; }
.filter-bar a.on { background: var(--blue); color: #fff; border-color: var(--blue); }
.filter-bar a:hover { text-decoration: none; }
hr { border: none; border-top: 1px solid var(--line); margin: 4px 0; }

/* 登录 */
.login-wrap { max-width: 460px; margin: 8vh auto; }
.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.user-pick { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.user-pick:hover { border-color: var(--blue); }
.feishu-btn { display: block; text-align: center; }

/* 能力授权 / 组织 */
details.user-row { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; padding: 4px 14px; background: #fff; }
details.user-row summary { cursor: pointer; padding: 10px 0; display: flex; align-items: center; gap: 10px; }
.caps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 8px; }
.cap-check { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 0; }
.cap-check input, .check-inline input, .setting.check input { width: auto; min-height: auto; }
.check-inline, .setting.check label { display: flex; align-items: center; gap: 8px; }
.inline-form { display: flex; gap: 6px; align-items: center; } .inline-form select { min-height: 34px; }
.settings { display: flex; flex-direction: column; gap: 14px; max-width: 440px; }
.metrics { display: flex; gap: 28px; margin-top: 12px; flex-wrap: wrap; }
.metric { display: flex; flex-direction: column; color: var(--dim); font-size: 12px; }
.metric span { font-size: 24px; font-weight: 700; color: var(--text); }
.scope-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 8px 0 16px; }
.scope-tab { padding: 8px 16px; color: var(--muted); border-bottom: 2px solid transparent; }
.scope-tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.scope-tab:hover { text-decoration: none; }
.alert-form .ov { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; font-size: 13px; }
.alert-form .ov input { width: auto; min-height: auto; }
.hit-panel { border-left: 3px solid var(--blue); }
tr.unread td { background: var(--blue-soft); }
.badge-red { background: var(--red); color: #fff; font-size: 12px; padding: 2px 9px; border-radius: 999px; margin-left: 6px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* 兼容：其余页面沿用的旧类 */
.pill { display: inline-flex; align-items: center; height: 22px; border-radius: 999px; padding: 0 9px; font-size: 12px; font-weight: 500; background: #f3f4f6; color: #4b5563; }
.pill.green { background: #dcfce7; color: #166534; }
.pill.grey { background: #eef0f2; color: #4b5563; }
.pill.red { background: #fee2e2; color: #991b1b; }
.tier { font-size: 11px; color: var(--amber); background: #fef3c7; padding: 2px 8px; border-radius: 6px; }
.rank { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: #f3f4f6; font-size: 12px; font-weight: 600; color: #4b5563; }
.rank.r1 { background: #fef3c7; color: #92400e; } .rank.r2 { background: #eef1f5; color: #64748b; } .rank.r3 { background: #ffe4d6; color: #c2410c; }
.health-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.health-tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 13px; }
.health-tile .big { font-size: 28px; font-weight: 700; color: var(--text); }
.health-tile .big.ok { color: var(--green); } .health-tile .big.warn { color: var(--red); }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.admin-card { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); }
.admin-card:hover { border-color: var(--blue); text-decoration: none; }
.admin-card b { font-size: 15px; } .admin-card span { color: var(--dim); font-size: 13px; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; }

/* 汉堡按钮 + 抽屉遮罩：默认隐藏，仅移动端启用 */
.hamburger { display: none; background: none; border: none; font-size: 22px; line-height: 1;
  cursor: pointer; color: var(--text); padding: 4px 6px; min-height: auto; }
.nav-overlay { display: none; }
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-left h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 860px) {
  .sidebar { width: 252px; transform: translateX(-100%); transition: transform .22s ease;
    z-index: 50; box-shadow: 2px 0 18px rgba(0,0,0,.28); }
  .layout.nav-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .nav-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
  .layout.nav-open .nav-overlay { display: block; }
  .hamburger { display: inline-flex; align-items: center; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar h1 { font-size: 16px; }
  .topbar .user { display: none; }
  .content { padding: 16px 14px 32px; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card { padding: 14px; }
  .card > .num { font-size: 24px; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-panel { padding: 14px; }
  /* 宽表格改为横向滑动，不再撑破布局 */
  table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .toolbar, .filter-bar, .scope-tabs, .form-row { overflow-x: auto; }
  .login-wrap { margin: 6vh auto; padding: 0 12px; }
}
@media (max-width: 420px) {
  .content { padding: 12px 10px 28px; }
  .card > .num { font-size: 22px; }
}
