* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif; color: #2b2f36; background: #f3f5f8; }

#app { height: 100%; }
.hidden { display: none !important; }

/* ===== 布局 ===== */
#main-view { display: flex; height: 100%; }
.sidebar {
  width: 220px; background: #1f2733; color: #cdd5e0; display: flex; flex-direction: column;
  flex-shrink: 0;
}
.sidebar .brand {
  padding: 20px 18px; font-size: 17px; font-weight: 700; color: #fff;
  border-bottom: 1px solid #2c3645; letter-spacing: 1px;
}
.sidebar .brand small { display: block; font-size: 11px; font-weight: 400; color: #8a94a6; margin-top: 3px; }
.sidebar nav { padding: 10px 0; flex: 1; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 12px 20px; color: #cdd5e0;
  text-decoration: none; font-size: 14px; cursor: pointer; border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: #283242; }
.sidebar nav a.active { background: #2c3a4f; color: #fff; border-left-color: #ff9f2e; }
.sidebar nav a .ico { width: 18px; text-align: center; }

.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; background: #fff; border-bottom: 1px solid #e6e9ef; display: flex;
  align-items: center; justify-content: space-between; padding: 0 22px;
}
.topbar .title { font-size: 16px; font-weight: 600; }
.topbar .user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #5a6472; }
.topbar .user b { color: #2b2f36; }
#page { padding: 22px; overflow-y: auto; flex: 1; }

/* ===== 卡片/工具条 ===== */
.card { background: #fff; border: 1px solid #e6e9ef; border-radius: 10px; padding: 18px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
input, select, textarea {
  border: 1px solid #d4dae3; border-radius: 7px; padding: 8px 10px; font-size: 13px;
  font-family: inherit; background: #fff; color: #2b2f36; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #ff9f2e; }
.btn {
  border: 1px solid #d4dae3; background: #fff; color: #2b2f36; border-radius: 7px;
  padding: 8px 14px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f5f7fa; }
.btn.primary { background: #ff9f2e; border-color: #ff9f2e; color: #fff; }
.btn.primary:hover { background: #f4911f; }
.btn.danger { color: #d9534f; border-color: #f0c4c2; }
.btn.danger:hover { background: #fdeaea; }
.btn.sm { padding: 5px 10px; font-size: 12px; }

/* ===== 表格 ===== */
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 13px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid #eef1f5; }
th { color: #7a8392; font-weight: 600; background: #fafbfc; }
td .muted { color: #9aa3b1; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; background: #eef1f5; color: #5a6472; margin: 1px 2px; }
.tag.on { background: #e6f7ee; color: #1a9c5b; }
.tag.off { background: #fbeaea; color: #d9534f; }
.badge-status { font-weight: 600; }
.badge-status.on { color: #1a9c5b; }
.badge-status.off { color: #d9534f; }
.row-actions { display: flex; gap: 6px; }

/* ===== 弹窗 ===== */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20,26,34,.45); display: flex;
  align-items: flex-start; justify-content: center; padding-top: 6vh; z-index: 50; overflow-y: auto;
}
.modal { background: #fff; width: 560px; max-width: 94vw; border-radius: 12px; box-shadow: 0 18px 50px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #eef1f5; font-weight: 600; font-size: 15px; }
.modal-head .x { border: none; background: none; font-size: 22px; cursor: pointer; color: #9aa3b1; line-height: 1; }
.modal-body { padding: 20px; max-height: 64vh; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid #eef1f5; display: flex; justify-content: flex-end; gap: 10px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; color: #5a6472; margin-bottom: 6px; }
.form-row input, .form-row select, .form-row textarea { width: 100%; }
.form-row textarea { min-height: 76px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.opt-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.opt-row input[type=text] { flex: 1; }
.opt-row .correct { display: flex; align-items: center; gap: 4px; font-size: 12px; color: #5a6472; }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
.perm-grid label { display: flex; align-items: center; gap: 6px; font-size: 13px; }

/* ===== 其他 ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid #e6e9ef; border-radius: 10px; padding: 18px; }
.stat .n { font-size: 28px; font-weight: 700; color: #ff9f2e; }
.stat .l { font-size: 13px; color: #7a8392; margin-top: 4px; }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 14px; font-size: 13px; color: #7a8392; }
.empty { text-align: center; color: #9aa3b1; padding: 40px 0; }
.login-wrap { height: 100%; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#2b5cff0d,#ff9f2e14); }
.login-card { background: #fff; border-radius: 14px; padding: 34px 30px; width: 340px; box-shadow: 0 16px 44px rgba(0,0,0,.12); }
.login-card h1 { font-size: 19px; margin-bottom: 4px; }
.login-card p { color: #8a94a6; font-size: 13px; margin-bottom: 20px; }
.login-card .form-row { margin-bottom: 16px; }
.login-err { color: #d9534f; font-size: 13px; min-height: 18px; margin-bottom: 8px; }
#toast-root { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #2b2f36; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.ok { background: #1a9c5b; }
.toast.err { background: #d9534f; }
