:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1b1f24;
  --muted: #667085;
  --border: #e4e7ec;
  --accent: #2f6feb;
  --accent-text: #ffffff;
  --ok: #12a150;
  --off: #98a2b3;
  --danger: #d92d20;
  --code-bg: #f2f4f7;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #171a21;
    --text: #e6e8eb;
    --muted: #98a2b3;
    --border: #2a2f3a;
    --accent: #5b8cff;
    --accent-text: #0f1115;
    --ok: #32d583;
    --off: #667085;
    --danger: #f97066;
    --code-bg: #1f2430;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 5px; }

/* layout */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 0 24px; height: 56px;
  background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 650; font-size: 15px; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 7px; white-space: nowrap; }
.nav a.active, .nav a:hover { color: var(--text); background: var(--code-bg); text-decoration: none; }
.who { color: var(--muted); display: flex; gap: 10px; align-items: center; white-space: nowrap; }
main { max-width: 1080px; margin: 0 auto; padding: 24px; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.sub { color: var(--muted); margin-top: 2px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.host-card { display: block; color: inherit; }
.host-card:hover { text-decoration: none; border-color: var(--accent); }
.host-card .name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin-top: 10px; color: var(--muted); }
.kv b { color: var(--text); font-weight: 500; overflow-wrap: anywhere; }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--off); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--code-bg); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--ok); }
.badge.bad { color: var(--danger); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
.empty { color: var(--muted); padding: 18px 4px; }

/* forms */
button, .btn {
  font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: 6px 12px; border-radius: 8px; min-height: 32px;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 550; }
button.danger { color: var(--danger); }
button.link { border: 0; background: none; color: var(--accent); padding: 0 4px; min-height: 0; }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: block; color: var(--muted); font-size: 12.5px; margin: 12px 0 5px; }
input, select, textarea {
  font: inherit; width: 100%; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.row > button { flex: none; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.error { color: var(--danger); margin-top: 10px; min-height: 1em; }

/* secret display */
.secret { position: relative; background: var(--code-bg); border-radius: 8px; padding: 10px 76px 10px 12px; margin: 6px 0 12px; overflow-wrap: anywhere; }
.secret button { position: absolute; right: 8px; top: 8px; min-height: 26px; padding: 2px 10px; }
.warn { color: var(--muted); font-size: 12.5px; }

/* login */
.login { max-width: 360px; margin: 12vh auto; }
.login h1 { margin-bottom: 4px; }

/* modal & toast */
dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--panel); color: var(--text); padding: 22px; width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .35); }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; transition: .2s; pointer-events: none; max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 640px) {
  .topbar { padding: 0 16px; gap: 10px; }
  main { padding: 16px; }
  .who span { display: none; }
}
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
