:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #7b8794;
  --border: #e4e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --side-bg: #111827;
  --side-text: #cbd2d9;
  --side-active: #1f2937;
  --ok-bg: #e8f7ee; --ok-text: #166534;
  --err-bg: #fdecec; --err-text: #b42318;
  --radius: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h3 { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; font-weight: normal; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; flex-shrink: 0; background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: block; padding: 20px; font-size: 18px; font-weight: 600; color: #fff; letter-spacing: 1px; }
.brand:hover { text-decoration: none; }
.sidebar nav { flex: 1; overflow-y: auto; }
.nav-group { padding: 16px 20px 6px; font-size: 12px; color: #6b7280; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 20px; color: var(--side-text); border-left: 3px solid transparent; }
.nav-item:hover { background: var(--side-active); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--side-active); color: #fff; border-left-color: var(--primary); }
.ico { width: 18px; text-align: center; }
.me { padding: 16px 20px; border-top: 1px solid #1f2937; font-size: 13px; }
.me-name { color: #fff; margin-bottom: 4px; }
.me-links a { color: var(--side-text); }
.content { flex: 1; min-width: 0; padding: 24px 32px; }

/* 组件 */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 8px; }
.page-title { font-size: 20px; }
.page-head p { margin: -6px 0 12px; }
.btn { display: inline-block; padding: 7px 16px; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text); font-size: 14px; cursor: pointer; }
.btn:hover { text-decoration: none; background: #f9fafb; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.block { display: block; width: 100%; text-align: center; }
.badge { display: inline-block; padding: 0 8px; border-radius: 10px; font-size: 12px; background: #e5e7eb; color: #374151; }
.badge.strong { background: #dbeafe; color: #1e40af; }
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.alert.success { background: var(--ok-bg); color: var(--ok-text); }
.alert.error { background: var(--err-bg); color: var(--err-text); }

/* 表单 */
.form { max-width: 720px; }
.form.narrow { max-width: 420px; }
.form fieldset { border: 0; padding: 0; margin: 0; }
.field { margin-bottom: 16px; }
.field > label, .login label { display: block; margin-bottom: 6px; font-weight: 500; }
input[type=text], input[type=number], input[type=password], input:not([type]), select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cbd2d9; border-radius: 6px; font: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
fieldset:disabled input, fieldset:disabled select, fieldset:disabled textarea { background: #f9fafb; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: normal; }
.help { margin-top: 4px; font-size: 12px; color: var(--muted); }
.req { color: var(--err-text); }
.actions { display: flex; gap: 8px; margin-top: 8px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { padding: 8px 16px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #f9fafb; font-weight: 500; color: #52606d; }
tbody tr:hover { background: #f9fafb; }
table.perm { max-width: 480px; margin-bottom: 16px; }
.result-head { font-weight: 600; margin-bottom: 12px; }
.result-head .muted { font-weight: normal; margin-left: 8px; }

/* 首页 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tile { color: var(--text); margin: 0; transition: border-color .15s; }
.tile:hover { border-color: var(--primary); text-decoration: none; }
.ic { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -0.125em; flex: none; }
.tile-ico { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px;
  background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); font-size: 20px; }
.tile-name { font-weight: 600; margin: 6px 0 2px; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.card.login { width: 360px; max-width: 100%; padding: 32px; }
.login h1 { font-size: 22px; margin-bottom: 4px; }
.login > p { margin: 0 0 20px; }
.login label { margin-bottom: 14px; }
.login input { margin-top: 6px; }
.login .btn { margin-top: 8px; padding: 10px; }

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .content { padding: 16px; }
}

/* 功能页扩展 */
.head-actions { display: flex; gap: 8px; align-items: flex-start; }
.btn.sm { padding: 3px 10px; font-size: 12px; }
.btn.danger { color: var(--err-text); }
.inline { display: inline; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #9aa5b1; margin-right: 6px; vertical-align: middle; }
.dot.online { background: #22c55e; }
.dot.offline { background: #ef4444; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; white-space: normal; }
.steps { margin: 0; padding-left: 20px; color: #52606d; }
.steps li { margin: 2px 0; }
details.raw summary { cursor: pointer; color: var(--primary); }
details.raw pre { margin: 6px 0 0; max-width: 720px; max-height: 320px; overflow: auto; background: #f9fafb; padding: 8px; border-radius: 6px; font-size: 12px; white-space: pre-wrap; word-break: break-all; }
td.wrap { white-space: normal; }
.form-inline { display: grid; grid-template-columns: 1fr 1fr 1fr auto auto auto; gap: 8px; align-items: end; }
.form-inline label { font-size: 12px; color: var(--muted); display: block; }
@media (max-width: 760px) { .form-inline { grid-template-columns: 1fr; } }
.btn, .badge { white-space: nowrap; }
td.wrap { min-width: 260px; }
.doc h4 { margin: 16px 0 6px; }
.doc p { margin: 6px 0; }
.doc code, .doc .code { background: #f3f4f6; padding: 1px 5px; border-radius: 4px; }
pre.code-block { background: #111827; color: #e5e7eb; padding: 12px; border-radius: 6px; overflow-x: auto; font-size: 12px; line-height: 1.5; }

/* 列表页顶部的筛选栏：搜索框占满剩余宽度，下拉框按内容宽度排在同一行（窄屏自动换行） */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-bar input:not([type=hidden]):not([type=checkbox]):not([type=radio]) { flex: 1 1 220px; width: auto; min-width: 0; }
.filter-bar select { flex: 0 0 auto; width: auto; max-width: 100%; }
