:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --side: #111827;
  --side-ink: #cbd5e1;
  --side-on: #ffffff;
  --line: #e5e7eb;
  --ink: #111827;
  --ink-2: #6b7280;
  --ink-3: #9ca3af;
  --brand: #2f6fed;
  --brand-soft: #eaf1fe;
  --ok: #16a34a; --ok-soft: #e8f7ee;
  --warn: #b45309; --warn-soft: #fdf3e2;
  --danger: #dc2626; --danger-soft: #fdecec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--ink-2); } .faint { color: var(--ink-3); } .small { font-size: 12px; }
.nowrap { white-space: nowrap; } .right { text-align: right; } .grow { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

/* 布局 */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 10px 14px; font-weight: 600; color: #fff; }
.brand-mark { color: #7aa5ff; font-size: 18px; } .brand-mark.lg { font-size: 30px; color: var(--brand); }
.nav-group { margin-top: 10px; }
.nav-title { font-size: 11px; letter-spacing: .08em; color: #64748b; padding: 6px 10px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--side-ink); }
.nav-item:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav-item.on { background: rgba(122,165,255,.16); color: var(--side-on); }
.nav-icon { width: 16px; text-align: center; opacity: .8; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; }
.side-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding: 12px 10px 0; display: flex; align-items: center; justify-content: space-between; }
.who-name { color: #fff; font-weight: 500; } .who-role { font-size: 12px; color: #94a3b8; }
.side-foot .btn-link { color: #94a3b8; }
.page { padding: 22px 28px 60px; min-width: 0; max-width: 1400px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-title { font-size: 20px; font-weight: 600; }
.crumbs { font-size: 12px; color: var(--ink-2); margin-bottom: 4px; } .crumbs a { color: var(--ink-2); }

/* 卡片与统计 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card + .card { margin-top: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.card-title { font-size: 14px; font-weight: 600; }
.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: block; color: inherit; }
a.stat:hover { border-color: var(--brand); text-decoration: none; }
.stat-n { font-size: 24px; font-weight: 600; line-height: 1.2; } .stat-l { font-size: 12px; color: var(--ink-2); }
.stat-sub { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.stat-n.warn { color: var(--warn); } .stat-n.danger { color: var(--danger); } .stat-n.ok { color: var(--ok); }
.meter { height: 8px; background: #eef0f3; border-radius: 999px; overflow: hidden; margin: 8px 0 4px; display: flex; }
.meter > span { display: block; height: 100%; background: var(--brand); }
.meter > span.mine { background: #7aa5ff; }
.meter.warn > span { background: var(--warn); } .meter.danger > span { background: var(--danger); }

/* 表格 */
.table { width: 100%; border-collapse: collapse; background: var(--card); }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12px; font-weight: 500; color: var(--ink-2); background: #fafbfc; white-space: nowrap; }
.table tr:hover td { background: #fafcff; }
.table tr.sel td { background: var(--brand-soft); }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--card); box-shadow: var(--shadow); }
.table-wrap .table tr:last-child td { border-bottom: 0; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--ink-2); font-size: 13px; } .kv dd { margin: 0; min-width: 0; word-break: break-all; }

/* 标签 */
.tag { display: inline-block; font-size: 12px; padding: 0 8px; border-radius: 999px; background: #f1f3f5; color: var(--ink-2); line-height: 20px; white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); } .tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); } .tag.brand { background: var(--brand-soft); color: var(--brand); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); margin-right: 6px; vertical-align: 1px; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.danger { background: var(--danger); } .dot.brand { background: var(--brand); }
.dot.pulse { animation: pulse 1.2s infinite; } @keyframes pulse { 50% { opacity: .35; } }

/* 按钮与表单 */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #cbd5e1; text-decoration: none; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.danger { color: var(--danger); } .btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.sm { padding: 3px 9px; font-size: 12px; } .btn.block { width: 100%; justify-content: center; padding: 9px 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-link { background: none; border: 0; padding: 0; color: var(--brand); cursor: pointer; font: inherit; }
.btn-group { display: inline-flex; } .btn-group .btn { border-radius: 0; } .btn-group .btn:first-child { border-radius: 8px 0 0 8px; } .btn-group .btn:last-child { border-radius: 0 8px 8px 0; } .btn-group .btn + .btn { margin-left: -1px; }
.btn-group .btn.on { background: var(--brand-soft); color: var(--brand); border-color: #bcd0fb; z-index: 1; }
input, select, textarea { font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd0fb; border-color: var(--brand); }
input.sm, select.sm { padding: 3px 8px; font-size: 12px; }
.form { display: grid; gap: 14px; } .field { display: grid; gap: 4px; } .field > span { font-size: 13px; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--ink-3); }
.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .search { min-width: 220px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--ink-2); font-size: 12px; background: #fff; }
.chip.on { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); } .chip:hover { text-decoration: none; border-color: #cbd5e1; }

/* 提示 */
.alert { padding: 10px 14px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); margin-bottom: 14px; border: 1px solid #f7caca; }
.alert.ok { background: var(--ok-soft); color: #166534; border-color: #bfe8cd; }
.alert.warn { background: var(--warn-soft); color: #92400e; border-color: #f4dcae; }
.alert.info { background: var(--brand-soft); color: #1e40af; border-color: #c8d8fb; }
.empty { text-align: center; padding: 40px 20px; color: var(--ink-2); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }

/* 工作区卡片 */
.ws-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.ws-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.ws-card:hover { border-color: #c9d6f5; }
.ws-card-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.ws-name { font-weight: 600; font-size: 15px; color: var(--ink); } .ws-name:hover { color: var(--brand); }
.ws-meta { display: grid; grid-template-columns: 70px 1fr; gap: 3px 8px; font-size: 13px; }
.ws-meta .k { color: var(--ink-3); }
.ws-card-foot { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; border-top: 1px dashed var(--line); }

/* 详情页标签与抽屉 */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { padding: 8px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.on { color: var(--brand); border-bottom-color: var(--brand); } .tab:hover { text-decoration: none; color: var(--ink); }
.drawer-mask { position: fixed; inset: 0; background: rgba(15,23,42,.25); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); background: #fff; z-index: 21; box-shadow: -8px 0 24px rgba(15,23,42,.12); display: flex; flex-direction: column; }
.drawer-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.drawer-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.drawer-body section + section { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.drawer-body h3 { font-size: 13px; color: var(--ink-2); font-weight: 500; margin-bottom: 8px; }
.danger-zone { border-color: #f7caca; } .danger-zone .card-title { color: var(--danger); }

/* 日志/时间线 */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.feed li:last-child { border-bottom: 0; }
.feed .t { color: var(--ink-3); white-space: nowrap; min-width: 82px; font-size: 12px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.ev { display: grid; grid-template-columns: 70px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.ev-time { color: var(--ink-3); font-size: 12px; }
.ev-text { white-space: pre-wrap; word-break: break-word; margin: 4px 0 0; font: inherit; }
.ev-user .ev-text { background: var(--warn-soft); padding: 8px 10px; border-radius: 8px; }
.ev-tool .ev-head { font-size: 12px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 13px; }
details.more > summary { cursor: pointer; color: var(--brand); list-style: none; } details.more > summary::-webkit-details-marker { display: none; }
details.pop { position: relative; display: inline-block; } details.pop > summary { list-style: none; } details.pop > summary::-webkit-details-marker { display: none; }
details.pop[open] > .pop-body { position: absolute; z-index: 10; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(15,23,42,.12); padding: 12px; min-width: 260px; }

/* 登录 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, #eef3ff, #f7f8fa); }
.login-card { width: 360px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: 0 10px 30px rgba(15,23,42,.08); }
.login-brand { text-align: center; margin-bottom: 18px; } .login-brand h1 { font-size: 20px; margin-top: 6px; }
.foot-note { text-align: center; font-size: 12px; color: var(--ink-3); margin: 16px 0 0; }

@media (max-width: 1100px) { .grid.c4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.side { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; }
  .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } .page { padding: 16px; }
}
