*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:            #f0f2f5;
  --sidebar-bg:    #1a2537;
  --sidebar-hover: #28364e;
  --sidebar-active:#3b82f6;
  --text:          #1f2937;
  --text-muted:    #6b7280;
  --text-light:    #e2e8f0;
  --border:        #e5e7eb;
  --white:         #ffffff;
  --primary:       #3b82f6;
  --primary-h:     #2563eb;
  --danger:        #ef4444;
  --danger-h:      #dc2626;
  --success:       #22c55e;
  --warning:       #f59e0b;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --radius:        8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
               'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ───────────── Icons ───────────── */
.icon { display:inline-block; vertical-align:middle; width:16px; height:16px; flex-shrink:0; }
.icon-xl { width:48px; height:48px; opacity:.15; }
.icon-warn { color: var(--warning); }
.icon-ok   { color: var(--success); }
.icon-err  { color: var(--danger); }
.modal-title .icon { width:18px; height:18px; margin-right:4px; vertical-align:-3px; }

/* ───────────── Login ───────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
}
.login-card {
  background: var(--white);
  border-radius: 14px;
  padding: 44px 40px;
  width: 380px;
  max-width: 95vw;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.login-logo { font-size: 30px; font-weight: 800; color: var(--primary); letter-spacing: -.5px; }
.login-subtitle { color: var(--text-muted); font-size: 13px; margin-top: 4px; margin-bottom: 32px; }

/* ───────────── Form ───────────── */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
  color: var(--text);
  background: var(--white);
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ───────────── Buttons ───────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-h); }
.btn-success  { background: #16a34a; color: #fff; }
.btn-success:hover  { background: #15803d; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover   { background: var(--danger-h); }
.btn-secondary {
  background: #f3f4f6;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #e5e7eb; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: #f3f4f6; color: var(--text); }
.btn-sm   { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; font-weight: 600; }
.btn:disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }

/* ───────────── Alerts ───────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-error   { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.hidden { display: none !important; }

/* ───────────── App Layout ───────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  user-select: none;
}
.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-logo { font-size: 20px; font-weight: 800; color: #fff; letter-spacing: -.3px; }
.sidebar-logo span { color: var(--primary); }
.sidebar-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,.4);
  letter-spacing: .06em;
  margin-top: 2px;
}

.sidebar-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.sidebar-section { padding: 14px 14px 0; }
.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,.3);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 0 8px;
  margin-bottom: 6px;
}
.nodes-list { padding: 0 14px 14px; flex: 1; }

.sidebar-search-wrap { padding: 0 14px 10px; }
.sidebar-search {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  background: rgba(255,255,255,.08);
  color: #fff;
  font-size: 12px;
}
.sidebar-search::placeholder { color: rgba(255,255,255,.45); }
.sidebar-search:focus {
  outline: none;
  border-color: rgba(59,130,246,.9);
  box-shadow: 0 0 0 2px rgba(59,130,246,.25);
}
.sidebar-search-meta {
  margin-top: 5px;
  font-size: 11px;
  color: rgba(255,255,255,.45);
}

.node-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: rgba(255,255,255,.65);
  font-size: 13px;
  margin-bottom: 2px;
  transition: background .14s, color .14s;
}
.node-item:hover          { background: var(--sidebar-hover); color: #fff; }
.node-item.active         { background: var(--primary); color: #fff; }
.node-dot                 { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.node-dot.on              { background: var(--success); }
.node-dot.off             { background: rgba(255,255,255,.25); }
.node-dot.err             { background: var(--danger); }
.node-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.node-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.node-item-host {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: rgba(255,255,255,.5);
}
.node-item.active .node-item-host { color: rgba(255,255,255,.8); }

.node-item-badge { flex-shrink: 0; }
.node-item:hover .node-item-badge { display: none; }

.node-item-actions { display: none; gap: 3px; flex-shrink: 0; }
.node-item:hover .node-item-actions { display: flex; }

.node-action-btn {
  background: rgba(255,255,255,.12);
  border: none;
  border-radius: 4px;
  color: rgba(255,255,255,.8);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 3px 6px;
  transition: background .12s, color .12s;
}
.node-action-btn:hover { background: rgba(255,255,255,.25); color: #fff; }
.node-action-del:hover { background: rgba(239,68,68,.5); color: #fff; }

.badge-toggle { cursor: pointer; transition: opacity .15s; }
.badge-toggle:hover { opacity: .75; }

.sidebar-add-node {
  margin: 0 14px 16px;
  width: calc(100% - 28px);
}

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: rgba(255,255,255,.5);
}
.sidebar-username { font-weight: 600; color: rgba(255,255,255,.8); }

/* Main */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 54px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 12px;
}
.topbar-title { font-size: 15px; font-weight: 600; flex: 1; }
.topbar-breadcrumb { color: var(--text-muted); font-size: 13px; }

.content { flex: 1; overflow-y: auto; padding: 24px; }

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 10px;
  text-align: center;
}
.empty-icon { display:flex; justify-content:center; margin-bottom:4px; color:var(--text-muted); }
.empty-state p { font-size: 15px; }
.empty-state small { font-size: 12px; }

/* Card */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}
.card-title { font-size: 14px; font-weight: 600; }
.users-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.user-search {
  min-width: 220px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
}
.user-search:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

/* Node Meta Card */
.node-meta-card { padding: 16px 20px; }
.node-meta-card .card-header { margin-bottom: 0; }
.node-meta-info { display: flex; flex-direction: column; gap: 3px; }
.node-meta-name { font-size: 16px; font-weight: 700; color: var(--text); }
.node-meta-host { font-size: 12px; color: var(--text-muted); font-family: monospace; }
.node-meta-remark { font-family: sans-serif; color: var(--text-muted); }

/* Node Info Bar (legacy, keep for compatibility) */
.node-infobar {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.infobar-name { font-size: 16px; font-weight: 700; }
.infobar-host { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.infobar-actions { margin-left: auto; display: flex; gap: 8px; }

/* Stats row */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.stat-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.stat-value { font-size: 20px; font-weight: 700; }

/* Table */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }
.td-email { font-family: monospace; font-size: 12px; }
.td-up   { color: #16a34a; font-weight: 500; }
.td-down { color: #2563eb; font-weight: 500; }
.td-actions { white-space: nowrap; }
.tbl-placeholder { text-align: center; padding: 28px; color: var(--text-muted); }

/* Badge */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green { background: #dcfce7; color: #15803d; }
.badge-gray  { background: #f3f4f6; color: #6b7280; }
.badge-blue  { background: #dbeafe; color: #1d4ed8; }
.badge-red   { background: #fef2f2; color: #b91c1c; }

/* Modal */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--white);
  border-radius: 12px;
  padding: 28px 28px 22px;
  width: 440px;
  max-width: 95vw;
  box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 22px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* Loading spinner */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────────── Node Checklist ───────────── */
.node-checklist {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-top: 4px;
}
.node-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 4px;
  transition: background .12s;
}
.node-check-item:hover { background: #f3f4f6; }
.node-check-item input[type=checkbox] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }

/* 节点分配复选框列表 */
.node-cb-list label { display: flex !important; align-items: center; font-size: 13px; font-weight: 400; color: var(--text); text-transform: none; letter-spacing: 0; margin-bottom: 0; }
.node-cb-list input[type=checkbox] { width: 15px !important; height: 15px; flex-shrink: 0; cursor: pointer; accent-color: var(--primary); padding: 0; border: none; box-shadow: none; }
.node-check-name { flex: 1; font-weight: 500; }
.node-check-host { color: var(--text-muted); font-size: 11px; font-family: monospace; }
.checklist-ctrl { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.checklist-ctrl a {
  font-size: 11px;
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
  background: rgba(59,130,246,.1);
  border: 1px solid rgba(59,130,246,.25);
  padding: 2px 10px;
  border-radius: 99px;
  transition: background .12s;
}
.checklist-ctrl a:hover { background: rgba(59,130,246,.2); }

/* Broadcast result */
.bcast-results {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 12px;
}
.bcast-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.bcast-row:last-child { border-bottom: none; }
.bcast-row.ok   { background: #f0fdf4; }
.bcast-row.fail { background: #fef2f2; }
.bcast-icon { font-size: 14px; flex-shrink: 0; }
.bcast-name { font-weight: 600; flex: 1; }
.bcast-msg  { font-size: 11px; color: var(--text-muted); }
.bcast-summary {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ───────────── Overview Summary Bar ───────────── */
.ov-summary {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.ov-sum-item {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 20px;
  flex: 1;
  min-width: 100px;
}
.ov-sum-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}
.ov-sum-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
}
.ov-sum-val.ok   { color: var(--success); }
.ov-sum-val.up   { color: #16a34a; }
.ov-sum-val.down { color: #2563eb; }

/* ───────────── Overview ───────────── */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.ov-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
  border: 2px solid transparent;
}
.ov-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.1); transform: translateY(-1px); }
.ov-card.offline { opacity: .7; border-color: #fecaca; }
.ov-card.ov-loading { opacity: .6; pointer-events: none; }
.ov-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.ov-card-name { font-size: 15px; font-weight: 700; }
.ov-card-host { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.ov-metrics { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.ov-metric-label { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing:.04em; margin-bottom: 4px; }
.ov-metric-value { font-size: 16px; font-weight: 700; }
.ov-metric-value.up   { color: #16a34a; }
.ov-metric-value.down { color: #2563eb; }
.ov-metric-value.err  { color: var(--danger); font-size: 12px; }

/* Refresh badge */
.refresh-badge {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 8px;
  white-space: nowrap;
}

/* Toast */
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 10px 25px rgba(0,0,0,.2);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: #15803d; }
.toast-warn { background: #b45309; }

/* 用户表格：超限/过期行高亮 */
.tr-warn { background: #fffbeb; }
.td-danger { color: var(--danger); font-weight: 600; }

@media (max-width: 960px) {
  .sidebar { width: 210px; }
  .content { padding: 14px; }
  .topbar { padding: 0 12px; }
  .users-toolbar { width: 100%; }
  .user-search { min-width: 150px; flex: 1; }
}

@media (max-width: 720px) {
  .app { flex-direction: column; height: auto; min-height: 100vh; }
  .sidebar { width: 100%; }
  .main { min-height: 70vh; }
  .node-infobar { padding: 12px; gap: 10px; }
  .infobar-actions { margin-left: 0; width: 100%; }
  .infobar-actions .btn { flex: 1; }
  .content { padding: 10px; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
