/* ---------------------------------------------------------------------------
 * 后台「人员与权限」样式
 * 复用 style.css 里的设计变量与顶栏，只补后台特有的布局与表格
 * ------------------------------------------------------------------------- */

.admin-body { overflow: hidden; }
.admin-body.modal-open { overflow: hidden; }

.admin-main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 14px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ------------------------------ 顶部数字卡 ------------------------------ */

.hero-cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  flex: 0 0 auto;
}

.hero-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
  min-width: 0;
}
.hero-card b {
  display: block;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.hero-card span { font-size: 12px; color: var(--ink-3); }
.hero-card em {
  display: block;
  font-style: normal;
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hero-card.warn b { color: var(--reject); }
.hero-card.warn em { color: #c98a86; }

/* -------------------------------- 卡片 -------------------------------- */

.admin-card {
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-2);
  flex: 0 0 auto;
  flex-wrap: wrap;
}
.tb-title { margin: 0; font-size: 14px; font-weight: 700; }
.tb-grow { flex: 1 1 auto; }
.tb-search { display: flex; align-items: center; gap: 6px; }
.tb-search span { font-size: 12px; color: var(--ink-3); }
.tb-search input {
  height: 30px;
  width: 190px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  outline: none;
}
.tb-search input:focus { border-color: #b9cdf7; box-shadow: 0 0 0 3px rgba(47, 107, 237, 0.1); }

.seg { display: flex; gap: 2px; padding: 3px; background: #f2f4f7; border-radius: 9px; }
.seg-btn {
  border: 0;
  background: transparent;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08); }

/* -------------------------------- 表格 -------------------------------- */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fafbfc;
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-3);
  white-space: nowrap;
}
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
.admin-table tbody tr:hover { background: #fbfcfe; }
.admin-table tbody tr.is-off { background: #fcfcfd; }
.admin-table tbody tr.is-off td { opacity: 0.72; }
.admin-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-table .num.strong { font-weight: 700; }
.admin-table .col-time { white-space: nowrap; color: var(--ink-2); font-size: 12px; }
.admin-table .detail { color: var(--ink-2); font-size: 12px; }
.admin-table .col-scope { min-width: 220px; }
.admin-table .col-act { width: 1%; white-space: nowrap; }
.empty-row { text-align: center; color: var(--ink-3); padding: 34px 0 !important; font-size: 12.5px; }
.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace; font-size: 12px; }

.who-cell { display: flex; align-items: center; gap: 9px; min-width: 0; }
.who-cell b { display: block; font-weight: 600; white-space: nowrap; }
.who-cell em { display: block; font-style: normal; font-size: 11.5px; color: var(--ink-3); }

.avatar {
  width: 28px; height: 28px;
  flex: 0 0 auto;
  border-radius: 9px;
  background: #eef2f8;
  color: var(--ink-2);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}
.avatar.admin { background: var(--accent-weak); color: var(--accent); }

.self-tag {
  display: inline-block;
  margin-left: 5px;
  padding: 0 5px;
  border-radius: 5px;
  background: var(--accent-weak);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 600;
  vertical-align: 1px;
}

/* 徽标 / 标签 */

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 1.5;
  white-space: nowrap;
  background: #f2f4f7;
  color: var(--ink-2);
}
.pill.role-admin { background: var(--accent-weak); color: var(--accent); }
.pill.role-auditor { background: #f1f3f7; color: var(--ink-2); }
.pill.granted { background: var(--pass-weak); color: var(--pass); }
.pill.warn { background: var(--reject-weak); color: var(--reject); }
.pill.act-create { background: var(--pass-weak); color: var(--pass); }
.pill.act-update { background: var(--accent-weak); color: var(--accent); }
.pill.act-password { background: #fff6e6; color: #b4670f; }
.pill.act-delete { background: var(--reject-weak); color: var(--reject); }

.chips-wrap { display: flex; flex-wrap: wrap; gap: 4px; max-width: 380px; }
.chip {
  padding: 1px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11.5px;
  color: var(--ink-2);
  background: #fbfcfd;
  white-space: nowrap;
}
.chip.more { color: var(--ink-3); border-style: dashed; }

.perm-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag-perm {
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 11.5px;
  border: 1px solid transparent;
}
.tag-perm.on { background: #eef3fe; color: #2f6bed; }
.tag-perm.off { background: #f4f5f7; color: #b3b9c2; text-decoration: line-through; }

.state { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; white-space: nowrap; }
.state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); }
.state.on { color: var(--pass); }
.state.on::before { background: var(--pass); }
.state.off { color: var(--reject); }
.state.off::before { background: var(--reject); }

.row-acts { display: flex; gap: 4px; }
.mini {
  height: 25px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  font-size: 11.5px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}
.mini:hover { border-color: #cfd6df; color: var(--ink); background: #fafbfc; }
.mini.warn { color: #b4670f; border-color: #f0e0c6; background: #fffbf4; }
.mini.danger { color: var(--reject); border-color: #f2d6d4; background: #fffafa; }
.mini.danger:hover { background: var(--reject-weak); }
.del-confirm { font-size: 11.5px; color: var(--reject); font-weight: 600; margin-right: 2px; }

.table-note {
  margin: 0;
  padding: 9px 14px;
  border-top: 1px solid var(--line-2);
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.7;
  flex: 0 0 auto;
}
.warn-text { color: var(--reject); font-weight: 600; }

/* ------------------------------ 门店分配 ------------------------------ */

.assign-layout {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
}

.assign-side {
  display: flex;
  flex-direction: column;
  padding: 0;
  min-height: 0;
  overflow: hidden;
}
.assign-side-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-2);
}
.assign-side-head h2 { margin: 0; font-size: 13px; font-weight: 700; }
.assign-side-head em { font-style: normal; font-size: 11.5px; color: var(--ink-3); }
.assign-list { flex: 1 1 auto; overflow: auto; padding: 6px; }
.assign-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.assign-item:hover { background: #f7f9fc; }
.assign-item.is-on { background: var(--accent-weak); border-color: #cfdffb; }
.assign-item-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.assign-item-text b { font-size: 12.5px; font-weight: 600; }
.assign-item-text em { font-style: normal; font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.assign-item-text .num { color: var(--accent); font-weight: 700; }

.assign-main {
  display: flex;
  flex-direction: column;
  padding: 0;
  min-height: 0;
  overflow: hidden;
}
.assign-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-2);
  flex-wrap: wrap;
}
.assign-who b { font-size: 13.5px; }
.assign-who em {
  display: block;
  font-style: normal;
  font-size: 11.5px;
  color: var(--ink-3);
}

.store-pick-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line-2);
  flex-wrap: wrap;
}
.store-pick-bar input {
  height: 30px;
  flex: 1 1 200px;
  min-width: 140px;
  max-width: 320px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  outline: none;
}
.store-pick-bar input:focus { border-color: #b9cdf7; box-shadow: 0 0 0 3px rgba(47, 107, 237, 0.1); }
.pick-count { margin-left: auto; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.store-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 6px;
  align-content: start;
  padding: 12px 14px;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 120px;
}
.store-list.tall { min-height: 200px; }
.store-list.is-locked { display: block; }

.store-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcfd;
  cursor: pointer;
  min-width: 0;
  position: relative;
  transition: 0.12s;
}
.store-item:hover { border-color: #cfd6df; background: #fff; }
.store-item.on { border-color: #a9c4f5; background: #eff5ff; box-shadow: inset 0 0 0 1px rgba(47, 107, 237, 0.05); }
.store-item input { position: absolute; opacity: 0; width: 0; height: 0; }
.store-box {
  width: 15px; height: 15px;
  flex: 0 0 auto;
  border: 1.5px solid #c6ccd6;
  border-radius: 4px;
  background: #fff;
  position: relative;
}
.store-item.on .store-box { background: var(--accent); border-color: var(--accent); }
.store-item.on .store-box::after {
  content: "";
  position: absolute;
  left: 4px; top: 1px;
  width: 4px; height: 8px;
  border: solid #fff;
  border-width: 0 1.8px 1.8px 0;
  transform: rotate(42deg);
}
.store-name {
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}
.store-meta { font-size: 10.5px; color: var(--ink-3); white-space: nowrap; }
.store-owner {
  font-size: 10px;
  color: #b4670f;
  background: #fff6e6;
  border-radius: 5px;
  padding: 0 5px;
  white-space: nowrap;
  max-width: 76px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.store-owner.ghosted { color: var(--ink-3); background: #f2f4f7; }
.store-empty { color: var(--ink-3); font-size: 12.5px; padding: 26px 4px; text-align: center; }
.store-empty.strong {
  background: #f7f9fc;
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 30px 20px;
  color: var(--ink-2);
}

.hint { margin: 0; padding: 9px 14px; font-size: 11.5px; color: var(--ink-3); line-height: 1.7; border-top: 1px solid var(--line-2); }
.hint.warn { color: #b4670f; background: #fffdf8; }

/* ------------------------------- 弹窗 ------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(16, 24, 40, 0.44);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-card {
  width: min(660px, 100%);
  max-height: calc(100vh - 40px);
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(16, 24, 40, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-in 0.16s ease-out;
}
.modal-card.wide { width: min(900px, 100%); }
.modal-card.narrow { width: min(470px, 100%); }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(6px) scale(0.995); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-2);
  flex: 0 0 auto;
}
.modal-head h3 { margin: 0; font-size: 14.5px; font-weight: 700; }
.modal-sub { font-size: 12px; color: var(--ink-3); }
.modal-x {
  margin-left: auto;
  width: 27px; height: 27px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-3);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}
.modal-x:hover { background: #f2f4f7; color: var(--ink); }

.modal-body {
  padding: 14px 16px 6px;
  overflow: auto;
  flex: 1 1 auto;
}

.modal-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-top: 1px solid var(--line-2);
  background: #fbfcfd;
  flex: 0 0 auto;
}
.modal-foot .ghost, .modal-foot .primary { height: 32px; padding: 0 16px; border-radius: 8px; }
.modal-hint { margin-right: auto; font-size: 11.5px; color: var(--ink-3); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.fld { display: block; margin-bottom: 13px; }
.fld > span { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 5px; font-weight: 600; }
.fld input,
.fld select {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  outline: none;
}
.fld input:focus, .fld select:focus { border-color: #b9cdf7; box-shadow: 0 0 0 3px rgba(47, 107, 237, 0.1); }
.fld input:disabled { background: #f6f7f9; color: var(--ink-3); }
.fld > em { display: block; font-style: normal; font-size: 11px; color: var(--ink-3); margin-top: 4px; line-height: 1.6; }
.fld-hint { display: block; font-style: normal; font-size: 11px; color: var(--ink-3); margin-top: 5px; line-height: 1.6; }

.scope-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.scope-row .chk { white-space: nowrap; flex: 0 0 auto; }
.scope-sum { font-size: 12px; color: var(--ink-2); }
.scope-sum.strong { color: var(--pass); font-weight: 600; }
.scope-sum.warn { color: var(--reject); }

.perm-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.perm {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfd;
  cursor: pointer;
  position: relative;
}
.perm input { position: absolute; opacity: 0; width: 0; height: 0; }
.perm b { font-size: 12.5px; font-weight: 600; }
.perm em { font-style: normal; font-size: 10.5px; color: var(--ink-3); line-height: 1.5; }
.perm.on { border-color: #b9cdf7; background: #f3f7ff; }
.perm.on b { color: var(--accent); }
.perm.locked { opacity: 0.85; cursor: default; }
.perm-note { grid-column: 1 / -1; margin: 0; font-size: 11px; color: var(--ink-3); }

.form-err {
  margin: 2px 0 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--reject-weak);
  color: var(--reject);
  font-size: 12px;
  line-height: 1.6;
}

.pwd-who { margin: 0 0 12px; font-size: 12.5px; color: var(--ink-2); }
.pwd-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.pwd-note { margin: 0 0 12px; font-size: 11.5px; color: var(--ink-3); line-height: 1.7; }
.pwd-result {
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--pass-weak);
  border: 1px solid #cdebdc;
}
.pwd-result > span { display: block; font-size: 11px; color: #0b6c4b; margin-bottom: 6px; }
.pwd-copy { display: flex; align-items: center; gap: 8px; }
.pwd-copy code {
  flex: 1 1 auto;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 15px;
  letter-spacing: 1.5px;
  color: #0b6c4b;
  background: #fff;
  border-radius: 7px;
  padding: 6px 10px;
  border: 1px dashed #b6e0cd;
}

.admin-entry { text-decoration: none; display: inline-flex; align-items: center; }
.ghost.is-on { border-color: #b9cdf7; color: var(--accent); background: var(--accent-weak); }

/* 日志页两张表按内容高度排列，不要拉满整屏 */
#viewLog { gap: 12px; }
#viewLog .admin-card { flex: 0 0 auto; }
#viewLog .table-wrap { max-height: 46vh; }

/* 无权限提示页 */
#forbidden .gate-card { max-width: 400px; }
#forbidden .gate-btn { display: block; width: 100%; text-align: center; line-height: 40px; }
.toast.bad { background: var(--reject); }

/* ------------------------------- 自适应 ------------------------------- */

@media (max-width: 1180px) {
  .hero-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .admin-table .col-perm { display: none; }
}

@media (max-width: 900px) {
  .assign-layout { grid-template-columns: 1fr; }
  .assign-side { max-height: 190px; }
  .grid2 { grid-template-columns: 1fr; }
  .perm-row { grid-template-columns: 1fr; }
  .admin-table .col-scope { min-width: 150px; }
  .admin-table .col-time { display: none; }
}

/* ---------------------- 门店分工来自 SQL 划分表（只读） ---------------------- */

.assign-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border: 1px solid #cfe0ff;
  border-radius: 12px;
  background: linear-gradient(180deg, #f6faff, #eef5ff);
  margin-bottom: 12px;
}
.assign-banner-main { flex: 1 1 auto; font-size: 13px; color: #2c3d5b; line-height: 1.6; }
.assign-banner-main b { color: #1f3864; }
.assign-banner-main #assignBannerText b { font-weight: 600; }
.assign-banner-tag {
  flex: 0 0 auto;
  font-size: 12px;
  color: var(--accent);
  background: rgba(47, 107, 237, 0.08);
  border: 1px solid #cfe0ff;
  border-radius: 999px;
  padding: 4px 10px;
  white-space: nowrap;
}

/* 人员弹窗里的「划分表员工」下拉 */
.assign-select {
  min-width: 260px;
  max-width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
  color: var(--text);
}
.assign-select:disabled { background: var(--bg-soft); color: var(--muted); }

/* 人员表里「门店范围」下面的小字（员工编号） */
.scope-sub {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* 「划分表」来源标签 */
.chip.src {
  background: rgba(47, 107, 237, 0.08);
  border-color: #cfe0ff;
  color: var(--accent);
  font-weight: 600;
}

/* 只读门店格：不显示可点击的手感 */
.store-item.is-ro { cursor: default; }
.store-item.is-ro:not(.on) { opacity: 0.72; }
.store-item.is-ro input { cursor: default; }

/* 禁用态的主按钮要看得出来不能点（划分表只读时用） */
.primary:disabled, .primary[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}
