:root {
  --primary: #4f6ef7;
  --bg: #f5f7fb;
  --card: #fff;
  --text: #1f2430;
  --muted: #7a8199;
  --border: #e6e9f2;
  --radius: 12px;
  --side-w: 190px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg); color: var(--text); visibility: hidden;
}
body.ready { visibility: visible; }
a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

.layout { display: flex; min-height: 100vh; }
.side {
  width: var(--side-w); background: #23283b; color: #cfd4e6;
  padding: 20px 10px; flex-shrink: 0;
}
.side .logo { color: #fff; font-weight: 700; font-size: 1.05rem; padding: 0 10px 20px; }
.side .logo span { color: #8ea2ff; }
.side a {
  display: block; padding: 10px 12px; border-radius: 8px;
  color: #cfd4e6; margin-bottom: 4px; font-size: .92rem;
}
.side a:hover { background: rgba(255,255,255,.08); }
.side a.active { background: var(--primary); color: #fff; }
.main { flex: 1; padding: 28px 32px; overflow-x: auto; }
.main h1 { font-size: 1.3rem; margin-bottom: 20px; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.stat .num { font-size: 1.7rem; font-weight: 700; color: var(--primary); }
.stat .lbl { color: var(--muted); font-size: .85rem; margin-top: 4px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: .82rem; }
tr:last-child td { border-bottom: none; }

.btn {
  display: inline-block; border: none; border-radius: 8px; padding: 9px 18px;
  font-size: .9rem; background: var(--primary); color: #fff;
}
.btn:hover { opacity: .9; }
.btn.small { padding: 5px 12px; font-size: .82rem; }
.btn.ghost { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn.danger { background: #e05252; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: .78rem; }
.badge.on { background: #e3f7e9; color: #189a4c; }
.badge.off { background: #f3f4f8; color: var(--muted); }
.badge.warn { background: #fff4e0; color: #c77f0a; }

input, textarea, select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: .9rem; font-family: inherit;
}
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(79,110,247,.35); border-color: var(--primary); }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 5px; font-size: .85rem; color: var(--muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.modal-mask {
  position: fixed; inset: 0; background: rgba(20,24,40,.45);
  display: none; align-items: center; justify-content: center; z-index: 100;
}
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: var(--radius); padding: 26px; width: 520px; max-width: 94vw; max-height: 88vh; overflow-y: auto; }
.modal h2 { margin-bottom: 16px; font-size: 1.1rem; }
.modal .err { color: #e05252; font-size: .85rem; min-height: 1.2em; margin-bottom: 6px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  background: #23283b; color: #fff; padding: 10px 20px; border-radius: 8px;
  font-size: .88rem; z-index: 200; display: none;
}
.toast.show { display: block; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; }

/* 登录页 */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: #fff; border-radius: var(--radius); padding: 36px; width: 360px; box-shadow: 0 8px 30px rgba(20,24,40,.08); }
.login-box h1 { font-size: 1.25rem; margin-bottom: 6px; }
.login-box p { color: var(--muted); font-size: .88rem; margin-bottom: 22px; }
