:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --border: #e5e7eb;
}

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

body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

header h1 { font-size: 20px; }

.header-right { display: flex; align-items: center; gap: 12px; }

.muted { color: var(--muted); font-size: 13px; }

main { max-width: 960px; margin: 24px auto; padding: 0 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.login-card { max-width: 380px; margin: 64px auto; }

.login-card h2 { margin-bottom: 16px; font-size: 18px; }

form label { display: block; margin-bottom: 12px; font-size: 14px; }

form input {
  width: 100%;
  margin-top: 6px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

form input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

.btn {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn:hover { background: #f3f4f6; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-ghost { border: none; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--err); background: transparent; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.toolbar-right { display: flex; align-items: center; gap: 10px; }

.toolbar h2 { font-size: 18px; }

.hosts { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }

.host-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.host-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.host-head strong { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot.online { background: var(--ok); }
.dot.offline { background: #9ca3af; }
.dot.pending_online { background: var(--warn); animation: pulse 1.2s infinite; }

@keyframes pulse { 50% { opacity: 0.4; } }

.badge {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--muted);
}

.badge.online { background: #dcfce7; color: var(--ok); }
.badge.offline { background: #f3f4f6; color: #6b7280; }
.badge.pending_online { background: #fef3c7; color: var(--warn); }
.badge.ok { background: #dcfce7; color: var(--ok); }
.badge.err { background: #fee2e2; color: var(--err); }

.host-meta { font-size: 13px; line-height: 1.8; color: #374151; margin-bottom: 12px; }
.host-meta code { background: #f3f4f6; padding: 1px 6px; border-radius: 4px; }

.host-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.action-result { font-size: 13px; color: var(--muted); }

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: -1px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== 模态框 ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay[hidden] { display: none; }

.modal-card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px 24px;
  width: 400px;
  max-width: 92vw;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.modal-card h3 { margin-bottom: 12px; font-size: 18px; }
.modal-card p { margin: 8px 0; font-size: 14px; }
.modal-card code { background: #f3f4f6; padding: 1px 6px; border-radius: 4px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.radio-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  margin: 6px 0;
  cursor: pointer;
}

.radio-row input { width: auto; margin: 0; }

/* ==================== Toast ==================== */
.toast-box {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
  border-left: 4px solid var(--primary);
  animation: toast-in 0.25s ease;
  max-width: 360px;
}

.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast-out { opacity: 0; transition: opacity 0.3s; }

@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
}

.pw-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.login-form {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.login-form input { flex: 1; min-width: 100px; margin-top: 0; }
.login-form .remember {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  margin: 0;
}
.login-form .remember input { width: auto; flex: none; margin: 0; }
.login-form .login-result { width: 100%; font-size: 13px; color: var(--muted); }

.pw-form input { flex: 1; min-width: 120px; }
.pw-form .pw-result { width: 100%; font-size: 13px; color: var(--muted); }

.error { color: var(--err); font-size: 13px; margin-top: 12px; }

.wake-form { display: flex; flex-wrap: wrap; gap: 8px; }
.wake-form input { flex: 1; min-width: 220px; margin-top: 0; }
.wake-form .pw-result { width: 100%; font-size: 13px; color: var(--muted); }

#enrollCard { margin-bottom: 16px; border-color: #fcd34d; }



.btn-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--err);
}

.btn-danger:hover { background: #fee2e2; }

section.card { margin-bottom: 16px; }
