/* ============================================================
   管理控制台 · lattice 夜色主题（对齐首页 lattice.css 的设计体系）
   深墨背景 + 点阵网格 + 墨色文字 + hot 强调 · panel 玻璃 · Doto 数字
   ============================================================ */

:root {
  --bg: #07080b;
  --bg-2: #0d0f14;
  --ink: #ece7da;
  --text: #ece7da;
  --text-dim: #9d988c;
  --text-faint: #6c685f;
  --hot: #ff5a1f;
  --hot-2: #7fd8ff;
  --amber: #ffb84d;
  --green: #7fd8a4;
  --line: rgb(236 231 218 / 0.14);
  --line-strong: rgb(236 231 218 / 0.3);
  --panel: rgb(7 8 11 / 0.78);
  --panel-solid: #0d0f14;
  --pitch: 9px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --f-ui: "Atkinson Hyperlegible Next", "Noto Sans SC", system-ui, sans-serif;
  --f-dot: "Doto", "Atkinson Hyperlegible Next", monospace;
  --f-zh: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font: 400 15px / 1.6 var(--f-ui);
  color: var(--text);
  background-color: var(--bg);
  /* 背景点阵：静息态的 lattice 网格 */
  background-image: radial-gradient(rgb(236 231 218 / 0.055) 1px, transparent 1.3px);
  background-size: var(--pitch) var(--pitch);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
[lang=zh], body { font-family: var(--f-zh); }
a { color: var(--hot-2); text-decoration: none; }
a:hover { color: var(--hot); }
.hidden { display: none !important; }
.mono, .hint.mono, td.mono { font-family: var(--f-dot); font-weight: 500; letter-spacing: 0.04em; }

@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* ===== 顶部品牌栏（锁定吸顶 · 融入背景，同首页 topbar） ===== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  min-height: 64px;
  padding: 12px clamp(16px, 3vw, 40px);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: rgb(7 8 11 / 0.82);
  backdrop-filter: blur(12px) saturate(140%); -webkit-backdrop-filter: blur(12px) saturate(140%);
  box-shadow: 0 1px 0 var(--line);
  animation: fadeDown 0.6s var(--ease) both;
}
.topbar .brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; border-radius: 8px; }
.topbar .brand:hover .t1 { color: var(--hot); }
.topbar .brand img { height: 42px; width: auto; object-fit: contain; }
.topbar .brand .titles { display: flex; flex-direction: column; }
.topbar .brand .t1 { font: 500 15px / 1.3 var(--f-ui); color: var(--text); transition: color 0.16s; white-space: nowrap; }
.topbar .brand .t2 { font: 700 11px / 1.5 var(--f-dot); letter-spacing: 0.16em; color: var(--text-faint); white-space: nowrap; }

/* 顶栏工具区：搜索 + 部门/审计/新建 */
.topbar .toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.topbar .toolbar .toolbar-input { width: 170px; }
.topbar .who { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-dim); flex-wrap: wrap; justify-content: flex-end; }
.topbar .who .name { color: var(--text); font-weight: 600; white-space: nowrap; }

/* 顶栏按钮 = 首页 ghost 药丸按钮 */
.topbar button, .pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 36px; padding: 0 14px; border: 0; border-radius: 999px;
  background: transparent; color: var(--text); white-space: nowrap;
  box-shadow: inset 0 0 0 1px var(--line-strong);
  font: 600 13px / 1 var(--f-ui); cursor: pointer; user-select: none;
  transition: box-shadow 0.16s, color 0.16s, background 0.16s;
}
.topbar button:hover { box-shadow: inset 0 0 0 1px var(--text); }
.topbar button.primary { background: var(--text); color: var(--bg); box-shadow: none; }
.topbar button.primary:hover { background: #fff; }

/* ===== 主内容：panel 玻璃卡 ===== */
.container { max-width: 1560px; margin: 0 auto; padding: 8px clamp(16px, 4vw, 40px) 48px; width: 100%; }
.card {
  padding: 26px 26px 22px; border-radius: 12px;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: fadeUp 0.6s var(--ease) 0.08s both;
}
.card h2 {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  font: 600 21px / 1.2 var(--f-ui); letter-spacing: -0.01em; margin-bottom: 18px;
}

/* 搜索框 = 首页 lx-field 的点线底边 */
.toolbar-input {
  width: 220px; padding: 9px 2px 11px;
  border: 0; outline: none; border-radius: 0;
  background: radial-gradient(circle, var(--line-strong) 1px, transparent 1.6px) 0 100% / var(--pitch) 4px repeat-x;
  font: 400 13.5px / 1.3 var(--f-ui); color: var(--text);
  transition: background-color 0.16s;
}
.toolbar-input::placeholder { color: var(--text-faint); opacity: 1; }
.toolbar-input:focus {
  background-image: radial-gradient(circle, var(--hot) 1.2px, transparent 1.8px);
}

/* ===== 徽章：点阵小签 ===== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  font: 700 11px / 1.4 var(--f-dot); letter-spacing: 0.06em;
  background: rgb(236 231 218 / 0.05); color: var(--text-dim);
  box-shadow: inset 0 0 0 1px var(--line);
}
.badge::before { content: ''; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
.badge.created, .badge.on { color: var(--green); box-shadow: inset 0 0 0 1px rgb(127 216 164 / 0.4); background: rgb(127 216 164 / 0.08); }
.badge.linked_existing { color: var(--hot-2); box-shadow: inset 0 0 0 1px rgb(127 216 255 / 0.4); background: rgb(127 216 255 / 0.08); }
.badge.pending { color: var(--amber); box-shadow: inset 0 0 0 1px rgb(255 184 77 / 0.4); background: rgb(255 184 77 / 0.08); }
.badge.failed, .badge.off { color: var(--hot); box-shadow: inset 0 0 0 1px rgb(255 90 31 / 0.4); background: rgb(255 90 31 / 0.08); }
.badge.none { color: var(--text-faint); }
.badge.admin { color: var(--hot); box-shadow: inset 0 0 0 1px rgb(255 90 31 / 0.4); background: rgb(255 90 31 / 0.08); }

/* ===== 用户表 ===== */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  padding: 10px 10px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--line-strong);
  font: 700 12px / 1.4 var(--f-dot); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-dim);
}
th.sortable { cursor: pointer; transition: color 0.16s; }
th.sortable:hover { color: var(--hot); }
tbody td { padding: 10px; border-bottom: 1px solid var(--line); color: var(--text); vertical-align: middle; }
tbody tr { transition: background 0.16s; }
tbody tr:hover { background: rgb(236 231 218 / 0.03); }
tbody td .hint { font-size: 12px; }

/* 部门表：固定列宽 —— 各部门卡片表头/列完全对齐（auto 布局会按各自内容错位） */
#usersWrap { overflow-x: auto; }
#usersWrap table { table-layout: fixed; min-width: 900px; }
#usersWrap thead th:nth-child(1) { width: 3.5%; }   /* # */
#usersWrap thead th:nth-child(2) { width: 28%; }    /* 邮箱 */
#usersWrap thead th:nth-child(3) { width: 11.5%; }  /* 姓名 */
#usersWrap thead th:nth-child(4) { width: 8.5%; }   /* 状态 */
#usersWrap thead th:nth-child(5) { width: 13%; }    /* 最近登录 */
#usersWrap thead th:nth-child(6) { width: 8.5%; }   /* 身份 */
#usersWrap thead th:nth-child(7) { width: 6.5%; }   /* CMS */
#usersWrap thead th:nth-child(8) { width: 6.5%; }   /* CR */
#usersWrap thead th:nth-child(9) { width: 6.5%; }   /* BD */
#usersWrap thead th:nth-child(10) { width: 7.5%; }  /* 操作 */
#usersWrap td:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#usersWrap td:nth-child(5) { white-space: nowrap; }

/* ===== 表单 ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 22px; }
.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--text-dim); margin-bottom: 6px; white-space: nowrap; }
.field input[type=text], .field input[type=password], .field input[type=email] {
  width: 100%; padding: 10px 2px 12px;
  border: 0; outline: none; border-radius: 0;
  background: radial-gradient(circle, var(--line-strong) 1px, transparent 1.6px) 0 100% / var(--pitch) 4px repeat-x;
  font: 400 15px / 1.3 var(--f-ui); color: var(--text);
  transition: background-color 0.16s;
}
.field input::placeholder { color: var(--text-faint); opacity: 1; }
.field input:focus {
  background-image: radial-gradient(circle, var(--hot) 1.2px, transparent 1.8px);
}
.field input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--bg-2) inset;
  -webkit-text-fill-color: var(--text);
  transition: background-color 999999s;
}
.field select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 6px; outline: none;
  background: var(--bg-2); color: var(--text);
  font: 400 14px / 1.3 var(--f-ui);
  transition: border-color 0.16s;
}
.field select:focus { border-color: var(--hot); }
.field select option { background: var(--bg-2); color: var(--text); }
.checkbox-row { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text); cursor: pointer; white-space: nowrap; }
.checkbox-row input { width: 15px; height: 15px; accent-color: var(--hot); flex: none; }

/* 平台开通盒 */
.platform-box {
  border: 1px solid var(--line); border-radius: 12px; padding: 16px 16px 14px;
  background: rgb(236 231 218 / 0.02);
  transition: border-color 0.2s, background 0.2s;
}
.platform-box .pb-head { display: flex; align-items: center; margin-bottom: 10px; gap: 8px; white-space: nowrap; }
.platform-box .pb-head .t { font-weight: 600; font-size: 14.5px; color: var(--text); }
.platform-box .inner { margin-top: 6px; }
.platform-box.enabled { border-color: rgb(127 216 255 / 0.45); background: rgb(127 216 255 / 0.05); }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.perm-grid .checkbox-row { font-size: 13px; color: var(--text-dim); }

.section-title {
  margin: 22px 0 12px; display: flex; align-items: center; gap: 12px;
  font: 700 12px / 1 var(--f-dot); letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-dim);
}

.hint { font-size: 12.5px; color: var(--text-faint); line-height: 1.7; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.msg { font-size: 13px; margin: 10px 0 0; color: var(--text-dim); min-height: 1.4em; }
.msg.err { color: var(--hot); }
.msg.ok { color: var(--green); }

/* ===== 按钮：ghost / primary / danger（同首页 lx-btn 语言） ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 18px; border: 0; border-radius: 999px;
  background: transparent; color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  font: 600 13.5px / 1 var(--f-ui); cursor: pointer; user-select: none;
  transition: box-shadow 0.16s, background 0.16s, color 0.16s, transform 0.16s var(--ease);
}
.btn:hover { box-shadow: inset 0 0 0 1px var(--text); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--text); color: var(--bg); box-shadow: none; }
.btn.primary:hover { background: #fff; }
.btn.danger { color: var(--hot); box-shadow: inset 0 0 0 1px rgb(255 90 31 / 0.45); }
.btn.danger:hover { background: var(--hot); color: var(--bg); box-shadow: none; }
.btn.sm { min-height: 30px; padding: 0 12px; font-size: 12px; }
.btn:disabled, .btn[aria-disabled=true] { color: var(--text-faint); box-shadow: inset 0 0 0 1px var(--line); cursor: not-allowed; transform: none; }

/* ===== 部门分组树 ===== */
.dept-group {
  margin-bottom: 12px; border-radius: 12px; overflow: hidden;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: fadeUp 0.5s var(--ease) both;
}
.dept-group-head {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer;
  background: rgb(236 231 218 / 0.03); transition: background 0.16s;
  font-weight: 600; font-size: 14px;
}
.dept-group-head:hover { background: rgb(236 231 218 / 0.06); }
.dept-arrow { transition: transform 0.2s var(--ease); color: var(--text-faint); font-size: 11px; }
.dept-group.collapsed .dept-arrow { transform: rotate(-90deg); }
.dept-group-body { padding: 6px 0 10px; }
.dept-group.collapsed .dept-group-body { display: none; }
.dept-name { flex: 1; }
.dept-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px 9px 34px;
  border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.dept-row:last-child { border-bottom: 0; }

/* ===== 弹窗（同首页 modal） ===== */
.modal-mask {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgb(3 4 5 / 0.72);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fadeDown 0.2s var(--ease);
}
.modal {
  width: min(560px, calc(100vw - 32px)); max-height: 86vh; overflow: auto;
  padding: 24px; border-radius: 12px;
  background: var(--bg-2);
  box-shadow: inset 0 0 0 1px var(--line-strong), 0 30px 80px -30px rgb(0 0 0 / 0.9);
  animation: fadeUp 0.42s var(--ease);
}
.modal-wide { width: min(920px, calc(100vw - 32px)); }
.audit-scroll { max-height: 62vh; overflow: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-head h3 { font: 600 21px / 1.3 var(--f-ui); }
.modal-close {
  width: 32px; height: 32px; border: 0; border-radius: 999px;
  background: transparent; color: var(--text-dim); cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: color 0.16s, box-shadow 0.16s;
}
.modal-close:hover { color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; flex-wrap: wrap; }

/* ===== 提示条 ===== */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 75;
  display: flex; align-items: center; gap: 12px; max-width: min(380px, calc(100vw - 40px));
  padding: 12px 16px; border-radius: 12px;
  background: var(--bg-2); color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-strong), 0 20px 40px -20px rgb(0 0 0 / 0.8);
  font-size: 14px; animation: fadeUp 0.5s var(--ease);
}
.toast.err { box-shadow: inset 0 0 0 1px rgb(255 90 31 / 0.5); }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgb(236 231 218 / 0.16); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: rgb(236 231 218 / 0.28); }
::-webkit-scrollbar-track { background: transparent; }

/* ===== 移动端 ===== */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; }
  .topbar .brand .t2 { display: none; }
  .card { padding: 18px 16px 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .perm-grid { grid-template-columns: 1fr; }
  .toolbar-input { width: 100%; }
  .card h2 .actions { width: 100%; }
  table { font-size: 12.5px; }
  thead th, tbody td { padding: 8px 6px; }
}
