:root {
  --bg: #f5f6f8; --panel: #fff; --line: #e3e6eb; --text: #1f2329; --muted: #8a919c;
  --primary: #2f6fed; --ok: #22a06b; --off: #b8bec7; --danger: #d64545;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); }
[hidden] { display: none !important; }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
button { font: inherit; padding: 5px 12px; border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; }
button:hover { border-color: var(--primary); color: var(--primary); }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { filter: brightness(1.08); color: #fff; }
button.danger:hover { border-color: var(--danger); color: var(--danger); }
button.small { padding: 1px 8px; font-size: 12px; }
input, select { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
input:focus, select:focus { outline: none; border-color: var(--primary); }
label { display: block; margin-bottom: 12px; color: var(--muted); }
label input { display: block; width: 100%; margin-top: 4px; color: var(--text); }
label.check { display: inline-flex; align-items: center; gap: 4px; margin: 0; color: var(--text); white-space: nowrap; }
.err { color: var(--danger); min-height: 1.5em; margin: 4px 0; }
.hint { color: var(--muted); margin: 0 0 12px; }

.center-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 24px; }
.panel.narrow { width: 320px; }
.panel.narrow h1 { margin-bottom: 20px; text-align: center; }
.panel.narrow button { width: 100%; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }

.topbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar .spacer { flex: 1; }
.topbar #search { width: 240px; }
.stats { color: var(--muted); }
.latest { padding: 2px 10px; border-radius: 12px; background: #eef3fe; color: var(--primary); font-size: 13px; }
.latest.warn { background: #fdf3e7; color: #b26a00; }
.latest .mono, .ver .mono { font-family: ui-monospace, Consolas, monospace; }
.tag-upgrade { margin-left: 6px; padding: 0 6px; border-radius: 8px; background: #fdf3e7; color: #b26a00; font-size: 12px; }
/* 整页固定高度：顶栏 + 左树 / 右内容各自独立滚动 */
#view-main { display: flex; flex-direction: column; height: 100vh; }
.layout { flex: 1; min-height: 0; display: flex; }
.content { flex: 1; min-width: 0; overflow: auto; }
.content-head { display: flex; align-items: baseline; gap: 8px; padding: 16px 20px 0; font-size: 15px; }
.content-head .count { color: var(--muted); font-size: 13px; }
main { padding: 12px 20px 16px; }
.foot { padding: 0 20px 20px; color: var(--muted); font-size: 12px; }

/* 左侧分组树：固定在顶栏下方，独立滚动 */
.sidebar { width: 220px; flex-shrink: 0; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 12px 8px; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 8px; color: var(--muted); font-size: 12px; }
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: 14px; }
.tree ul.collapsed { display: none; }
.node { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-radius: 6px; cursor: pointer; user-select: none; }
.node:hover { background: #f0f2f5; }
.node.active { background: #e8f0fe; color: var(--primary); font-weight: 500; }
.node .twisty { display: inline-block; width: 14px; text-align: center; color: var(--muted); font-size: 11px; transition: transform .15s; }
.node .twisty.closed { transform: rotate(-90deg); }
.node .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .num { color: var(--muted); font-size: 12px; font-weight: normal; }

.group { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th { font-weight: 500; color: var(--muted); background: #fafbfc; font-size: 12px; }
tr:last-child td { border-bottom: none; }
tr.offline td { color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--off); }
.dot.on { background: var(--ok); }
.alias { cursor: text; min-width: 80px; display: inline-block; }
.alias.empty { color: var(--off); }
.alias-input { width: 160px; padding: 2px 6px; }
.id { font-family: ui-monospace, Consolas, monospace; cursor: copy; }
.id.alt { color: var(--muted); font-size: 12px; }
.ips a, .ips span { display: block; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.ops { display: flex; gap: 6px; align-items: center; }
.empty-tip { padding: 40px; text-align: center; color: var(--muted); }

dialog { border: none; padding: 0; background: transparent; }
dialog::backdrop { background: rgba(0, 0, 0, .3); }
dialog .panel { width: 420px; }
#dlg-groups .panel { width: 600px; }
.group-list li select, .row select { max-width: 220px; }
.group-list { list-style: none; padding: 0; margin: 0 0 12px; max-height: 320px; overflow-y: auto; }
.group-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.group-list li .name { flex: 1; }
.group-list li input { flex: 1; }

.toast { position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%); background: rgba(31, 35, 41, .9); color: #fff; padding: 8px 16px; border-radius: 6px; z-index: 10; }
