* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #2563eb; --primary-dark: #1d4ed8; --bg: #f4f6fa; --card: #ffffff;
  --text: #1f2937; --muted: #6b7280; --border: #e5e7eb; --danger: #dc2626;
  --success: #16a34a; --warn: #f59e0b;
}
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }

/* 登录页 */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, #e0e7ff 0%, #f4f6fa 50%, #dbeafe 100%); }
.login-box { width: 380px; background: var(--card); border-radius: 14px; padding: 36px;
  box-shadow: 0 12px 40px rgba(37,99,235,.15); }
.login-logo { text-align: center; font-size: 22px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.login-box h2 { text-align: center; margin-bottom: 24px; font-size: 18px; font-weight: 600; }
.login-box label { display: block; margin: 14px 0 6px; font-weight: 500; }
.login-box input { width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; outline: none; }
.login-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.login-box input[readonly] { cursor: pointer; }
.login-box button { width: 100%; margin-top: 22px; padding: 11px; background: var(--primary);
  color: #fff; border: 0; border-radius: 8px; font-size: 15px; cursor: pointer; font-weight: 600; }
.login-box button:hover { background: var(--primary-dark); }
.login-box .hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 14px; }
.err { color: var(--danger); min-height: 20px; margin-top: 10px; font-size: 13px; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; flex-shrink: 0; background: #111827; color: #d1d5db;
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; }
.brand { padding: 22px 20px; font-size: 17px; font-weight: 700; color: #fff;
  border-bottom: 1px solid #1f2937; }
.sidebar nav { padding: 14px 10px; flex: 1; }
.sidebar nav a { display: block; padding: 11px 14px; margin: 3px 0; border-radius: 8px;
  color: #d1d5db; cursor: pointer; font-size: 14px; }
.sidebar nav a:hover { background: #1f2937; color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.nav-badge { float: right; background: var(--danger); color: #fff; border-radius: 10px;
  padding: 0 7px; font-size: 11px; line-height: 18px; font-weight: 700; }
.sidebar-foot { padding: 16px; border-top: 1px solid #1f2937; font-size: 12px; }
.sidebar-foot #teamName { display: block; margin-bottom: 10px; color: #9ca3af; }
.sidebar-foot button { width: 100%; padding: 8px; background: #1f2937; color: #d1d5db;
  border: 1px solid #374151; border-radius: 6px; cursor: pointer; }
.sidebar-foot button:hover { background: #374151; color: #fff; }
.main { margin-left: 220px; flex: 1; min-width: 0; }
.topbar { height: 62px; background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 26px; }
.topbar h1 { font-size: 18px; font-weight: 600; }
.user-chip { background: #eff6ff; color: var(--primary); padding: 6px 12px;
  border-radius: 20px; font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
/* 与「管理员：admin」标签同款：浅蓝底、蓝字、同字号，看着协调 */
.top-logout { padding: 6px 12px; background: #eff6ff; color: var(--primary);
  border: 1px solid #dbeafe; border-radius: 20px; cursor: pointer;
  font-size: 13px; white-space: nowrap; }
.top-logout:hover { background: #dbeafe; border-color: #bfdbfe; }
.content { padding: 24px 26px; }

/* 卡片与统计 */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 22px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.stat-card .label { color: var(--muted); font-size: 13px; }
.stat-card .value { font-size: 30px; font-weight: 700; margin: 8px 0 2px; }
.stat-card.c-blue .value { color: var(--primary); }
.stat-card.c-green .value { color: var(--success); }
.stat-card.c-orange .value { color: var(--warn); }
.stat-card.c-red .value { color: var(--danger); }
.stat-card.c-purple .value { color: #7c3aed; }
.stat-card.c-teal .value { color: #0d9488; }
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.panel h3 { font-size: 15px; margin-bottom: 14px; font-weight: 600; }

/* 表格 */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select { padding: 8px 11px; border: 1px solid var(--border);
  border-radius: 7px; font-size: 13px; outline: none; }
.toolbar input:focus, .toolbar select:focus { border-color: var(--primary); }
.toolbar .spacer { flex: 1; }
/* 筛选状态提示：避免把搜索过滤误认为设备丢失 */
.filter-hint { display:none; align-items:center; gap:10px; background:#fff7ed; color:#9a3412;
  border:1px solid #fed7aa; border-radius:7px; padding:7px 12px; font-size:13px; }
.filter-hint.show { display:inline-flex; }
.filter-hint b { color:#c2410c; }
.filter-hint .btn-clear { background:#c2410c; color:#fff; border:none; border-radius:6px;
  padding:5px 11px; font-size:12px; cursor:pointer; }
.filter-hint .btn-clear:hover { background:#9a3412; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #f9fafb; color: var(--muted); font-weight: 600; font-size: 12px; }
tr:hover td { background: #f9fafb; }
.table-wrap { overflow-x: auto; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; }
.badge-online { background: #dcfce7; color: var(--success); }
.badge-offline { background: #f3f4f6; color: var(--muted); }
.badge-manual { background: #dbeafe; color: var(--primary); }
.badge-auto { background: #fef3c7; color: #b45309; }
.badge-important { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; font-weight: 600; }

/* IP 变更重点提醒 */
.ip-num { font-family: Consolas, Monaco, monospace; font-weight: 600; }
tr.row-important td { background: #fff7f7; }
tr.row-important td:first-child { box-shadow: inset 3px 0 0 #dc2626; }
tr.row-important:hover td { background: #fef2f2; }
.alert-bar { display: flex; align-items: center; gap: 14px; background: #fff7ed;
  border: 1px solid #fed7aa; border-radius: 12px; padding: 14px 18px; margin-bottom: 18px; }
.alert-icon { flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; background: #f59e0b;
  color: #fff; font-weight: 700; text-align: center; line-height: 26px; font-size: 15px; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; color: #92400e; margin-bottom: 6px; }
.alert-list { display: flex; flex-wrap: wrap; gap: 8px; }
.alert-chip { background: #fff; border: 1px solid #fde68a; border-radius: 20px;
  padding: 3px 11px; font-size: 12px; color: #78350f; }
.alert-chip b { font-weight: 600; }
.alert-chip i { font-style: normal; color: var(--muted); margin-left: 6px; }
.nic-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 22px; }
.nic-item { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; }
.nic-item .name { color: var(--text); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nic-item .ip { font-family: Consolas, Monaco, monospace; font-weight: 600; color: var(--primary); }
.nic-item .mac { color: var(--muted); font-family: Consolas, Monaco, monospace; }
.nic-item.virtual { background: #f9fafb; }
.prn-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 22px; }
.prn-item { display: flex; justify-content: space-between; align-items: center; gap: 14px;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; }
.prn-item .pname { color: var(--text); font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.prn-item .pmeta { color: var(--muted); font-family: Consolas, Monaco, monospace;
  text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46%; }
.prn-item .pstate { font-size: 11px; color: var(--muted); }
.prn-item .pstate.on { color: var(--success); }
.prn-item .pstate.off { color: var(--danger); }
.prn-item.virtual { background: #f9fafb; }
.badge-mini { font-size: 10px; padding: 1px 6px; border-radius: 20px; border: 1px solid var(--border);
  color: var(--muted); background: #fff; font-weight: 500; }
.badge-mini.blue { color: var(--primary); border-color: #bfd7f5; background: #eff6fe; }
.badge-mini.gray { color: #6b7280; }
.badge-mini.green { color: #0f766e; border-color: #b6e3dd; background: #f0fdfa; }
.badge-mini.orange { color: #b45309; border-color: #f3d9a4; background: #fffbeb; }
.section-title span { font-size: 12px; margin-left: 4px; }
.badge-mini.red { color: var(--danger); border-color: #f5c2c2; background: #fdf2f2; }
.ip-history { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 22px; }
.ip-hist-row { display: flex; justify-content: space-between; gap: 16px; padding: 9px 12px;
  font-size: 12px; border-bottom: 1px solid var(--border); }
.ip-hist-row:last-child { border-bottom: 0; }
.ip-hist-row .t { color: var(--muted); font-family: Consolas, Monaco, monospace; }
.ip-hist-row .v s { color: var(--muted); }
.ip-hist-row .v b { color: #b91c1c; font-family: Consolas, Monaco, monospace; }
.btn { padding: 7px 13px; border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 7px; cursor: pointer; font-size: 13px; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-warn { color: #b8860b; }
.btn-warn:hover { border-color: #b8860b; color: #b8860b; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }

/* 详情模态框 */
.modal-mask { position: fixed; inset: 0; background: rgba(17,24,39,.5);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: var(--card); border-radius: 14px; width: 720px; max-width: 100%;
  max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; }
.modal-close { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); text-align: right; }
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 24px; margin-bottom: 22px; }
.kv .item { border-bottom: 1px dashed var(--border); padding-bottom: 6px; }
.kv .k { color: var(--muted); font-size: 12px; }
.kv .v { font-weight: 500; word-break: break-all; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.form-grid input { width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 7px; font-size: 13px; outline: none; }
.form-grid input:focus { border-color: var(--primary); }
.section-title { font-weight: 600; margin: 8px 0 14px; padding-left: 9px; border-left: 3px solid var(--primary); }
.toast { position: fixed; top: 20px; right: 24px; background: #111827; color: #fff;
  padding: 11px 18px; border-radius: 8px; z-index: 100; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.invite-box { display: flex; align-items: center; gap: 10px; margin: 12px 0 6px; }
.invite-code { font-family: Consolas, Monaco, monospace; font-size: 20px; font-weight: 700;
  color: var(--primary); background: #eff6ff; padding: 10px 16px; border-radius: 8px; letter-spacing: 1px; }
.muted { color: var(--muted); font-size: 12px; }
/* ---------- 分组折叠（外设按使用人 / 变更按人+项） ---------- */
tr.grp-head { cursor: pointer; background: #f8fafc; }
tr.grp-head:hover td { background: #eff6ff; }
tr.grp-head td { font-weight: 600; border-top: 1px solid var(--border); }
.grp-caret { display: inline-block; width: 14px; color: var(--primary);
  transition: transform .15s; font-size: 11px; }
.grp-caret.open { transform: rotate(90deg); }
.grp-name { font-weight: 700; }
.grp-count { font-size: 11px; font-weight: 600; color: var(--primary);
  background: #eff6fe; border: 1px solid #bfd7f5; border-radius: 20px;
  padding: 1px 8px; margin-left: 8px; }
.grp-sub { color: var(--muted); font-size: 11.5px; font-weight: 400; margin-left: 10px; }
tr.grp-detail td { background: #fff; }
tr.grp-detail td:first-child { padding-left: 30px; color: var(--muted); }
tr.grp-detail td:first-child::before { content: "└ "; color: #cbd5e1; }
tr.grp-detail:hover td { background: #fafbfc; }
/* ---------- 服务器运行状态监控 ---------- */
.alert-bar-danger { background: #fef2f2; border-color: #fecaca; }
.alert-icon-danger { background: var(--danger); }
.alert-bar-danger .alert-title { color: #991b1b; }
.alert-bar-danger .alert-chip { border-color: #fecaca; color: #991b1b; }
.alert-chip.crit { background: #fee2e2; border-color: #fca5a5; font-weight: 600; }
.alert-chip.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; align-items: end; }
.settings-grid label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.settings-grid input { width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 7px; font-size: 13px; outline: none; }
.settings-grid input:focus { border-color: var(--primary); }
.settings-actions { display: flex; align-items: flex-end; }
.add-server { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--border); }
.add-server select { padding: 8px 11px; border: 1px solid var(--border);
  border-radius: 7px; font-size: 13px; min-width: 220px; outline: none; }

.modal-wide { width: 900px; }
.gauge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 22px; }
.gauge { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.gauge-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.gauge-head .g-name { font-size: 13px; color: var(--muted); }
.gauge-head .g-val { font-size: 22px; font-weight: 700; }
.gauge-head .g-val.ok { color: var(--success); }
.gauge-head .g-val.warn { color: var(--warn); }
.gauge-head .g-val.crit { color: var(--danger); }
.gauge-sub { font-size: 11px; color: var(--muted); margin-top: 8px; }
.bar { height: 8px; border-radius: 6px; background: #eef1f5; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; transition: width .3s; }
.bar-fill.ok { background: var(--success); }
.bar-fill.warn { background: var(--warn); }
.bar-fill.crit { background: var(--danger); }
.bar-cell { min-width: 96px; }
.bar-cell .bar { height: 7px; }
.bar-cell .pct { font-size: 11px; font-weight: 600; }

.alert-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; font-size: 12px; }
.alert-item.crit { background: #fef2f2; border-color: #fecaca; }
.alert-item.warn { background: #fffbeb; border-color: #fde68a; }
.alert-item .a-cat { font-weight: 700; flex-shrink: 0; }
.alert-item.crit .a-cat { color: var(--danger); }
.alert-item.warn .a-cat { color: #b45309; }
.alert-item .a-msg { flex: 1; }
.alert-item .a-host { color: var(--muted); font-family: Consolas, Monaco, monospace; }
.no-alert { padding: 12px; border: 1px solid #bbf7d0; background: #f0fdf4;
  border-radius: 8px; color: #15803d; font-size: 13px; margin-bottom: 20px; }

.trend-wrap { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 22px; }
.trend-legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.trend-legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px;
  vertical-align: middle; margin-right: 5px; }
.trend-svg { width: 100%; height: 170px; display: block; }
.disk-row, .listen-row { display: flex; justify-content: space-between; gap: 12px;
  padding: 8px 12px; border-bottom: 1px dashed var(--border); font-size: 12px; }
.disk-row:last-child, .listen-row:last-child { border-bottom: 0; }
.port-chip { display: inline-block; padding: 3px 9px; margin: 0 6px 6px 0; border-radius: 6px;
  background: #eff6ff; border: 1px solid #bfdbfe; color: var(--primary);
  font-family: Consolas, Monaco, monospace; font-size: 12px; }
.port-chip b { font-weight: 600; }
.port-chip span { color: var(--muted); font-family: inherit; margin-left: 5px; }
.badge-crit { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; font-weight: 600; }
.badge-ok { background: #dcfce7; color: var(--success); }

/* 使用人名字可点击进详情 */
.user-link { color: var(--primary); cursor: pointer; border-bottom: 1px dashed #93b8e8; }
.user-link:hover { color: #1e4e8c; border-bottom-style: solid; }
/* 已安装软件列表（电脑 / 服务器详情） */
.sw-summary { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.sw-list { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 22px;
  max-height: 260px; overflow-y: auto; padding: 2px; }
.sw-chip { display: inline-block; padding: 4px 10px; border-radius: 6px; font-size: 12px;
  background: #f3f7fc; border: 1px solid #d7e5f5; color: #274b78; }
.sw-empty { color: var(--muted); font-size: 12px; margin-bottom: 22px; }
.sw-sys-toggle { display: flex; align-items: center; gap: 10px; font-size: 12px;
  margin-bottom: 8px; }
.sw-sys-toggle a { color: #2a6fd0; cursor: pointer; }
.sw-chip-sys { background: #f5f5f7; border-color: #dcdce0; color: #6b6b70; }

@media (max-width: 900px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 64px; } .brand { font-size: 0; padding: 20px; }
  .brand::after { content: "≡"; font-size: 20px; }
  .sidebar nav a { font-size: 0; text-align: center; padding: 14px 0; }
  .sidebar nav a::first-letter { font-size: 16px; }
  .sidebar-foot #teamName { display: none; }
  .main { margin-left: 64px; }
  .kv, .form-grid, .gauge-grid { grid-template-columns: 1fr; }
}
